From 4ef1f114ff4ca56c1f317aa59b4c61e6a4f0468a Mon Sep 17 00:00:00 2001 From: Exitare Date: Sun, 5 Jan 2025 12:10:40 -0800 Subject: [PATCH 1/8] Create rev_1736100900062273000.sql --- .../rev_1736100900062273000.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1736100900062273000.sql diff --git a/data/sql/updates/pending_db_world/rev_1736100900062273000.sql b/data/sql/updates/pending_db_world/rev_1736100900062273000.sql new file mode 100644 index 0000000000..f2662d760f --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1736100900062273000.sql @@ -0,0 +1,22 @@ +-- +UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` IN (5357, 5358, 5359, 5360, 5361); +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 5359) AND (`source_type` = 0) AND (`id` = 1); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(5359, 0, 1, 0, 8, 0, 100, 0, 23359, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Shore Strider - On Spellhit \'Transmogrify!\' - Starts an attack'); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 5360) AND (`source_type` = 0) AND (`id` = 1); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(5360, 0, 1, 0, 8, 0, 100, 0, 23359, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Deep Strider - On Spellhit \'Transmogrify!\' - Starts an attack'); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 5357) AND (`source_type` = 0) AND (`id` = 1); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(5357, 0, 1, 0, 8, 0, 100, 0, 23359, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Land Walker - On Spellhit \'Transmogrify!\' - Starts an attack'); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 5361) AND (`source_type` = 0) AND (`id` = 1); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(5361, 0, 1, 0, 8, 0, 100, 0, 23359, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Wave Strider - On Spellhit \'Transmogrify!\' - Starts an attack'); + +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 5358) AND (`source_type` = 0) AND (`id` = 1); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(5358, 0, 1, 0, 8, 0, 100, 0, 23359, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Cliff Giant - On Spellhit \'Transmogrify!\' - Starts an attack'); + From 1cdae1b0d62b4b43d8fb18ad32895f7dd1e47766 Mon Sep 17 00:00:00 2001 From: Exitare Date: Sun, 5 Jan 2025 12:14:59 -0800 Subject: [PATCH 2/8] Update rev_1736100900062273000.sql --- data/sql/updates/pending_db_world/rev_1736100900062273000.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/data/sql/updates/pending_db_world/rev_1736100900062273000.sql b/data/sql/updates/pending_db_world/rev_1736100900062273000.sql index f2662d760f..63e8539bf6 100644 --- a/data/sql/updates/pending_db_world/rev_1736100900062273000.sql +++ b/data/sql/updates/pending_db_world/rev_1736100900062273000.sql @@ -18,5 +18,4 @@ INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_ DELETE FROM `smart_scripts` WHERE (`entryorguid` = 5358) AND (`source_type` = 0) AND (`id` = 1); INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(5358, 0, 1, 0, 8, 0, 100, 0, 23359, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Cliff Giant - On Spellhit \'Transmogrify!\' - Starts an attack'); - +(5358, 0, 1, 0, 8, 0, 100, 0, 23359, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Cliff Giant - On Spellhit \'Transmogrify!\' - Starts an attack'); \ No newline at end of file From ff3e0a3c3598535d85372008aea1b0af4761395c Mon Sep 17 00:00:00 2001 From: Exitare Date: Sun, 5 Jan 2025 12:16:20 -0800 Subject: [PATCH 3/8] Update rev_1736100900062273000.sql --- data/sql/updates/pending_db_world/rev_1736100900062273000.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/sql/updates/pending_db_world/rev_1736100900062273000.sql b/data/sql/updates/pending_db_world/rev_1736100900062273000.sql index 63e8539bf6..293f2952fc 100644 --- a/data/sql/updates/pending_db_world/rev_1736100900062273000.sql +++ b/data/sql/updates/pending_db_world/rev_1736100900062273000.sql @@ -18,4 +18,4 @@ INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_ DELETE FROM `smart_scripts` WHERE (`entryorguid` = 5358) AND (`source_type` = 0) AND (`id` = 1); INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(5358, 0, 1, 0, 8, 0, 100, 0, 23359, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Cliff Giant - On Spellhit \'Transmogrify!\' - Starts an attack'); \ No newline at end of file +(5358, 0, 1, 0, 8, 0, 100, 0, 23359, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Cliff Giant - On Spellhit \'Transmogrify!\' - Starts an attack'); From a1a5c12557ef2d54c512d940ed55765aa900d8a5 Mon Sep 17 00:00:00 2001 From: Exitare Date: Sun, 12 Jan 2025 10:07:50 -0800 Subject: [PATCH 4/8] Add missing spell script for transmogrify! spell --- .../rev_1736100900062273000.sql | 3 ++ src/server/scripts/Kalimdor/zone_feralas.cpp | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/data/sql/updates/pending_db_world/rev_1736100900062273000.sql b/data/sql/updates/pending_db_world/rev_1736100900062273000.sql index 293f2952fc..fadf85da24 100644 --- a/data/sql/updates/pending_db_world/rev_1736100900062273000.sql +++ b/data/sql/updates/pending_db_world/rev_1736100900062273000.sql @@ -19,3 +19,6 @@ INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_ DELETE FROM `smart_scripts` WHERE (`entryorguid` = 5358) AND (`source_type` = 0) AND (`id` = 1); INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES (5358, 0, 1, 0, 8, 0, 100, 0, 23359, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Cliff Giant - On Spellhit \'Transmogrify!\' - Starts an attack'); +-- Add spell script for Transmogrify! +DELETE FROM `spell_script_names` WHERE `spell_id`=23359 AND `ScriptName`='spell_transmogrify'; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES(23359, 'spell_transmogrify'); diff --git a/src/server/scripts/Kalimdor/zone_feralas.cpp b/src/server/scripts/Kalimdor/zone_feralas.cpp index 794f49cab3..197924c75d 100644 --- a/src/server/scripts/Kalimdor/zone_feralas.cpp +++ b/src/server/scripts/Kalimdor/zone_feralas.cpp @@ -52,7 +52,35 @@ class spell_gordunni_trap : public SpellScript } }; +class spell_transmogrify : public SpellScript +{ + PrepareSpellScript(spell_transmogrify); + + SpellCastResult CheckTarget() + { + Unit* caster = GetCaster(); + Unit* target = GetExplTargetUnit(); // Explicit target selected by the caster + + // List of valid creature IDs + std::set validCreatureIds = { 5357, 5358, 5359, 5360, 5361 }; + + // Validate the target + if (!target || validCreatureIds.find(target->GetEntry()) == validCreatureIds.end()) + return SPELL_FAILED_BAD_TARGETS; // Prevent the spell cast with an error + + return SPELL_CAST_OK; // Allow the spell cast + } + + + void Register() override + { + // Register the check cast hook + OnCheckCast += SpellCheckCastFn(spell_transmogrify::CheckTarget); + } +}; + void AddSC_feralas() { RegisterSpellScript(spell_gordunni_trap); + RegisterSpellScript(spell_transmogrify); } From 20b1997b21f793d0de807a53337262f7f5a1f32f Mon Sep 17 00:00:00 2001 From: Exitare Date: Sun, 12 Jan 2025 10:10:46 -0800 Subject: [PATCH 5/8] Update magic numbers --- src/server/scripts/Kalimdor/zone_feralas.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/server/scripts/Kalimdor/zone_feralas.cpp b/src/server/scripts/Kalimdor/zone_feralas.cpp index 197924c75d..20913d9e39 100644 --- a/src/server/scripts/Kalimdor/zone_feralas.cpp +++ b/src/server/scripts/Kalimdor/zone_feralas.cpp @@ -52,6 +52,15 @@ class spell_gordunni_trap : public SpellScript } }; +enum ZAPPED_GIANTS +{ + NPC_SHORE_STRIDER = 5359, + NPC_DEEP_STRIDER = 5360, + NPC_LAND_WALKER = 5357, + NPC_WAVE_STRIDER = 5361, + NPC_CLIFF_GIANT = 5358 +}; + class spell_transmogrify : public SpellScript { PrepareSpellScript(spell_transmogrify); @@ -62,7 +71,7 @@ class spell_transmogrify : public SpellScript Unit* target = GetExplTargetUnit(); // Explicit target selected by the caster // List of valid creature IDs - std::set validCreatureIds = { 5357, 5358, 5359, 5360, 5361 }; + std::set validCreatureIds = { NPC_SHORE_STRIDER, NPC_DEEP_STRIDER, NPC_LAND_WALKER, NPC_WAVE_STRIDER, NPC_CLIFF_GIANT }; // Validate the target if (!target || validCreatureIds.find(target->GetEntry()) == validCreatureIds.end()) From 1fc657c2fcb8a7d4424cdfccf59ce4a3a30b3995 Mon Sep 17 00:00:00 2001 From: Exitare Date: Sun, 12 Jan 2025 10:12:05 -0800 Subject: [PATCH 6/8] Fix CI --- src/server/scripts/Kalimdor/zone_feralas.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/server/scripts/Kalimdor/zone_feralas.cpp b/src/server/scripts/Kalimdor/zone_feralas.cpp index 20913d9e39..e65a6c9d36 100644 --- a/src/server/scripts/Kalimdor/zone_feralas.cpp +++ b/src/server/scripts/Kalimdor/zone_feralas.cpp @@ -76,11 +76,10 @@ class spell_transmogrify : public SpellScript // Validate the target if (!target || validCreatureIds.find(target->GetEntry()) == validCreatureIds.end()) return SPELL_FAILED_BAD_TARGETS; // Prevent the spell cast with an error - + return SPELL_CAST_OK; // Allow the spell cast } - void Register() override { // Register the check cast hook From dbb51b94d3b72d94ffba792a05902502eaeaa53f Mon Sep 17 00:00:00 2001 From: Exitare Date: Sun, 12 Jan 2025 10:18:25 -0800 Subject: [PATCH 7/8] Remove unused variable --- src/server/scripts/Kalimdor/zone_feralas.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/server/scripts/Kalimdor/zone_feralas.cpp b/src/server/scripts/Kalimdor/zone_feralas.cpp index e65a6c9d36..a16c6efe01 100644 --- a/src/server/scripts/Kalimdor/zone_feralas.cpp +++ b/src/server/scripts/Kalimdor/zone_feralas.cpp @@ -67,7 +67,6 @@ class spell_transmogrify : public SpellScript SpellCastResult CheckTarget() { - Unit* caster = GetCaster(); Unit* target = GetExplTargetUnit(); // Explicit target selected by the caster // List of valid creature IDs From 4feddc0e9f8e2853530276945d3f9ba4c02f0f52 Mon Sep 17 00:00:00 2001 From: Exitare Date: Wed, 15 Jan 2025 10:43:36 -0800 Subject: [PATCH 8/8] Address code review --- src/server/scripts/Kalimdor/zone_feralas.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/server/scripts/Kalimdor/zone_feralas.cpp b/src/server/scripts/Kalimdor/zone_feralas.cpp index a16c6efe01..3392c0e66a 100644 --- a/src/server/scripts/Kalimdor/zone_feralas.cpp +++ b/src/server/scripts/Kalimdor/zone_feralas.cpp @@ -67,21 +67,19 @@ class spell_transmogrify : public SpellScript SpellCastResult CheckTarget() { - Unit* target = GetExplTargetUnit(); // Explicit target selected by the caster + Unit* target = GetExplTargetUnit(); - // List of valid creature IDs - std::set validCreatureIds = { NPC_SHORE_STRIDER, NPC_DEEP_STRIDER, NPC_LAND_WALKER, NPC_WAVE_STRIDER, NPC_CLIFF_GIANT }; + std::unordered_set validCreatureIds = { NPC_SHORE_STRIDER, NPC_DEEP_STRIDER, NPC_LAND_WALKER, NPC_WAVE_STRIDER, NPC_CLIFF_GIANT }; // Validate the target - if (!target || validCreatureIds.find(target->GetEntry()) == validCreatureIds.end()) - return SPELL_FAILED_BAD_TARGETS; // Prevent the spell cast with an error + if (!target || !validCreatureIds.contains(target->GetEntry())) + return SPELL_FAILED_BAD_TARGETS; - return SPELL_CAST_OK; // Allow the spell cast + return SPELL_CAST_OK; } void Register() override { - // Register the check cast hook OnCheckCast += SpellCheckCastFn(spell_transmogrify::CheckTarget); } };