Core/Movement: Use SetWalk(true/false) instead of AddUnit/RemoveUnit.
This commit is contained in:
@@ -307,11 +307,7 @@ void npc_escortAI::MovementInform(uint32 moveType, uint32 pointId)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_TSCR, "TSCR: EscortAI has returned to original position before combat");
|
||||
|
||||
if (m_bIsRunning && me->HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
|
||||
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
else if (!m_bIsRunning && !me->HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
|
||||
me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
|
||||
me->SetWalk(!m_bIsRunning);
|
||||
RemoveEscortState(STATE_ESCORT_RETURNING);
|
||||
|
||||
if (!m_uiWPWaitTimer)
|
||||
@@ -400,14 +396,14 @@ void npc_escortAI::SetRun(bool on)
|
||||
if (on)
|
||||
{
|
||||
if (!m_bIsRunning)
|
||||
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
me->SetWalk(false);
|
||||
else
|
||||
sLog->outDebug(LOG_FILTER_TSCR, "TSCR: EscortAI attempt to set run mode, but is already running.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_bIsRunning)
|
||||
me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
me->SetWalk(true);
|
||||
else
|
||||
sLog->outDebug(LOG_FILTER_TSCR, "TSCR: EscortAI attempt to set walk mode, but is already walking.");
|
||||
}
|
||||
@@ -473,9 +469,9 @@ void npc_escortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false
|
||||
|
||||
//Set initial speed
|
||||
if (m_bIsRunning)
|
||||
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
me->SetWalk(false);
|
||||
else
|
||||
me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
me->SetWalk(true);
|
||||
|
||||
AddEscortState(STATE_ESCORT_ESCORTING);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
|
||||
mCanRepeatPath = false;
|
||||
|
||||
// spawn in run mode
|
||||
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
me->SetWalk(false);
|
||||
mRun = false;
|
||||
|
||||
me->GetPosition(&mLastOOCPos);
|
||||
@@ -720,9 +720,9 @@ uint64 SmartAI::GetGUID(int32 /*id*/)
|
||||
void SmartAI::SetRun(bool run)
|
||||
{
|
||||
if (run)
|
||||
me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
me->SetWalk(false);
|
||||
else
|
||||
me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
me->SetWalk(true);
|
||||
|
||||
mRun = run;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z)
|
||||
if (member->IsWithinDist(m_leader, dist + MAX_DESYNC))
|
||||
member->SetUnitMovementFlags(m_leader->GetUnitMovementFlags());
|
||||
else
|
||||
member->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
member->SetWalk(false);
|
||||
|
||||
member->GetMotionMaster()->MovePoint(0, dx, dy, dz);
|
||||
member->SetHomePosition(dx, dy, dz, pathangle);
|
||||
|
||||
@@ -9906,7 +9906,7 @@ void Unit::SetCharm(Unit* charm, bool apply)
|
||||
|
||||
if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
|
||||
{
|
||||
charm->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
charm->SetWalk(false);
|
||||
charm->SendMovementFlagUpdate();
|
||||
}
|
||||
|
||||
@@ -17455,3 +17455,11 @@ void Unit::SetFacingToObject(WorldObject* pObject)
|
||||
// TODO: figure out under what conditions creature will move towards object instead of facing it where it currently is.
|
||||
SetFacingTo(GetAngle(pObject));
|
||||
}
|
||||
|
||||
void Unit::SetWalk(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
else
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
|
||||
}
|
||||
@@ -1627,6 +1627,7 @@ class Unit : public WorldObject
|
||||
void SendMovementFlagUpdate();
|
||||
bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_LEVITATING);}
|
||||
bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING);}
|
||||
virtual void SetWalk(bool enable);
|
||||
|
||||
void SetInFront(Unit const* target);
|
||||
void SetFacingTo(float ori);
|
||||
|
||||
Reference in New Issue
Block a user