aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp327
1 files changed, 155 insertions, 172 deletions
diff --git a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
index e61e04fa8e4..0d126ae1fbd 100644
--- a/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
+++ b/src/server/scripts/Northrend/Gundrak/boss_slad_ran.cpp
@@ -70,232 +70,215 @@ enum Misc
DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES = 1
};
-class boss_slad_ran : public CreatureScript
+enum Phase
{
-public:
- boss_slad_ran() : CreatureScript("boss_slad_ran") { }
-
- struct boss_slad_ranAI : public BossAI
- {
- boss_slad_ranAI(Creature* creature) : BossAI(creature, DATA_SLAD_RAN)
- {
- Initialize();
- }
-
- void Initialize()
- {
- uiPoisonNovaTimer = 10 * IN_MILLISECONDS;
- uiPowerfullBiteTimer = 3 * IN_MILLISECONDS;
- uiVenomBoltTimer = 15 * IN_MILLISECONDS;
- uiSpawnTimer = 5 * IN_MILLISECONDS;
- uiPhase = 0;
- }
-
- uint32 uiPoisonNovaTimer;
- uint32 uiPowerfullBiteTimer;
- uint32 uiVenomBoltTimer;
- uint32 uiSpawnTimer;
+ PHASE_NONE = 0,
+ PHASE_SNAKES = 1,
+ PHASE_CONSTRICTORS = 2
+};
- uint8 uiPhase;
+enum TaskGroup
+{
+ GROUP_SNAKES = 0
+};
- GuidSet lWrappedPlayers;
+struct boss_slad_ran : public BossAI
+{
+ boss_slad_ran(Creature* creature) : BossAI(creature, DATA_SLAD_RAN)
+ {
+ Initialize();
+ }
- void Reset() override
- {
- Initialize();
- _Reset();
- lWrappedPlayers.clear();
- }
+ void Initialize()
+ {
+ _phase = Phase::PHASE_NONE;
+ }
- void JustEngagedWith(Unit* who) override
- {
- BossAI::JustEngagedWith(who);
- Talk(SAY_AGGRO);
- }
+ void Reset() override
+ {
+ _Reset();
+ Initialize();
+ _wrappedPlayers.clear();
+ }
- void UpdateAI(uint32 diff) override
- {
- //Return since we have no target
- if (!UpdateVictim())
- return;
+ void JustEngagedWith(Unit* who) override
+ {
+ BossAI::JustEngagedWith(who);
+ Talk(SAY_AGGRO);
+ }
- if (uiPoisonNovaTimer <= diff)
+ void ScheduleTasks() override
+ {
+ scheduler
+ .Schedule(10s, [this](TaskContext task)
{
DoCastVictim(SPELL_POISON_NOVA);
Talk(EMOTE_NOVA);
- uiPoisonNovaTimer = 15*IN_MILLISECONDS;
- } else uiPoisonNovaTimer -= diff;
-
- if (uiPowerfullBiteTimer <= diff)
+ task.Repeat(15s);
+ })
+ .Schedule(3s, [this](TaskContext task)
{
DoCastVictim(SPELL_POWERFULL_BITE);
- uiPowerfullBiteTimer = 10*IN_MILLISECONDS;
- } else uiPowerfullBiteTimer -= diff;
-
- if (uiVenomBoltTimer <= diff)
+ task.Repeat(10s);
+ })
+ .Schedule(15s, [this](TaskContext task)
{
DoCastVictim(SPELL_VENOM_BOLT);
- uiVenomBoltTimer = 10*IN_MILLISECONDS;
- } else uiVenomBoltTimer -= diff;
+ task.Repeat(10s);
+ });
+ }
- if (uiPhase)
- {
- if (uiSpawnTimer <= diff)
- {
- if (uiPhase == 1)
- for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
- me->SummonCreature(CREATURE_SNAKE, SpawnLoc[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20s);
- if (uiPhase == 2)
- for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
- me->SummonCreature(CREATURE_CONSTRICTORS, SpawnLoc[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20s);
- uiSpawnTimer = 5*IN_MILLISECONDS;
- } else uiSpawnTimer -= diff;
- }
+ void UpdateAI(uint32 diff) override
+ {
+ if (!UpdateVictim())
+ return;
- if (uiPhase == 0 && HealthBelowPct(30))
- {
- Talk(SAY_SUMMON_SNAKES);
- uiPhase = 1;
- }
+ scheduler.Update(diff, [this]
+ {
+ DoMeleeAttackIfReady();
+ });
+ }
+
+ void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) override
+ {
+ if (_phase == Phase::PHASE_NONE && HealthBelowPct(30))
+ {
+ Talk(SAY_SUMMON_SNAKES);
+ _phase = Phase::PHASE_SNAKES;
- if (uiPhase == 1 && HealthBelowPct(25))
+ scheduler.Schedule(5s, GROUP_SNAKES, [this](TaskContext task)
{
- Talk(SAY_SUMMON_CONSTRICTORS);
- uiPhase = 2;
- }
+ for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
+ me->SummonCreature(CREATURE_SNAKE, SpawnLoc[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20s);
- DoMeleeAttackIfReady();
+ task.Repeat();
+ });
}
- void JustDied(Unit* /*killer*/) override
+ if (_phase == Phase::PHASE_SNAKES && HealthBelowPct(25))
{
- _JustDied();
- Talk(EMOTE_ACTIVATE_ALTAR);
- Talk(SAY_DEATH);
- }
+ Talk(SAY_SUMMON_CONSTRICTORS);
+ _phase = Phase::PHASE_CONSTRICTORS;
- void KilledUnit(Unit* who) override
- {
- if (who->GetTypeId() == TYPEID_PLAYER)
- Talk(SAY_SLAY);
- }
+ scheduler.CancelGroup(GROUP_SNAKES);
+ scheduler.Schedule(5s, [this](TaskContext task)
+ {
+ for (uint8 i = 0; i < DUNGEON_MODE(3, 5); ++i)
+ me->SummonCreature(CREATURE_CONSTRICTORS, SpawnLoc[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20s);
- void JustSummoned(Creature* summon) override
- {
- summon->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
- summons.Summon(summon);
+ task.Repeat();
+ });
}
+ }
- void SetGUID(ObjectGuid const& guid, int32 id) override
- {
- if (id == DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES)
- lWrappedPlayers.insert(guid);
- }
+ void JustDied(Unit* /*killer*/) override
+ {
+ _JustDied();
+ Talk(EMOTE_ACTIVATE_ALTAR);
+ Talk(SAY_DEATH);
+ }
- bool WasWrapped(ObjectGuid guid)
- {
- return lWrappedPlayers.count(guid) != 0;
- }
- };
+ void KilledUnit(Unit* who) override
+ {
+ if (who->GetTypeId() == TYPEID_PLAYER)
+ Talk(SAY_SLAY);
+ }
+
+ void JustSummoned(Creature* summon) override
+ {
+ summon->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
+ summons.Summon(summon);
+ }
- CreatureAI* GetAI(Creature* creature) const override
+ void SetGUID(ObjectGuid const& guid, int32 id) override
{
- return GetGundrakAI<boss_slad_ranAI>(creature);
+ if (id == DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES)
+ _wrappedPlayers.insert(guid);
}
+
+ bool WasWrapped(ObjectGuid guid) const
+ {
+ return _wrappedPlayers.count(guid) != 0;
+ }
+
+private:
+ Phase _phase;
+ GuidSet _wrappedPlayers;
};
-class npc_slad_ran_constrictor : public CreatureScript
+struct npc_slad_ran_constrictor : public ScriptedAI
{
-public:
- npc_slad_ran_constrictor() : CreatureScript("npc_slad_ran_constrictor") { }
+ npc_slad_ran_constrictor(Creature* creature) : ScriptedAI(creature) { }
- CreatureAI* GetAI(Creature* creature) const override
+ void Reset() override
{
- return GetGundrakAI<npc_slad_ran_constrictorAI>(creature);
+ _scheduler.CancelAll();
}
- struct npc_slad_ran_constrictorAI : public ScriptedAI
+ void JustEngagedWith(Unit* /*who*/) override
{
- npc_slad_ran_constrictorAI(Creature* creature) : ScriptedAI(creature)
+ _scheduler.Schedule(2s, [this](TaskContext task)
{
- uiGripOfSladRanTimer = 1 * IN_MILLISECONDS;
- }
+ Unit* target = me->GetVictim();
- uint32 uiGripOfSladRanTimer;
+ DoCast(target, SPELL_GRIP_OF_SLAD_RAN);
- void Reset() override
- {
- uiGripOfSladRanTimer = 1*IN_MILLISECONDS;
- }
-
- void UpdateAI(uint32 diff) override
- {
- if (!UpdateVictim())
- return;
-
- if (uiGripOfSladRanTimer <= diff)
+ Aura* grip = target->GetAura(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
+ if (grip && grip->GetStackAmount() == 5)
{
- Unit* target = me->GetVictim();
+ target->RemoveAurasDueToSpell(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
+ target->CastSpell(target, SPELL_SNAKE_WRAP, true);
- DoCast(target, SPELL_GRIP_OF_SLAD_RAN);
- uiGripOfSladRanTimer = urand(3, 6)*IN_MILLISECONDS;
+ if (TempSummon* _me = me->ToTempSummon())
+ if (Unit* summoner = _me->GetSummonerUnit())
+ if (Creature* sladran = summoner->ToCreature())
+ sladran->AI()->SetGUID(target->GetGUID(), DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES);
- Aura* grip = target->GetAura(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
- if (grip && grip->GetStackAmount() == 5)
- {
- target->RemoveAurasDueToSpell(SPELL_GRIP_OF_SLAD_RAN, me->GetGUID());
- target->CastSpell(target, SPELL_SNAKE_WRAP, true);
+ me->DespawnOrUnsummon();
+ }
- if (TempSummon* _me = me->ToTempSummon())
- if (Unit* summoner = _me->GetSummonerUnit())
- if (Creature* sladran = summoner->ToCreature())
- sladran->AI()->SetGUID(target->GetGUID(), DATA_SNAKES_WHYD_IT_HAVE_TO_BE_SNAKES);
+ task.Repeat(3s, 6s);
+ });
+ }
- me->DespawnOrUnsummon();
- }
- } else uiGripOfSladRanTimer -= diff;
- }
- };
+ void UpdateAI(uint32 diff) override
+ {
+ if (!UpdateVictim())
+ return;
+ _scheduler.Update(diff);
+ }
+private:
+ TaskScheduler _scheduler;
};
-class npc_slad_ran_viper : public CreatureScript
+struct npc_slad_ran_viper : public ScriptedAI
{
-public:
- npc_slad_ran_viper() : CreatureScript("npc_slad_ran_viper") { }
+ npc_slad_ran_viper(Creature* creature) : ScriptedAI(creature) { }
- CreatureAI* GetAI(Creature* creature) const override
+ void Reset() override
{
- return GetGundrakAI<npc_slad_ran_viperAI>(creature);
+ _scheduler.CancelAll();
}
- struct npc_slad_ran_viperAI : public ScriptedAI
+ void JustEngagedWith(Unit* /*who*/) override
{
- npc_slad_ran_viperAI(Creature* creature) : ScriptedAI(creature)
+ _scheduler.Schedule(2s, [this](TaskContext task)
{
- uiVenomousBiteTimer = 2 * IN_MILLISECONDS;
- }
-
- uint32 uiVenomousBiteTimer;
-
- void Reset() override
- {
- uiVenomousBiteTimer = 2*IN_MILLISECONDS;
- }
-
- void UpdateAI(uint32 diff) override
- {
- if (!UpdateVictim())
- return;
+ DoCastVictim(SPELL_VENOMOUS_BITE);
+ task.Repeat(10s);
+ });
+ }
- if (uiVenomousBiteTimer <= diff)
- {
- DoCastVictim(SPELL_VENOMOUS_BITE);
- uiVenomousBiteTimer = 10*IN_MILLISECONDS;
- } else uiVenomousBiteTimer -= diff;
- }
- };
+ void UpdateAI(uint32 diff) override
+ {
+ if (!UpdateVictim())
+ return;
+ _scheduler.Update(diff);
+ }
+private:
+ TaskScheduler _scheduler;
};
class achievement_snakes_whyd_it_have_to_be_snakes : public AchievementCriteriaScript
@@ -308,7 +291,7 @@ class achievement_snakes_whyd_it_have_to_be_snakes : public AchievementCriteriaS
if (!target)
return false;
- if (boss_slad_ran::boss_slad_ranAI* sladRanAI = CAST_AI(boss_slad_ran::boss_slad_ranAI, target->GetAI()))
+ if (boss_slad_ran* sladRanAI = CAST_AI(boss_slad_ran, target->GetAI()))
return !sladRanAI->WasWrapped(player->GetGUID());
return false;
}
@@ -316,8 +299,8 @@ class achievement_snakes_whyd_it_have_to_be_snakes : public AchievementCriteriaS
void AddSC_boss_slad_ran()
{
- new boss_slad_ran();
- new npc_slad_ran_constrictor();
- new npc_slad_ran_viper();
+ RegisterCreatureAIWithFactory(boss_slad_ran, GetGundrakAI);
+ RegisterCreatureAIWithFactory(npc_slad_ran_constrictor, GetGundrakAI);
+ RegisterCreatureAIWithFactory(npc_slad_ran_viper, GetGundrakAI);
new achievement_snakes_whyd_it_have_to_be_snakes();
}