feat(Core/Scripting): Implement SetInvincibility() to prevent creatur… (#20508)

This commit is contained in:
Andrew
2024-11-11 00:22:03 -03:00
committed by GitHub
parent d817f67658
commit e741a9a87f
3 changed files with 24 additions and 21 deletions

View File

@@ -62,13 +62,20 @@ public:
void Reset() override
{
_summonedRend = false;
if (instance->GetBossState(DATA_GYTH) == IN_PROGRESS)
{
instance->SetBossState(DATA_GYTH, NOT_STARTED);
summons.DespawnAll();
me->DespawnOrUnsummon();
}
SetInvincibility(true); // Don't let boss die before summoning Rend.
ScheduleHealthCheckEvent(25, [&] {
DoCastAOE(SPELL_SUMMON_REND, true);
me->RemoveAura(SPELL_REND_MOUNTS);
SetInvincibility(false);
});
}
void JustEngagedWith(Unit* /*who*/) override
@@ -104,21 +111,6 @@ public:
instance->SetBossState(DATA_GYTH, DONE);
}
void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*type*/, SpellSchoolMask /*school*/) override
{
if (!_summonedRend && me->HealthBelowPctDamaged(25, damage))
{
if (damage >= me->GetHealth())
{
// Let creature fall to 1 HP but prevent it from dying before boss is summoned.
damage = me->GetHealth() - 1;
}
DoCast(me, SPELL_SUMMON_REND, true);
me->RemoveAura(SPELL_REND_MOUNTS);
_summonedRend = true;
}
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
@@ -173,9 +165,6 @@ public:
}
DoMeleeAttackIfReady();
}
private:
bool _summonedRend;
};
CreatureAI* GetAI(Creature* creature) const override