mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-03-10 19:20:32 +00:00
refactor(Core): AddEventAtOffset (#23140)
This commit is contained in:
@@ -375,7 +375,7 @@ public:
|
||||
me->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
|
||||
me->SetReactState(REACT_AGGRESSIVE);
|
||||
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);
|
||||
me->SetHealth(1);
|
||||
break;
|
||||
@@ -645,7 +645,7 @@ public:
|
||||
me->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
|
||||
me->SetReactState(REACT_AGGRESSIVE);
|
||||
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);
|
||||
me->SetHealth(1);
|
||||
break;
|
||||
@@ -889,7 +889,7 @@ public:
|
||||
summon->CastSpell(summon, SPELL_KINETIC_BOMB, true, nullptr, nullptr, me->GetGUID());
|
||||
break;
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
@@ -939,7 +939,7 @@ public:
|
||||
me->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
|
||||
me->SetReactState(REACT_AGGRESSIVE);
|
||||
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());
|
||||
DoAction(ACTION_CAST_INVOCATION);
|
||||
break;
|
||||
|
||||
@@ -373,7 +373,7 @@ class BattleExperienceEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
static uint32 const ExperiencedSpells[5];
|
||||
static uint32 const ExperiencedTimes[5];
|
||||
static Milliseconds const ExperiencedTimes[5];
|
||||
|
||||
BattleExperienceEvent(Creature* creature) : _creature(creature), _level(0) { }
|
||||
|
||||
@@ -388,7 +388,8 @@ public:
|
||||
_creature->CastSpell(_creature, ExperiencedSpells[_level], true);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -401,7 +402,7 @@ private:
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
@@ -675,7 +676,7 @@ public:
|
||||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
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->SetReactState(REACT_AGGRESSIVE);
|
||||
}
|
||||
@@ -1579,7 +1580,7 @@ struct npc_gunship_boarding_addAI : public ScriptedAI
|
||||
{
|
||||
SetSlotInfo(data);
|
||||
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)
|
||||
{
|
||||
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->SetReactState(REACT_AGGRESSIVE);
|
||||
|
||||
|
||||
@@ -522,7 +522,7 @@ public:
|
||||
darnavan->GetMotionMaster()->MoveIdle();
|
||||
darnavan->StopMoving();
|
||||
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);
|
||||
if (Player* owner = killer->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
{
|
||||
|
||||
@@ -384,7 +384,7 @@ public:
|
||||
me->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
|
||||
me->SetSpeed(MOVE_RUN, 4.28571f);
|
||||
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);
|
||||
|
||||
if (!instance->GetData(DATA_SINDRAGOSA_INTRO))
|
||||
@@ -478,7 +478,7 @@ public:
|
||||
{
|
||||
summons.Summon(summon);
|
||||
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
|
||||
@@ -1079,7 +1079,7 @@ class spell_sindragosa_ice_tomb_trap_aura : public AuraScript
|
||||
void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
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*/)
|
||||
@@ -1245,7 +1245,7 @@ public:
|
||||
me->setActive(true);
|
||||
me->SetImmuneToPC(true);
|
||||
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->GetMotionMaster()->MoveIdle();
|
||||
me->StopMoving();
|
||||
@@ -1376,7 +1376,7 @@ public:
|
||||
me->setActive(true);
|
||||
me->SetImmuneToPC(true);
|
||||
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->GetMotionMaster()->MoveIdle();
|
||||
me->StopMoving();
|
||||
|
||||
@@ -552,7 +552,7 @@ public:
|
||||
|
||||
if (--_counter)
|
||||
{
|
||||
_owner->m_Events.AddEvent(this, _owner->m_Events.CalculateTime(3000));
|
||||
_owner->m_Events.AddEventAtOffset(this, 3s);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -830,8 +830,8 @@ public:
|
||||
if (Creature* terenas = me->FindNearestCreature(NPC_TERENAS_MENETHIL_OUTRO, 50.0f))
|
||||
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.AddEvent(new LichKingMovieEvent(*me), me->m_Events.CalculateTime(11500));
|
||||
me->m_Events.AddEventAtOffset(new LichKingDeathEvent(*me), 2500ms); // die after spinning anim is over, so death anim is visible
|
||||
me->m_Events.AddEventAtOffset(new LichKingMovieEvent(*me), 11500ms);
|
||||
}
|
||||
|
||||
if (!_bFordringMustFallYell && me->GetHealth() < 500000)
|
||||
@@ -862,7 +862,7 @@ public:
|
||||
summon->CastSpell(summon, SPELL_RISEN_WITCH_DOCTOR_SPAWN, true);
|
||||
summon->SetReactState(REACT_PASSIVE);
|
||||
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;
|
||||
case NPC_RAGING_SPIRIT:
|
||||
summon->SetHomePosition(CenterPosition);
|
||||
@@ -872,7 +872,7 @@ public:
|
||||
summon->SetReactState(REACT_PASSIVE);
|
||||
summon->GetMotionMaster()->MoveRandom(10.0f);
|
||||
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;
|
||||
}
|
||||
case NPC_STRANGULATE_VEHICLE:
|
||||
@@ -1189,7 +1189,7 @@ public:
|
||||
if (summon->GetEntry() == NPC_VILE_SPIRIT)
|
||||
{
|
||||
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->StopMoving();
|
||||
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_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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,13 +417,13 @@ public:
|
||||
{
|
||||
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.AddEvent(new AuraRemoveEvent(summon, SPELL_DREAM_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000));
|
||||
summon->m_Events.AddEventAtOffset(new DelayedCastEvent(summon, SPELL_SUMMON_DREAM_PORTAL, me->GetGUID(), 6s), 15s);
|
||||
summon->m_Events.AddEventAtOffset(new AuraRemoveEvent(summon, SPELL_DREAM_PORTAL_VISUAL_PRE), 15s);
|
||||
}
|
||||
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.AddEvent(new AuraRemoveEvent(summon, SPELL_NIGHTMARE_PORTAL_VISUAL_PRE), summon->m_Events.CalculateTime(15000));
|
||||
summon->m_Events.AddEventAtOffset(new DelayedCastEvent(summon, SPELL_SUMMON_NIGHTMARE_PORTAL, me->GetGUID(), 6s), 15s);
|
||||
summon->m_Events.AddEventAtOffset(new AuraRemoveEvent(summon, SPELL_NIGHTMARE_PORTAL_VISUAL_PRE), 15s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ public:
|
||||
void DoAction(int32 action) override
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (!me->IsInCombat())
|
||||
@@ -750,7 +750,7 @@ public:
|
||||
void JustSummoned(Creature* summon) override
|
||||
{
|
||||
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)
|
||||
summon->DespawnOrUnsummon(36s);
|
||||
}
|
||||
|
||||
@@ -1017,15 +1017,15 @@ public:
|
||||
if (Creature* crok = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CROK_SCOURGEBANE))) // _isEventDone = true, setActive(false)
|
||||
crok->AI()->DoAction(ACTION_RESET_EVENT);
|
||||
|
||||
uint64 delay = 6000;
|
||||
Milliseconds delay = 6s;
|
||||
for (uint32 i = 0; i < 4; ++i)
|
||||
if (Creature* crusader = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CAPTAIN_ARNATH + i)))
|
||||
if (crusader->IsAlive())
|
||||
{
|
||||
if (crusader->GetEntry() == crusader->GetCreatureData()->id1)
|
||||
{
|
||||
crusader->m_Events.AddEvent(new CaptainSurviveTalk(*crusader), crusader->m_Events.CalculateTime(delay));
|
||||
delay += 6000;
|
||||
crusader->m_Events.AddEventAtOffset(new CaptainSurviveTalk(*crusader), delay);
|
||||
delay += 6s;
|
||||
}
|
||||
else
|
||||
Unit::Kill(crusader, crusader);
|
||||
|
||||
@@ -513,7 +513,7 @@ public:
|
||||
spellId = BLOOD_BEAM_VISUAL_LLEG;
|
||||
else
|
||||
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;
|
||||
case NPC_SKYBREAKER_DECKHAND:
|
||||
@@ -608,7 +608,7 @@ public:
|
||||
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->GetLootRecipient())
|
||||
creature->m_Events.AddEvent(new RespawnEvent(*creature), creature->m_Events.CalculateTime(3000));
|
||||
creature->m_Events.AddEventAtOffset(new RespawnEvent(*creature), 3s);
|
||||
|
||||
switch (creature->GetEntry())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user