diff --git a/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp b/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp index d046864c1..3af92dd8a 100644 --- a/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp +++ b/src/server/scripts/Outland/TempestKeep/botanica/boss_high_botanist_freywinn.cpp @@ -40,121 +40,84 @@ enum Spells SPELL_PLANT_RED = 34763 }; -enum Misc +enum Npcs { - NPC_FRAYER = 19953, - - EVENT_SUMMON_SEEDLING = 1, - EVENT_TREE_FORM = 2, - EVENT_CHECK_FRAYERS = 3, - EVENT_RESTORE_COMBAT = 4 + NPC_FRAYER = 19953 }; -class boss_high_botanist_freywinn : public CreatureScript +struct boss_high_botanist_freywinn : public BossAI { -public: - boss_high_botanist_freywinn() : CreatureScript("boss_high_botanist_freywinn") + boss_high_botanist_freywinn(Creature* creature) : BossAI(creature, DATA_HIGH_BOTANIST_FREYWINN) { } + + void EnterCombat(Unit* /*who*/) override { - } + _EnterCombat(); + Talk(SAY_AGGRO); - struct boss_high_botanist_freywinnAI : public BossAI - { - boss_high_botanist_freywinnAI(Creature* creature) : BossAI(creature, DATA_HIGH_BOTANIST_FREYWINN) { } - - void Reset() override + scheduler.Schedule(6s, [this](TaskContext context) { - _Reset(); - } - - void EnterCombat(Unit* /*who*/) override - { - _EnterCombat(); - Talk(SAY_AGGRO); - - events.ScheduleEvent(EVENT_SUMMON_SEEDLING, 6000); - events.ScheduleEvent(EVENT_TREE_FORM, 30000); - } - - void KilledUnit(Unit* victim) override - { - if (victim->GetTypeId() == TYPEID_PLAYER) - Talk(SAY_KILL); - } - - void JustDied(Unit* /*killer*/) override - { - Talk(SAY_DEATH); - _JustDied(); - } - - void SummonedCreatureDies(Creature* summon, Unit*) override - { - summons.Despawn(summon); - } - - void UpdateAI(uint32 diff) override - { - if (!UpdateVictim()) - return; - - events.Update(diff); - if (!events.IsInPhase(1) && me->HasUnitState(UNIT_STATE_CASTING)) - return; - - switch (events.ExecuteEvent()) + if (roll_chance_i(20)) { - case EVENT_SUMMON_SEEDLING: - if (roll_chance_i(20)) - Talk(SAY_OOC_RANDOM); - me->CastSpell(me, RAND(SPELL_PLANT_WHITE, SPELL_PLANT_GREEN, SPELL_PLANT_BLUE, SPELL_PLANT_RED), false); - events.ScheduleEvent(EVENT_SUMMON_SEEDLING, 6000); - break; - case EVENT_TREE_FORM: - events.Reset(); - events.SetPhase(1); - events.ScheduleEvent(EVENT_CHECK_FRAYERS, 1000); - events.ScheduleEvent(EVENT_TREE_FORM, 75000); - events.ScheduleEvent(EVENT_RESTORE_COMBAT, 46000); - - Talk(SAY_TREE); - me->RemoveAllAuras(); - me->GetMotionMaster()->MoveIdle(); - me->GetMotionMaster()->Clear(false); - - me->CastSpell(me, SPELL_SUMMON_FRAYER, true); - me->CastSpell(me, SPELL_TRANQUILITY, true); - me->CastSpell(me, SPELL_TREE_FORM, true); - break; - case EVENT_RESTORE_COMBAT: - events.SetPhase(0); - events.ScheduleEvent(EVENT_SUMMON_SEEDLING, 6000); - me->GetMotionMaster()->MoveChase(me->GetVictim()); - break; - case EVENT_CHECK_FRAYERS: - if (!summons.HasEntry(NPC_FRAYER)) - { - me->InterruptNonMeleeSpells(true); - me->RemoveAllAuras(); - events.RescheduleEvent(EVENT_RESTORE_COMBAT, 0); - events.RescheduleEvent(EVENT_TREE_FORM, 30000); - break; - } - events.ScheduleEvent(EVENT_CHECK_FRAYERS, 500); - break; + Talk(SAY_OOC_RANDOM); } - if (!events.IsInPhase(1)) - DoMeleeAttackIfReady(); - } - }; + DoCastAOE(RAND(SPELL_PLANT_WHITE, SPELL_PLANT_GREEN, SPELL_PLANT_BLUE, SPELL_PLANT_RED)); + context.Repeat(); + }).Schedule(30s, [this](TaskContext context) + { + scheduler.CancelAll(); - CreatureAI* GetAI(Creature* creature) const override + Talk(SAY_TREE); + me->RemoveAllAuras(); + me->GetMotionMaster()->MoveIdle(); + me->GetMotionMaster()->Clear(false); + + DoCastSelf(SPELL_SUMMON_FRAYER, true); + DoCastSelf(SPELL_TRANQUILITY, true); + DoCastSelf(SPELL_TREE_FORM, true); + + scheduler.Schedule(45s, [this](TaskContext) + { + ResumeEncounter(); + }); + + context.Repeat(75s); + }); + } + + void ResumeEncounter() { - return GetTheBotanicaAI(creature); + me->GetMotionMaster()->MoveChase(me->GetVictim()); + me->RemoveAurasDueToSpell(SPELL_TREE_FORM); + me->InterruptNonMeleeSpells(false); + } + + void KilledUnit(Unit* victim) override + { + if (victim->IsPlayer()) + { + Talk(SAY_KILL); + } + } + + void JustDied(Unit* /*killer*/) override + { + Talk(SAY_DEATH); + _JustDied(); + } + + void SummonedCreatureDies(Creature* summon, Unit*) override + { + summons.Despawn(summon); + + if (!summons.HasEntry(NPC_FRAYER)) + { + ResumeEncounter(); + } } }; void AddSC_boss_high_botanist_freywinn() { - new boss_high_botanist_freywinn(); + RegisterTheBotanicaCreatureAI(boss_high_botanist_freywinn); }