refactor(Core): AddEventAtOffset (#23140)

This commit is contained in:
天鹭
2025-10-17 12:09:57 +08:00
committed by GitHub
parent 762f5a7158
commit 058f7acac6
47 changed files with 141 additions and 139 deletions
+4 -4
View File
@@ -75,7 +75,7 @@ void EventProcessor::Update(uint32 p_time)
// Reschedule non deletable events to be checked at // Reschedule non deletable events to be checked at
// the next update tick // the next update tick
AddEvent(event, CalculateTime(1), false, 0); AddEvent(event, CalculateTime(1), false);
} }
} }
@@ -133,13 +133,13 @@ void EventProcessor::CancelEventGroup(uint8 group)
} }
} }
void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime, uint8 eventGroup) void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime /*= true*/, uint8 eventGroup /*= 0*/)
{ {
if (set_addtime) if (set_addtime)
Event->m_addTime = m_time; Event->m_addTime = m_time;
Event->m_execTime = e_time; Event->m_execTime = e_time;
Event->m_eventGroup = eventGroup; Event->m_eventGroup = eventGroup;
m_events.insert(std::pair<uint64, BasicEvent*>(e_time, Event)); m_events.emplace(e_time, Event);
} }
void EventProcessor::ModifyEventTime(BasicEvent* event, Milliseconds newTime) void EventProcessor::ModifyEventTime(BasicEvent* event, Milliseconds newTime)
@@ -151,7 +151,7 @@ void EventProcessor::ModifyEventTime(BasicEvent* event, Milliseconds newTime)
event->m_execTime = newTime.count(); event->m_execTime = newTime.count();
m_events.erase(itr); m_events.erase(itr);
m_events.insert(std::pair<uint64, BasicEvent*>(newTime.count(), event)); m_events.emplace(newTime.count(), event);
break; break;
} }
} }
+11 -11
View File
@@ -100,20 +100,19 @@ class EventProcessor
void Update(uint32 p_time); void Update(uint32 p_time);
void KillAllEvents(bool force); void KillAllEvents(bool force);
void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true) { AddEvent(Event, e_time, set_addtime, 0); };
void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime, uint8 eventGroup); void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true, uint8 eventGroup = 0);
template<typename T> template<typename T>
is_lambda_event<T> AddEvent(T&& event, Milliseconds e_time, bool set_addtime = true) { AddEvent(new LambdaBasicEvent<T>(std::move(event)), e_time, set_addtime); } is_lambda_event<T> AddEvent(T&& event, Milliseconds e_time, bool set_addtime = true, uint8 eventGroup = 0) { AddEvent(new LambdaBasicEvent<T>(std::move(event)), e_time.count(), set_addtime, eventGroup); }
void AddEventAtOffset(BasicEvent* event, Milliseconds offset) { AddEvent(event, CalculateTime(offset.count()), true, 0); }
void AddEventAtOffset(BasicEvent* event, Milliseconds offset, Milliseconds offset2) { AddEvent(event, CalculateTime(randtime(offset, offset2).count()), true, false); } void AddEventAtOffset(BasicEvent* event, Milliseconds offset, uint8 eventGroup = 0) { AddEvent(event, CalculateTime(offset.count()), true, eventGroup); }
template<typename T> template<typename T>
is_lambda_event<T> AddEventAtOffset(T&& event, Milliseconds offset, uint8 eventGroup) { AddEvent(new LambdaBasicEvent<T>(std::move(event)), CalculateTime(offset.count()), true, eventGroup); }; is_lambda_event<T> AddEventAtOffset(T&& event, Milliseconds offset, uint8 eventGroup = 0) { AddEventAtOffset(new LambdaBasicEvent<T>(std::move(event)), offset, eventGroup); };
void AddEventAtOffset(BasicEvent* event, Milliseconds offset, Milliseconds offset2, uint8 eventGroup = 0) { AddEvent(event, CalculateTime(randtime(offset, offset2).count()), true, eventGroup); }
template<typename T> template<typename T>
is_lambda_event<T> AddEventAtOffset(T&& event, Milliseconds offset, Milliseconds offset2, uint8 eventGroup) { AddEvent(new LambdaBasicEvent<T>(std::move(event)), CalculateTime(randtime(offset, offset2).count()), true, eventGroup); }; is_lambda_event<T> AddEventAtOffset(T&& event, Milliseconds offset, Milliseconds offset2, uint8 eventGroup = 0) { AddEventAtOffset(new LambdaBasicEvent<T>(std::move(event)), offset, offset2, eventGroup); };
template<typename T>
is_lambda_event<T> AddEventAtOffset(T&& event, Milliseconds offset) { AddEventAtOffset(new LambdaBasicEvent<T>(std::move(event)), offset); }
template<typename T>
is_lambda_event<T> AddEventAtOffset(T&& event, Milliseconds offset, Milliseconds offset2) { AddEventAtOffset(new LambdaBasicEvent<T>(std::move(event)), offset, offset2); }
void ModifyEventTime(BasicEvent* event, Milliseconds newTime); void ModifyEventTime(BasicEvent* event, Milliseconds newTime);
[[nodiscard]] uint64 CalculateTime(uint64 t_offset) const; [[nodiscard]] uint64 CalculateTime(uint64 t_offset) const;
@@ -121,6 +120,7 @@ class EventProcessor
[[nodiscard]] uint64 CalculateQueueTime(uint64 delay) const; [[nodiscard]] uint64 CalculateQueueTime(uint64 delay) const;
void CancelEventGroup(uint8 group); void CancelEventGroup(uint8 group);
bool HaveEventList() const { return !m_events.empty(); }
protected: protected:
uint64 m_time{0}; uint64 m_time{0};
@@ -366,7 +366,7 @@ void BattlegroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount)
void BattlegroundQueue::AddEvent(BasicEvent* Event, uint64 e_time) void BattlegroundQueue::AddEvent(BasicEvent* Event, uint64 e_time)
{ {
m_events.AddEvent(Event, m_events.CalculateTime(e_time)); m_events.AddEventAtOffset(Event, Milliseconds(e_time));
} }
bool BattlegroundQueue::IsPlayerInvitedToRatedArena(ObjectGuid pl_guid) bool BattlegroundQueue::IsPlayerInvitedToRatedArena(ObjectGuid pl_guid)
@@ -2159,12 +2159,12 @@ void Creature::Respawn(bool force)
} }
} }
void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds forceRespawnTimer) void Creature::ForcedDespawn(Milliseconds timeMSToDespawn, Seconds forceRespawnTimer)
{ {
if (timeMSToDespawn) if (timeMSToDespawn > 0ms)
{ {
ForcedDespawnDelayEvent* pEvent = new ForcedDespawnDelayEvent(*this, forceRespawnTimer); ForcedDespawnDelayEvent* pEvent = new ForcedDespawnDelayEvent(*this, forceRespawnTimer);
m_Events.AddEvent(pEvent, m_Events.CalculateTime(timeMSToDespawn)); m_Events.AddEventAtOffset(pEvent, timeMSToDespawn);
return; return;
} }
@@ -2182,9 +2182,9 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds forceRespawnTimer)
void Creature::DespawnOrUnsummon(Milliseconds msTimeToDespawn /*= 0ms*/, Seconds forcedRespawnTimer /*= 0s*/) void Creature::DespawnOrUnsummon(Milliseconds msTimeToDespawn /*= 0ms*/, Seconds forcedRespawnTimer /*= 0s*/)
{ {
if (TempSummon* summon = this->ToTempSummon()) if (TempSummon* summon = this->ToTempSummon())
summon->UnSummon(msTimeToDespawn.count()); summon->UnSummon(msTimeToDespawn);
else else
ForcedDespawn(msTimeToDespawn.count(), forcedRespawnTimer); ForcedDespawn(msTimeToDespawn, forcedRespawnTimer);
} }
void Creature::DespawnOnEvade(Seconds respawnDelay) void Creature::DespawnOnEvade(Seconds respawnDelay)
@@ -2464,7 +2464,7 @@ void Creature::CallAssistance(Unit* target /*= nullptr*/)
e->AddAssistant((*assistList.begin())->GetGUID()); e->AddAssistant((*assistList.begin())->GetGUID());
assistList.pop_front(); assistList.pop_front();
} }
m_Events.AddEvent(e, m_Events.CalculateTime(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY))); m_Events.AddEventAtOffset(e, Milliseconds(sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY)));
} }
} }
} }
@@ -3762,7 +3762,7 @@ void Creature::ModifyThreatPercentTemp(Unit* victim, int32 percent, Milliseconds
} }
TemporaryThreatModifierEvent* pEvent = new TemporaryThreatModifierEvent(*this, victim->GetGUID(), currentThreat); TemporaryThreatModifierEvent* pEvent = new TemporaryThreatModifierEvent(*this, victim->GetGUID(), currentThreat);
m_Events.AddEvent(pEvent, m_Events.CalculateTime(duration.count())); m_Events.AddEventAtOffset(pEvent, duration);
} }
} }
+1 -1
View File
@@ -505,7 +505,7 @@ protected:
bool IsAlwaysDetectableFor(WorldObject const* seer) const override; bool IsAlwaysDetectableFor(WorldObject const* seer) const override;
private: private:
void ForcedDespawn(uint32 timeMSToDespawn = 0, Seconds forcedRespawnTimer = 0s); void ForcedDespawn(Milliseconds timeMSToDespawn = 0ms, Seconds forcedRespawnTimer = 0s);
[[nodiscard]] bool CanPeriodicallyCallForAssistance() const; [[nodiscard]] bool CanPeriodicallyCallForAssistance() const;
@@ -284,13 +284,12 @@ void TempSummon::SetTempSummonType(TempSummonType type)
m_type = type; m_type = type;
} }
void TempSummon::UnSummon(uint32 msTime) void TempSummon::UnSummon(Milliseconds msTime)
{ {
if (msTime) if (msTime > 0ms)
{ {
ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this); ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this);
m_Events.AddEventAtOffset(pEvent, msTime);
m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime));
return; return;
} }
@@ -44,7 +44,7 @@ public:
void Update(uint32 time) override; void Update(uint32 time) override;
virtual void InitStats(uint32 lifetime); virtual void InitStats(uint32 lifetime);
virtual void InitSummon(); virtual void InitSummon();
virtual void UnSummon(uint32 msTime = 0); virtual void UnSummon(Milliseconds msTime = 0ms);
void UpdateObjectVisibilityOnCreate() override; void UpdateObjectVisibilityOnCreate() override;
void RemoveFromWorld() override; void RemoveFromWorld() override;
void SetTempSummonType(TempSummonType type); void SetTempSummonType(TempSummonType type);
@@ -133,4 +133,5 @@ public:
private: private:
TempSummon& m_owner; TempSummon& m_owner;
}; };
#endif #endif
+3 -3
View File
@@ -119,11 +119,11 @@ void Totem::InitSummon()
} }
} }
void Totem::UnSummon(uint32 msTime) void Totem::UnSummon(Milliseconds msTime)
{ {
if (msTime) if (msTime > 0ms)
{ {
m_Events.AddEvent(new ForcedUnsummonDelayEvent(*this), m_Events.CalculateTime(msTime)); m_Events.AddEventAtOffset(new ForcedUnsummonDelayEvent(*this), msTime);
return; return;
} }
+1 -1
View File
@@ -55,7 +55,7 @@ public:
void Update(uint32 time) override; void Update(uint32 time) override;
void InitStats(uint32 duration) override; void InitStats(uint32 duration) override;
void InitSummon() override; void InitSummon() override;
void UnSummon(uint32 msTime = 0) override; void UnSummon(Milliseconds msTime = 0ms) override;
uint32 GetSpell(uint8 slot = 0) const { return m_spells[slot]; } uint32 GetSpell(uint8 slot = 0) const { return m_spells[slot]; }
uint32 GetTotemDuration() const { return m_duration; } uint32 GetTotemDuration() const { return m_duration; }
void SetTotemDuration(uint32 duration) { m_duration = duration; } void SetTotemDuration(uint32 duration) { m_duration = duration; }
+4 -4
View File
@@ -11071,7 +11071,7 @@ int32 Unit::DealHeal(Unit* healer, Unit* victim, uint32 addhealth)
return gain; return gain;
} }
bool RedirectSpellEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) bool RedirectSpellEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{ {
if (Unit* auraOwner = ObjectAccessor::GetUnit(_self, _auraOwnerGUID)) if (Unit* auraOwner = ObjectAccessor::GetUnit(_self, _auraOwnerGUID))
{ {
@@ -19572,7 +19572,7 @@ void Unit::ExitVehicle(Position const* /*exitPosition*/)
} }
} }
bool VehicleDespawnEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) bool VehicleDespawnEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{ {
Position pos = _self; Position pos = _self;
_self.MovePositionToFirstCollision(pos, 20.0f, M_PI); _self.MovePositionToFirstCollision(pos, 20.0f, M_PI);
@@ -19699,7 +19699,7 @@ void Unit::_ExitVehicle(Position const* exitPosition)
setDeathState(DeathState::JustDied); setDeathState(DeathState::JustDied);
// If for other reason we as minion are exiting the vehicle (ejected, master dismounted) - unsummon // If for other reason we as minion are exiting the vehicle (ejected, master dismounted) - unsummon
else else
ToTempSummon()->UnSummon(2000); // Approximation ToTempSummon()->UnSummon(2s); // Approximation
} }
if (player) if (player)
@@ -20086,7 +20086,7 @@ class AuraMunchingQueue : public BasicEvent
public: public:
AuraMunchingQueue(Unit& owner, ObjectGuid targetGUID, int32 basePoints, uint32 spellId, AuraEffect* aurEff, AuraType auraType) : _owner(owner), _targetGUID(targetGUID), _basePoints(basePoints), _spellId(spellId), _aurEff(aurEff), _auraType(auraType) { } AuraMunchingQueue(Unit& owner, ObjectGuid targetGUID, int32 basePoints, uint32 spellId, AuraEffect* aurEff, AuraType auraType) : _owner(owner), _targetGUID(targetGUID), _basePoints(basePoints), _spellId(spellId), _aurEff(aurEff), _auraType(auraType) { }
bool Execute(uint64 /*eventTime*/, uint32 /*updateTime*/) override bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) override
{ {
if (_owner.IsInWorld() && _owner.FindMap()) if (_owner.IsInWorld() && _owner.FindMap())
if (Unit* target = ObjectAccessor::GetUnit(_owner, _targetGUID)) if (Unit* target = ObjectAccessor::GetUnit(_owner, _targetGUID))
+3 -3
View File
@@ -2392,7 +2392,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
targetInfo.reflectResult = SPELL_MISS_PARRY; targetInfo.reflectResult = SPELL_MISS_PARRY;
// Increase time interval for reflected spells by 1.5 // Increase time interval for reflected spells by 1.5
m_caster->m_Events.AddEvent(new ReflectEvent(m_caster, targetInfo.targetGUID, m_spellInfo), m_caster->m_Events.CalculateTime(targetInfo.timeDelay)); m_caster->m_Events.AddEventAtOffset(new ReflectEvent(m_caster, targetInfo.targetGUID, m_spellInfo), Milliseconds(targetInfo.timeDelay));
targetInfo.timeDelay += targetInfo.timeDelay >> 1; targetInfo.timeDelay += targetInfo.timeDelay >> 1;
m_spellFlags |= SPELL_FLAG_REFLECTED; m_spellFlags |= SPELL_FLAG_REFLECTED;
@@ -3439,7 +3439,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const
// create and add update event for this spell // create and add update event for this spell
_spellEvent = new SpellEvent(this); _spellEvent = new SpellEvent(this);
m_caster->m_Events.AddEvent(_spellEvent, m_caster->m_Events.CalculateTime(1)); m_caster->m_Events.AddEventAtOffset(_spellEvent, 1ms);
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, m_caster)) if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, m_caster))
{ {
@@ -8166,7 +8166,7 @@ bool SpellEvent::IsDeletable() const
return m_Spell->IsDeletable(); return m_Spell->IsDeletable();
} }
bool ReflectEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) bool ReflectEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{ {
Unit* target = ObjectAccessor::GetUnit(*_caster, _targetGUID); Unit* target = ObjectAccessor::GetUnit(*_caster, _targetGUID);
if (target && _caster->IsInMap(target)) if (target && _caster->IsInMap(target))
@@ -606,7 +606,7 @@ public:
if (Creature* argelmach = instance->GetCreature(ArgelmachGUID)) if (Creature* argelmach = instance->GetCreature(ArgelmachGUID))
{ {
argelmach->HandleEmoteCommand(EMOTE_ONESHOT_SHOUT); argelmach->HandleEmoteCommand(EMOTE_ONESHOT_SHOUT);
argelmach->m_Events.AddEvent(new RestoreAttack(argelmach), argelmach->m_Events.CalculateTime(3000)); argelmach->m_Events.AddEventAtOffset(new RestoreAttack(argelmach), 3s);
for (ObjectGuid const& argelmachAddGUID : ArgelmachAdds) for (ObjectGuid const& argelmachAddGUID : ArgelmachAdds)
{ {
@@ -157,8 +157,8 @@ public:
orc->AI()->Talk(SAY_BLACKHAND_DOOMED); orc->AI()->Talk(SAY_BLACKHAND_DOOMED);
} }
orc->m_Events.AddEvent(new OrcMoveEvent(orc), me->m_Events.CalculateTime(3 * IN_MILLISECONDS)); orc->m_Events.AddEventAtOffset(new OrcMoveEvent(orc), 3s);
orc->m_Events.AddEvent(new OrcDeathEvent(orc), me->m_Events.CalculateTime(9 * IN_MILLISECONDS)); orc->m_Events.AddEventAtOffset(new OrcDeathEvent(orc), 9s);
} }
} }
} }
@@ -473,7 +473,7 @@ public:
if (battleStarted != ENCOUNTER_STATE_FIGHT) if (battleStarted != ENCOUNTER_STATE_FIGHT)
return; return;
me->m_Events.AddEvent(new DelayedSummonEvent(me, creature->GetEntry(), *creature), me->m_Events.CalculateTime(3000)); me->m_Events.AddEventAtOffset(new DelayedSummonEvent(me, creature->GetEntry(), *creature), 3s);
if (creature->GetEntry() >= NPC_RAMPAGING_ABOMINATION) if (creature->GetEntry() >= NPC_RAMPAGING_ABOMINATION)
{ {
--scourgeRemaining; --scourgeRemaining;
@@ -319,9 +319,10 @@ struct boss_felmyst : public BossAI
break; break;
case POINT_LANE: case POINT_LANE:
Talk(EMOTE_BREATH); Talk(EMOTE_BREATH);
me->m_Events.AddEventAtOffset([&] { me->m_Events.AddEventAtOffset([this]()
{
for (uint8 i = 0; i < 16; ++i) for (uint8 i = 0; i < 16; ++i)
me->m_Events.AddEvent(new CorruptTriggers(me, _currentLane), me->m_Events.CalculateTime(i*250)); me->m_Events.AddEventAtOffset(new CorruptTriggers(me, _currentLane), Milliseconds(i * 250));
}, 5s); }, 5s);
me->m_Events.AddEventAtOffset([&] { me->m_Events.AddEventAtOffset([&] {
@@ -554,7 +554,7 @@ struct boss_kiljaeden : public BossAI
summon->SetDisableGravity(true); summon->SetDisableGravity(true);
summon->CastSpell(summon, SPELL_ARMAGEDDON_VISUAL, true); summon->CastSpell(summon, SPELL_ARMAGEDDON_VISUAL, true);
summon->SetPosition(summon->GetPositionX(), summon->GetPositionY(), summon->GetPositionZ() + 20.0f, 0.0f); summon->SetPosition(summon->GetPositionX(), summon->GetPositionY(), summon->GetPositionZ() + 20.0f, 0.0f);
summon->m_Events.AddEvent(new CastArmageddon(summon), summon->m_Events.CalculateTime(6000)); summon->m_Events.AddEventAtOffset(new CastArmageddon(summon), 6s);
summon->DespawnOrUnsummon(randtime(8s, 10s)); summon->DespawnOrUnsummon(randtime(8s, 10s));
} }
} }
@@ -787,8 +787,8 @@ struct npc_kalecgos_kj : public NullCreatureAI
case EVENT_SCENE_05: case EVENT_SCENE_05:
if (Creature* first = me->SummonCreature(NPC_SHATTERED_SUN_SOLDIER, 1729.48f, 640.49f, 28.06f, 3.49f)) if (Creature* first = me->SummonCreature(NPC_SHATTERED_SUN_SOLDIER, 1729.48f, 640.49f, 28.06f, 3.49f))
{ {
first->m_Events.AddEvent(new MoveDelayed(first, 1718.70f, 607.78f, 28.06f, 2.323f), first->m_Events.CalculateTime(5000)); first->m_Events.AddEventAtOffset(new MoveDelayed(first, 1718.70f, 607.78f, 28.06f, 2.323f), 5s);
first->m_Events.AddEvent(new FixOrientation(first), first->m_Events.CalculateTime(12000)); first->m_Events.AddEventAtOffset(new FixOrientation(first), 12s);
for (uint8 i = 0; i < 9; ++i) for (uint8 i = 0; i < 9; ++i)
if (Creature* follower = me->SummonCreature(NPC_SHATTERED_SUN_SOLDIER, 1729.48f + 5 * cos(i * 2.0f * M_PI / 9), 640.49f + 5 * std::sin(i * 2.0f * M_PI / 9), 28.06f, 3.49f)) if (Creature* follower = me->SummonCreature(NPC_SHATTERED_SUN_SOLDIER, 1729.48f + 5 * cos(i * 2.0f * M_PI / 9), 640.49f + 5 * std::sin(i * 2.0f * M_PI / 9), 28.06f, 3.49f))
follower->GetMotionMaster()->MoveFollow(first, 3.0f, follower->GetAngle(first)); follower->GetMotionMaster()->MoveFollow(first, 3.0f, follower->GetAngle(first));
@@ -798,8 +798,8 @@ struct npc_kalecgos_kj : public NullCreatureAI
case EVENT_SCENE_06: case EVENT_SCENE_06:
if (Creature* first = me->SummonCreature(NPC_SHATTERED_SUN_SOLDIER, 1729.48f, 640.49f, 28.06f, 3.49f)) if (Creature* first = me->SummonCreature(NPC_SHATTERED_SUN_SOLDIER, 1729.48f, 640.49f, 28.06f, 3.49f))
{ {
first->m_Events.AddEvent(new MoveDelayed(first, 1678.69f, 649.27f, 28.06f, 5.46f), first->m_Events.CalculateTime(5000)); first->m_Events.AddEventAtOffset(new MoveDelayed(first, 1678.69f, 649.27f, 28.06f, 5.46f), 5s);
first->m_Events.AddEvent(new FixOrientation(first), first->m_Events.CalculateTime(14500)); first->m_Events.AddEventAtOffset(new FixOrientation(first), 14500ms);
for (uint8 i = 0; i < 9; ++i) for (uint8 i = 0; i < 9; ++i)
if (Creature* follower = me->SummonCreature(NPC_SHATTERED_SUN_SOLDIER, 1729.48f + 5 * cos(i * 2.0f * M_PI / 9), 640.49f + 5 * std::sin(i * 2.0f * M_PI / 9), 28.06f, 3.49f)) if (Creature* follower = me->SummonCreature(NPC_SHATTERED_SUN_SOLDIER, 1729.48f + 5 * cos(i * 2.0f * M_PI / 9), 640.49f + 5 * std::sin(i * 2.0f * M_PI / 9), 28.06f, 3.49f))
follower->GetMotionMaster()->MoveFollow(first, 3.0f, follower->GetAngle(first)); follower->GetMotionMaster()->MoveFollow(first, 3.0f, follower->GetAngle(first));
@@ -199,19 +199,19 @@ struct npc_medivh_bm : public ScriptedAI
events.ScheduleEvent(EVENT_OUTRO_3, 2s); events.ScheduleEvent(EVENT_OUTRO_3, 2s);
break; break;
case EVENT_OUTRO_3: case EVENT_OUTRO_3:
SummonOrcs(-2046.158f, -3.0f, 37s, 30000, true); SummonOrcs(-2046.158f, -3.0f, 37s, 30s, true);
events.ScheduleEvent(EVENT_OUTRO_4, 2s); events.ScheduleEvent(EVENT_OUTRO_4, 2s);
break; break;
case EVENT_OUTRO_4: case EVENT_OUTRO_4:
SummonOrcs(-2055.97f, -2.0f, 33s, 28000, false); SummonOrcs(-2055.97f, -2.0f, 33s, 28s, false);
events.ScheduleEvent(EVENT_OUTRO_5, 2s); events.ScheduleEvent(EVENT_OUTRO_5, 2s);
break; break;
case EVENT_OUTRO_5: case EVENT_OUTRO_5:
SummonOrcs(-2064.0f, -1.5f, 29s, 26000, false); SummonOrcs(-2064.0f, -1.5f, 29s, 26s, false);
events.ScheduleEvent(EVENT_OUTRO_6, 2s); events.ScheduleEvent(EVENT_OUTRO_6, 2s);
break; break;
case EVENT_OUTRO_6: case EVENT_OUTRO_6:
SummonOrcs(-2074.35f, -0.1f, 26s, 24000, false); SummonOrcs(-2074.35f, -0.1f, 26s, 24s, false);
events.ScheduleEvent(EVENT_OUTRO_7, 7s); events.ScheduleEvent(EVENT_OUTRO_7, 7s);
break; break;
case EVENT_OUTRO_7: case EVENT_OUTRO_7:
@@ -228,14 +228,14 @@ struct npc_medivh_bm : public ScriptedAI
} }
} }
void SummonOrcs(float x, float y, Milliseconds duration, uint32 homeTime, bool first) void SummonOrcs(float x, float y, Milliseconds duration, Milliseconds homeTime, bool first)
{ {
for (uint8 i = 0; i < 6; ++i) for (uint8 i = 0; i < 6; ++i)
{ {
if (Creature* cr = me->SummonCreature(NPC_SHADOW_COUNCIL_ENFORCER, -2091.731f, 7133.083f - 3.0f * i, 34.589f, 0.0f)) if (Creature* cr = me->SummonCreature(NPC_SHADOW_COUNCIL_ENFORCER, -2091.731f, 7133.083f - 3.0f * i, 34.589f, 0.0f))
{ {
cr->GetMotionMaster()->MovePoint(0, (first && i == 3) ? x + 2.0f : x, cr->GetPositionY() + y, cr->GetMapHeight(x, cr->GetPositionY() + y, cr->GetPositionZ(), true)); cr->GetMotionMaster()->MovePoint(0, (first && i == 3) ? x + 2.0f : x, cr->GetPositionY() + y, cr->GetMapHeight(x, cr->GetPositionY() + y, cr->GetPositionZ(), true));
cr->m_Events.AddEvent(new NpcRunToHome(*cr), cr->m_Events.CalculateTime(homeTime + urand(0, 2000))); cr->m_Events.AddEventAtOffset(new NpcRunToHome(*cr), homeTime + randtime(0ms, 2s));
cr->DespawnOrUnsummon(duration + randtime(0ms, 2s)); cr->DespawnOrUnsummon(duration + randtime(0ms, 2s));
} }
} }
@@ -1174,7 +1174,7 @@ public:
summons->SetLootRecipient(player); summons->SetLootRecipient(player);
summons->CastSpell(summons, SPELL_SPAWN_IN, false); summons->CastSpell(summons, SPELL_SPAWN_IN, false);
summons->AI()->Talk(SAY_ON_SPAWN_IN, player); summons->AI()->Talk(SAY_ON_SPAWN_IN, player);
summons->m_Events.AddEvent(new DelayedWindstoneSummonEvent(summons, player->GetGUID()), summons->m_Events.CalculateTime(5200)); summons->m_Events.AddEventAtOffset(new DelayedWindstoneSummonEvent(summons, player->GetGUID()), 5200ms);
_creatureGuid = summons->GetGUID(); _creatureGuid = summons->GetGUID();
} }
} }
@@ -152,7 +152,7 @@ public:
if (action == ACTION_INTRO_BALTHARUS && !_introDone) if (action == ACTION_INTRO_BALTHARUS && !_introDone)
{ {
_introDone = true; _introDone = true;
me->m_Events.AddEvent(new DelayedTalk(me, SAY_BALTHARUS_INTRO), me->m_Events.CalculateTime(6000)); me->m_Events.AddEventAtOffset(new DelayedTalk(me, SAY_BALTHARUS_INTRO), 6s);
} }
else if (action == ACTION_CLONE) else if (action == ACTION_CLONE)
{ {
@@ -204,7 +204,7 @@ public:
summon->SetHealth(me->GetHealth()); summon->SetHealth(me->GetHealth());
summon->CastSpell(summon, SPELL_SPAWN_EFFECT, true); summon->CastSpell(summon, SPELL_SPAWN_EFFECT, true);
summon->SetReactState(REACT_PASSIVE); summon->SetReactState(REACT_PASSIVE);
summon->m_Events.AddEvent(new RestoreFight(summon), summon->m_Events.CalculateTime(2000)); summon->m_Events.AddEventAtOffset(new RestoreFight(summon), 2s);
} }
void UpdateAI(uint32 diff) override void UpdateAI(uint32 diff) override
@@ -1120,7 +1120,7 @@ class spell_halion_twilight_realm_aura : public AuraScript
target->RemoveAurasDueToSpell(SPELL_FIERY_COMBUSTION, ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL); target->RemoveAurasDueToSpell(SPELL_FIERY_COMBUSTION, ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL);
if (!GetTarget()->IsPlayer()) if (!GetTarget()->IsPlayer())
return; return;
GetTarget()->m_Events.AddEvent(new SendEncounterUnit(GetTarget()->ToPlayer()), GetTarget()->m_Events.CalculateTime(500)); GetTarget()->m_Events.AddEventAtOffset(new SendEncounterUnit(GetTarget()->ToPlayer()), 500ms);
} }
void Register() override void Register() override
@@ -1153,7 +1153,7 @@ class spell_halion_leave_twilight_realm_aura : public AuraScript
if (!GetTarget()->IsPlayer()) if (!GetTarget()->IsPlayer())
return; return;
GetTarget()->m_Events.AddEvent(new SendEncounterUnit(GetTarget()->ToPlayer()), GetTarget()->m_Events.CalculateTime(500)); GetTarget()->m_Events.AddEventAtOffset(new SendEncounterUnit(GetTarget()->ToPlayer()), 500ms);
} }
void Register() override void Register() override
@@ -502,7 +502,7 @@ public:
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
me->CastSpell(me, RAID_MODE(SPELL_TRAITOR_KING_10, SPELL_TRAITOR_KING_25, SPELL_TRAITOR_KING_10, SPELL_TRAITOR_KING_25), true); me->CastSpell(me, RAID_MODE(SPELL_TRAITOR_KING_10, SPELL_TRAITOR_KING_25, SPELL_TRAITOR_KING_10, SPELL_TRAITOR_KING_25), true);
me->m_Events.AddEvent(new HideNpcEvent(*me), me->m_Events.CalculateTime(5000)); me->m_Events.AddEventAtOffset(new HideNpcEvent(*me), 5s);
} }
bool CanAIAttack(Unit const* target) const override bool CanAIAttack(Unit const* target) const override
@@ -710,7 +710,7 @@ public:
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
me->m_Events.AddEvent(new HideNpcEvent(*me), me->m_Events.CalculateTime(5000)); me->m_Events.AddEventAtOffset(new HideNpcEvent(*me), 5s);
} }
bool CanAIAttack(Unit const* target) const override bool CanAIAttack(Unit const* target) const override
@@ -38,7 +38,7 @@ public:
_owner.GetMotionMaster()->Clear(); _owner.GetMotionMaster()->Clear();
_owner.SetVisible(true); _owner.SetVisible(true);
_owner.NearTeleportTo(5300.53f, 1987.80f, 707.70f, 3.89f); _owner.NearTeleportTo(5300.53f, 1987.80f, 707.70f, 3.89f);
_owner.m_Events.AddEvent(new UtherBatteredHiltEvent(_owner, 2), _owner.m_Events.CalculateTime(1000)); _owner.m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(_owner, 2), 1s);
break; break;
case 2: case 2:
_owner.AI()->Talk(SAY_BATTERED_HILT_HALT); _owner.AI()->Talk(SAY_BATTERED_HILT_HALT);
@@ -52,12 +52,12 @@ public:
{ {
quel->AI()->Talk(EMOTE_QUEL_SPAWN); quel->AI()->Talk(EMOTE_QUEL_SPAWN);
} }
_owner.m_Events.AddEvent(new UtherBatteredHiltEvent(_owner, 4), _owner.m_Events.CalculateTime(3500)); _owner.m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(_owner, 4), 3500ms);
break; break;
case 4: case 4:
_owner.SetWalk(false); _owner.SetWalk(false);
_owner.GetMotionMaster()->MovePoint(0, 5337.53f, 1981.21f, 709.32f); _owner.GetMotionMaster()->MovePoint(0, 5337.53f, 1981.21f, 709.32f);
_owner.m_Events.AddEvent(new UtherBatteredHiltEvent(_owner, 5), _owner.m_Events.CalculateTime(6000)); _owner.m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(_owner, 5), 6s);
break; break;
case 5: case 5:
_owner.SetFacingTo(2.82f); _owner.SetFacingTo(2.82f);
@@ -66,7 +66,7 @@ public:
case 6: case 6:
if (InstanceScript* instance = _owner.GetInstanceScript()) if (InstanceScript* instance = _owner.GetInstanceScript())
instance->SetData(DATA_BATTERED_HILT, 6); instance->SetData(DATA_BATTERED_HILT, 6);
_owner.m_Events.AddEvent(new UtherBatteredHiltEvent(_owner, 7), _owner.m_Events.CalculateTime(2000)); _owner.m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(_owner, 7), 2s);
break; break;
case 7: case 7:
if (InstanceScript* instance = _owner.GetInstanceScript()) if (InstanceScript* instance = _owner.GetInstanceScript())
@@ -77,7 +77,7 @@ public:
{ {
quel->AI()->Talk(EMOTE_QUEL_PREPARE); quel->AI()->Talk(EMOTE_QUEL_PREPARE);
} }
_owner.m_Events.AddEvent(new UtherBatteredHiltEvent(_owner, 8), _owner.m_Events.CalculateTime(4000)); _owner.m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(_owner, 8), 4s);
break; break;
case 8: case 8:
_owner.SetReactState(REACT_AGGRESSIVE); _owner.SetReactState(REACT_AGGRESSIVE);
@@ -87,23 +87,23 @@ public:
break; break;
case 9: case 9:
_owner.AI()->Talk(SAY_BATTERED_HILT_OUTRO1); _owner.AI()->Talk(SAY_BATTERED_HILT_OUTRO1);
_owner.m_Events.AddEvent(new UtherBatteredHiltEvent(_owner, _eventId + 1), _owner.m_Events.CalculateTime(11000)); _owner.m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(_owner, _eventId + 1), 11s);
break; break;
case 10: case 10:
_owner.AI()->Talk(SAY_BATTERED_HILT_OUTRO2); _owner.AI()->Talk(SAY_BATTERED_HILT_OUTRO2);
_owner.m_Events.AddEvent(new UtherBatteredHiltEvent(_owner, _eventId + 1), _owner.m_Events.CalculateTime(7500)); _owner.m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(_owner, _eventId + 1), 7500ms);
break; break;
case 11: case 11:
_owner.AI()->Talk(SAY_BATTERED_HILT_OUTRO3); _owner.AI()->Talk(SAY_BATTERED_HILT_OUTRO3);
_owner.m_Events.AddEvent(new UtherBatteredHiltEvent(_owner, _eventId + 1), _owner.m_Events.CalculateTime(8000)); _owner.m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(_owner, _eventId + 1), 8s);
break; break;
case 12: case 12:
_owner.AI()->Talk(SAY_BATTERED_HILT_OUTRO4); _owner.AI()->Talk(SAY_BATTERED_HILT_OUTRO4);
_owner.m_Events.AddEvent(new UtherBatteredHiltEvent(_owner, _eventId + 1), _owner.m_Events.CalculateTime(5000)); _owner.m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(_owner, _eventId + 1), 5s);
break; break;
case 13: case 13:
_owner.CastSpell((Unit*)nullptr, 73036, true); _owner.CastSpell((Unit*)nullptr, 73036, true);
_owner.m_Events.AddEvent(new UtherBatteredHiltEvent(_owner, _eventId + 1), _owner.m_Events.CalculateTime(3000)); _owner.m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(_owner, _eventId + 1), 3s);
break; break;
case 14: case 14:
{ {
@@ -594,7 +594,7 @@ public:
if (Creature* c = instance->GetCreature(NPC_AltarBunnyGUID)) if (Creature* c = instance->GetCreature(NPC_AltarBunnyGUID))
c->CastSpell(c, 70720, true); c->CastSpell(c, 70720, true);
if (Creature* c = instance->GetCreature(NPC_UtherGUID)) if (Creature* c = instance->GetCreature(NPC_UtherGUID))
c->m_Events.AddEvent(new UtherBatteredHiltEvent(*c, 1), c->m_Events.CalculateTime(3000)); c->m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(*c, 1), 3s);
break; break;
case 3: case 3:
if ((BatteredHiltStatus & BHSF_STARTED) == 0 || (BatteredHiltStatus & BHSF_THROWN)) if ((BatteredHiltStatus & BHSF_STARTED) == 0 || (BatteredHiltStatus & BHSF_THROWN))
@@ -602,7 +602,7 @@ public:
BatteredHiltStatus |= BHSF_THROWN; BatteredHiltStatus |= BHSF_THROWN;
if (Creature* c = instance->GetCreature(NPC_UtherGUID)) if (Creature* c = instance->GetCreature(NPC_UtherGUID))
{ {
c->m_Events.AddEvent(new UtherBatteredHiltEvent(*c, 3), c->m_Events.CalculateTime(5500)); c->m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(*c, 3), 5500ms);
} }
break; break;
case 4: case 4:
@@ -614,7 +614,7 @@ public:
break; break;
case 5: case 5:
if (Creature* c = instance->GetCreature(NPC_UtherGUID)) if (Creature* c = instance->GetCreature(NPC_UtherGUID))
c->m_Events.AddEvent(new UtherBatteredHiltEvent(*c, 6), c->m_Events.CalculateTime(3000)); c->m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(*c, 6), 3s);
break; break;
case 6: case 6:
if (Creature* c = instance->GetCreature(NPC_QuelDelarGUID)) if (Creature* c = instance->GetCreature(NPC_QuelDelarGUID))
@@ -726,7 +726,7 @@ public:
c->SetStandState(UNIT_STAND_STATE_STAND); c->SetStandState(UNIT_STAND_STATE_STAND);
c->SetWalk(false); c->SetWalk(false);
c->GetMotionMaster()->MovePoint(0, 5313.92f, 1989.36f, 707.70f); c->GetMotionMaster()->MovePoint(0, 5313.92f, 1989.36f, 707.70f);
c->m_Events.AddEvent(new UtherBatteredHiltEvent(*c, 9), c->m_Events.CalculateTime(7000)); c->m_Events.AddEventAtOffset(new UtherBatteredHiltEvent(*c, 9), 7s);
} }
} }
@@ -1383,7 +1383,7 @@ class spell_pos_slave_trigger_closest : public SpellScript
{ {
c->DespawnOrUnsummon(7s); c->DespawnOrUnsummon(7s);
c->AI()->Talk(0, p); c->AI()->Talk(0, p);
c->m_Events.AddEvent(new SlaveRunEvent(*c), c->m_Events.CalculateTime(3000)); c->m_Events.AddEventAtOffset(new SlaveRunEvent(*c), 3s);
} }
} }
} }
@@ -160,7 +160,7 @@ public:
{ {
summon->SetRegeneratingHealth(false); summon->SetRegeneratingHealth(false);
summon->SetReactState(REACT_PASSIVE); summon->SetReactState(REACT_PASSIVE);
summon->m_Events.AddEvent(new RestoreFight(summon), summon->m_Events.CalculateTime(3000)); summon->m_Events.AddEventAtOffset(new RestoreFight(summon), 3s);
if (!events.HasTimeUntilEvent(EVENT_COLOSSUS_HEALTH_2)) if (!events.HasTimeUntilEvent(EVENT_COLOSSUS_HEALTH_2))
{ {
summon->SetHealth(summon->GetMaxHealth() / 2); summon->SetHealth(summon->GetMaxHealth() / 2);
@@ -375,7 +375,7 @@ public:
me->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH); me->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
me->SetReactState(REACT_AGGRESSIVE); me->SetReactState(REACT_AGGRESSIVE);
me->ForceValuesUpdateAtIndex(UNIT_NPC_FLAGS); // was in sniff. don't ask why me->ForceValuesUpdateAtIndex(UNIT_NPC_FLAGS); // was in sniff. don't ask why
me->m_Events.AddEvent(new StandUpEvent(*me), me->m_Events.CalculateTime(1000)); me->m_Events.AddEventAtOffset(new StandUpEvent(*me), 1s);
DoAction(ACTION_REMOVE_INVOCATION); DoAction(ACTION_REMOVE_INVOCATION);
me->SetHealth(1); me->SetHealth(1);
break; break;
@@ -645,7 +645,7 @@ public:
me->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH); me->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
me->SetReactState(REACT_AGGRESSIVE); me->SetReactState(REACT_AGGRESSIVE);
me->ForceValuesUpdateAtIndex(UNIT_NPC_FLAGS); // was in sniff. don't ask why me->ForceValuesUpdateAtIndex(UNIT_NPC_FLAGS); // was in sniff. don't ask why
me->m_Events.AddEvent(new StandUpEvent(*me), me->m_Events.CalculateTime(1000)); me->m_Events.AddEventAtOffset(new StandUpEvent(*me), 1s);
DoAction(ACTION_REMOVE_INVOCATION); DoAction(ACTION_REMOVE_INVOCATION);
me->SetHealth(1); me->SetHealth(1);
break; break;
@@ -889,7 +889,7 @@ public:
summon->CastSpell(summon, SPELL_KINETIC_BOMB, true, nullptr, nullptr, me->GetGUID()); summon->CastSpell(summon, SPELL_KINETIC_BOMB, true, nullptr, nullptr, me->GetGUID());
break; break;
case NPC_SHOCK_VORTEX: case NPC_SHOCK_VORTEX:
summon->m_Events.AddEvent(new ShockVortexExplodeEvent(*summon), summon->m_Events.CalculateTime(4500)); summon->m_Events.AddEventAtOffset(new ShockVortexExplodeEvent(*summon), 4500ms);
break; break;
default: default:
break; break;
@@ -939,7 +939,7 @@ public:
me->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH); me->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
me->SetReactState(REACT_AGGRESSIVE); me->SetReactState(REACT_AGGRESSIVE);
me->ForceValuesUpdateAtIndex(UNIT_NPC_FLAGS); // was in sniff. don't ask why me->ForceValuesUpdateAtIndex(UNIT_NPC_FLAGS); // was in sniff. don't ask why
me->m_Events.AddEvent(new StandUpEvent(*me), me->m_Events.CalculateTime(1000)); me->m_Events.AddEventAtOffset(new StandUpEvent(*me), 1s);
me->SetHealth(me->GetMaxHealth()); me->SetHealth(me->GetMaxHealth());
DoAction(ACTION_CAST_INVOCATION); DoAction(ACTION_CAST_INVOCATION);
break; break;
@@ -373,7 +373,7 @@ class BattleExperienceEvent : public BasicEvent
{ {
public: public:
static uint32 const ExperiencedSpells[5]; static uint32 const ExperiencedSpells[5];
static uint32 const ExperiencedTimes[5]; static Milliseconds const ExperiencedTimes[5];
BattleExperienceEvent(Creature* creature) : _creature(creature), _level(0) { } BattleExperienceEvent(Creature* creature) : _creature(creature), _level(0) { }
@@ -388,7 +388,8 @@ public:
_creature->CastSpell(_creature, ExperiencedSpells[_level], true); _creature->CastSpell(_creature, ExperiencedSpells[_level], true);
if (_level < (_creature->GetMap()->IsHeroic() ? 4 : 3)) if (_level < (_creature->GetMap()->IsHeroic() ? 4 : 3))
{ {
_creature->m_Events.AddEvent(this, timer + ExperiencedTimes[_level]); Milliseconds nextExperienceEventTime = Milliseconds(timer) + ExperiencedTimes[_level];
_creature->m_Events.AddEventAtOffset(this, nextExperienceEventTime);
return false; return false;
} }
@@ -401,7 +402,7 @@ private:
}; };
uint32 const BattleExperienceEvent::ExperiencedSpells[5] = { 0, SPELL_EXPERIENCED, SPELL_VETERAN, SPELL_ELITE, SPELL_ADDS_BERSERK }; uint32 const BattleExperienceEvent::ExperiencedSpells[5] = { 0, SPELL_EXPERIENCED, SPELL_VETERAN, SPELL_ELITE, SPELL_ADDS_BERSERK };
uint32 const BattleExperienceEvent::ExperiencedTimes[5] = { 100000, 70000, 60000, 90000, 0 }; Milliseconds const BattleExperienceEvent::ExperiencedTimes[5] = { 100s, 70s, 60s, 90s, 0ms };
class PassengerController class PassengerController
{ {
@@ -675,7 +676,7 @@ public:
else else
{ {
uint32 teleportSpellId = _teamIdInInstance == TEAM_HORDE ? SPELL_TELEPORT_PLAYERS_ON_RESET_H : SPELL_TELEPORT_PLAYERS_ON_RESET_A; uint32 teleportSpellId = _teamIdInInstance == TEAM_HORDE ? SPELL_TELEPORT_PLAYERS_ON_RESET_H : SPELL_TELEPORT_PLAYERS_ON_RESET_A;
me->m_Events.AddEvent(new ResetEncounterEvent(me, teleportSpellId, _instance->GetGuidData(DATA_ENEMY_GUNSHIP)), me->m_Events.CalculateTime(8000)); me->m_Events.AddEventAtOffset(new ResetEncounterEvent(me, teleportSpellId, _instance->GetGuidData(DATA_ENEMY_GUNSHIP)), 8s);
} }
} }
@@ -1544,7 +1545,7 @@ struct gunship_npc_AI : public ScriptedAI
if (type == POINT_MOTION_TYPE && pointId == EVENT_CHARGE_PREPATH && Slot) if (type == POINT_MOTION_TYPE && pointId == EVENT_CHARGE_PREPATH && Slot)
{ {
me->SetFacingTo(Slot->TargetPosition.GetOrientation()); me->SetFacingTo(Slot->TargetPosition.GetOrientation());
me->m_Events.AddEvent(new BattleExperienceEvent(me), me->m_Events.CalculateTime(BattleExperienceEvent::ExperiencedTimes[0])); me->m_Events.AddEventAtOffset(new BattleExperienceEvent(me), BattleExperienceEvent::ExperiencedTimes[0]);
me->CastSpell(me, SPELL_BATTLE_EXPERIENCE, true); me->CastSpell(me, SPELL_BATTLE_EXPERIENCE, true);
me->SetReactState(REACT_AGGRESSIVE); me->SetReactState(REACT_AGGRESSIVE);
} }
@@ -1579,7 +1580,7 @@ struct npc_gunship_boarding_addAI : public ScriptedAI
{ {
SetSlotInfo(data); SetSlotInfo(data);
me->SetReactState(REACT_PASSIVE); me->SetReactState(REACT_PASSIVE);
me->m_Events.AddEvent(new DelayedMovementEvent(me, Slot->TargetPosition), me->m_Events.CalculateTime(3000 * (Index - SLOT_MARINE_1))); me->m_Events.AddEventAtOffset(new DelayedMovementEvent(me, Slot->TargetPosition), Milliseconds(3000 * (Index - SLOT_MARINE_1)));
} }
} }
@@ -1608,7 +1609,7 @@ struct npc_gunship_boarding_addAI : public ScriptedAI
if (type == POINT_MOTION_TYPE && pointId == EVENT_CHARGE_PREPATH && Slot) if (type == POINT_MOTION_TYPE && pointId == EVENT_CHARGE_PREPATH && Slot)
{ {
me->SetFacingTo(Slot->TargetPosition.GetOrientation()); me->SetFacingTo(Slot->TargetPosition.GetOrientation());
me->m_Events.AddEvent(new BattleExperienceEvent(me), me->m_Events.CalculateTime(BattleExperienceEvent::ExperiencedTimes[0])); me->m_Events.AddEventAtOffset(new BattleExperienceEvent(me), BattleExperienceEvent::ExperiencedTimes[0]);
me->CastSpell(me, SPELL_BATTLE_EXPERIENCE, true); me->CastSpell(me, SPELL_BATTLE_EXPERIENCE, true);
me->SetReactState(REACT_AGGRESSIVE); me->SetReactState(REACT_AGGRESSIVE);
@@ -522,7 +522,7 @@ public:
darnavan->GetMotionMaster()->MoveIdle(); darnavan->GetMotionMaster()->MoveIdle();
darnavan->StopMoving(); darnavan->StopMoving();
darnavan->SetReactState(REACT_PASSIVE); darnavan->SetReactState(REACT_PASSIVE);
darnavan->m_Events.AddEvent(new DaranavanMoveEvent(*darnavan), darnavan->m_Events.CalculateTime(10000)); darnavan->m_Events.AddEventAtOffset(new DaranavanMoveEvent(*darnavan), 10s);
darnavan->AI()->Talk(SAY_DARNAVAN_RESCUED); darnavan->AI()->Talk(SAY_DARNAVAN_RESCUED);
if (Player* owner = killer->GetCharmerOrOwnerPlayerOrPlayerItself()) if (Player* owner = killer->GetCharmerOrOwnerPlayerOrPlayerItself())
{ {
@@ -384,7 +384,7 @@ public:
me->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE); me->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
me->SetSpeed(MOVE_RUN, 4.28571f); me->SetSpeed(MOVE_RUN, 4.28571f);
float moveTime = me->GetExactDist(&SindragosaFlyInPos) / (me->GetSpeed(MOVE_RUN) * 0.001f); float moveTime = me->GetExactDist(&SindragosaFlyInPos) / (me->GetSpeed(MOVE_RUN) * 0.001f);
me->m_Events.AddEvent(new FrostwyrmLandEvent(*me, SindragosaLandPos), me->m_Events.CalculateTime(uint64(moveTime) + 250)); me->m_Events.AddEventAtOffset(new FrostwyrmLandEvent(*me, SindragosaLandPos), Milliseconds(uint32(moveTime) + 250));
me->GetMotionMaster()->MovePoint(POINT_FROSTWYRM_FLY_IN, SindragosaFlyInPos); me->GetMotionMaster()->MovePoint(POINT_FROSTWYRM_FLY_IN, SindragosaFlyInPos);
if (!instance->GetData(DATA_SINDRAGOSA_INTRO)) if (!instance->GetData(DATA_SINDRAGOSA_INTRO))
@@ -478,7 +478,7 @@ public:
{ {
summons.Summon(summon); summons.Summon(summon);
if (summon->GetEntry() == NPC_FROST_BOMB) if (summon->GetEntry() == NPC_FROST_BOMB)
summon->m_Events.AddEvent(new FrostBombExplosion(summon, me->GetGUID()), summon->m_Events.CalculateTime(5500)); summon->m_Events.AddEventAtOffset(new FrostBombExplosion(summon, me->GetGUID()), 5500ms);
} }
void SummonedCreatureDespawn(Creature* summon) override void SummonedCreatureDespawn(Creature* summon) override
@@ -1079,7 +1079,7 @@ class spell_sindragosa_ice_tomb_trap_aura : public AuraScript
void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
if (Unit* c = GetCaster()) if (Unit* c = GetCaster())
GetTarget()->m_Events.AddEvent(new IceTombSummonEvent(GetTarget(), c->GetGUID()), GetTarget()->m_Events.CalculateTime(500)); GetTarget()->m_Events.AddEventAtOffset(new IceTombSummonEvent(GetTarget(), c->GetGUID()), 500ms);
} }
void ExtraRemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void ExtraRemoveEffect(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
@@ -1245,7 +1245,7 @@ public:
me->setActive(true); me->setActive(true);
me->SetImmuneToPC(true); me->SetImmuneToPC(true);
float moveTime = me->GetExactDist(&SpinestalkerFlyPos) / (me->GetSpeed(MOVE_RUN) * 0.001f); float moveTime = me->GetExactDist(&SpinestalkerFlyPos) / (me->GetSpeed(MOVE_RUN) * 0.001f);
me->m_Events.AddEvent(new FrostwyrmLandEvent(*me, SpinestalkerLandPos), me->m_Events.CalculateTime(uint64(moveTime) + 250)); me->m_Events.AddEventAtOffset(new FrostwyrmLandEvent(*me, SpinestalkerLandPos), Milliseconds(uint32(moveTime) + 250));
me->SetDefaultMovementType(IDLE_MOTION_TYPE); me->SetDefaultMovementType(IDLE_MOTION_TYPE);
me->GetMotionMaster()->MoveIdle(); me->GetMotionMaster()->MoveIdle();
me->StopMoving(); me->StopMoving();
@@ -1376,7 +1376,7 @@ public:
me->setActive(true); me->setActive(true);
me->SetImmuneToPC(true); me->SetImmuneToPC(true);
float moveTime = me->GetExactDist(&RimefangFlyPos) / (me->GetSpeed(MOVE_RUN) * 0.001f); float moveTime = me->GetExactDist(&RimefangFlyPos) / (me->GetSpeed(MOVE_RUN) * 0.001f);
me->m_Events.AddEvent(new FrostwyrmLandEvent(*me, RimefangLandPos), me->m_Events.CalculateTime(uint64(moveTime) + 250)); me->m_Events.AddEventAtOffset(new FrostwyrmLandEvent(*me, RimefangLandPos), Milliseconds(uint32(moveTime) + 250));
me->SetDefaultMovementType(IDLE_MOTION_TYPE); me->SetDefaultMovementType(IDLE_MOTION_TYPE);
me->GetMotionMaster()->MoveIdle(); me->GetMotionMaster()->MoveIdle();
me->StopMoving(); me->StopMoving();
@@ -552,7 +552,7 @@ public:
if (--_counter) if (--_counter)
{ {
_owner->m_Events.AddEvent(this, _owner->m_Events.CalculateTime(3000)); _owner->m_Events.AddEventAtOffset(this, 3s);
return false; return false;
} }
@@ -830,8 +830,8 @@ public:
if (Creature* terenas = me->FindNearestCreature(NPC_TERENAS_MENETHIL_OUTRO, 50.0f)) if (Creature* terenas = me->FindNearestCreature(NPC_TERENAS_MENETHIL_OUTRO, 50.0f))
terenas->DespawnOrUnsummon(1ms); terenas->DespawnOrUnsummon(1ms);
me->m_Events.AddEvent(new LichKingDeathEvent(*me), me->m_Events.CalculateTime(2500)); // die after spinning anim is over, so death anim is visible me->m_Events.AddEventAtOffset(new LichKingDeathEvent(*me), 2500ms); // die after spinning anim is over, so death anim is visible
me->m_Events.AddEvent(new LichKingMovieEvent(*me), me->m_Events.CalculateTime(11500)); me->m_Events.AddEventAtOffset(new LichKingMovieEvent(*me), 11500ms);
} }
if (!_bFordringMustFallYell && me->GetHealth() < 500000) if (!_bFordringMustFallYell && me->GetHealth() < 500000)
@@ -862,7 +862,7 @@ public:
summon->CastSpell(summon, SPELL_RISEN_WITCH_DOCTOR_SPAWN, true); summon->CastSpell(summon, SPELL_RISEN_WITCH_DOCTOR_SPAWN, true);
summon->SetReactState(REACT_PASSIVE); summon->SetReactState(REACT_PASSIVE);
summon->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE); summon->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE);
summon->m_Events.AddEvent(new StartMovementEvent(me, summon), summon->m_Events.CalculateTime(5000)); summon->m_Events.AddEventAtOffset(new StartMovementEvent(me, summon), 5s);
break; break;
case NPC_RAGING_SPIRIT: case NPC_RAGING_SPIRIT:
summon->SetHomePosition(CenterPosition); summon->SetHomePosition(CenterPosition);
@@ -872,7 +872,7 @@ public:
summon->SetReactState(REACT_PASSIVE); summon->SetReactState(REACT_PASSIVE);
summon->GetMotionMaster()->MoveRandom(10.0f); summon->GetMotionMaster()->MoveRandom(10.0f);
if (_phase == PHASE_THREE) if (_phase == PHASE_THREE)
summon->m_Events.AddEvent(new VileSpiritActivateEvent(summon), summon->m_Events.CalculateTime(15000)); summon->m_Events.AddEventAtOffset(new VileSpiritActivateEvent(summon), 15s);
break; break;
} }
case NPC_STRANGULATE_VEHICLE: case NPC_STRANGULATE_VEHICLE:
@@ -1189,7 +1189,7 @@ public:
if (summon->GetEntry() == NPC_VILE_SPIRIT) if (summon->GetEntry() == NPC_VILE_SPIRIT)
{ {
summon->m_Events.KillAllEvents(true); summon->m_Events.KillAllEvents(true);
summon->m_Events.AddEvent(new VileSpiritActivateEvent(summon), summon->m_Events.CalculateTime(55000)); summon->m_Events.AddEventAtOffset(new VileSpiritActivateEvent(summon), 55s);
summon->GetMotionMaster()->Clear(true); summon->GetMotionMaster()->Clear(true);
summon->StopMoving(); summon->StopMoving();
summon->SetReactState(REACT_PASSIVE); summon->SetReactState(REACT_PASSIVE);
@@ -1213,7 +1213,7 @@ public:
{ {
spawner->CastSpell(spawner, SPELL_SUMMON_SPIRIT_BOMB_1, true); // summons bombs randomly spawner->CastSpell(spawner, SPELL_SUMMON_SPIRIT_BOMB_1, true); // summons bombs randomly
spawner->CastSpell(spawner, SPELL_SUMMON_SPIRIT_BOMB_2, true); // summons bombs on players spawner->CastSpell(spawner, SPELL_SUMMON_SPIRIT_BOMB_2, true); // summons bombs on players
spawner->m_Events.AddEvent(new TriggerWickedSpirit(spawner), spawner->m_Events.CalculateTime(3000)); spawner->m_Events.AddEventAtOffset(new TriggerWickedSpirit(spawner), 3s);
terenas->SetImmuneToAll(true); // to avoid being healed by player trinket procs. terenas' health doesn't matter on heroic terenas->SetImmuneToAll(true); // to avoid being healed by player trinket procs. terenas' health doesn't matter on heroic
} }
} }
@@ -417,13 +417,13 @@ public:
{ {
if (summon->GetEntry() == NPC_DREAM_PORTAL_PRE_EFFECT) if (summon->GetEntry() == NPC_DREAM_PORTAL_PRE_EFFECT)
{ {
summon->m_Events.AddEvent(new DelayedCastEvent(summon, SPELL_SUMMON_DREAM_PORTAL, me->GetGUID(), 6s), summon->m_Events.CalculateTime(15000)); summon->m_Events.AddEventAtOffset(new DelayedCastEvent(summon, SPELL_SUMMON_DREAM_PORTAL, me->GetGUID(), 6s), 15s);
summon->m_Events.AddEvent(new AuraRemoveEvent(summon, SPELL_DREAM_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000)); summon->m_Events.AddEventAtOffset(new AuraRemoveEvent(summon, SPELL_DREAM_PORTAL_VISUAL_PRE), 15s);
} }
else if (summon->GetEntry() == NPC_NIGHTMARE_PORTAL_PRE_EFFECT) else if (summon->GetEntry() == NPC_NIGHTMARE_PORTAL_PRE_EFFECT)
{ {
summon->m_Events.AddEvent(new DelayedCastEvent(summon, SPELL_SUMMON_NIGHTMARE_PORTAL, me->GetGUID(), 6s), summon->m_Events.CalculateTime(15000)); summon->m_Events.AddEventAtOffset(new DelayedCastEvent(summon, SPELL_SUMMON_NIGHTMARE_PORTAL, me->GetGUID(), 6s), 15s);
summon->m_Events.AddEvent(new AuraRemoveEvent(summon, SPELL_NIGHTMARE_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000)); summon->m_Events.AddEventAtOffset(new AuraRemoveEvent(summon, SPELL_NIGHTMARE_PORTAL_VISUAL_PRE), 15s);
} }
} }
@@ -579,7 +579,7 @@ public:
void DoAction(int32 action) override void DoAction(int32 action) override
{ {
if (action == ACTION_DEATH) if (action == ACTION_DEATH)
me->m_Events.AddEvent(new ValithriaDespawner(me), me->m_Events.CalculateTime(5000)); me->m_Events.AddEventAtOffset(new ValithriaDespawner(me), 5s);
else if (action == ACTION_ENTER_COMBAT) else if (action == ACTION_ENTER_COMBAT)
{ {
if (!me->IsInCombat()) if (!me->IsInCombat())
@@ -750,7 +750,7 @@ public:
void JustSummoned(Creature* summon) override void JustSummoned(Creature* summon) override
{ {
if (summon->GetEntry() == NPC_COLUMN_OF_FROST) if (summon->GetEntry() == NPC_COLUMN_OF_FROST)
summon->m_Events.AddEvent(new DelayedCastEvent(summon, SPELL_COLUMN_OF_FROST_DAMAGE, ObjectGuid::Empty, 8s), summon->m_Events.CalculateTime(2000)); summon->m_Events.AddEventAtOffset(new DelayedCastEvent(summon, SPELL_COLUMN_OF_FROST_DAMAGE, ObjectGuid::Empty, 8s), 2s);
else if (summon->GetEntry() == NPC_MANA_VOID) else if (summon->GetEntry() == NPC_MANA_VOID)
summon->DespawnOrUnsummon(36s); summon->DespawnOrUnsummon(36s);
} }
@@ -1017,15 +1017,15 @@ public:
if (Creature* crok = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CROK_SCOURGEBANE))) // _isEventDone = true, setActive(false) if (Creature* crok = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CROK_SCOURGEBANE))) // _isEventDone = true, setActive(false)
crok->AI()->DoAction(ACTION_RESET_EVENT); crok->AI()->DoAction(ACTION_RESET_EVENT);
uint64 delay = 6000; Milliseconds delay = 6s;
for (uint32 i = 0; i < 4; ++i) for (uint32 i = 0; i < 4; ++i)
if (Creature* crusader = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CAPTAIN_ARNATH + i))) if (Creature* crusader = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CAPTAIN_ARNATH + i)))
if (crusader->IsAlive()) if (crusader->IsAlive())
{ {
if (crusader->GetEntry() == crusader->GetCreatureData()->id1) if (crusader->GetEntry() == crusader->GetCreatureData()->id1)
{ {
crusader->m_Events.AddEvent(new CaptainSurviveTalk(*crusader), crusader->m_Events.CalculateTime(delay)); crusader->m_Events.AddEventAtOffset(new CaptainSurviveTalk(*crusader), delay);
delay += 6000; delay += 6s;
} }
else else
Unit::Kill(crusader, crusader); Unit::Kill(crusader, crusader);
@@ -513,7 +513,7 @@ public:
spellId = BLOOD_BEAM_VISUAL_LLEG; spellId = BLOOD_BEAM_VISUAL_LLEG;
else else
spellId = BLOOD_BEAM_VISUAL_RLEG; spellId = BLOOD_BEAM_VISUAL_RLEG;
creature->m_Events.AddEvent(new DelayedCastMincharEvent(creature, spellId), creature->m_Events.CalculateTime(1000)); creature->m_Events.AddEventAtOffset(new DelayedCastMincharEvent(creature, spellId), 1s);
} }
break; break;
case NPC_SKYBREAKER_DECKHAND: case NPC_SKYBREAKER_DECKHAND:
@@ -608,7 +608,7 @@ public:
std::string name2("Kor'kron "); std::string name2("Kor'kron ");
if (!creature->GetTransport() && creature->GetPositionZ() <= 205.0f && creature->GetExactDist2d(-439.0f, 2210.0f) <= 150.0f && (creature->GetEntry() == 37544 || creature->GetEntry() == 37545 || creature->GetName().compare(0, name1.length(), name1) == 0 || creature->GetName().compare(0, name2.length(), name2) == 0)) if (!creature->GetTransport() && creature->GetPositionZ() <= 205.0f && creature->GetExactDist2d(-439.0f, 2210.0f) <= 150.0f && (creature->GetEntry() == 37544 || creature->GetEntry() == 37545 || creature->GetName().compare(0, name1.length(), name1) == 0 || creature->GetName().compare(0, name2.length(), name2) == 0))
if (!creature->GetLootRecipient()) if (!creature->GetLootRecipient())
creature->m_Events.AddEvent(new RespawnEvent(*creature), creature->m_Events.CalculateTime(3000)); creature->m_Events.AddEventAtOffset(new RespawnEvent(*creature), 3s);
switch (creature->GetEntry()) switch (creature->GetEntry())
{ {
@@ -727,7 +727,7 @@ public:
{ {
c->SetFaction(pPlayer->GetFaction()); c->SetFaction(pPlayer->GetFaction());
//pPlayer->CastCustomSpell(60683, SPELLVALUE_BASE_POINT0, 1, c, true); //pPlayer->CastCustomSpell(60683, SPELLVALUE_BASE_POINT0, 1, c, true);
c->m_Events.AddEvent(new EoEDrakeEnterVehicleEvent(*c, pPlayer->GetGUID()), c->m_Events.CalculateTime(500)); c->m_Events.AddEventAtOffset(new EoEDrakeEnterVehicleEvent(*c, pPlayer->GetGUID()), 500ms);
AttackStart(c); AttackStart(c);
} }
} }
@@ -89,7 +89,7 @@ public:
c->SetCanFly(true); c->SetCanFly(true);
c->SetFaction(pPlayer->GetFaction()); c->SetFaction(pPlayer->GetFaction());
//pPlayer->CastCustomSpell(60683, SPELLVALUE_BASE_POINT0, 1, c, true); //pPlayer->CastCustomSpell(60683, SPELLVALUE_BASE_POINT0, 1, c, true);
c->m_Events.AddEvent(new EoEDrakeEnterVehicleEvent(*c, pPlayer->GetGUID()), c->m_Events.CalculateTime(500)); c->m_Events.AddEventAtOffset(new EoEDrakeEnterVehicleEvent(*c, pPlayer->GetGUID()), 500ms);
} }
} }
} }
@@ -171,7 +171,7 @@ struct boss_anomalus : public BossAI
me->CastSpell(me, SPELL_CREATE_RIFT, false); me->CastSpell(me, SPELL_CREATE_RIFT, false);
me->CastSpell(me, SPELL_RIFT_SHIELD, true); me->CastSpell(me, SPELL_RIFT_SHIELD, true);
me->m_Events.AddEvent(new ChargeRifts(me), me->m_Events.CalculateTime(1000)); me->m_Events.AddEventAtOffset(new ChargeRifts(me), 1s);
events.DelayEvents(46s); events.DelayEvents(46s);
//As we just spawned an empowered spawn a normal one //As we just spawned an empowered spawn a normal one
events.ScheduleEvent(EVENT_ANOMALUS_SPAWN_RIFT, IsHeroic() ? 15s : 25s); events.ScheduleEvent(EVENT_ANOMALUS_SPAWN_RIFT, IsHeroic() ? 15s : 25s);
@@ -574,7 +574,7 @@ public:
summon->SetHomePosition(x, y, z, o); summon->SetHomePosition(x, y, z, o);
summon->UpdatePosition(x, y, z, o, true); summon->UpdatePosition(x, y, z, o, true);
summon->StopMovingOnCurrentPos(); summon->StopMovingOnCurrentPos();
summon->m_Events.AddEvent(new CosmicSmashDamageEvent(summon), summon->m_Events.CalculateTime(4000)); summon->m_Events.AddEventAtOffset(new CosmicSmashDamageEvent(summon), 4s);
break; break;
} }
case NPC_UNLEASHED_DARK_MATTER: case NPC_UNLEASHED_DARK_MATTER:
@@ -418,7 +418,7 @@ public:
if (pInstance) if (pInstance)
pInstance->SetData(TYPE_ASSEMBLY, NOT_STARTED); pInstance->SetData(TYPE_ASSEMBLY, NOT_STARTED);
me->m_Events.AddEvent(new CastRunesEvent(*me), me->m_Events.CalculateTime(8000)); me->m_Events.AddEventAtOffset(new CastRunesEvent(*me), 8s);
} }
void JustReachedHome() override void JustReachedHome() override
@@ -769,12 +769,12 @@ public:
// so that can't be the issue // so that can't be the issue
// See BoomEvent class // See BoomEvent class
// Schedule 1s delayed // Schedule 1s delayed
me->m_Events.AddEvent(new BoomEvent(me), me->m_Events.CalculateTime(1 * IN_MILLISECONDS)); me->m_Events.AddEventAtOffset(new BoomEvent(me), 1s);
} }
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
me->m_Events.AddEvent(new BoomEvent(me), me->m_Events.CalculateTime(1 * IN_MILLISECONDS)); me->m_Events.AddEventAtOffset(new BoomEvent(me), 1s);
} }
void DamageTaken(Unit*, uint32& damage, DamageEffectType, SpellSchoolMask) override void DamageTaken(Unit*, uint32& damage, DamageEffectType, SpellSchoolMask) override
@@ -1439,7 +1439,7 @@ public:
{ {
me->SetDisplayId(me->GetNativeDisplayId()); me->SetDisplayId(me->GetNativeDisplayId());
me->CastSpell(me, SPELL_SAC_EMERGE, true); me->CastSpell(me, SPELL_SAC_EMERGE, true);
me->m_Events.AddEvent(new SACActivateEvent(me), me->m_Events.CalculateTime(4000)); me->m_Events.AddEventAtOffset(new SACActivateEvent(me), 4s);
} }
void Deactivate() void Deactivate()
@@ -1452,7 +1452,7 @@ public:
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
me->RemoveAurasDueToSpell(SPELL_SAC_GHOUL_AREA_AURA); me->RemoveAurasDueToSpell(SPELL_SAC_GHOUL_AREA_AURA);
me->m_Events.AddEvent(new SACDeactivateEvent(me), me->m_Events.CalculateTime(4000)); me->m_Events.AddEventAtOffset(new SACDeactivateEvent(me), 4s);
} }
void JustRespawned() override void JustRespawned() override
@@ -975,7 +975,7 @@ public:
}; };
if (who->IsPlayer()) if (who->IsPlayer())
who->m_Events.AddEvent(new DelayedTransportPositionOffsets(who), who->m_Events.CalculateTime(500)); who->m_Events.AddEventAtOffset(new DelayedTransportPositionOffsets(who), 500ms);
return; return;
} }
@@ -771,7 +771,7 @@ class spell_illidari_council_deadly_strike_aura : public AuraScript
if (Unit* target = GetUnitOwner()->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true)) if (Unit* target = GetUnitOwner()->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
{ {
GetUnitOwner()->CastSpell(target, GetSpellInfo()->Effects[effect->GetEffIndex()].TriggerSpell, true); GetUnitOwner()->CastSpell(target, GetSpellInfo()->Effects[effect->GetEffIndex()].TriggerSpell, true);
GetUnitOwner()->m_Events.AddEvent(new VerasEnvenom(*GetUnitOwner(), target->GetGUID()), GetUnitOwner()->m_Events.CalculateTime(urand(1500, 3500))); GetUnitOwner()->m_Events.AddEventAtOffset(new VerasEnvenom(*GetUnitOwner(), target->GetGUID()), randtime(1500ms, 3500ms));
} }
} }
@@ -284,7 +284,7 @@ public:
if (type != POINT_MOTION_TYPE || id != POINT_GO_BACK) if (type != POINT_MOTION_TYPE || id != POINT_GO_BACK)
return; return;
me->m_Events.AddEvent(new SuckBackEvent(*me, ACTION_ESSENCE_OF_SUFFERING), me->m_Events.CalculateTime(1500)); me->m_Events.AddEventAtOffset(new SuckBackEvent(*me, ACTION_ESSENCE_OF_SUFFERING), 1500ms);
me->SetTarget(); me->SetTarget();
me->SetFacingTo(M_PI / 2.0f); me->SetFacingTo(M_PI / 2.0f);
} }
@@ -392,7 +392,7 @@ public:
if (type != POINT_MOTION_TYPE || id != POINT_GO_BACK) if (type != POINT_MOTION_TYPE || id != POINT_GO_BACK)
return; return;
me->m_Events.AddEvent(new SuckBackEvent(*me, ACTION_ESSENCE_OF_DESIRE), me->m_Events.CalculateTime(1500)); me->m_Events.AddEventAtOffset(new SuckBackEvent(*me, ACTION_ESSENCE_OF_DESIRE), 1500ms);
me->SetTarget(); me->SetTarget();
me->SetFacingTo(M_PI / 2.0f); me->SetFacingTo(M_PI / 2.0f);
} }
@@ -452,10 +452,10 @@ class spell_alar_flame_quills : public AuraScript
// 24 spells in total // 24 spells in total
for (uint8 i = 0; i < 21; ++i) for (uint8 i = 0; i < 21; ++i)
GetUnitOwner()->m_Events.AddEvent(new CastQuill(GetUnitOwner(), SPELL_QUILL_MISSILE_1 + i), GetUnitOwner()->m_Events.CalculateTime(i * 40)); GetUnitOwner()->m_Events.AddEventAtOffset(new CastQuill(GetUnitOwner(), SPELL_QUILL_MISSILE_1 + i), Milliseconds(i * 40));
GetUnitOwner()->m_Events.AddEvent(new CastQuill(GetUnitOwner(), SPELL_QUILL_MISSILE_2 + 0), GetUnitOwner()->m_Events.CalculateTime(22 * 40)); GetUnitOwner()->m_Events.AddEventAtOffset(new CastQuill(GetUnitOwner(), SPELL_QUILL_MISSILE_2 + 0), Milliseconds(22 * 40));
GetUnitOwner()->m_Events.AddEvent(new CastQuill(GetUnitOwner(), SPELL_QUILL_MISSILE_2 + 1), GetUnitOwner()->m_Events.CalculateTime(23 * 40)); GetUnitOwner()->m_Events.AddEventAtOffset(new CastQuill(GetUnitOwner(), SPELL_QUILL_MISSILE_2 + 1), Milliseconds(23 * 40));
GetUnitOwner()->m_Events.AddEvent(new CastQuill(GetUnitOwner(), SPELL_QUILL_MISSILE_2 + 2), GetUnitOwner()->m_Events.CalculateTime(24 * 40)); GetUnitOwner()->m_Events.AddEventAtOffset(new CastQuill(GetUnitOwner(), SPELL_QUILL_MISSILE_2 + 2), Milliseconds(24 * 40));
} }
void Register() override void Register() override
@@ -1032,7 +1032,7 @@ public:
bool Execute(uint64 /*execTime*/, uint32 /*diff*/) override bool Execute(uint64 /*execTime*/, uint32 /*diff*/) override
{ {
if (_owner->IsBeingTeleportedNear()) if (_owner->IsBeingTeleportedNear())
_owner->m_Events.AddEvent(new lapseTeleport(_owner), _owner->m_Events.CalculateTime(1)); _owner->m_Events.AddEventAtOffset(new lapseTeleport(_owner), 1ms);
else if (!_owner->IsBeingTeleported()) else if (!_owner->IsBeingTeleported())
{ {
_owner->CastSpell(_owner, SPELL_GRAVITY_LAPSE_KNOCKBACK, true); _owner->CastSpell(_owner, SPELL_GRAVITY_LAPSE_KNOCKBACK, true);
@@ -1062,7 +1062,7 @@ class spell_kaelthas_gravity_lapse : public SpellScript
if (Player* target = GetHitPlayer()) if (Player* target = GetHitPlayer())
{ {
GetCaster()->CastSpell(target, _currentSpellId++, true); GetCaster()->CastSpell(target, _currentSpellId++, true);
target->m_Events.AddEvent(new lapseTeleport(target), target->m_Events.CalculateTime(1)); target->m_Events.AddEventAtOffset(new lapseTeleport(target), 1ms);
} }
} }
+2 -2
View File
@@ -193,7 +193,7 @@ struct npc_pet_gen_argent_pony_bridle : public ScriptedAI
duration = cooldown; duration = cooldown;
aura = SPELL_AURA_POSTMAN_S + i; aura = SPELL_AURA_POSTMAN_S + i;
_state = argentPonyService[TEAM_ALLIANCE][i]; _state = argentPonyService[TEAM_ALLIANCE][i];
me->ToTempSummon()->UnSummon(duration); me->ToTempSummon()->UnSummon(Milliseconds(duration));
break; break;
} }
} }
@@ -204,7 +204,7 @@ struct npc_pet_gen_argent_pony_bridle : public ScriptedAI
duration = cooldown * IN_MILLISECONDS; duration = cooldown * IN_MILLISECONDS;
aura = SPELL_AURA_BANK_G + i; aura = SPELL_AURA_BANK_G + i;
_state = argentPonyService[TEAM_HORDE][i]; _state = argentPonyService[TEAM_HORDE][i];
me->ToTempSummon()->UnSummon(duration); me->ToTempSummon()->UnSummon(Milliseconds(duration));
break; break;
} }
} }
+1 -1
View File
@@ -138,7 +138,7 @@ struct npc_pet_mage_mirror_image : CasterAI
newAura->SetDuration(visAura->GetDuration()); newAura->SetDuration(visAura->GetDuration());
} }
me->m_Events.AddEvent(new DeathEvent(*me), me->m_Events.CalculateTime(29500)); me->m_Events.AddEventAtOffset(new DeathEvent(*me), 29500ms);
} }
// Do not reload Creature templates on evade mode enter - prevent visual lost // Do not reload Creature templates on evade mode enter - prevent visual lost
+2 -2
View File
@@ -1669,7 +1669,7 @@ public:
_player->HandleEmoteCommand(RAND(EMOTE_ONESHOT_APPLAUD, EMOTE_ONESHOT_DANCESPECIAL, EMOTE_ONESHOT_LAUGH, EMOTE_ONESHOT_CHEER, EMOTE_ONESHOT_CHICKEN)); _player->HandleEmoteCommand(RAND(EMOTE_ONESHOT_APPLAUD, EMOTE_ONESHOT_DANCESPECIAL, EMOTE_ONESHOT_LAUGH, EMOTE_ONESHOT_CHEER, EMOTE_ONESHOT_CHICKEN));
} }
_player->m_Events.AddEvent(this, RAND(_player->m_Events.CalculateTime(5000), _player->m_Events.CalculateTime(10000), _player->m_Events.CalculateTime(15000))); _player->m_Events.AddEventAtOffset(this, RAND(5s, 10s, 15s));
return false; // do not delete re-added event in EventProcessor::Update return false; // do not delete re-added event in EventProcessor::Update
} }
@@ -1690,7 +1690,7 @@ class spell_item_party_time : public AuraScript
return; return;
} }
player->m_Events.AddEvent(new PartyTimeEmoteEvent(player), RAND(player->m_Events.CalculateTime(5000), player->m_Events.CalculateTime(10000), player->m_Events.CalculateTime(15000))); player->m_Events.AddEventAtOffset(new PartyTimeEmoteEvent(player), RAND(5s, 10s, 15s));
} }
void Register() override void Register() override