From 4cb544182d0cbe9dc6f756092a72c9d942f4dd90 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sat, 15 Nov 2025 21:02:50 +0100 Subject: [PATCH] Setup/Spawns * evaluate waypoint paths linked via creature_template_addon --- setup/sql/updates/1763240934_01.sql | 1 + setup/tools/sqlgen/spawns.ss.php | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 setup/sql/updates/1763240934_01.sql diff --git a/setup/sql/updates/1763240934_01.sql b/setup/sql/updates/1763240934_01.sql new file mode 100644 index 00000000..c0c38b25 --- /dev/null +++ b/setup/sql/updates/1763240934_01.sql @@ -0,0 +1 @@ +UPDATE `aowow_dbversion` SET `sql` = CONCAT(IFNULL(`sql`, ''), ' spawns'); diff --git a/setup/tools/sqlgen/spawns.ss.php b/setup/tools/sqlgen/spawns.ss.php index f139a424..522fead5 100644 --- a/setup/tools/sqlgen/spawns.ss.php +++ b/setup/tools/sqlgen/spawns.ss.php @@ -24,7 +24,7 @@ CLISetup::registerSetup("sql", new class extends SetupScript ); protected $dbcSourceFiles = ['worldmaparea', 'map', 'taxipathnode', 'soundemitters', 'areatrigger', 'areatable']; - protected $worldDependency = ['creature', 'creature_addon', 'gameobject', 'gameobject_template', 'vehicle_accessory', 'vehicle_accessory_template', 'script_waypoint', 'waypoints', 'waypoint_data', 'smart_scripts', 'areatrigger_teleport']; + protected $worldDependency = ['creature', 'creature_addon', 'creature_template_addon', 'gameobject', 'gameobject_template', 'vehicle_accessory', 'vehicle_accessory_template', 'script_waypoint', 'waypoints', 'waypoint_data', 'smart_scripts', 'areatrigger_teleport']; protected $setupAfter = [['dungeonmap', 'worldmaparea', 'zones'], ['img-maps']]; private $transports = []; @@ -214,9 +214,11 @@ CLISetup::registerSetup("sql", new class extends SetupScript { // [guid, type, typeId, map, posX, posY [, respawn, spawnMask, phaseMask, areaId, floor, pathId]] return DB::World()->select( - 'SELECT c.`guid`, ?d AS `type`, c.`id` AS `typeId`, c.`map`, c.`position_x` AS `posX`, c.`position_y` AS `posY`, c.`spawntimesecs` AS `respawn`, c.`spawnMask`, c.`phaseMask`, c.`zoneId` AS `areaId`, IFNULL(ca.`path_id`, 0) AS `pathId` + 'SELECT c.`guid`, ?d AS `type`, c.`id` AS `typeId`, c.`map`, c.`position_x` AS `posX`, c.`position_y` AS `posY`, c.`spawntimesecs` AS `respawn`, c.`spawnMask`, c.`phaseMask`, c.`zoneId` AS `areaId`, IFNULL(ca.`path_id`, IFNULL(cta.`path_id`, 0)) AS `pathId` FROM creature c - LEFT JOIN creature_addon ca ON ca.guid = c.guid', + LEFT JOIN creature_addon ca ON ca.guid = c.guid + LEFT JOIN creature_template_addon cta ON cta.entry = c.id + GROUP BY c.id', Type::NPC ); } @@ -277,6 +279,8 @@ CLISetup::registerSetup("sql", new class extends SetupScript { // todo (med): at least `waypoints` can contain paths that do not belong to a creature but get assigned by SmartAI (or script) during runtime // in the future guid should be optional and additional parameters substituting guid should be passed down from NpcPage after SmartAI has been evaluated + + // assume that creature_template_addon data isn't stupid and only creatures with a single spawn are referenced here return DB::World()->select( 'SELECT c.`guid`, w.`entry` AS `creatureOrPath`, w.`pointId` AS `point`, c.`zoneId` AS `areaId`, c.`map`, w.`waittime` AS `wait`, w.`location_x` AS `posX`, w.`location_y` AS `posY` FROM creature c @@ -288,7 +292,12 @@ CLISetup::registerSetup("sql", new class extends SetupScript FROM creature c JOIN creature_addon ca ON ca.`guid` = c.`guid` JOIN waypoint_data w ON w.`id` = ca.`path_id` - WHERE ca.`path_id` <> 0' + WHERE ca.`path_id` <> 0 UNION + SELECT c.`guid`, -w.`id` AS `creatureOrPath`, w.`point`, c.`zoneId` AS `areaId`, c.`map`, w.`delay` AS `wait`, w.`position_x` AS `posX`, w.`position_y` AS `posY` + FROM creature c + JOIN creature_template_addon cta ON cta.`entry` = c.`id` + JOIN waypoint_data w ON w.`id` = cta.`path_id` + WHERE cta.`path_id` <> 0' ); }