implemented type areatrigger

* staff only
This commit is contained in:
Sarjuuk
2018-06-30 23:43:57 +02:00
parent 56ccc592a6
commit e0150feda6
45 changed files with 1193 additions and 160 deletions

View File

@@ -340,6 +340,31 @@ CREATE TABLE `aowow_announcements` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `aowow_areatrigger`
--
DROP TABLE IF EXISTS `aowow_areatrigger`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `aowow_areatrigger` (
`id` int(10) unsigned NOT NULL,
`cuFlags` int(10) unsigned NOT NULL,
`type` smallint(5) unsigned NOT NULL,
`name` varchar(100) NULL DEFAULT NULL,
`orientation` float NOT NULL,
`quest` mediumint(8) unsigned NULL DEFAULT NULL,
`teleportA` smallint(5) unsigned NULL DEFAULT NULL,
`teleportX` float unsigned NULL DEFAULT NULL,
`teleportY` float unsigned NULL DEFAULT NULL,
`teleportO` float NULL DEFAULT NULL,
`teleportF` tinyint(4) unsigned NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `quest` (`quest`),
INDEX `type` (`type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE='utf8mb4_general_ci' ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `aowow_articles`
--
@@ -3092,7 +3117,7 @@ UNLOCK TABLES;
LOCK TABLES `aowow_dbversion` WRITE;
/*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */;
INSERT INTO `aowow_dbversion` VALUES (1528316366,0,NULL,NULL);
INSERT INTO `aowow_dbversion` VALUES (1531668312,0,NULL,NULL);
/*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */;
UNLOCK TABLES;

View File

@@ -45,7 +45,7 @@ class DBC
'achievement_category' => 'nisxsssxsxsxxxxxxxxx',
'achievement_criteria' => 'niiiiiiiisxsssxsxsxxxxxxxxiixii',
'areatable' => 'niixixxiiixsxsssxsxsxxxxxxxxixxxxxxx',
'areatrigger' => 'niffxxxxxx',
'areatrigger' => 'niffxxxxxf',
'battlemasterlist' => 'niixxxxxxixxxxxxxxxxxxxxxxxxixii',
'charbaseinfo' => 'bb',
'charstartoutfit' => 'nbbbXiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
@@ -146,7 +146,7 @@ class DBC
'achievement_category' => 'id,parentCategory,name_loc0,name_loc2,name_loc3,name_loc4,name_loc6,name_loc8',
'achievement_criteria' => 'id,refAchievementId,type,value1,value2,value3,value4,value5,value6,name_loc0,name_loc2,name_loc3,name_loc4,name_loc6,name_loc8,completionFlags,groupFlags,timeLimit,order',
'areatable' => 'id,mapId,areaTable,flags,soundAmbience,zoneMusic,zoneIntroMusic,name_loc0,name_loc2,name_loc3,name_loc4,name_loc6,name_loc8,factionGroupMask',
'areatrigger' => 'id,mapId,posY,posX',
'areatrigger' => 'id,mapId,posY,posX,orientation',
'battlemasterlist' => 'id,mapId,moreMapId,areaType,maxPlayers,minLevel,maxLevel',
'charbaseinfo' => 'raceId,classId',
'charstartoutfit' => 'id,raceId,classId,gender,item1,item2,item3,item4,item5,item6,item7,item8,item9,item10,item11,item12,item13,item14,item15,item16,item17,item18,item19,item20',

View File

@@ -54,6 +54,7 @@ class SqlGen
'skillline' => [null, null, ['icons'], null],
'emotes' => [null, null, null, null],
'sounds' => [null, null, null, null],
'areatrigger' => [null, null, null, ['areatrigger_involvedrelation', 'areatrigger_scripts', 'areatrigger_tavern', 'areatrigger_teleport', 'quest_template', 'quest_template_addon']],
'itemenchantment' => [null, null, null, ['spell_enchant_proc_data']],
'achievement' => [null, null, ['icons'], ['dbc_achievement', 'disables']],
'creature' => [null, null, null, ['creature_template', 'creature_template_locale', 'creature_classlevelstats', 'instance_encounters']],

View File

@@ -0,0 +1,107 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
if (!CLI)
die('not in cli mode');
/* deps:
* areatrigger_tavern
* areatrigger_scripts
* areatrigger_involvedrelation
* quest_template
* quest_template_addon
* areatrigger_teleport
*/
$customData = array(
);
$reqDBC = ['areatrigger'];
function areatrigger(/*array $ids = [] */)
{
DB::Aowow()->query('TRUNCATE ?_areatrigger');
DB::Aowow()->query('INSERT INTO ?_areatrigger SELECT id, 0, 0, NULL, orientation, NULL, NULL, NULL, NULL, NULL, NULL FROM dbc_areatrigger');
/* notes:
* while areatrigger DO have dimensions, displaying them on a map is almost always futile,
* as they are either too small to be noticable or larger than the map itself (looking at you, oculus dungeon exit)
*/
// 1: Taverns
CLI::write(' - fetching taverns');
$addData = DB::World()->select('SELECT id AS ARRAY_KEY, name, ?d AS `type` FROM areatrigger_tavern', AT_TYPE_TAVERN);
foreach ($addData as $id => $ad)
DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE id = ?d', $ad, $id);
// 2: Teleporter + teleporting 4: Smart Trigger
CLI::write(' - calculation teleporter coordinates');
$addData = DB::World()->select('
SELECT ID AS ARRAY_KEY, Name AS `name`, target_map AS `map`, target_position_x AS `posY`, target_position_y AS `posX`, target_orientation AS `orientation` FROM areatrigger_teleport UNION
SELECT entryorguid AS ARRAY_KEY, "TBD" AS `name`, action_param1 AS `map`, target_x AS `posY`, target_y AS `posX`, target_o AS `orientation` FROM smart_scripts WHERE source_type = 2 AND action_type = 62
');
foreach ($addData as $id => $ad)
{
// todo (low): unify with spawns function
$queryPost = 'SELECT dm.id, wma.areaId, IFNULL(dm.floor, 0) AS floor, ' .
'100 - ROUND(IF(dm.id IS NOT NULL, (?f - dm.minY) * 100 / (dm.maxY - dm.minY), (?f - wma.right) * 100 / (wma.left - wma.right)), 1) AS `posX`, ' .
'100 - ROUND(IF(dm.id IS NOT NULL, (?f - dm.minX) * 100 / (dm.maxX - dm.minX), (?f - wma.bottom) * 100 / (wma.top - wma.bottom)), 1) AS `posY`, ' .
'((abs(IF(dm.id IS NOT NULL, (?f - dm.minY) * 100 / (dm.maxY - dm.minY), (?f - wma.right) * 100 / (wma.left - wma.right)) - 50) / 50) * ' .
' (abs(IF(dm.id IS NOT NULL, (?f - dm.minX) * 100 / (dm.maxX - dm.minX), (?f - wma.bottom) * 100 / (wma.top - wma.bottom)) - 50) / 50)) AS quality ' .
'FROM dbc_worldmaparea wma ' .
'LEFT JOIN dbc_dungeonmap dm ON dm.mapId = IF(?d AND (wma.mapId NOT IN (0, 1, 530, 571) OR wma.areaId = 4395), wma.mapId, -1) ' .
'WHERE wma.mapId = ?d AND wma.areaId <> 0 ' .
'HAVING (`posX` BETWEEN 0.1 AND 99.9 AND `posY` BETWEEN 0.1 AND 99.9) ' .
'ORDER BY quality ASC';
$points = DB::Aowow()->select($queryPost, $ad['posX'], $ad['posX'], $ad['posY'], $ad['posY'], $ad['posX'], $ad['posX'], $ad['posY'], $ad['posY'], 1, $ad['map']);
if (!$points)
$points = DB::Aowow()->select($queryPost, $ad['posX'], $ad['posX'], $ad['posY'], $ad['posY'], $ad['posX'], $ad['posX'], $ad['posY'], $ad['posY'], 0, $ad['map']);
if (!$points)
{
CLI::write(' * AT '.$id.' teleporter endpoint '.CLI::bold($ad['name']).' could not be matched to displayable area [M:'.$ad['map'].'; X:'.$ad['posY'].'; Y:'.$ad['posX'].']', CLI::LOG_WARN);
DB::Aowow()->query('UPDATE ?_areatrigger SET `name` = ?, `type` = ?d WHERE id = ?d', $ad['name'], AT_TYPE_TELEPORT, $id);
continue;
}
$update = array(
'name' => $ad['name'],
'type' => AT_TYPE_TELEPORT,
'teleportA' => $points[0]['areaId'],
'teleportX' => $points[0]['posX'],
'teleportY' => $points[0]['posY'],
'teleportO' => $ad['orientation'],
'teleportF' => $points[0]['floor']
);
DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE id = ?d', $update, $id);
}
// 3: Quest Objectives
CLI::write(' - satisfying quest objectives');
$addData = DB::World()->select('SELECT atir.id AS ARRAY_KEY, qt.ID AS quest, NULLIF(qt.AreaDescription, "") AS `name`, qta.SpecialFlags FROM quest_template qt LEFT JOIN quest_template_addon qta ON qta.ID = qt.ID JOIN areatrigger_involvedrelation atir ON atir.quest = qt.ID');
foreach ($addData as $id => $ad)
{
if (!($ad['SpecialFlags'] & QUEST_FLAG_SPECIAL_EXT_COMPLETE))
CLI::write(' * Areatrigger '.CLI::bold($id).' is involved in Quest '.CLI::bold($ad['quest']).', but Quest is not flagged for external completion (SpecialFlags & '.Util::asHex(QUEST_FLAG_SPECIAL_EXT_COMPLETE).')', CLI::LOG_WARN);
DB::Aowow()->query('UPDATE ?_areatrigger SET name = ?, type = ?d, quest = ?d WHERE id = ?d', $ad['name'], AT_TYPE_OBJECTIVE, $ad['quest'], $id);
}
// 4/5 Scripted
CLI::write(' - assigning scripts');
$addData = DB::World()->select('SELECT entry AS ARRAY_KEY, IF(ScriptName = "SmartTrigger", NULL, ScriptName) AS `name`, IF(ScriptName = "SmartTrigger", 4, 5) AS `type` FROM areatrigger_scripts');
foreach ($addData as $id => $ad)
DB::Aowow()->query('UPDATE ?_areatrigger SET ?a WHERE id = ?d', $ad, $id);
return true;
}
?>

View File

@@ -0,0 +1,20 @@
DROP TABLE IF EXISTS `dbc_areatrigger`;
DROP TABLE IF EXISTS `aowow_areatrigger`;
CREATE TABLE `aowow_areatrigger` (
`id` INT(10) UNSIGNED NOT NULL,
`cuFlags` INT(10) UNSIGNED NOT NULL,
`type` SMALLINT(5) UNSIGNED NOT NULL,
`name` VARCHAR(100) NULL DEFAULT NULL,
`orientation` FLOAT NOT NULL,
`quest` MEDIUMINT(8) UNSIGNED NULL DEFAULT NULL,
`teleportA` SMALLINT(5) UNSIGNED NULL DEFAULT NULL,
`teleportX` FLOAT UNSIGNED NULL DEFAULT NULL,
`teleportY` FLOAT UNSIGNED NULL DEFAULT NULL,
`teleportO` FLOAT NULL DEFAULT NULL,
`teleportF` TINYINT(4) UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `quest` (`quest`),
INDEX `type` (`type`)
) COLLATE='utf8mb4_general_ci' ENGINE=MyISAM;
UPDATE `aowow_dbversion` SET `sql` = CONCAT(IFNULL(`sql`, ''), ' areatrigger');