diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index 0585798d2e2..8e398c9ecf1 100644 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -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()); } diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp index a6eefd0cb7b..531bdd9044f 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp @@ -27,12 +27,12 @@ #include "Transport.h" #include "WaypointManager.h" -WaypointMovementGenerator::WaypointMovementGenerator(uint32 pathId, bool repeating) : _lastSplineId(0), _pathId(pathId), _waypointDelay(0), +WaypointMovementGenerator::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::WaypointMovementGenerator(WaypointPath& path, bool repeating) : _lastSplineId(0), _pathId(0), _waypointDelay(0), +WaypointMovementGenerator::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::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::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::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::DoUpdate(Creature* creature, uint32 di return true; } -void WaypointMovementGenerator::Pause(uint32 timer/* = 0*/) +void WaypointMovementGenerator::Pause(uint32 timer /*= 0*/) { _stalled = timer ? false : true; _hasBeenStalled = !_waypointReached; - _waypointDelay = 0; + _pauseTime = timer; } -void WaypointMovementGenerator::Resume(uint32 overrideTimer/* = 0*/) +void WaypointMovementGenerator::Resume(uint32 overrideTimer /*= 0*/) { _hasBeenStalled = !_waypointReached; _stalled = false; if (overrideTimer) - _waypointDelay = overrideTimer; + _pauseTime = overrideTimer; } bool WaypointMovementGenerator::GetResetPosition(Unit* /*owner*/, float& x, float& y, float& z) @@ -354,5 +358,5 @@ bool WaypointMovementGenerator::GetResetPosition(Unit* /*owner*/, floa bool WaypointMovementGenerator::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()); } diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h index e694feb5ce5..c69434a834e 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h @@ -65,6 +65,7 @@ class WaypointMovementGenerator : public MovementGeneratorMedium Orientation; float Velocity; - int32 Delay; + uint32 Delay; uint32 EventId; uint32 MoveType; uint8 EventChance;