From 75d64cc8f6496f2bac699600cb58393771f0c381 Mon Sep 17 00:00:00 2001 From: MokonaNico Date: Sun, 2 Nov 2025 17:54:08 +0100 Subject: [PATCH 1/3] fix(Script): Implement correct behaviour for Prismatic Exiles summoned by Myzrael --- data/sql/base/db_world/creature_template.sql | 2 +- .../EasternKingdoms/zone_arathi_highlands.cpp | 98 +++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/data/sql/base/db_world/creature_template.sql b/data/sql/base/db_world/creature_template.sql index 7806c22808..e494f7ed57 100644 --- a/data/sql/base/db_world/creature_template.sql +++ b/data/sql/base/db_world/creature_template.sql @@ -2552,7 +2552,7 @@ INSERT INTO `creature_template` VALUES (2883,0,0,0,0,0,'[UNUSED] [PH] Monster Slayer Trainer','Monster Slayer Trainer','',0,8,12,0,55,0,1,1.14286,1,1,20,1,0,0,1,2000,2000,1,1,1,0,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,1,1,1,1,0,0,1,0,0,0,'',12340), (2885,0,0,0,0,0,'[UNUSED] [PH] Magic Skills Trainer','Magic Skills Trainer','',0,8,12,0,55,0,1,1.14286,1,1,20,1,0,0,1,2000,2000,1,1,1,0,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,1,1,1,1,0,0,1,0,0,0,'',12340), (2886,0,0,0,0,0,'Ranged Skills Trainer','Ranged Skills Trainer',NULL,0,8,12,0,55,0,1.2,1.14286,1,1,20,1,0,0,1,2000,2000,1,1,1,0,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,1,1,1,1,0,0,1,0,0,2,'',12340), -(2887,0,0,0,0,0,'Prismatic Exile',NULL,NULL,0,44,44,0,91,0,1.55556,1.14286,1,1,18,1,0,0,1,2000,2000,1,1,2,0,2048,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,'SmartAI',0,1,0.05,1,1,1,0,0,1,0,0,0,'',12340), +(2887,0,0,0,0,0,'Prismatic Exile',NULL,NULL,0,44,44,0,91,0,1.55556,1.14286,1,1,18,1,0,0,1,2000,2000,1,1,2,0,2048,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,'',0,1,0.05,1,1,1,0,0,1,0,0,0,'npc_prismatic_exile',12340), (2888,0,0,0,0,0,'Garek',NULL,NULL,0,50,50,0,35,2,1,1.14286,1,1,18,1,0,0,1,1500,2000,1,1,1,768,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,1.25,1,1,1,0,0,1,0,0,2,'',12340), (2889,0,0,0,0,0,'Stonevault Trogg','',NULL,0,35,36,0,59,0,1.2,1.14286,1,1,20,1,1,0,7.5,2000,2000,1,1,1,0,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,3,1,1,1,0,0,1,0,0,0,'',12340), (2890,0,0,0,0,0,'Stonevault Scout','',NULL,0,36,37,0,59,0,1.2,1.14286,1,1,20,1,1,0,7.5,2000,2000,1,1,1,0,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,3,1,1,1,0,0,1,0,0,0,'',12340), diff --git a/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp b/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp index dea0884b75..8b17bb225a 100644 --- a/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp @@ -124,7 +124,105 @@ public: } }; +enum Spells +{ + SPELL_FIREBALL = 34083, + SPELL_FROSTNOVA = 38033, + SPELL_LIGHTNING_SHIELD = 12550, + SPELL_VISUAL_TRANSFORMATION = 24085 +}; + +// Fire, Air, Water, earth model displayId (same as the elemental in the zone) +uint32_t elements_display[] = {2172, 5490, 5561, 9587}; +class npc_prismatic_exile : public CreatureScript +{ +public: + npc_prismatic_exile() : CreatureScript("npc_prismatic_exile") {} + + struct npc_prismatic_exileAI : public ScriptedAI + { + uint32 changeElementTimer; + uint32 currentElement; + uint32 frostNovaTimer; + bool hasLightningShield; + + npc_prismatic_exileAI(Creature* creature) : ScriptedAI(creature) { + currentElement = 3; + hasLightningShield = false; + frostNovaTimer = urand(1400, 7300); // Got those values from smart_script of 2761 + changeElementTimer = urand(6 * IN_MILLISECONDS, 10 * IN_MILLISECONDS); + } + + void InitializeAI() override + { + ScriptedAI::InitializeAI(); + + // Get the target from Myzrael + Unit* owner = me->GetOwner(); + if (!owner) + return; + + Unit* target = owner->GetVictim(); + if (target) + SetGazeOn(target); + } + + void UpdateAI(uint32 diff) override + { + // Change Element + if (changeElementTimer <= diff) + { + uint32 _rand = urand(1, 3); + me->CastStop(); + me->CastSpell(me, SPELL_VISUAL_TRANSFORMATION, true); + currentElement = (currentElement + _rand) % 4; // Change to a new element different from actual one + me->SetDisplayId(elements_display[currentElement]); + changeElementTimer = urand(6 * IN_MILLISECONDS, 10 * IN_MILLISECONDS); + } + else changeElementTimer -= diff; + + + if (!me->HasUnitState(UNIT_STATE_CASTING)) + { + // Cast spell depending on the current element + switch (currentElement) { + case 0: // FIRE + // Always cast fire ball + me->CastSpell(me->GetVictim(), SPELL_FIREBALL, false); + return; + case 1: // AIR + // Can only cast lightning shield once + if (!hasLightningShield) { + me->CastSpell(me, SPELL_LIGHTNING_SHIELD, false); + hasLightningShield = true; + } + break; + case 2: // WATER + // Can only case frostnova if is in range and timer is done + Unit * target = me->GetVictim(); + if (target && me->IsInRange(target, 0.0f, 10.0f) && frostNovaTimer <= diff) + { + me->CastSpell((Unit*)nullptr, SPELL_FROSTNOVA, false); + frostNovaTimer = urand(1400, 7300); + } + else frostNovaTimer -= diff; + break; + } + + // By default, melee attack + DoMeleeAttackIfReady(); + } + } + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_prismatic_exileAI(creature); + } +}; + void AddSC_arathi_highlands() { + new npc_prismatic_exile(); new npc_professor_phizzlethorpe(); } From 7a3e4066a34979ed35a00d48272061eea38abda2 Mon Sep 17 00:00:00 2001 From: MokonaNico Date: Mon, 3 Nov 2025 17:44:06 +0100 Subject: [PATCH 2/3] Style : fix c++ codestyle --- .../scripts/EasternKingdoms/zone_arathi_highlands.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp b/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp index 8b17bb225a..d058264829 100644 --- a/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_arathi_highlands.cpp @@ -163,7 +163,7 @@ public: return; Unit* target = owner->GetVictim(); - if (target) + if (target) SetGazeOn(target); } @@ -181,7 +181,6 @@ public: } else changeElementTimer -= diff; - if (!me->HasUnitState(UNIT_STATE_CASTING)) { // Cast spell depending on the current element @@ -192,7 +191,8 @@ public: return; case 1: // AIR // Can only cast lightning shield once - if (!hasLightningShield) { + if (!hasLightningShield) + { me->CastSpell(me, SPELL_LIGHTNING_SHIELD, false); hasLightningShield = true; } From bef7204bb6af70802430f5385a626c779247e8a1 Mon Sep 17 00:00:00 2001 From: MokonaNico Date: Mon, 3 Nov 2025 17:54:37 +0100 Subject: [PATCH 3/3] Move sql changes to pending --- data/sql/base/db_world/creature_template.sql | 2 +- data/sql/updates/pending_db_world/fix_prismatic_exiles.sql | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 data/sql/updates/pending_db_world/fix_prismatic_exiles.sql diff --git a/data/sql/base/db_world/creature_template.sql b/data/sql/base/db_world/creature_template.sql index e494f7ed57..7806c22808 100644 --- a/data/sql/base/db_world/creature_template.sql +++ b/data/sql/base/db_world/creature_template.sql @@ -2552,7 +2552,7 @@ INSERT INTO `creature_template` VALUES (2883,0,0,0,0,0,'[UNUSED] [PH] Monster Slayer Trainer','Monster Slayer Trainer','',0,8,12,0,55,0,1,1.14286,1,1,20,1,0,0,1,2000,2000,1,1,1,0,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,1,1,1,1,0,0,1,0,0,0,'',12340), (2885,0,0,0,0,0,'[UNUSED] [PH] Magic Skills Trainer','Magic Skills Trainer','',0,8,12,0,55,0,1,1.14286,1,1,20,1,0,0,1,2000,2000,1,1,1,0,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,1,1,1,1,0,0,1,0,0,0,'',12340), (2886,0,0,0,0,0,'Ranged Skills Trainer','Ranged Skills Trainer',NULL,0,8,12,0,55,0,1.2,1.14286,1,1,20,1,0,0,1,2000,2000,1,1,1,0,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,1,1,1,1,0,0,1,0,0,2,'',12340), -(2887,0,0,0,0,0,'Prismatic Exile',NULL,NULL,0,44,44,0,91,0,1.55556,1.14286,1,1,18,1,0,0,1,2000,2000,1,1,2,0,2048,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,'',0,1,0.05,1,1,1,0,0,1,0,0,0,'npc_prismatic_exile',12340), +(2887,0,0,0,0,0,'Prismatic Exile',NULL,NULL,0,44,44,0,91,0,1.55556,1.14286,1,1,18,1,0,0,1,2000,2000,1,1,2,0,2048,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,'SmartAI',0,1,0.05,1,1,1,0,0,1,0,0,0,'',12340), (2888,0,0,0,0,0,'Garek',NULL,NULL,0,50,50,0,35,2,1,1.14286,1,1,18,1,0,0,1,1500,2000,1,1,1,768,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,1.25,1,1,1,0,0,1,0,0,2,'',12340), (2889,0,0,0,0,0,'Stonevault Trogg','',NULL,0,35,36,0,59,0,1.2,1.14286,1,1,20,1,1,0,7.5,2000,2000,1,1,1,0,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,3,1,1,1,0,0,1,0,0,0,'',12340), (2890,0,0,0,0,0,'Stonevault Scout','',NULL,0,36,37,0,59,0,1.2,1.14286,1,1,20,1,1,0,7.5,2000,2000,1,1,1,0,2048,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,'',0,1,3,1,1,1,0,0,1,0,0,0,'',12340), diff --git a/data/sql/updates/pending_db_world/fix_prismatic_exiles.sql b/data/sql/updates/pending_db_world/fix_prismatic_exiles.sql new file mode 100644 index 0000000000..0253735720 --- /dev/null +++ b/data/sql/updates/pending_db_world/fix_prismatic_exiles.sql @@ -0,0 +1,5 @@ +-- Remove SmartAI and add script name +UPDATE `creature_template` SET `AIName` = '', `ScriptName` = 'npc_prismatic_exile' WHERE `entry` = 2887; + +-- delete old smartscript +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 2887) AND (`source_type` = 0);