mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-09 05:41:09 +00:00
feat(Core/AI): Implement ScheduleTimedEvent() helper (#17813)
This commit is contained in:
@@ -311,6 +311,29 @@ Creature* ScriptedAI::DoSpawnCreature(uint32 entry, float offsetX, float offsetY
|
||||
return me->SummonCreature(entry, me->GetPositionX() + offsetX, me->GetPositionY() + offsetY, me->GetPositionZ() + offsetZ, angle, TempSummonType(type), despawntime);
|
||||
}
|
||||
|
||||
void ScriptedAI::ScheduleTimedEvent(Milliseconds timer, std::function<void()> exec, Milliseconds repeatMin, Milliseconds repeatMax, uint32 uniqueId)
|
||||
{
|
||||
if (uniqueId && IsUniqueTimedEventDone(uniqueId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
scheduler.Schedule(timer, [exec, repeatMin, repeatMax, uniqueId](TaskContext context)
|
||||
{
|
||||
exec();
|
||||
|
||||
if (!uniqueId)
|
||||
{
|
||||
repeatMax > 0s ? context.Repeat(repeatMin, repeatMax) : context.Repeat(repeatMin);
|
||||
}
|
||||
});
|
||||
|
||||
if (uniqueId)
|
||||
{
|
||||
SetUniqueTimedEventDone(uniqueId);
|
||||
}
|
||||
}
|
||||
|
||||
SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mechanic, SelectTargetType targets, uint32 powerCostMin, uint32 powerCostMax, float rangeMin, float rangeMax, SelectEffect effects)
|
||||
{
|
||||
//No target so we can't cast
|
||||
@@ -588,6 +611,7 @@ void BossAI::_Reset()
|
||||
events.Reset();
|
||||
scheduler.CancelAll();
|
||||
summons.DespawnAll();
|
||||
ClearUniqueTimedEventsDone();
|
||||
_healthCheckEvents.clear();
|
||||
if (instance)
|
||||
instance->SetBossState(_bossId, NOT_STARTED);
|
||||
|
||||
Reference in New Issue
Block a user