From 8eb7b24670b560bfe0b8011f9bd4f7df6dae5133 Mon Sep 17 00:00:00 2001 From: Gultask <100873791+Gultask@users.noreply.github.com> Date: Sun, 14 Jul 2024 12:27:32 -0300 Subject: [PATCH] fix(Scripts/Netherstorm): Rewrite Phase Hunter AI (#19401) * Update zone_netherstorm.cpp * Update zone_netherstorm.cpp * db --- .../rev_1720928725467169800.sql | 13 ++ .../scripts/Outland/zone_netherstorm.cpp | 142 +----------------- 2 files changed, 21 insertions(+), 134 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1720928725467169800.sql diff --git a/data/sql/updates/pending_db_world/rev_1720928725467169800.sql b/data/sql/updates/pending_db_world/rev_1720928725467169800.sql new file mode 100644 index 000000000..049494b04 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1720928725467169800.sql @@ -0,0 +1,13 @@ +-- +UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE `entry` = 18879; +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 18879); +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 +(18879, 0, 0, 0, 25, 0, 100, 0, 0, 0, 0, 0, 0, 0, 11, 34804, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Phase Hunter - On Reset - Cast \'Materialize\''), +(18879, 0, 2, 0, 2, 0, 100, 0, 0, 35, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Phase Hunter - Between 0-35% Health - Say Line 0'), +(18879, 0, 3, 0, 23, 0, 100, 0, 8000, 16000, 20000, 31000, 0, 0, 11, 37176, 0, 0, 0, 0, 0, 5, 0, 0, 1, 0, 0, 0, 0, 0, 'Phase Hunter - In Combat - Cast \'Mana Burn\''), +(18879, 0, 1, 0, 0, 0, 100, 0, 3600, 3600, 3600, 3600, 0, 0, 11, 36574, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Phase Hunter - In Combat - Cast \'Phase Slip\''); + +DELETE FROM `conditions` WHERE (`SourceTypeOrReferenceId` = 22) AND (`SourceGroup` = 2) AND (`SourceEntry` = 18879) AND (`SourceId` = 0); +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(22, 2, 18879, 0, 0, 102, 1, 26, 0, 0, 0, 0, 0, '', 'Only execute SAI if Phase Hunter is under a Root effect'), +(22, 2, 18879, 0, 1, 102, 1, 33, 0, 0, 0, 0, 0, '', 'Only execute SAI if Phase Hunter is under a Move Speed Decrease effect'); diff --git a/src/server/scripts/Outland/zone_netherstorm.cpp b/src/server/scripts/Outland/zone_netherstorm.cpp index e61baf0ff..61bf6c91c 100644 --- a/src/server/scripts/Outland/zone_netherstorm.cpp +++ b/src/server/scripts/Outland/zone_netherstorm.cpp @@ -580,137 +580,6 @@ public: } }; -/*###### -## npc_phase_hunter -######*/ - -enum PhaseHunterData -{ - QUEST_RECHARGING_THE_BATTERIES = 10190, - - NPC_PHASE_HUNTER_ENTRY = 18879, - NPC_DRAINED_PHASE_HUNTER_ENTRY = 19595, - - EMOTE_WEAK = 0, - - // Spells - SPELL_RECHARGING_BATTERY = 34219, - SPELL_PHASE_SLIP = 36574, - SPELL_MANA_BURN = 13321, - SPELL_MATERIALIZE = 34804, - SPELL_DE_MATERIALIZE = 34814, -}; - -class npc_phase_hunter : public CreatureScript -{ -public: - npc_phase_hunter() : CreatureScript("npc_phase_hunter") { } - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_phase_hunterAI(creature); - } - - struct npc_phase_hunterAI : public ScriptedAI - { - npc_phase_hunterAI(Creature* creature) : ScriptedAI(creature) { } - - bool Weak; - bool Materialize; - bool Drained; - uint8 WeakPercent; - - ObjectGuid PlayerGUID; - - uint32 ManaBurnTimer; - - void Reset() override - { - Weak = false; - Materialize = false; - Drained = false; - WeakPercent = 25 + (rand() % 16); // 25-40 - - PlayerGUID.Clear(); - - ManaBurnTimer = 5000 + (rand() % 3 * 1000); // 5-8 sec cd - - if (me->GetEntry() == NPC_DRAINED_PHASE_HUNTER_ENTRY) - me->UpdateEntry(NPC_PHASE_HUNTER_ENTRY); - } - - void JustEngagedWith(Unit* who) override - { - if (who->GetTypeId() == TYPEID_PLAYER) - PlayerGUID = who->GetGUID(); - } - - //void SpellHit(Unit* /*caster*/, SpellInfo const* /*spell*/) - //{ - // DoCast(me, SPELL_DE_MATERIALIZE); - //} - - void UpdateAI(uint32 diff) override - { - if (!Materialize) - { - DoCast(me, SPELL_MATERIALIZE); - Materialize = true; - } - - if (me->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED) || me->HasUnitState(UNIT_STATE_ROOT)) // if the mob is rooted/slowed by spells eg.: Entangling Roots, Frost Nova, Hamstring, Crippling Poison, etc. => remove it - DoCast(me, SPELL_PHASE_SLIP); - - if (!UpdateVictim()) - return; - - // some code to cast spell Mana Burn on random target which has mana - if (ManaBurnTimer <= diff) - { - std::list AggroList = me->GetThreatMgr().GetThreatList(); - std::list UnitsWithMana; - - for (std::list::const_iterator itr = AggroList.begin(); itr != AggroList.end(); ++itr) - { - if (Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid())) - { - if (unit->GetCreateMana() > 0) - UnitsWithMana.push_back(unit); - } - } - if (!UnitsWithMana.empty()) - { - DoCast(Acore::Containers::SelectRandomContainerElement(UnitsWithMana), SPELL_MANA_BURN); - ManaBurnTimer = 8000 + (rand() % 10 * 1000); // 8-18 sec cd - } - else - ManaBurnTimer = 3500; - } - else ManaBurnTimer -= diff; - - if (Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID)) // start: support for quest 10190 - { - if (!Weak && HealthBelowPct(WeakPercent) - && player->GetQuestStatus(QUEST_RECHARGING_THE_BATTERIES) == QUEST_STATUS_INCOMPLETE) - { - Talk(EMOTE_WEAK); - Weak = true; - } - if (Weak && !Drained && me->HasAura(SPELL_RECHARGING_BATTERY)) - { - Drained = true; - int32 uHpPct = int32(me->GetHealthPct()); - me->SetHealth(me->CountPctFromMaxHealth(uHpPct)); - me->LowerPlayerDamageReq(me->GetMaxHealth() - me->GetHealth()); - me->SetInCombatWith(player); - } - } // end: support for quest 10190 - - DoMeleeAttackIfReady(); - } - }; -}; - /*###### ## npc_bessy ######*/ @@ -911,6 +780,12 @@ public: } }; +enum PhaseHunterData +{ + NPC_PHASE_HUNTER_ENTRY = 18879, + NPC_DRAINED_PHASE_HUNTER_ENTRY = 19595 +}; + class spell_q10190_battery_recharging_blaster : public SpellScript { PrepareSpellScript(spell_q10190_battery_recharging_blaster); @@ -918,7 +793,7 @@ class spell_q10190_battery_recharging_blaster : public SpellScript SpellCastResult CheckCast() { if (Unit* target = GetExplTargetUnit()) - if (target->GetHealthPct() <= 25.0f) + if (target->GetHealthPct() <= 35.0f) return SPELL_CAST_OK; return SPELL_FAILED_BAD_TARGETS; @@ -941,7 +816,7 @@ class spell_q10190_battery_recharging_blaster_aura : public AuraScript if (Creature* phasehunter = GetTarget()->ToCreature()) if (phasehunter->GetEntry() == NPC_PHASE_HUNTER_ENTRY) - phasehunter->UpdateEntry(NPC_DRAINED_PHASE_HUNTER_ENTRY); + phasehunter->UpdateEntry(NPC_DRAINED_PHASE_HUNTER_ENTRY, nullptr, false); } void Register() override @@ -989,7 +864,6 @@ void AddSC_netherstorm() // Theirs new npc_commander_dawnforge(); new at_commander_dawnforge(); - new npc_phase_hunter(); new npc_bessy(); new npc_maxx_a_million_escort(); RegisterSpellAndAuraScriptPair(spell_q10190_battery_recharging_blaster, spell_q10190_battery_recharging_blaster_aura);