Core/EscortAI: std::chrono-ify SetPauseTimer

This commit is contained in:
Carbenium
2020-07-25 21:53:55 +02:00
committed by Peter Keresztes Schmidt
parent 4b9fdc5d3d
commit cdaf890af4
3 changed files with 11 additions and 11 deletions

View File

@@ -33,7 +33,7 @@ enum Points
POINT_HOME = 0xFFFFFE
};
EscortAI::EscortAI(Creature* creature) : ScriptedAI(creature), _pauseTimer(2500), _playerCheckTimer(1000), _escortState(STATE_ESCORT_NONE), _maxPlayerDistance(DEFAULT_MAX_PLAYER_DISTANCE),
EscortAI::EscortAI(Creature* creature) : ScriptedAI(creature), _pauseTimer(2500ms), _playerCheckTimer(1000), _escortState(STATE_ESCORT_NONE), _maxPlayerDistance(DEFAULT_MAX_PLAYER_DISTANCE),
_escortQuest(nullptr), _activeAttacker(true), _running(false), _instantRespawn(false), _returnToStart(false), _despawnAtEnd(true), _despawnAtFar(true), _manualPath(false),
_hasImmuneToNPCFlags(false), _started(false), _ended(false), _resume(false)
{
@@ -79,7 +79,7 @@ void EscortAI::InitializeAI()
SetCombatMovement(true);
// add a small delay before going to first waypoint, normal in near all cases
_pauseTimer = 2000;
_pauseTimer = 2s;
if (me->GetFaction() != me->GetCreatureTemplate()->faction)
me->RestoreFaction();
@@ -123,8 +123,8 @@ void EscortAI::MovementInform(uint32 type, uint32 id)
if (type == POINT_MOTION_TYPE)
{
if (!_pauseTimer)
_pauseTimer = 2000;
if (_pauseTimer == 0s)
_pauseTimer = 2s;
// continue waypoint movement
if (id == POINT_LAST_POINT)
@@ -151,7 +151,7 @@ void EscortAI::MovementInform(uint32 type, uint32 id)
{
_started = false;
_ended = true;
_pauseTimer = 1000;
_pauseTimer = 1s;
}
}
}
@@ -161,11 +161,11 @@ void EscortAI::UpdateAI(uint32 diff)
// Waypoint Updating
if (HasEscortState(STATE_ESCORT_ESCORTING) && !me->IsEngaged() && !HasEscortState(STATE_ESCORT_RETURNING))
{
if (_pauseTimer <= diff)
if (_pauseTimer.count() <= diff)
{
if (!HasEscortState(STATE_ESCORT_PAUSED))
{
_pauseTimer = 0;
_pauseTimer = 0s;
if (_ended)
{
@@ -208,7 +208,7 @@ void EscortAI::UpdateAI(uint32 diff)
}
}
else
_pauseTimer -= diff;
_pauseTimer -= Milliseconds(diff);
}
// Check if player or any member of his group is within range

View File

@@ -53,7 +53,7 @@ struct TC_GAME_API EscortAI : public ScriptedAI
void SetRun(bool on = true);
void SetEscortPaused(bool on);
void SetPauseTimer(uint32 Timer) { _pauseTimer = Timer; }
void SetPauseTimer(Milliseconds timer) { _pauseTimer = timer; }
bool HasEscortState(uint32 escortState) { return (_escortState & escortState) != 0; }
bool IsEscorted() const override { return !_playerGUID.IsEmpty(); }
void SetMaxPlayerDistance(float newMax) { _maxPlayerDistance = newMax; }
@@ -76,7 +76,7 @@ struct TC_GAME_API EscortAI : public ScriptedAI
void RemoveEscortState(uint32 escortState) { _escortState &= ~escortState; }
ObjectGuid _playerGUID;
uint32 _pauseTimer;
Milliseconds _pauseTimer;
uint32 _playerCheckTimer;
uint32 _escortState;
float _maxPlayerDistance;

View File

@@ -1622,7 +1622,7 @@ public:
_events.ScheduleEvent(EVENT_TALK_1, Seconds(2));
_events.CancelEvent(EVENT_OOC_TALK);
Start(true, true, player->GetGUID());
SetPauseTimer(12 * IN_MILLISECONDS);
SetPauseTimer(12s);
}
}