feat(Core/AI): Implement ScheduleHealthCheckEvent() for events that fire … (#15275)

This commit is contained in:
Skjalf
2023-03-04 23:25:43 -03:00
committed by GitHub
parent 7d970d057c
commit 81d831faac
3 changed files with 54 additions and 20 deletions

View File

@@ -430,6 +430,14 @@ private:
bool _isHeroic;
};
struct HealthCheckEventData
{
HealthCheckEventData(uint8 healthPct, std::function<void()> exec) : _healthPct(healthPct), _exec(exec) { };
uint8 _healthPct;
std::function<void()> _exec;
};
class BossAI : public ScriptedAI
{
public:
@@ -440,12 +448,15 @@ public:
bool CanRespawn() override;
void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask) override;
void JustSummoned(Creature* summon) override;
void SummonedCreatureDespawn(Creature* summon) override;
void SummonedCreatureDespawnAll() override;
void UpdateAI(uint32 diff) override;
void ScheduleHealthCheckEvent(uint32 healthPct, std::function<void()> exec);
// Hook used to execute events scheduled into EventMap without the need
// to override UpdateAI
// note: You must re-schedule the event within this method if the event
@@ -464,6 +475,7 @@ protected:
void _JustEngagedWith();
void _JustDied();
void _JustReachedHome() { me->setActive(false); }
[[nodiscard]] bool _ProccessHealthCheckEvent(uint8 healthPct, uint32 damage, std::function<void()> exec) const;
void TeleportCheaters();
@@ -473,6 +485,7 @@ protected:
private:
uint32 const _bossId;
std::list<HealthCheckEventData> _healthCheckEvents;
};
class WorldBossAI : public ScriptedAI