diff options
author | Peter Keresztes Schmidt <carbenium@outlook.com> | 2020-08-01 23:32:10 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-01-24 22:32:11 +0100 |
commit | 43591bb4d5166ef2506f270d2d49e98e67f71862 (patch) | |
tree | 20152688b658590db46f6714b2c955ce96088391 /src | |
parent | 5b1ba7b5037c639a24d2872ea59833f06413bcde (diff) |
Scripts/AzjolNerub: Update Anub'Arak encounter to current coding standards (#25192)
* Scripts/AzjolNerub: Update Anub'Arak to current coding standards
* no functional changes
* Scripts/AzjolNerub: Update Anub'Arak Darter to current coding standards
* no functional changes
* Scripts/AzjolNerub: Update Anub'Arak Assassin to current coding standards
* no functional changes
* Scripts/AzjolNerub: Update Anub'Arak Guardian to current coding standards
* no functional changes
* Scripts/AzjolNerub: Update Anub'Arak Venomancer to current coding standards
* no functional changes
* Scripts/AzjolNerub: Update Anub'Arak Impale Target to current coding standards
* Scripts/AzjolNerub: Update Anub'Arak Pound spell to current coding standards
* Scripts/AzjolNerub: Update Anub'Arak carrion beetles aura script to current coding standards
(cherry picked from commit dab8768c183dc43f970187a65961fc8fce647c29)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp | 852 |
1 files changed, 395 insertions, 457 deletions
diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp index a93e0a3ccae..9be552892da 100644 --- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_anubarak.cpp @@ -110,310 +110,297 @@ enum SummonGroups SUMMON_GROUP_WORLD_TRIGGER_GUARDIAN = 1 }; -class boss_anub_arak : public CreatureScript +struct boss_anub_arak : public BossAI { -public: - boss_anub_arak() : CreatureScript("boss_anub_arak") { } + boss_anub_arak(Creature* creature) : BossAI(creature, DATA_ANUBARAK), _nextSubmerge(0), _petCount(0), _assassinCount(0), _guardianCount(0), _venomancerCount(0) { } - struct boss_anub_arakAI : public BossAI + void Reset() override { - boss_anub_arakAI(Creature* creature) : BossAI(creature, DATA_ANUBARAK), _nextSubmerge(0), _petCount(0), _assassinCount(0), _guardianCount(0), _venomancerCount(0) { } - - void Reset() override - { - BossAI::Reset(); - me->RemoveUnitFlag(UnitFlags(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)); - instance->DoStopCriteriaTimer(CriteriaStartEvent::SendEvent, ACHIEV_GOTTA_GO_START_EVENT); - _nextSubmerge = 75; - _petCount = 0; - } + BossAI::Reset(); + me->RemoveUnitFlag(UnitFlags(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)); + instance->DoStopCriteriaTimer(CriteriaStartEvent::SendEvent, ACHIEV_GOTTA_GO_START_EVENT); + _nextSubmerge = 75; + _petCount = 0; + } - bool CanAIAttack(Unit const* /*who*/) const override { return true; } // do not check boundary here + bool CanAIAttack(Unit const* /*who*/) const override { return true; } // do not check boundary here - void JustEngagedWith(Unit* who) override + void JustEngagedWith(Unit* who) override + { + BossAI::JustEngagedWith(who); + + if (GameObject* door = instance->GetGameObject(DATA_ANUBARAK_WALL)) + door->SetGoState(GO_STATE_ACTIVE); // open door for now + if (GameObject* door2 = instance->GetGameObject(DATA_ANUBARAK_WALL_2)) + door2->SetGoState(GO_STATE_ACTIVE); + + Talk(SAY_AGGRO); + instance->DoStartCriteriaTimer(CriteriaStartEvent::SendEvent, ACHIEV_GOTTA_GO_START_EVENT); + + events.SetPhase(PHASE_EMERGE); + events.ScheduleEvent(EVENT_CLOSE_DOOR, 5s); + events.ScheduleEvent(EVENT_POUND, 2s, 4s, 0, PHASE_EMERGE); + events.ScheduleEvent(EVENT_LEECHING_SWARM, 5s, 7s, 0, PHASE_EMERGE); + events.ScheduleEvent(EVENT_CARRION_BEETLES, 14s, 17s, 0, PHASE_EMERGE); + + // set up world triggers + std::list<TempSummon*> summoned; + me->SummonCreatureGroup(SUMMON_GROUP_WORLD_TRIGGER_GUARDIAN, &summoned); + if (summoned.empty()) // something went wrong { - BossAI::JustEngagedWith(who); - - if (GameObject* door = instance->GetGameObject(DATA_ANUBARAK_WALL)) - door->SetGoState(GO_STATE_ACTIVE); // open door for now - if (GameObject* door2 = instance->GetGameObject(DATA_ANUBARAK_WALL_2)) - door2->SetGoState(GO_STATE_ACTIVE); - - Talk(SAY_AGGRO); - instance->DoStartCriteriaTimer(CriteriaStartEvent::SendEvent, ACHIEV_GOTTA_GO_START_EVENT); - - events.SetPhase(PHASE_EMERGE); - events.ScheduleEvent(EVENT_CLOSE_DOOR, 5s); - events.ScheduleEvent(EVENT_POUND, randtime(Seconds(2), Seconds(4)), 0, PHASE_EMERGE); - events.ScheduleEvent(EVENT_LEECHING_SWARM, randtime(Seconds(5), Seconds(7)), 0, PHASE_EMERGE); - events.ScheduleEvent(EVENT_CARRION_BEETLES, randtime(Seconds(14), Seconds(17)), 0, PHASE_EMERGE); - - // set up world triggers - std::list<TempSummon*> summoned; - me->SummonCreatureGroup(SUMMON_GROUP_WORLD_TRIGGER_GUARDIAN, &summoned); - if (summoned.empty()) // something went wrong - { - EnterEvadeMode(EVADE_REASON_OTHER); - return; - } - _guardianTrigger = (*summoned.begin())->GetGUID(); - - if (Creature* trigger = DoSummon(NPC_WORLD_TRIGGER, me->GetPosition(), 0s, TEMPSUMMON_MANUAL_DESPAWN)) - _assassinTrigger = trigger->GetGUID(); - else - { - EnterEvadeMode(EVADE_REASON_OTHER); - return; - } + EnterEvadeMode(EVADE_REASON_OTHER); + return; } + _guardianTrigger = (*summoned.begin())->GetGUID(); - void EnterEvadeMode(EvadeReason /*why*/) override + if (Creature* trigger = DoSummon(NPC_WORLD_TRIGGER, me->GetPosition(), 0s, TEMPSUMMON_MANUAL_DESPAWN)) + _assassinTrigger = trigger->GetGUID(); + else { - summons.DespawnAll(); - _DespawnAtEvade(); + EnterEvadeMode(EVADE_REASON_OTHER); + return; } + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void EnterEvadeMode(EvadeReason /*why*/) override + { + summons.DespawnAll(); + _DespawnAtEvade(); + } + + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - events.Update(diff); + events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; - while (uint32 eventId = events.ExecuteEvent()) + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) { - switch (eventId) + case EVENT_CLOSE_DOOR: + if (GameObject* door = instance->GetGameObject(DATA_ANUBARAK_WALL)) + door->SetGoState(GO_STATE_READY); + if (GameObject* door2 = instance->GetGameObject(DATA_ANUBARAK_WALL_2)) + door2->SetGoState(GO_STATE_READY); + break; + case EVENT_POUND: + DoCastVictim(SPELL_POUND); + events.Repeat(26s, 32s); + break; + case EVENT_LEECHING_SWARM: + Talk(SAY_LOCUST); + DoCastAOE(SPELL_LEECHING_SWARM); + events.Repeat(25s, 28s); + break; + case EVENT_CARRION_BEETLES: + DoCastAOE(SPELL_CARRION_BEETLES); + events.Repeat(24s, 27s); + break; + case EVENT_IMPALE: + if (Creature* impaleTarget = ObjectAccessor::GetCreature(*me, _impaleTarget)) + DoCast(impaleTarget, SPELL_IMPALE_DAMAGE, true); + break; + case EVENT_SUBMERGE: + Talk(SAY_SUBMERGE); + DoCastSelf(SPELL_SUBMERGE); + break; + case EVENT_DARTER: { - case EVENT_CLOSE_DOOR: - if (GameObject* door = instance->GetGameObject(DATA_ANUBARAK_WALL)) - door->SetGoState(GO_STATE_READY); - if (GameObject* door2 = instance->GetGameObject(DATA_ANUBARAK_WALL_2)) - door2->SetGoState(GO_STATE_READY); - break; - case EVENT_POUND: - DoCastVictim(SPELL_POUND); - events.Repeat(randtime(Seconds(26), Seconds(32))); - break; - case EVENT_LEECHING_SWARM: - Talk(SAY_LOCUST); - DoCastAOE(SPELL_LEECHING_SWARM); - events.Repeat(randtime(Seconds(25), Seconds(28))); - break; - case EVENT_CARRION_BEETLES: - DoCastAOE(SPELL_CARRION_BEETLES); - events.Repeat(randtime(Seconds(24), Seconds(27))); - break; - case EVENT_IMPALE: - if (Creature* impaleTarget = ObjectAccessor::GetCreature(*me, _impaleTarget)) - DoCast(impaleTarget, SPELL_IMPALE_DAMAGE, true); - break; - case EVENT_SUBMERGE: - Talk(SAY_SUBMERGE); - DoCastSelf(SPELL_SUBMERGE); - break; - case EVENT_DARTER: + std::list<Creature*> triggers; + me->GetCreatureListWithEntryInGrid(triggers, NPC_WORLD_TRIGGER); + if (!triggers.empty()) { - std::list<Creature*> triggers; - me->GetCreatureListWithEntryInGrid(triggers, NPC_WORLD_TRIGGER); - if (!triggers.empty()) + Creature* trigger = Trinity::Containers::SelectRandomContainerElement(triggers); + trigger->CastSpell(trigger, SPELL_SUMMON_DARTER, true); + + events.Repeat(11s); + } + else + EnterEvadeMode(EVADE_REASON_OTHER); + break; + } + case EVENT_ASSASSIN: + if (Creature* trigger = ObjectAccessor::GetCreature(*me, _assassinTrigger)) + { + trigger->CastSpell(trigger, SPELL_SUMMON_ASSASSIN, true); + trigger->CastSpell(trigger, SPELL_SUMMON_ASSASSIN, true); + if (_assassinCount > 2) { - std::list<Creature*>::iterator it = triggers.begin(); - std::advance(it, urand(0, triggers.size()-1)); - (*it)->CastSpell(*it, SPELL_SUMMON_DARTER, true); - events.Repeat(Seconds(11)); + _assassinCount -= 2; + events.Repeat(20s); } else - EnterEvadeMode(EVADE_REASON_OTHER); - break; + _assassinCount = 0; } - case EVENT_ASSASSIN: - if (Creature* trigger = ObjectAccessor::GetCreature(*me, _assassinTrigger)) - { - trigger->CastSpell(trigger, SPELL_SUMMON_ASSASSIN, true); - trigger->CastSpell(trigger, SPELL_SUMMON_ASSASSIN, true); - if (_assassinCount > 2) - { - _assassinCount -= 2; - events.Repeat(Seconds(20)); - } - else - _assassinCount = 0; - } - else // something went wrong - EnterEvadeMode(EVADE_REASON_OTHER); - break; - case EVENT_GUARDIAN: - if (Creature* trigger = ObjectAccessor::GetCreature(*me, _guardianTrigger)) + else // something went wrong + EnterEvadeMode(EVADE_REASON_OTHER); + break; + case EVENT_GUARDIAN: + if (Creature* trigger = ObjectAccessor::GetCreature(*me, _guardianTrigger)) + { + trigger->CastSpell(trigger, SPELL_SUMMON_GUARDIAN, true); + trigger->CastSpell(trigger, SPELL_SUMMON_GUARDIAN, true); + if (_guardianCount > 2) { - trigger->CastSpell(trigger, SPELL_SUMMON_GUARDIAN, true); - trigger->CastSpell(trigger, SPELL_SUMMON_GUARDIAN, true); - if (_guardianCount > 2) - { - _guardianCount -= 2; - events.Repeat(Seconds(20)); - } - else - _guardianCount = 0; + _guardianCount -= 2; + events.Repeat(20s); } else - EnterEvadeMode(EVADE_REASON_OTHER); - break; - case EVENT_VENOMANCER: - if (Creature* trigger = ObjectAccessor::GetCreature(*me, _guardianTrigger)) + _guardianCount = 0; + } + else + EnterEvadeMode(EVADE_REASON_OTHER); + break; + case EVENT_VENOMANCER: + if (Creature* trigger = ObjectAccessor::GetCreature(*me, _guardianTrigger)) + { + trigger->CastSpell(trigger, SPELL_SUMMON_VENOMANCER, true); + trigger->CastSpell(trigger, SPELL_SUMMON_VENOMANCER, true); + if (_venomancerCount > 2) { - trigger->CastSpell(trigger, SPELL_SUMMON_VENOMANCER, true); - trigger->CastSpell(trigger, SPELL_SUMMON_VENOMANCER, true); - if (_venomancerCount > 2) - { - _venomancerCount -= 2; - events.Repeat(Seconds(20)); - } - else - _venomancerCount = 0; + _venomancerCount -= 2; + events.Repeat(20s); } else - EnterEvadeMode(EVADE_REASON_OTHER); - break; - default: - break; - } - - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + _venomancerCount = 0; + } + else + EnterEvadeMode(EVADE_REASON_OTHER); + break; + default: + break; } - - DoMeleeAttackIfReady(); + if (me->HasUnitState(UNIT_STATE_CASTING)) + return; } - void JustDied(Unit* /*killer*/) override - { - _JustDied(); - Talk(SAY_DEATH); - } + DoMeleeAttackIfReady(); + } - void KilledUnit(Unit* victim) override - { - if (victim->GetTypeId() == TYPEID_PLAYER) - Talk(SAY_SLAY); - } + void JustDied(Unit* /*killer*/) override + { + _JustDied(); + Talk(SAY_DEATH); + } - void SetGUID(ObjectGuid const& guid, int32 id) override - { - switch (id) - { - case GUID_TYPE_PET: - { - if (Creature* creature = ObjectAccessor::GetCreature(*me, guid)) - JustSummoned(creature); - else // something has gone horribly wrong - EnterEvadeMode(EVADE_REASON_OTHER); - break; - } - case GUID_TYPE_IMPALE: - _impaleTarget = guid; - events.ScheduleEvent(EVENT_IMPALE, 4s); - break; - } - } + void KilledUnit(Unit* victim) override + { + if (victim->GetTypeId() == TYPEID_PLAYER) + Talk(SAY_SLAY); + } - void DoAction(int32 action) override + void SetGUID(ObjectGuid const& guid, int32 id) override + { + switch (id) { - switch (action) + case GUID_TYPE_PET: { - case ACTION_PET_DIED: - if (!_petCount) // underflow check - something has gone horribly wrong - { - EnterEvadeMode(EVADE_REASON_OTHER); - return; - } - if (!--_petCount) // last pet died, emerge - { - me->RemoveAurasDueToSpell(SPELL_SUBMERGE); - me->RemoveAurasDueToSpell(SPELL_IMPALE_AURA); - me->RemoveUnitFlag(UnitFlags(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)); - DoCastSelf(SPELL_EMERGE); - events.SetPhase(PHASE_EMERGE); - events.ScheduleEvent(EVENT_POUND, randtime(Seconds(13), Seconds(18)), 0, PHASE_EMERGE); - events.ScheduleEvent(EVENT_LEECHING_SWARM, randtime(Seconds(3), Seconds(7)), 0, PHASE_EMERGE); - events.ScheduleEvent(EVENT_CARRION_BEETLES, randtime(Seconds(10), Seconds(15)), 0, PHASE_EMERGE); - } - break; - case ACTION_PET_EVADE: + if (Creature* creature = ObjectAccessor::GetCreature(*me, guid)) + JustSummoned(creature); + else // something has gone horribly wrong EnterEvadeMode(EVADE_REASON_OTHER); - break; + break; } + case GUID_TYPE_IMPALE: + _impaleTarget = guid; + events.ScheduleEvent(EVENT_IMPALE, 4s); + break; } + } - void DamageTaken(Unit* /*source*/, uint32& damage) override + void DoAction(int32 action) override + { + switch (action) { - if (me->HasAura(SPELL_SUBMERGE)) - damage = 0; - else - if (_nextSubmerge && me->HealthBelowPctDamaged(_nextSubmerge, damage)) + case ACTION_PET_DIED: + if (!_petCount) // underflow check - something has gone horribly wrong { - events.CancelEvent(EVENT_SUBMERGE); - events.ScheduleEvent(EVENT_SUBMERGE, 0s, 0, PHASE_EMERGE); - _nextSubmerge = _nextSubmerge-25; + EnterEvadeMode(EVADE_REASON_OTHER); + return; + } + if (!--_petCount) // last pet died, emerge + { + me->RemoveAurasDueToSpell(SPELL_SUBMERGE); + me->RemoveAurasDueToSpell(SPELL_IMPALE_AURA); + me->RemoveUnitFlag(UnitFlags(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)); + DoCastSelf(SPELL_EMERGE); + events.SetPhase(PHASE_EMERGE); + events.ScheduleEvent(EVENT_POUND, 13s, 18s, 0, PHASE_EMERGE); + events.ScheduleEvent(EVENT_LEECHING_SWARM, 3s, 7s, 0, PHASE_EMERGE); + events.ScheduleEvent(EVENT_CARRION_BEETLES, 10s, 15s, 0, PHASE_EMERGE); } + break; + case ACTION_PET_EVADE: + EnterEvadeMode(EVADE_REASON_OTHER); + break; } + } - void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override - { - if (spellInfo->Id == SPELL_SUBMERGE) + void DamageTaken(Unit* /*source*/, uint32& damage) override + { + if (me->HasAura(SPELL_SUBMERGE)) + damage = 0; + else + if (_nextSubmerge && me->HealthBelowPctDamaged(_nextSubmerge, damage)) { - me->AddUnitFlag(UnitFlags(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)); - me->RemoveAurasDueToSpell(SPELL_LEECHING_SWARM); - DoCastSelf(SPELL_IMPALE_AURA, true); - - events.SetPhase(PHASE_SUBMERGE); - switch (_nextSubmerge) - { - case 50: // first submerge phase - _assassinCount = 4; - _guardianCount = 2; - _venomancerCount = 0; - break; - case 25: // second submerge phase - _assassinCount = 6; - _guardianCount = 2; - _venomancerCount = 2; - break; - case 0: // third submerge phase - _assassinCount = 6; - _guardianCount = 2; - _venomancerCount = 2; - events.ScheduleEvent(EVENT_DARTER, 0s, 0, PHASE_SUBMERGE); - break; - } - _petCount = _guardianCount + _venomancerCount; - if (_assassinCount) - events.ScheduleEvent(EVENT_ASSASSIN, 0s, 0, PHASE_SUBMERGE); - if (_guardianCount) - events.ScheduleEvent(EVENT_GUARDIAN, Seconds(4), 0, PHASE_SUBMERGE); - if (_venomancerCount) - events.ScheduleEvent(EVENT_VENOMANCER, Seconds(20), 0, PHASE_SUBMERGE); + events.RescheduleEvent(EVENT_SUBMERGE, 0s, 0, PHASE_EMERGE); + _nextSubmerge = _nextSubmerge-25; } - } + } - private: - ObjectGuid _impaleTarget; - uint32 _nextSubmerge; - uint32 _petCount; - ObjectGuid _guardianTrigger; - ObjectGuid _assassinTrigger; - uint8 _assassinCount; - uint8 _guardianCount; - uint8 _venomancerCount; - }; - - CreatureAI* GetAI(Creature* creature) const override + void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override { - return GetAzjolNerubAI<boss_anub_arakAI>(creature); + if (spellInfo->Id == SPELL_SUBMERGE) + { + me->AddUnitFlag(UnitFlags(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)); + me->RemoveAurasDueToSpell(SPELL_LEECHING_SWARM); + DoCastSelf(SPELL_IMPALE_AURA, true); + + events.SetPhase(PHASE_SUBMERGE); + switch (_nextSubmerge) + { + case 50: // first submerge phase + _assassinCount = 4; + _guardianCount = 2; + _venomancerCount = 0; + break; + case 25: // second submerge phase + _assassinCount = 6; + _guardianCount = 2; + _venomancerCount = 2; + break; + case 0: // third submerge phase + _assassinCount = 6; + _guardianCount = 2; + _venomancerCount = 2; + events.ScheduleEvent(EVENT_DARTER, 0s, 0, PHASE_SUBMERGE); + break; + } + _petCount = _guardianCount + _venomancerCount; + if (_assassinCount) + events.ScheduleEvent(EVENT_ASSASSIN, 0s, 0, PHASE_SUBMERGE); + if (_guardianCount) + events.ScheduleEvent(EVENT_GUARDIAN, 4s, 0, PHASE_SUBMERGE); + if (_venomancerCount) + events.ScheduleEvent(EVENT_VENOMANCER, 20s, 0, PHASE_SUBMERGE); + } } + + private: + ObjectGuid _impaleTarget; + uint32 _nextSubmerge; + uint32 _petCount; + ObjectGuid _guardianTrigger; + ObjectGuid _assassinTrigger; + uint8 _assassinCount; + uint8 _guardianCount; + uint8 _venomancerCount; }; class npc_anubarak_pet_template : public ScriptedAI @@ -452,268 +439,219 @@ class npc_anubarak_pet_template : public ScriptedAI bool const _isLarge; }; -class npc_anubarak_anub_ar_darter : public CreatureScript +struct npc_anubarak_anub_ar_darter : public npc_anubarak_pet_template { - public: - npc_anubarak_anub_ar_darter() : CreatureScript("npc_anubarak_anub_ar_darter") { } - - struct npc_anubarak_anub_ar_darterAI : public npc_anubarak_pet_template - { - npc_anubarak_anub_ar_darterAI(Creature* creature) : npc_anubarak_pet_template(creature, false) { } - - void InitializeAI() override - { - npc_anubarak_pet_template::InitializeAI(); - DoCastAOE(SPELL_DART); - } - }; + npc_anubarak_anub_ar_darter(Creature* creature) : npc_anubarak_pet_template(creature, false) { } - CreatureAI* GetAI(Creature* creature) const override - { - return GetAzjolNerubAI<npc_anubarak_anub_ar_darterAI>(creature); - } + void InitializeAI() override + { + npc_anubarak_pet_template::InitializeAI(); + DoCastAOE(SPELL_DART); + } }; -class npc_anubarak_anub_ar_assassin : public CreatureScript +struct npc_anubarak_anub_ar_assassin : public npc_anubarak_pet_template { - public: - npc_anubarak_anub_ar_assassin() : CreatureScript("npc_anubarak_anub_ar_assassin") { } + npc_anubarak_anub_ar_assassin(Creature* creature) : npc_anubarak_pet_template(creature, false){ } - struct npc_anubarak_anub_ar_assassinAI : public npc_anubarak_pet_template - { - npc_anubarak_anub_ar_assassinAI(Creature* creature) : npc_anubarak_pet_template(creature, false), _backstabTimer(6 * IN_MILLISECONDS) { } + Position GetRandomPositionAround(Creature* anubarak) + { + static float DISTANCE_MIN = 10.0f; + static float DISTANCE_MAX = 30.0f; + double angle = rand_norm() * 2.0 * M_PI; + return { anubarak->GetPositionX() + (float)(frand(DISTANCE_MIN, DISTANCE_MAX)*std::sin(angle)), anubarak->GetPositionY() + (float)(frand(DISTANCE_MIN, DISTANCE_MAX)*std::cos(angle)), anubarak->GetPositionZ() }; + } - Position GetRandomPositionAround(Creature* anubarak) - { - static float DISTANCE_MIN = 10.0f; - static float DISTANCE_MAX = 30.0f; - double angle = rand_norm() * 2.0 * M_PI; - return { anubarak->GetPositionX() + (float)(frand(DISTANCE_MIN, DISTANCE_MAX)*std::sin(angle)), anubarak->GetPositionY() + (float)(frand(DISTANCE_MIN, DISTANCE_MAX)*std::cos(angle)), anubarak->GetPositionZ() }; - } - void InitializeAI() override - { - npc_anubarak_pet_template::InitializeAI(); - CreatureBoundary const* boundary = _instance->GetBossBoundary(DATA_ANUBARAK); - if (Creature* anubarak = _instance->GetCreature(DATA_ANUBARAK)) - { - Position jumpTo; - do - jumpTo = GetRandomPositionAround(anubarak); - while (!CreatureAI::IsInBounds(*boundary, &jumpTo)); - me->GetMotionMaster()->MoveJump(jumpTo, 40.0f, 40.0f); - DoCastSelf(SPELL_ASSASSIN_VISUAL, true); - } - } + void InitializeAI() override + { + npc_anubarak_pet_template::InitializeAI(); + CreatureBoundary const* boundary = _instance->GetBossBoundary(DATA_ANUBARAK); + if (Creature* anubarak = _instance->GetCreature(DATA_ANUBARAK)) + { + Position jumpTo; + do + jumpTo = GetRandomPositionAround(anubarak); + while (!CreatureAI::IsInBounds(*boundary, &jumpTo)); + me->GetMotionMaster()->MoveJump(jumpTo, 40.0f, 40.0f); + DoCastSelf(SPELL_ASSASSIN_VISUAL, true); + } + } - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; + void Reset() override + { + _scheduler.CancelAll(); + } - if (diff >= _backstabTimer) - { - if (me->GetVictim() && me->GetVictim()->isInBack(me)) - DoCastVictim(SPELL_BACKSTAB); - _backstabTimer = 6 * IN_MILLISECONDS; - } - else - _backstabTimer -= diff; + void JustEngagedWith(Unit* /*who*/) override + { + _scheduler.Schedule(6s, [this](TaskContext task) + { + if (me->GetVictim() && me->GetVictim()->isInBack(me)) + DoCastVictim(SPELL_BACKSTAB); - DoMeleeAttackIfReady(); - } + task.Repeat(); + }); + } - void MovementInform(uint32 /*type*/, uint32 id) override - { - if (id == EVENT_JUMP) - { - me->RemoveAurasDueToSpell(SPELL_ASSASSIN_VISUAL); - DoZoneInCombat(); - } - } + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; - private: - uint32 _backstabTimer; - }; + _scheduler.Update(diff, [this] + { + DoMeleeAttackIfReady(); + }); + } - CreatureAI* GetAI(Creature* creature) const override + void MovementInform(uint32 /*type*/, uint32 id) override + { + if (id == EVENT_JUMP) { - return GetAzjolNerubAI<npc_anubarak_anub_ar_assassinAI>(creature); + me->RemoveAurasDueToSpell(SPELL_ASSASSIN_VISUAL); + DoZoneInCombat(); } + } + +private: + TaskScheduler _scheduler; }; -class npc_anubarak_anub_ar_guardian : public CreatureScript +struct npc_anubarak_anub_ar_guardian : public npc_anubarak_pet_template { - public: - npc_anubarak_anub_ar_guardian() : CreatureScript("npc_anubarak_anub_ar_guardian") { } + npc_anubarak_anub_ar_guardian(Creature* creature) : npc_anubarak_pet_template(creature, true) { } - struct npc_anubarak_anub_ar_guardianAI : public npc_anubarak_pet_template + void Reset() override { - npc_anubarak_anub_ar_guardianAI(Creature* creature) : npc_anubarak_pet_template(creature, true), _sunderTimer(6 * IN_MILLISECONDS) { } + _scheduler.CancelAll(); + } - void UpdateAI(uint32 diff) override + void JustEngagedWith(Unit* /*who*/) override + { + _scheduler.Schedule(6s, [this](TaskContext task) { - if (!UpdateVictim()) - return; + DoCastVictim(SPELL_SUNDER_ARMOR); + task.Repeat(12s); + }); + } - if (diff >= _sunderTimer) - { - DoCastVictim(SPELL_SUNDER_ARMOR); - _sunderTimer = 12 * IN_MILLISECONDS; - } - else - _sunderTimer -= diff; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; + _scheduler.Update(diff, [this] + { DoMeleeAttackIfReady(); - } - - private: - uint32 _sunderTimer; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetAzjolNerubAI<npc_anubarak_anub_ar_guardianAI>(creature); + }); } + +private: + TaskScheduler _scheduler; }; -class npc_anubarak_anub_ar_venomancer : public CreatureScript +struct npc_anubarak_anub_ar_venomancer : public npc_anubarak_pet_template { - public: - npc_anubarak_anub_ar_venomancer() : CreatureScript("npc_anubarak_anub_ar_venomancer") { } + npc_anubarak_anub_ar_venomancer(Creature* creature) : npc_anubarak_pet_template(creature, true) { } - struct npc_anubarak_anub_ar_venomancerAI : public npc_anubarak_pet_template + void Reset() override { - npc_anubarak_anub_ar_venomancerAI(Creature* creature) : npc_anubarak_pet_template(creature, true), _boltTimer(5 * IN_MILLISECONDS) { } + _scheduler.CancelAll(); + } - void UpdateAI(uint32 diff) override + void JustEngagedWith(Unit* /*who*/) override + { + _scheduler.Schedule(5s, [this](TaskContext task) { - if (!UpdateVictim()) - return; + DoCastVictim(SPELL_POISON_BOLT); + task.Repeat(2s, 3s); + }); + } - if (diff >= _boltTimer) - { - DoCastVictim(SPELL_POISON_BOLT); - _boltTimer = urandms(2, 3); - } - else - _boltTimer -= diff; + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + return; + _scheduler.Update(diff, [this] + { DoMeleeAttackIfReady(); - } - - private: - uint32 _boltTimer; - }; - - CreatureAI* GetAI(Creature* creature) const override - { - return GetAzjolNerubAI<npc_anubarak_anub_ar_venomancerAI>(creature); + }); } + +private: + TaskScheduler _scheduler; }; -class npc_anubarak_impale_target : public CreatureScript +struct npc_anubarak_impale_target : public NullCreatureAI { - public: - npc_anubarak_impale_target() : CreatureScript("npc_anubarak_impale_target") { } - - struct npc_anubarak_impale_targetAI : public NullCreatureAI - { - npc_anubarak_impale_targetAI(Creature* creature) : NullCreatureAI(creature) { } + npc_anubarak_impale_target(Creature* creature) : NullCreatureAI(creature) { } - void InitializeAI() override - { - if (Creature* anubarak = me->GetInstanceScript()->GetCreature(DATA_ANUBARAK)) - { - DoCastSelf(SPELL_IMPALE_VISUAL); - me->DespawnOrUnsummon(Seconds(6)); - anubarak->AI()->SetGUID(me->GetGUID(), GUID_TYPE_IMPALE); - } - else - me->DespawnOrUnsummon(); - } - }; - - CreatureAI* GetAI(Creature* creature) const override + void InitializeAI() override + { + if (Creature* anubarak = me->GetInstanceScript()->GetCreature(DATA_ANUBARAK)) { - return GetAzjolNerubAI<npc_anubarak_impale_targetAI>(creature); + DoCastSelf(SPELL_IMPALE_VISUAL); + me->DespawnOrUnsummon(6s); + anubarak->AI()->SetGUID(me->GetGUID(), GUID_TYPE_IMPALE); } + else + me->DespawnOrUnsummon(); + } }; -class spell_anubarak_pound : public SpellScriptLoader +class spell_anubarak_pound : public SpellScript { - public: - spell_anubarak_pound() : SpellScriptLoader("spell_anubarak_pound") { } - - class spell_anubarak_pound_SpellScript : public SpellScript - { - PrepareSpellScript(spell_anubarak_pound_SpellScript); + PrepareSpellScript(spell_anubarak_pound); - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_POUND_DAMAGE }); - } - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (Unit* target = GetHitUnit()) - GetCaster()->CastSpell(target, SPELL_POUND_DAMAGE, true); - } + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({ SPELL_POUND_DAMAGE }); + } - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_anubarak_pound_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_APPLY_AURA); - } - }; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (Unit* target = GetHitUnit()) + GetCaster()->CastSpell(target, SPELL_POUND_DAMAGE, true); + } - SpellScript* GetSpellScript() const override - { - return new spell_anubarak_pound_SpellScript(); - } + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_anubarak_pound::HandleDummy, EFFECT_0, SPELL_EFFECT_APPLY_AURA); + } }; -class spell_anubarak_carrion_beetles : public SpellScriptLoader +class spell_anubarak_carrion_beetles : public AuraScript { - public: - spell_anubarak_carrion_beetles() : SpellScriptLoader("spell_anubarak_carrion_beetles") { } + PrepareAuraScript(spell_anubarak_carrion_beetles); - class spell_anubarak_carrion_beetles_AuraScript : public AuraScript - { - public: - PrepareAuraScript(spell_anubarak_carrion_beetles_AuraScript); - - bool Validate(SpellInfo const* /*spell*/) override - { - return ValidateSpellInfo({ SPELL_CARRION_BEETLE }); - } - - void HandlePeriodic(AuraEffect const* /*eff*/) - { - GetCaster()->CastSpell(GetCaster(), SPELL_CARRION_BEETLE, true); - GetCaster()->CastSpell(GetCaster(), SPELL_CARRION_BEETLE, true); - } + bool Validate(SpellInfo const* /*spell*/) override + { + return ValidateSpellInfo({ SPELL_CARRION_BEETLE }); + } - void Register() override - { - OnEffectPeriodic += AuraEffectPeriodicFn(spell_anubarak_carrion_beetles_AuraScript::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); - } - }; + void HandlePeriodic(AuraEffect const* /*eff*/) + { + GetCaster()->CastSpell(GetCaster(), SPELL_CARRION_BEETLE, true); + GetCaster()->CastSpell(GetCaster(), SPELL_CARRION_BEETLE, true); + } - AuraScript* GetAuraScript() const override - { - return new spell_anubarak_carrion_beetles_AuraScript(); - } + void Register() override + { + OnEffectPeriodic += AuraEffectPeriodicFn(spell_anubarak_carrion_beetles::HandlePeriodic, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY); + } }; void AddSC_boss_anub_arak() { - new boss_anub_arak(); + RegisterCreatureAIWithFactory(boss_anub_arak, GetAzjolNerubAI); - new npc_anubarak_anub_ar_darter(); - new npc_anubarak_anub_ar_assassin(); - new npc_anubarak_anub_ar_guardian(); - new npc_anubarak_anub_ar_venomancer(); - new npc_anubarak_impale_target(); + RegisterCreatureAIWithFactory(npc_anubarak_anub_ar_darter, GetAzjolNerubAI); + RegisterCreatureAIWithFactory(npc_anubarak_anub_ar_assassin, GetAzjolNerubAI); + RegisterCreatureAIWithFactory(npc_anubarak_anub_ar_guardian, GetAzjolNerubAI); + RegisterCreatureAIWithFactory(npc_anubarak_anub_ar_venomancer, GetAzjolNerubAI); + RegisterCreatureAIWithFactory(npc_anubarak_impale_target, GetAzjolNerubAI); - new spell_anubarak_pound(); - new spell_anubarak_carrion_beetles(); + RegisterSpellScript(spell_anubarak_pound); + RegisterAuraScript(spell_anubarak_carrion_beetles); } |