Core/Movement: Use SetWalk(true/false) instead of AddUnit/RemoveUnit.

This commit is contained in:
Venugh
2012-02-23 11:50:58 +01:00
parent 9219625243
commit 1cac01b3df
50 changed files with 131 additions and 122 deletions
@@ -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);
}
+3 -3
View File
@@ -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);
+9 -1
View File
@@ -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);
}
+1
View File
@@ -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);