Scripts/Uldaman: Fix Ironaya crash (#27189)

* Scripts/Uldaman: Fix Ironaya crash
* little code cleanup

* oops

(cherry picked from commit cb4e12bdf0)
This commit is contained in:
Gildor
2021-10-29 19:38:01 +02:00
committed by Shauren
parent 281b0a867e
commit 2cfcecaf26
2 changed files with 55 additions and 65 deletions

View File

@@ -33,82 +33,70 @@ enum Ironaya
SPELL_WSTOMP = 11876
};
class boss_ironaya : public CreatureScript
struct boss_ironaya : public ScriptedAI
{
public:
boss_ironaya(Creature* creature) : ScriptedAI(creature)
{
Initialize();
}
boss_ironaya()
: CreatureScript("boss_ironaya")
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;
if (!bHasCastWstomp && HealthBelowPct(25))
{
DoCast(me, SPELL_WSTOMP);
bHasCastWstomp = true;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetUldamanAI<boss_ironayaAI>(creature);
_hasCastWstomp = true;
DoCastSelf(SPELL_WSTOMP);
}
}
void JustEngagedWith(Unit* /*who*/) override
{
_scheduler.Schedule(3s, [this](TaskContext task)
{
DoCastSelf(SPELL_ARCINGSMASH);
task.Repeat(13s);
});
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
_scheduler.Update(diff, [this]
{
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);
}

View File

@@ -50,4 +50,6 @@ inline AI* GetUldamanAI(T* obj)
return GetInstanceAI<AI>(obj, UldamanScriptName);
}
#define RegisterUldamanCreatureAI(ai_name) RegisterCreatureAIWithFactory(ai_name, GetUldamanAI)
#endif