Core/Waypoints: Stop creatures from skipping at waypoint nodes
and add smoothing to pathing.
This commit is contained in:
@@ -74,19 +74,24 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature* creature)
|
||||
if (m_isArrivalDone)
|
||||
return;
|
||||
|
||||
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
m_isArrivalDone = true;
|
||||
|
||||
if (i_path->at(i_currentNode)->event_id && urand(0, 99) < i_path->at(i_currentNode)->event_chance)
|
||||
{
|
||||
TC_LOG_DEBUG("maps.script", "Creature movement start script %u at point %u for " UI64FMTD ".", i_path->at(i_currentNode)->event_id, i_currentNode, creature->GetGUID());
|
||||
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
creature->GetMap()->ScriptsStart(sWaypointScripts, i_path->at(i_currentNode)->event_id, creature, NULL);
|
||||
}
|
||||
|
||||
// Inform script
|
||||
MovementInform(creature);
|
||||
creature->UpdateWaypointID(i_currentNode);
|
||||
Stop(i_path->at(i_currentNode)->delay);
|
||||
|
||||
if (i_path->at(i_currentNode)->delay)
|
||||
{
|
||||
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
Stop(i_path->at(i_currentNode)->delay);
|
||||
}
|
||||
}
|
||||
|
||||
bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
|
||||
@@ -188,7 +193,8 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
|
||||
{
|
||||
if (creature->IsStopped())
|
||||
Stop(STOP_TIME_FOR_PLAYER);
|
||||
else if (creature->movespline->Finalized())
|
||||
// Checking just before reaching waypoint gives smother movement than using FinalDestination
|
||||
else if (creature->movespline->timeElapsed() < 150)
|
||||
{
|
||||
OnArrived(creature);
|
||||
return StartMove(creature);
|
||||
|
||||
@@ -79,10 +79,10 @@ namespace Movement
|
||||
UpdateResult _updateState(int32& ms_time_diff);
|
||||
int32 next_timestamp() const { return spline.length(point_Idx + 1); }
|
||||
int32 segment_time_elapsed() const { return next_timestamp() - time_passed; }
|
||||
int32 timeElapsed() const { return Duration() - time_passed; }
|
||||
int32 timePassed() const { return time_passed; }
|
||||
|
||||
public:
|
||||
int32 timeElapsed() const { return Duration() - time_passed; }
|
||||
int32 Duration() const { return spline.length(); }
|
||||
MySpline const& _Spline() const { return spline; }
|
||||
int32 _currentSplineIdx() const { return point_Idx; }
|
||||
|
||||
Reference in New Issue
Block a user