mirror of
https://github.com/mangosfour/server.git
synced 2025-12-28 13:37:13 +00:00
Apply style fix
This commit is contained in:
parent
5531a0087d
commit
35405dd549
155 changed files with 10968 additions and 3660 deletions
|
|
@ -37,7 +37,9 @@ void ConfusedMovementGenerator<T>::Initialize(T& unit)
|
|||
unit.GetPosition(i_x, i_y, i_z);
|
||||
|
||||
if (!unit.IsAlive() || unit.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unit.StopMoving();
|
||||
unit.addUnitState(UNIT_STAT_CONFUSED_MOVE);
|
||||
|
|
@ -57,7 +59,9 @@ void ConfusedMovementGenerator<T>::Reset(T& unit)
|
|||
i_nextMoveTime.Reset(0);
|
||||
|
||||
if (!unit.IsAlive() || unit.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unit.StopMoving();
|
||||
unit.addUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_CONFUSED_MOVE);
|
||||
|
|
@ -68,7 +72,9 @@ bool ConfusedMovementGenerator<T>::Update(T& unit, const uint32& diff)
|
|||
{
|
||||
// ignore in case other no reaction state
|
||||
if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT & ~UNIT_STAT_CONFUSED))
|
||||
{ return true; }
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (i_nextMoveTime.Passed())
|
||||
{
|
||||
|
|
@ -76,7 +82,9 @@ bool ConfusedMovementGenerator<T>::Update(T& unit, const uint32& diff)
|
|||
unit.addUnitState(UNIT_STAT_CONFUSED_MOVE);
|
||||
|
||||
if (unit.movespline->Finalized())
|
||||
{ i_nextMoveTime.Reset(urand(800, 1500)); }
|
||||
{
|
||||
i_nextMoveTime.Reset(urand(800, 1500));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ void FleeingMovementGenerator<T>::_setTargetLocation(T& owner)
|
|||
{
|
||||
// ignore in case other no reaction state
|
||||
if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float x, y, z;
|
||||
if (!_getPoint(owner, x, y, z))
|
||||
|
|
@ -76,7 +78,9 @@ bool FleeingMovementGenerator<T>::_getPoint(T& owner, float& x, float& y, float&
|
|||
{
|
||||
dist_from_caster = fright->GetDistance(&owner);
|
||||
if (dist_from_caster > 0.2f)
|
||||
{ angle_to_caster = fright->GetAngle(&owner); }
|
||||
{
|
||||
angle_to_caster = fright->GetAngle(&owner);
|
||||
}
|
||||
else
|
||||
{ angle_to_caster = frand(0, 2 * M_PI_F); }
|
||||
}
|
||||
|
|
@ -172,7 +176,9 @@ template<class T>
|
|||
bool FleeingMovementGenerator<T>::Update(T& owner, const uint32& time_diff)
|
||||
{
|
||||
if (!owner.IsAlive())
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ignore in case other no reaction state
|
||||
if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING))
|
||||
|
|
@ -183,7 +189,9 @@ bool FleeingMovementGenerator<T>::Update(T& owner, const uint32& time_diff)
|
|||
|
||||
i_nextCheckTime.Update(time_diff);
|
||||
if (i_nextCheckTime.Passed() && owner.movespline->Finalized())
|
||||
{ _setTargetLocation(owner); }
|
||||
{
|
||||
_setTargetLocation(owner);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -217,7 +225,9 @@ void TimedFleeingMovementGenerator::Finalize(Unit& owner)
|
|||
bool TimedFleeingMovementGenerator::Update(Unit& owner, const uint32& time_diff)
|
||||
{
|
||||
if (!owner.IsAlive())
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ignore in case other no reaction state
|
||||
if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING))
|
||||
|
|
@ -228,7 +238,9 @@ bool TimedFleeingMovementGenerator::Update(Unit& owner, const uint32& time_diff)
|
|||
|
||||
i_totalFleeTime.Update(time_diff);
|
||||
if (i_totalFleeTime.Passed())
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, const uint32 &) version
|
||||
// This is done instead of casting Unit& to Creature& and call parent method, then we can use Unit directly
|
||||
|
|
|
|||
|
|
@ -42,7 +42,9 @@ void HomeMovementGenerator<Creature>::Reset(Creature&)
|
|||
void HomeMovementGenerator<Creature>::_setTargetLocation(Creature& owner)
|
||||
{
|
||||
if (owner.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Movement::MoveSplineInit init(owner);
|
||||
float x, y, z, o;
|
||||
|
|
@ -71,7 +73,9 @@ void HomeMovementGenerator<Creature>::Finalize(Creature& owner)
|
|||
if (arrived)
|
||||
{
|
||||
if (owner.GetTemporaryFactionFlags() & TEMPFACTION_RESTORE_REACH_HOME)
|
||||
{ owner.ClearTemporaryFaction(); }
|
||||
{
|
||||
owner.ClearTemporaryFaction();
|
||||
}
|
||||
|
||||
owner.SetWalk(!owner.hasUnitState(UNIT_STAT_RUNNING_STATE) && !owner.IsLevitating(), false);
|
||||
owner.LoadCreatureAddon(true);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,9 @@ bool
|
|||
DistractMovementGenerator::Update(Unit& /*owner*/, const uint32& time_diff)
|
||||
{
|
||||
if (time_diff > m_timer)
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_timer -= time_diff;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -76,14 +76,18 @@ MotionMaster::~MotionMaster()
|
|||
MovementGenerator* m = top();
|
||||
pop();
|
||||
if (!isStatic(m))
|
||||
{ delete m; }
|
||||
{
|
||||
delete m;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MotionMaster::UpdateMotion(uint32 diff)
|
||||
{
|
||||
if (m_owner->hasUnitState(UNIT_STAT_CAN_NOT_MOVE))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MANGOS_ASSERT(!empty());
|
||||
m_cleanFlag |= MMCF_UPDATE;
|
||||
|
|
@ -102,14 +106,18 @@ void MotionMaster::UpdateMotion(uint32 diff)
|
|||
{
|
||||
MovementGenerator* mg = (*m_expList)[i];
|
||||
if (!isStatic(mg))
|
||||
{ delete mg; }
|
||||
{
|
||||
delete mg;
|
||||
}
|
||||
}
|
||||
|
||||
delete m_expList;
|
||||
m_expList = NULL;
|
||||
|
||||
if (empty())
|
||||
{ Initialize(); }
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
if (m_cleanFlag & MMCF_RESET)
|
||||
{
|
||||
|
|
@ -128,7 +136,9 @@ void MotionMaster::DirectClean(bool reset, bool all)
|
|||
curr->Finalize(*m_owner);
|
||||
|
||||
if (!isStatic(curr))
|
||||
{ delete curr; }
|
||||
{
|
||||
delete curr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!all && reset)
|
||||
|
|
@ -141,15 +151,21 @@ void MotionMaster::DirectClean(bool reset, bool all)
|
|||
void MotionMaster::DelayedClean(bool reset, bool all)
|
||||
{
|
||||
if (reset)
|
||||
{ m_cleanFlag |= MMCF_RESET; }
|
||||
{
|
||||
m_cleanFlag |= MMCF_RESET;
|
||||
}
|
||||
else
|
||||
{ m_cleanFlag &= ~MMCF_RESET; }
|
||||
|
||||
if (empty() || (!all && size() == 1))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_expList)
|
||||
{ m_expList = new ExpireList(); }
|
||||
{
|
||||
m_expList = new ExpireList();
|
||||
}
|
||||
|
||||
while (all ? !empty() : size() > 1)
|
||||
{
|
||||
|
|
@ -158,14 +174,18 @@ void MotionMaster::DelayedClean(bool reset, bool all)
|
|||
curr->Finalize(*m_owner);
|
||||
|
||||
if (!isStatic(curr))
|
||||
{ m_expList->push_back(curr); }
|
||||
{
|
||||
m_expList->push_back(curr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MotionMaster::DirectExpire(bool reset)
|
||||
{
|
||||
if (empty() || size() == 1)
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MovementGenerator* curr = top();
|
||||
pop();
|
||||
|
|
@ -185,31 +205,43 @@ void MotionMaster::DirectExpire(bool reset)
|
|||
curr->Finalize(*m_owner);
|
||||
|
||||
if (!isStatic(curr))
|
||||
{ delete curr; }
|
||||
{
|
||||
delete curr;
|
||||
}
|
||||
|
||||
if (empty())
|
||||
{ Initialize(); }
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
// Prevent reseting possible new pushed MMGen
|
||||
if (reset && top() == nowTop)
|
||||
{ top()->Reset(*m_owner); }
|
||||
{
|
||||
top()->Reset(*m_owner);
|
||||
}
|
||||
}
|
||||
|
||||
void MotionMaster::DelayedExpire(bool reset)
|
||||
{
|
||||
if (reset)
|
||||
{ m_cleanFlag |= MMCF_RESET; }
|
||||
{
|
||||
m_cleanFlag |= MMCF_RESET;
|
||||
}
|
||||
else
|
||||
{ m_cleanFlag &= ~MMCF_RESET; }
|
||||
|
||||
if (empty() || size() == 1)
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MovementGenerator* curr = top();
|
||||
pop();
|
||||
|
||||
if (!m_expList)
|
||||
{ m_expList = new ExpireList(); }
|
||||
{
|
||||
m_expList = new ExpireList();
|
||||
}
|
||||
|
||||
// also drop stored under top() targeted motions
|
||||
while (!empty() && (top()->GetMovementGeneratorType() == CHASE_MOTION_TYPE || top()->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE))
|
||||
|
|
@ -223,13 +255,17 @@ void MotionMaster::DelayedExpire(bool reset)
|
|||
curr->Finalize(*m_owner);
|
||||
|
||||
if (!isStatic(curr))
|
||||
{ m_expList->push_back(curr); }
|
||||
{
|
||||
m_expList->push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
void MotionMaster::MoveIdle()
|
||||
{
|
||||
if (empty() || !isStatic(top()))
|
||||
{ push(&si_idleMovement); }
|
||||
{
|
||||
push(&si_idleMovement);
|
||||
}
|
||||
}
|
||||
|
||||
void MotionMaster::MoveRandomAroundPoint(float x, float y, float z, float radius, float verticalZ)
|
||||
|
|
@ -248,7 +284,9 @@ void MotionMaster::MoveRandomAroundPoint(float x, float y, float z, float radius
|
|||
void MotionMaster::MoveTargetedHome()
|
||||
{
|
||||
if (m_owner->hasUnitState(UNIT_STAT_LOST_CONTROL))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Clear(false);
|
||||
|
||||
|
|
@ -256,7 +294,9 @@ void MotionMaster::MoveTargetedHome()
|
|||
{
|
||||
// Manual exception for linked mobs
|
||||
if (m_owner->IsLinkingEventTrigger() && m_owner->GetMap()->GetCreatureLinkingHolder()->TryFollowMaster((Creature*)m_owner))
|
||||
{ DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s refollowed linked master", m_owner->GetGuidStr().c_str()); }
|
||||
{
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s refollowed linked master", m_owner->GetGuidStr().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted home", m_owner->GetGuidStr().c_str());
|
||||
|
|
@ -284,7 +324,9 @@ void MotionMaster::MoveConfused()
|
|||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s move confused", m_owner->GetGuidStr().c_str());
|
||||
|
||||
if (m_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{ Mutate(new ConfusedMovementGenerator<Player>()); }
|
||||
{
|
||||
Mutate(new ConfusedMovementGenerator<Player>());
|
||||
}
|
||||
else
|
||||
{ Mutate(new ConfusedMovementGenerator<Creature>()); }
|
||||
}
|
||||
|
|
@ -293,12 +335,16 @@ void MotionMaster::MoveChase(Unit* target, float dist, float angle)
|
|||
{
|
||||
// ignore movement request if target not exist
|
||||
if (!target)
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s chase to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str());
|
||||
|
||||
if (m_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{ Mutate(new ChaseMovementGenerator<Player>(*target, dist, angle)); }
|
||||
{
|
||||
Mutate(new ChaseMovementGenerator<Player>(*target, dist, angle));
|
||||
}
|
||||
else
|
||||
{ Mutate(new ChaseMovementGenerator<Creature>(*target, dist, angle)); }
|
||||
}
|
||||
|
|
@ -306,18 +352,24 @@ void MotionMaster::MoveChase(Unit* target, float dist, float angle)
|
|||
void MotionMaster::MoveFollow(Unit* target, float dist, float angle)
|
||||
{
|
||||
if (m_owner->hasUnitState(UNIT_STAT_LOST_CONTROL))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Clear();
|
||||
|
||||
// ignore movement request if target not exist
|
||||
if (!target)
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str());
|
||||
|
||||
if (m_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{ Mutate(new FollowMovementGenerator<Player>(*target, dist, angle)); }
|
||||
{
|
||||
Mutate(new FollowMovementGenerator<Player>(*target, dist, angle));
|
||||
}
|
||||
else
|
||||
{ Mutate(new FollowMovementGenerator<Creature>(*target, dist, angle)); }
|
||||
}
|
||||
|
|
@ -327,7 +379,9 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generate
|
|||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), id, x, y, z);
|
||||
|
||||
if (m_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{ Mutate(new PointMovementGenerator<Player>(id, x, y, z, generatePath)); }
|
||||
{
|
||||
Mutate(new PointMovementGenerator<Player>(id, x, y, z, generatePath));
|
||||
}
|
||||
else
|
||||
{ Mutate(new PointMovementGenerator<Creature>(id, x, y, z, generatePath)); }
|
||||
}
|
||||
|
|
@ -363,16 +417,22 @@ void MotionMaster::MoveSeekAssistanceDistract(uint32 time)
|
|||
void MotionMaster::MoveFleeing(Unit* enemy, uint32 time)
|
||||
{
|
||||
if (!enemy)
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s flee from %s", m_owner->GetGuidStr().c_str(), enemy->GetGuidStr().c_str());
|
||||
|
||||
if (m_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{ Mutate(new FleeingMovementGenerator<Player>(enemy->GetObjectGuid())); }
|
||||
{
|
||||
Mutate(new FleeingMovementGenerator<Player>(enemy->GetObjectGuid()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (time)
|
||||
{ Mutate(new TimedFleeingMovementGenerator(enemy->GetObjectGuid(), time)); }
|
||||
{
|
||||
Mutate(new TimedFleeingMovementGenerator(enemy->GetObjectGuid(), time));
|
||||
}
|
||||
else
|
||||
{ Mutate(new FleeingMovementGenerator<Creature>(enemy->GetObjectGuid())); }
|
||||
}
|
||||
|
|
@ -434,7 +494,9 @@ void MotionMaster::MoveDistract(uint32 timer)
|
|||
void MotionMaster::MoveFlyOrLand(uint32 id, float x, float y, float z, bool liftOff)
|
||||
{
|
||||
if (m_owner->GetTypeId() != TYPEID_UNIT)
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point for %s (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), liftOff ? "liftoff" : "landing", id, x, y, z);
|
||||
Mutate(new FlyOrLandMovementGenerator(id, x, y, z, liftOff));
|
||||
|
|
@ -457,7 +519,9 @@ void MotionMaster::Mutate(MovementGenerator* m)
|
|||
}
|
||||
|
||||
if (!empty())
|
||||
{ top()->Interrupt(*m_owner); }
|
||||
{
|
||||
top()->Interrupt(*m_owner);
|
||||
}
|
||||
}
|
||||
|
||||
m->Initialize(*m_owner);
|
||||
|
|
@ -488,7 +552,9 @@ uint32 MotionMaster::getLastReachedWaypoint() const
|
|||
for (Impl::container_type::const_reverse_iterator rItr = Impl::c.rbegin(); rItr != Impl::c.rend(); ++rItr)
|
||||
{
|
||||
if ((*rItr)->GetMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
|
||||
{ return (static_cast<WaypointMovementGenerator<Creature>*>(*rItr))->getLastReachedWaypoint(); }
|
||||
{
|
||||
return (static_cast<WaypointMovementGenerator<Creature>*>(*rItr))->getLastReachedWaypoint();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -496,7 +562,9 @@ uint32 MotionMaster::getLastReachedWaypoint() const
|
|||
MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType() const
|
||||
{
|
||||
if (empty())
|
||||
{ return IDLE_MOTION_TYPE; }
|
||||
{
|
||||
return IDLE_MOTION_TYPE;
|
||||
}
|
||||
|
||||
return top()->GetMovementGeneratorType();
|
||||
}
|
||||
|
|
@ -516,7 +584,9 @@ void MotionMaster::GetWaypointPathInformation(std::ostringstream& oss) const
|
|||
bool MotionMaster::GetDestination(float& x, float& y, float& z)
|
||||
{
|
||||
if (m_owner->movespline->Finalized())
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const G3D::Vector3& dest = m_owner->movespline->FinalDestination();
|
||||
x = dest.x;
|
||||
|
|
@ -558,7 +628,9 @@ void MotionMaster::MoveFall()
|
|||
|
||||
// Abort too if the ground is very near
|
||||
if (fabs(m_owner->GetPositionZ() - tz) < 0.1f)
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Movement::MoveSplineInit init(*m_owner);
|
||||
init.MoveTo(m_owner->GetPositionX(), m_owner->GetPositionY(), tz);
|
||||
|
|
|
|||
|
|
@ -95,14 +95,18 @@ class MotionMaster : private std::stack<MovementGenerator*>
|
|||
void Clear(bool reset = true, bool all = false)
|
||||
{
|
||||
if (m_cleanFlag & MMCF_UPDATE)
|
||||
{ DelayedClean(reset, all); }
|
||||
{
|
||||
DelayedClean(reset, all);
|
||||
}
|
||||
else
|
||||
{ DirectClean(reset, all); }
|
||||
}
|
||||
void MovementExpired(bool reset = true)
|
||||
{
|
||||
if (m_cleanFlag & MMCF_UPDATE)
|
||||
{ DelayedExpire(reset); }
|
||||
{
|
||||
DelayedExpire(reset);
|
||||
}
|
||||
else
|
||||
{ DirectExpire(reset); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,9 @@ bool PathFinder::calculate(float destX, float destY, float destZ, bool forceDest
|
|||
dtPolyRef PathFinder::getPathPolyByPosition(const dtPolyRef* polyPath, uint32 polyPathSize, const float* point, float* distance) const
|
||||
{
|
||||
if (!polyPath || !polyPathSize)
|
||||
{ return INVALID_POLYREF; }
|
||||
{
|
||||
return INVALID_POLYREF;
|
||||
}
|
||||
|
||||
dtPolyRef nearestPoly = INVALID_POLYREF;
|
||||
float minDist2d = FLT_MAX;
|
||||
|
|
@ -110,11 +112,15 @@ dtPolyRef PathFinder::getPathPolyByPosition(const dtPolyRef* polyPath, uint32 po
|
|||
}
|
||||
|
||||
if (minDist2d < 1.0f) // shortcut out - close enough for us
|
||||
{ break; }
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (distance)
|
||||
{ *distance = dtSqrt(minDist3d); }
|
||||
{
|
||||
*distance = dtSqrt(minDist3d);
|
||||
}
|
||||
|
||||
return (minDist2d < 3.0f) ? nearestPoly : INVALID_POLYREF;
|
||||
}
|
||||
|
|
@ -126,7 +132,9 @@ dtPolyRef PathFinder::getPolyByLocation(const float* point, float* distance) con
|
|||
// we need to use the expensive navMesh.findNearestPoly
|
||||
dtPolyRef polyRef = getPathPolyByPosition(m_pathPolyRefs, m_polyLength, point, distance);
|
||||
if (polyRef != INVALID_POLYREF)
|
||||
{ return polyRef; }
|
||||
{
|
||||
return polyRef;
|
||||
}
|
||||
|
||||
// we don't have it in our old path
|
||||
// try to get it by findNearestPoly()
|
||||
|
|
@ -205,13 +213,17 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
|
|||
{
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ BuildPolyPath :: underWater case\n");
|
||||
if (owner->CanSwim())
|
||||
{ buildShotrcut = true; }
|
||||
{
|
||||
buildShotrcut = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ BuildPolyPath :: flying case\n");
|
||||
if (owner->CanFly())
|
||||
{ buildShotrcut = true; }
|
||||
{
|
||||
buildShotrcut = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -391,7 +403,9 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos)
|
|||
|
||||
// by now we know what type of path we can get
|
||||
if (m_pathPolyRefs[m_polyLength - 1] == endPoly && !(m_type & PATHFIND_INCOMPLETE))
|
||||
{ m_type = PATHFIND_NORMAL; }
|
||||
{
|
||||
m_type = PATHFIND_NORMAL;
|
||||
}
|
||||
else
|
||||
{ m_type = PATHFIND_INCOMPLETE; }
|
||||
|
||||
|
|
@ -576,12 +590,16 @@ uint32 PathFinder::fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath,
|
|||
}
|
||||
}
|
||||
if (found)
|
||||
{ break; }
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If no intersection found just return current path.
|
||||
if (furthestPath == -1 || furthestVisited == -1)
|
||||
{ return npath; }
|
||||
{
|
||||
return npath;
|
||||
}
|
||||
|
||||
// Concatenate paths.
|
||||
|
||||
|
|
@ -590,10 +608,14 @@ uint32 PathFinder::fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath,
|
|||
uint32 orig = uint32(furthestPath + 1) < npath ? furthestPath + 1 : npath;
|
||||
uint32 size = npath > orig ? npath - orig : 0;
|
||||
if (req + size > maxPath)
|
||||
{ size = maxPath - req; }
|
||||
{
|
||||
size = maxPath - req;
|
||||
}
|
||||
|
||||
if (size)
|
||||
{ memmove(path + req, path + orig, size * sizeof(dtPolyRef)); }
|
||||
{
|
||||
memmove(path + req, path + orig, size * sizeof(dtPolyRef));
|
||||
}
|
||||
|
||||
// Store visited
|
||||
for (uint32 i = 0; i < req; ++i)
|
||||
|
|
@ -615,7 +637,9 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos,
|
|||
dtStatus dtResult = m_navMeshQuery->findStraightPath(startPos, endPos, path, pathSize,
|
||||
steerPath, steerPathFlags, steerPathPolys, (int*)&nsteerPath, MAX_STEER_POINTS);
|
||||
if (!nsteerPath || dtStatusFailed(dtResult))
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find vertex far enough to steer to.
|
||||
uint32 ns = 0;
|
||||
|
|
@ -629,7 +653,9 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos,
|
|||
}
|
||||
// Failed to find good point to steer to.
|
||||
if (ns >= nsteerPath)
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
dtVcopy(steerPos, &steerPath[ns * VERTEX_SIZE]);
|
||||
steerPos[1] = startPos[1]; // keep Z value
|
||||
|
|
@ -653,11 +679,15 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
|||
float iterPos[VERTEX_SIZE], targetPos[VERTEX_SIZE];
|
||||
dtStatus dtResult = m_navMeshQuery->closestPointOnPolyBoundary(polys[0], startPos, iterPos);
|
||||
if (dtStatusFailed(dtResult))
|
||||
{ return DT_FAILURE; }
|
||||
{
|
||||
return DT_FAILURE;
|
||||
}
|
||||
|
||||
dtResult = m_navMeshQuery->closestPointOnPolyBoundary(polys[npolys - 1], endPos, targetPos);
|
||||
if (dtStatusFailed(dtResult))
|
||||
{ return DT_FAILURE; }
|
||||
{
|
||||
return DT_FAILURE;
|
||||
}
|
||||
|
||||
dtVcopy(&smoothPath[nsmoothPath * VERTEX_SIZE], iterPos);
|
||||
++nsmoothPath;
|
||||
|
|
@ -672,7 +702,9 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
|||
dtPolyRef steerPosRef = INVALID_POLYREF;
|
||||
|
||||
if (!getSteerTarget(iterPos, targetPos, SMOOTH_PATH_SLOP, polys, npolys, steerPos, steerPosFlag, steerPosRef))
|
||||
{ break; }
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
bool endOfPath = (steerPosFlag & DT_STRAIGHTPATH_END);
|
||||
bool offMeshConnection = (steerPosFlag & DT_STRAIGHTPATH_OFFMESH_CONNECTION);
|
||||
|
|
@ -683,7 +715,9 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos,
|
|||
float len = dtSqrt(dtVdot(delta, delta));
|
||||
// If the steer target is end of path or off-mesh link, do not move past the location.
|
||||
if ((endOfPath || offMeshConnection) && len < SMOOTH_PATH_STEP_SIZE)
|
||||
{ len = 1.0f; }
|
||||
{
|
||||
len = 1.0f;
|
||||
}
|
||||
else
|
||||
{ len = SMOOTH_PATH_STEP_SIZE / len; }
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,9 @@ template<class T>
|
|||
void PointMovementGenerator<T>::Initialize(T& unit)
|
||||
{
|
||||
if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unit.StopMoving();
|
||||
|
||||
|
|
@ -52,7 +54,9 @@ void PointMovementGenerator<T>::Finalize(T& unit)
|
|||
unit.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
|
||||
|
||||
if (unit.movespline->Finalized())
|
||||
{ MovementInform(unit); }
|
||||
{
|
||||
MovementInform(unit);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
|
@ -79,7 +83,9 @@ bool PointMovementGenerator<T>::Update(T& unit, const uint32& diff)
|
|||
}
|
||||
|
||||
if (!unit.hasUnitState(UNIT_STAT_ROAMING_MOVE) && unit.movespline->Finalized())
|
||||
{ Initialize(unit); }
|
||||
{
|
||||
Initialize(unit);
|
||||
}
|
||||
|
||||
return !unit.movespline->Finalized();
|
||||
}
|
||||
|
|
@ -93,7 +99,9 @@ template <>
|
|||
void PointMovementGenerator<Creature>::MovementInform(Creature& unit)
|
||||
{
|
||||
if (unit.AI())
|
||||
{ unit.AI()->MovementInform(POINT_MOTION_TYPE, id); }
|
||||
{
|
||||
unit.AI()->MovementInform(POINT_MOTION_TYPE, id);
|
||||
}
|
||||
|
||||
if (unit.IsTemporarySummon())
|
||||
{
|
||||
|
|
@ -101,7 +109,9 @@ void PointMovementGenerator<Creature>::MovementInform(Creature& unit)
|
|||
if (pSummon->GetSummonerGuid().IsCreatureOrVehicle())
|
||||
if (Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid()))
|
||||
if (pSummoner->AI())
|
||||
{ pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id); }
|
||||
{
|
||||
pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +133,9 @@ void AssistanceMovementGenerator::Finalize(Unit& unit)
|
|||
((Creature*)&unit)->SetNoCallAssistance(false);
|
||||
((Creature*)&unit)->CallAssistance();
|
||||
if (unit.IsAlive())
|
||||
{ unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY)); }
|
||||
{
|
||||
unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY));
|
||||
}
|
||||
}
|
||||
|
||||
bool EffectMovementGenerator::Update(Unit& unit, const uint32&)
|
||||
|
|
@ -134,15 +146,21 @@ bool EffectMovementGenerator::Update(Unit& unit, const uint32&)
|
|||
void EffectMovementGenerator::Finalize(Unit& unit)
|
||||
{
|
||||
if (unit.GetTypeId() != TYPEID_UNIT)
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Creature&)unit).AI() && unit.movespline->Finalized())
|
||||
{ ((Creature&)unit).AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id); }
|
||||
{
|
||||
((Creature&)unit).AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id);
|
||||
}
|
||||
// Need restore previous movement since we have no proper states system
|
||||
if (unit.IsAlive() && !unit.hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_NO_COMBAT_MOVEMENT))
|
||||
{
|
||||
if (Unit* victim = unit.getVictim())
|
||||
{ unit.GetMotionMaster()->MoveChase(victim); }
|
||||
{
|
||||
unit.GetMotionMaster()->MoveChase(victim);
|
||||
}
|
||||
else
|
||||
{ unit.GetMotionMaster()->Initialize(); }
|
||||
}
|
||||
|
|
@ -151,7 +169,9 @@ void EffectMovementGenerator::Finalize(Unit& unit)
|
|||
void FlyOrLandMovementGenerator::Initialize(Unit& unit)
|
||||
{
|
||||
if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unit.StopMoving();
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,9 @@ void RandomMovementGenerator<Creature>::Initialize(Creature& creature)
|
|||
creature.addUnitState(UNIT_STAT_ROAMING); // _MOVE set in _setRandomLocation
|
||||
|
||||
if (!creature.IsAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_setRandomLocation(creature);
|
||||
}
|
||||
|
|
@ -116,7 +118,9 @@ bool RandomMovementGenerator<Creature>::Update(Creature& creature, const uint32&
|
|||
{
|
||||
i_nextMoveTime.Update(diff);
|
||||
if (i_nextMoveTime.Passed())
|
||||
{ _setRandomLocation(creature); }
|
||||
{
|
||||
_setRandomLocation(creature);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,10 +38,14 @@ template<class T, typename D>
|
|||
void TargetedMovementGeneratorMedium<T, D>::_setTargetLocation(T& owner, bool updateDestination)
|
||||
{
|
||||
if (!i_target.isValid() || !i_target->IsInWorld())
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (owner.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float x, y, z;
|
||||
|
||||
|
|
@ -55,7 +59,9 @@ void TargetedMovementGeneratorMedium<T, D>::_setTargetLocation(T& owner, bool up
|
|||
if (!RequiresNewPosition(owner, x, y, z))
|
||||
{
|
||||
if (!owner.movespline->Finalized())
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Chase Movement and angle == 0 case: Chase to current angle
|
||||
else if (this->GetMovementGeneratorType() == CHASE_MOTION_TYPE && i_angle == 0.0f)
|
||||
|
|
@ -78,14 +84,18 @@ void TargetedMovementGeneratorMedium<T, D>::_setTargetLocation(T& owner, bool up
|
|||
}
|
||||
|
||||
if (!i_path)
|
||||
{ i_path = new PathFinder(&owner); }
|
||||
{
|
||||
i_path = new PathFinder(&owner);
|
||||
}
|
||||
|
||||
// allow pets following their master to cheat while generating paths
|
||||
bool forceDest = (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->IsPet()
|
||||
&& owner.hasUnitState(UNIT_STAT_FOLLOW));
|
||||
i_path->calculate(x, y, z, forceDest);
|
||||
if (i_path->getPathType() & PATHFIND_NOPATH)
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
D::_addUnitStateMove(owner);
|
||||
i_targetReached = false;
|
||||
|
|
@ -101,10 +111,14 @@ template<class T, typename D>
|
|||
bool TargetedMovementGeneratorMedium<T, D>::Update(T& owner, const uint32& time_diff)
|
||||
{
|
||||
if (!i_target.isValid() || !i_target->IsInWorld())
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!owner.IsAlive())
|
||||
{ return true; }
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (owner.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
{
|
||||
|
|
@ -122,7 +136,9 @@ bool TargetedMovementGeneratorMedium<T, D>::Update(T& owner, const uint32& time_
|
|||
if (owner.IsNonMeleeSpellCasted(false, false, true))
|
||||
{
|
||||
if (!owner.IsStopped())
|
||||
{ owner.StopMoving(); }
|
||||
{
|
||||
owner.StopMoving();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -143,12 +159,16 @@ bool TargetedMovementGeneratorMedium<T, D>::Update(T& owner, const uint32& time_
|
|||
}
|
||||
|
||||
if (m_speedChanged || targetMoved)
|
||||
{ _setTargetLocation(owner, targetMoved); }
|
||||
{
|
||||
_setTargetLocation(owner, targetMoved);
|
||||
}
|
||||
|
||||
if (owner.movespline->Finalized())
|
||||
{
|
||||
if (i_angle == 0.f && !owner.HasInArc(0.01f, i_target.getTarget()))
|
||||
{ owner.SetInFront(i_target.getTarget()); }
|
||||
{
|
||||
owner.SetInFront(i_target.getTarget());
|
||||
}
|
||||
|
||||
if (!i_targetReached)
|
||||
{
|
||||
|
|
@ -170,7 +190,9 @@ bool TargetedMovementGeneratorMedium<T, D>::RequiresNewPosition(T& owner, float
|
|||
{
|
||||
// More distance let have better performance, less distance let have more sensitive reaction at target move.
|
||||
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->CanFly())
|
||||
{ return !i_target->IsWithinDist3d(x, y, z, this->GetDynamicTargetDistance(owner, true)); }
|
||||
{
|
||||
return !i_target->IsWithinDist3d(x, y, z, this->GetDynamicTargetDistance(owner, true));
|
||||
}
|
||||
else
|
||||
{ return !i_target->IsWithinDist2d(x, y, this->GetDynamicTargetDistance(owner, true)); }
|
||||
}
|
||||
|
|
@ -191,7 +213,9 @@ template<class T>
|
|||
void ChaseMovementGenerator<T>::_reachTarget(T& owner)
|
||||
{
|
||||
if (owner.CanReachWithMeleeAttack(this->i_target.getTarget()))
|
||||
{ owner.Attack(this->i_target.getTarget(), true); }
|
||||
{
|
||||
owner.Attack(this->i_target.getTarget(), true);
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
@ -236,7 +260,9 @@ template<class T>
|
|||
float ChaseMovementGenerator<T>::GetDynamicTargetDistance(T& owner, bool forRangeCheck) const
|
||||
{
|
||||
if (!forRangeCheck)
|
||||
{ return this->i_offset + CHASE_DEFAULT_RANGE_FACTOR * this->i_target->GetCombatReach(&owner); }
|
||||
{
|
||||
return this->i_offset + CHASE_DEFAULT_RANGE_FACTOR * this->i_target->GetCombatReach(&owner);
|
||||
}
|
||||
|
||||
return CHASE_RECHASE_RANGE_FACTOR * this->i_target->GetCombatReach(&owner) - this->i_target->GetObjectBoundingRadius();
|
||||
}
|
||||
|
|
@ -270,7 +296,9 @@ void FollowMovementGenerator<Creature>::_updateSpeed(Creature& u)
|
|||
{
|
||||
// pet only sync speed with owner
|
||||
if (!((Creature&)u).IsPet() || !i_target.isValid() || i_target->GetObjectGuid() != u.GetOwnerGuid())
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
u.UpdateSpeed(MOVE_RUN, true);
|
||||
u.UpdateSpeed(MOVE_WALK, true);
|
||||
|
|
@ -326,12 +354,16 @@ template<class T>
|
|||
float FollowMovementGenerator<T>::GetDynamicTargetDistance(T& owner, bool forRangeCheck) const
|
||||
{
|
||||
if (!forRangeCheck)
|
||||
{ return this->i_offset + owner.GetObjectBoundingRadius() + this->i_target->GetObjectBoundingRadius(); }
|
||||
{
|
||||
return this->i_offset + owner.GetObjectBoundingRadius() + this->i_target->GetObjectBoundingRadius();
|
||||
}
|
||||
|
||||
float allowed_dist = sWorld.getConfig(CONFIG_FLOAT_RATE_TARGET_POS_RECALCULATION_RANGE) - this->i_target->GetObjectBoundingRadius();
|
||||
allowed_dist += FOLLOW_RECALCULATE_FACTOR * (owner.GetObjectBoundingRadius() + this->i_target->GetObjectBoundingRadius());
|
||||
if (this->i_offset > FOLLOW_DIST_GAP_FOR_DIST_FACTOR)
|
||||
{ allowed_dist += FOLLOW_DIST_RECALCULATE_FACTOR * this->i_offset; }
|
||||
{
|
||||
allowed_dist += FOLLOW_DIST_RECALCULATE_FACTOR * this->i_offset;
|
||||
}
|
||||
|
||||
return allowed_dist;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,9 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature& creature, int32 pat
|
|||
}
|
||||
|
||||
if (i_path->empty())
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Initialize the i_currentNode to point to the first node
|
||||
i_currentNode = i_path->begin()->first;
|
||||
m_lastReachedWaypoint = 0;
|
||||
|
|
@ -107,12 +109,16 @@ void WaypointMovementGenerator<Creature>::Reset(Creature& creature)
|
|||
void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
|
||||
{
|
||||
if (!i_path || i_path->empty())
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_lastReachedWaypoint = i_currentNode;
|
||||
|
||||
if (m_isArrivalDone)
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
|
||||
m_isArrivalDone = true;
|
||||
|
|
@ -131,13 +137,19 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
|
|||
if (WaypointBehavior* behavior = node.behavior)
|
||||
{
|
||||
if (behavior->emote != 0)
|
||||
{ creature.HandleEmote(behavior->emote); }
|
||||
{
|
||||
creature.HandleEmote(behavior->emote);
|
||||
}
|
||||
|
||||
if (behavior->spell != 0)
|
||||
{ creature.CastSpell(&creature, behavior->spell, false); }
|
||||
{
|
||||
creature.CastSpell(&creature, behavior->spell, false);
|
||||
}
|
||||
|
||||
if (behavior->model1 != 0)
|
||||
{ creature.SetDisplayId(behavior->model1); }
|
||||
{
|
||||
creature.SetDisplayId(behavior->model1);
|
||||
}
|
||||
|
||||
if (behavior->textid[0])
|
||||
{
|
||||
|
|
@ -150,14 +162,18 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
|
|||
for (; i < MAX_WAYPOINT_TEXT; ++i)
|
||||
{
|
||||
if (!behavior->textid[i])
|
||||
{ break; }
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
textId = behavior->textid[urand(0, i - 1)];
|
||||
}
|
||||
|
||||
if (MangosStringLocale const* textData = sObjectMgr.GetMangosStringLocale(textId))
|
||||
{ creature.MonsterText(textData, NULL); }
|
||||
{
|
||||
creature.MonsterText(textData, NULL);
|
||||
}
|
||||
else
|
||||
{ sLog.outErrorDb("%s reached waypoint %u, attempted to do text %i, but required text-data could not be found", creature.GetGuidStr().c_str(), i_currentNode, textId); }
|
||||
}
|
||||
|
|
@ -179,13 +195,19 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
|
|||
void WaypointMovementGenerator<Creature>::StartMove(Creature& creature)
|
||||
{
|
||||
if (!i_path || i_path->empty())
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Stopped(creature))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!creature.IsAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
WaypointPath::const_iterator currPoint = i_path->find(i_currentNode);
|
||||
MANGOS_ASSERT(currPoint != i_path->end());
|
||||
|
|
@ -193,7 +215,9 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature& creature)
|
|||
if (WaypointBehavior* behavior = currPoint->second.behavior)
|
||||
{
|
||||
if (behavior->model2 != 0)
|
||||
{ creature.SetDisplayId(behavior->model2); }
|
||||
{
|
||||
creature.SetDisplayId(behavior->model2);
|
||||
}
|
||||
creature.SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +255,9 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature& creature)
|
|||
init.MoveTo(nextNode.x, nextNode.y, nextNode.z, true);
|
||||
|
||||
if (nextNode.orientation != 100 && nextNode.delay != 0)
|
||||
{ init.SetFacing(nextNode.orientation); }
|
||||
{
|
||||
init.SetFacing(nextNode.orientation);
|
||||
}
|
||||
creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE) && !creature.IsLevitating(), false);
|
||||
init.Launch();
|
||||
}
|
||||
|
|
@ -256,12 +282,16 @@ bool WaypointMovementGenerator<Creature>::Update(Creature& creature, const uint3
|
|||
if (Stopped(creature))
|
||||
{
|
||||
if (CanMove(diff, creature))
|
||||
{ StartMove(creature); }
|
||||
{
|
||||
StartMove(creature);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (creature.IsStopped())
|
||||
{ Stop(STOP_TIME_FOR_PLAYER); }
|
||||
{
|
||||
Stop(STOP_TIME_FOR_PLAYER);
|
||||
}
|
||||
else if (creature.movespline->Finalized())
|
||||
{
|
||||
OnArrived(creature);
|
||||
|
|
@ -291,12 +321,16 @@ bool WaypointMovementGenerator<Creature>::GetResetPosition(Creature&, float& x,
|
|||
{
|
||||
// prevent a crash at empty waypoint path.
|
||||
if (!i_path || i_path->empty())
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
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; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MANGOS_ASSERT(lastPoint != i_path->end());
|
||||
|
||||
|
|
@ -369,14 +403,18 @@ bool WaypointMovementGenerator<Creature>::SetNextWaypoint(uint32 pointId)
|
|||
uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const
|
||||
{
|
||||
if (i_currentNode >= i_path->size())
|
||||
{ return i_path->size(); }
|
||||
{
|
||||
return i_path->size();
|
||||
}
|
||||
|
||||
uint32 curMapId = (*i_path)[i_currentNode].mapid;
|
||||
|
||||
for (uint32 i = i_currentNode; i < i_path->size(); ++i)
|
||||
{
|
||||
if ((*i_path)[i].mapid != curMapId)
|
||||
{ return i; }
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return i_path->size();
|
||||
|
|
@ -400,7 +438,9 @@ void FlightPathMovementGenerator::Finalize(Player& player)
|
|||
{
|
||||
player.GetHostileRefManager().setOnlineOfflineState(true);
|
||||
if (player.pvpInfo.inHostileArea)
|
||||
{ player.CastSpell(&player, 2479, true); }
|
||||
{
|
||||
player.CastSpell(&player, 2479, true);
|
||||
}
|
||||
|
||||
// update z position to ground and orientation for landing point
|
||||
// this prevent cheating with landing point at lags
|
||||
|
|
@ -448,7 +488,9 @@ bool FlightPathMovementGenerator::Update(Player& player, const uint32& diff)
|
|||
{
|
||||
DoEventIfAny(player, (*i_path)[i_currentNode], departureEvent);
|
||||
if (pointId == i_currentNode)
|
||||
{ break; }
|
||||
{
|
||||
break;
|
||||
}
|
||||
i_currentNode += (uint32)departureEvent;
|
||||
departureEvent = !departureEvent;
|
||||
}
|
||||
|
|
@ -461,7 +503,9 @@ bool FlightPathMovementGenerator::Update(Player& player, const uint32& diff)
|
|||
void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
|
||||
{
|
||||
if (i_path->empty())
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 map0 = (*i_path)[0].mapid;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue