mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
fix(Scripts/AzjolNerub): Fix Anubarak impale sequence (#22717)
This commit is contained in:
@@ -746,27 +746,39 @@ void BossAI::UpdateAI(uint32 diff)
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
|
||||
void BossAI::OnSpellCastFinished(SpellInfo const* spellInfo, SpellFinishReason reason)
|
||||
{
|
||||
ScriptedAI::OnSpellCastFinished(spellInfo, reason);
|
||||
// Check if any health check events are pending (i.e. waiting for the boss to stop casting.
|
||||
if (_nextHealthCheck.IsPending() && me->IsInCombat())
|
||||
{
|
||||
_nextHealthCheck.UpdateStatus(HEALTH_CHECK_PROCESSED);
|
||||
// This must be delayed because creature might still have unit state casting at this point, which might break scripts.
|
||||
scheduler.Schedule(1s, [this](TaskContext context)
|
||||
{
|
||||
if (me->HasUnitState(UNIT_STATE_CASTING))
|
||||
context.Repeat();
|
||||
else
|
||||
ProcessHealthCheck();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void BossAI::DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask)
|
||||
{
|
||||
ScriptedAI::DamageTaken(attacker, damage, damagetype, damageSchoolMask);
|
||||
|
||||
if (_nextHealthCheck._valid)
|
||||
if (!_nextHealthCheck.HasBeenProcessed())
|
||||
{
|
||||
if (!_nextHealthCheck._allowedWhileCasting && me->HasUnitState(UNIT_STATE_CASTING))
|
||||
return;
|
||||
|
||||
if (me->HealthBelowPctDamaged(_nextHealthCheck._healthPct, damage))
|
||||
{
|
||||
_nextHealthCheck._exec();
|
||||
_nextHealthCheck._valid = false;
|
||||
|
||||
_healthCheckEvents.remove_if([&](HealthCheckEventData data) -> bool
|
||||
if (!_nextHealthCheck._allowedWhileCasting && me->HasUnitState(UNIT_STATE_CASTING))
|
||||
{
|
||||
return data._healthPct == _nextHealthCheck._healthPct;
|
||||
});
|
||||
_nextHealthCheck.UpdateStatus(HEALTH_CHECK_PENDING);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_healthCheckEvents.empty())
|
||||
_nextHealthCheck = _healthCheckEvents.front();
|
||||
ProcessHealthCheck();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -780,18 +792,32 @@ void BossAI::DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damage
|
||||
*/
|
||||
void BossAI::ScheduleHealthCheckEvent(uint32 healthPct, std::function<void()> exec, bool allowedWhileCasting /*=true*/)
|
||||
{
|
||||
_healthCheckEvents.push_back(HealthCheckEventData(healthPct, exec, true, allowedWhileCasting));
|
||||
_healthCheckEvents.push_back(HealthCheckEventData(healthPct, exec, HEALTH_CHECK_SCHEDULED, allowedWhileCasting));
|
||||
_nextHealthCheck = _healthCheckEvents.front();
|
||||
};
|
||||
|
||||
void BossAI::ScheduleHealthCheckEvent(std::initializer_list<uint8> healthPct, std::function<void()> exec, bool allowedWhileCasting /*=true*/)
|
||||
{
|
||||
for (auto const& checks : healthPct)
|
||||
_healthCheckEvents.push_back(HealthCheckEventData(checks, exec, true, allowedWhileCasting));
|
||||
_healthCheckEvents.push_back(HealthCheckEventData(checks, exec, HEALTH_CHECK_SCHEDULED, allowedWhileCasting));
|
||||
|
||||
_nextHealthCheck = _healthCheckEvents.front();
|
||||
}
|
||||
|
||||
void BossAI::ProcessHealthCheck()
|
||||
{
|
||||
_nextHealthCheck.UpdateStatus(HEALTH_CHECK_PROCESSED);
|
||||
_nextHealthCheck._exec();
|
||||
|
||||
_healthCheckEvents.remove_if([&](HealthCheckEventData data) -> bool
|
||||
{
|
||||
return data._healthPct == _nextHealthCheck._healthPct;
|
||||
});
|
||||
|
||||
if (!_healthCheckEvents.empty())
|
||||
_nextHealthCheck = _healthCheckEvents.front();
|
||||
}
|
||||
|
||||
void BossAI::ScheduleEnrageTimer(uint32 spellId, Milliseconds timer, uint8 textId /*= 0*/)
|
||||
{
|
||||
me->m_Events.AddEventAtOffset([this, spellId, textId]
|
||||
|
||||
Reference in New Issue
Block a user