mirror of
https://github.com/mangosfour/server.git
synced 2025-12-19 22:37:05 +00:00
[12695] Improve WaypointMMGen
* Add correct Reset position (Npc will evade now to the last reached waypoint, and not to the next waypoint) * Add proper return value for the CONDITION_LAST_WAYPOINT * Let WaypointMMGen behave better after evading (keep PAUSED state, keep waittimer (original author @Schmoozerd)
This commit is contained in:
parent
1c381f206b
commit
6658234c07
3 changed files with 21 additions and 13 deletions
|
|
@ -67,17 +67,16 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature& creature)
|
|||
if (i_path->empty())
|
||||
return;
|
||||
i_currentNode = i_path->begin()->first;
|
||||
m_lastReachedWaypoint = 0;
|
||||
}
|
||||
|
||||
void WaypointMovementGenerator<Creature>::Initialize(Creature& creature)
|
||||
{
|
||||
creature.addUnitState(UNIT_STAT_ROAMING);
|
||||
creature.clearUnitState(UNIT_STAT_WAYPOINT_PAUSED);
|
||||
|
||||
LoadPath(creature);
|
||||
|
||||
if (!creature.isAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
return;
|
||||
|
||||
creature.addUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||
StartMoveNow(creature);
|
||||
}
|
||||
|
||||
|
|
@ -96,8 +95,8 @@ void WaypointMovementGenerator<Creature>::Interrupt(Creature& creature)
|
|||
|
||||
void WaypointMovementGenerator<Creature>::Reset(Creature& creature)
|
||||
{
|
||||
creature.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
|
||||
StartMoveNow(creature);
|
||||
creature.addUnitState(UNIT_STAT_ROAMING);
|
||||
StartMove(creature);
|
||||
}
|
||||
|
||||
void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
|
||||
|
|
@ -105,6 +104,8 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
|
|||
if (!i_path || i_path->empty())
|
||||
return;
|
||||
|
||||
m_lastReachedWaypoint = i_currentNode;
|
||||
|
||||
if (m_isArrivalDone)
|
||||
return;
|
||||
|
||||
|
|
@ -161,7 +162,6 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
|
|||
void WaypointMovementGenerator<Creature>::StartMoveNow(Creature& creature)
|
||||
{
|
||||
i_nextMoveTime.Reset(0);
|
||||
creature.clearUnitState(UNIT_STAT_WAYPOINT_PAUSED);
|
||||
StartMove(creature);
|
||||
}
|
||||
|
||||
|
|
@ -173,6 +173,9 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature& creature)
|
|||
if (Stopped(creature))
|
||||
return;
|
||||
|
||||
if (!creature.isAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
return;
|
||||
|
||||
WaypointPath::const_iterator currPoint = i_path->find(i_currentNode);
|
||||
MANGOS_ASSERT(currPoint != i_path->end());
|
||||
|
||||
|
|
@ -253,10 +256,14 @@ bool WaypointMovementGenerator<Creature>::GetResetPosition(Creature&, float& x,
|
|||
if (!i_path || i_path->empty())
|
||||
return false;
|
||||
|
||||
WaypointPath::const_iterator currPoint = i_path->find(i_currentNode);
|
||||
MANGOS_ASSERT(currPoint != i_path->end());
|
||||
WaypointPath::const_iterator lastPoint = i_path->find(m_lastReachedWaypoint);
|
||||
// Special case: Before the first waypoint is reached, m_lastReachedWaypoint is set to 0 (which may not be contained in i_path)
|
||||
if (!m_lastReachedWaypoint && lastPoint == i_path->end())
|
||||
return false;
|
||||
|
||||
x = currPoint->second.x; y = currPoint->second.y; z = currPoint->second.z;
|
||||
MANGOS_ASSERT(lastPoint != i_path->end());
|
||||
|
||||
x = lastPoint->second.x; y = lastPoint->second.y; z = lastPoint->second.z;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class MANGOS_DLL_SPEC WaypointMovementGenerator<Creature>
|
|||
public PathMovementBase<Creature, WaypointPath const*>
|
||||
{
|
||||
public:
|
||||
WaypointMovementGenerator(Creature&) : i_nextMoveTime(0), m_isArrivalDone(false) {}
|
||||
WaypointMovementGenerator(Creature&) : i_nextMoveTime(0), m_isArrivalDone(false), m_lastReachedWaypoint(0) {}
|
||||
~WaypointMovementGenerator() { i_path = NULL; }
|
||||
void Initialize(Creature& u);
|
||||
void Interrupt(Creature&);
|
||||
|
|
@ -84,7 +84,7 @@ class MANGOS_DLL_SPEC WaypointMovementGenerator<Creature>
|
|||
|
||||
void AddToWaypointPauseTime(int32 waitTimeDiff);
|
||||
|
||||
uint32 getLastReachedWaypoint() const { return m_isArrivalDone ? i_currentNode + 1 : i_currentNode; }
|
||||
uint32 getLastReachedWaypoint() const { return m_lastReachedWaypoint; }
|
||||
|
||||
private:
|
||||
void Stop(int32 time) { i_nextMoveTime.Reset(time); }
|
||||
|
|
@ -98,6 +98,7 @@ class MANGOS_DLL_SPEC WaypointMovementGenerator<Creature>
|
|||
|
||||
ShortTimeTracker i_nextMoveTime;
|
||||
bool m_isArrivalDone;
|
||||
uint32 m_lastReachedWaypoint;
|
||||
};
|
||||
|
||||
/** FlightPathMovementGenerator generates movement of the player for the paths
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "12694"
|
||||
#define REVISION_NR "12695"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue