mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-07 01:18:55 +01:00
Core/Movement: fixed waypoint movement ignoring pause timers and interaction pause time
This commit is contained in:
@@ -179,7 +179,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPackets::NPC::Hello& packet)
|
||||
// Stop the npc if moving
|
||||
if (uint32 pause = unit->GetMovementTemplate().GetInteractionPauseTimer())
|
||||
{
|
||||
unit->PauseMovement(sWorld->getIntConfig(CONFIG_CREATURE_STOP_FOR_PLAYER));
|
||||
unit->PauseMovement(pause);
|
||||
unit->SetHomePosition(unit->GetPosition());
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
#include "Transport.h"
|
||||
#include "WaypointManager.h"
|
||||
|
||||
WaypointMovementGenerator<Creature>::WaypointMovementGenerator(uint32 pathId, bool repeating) : _lastSplineId(0), _pathId(pathId), _waypointDelay(0),
|
||||
WaypointMovementGenerator<Creature>::WaypointMovementGenerator(uint32 pathId, bool repeating) : _lastSplineId(0), _pathId(pathId), _waypointDelay(0), _pauseTime(0),
|
||||
_waypointReached(true), _recalculateSpeed(false), _repeating(repeating), _loadedFromDB(true), _stalled(false), _hasBeenStalled(false), _done(false)
|
||||
{
|
||||
}
|
||||
|
||||
WaypointMovementGenerator<Creature>::WaypointMovementGenerator(WaypointPath& path, bool repeating) : _lastSplineId(0), _pathId(0), _waypointDelay(0),
|
||||
WaypointMovementGenerator<Creature>::WaypointMovementGenerator(WaypointPath& path, bool repeating) : _lastSplineId(0), _pathId(0), _waypointDelay(0), _pauseTime(0),
|
||||
_waypointReached(true), _recalculateSpeed(false), _repeating(repeating), _loadedFromDB(false), _stalled(false), _hasBeenStalled(false), _done(false)
|
||||
{
|
||||
_path = &path;
|
||||
@@ -239,7 +239,7 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature* creature, bool rel
|
||||
init.SetVelocity(waypoint.Velocity);
|
||||
|
||||
init.Launch();
|
||||
_waypointDelay = std::abs(waypoint.Delay);
|
||||
_waypointDelay = waypoint.Delay;
|
||||
|
||||
if (!creature->movespline->Finalized())
|
||||
_lastSplineId = creature->movespline->GetId();
|
||||
@@ -271,6 +271,10 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
|
||||
if (_waypointDelay > 0)
|
||||
_waypointDelay -= diff;
|
||||
|
||||
// Creature's movement has been paused.
|
||||
if (_pauseTime > 0)
|
||||
_pauseTime -= diff;
|
||||
|
||||
// Creature cannot move at the moment. Stop movement and hold further updates until the creature can move again.
|
||||
if (!IsAllowedToMove(creature))
|
||||
{
|
||||
@@ -311,7 +315,7 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
|
||||
if (!hasToRelaunchSpline && _waypointDelay > 0)
|
||||
return true;
|
||||
|
||||
if (shouldLaunchNextSpline)
|
||||
if (shouldLaunchNextSpline || hasToRelaunchSpline)
|
||||
StartMove(creature, hasToRelaunchSpline);
|
||||
|
||||
// Set home position to current position.
|
||||
@@ -322,19 +326,19 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
|
||||
return true;
|
||||
}
|
||||
|
||||
void WaypointMovementGenerator<Creature>::Pause(uint32 timer/* = 0*/)
|
||||
void WaypointMovementGenerator<Creature>::Pause(uint32 timer /*= 0*/)
|
||||
{
|
||||
_stalled = timer ? false : true;
|
||||
_hasBeenStalled = !_waypointReached;
|
||||
_waypointDelay = 0;
|
||||
_pauseTime = timer;
|
||||
}
|
||||
|
||||
void WaypointMovementGenerator<Creature>::Resume(uint32 overrideTimer/* = 0*/)
|
||||
void WaypointMovementGenerator<Creature>::Resume(uint32 overrideTimer /*= 0*/)
|
||||
{
|
||||
_hasBeenStalled = !_waypointReached;
|
||||
_stalled = false;
|
||||
if (overrideTimer)
|
||||
_waypointDelay = overrideTimer;
|
||||
_pauseTime = overrideTimer;
|
||||
}
|
||||
|
||||
bool WaypointMovementGenerator<Creature>::GetResetPosition(Unit* /*owner*/, float& x, float& y, float& z)
|
||||
@@ -354,5 +358,5 @@ bool WaypointMovementGenerator<Creature>::GetResetPosition(Unit* /*owner*/, floa
|
||||
|
||||
bool WaypointMovementGenerator<Creature>::IsAllowedToMove(Creature* creature)
|
||||
{
|
||||
return (!_stalled && !creature->HasUnitState(UNIT_STATE_NOT_MOVE) && !creature->IsMovementPreventedByCasting());
|
||||
return (!_stalled && _pauseTime <= 0 && !creature->HasUnitState(UNIT_STATE_NOT_MOVE) && !creature->IsMovementPreventedByCasting());
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium<Creat
|
||||
uint32 _lastSplineId;
|
||||
uint32 _pathId;
|
||||
int32 _waypointDelay;
|
||||
int32 _pauseTime;
|
||||
bool _waypointReached;
|
||||
bool _recalculateSpeed;
|
||||
bool _repeating;
|
||||
|
||||
@@ -48,7 +48,7 @@ struct WaypointNode
|
||||
float X, Y, Z;
|
||||
Optional<float> Orientation;
|
||||
float Velocity;
|
||||
int32 Delay;
|
||||
uint32 Delay;
|
||||
uint32 EventId;
|
||||
uint32 MoveType;
|
||||
uint8 EventChance;
|
||||
|
||||
Reference in New Issue
Block a user