aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp114
-rw-r--r--src/server/scripts/EasternKingdoms/Uldaman/uldaman.h2
2 files changed, 53 insertions, 63 deletions
diff --git a/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp b/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp
index 13a23d59238..5c331eb2c65 100644
--- a/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp
+++ b/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp
@@ -33,82 +33,70 @@ enum Ironaya
SPELL_WSTOMP = 11876
};
-class boss_ironaya : public CreatureScript
+struct boss_ironaya : public ScriptedAI
{
- public:
-
- boss_ironaya()
- : CreatureScript("boss_ironaya")
+ boss_ironaya(Creature* creature) : ScriptedAI(creature)
+ {
+ Initialize();
+ }
+
+ void Initialize()
+ {
+ _hasCastKnockaway = false;
+ _hasCastWstomp = false;
+ }
+
+ void Reset() override
+ {
+ _scheduler.CancelAll();
+ Initialize();
+ }
+
+ void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
+ {
+ if (!_hasCastKnockaway && HealthBelowPct(50) && me->GetVictim())
{
+ _hasCastKnockaway = true;
+ DoCastVictim(SPELL_KNOCKAWAY, true);
+ ResetThreat(me->GetVictim(), me);
}
- struct boss_ironayaAI : public ScriptedAI
+ if (!_hasCastWstomp && HealthBelowPct(25))
{
- boss_ironayaAI(Creature* creature) : ScriptedAI(creature)
- {
- Initialize();
- }
-
- void Initialize()
- {
- uiArcingTimer = 3000;
- bHasCastKnockaway = false;
- bHasCastWstomp = false;
- }
-
- uint32 uiArcingTimer;
- bool bHasCastWstomp;
- bool bHasCastKnockaway;
-
- void Reset() override
- {
- Initialize();
- }
-
- void JustEngagedWith(Unit* /*who*/) override { }
-
- void UpdateAI(uint32 uiDiff) override
- {
- //Return since we have no target
- if (!UpdateVictim())
- return;
-
- //If we are <50% hp do knockaway ONCE
- if (!bHasCastKnockaway && HealthBelowPct(50) && me->GetVictim())
- {
- DoCastVictim(SPELL_KNOCKAWAY, true);
- me->GetThreatManager().ResetThreat(me->EnsureVictim());
-
- //Shouldn't cast this agian
- bHasCastKnockaway = true;
- }
-
- //uiArcingTimer
- if (uiArcingTimer <= uiDiff)
- {
- DoCast(me, SPELL_ARCINGSMASH);
- uiArcingTimer = 13000;
- } else uiArcingTimer -= uiDiff;
+ _hasCastWstomp = true;
+ DoCastSelf(SPELL_WSTOMP);
+ }
+ }
- if (!bHasCastWstomp && HealthBelowPct(25))
- {
- DoCast(me, SPELL_WSTOMP);
- bHasCastWstomp = true;
- }
+ void JustEngagedWith(Unit* /*who*/) override
+ {
+ _scheduler.Schedule(3s, [this](TaskContext task)
+ {
+ DoCastSelf(SPELL_ARCINGSMASH);
+ task.Repeat(13s);
+ });
+ }
- DoMeleeAttackIfReady();
- }
- };
+ void UpdateAI(uint32 diff) override
+ {
+ if (!UpdateVictim())
+ return;
- CreatureAI* GetAI(Creature* creature) const override
+ _scheduler.Update(diff, [this]
{
- return GetUldamanAI<boss_ironayaAI>(creature);
- }
+ DoMeleeAttackIfReady();
+ });
+ }
+
+private:
+ TaskScheduler _scheduler;
+ bool _hasCastKnockaway;
+ bool _hasCastWstomp;
};
//This is the actual function called only once durring InitScripts()
//It must define all handled functions that are to be run in this script
void AddSC_boss_ironaya()
{
- new boss_ironaya();
+ RegisterUldamanCreatureAI(boss_ironaya);
}
diff --git a/src/server/scripts/EasternKingdoms/Uldaman/uldaman.h b/src/server/scripts/EasternKingdoms/Uldaman/uldaman.h
index 595354f1c92..ea6ccdbbe34 100644
--- a/src/server/scripts/EasternKingdoms/Uldaman/uldaman.h
+++ b/src/server/scripts/EasternKingdoms/Uldaman/uldaman.h
@@ -50,4 +50,6 @@ inline AI* GetUldamanAI(T* obj)
return GetInstanceAI<AI>(obj, UldamanScriptName);
}
+#define RegisterUldamanCreatureAI(ai_name) RegisterCreatureAIWithFactory(ai_name, GetUldamanAI)
+
#endif