mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 00:18:43 +01:00
Core/Scripts: Added ExecuteEvent BossAI hook designed to contain event code which would otherwise be in while (uint32 eventId = events.ExecuteEvent()) switch blocks. This allows to define a base class sharing spells with other scripts
This commit is contained in:
@@ -624,6 +624,22 @@ void BossAI::SummonedCreatureDespawn(Creature* summon)
|
||||
summons.Despawn(summon);
|
||||
}
|
||||
|
||||
void BossAI::UpdateAI(uint32 const diff)
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
events.Update(diff);
|
||||
|
||||
if (me->HasUnitState(UNIT_STAT_CASTING))
|
||||
return;
|
||||
|
||||
while (uint32 eventId = events.ExecuteEvent())
|
||||
ExecuteEvent(eventId);
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
|
||||
// SD2 grid searchers.
|
||||
Creature* GetClosestCreatureWithEntry(WorldObject* source, uint32 entry, float maxSearchRange, bool alive /*= true*/)
|
||||
{
|
||||
|
||||
@@ -266,7 +266,13 @@ class BossAI : public ScriptedAI
|
||||
void JustSummoned(Creature* summon);
|
||||
void SummonedCreatureDespawn(Creature* summon);
|
||||
|
||||
void UpdateAI(uint32 const diff) = 0;
|
||||
virtual void UpdateAI(uint32 const diff);
|
||||
|
||||
// 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
|
||||
// is supposed to run more than once
|
||||
virtual void ExecuteEvent(uint32 const eventId) { }
|
||||
|
||||
void Reset() { _Reset(); }
|
||||
void EnterCombat(Unit* /*who*/) { _EnterCombat(); }
|
||||
@@ -296,7 +302,7 @@ class BossAI : public ScriptedAI
|
||||
|
||||
private:
|
||||
BossBoundaryMap const* const _boundary;
|
||||
const uint32 _bossId;
|
||||
uint32 const _bossId;
|
||||
};
|
||||
|
||||
// SD2 grid searchers.
|
||||
|
||||
Reference in New Issue
Block a user