diff --git a/sql/updates/world/4.3.4/2020_07_12_01_world.sql b/sql/updates/world/4.3.4/2020_07_12_01_world.sql new file mode 100644 index 00000000000..fbd9debf1f5 --- /dev/null +++ b/sql/updates/world/4.3.4/2020_07_12_01_world.sql @@ -0,0 +1,2 @@ +UPDATE `creature_template` SET `ScriptName`= '', `AIName`= '' WHERE `entry`= 42098; +UPDATE `creature` SET `ScriptName`= 'npc_bot_invisible_stalker_phase_twist' WHERE `guid` IN (253820, 253821, 253808, 253815); diff --git a/src/server/scripts/EasternKingdoms/BastionOfTwilight/bastion_of_twilight.cpp b/src/server/scripts/EasternKingdoms/BastionOfTwilight/bastion_of_twilight.cpp index d31705817b2..02c45fe18c9 100644 --- a/src/server/scripts/EasternKingdoms/BastionOfTwilight/bastion_of_twilight.cpp +++ b/src/server/scripts/EasternKingdoms/BastionOfTwilight/bastion_of_twilight.cpp @@ -23,9 +23,91 @@ #include "SpellAuraEffects.h" #include "GameObject.h" #include "GameObjectAI.h" +#include "Object.h" +#include "PassiveAI.h" #include "Player.h" #include "bastion_of_twilight.h" +#include + +enum PhaseTwist +{ + // Events + EVENT_REGISTER_TWISTERS = 1, + EVENT_CHECK_TWISTERS, + EVENT_PHASE_BURN, + + // Spells + SPELL_PHASED_BURN = 85799 +}; + +struct npc_bot_invisible_stalker_phase_twist : public NullCreatureAI +{ + npc_bot_invisible_stalker_phase_twist(Creature* creature) : NullCreatureAI(creature) { } + + void JustAppeared() override + { + _events.ScheduleEvent(EVENT_REGISTER_TWISTERS, 1s); + } + + void UpdateAI(uint32 diff) override + { + _events.Update(diff); + + while (uint32 eventId = _events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_REGISTER_TWISTERS: + me->GetCreatureListWithEntryInGrid(_phaseTwisterVector, NPC_TWILIGHT_PHASE_SHIFTER, 10.f); + if (_phaseTwisterVector.empty()) // if the twister have not been added to the grid yet, keep searching + _events.Repeat(1s); + else + { + _events.ScheduleEvent(EVENT_CHECK_TWISTERS, 1s); + _events.ScheduleEvent(EVENT_PHASE_BURN, 1s); + } + break; + case EVENT_CHECK_TWISTERS: + { + uint8 deadTwisters = 0; + for (Unit const* twister : _phaseTwisterVector) + { + if (!twister || twister->isDead()) + ++deadTwisters; + } + + if (deadTwisters == _phaseTwisterVector.size()) + { + _events.Reset(); + me->InterruptNonMeleeSpells(true); + me->RemoveAllAuras(); + me->DespawnOrUnsummon(4s); + } + else + _events.Repeat(1s); + break; + } + case EVENT_PHASE_BURN: + if (Unit* target = me->SelectNearestTarget(40.f, true)) + { + DoCast(target, SPELL_PHASED_BURN); + _events.Repeat(8s); + } + else + _events.Repeat(1s); + break; + default: + break; + } + } + } + +private: + EventMap _events; + std::vector _phaseTwisterVector; +}; + class at_theralion_and_valiona_intro : public AreaTriggerScript { public: @@ -93,9 +175,10 @@ class at_chogall_intro : public AreaTriggerScript void AddSC_bastion_of_twilight() { + RegisterBastionOfTwilightCreatureAI(npc_bot_invisible_stalker_phase_twist); new at_theralion_and_valiona_intro(); new at_ascendant_council_intro_1(); new at_ascendant_council_intro_2(); new at_ascendant_council_intro_3(); new at_chogall_intro(); -} \ No newline at end of file +} diff --git a/src/server/scripts/EasternKingdoms/BastionOfTwilight/bastion_of_twilight.h b/src/server/scripts/EasternKingdoms/BastionOfTwilight/bastion_of_twilight.h index 8ebff90e117..10de003b81b 100644 --- a/src/server/scripts/EasternKingdoms/BastionOfTwilight/bastion_of_twilight.h +++ b/src/server/scripts/EasternKingdoms/BastionOfTwilight/bastion_of_twilight.h @@ -145,7 +145,8 @@ enum BoTCreatures NPC_SPIKED_TENTACLE_TRIGGER = 50265, // Generic Creatures - NPC_INVISIBLE_STALKER = 42098 + NPC_INVISIBLE_STALKER = 42098, + NPC_TWILIGHT_PHASE_SHIFTER = 45267 }; enum BoTGameObjects