converted all tabs to 4 spaces

This commit is contained in:
Yehonal
2016-06-26 19:23:57 +02:00
parent 52f305111c
commit f6eefedcd5
717 changed files with 132388 additions and 132388 deletions

View File

@@ -72,7 +72,7 @@ void ConfusedMovementGenerator<T>::DoInitialize(T* unit)
i_waypoints[idx][2] = idx > 0 ? i_waypoints[idx-1][2] : z;
continue;
}
}
else
{
@@ -91,10 +91,10 @@ void ConfusedMovementGenerator<T>::DoInitialize(T* unit)
i_waypoints[idx][2] = new_z;
}
// Xinef: Call movement immediately to broadcast movement packet
// Xinef: Initial timer is set to 1 so update with 1
i_nextMove = urand(1, MAX_CONF_WAYPOINTS);
DoUpdate(unit, 1);
// Xinef: Call movement immediately to broadcast movement packet
// Xinef: Initial timer is set to 1 so update with 1
i_nextMove = urand(1, MAX_CONF_WAYPOINTS);
DoUpdate(unit, 1);
unit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
unit->AddUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_CONFUSED_MOVE);
@@ -117,7 +117,7 @@ void ConfusedMovementGenerator<Player>::_InitSpecific(Player* , bool &is_water_o
template<class T>
void ConfusedMovementGenerator<T>::DoReset(T* unit)
{
DoInitialize(unit);
DoInitialize(unit);
}
template<class T>

View File

@@ -28,7 +28,7 @@ void EscortMovementGenerator<T>::DoInitialize(T* unit)
init.Launch();
_splineId = unit->movespline->GetId();
_splineId = unit->movespline->GetId();
}
template<class T>
@@ -70,8 +70,8 @@ bool EscortMovementGenerator<T>::DoUpdate(T* unit, uint32 diff)
}
init.Launch();
// Xinef: Override spline Id on recalculate launch
_splineId = unit->movespline->GetId();
// Xinef: Override spline Id on recalculate launch
_splineId = unit->movespline->GetId();
}
return !arrived;

View File

@@ -26,13 +26,13 @@ class EscortMovementGenerator : public MovementGeneratorMedium< T, EscortMovemen
MovementGeneratorType GetMovementGeneratorType() { return ESCORT_MOTION_TYPE; }
uint32 GetSplineId() const { return _splineId; }
uint32 GetSplineId() const { return _splineId; }
private:
bool i_recalculateSpeed;
Movement::PointsArray m_precomputedPath;
uint32 _splineId;
uint32 _splineId;
};
#endif

View File

@@ -33,7 +33,7 @@ void HomeMovementGenerator<Creature>::DoFinalize(Creature* owner)
owner->ClearUnitState(UNIT_STATE_EVADE);
if (arrived)
{
// Xinef: npc run by default
// Xinef: npc run by default
//owner->SetWalk(true);
owner->LoadCreaturesAddon(true);
owner->AI()->JustReachedHome();
@@ -48,15 +48,15 @@ void HomeMovementGenerator<Creature>::DoReset(Creature*)
void HomeMovementGenerator<Creature>::_setTargetLocation(Creature* owner)
{
// Xinef: dont interrupt in any cast!
// Xinef: dont interrupt in any cast!
//if (owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED))
// return;
Movement::MoveSplineInit init(owner);
float x, y, z, o;
// Xinef: if there is motion generator on controlled slot, this one is not updated
// Xinef: always get reset pos from idle slot
MovementGenerator* gen = owner->GetMotionMaster()->GetMotionSlot(MOTION_SLOT_IDLE);
// Xinef: if there is motion generator on controlled slot, this one is not updated
// Xinef: always get reset pos from idle slot
MovementGenerator* gen = owner->GetMotionMaster()->GetMotionSlot(MOTION_SLOT_IDLE);
if (owner->GetMotionMaster()->empty() || !gen || !gen->GetResetPosition(x, y, z))
{
owner->GetHomePosition(x, y, z, o);
@@ -74,15 +74,15 @@ void HomeMovementGenerator<Creature>::_setTargetLocation(Creature* owner)
bool HomeMovementGenerator<Creature>::DoUpdate(Creature* owner, const uint32 /*time_diff*/)
{
arrived = owner->movespline->Finalized();
if (arrived)
return false;
arrived = owner->movespline->Finalized();
if (arrived)
return false;
if (i_recalculateTravel)
{
_setTargetLocation(owner);
i_recalculateTravel = false;
}
if (i_recalculateTravel)
{
_setTargetLocation(owner);
i_recalculateTravel = false;
}
return true;
return true;
}

View File

@@ -62,7 +62,7 @@ bool RotateMovementGenerator::Update(Unit* owner, uint32 diff)
while (angle < 0) angle += static_cast<float>(M_PI * 2);
}
owner->SetFacingTo(angle);
owner->SetFacingTo(angle);
if (m_duration > diff)
m_duration -= diff;

File diff suppressed because it is too large Load Diff

View File

@@ -33,7 +33,7 @@ void PointMovementGenerator<T>::DoInitialize(T* unit)
unit->StopMoving();
unit->AddUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE);
i_recalculateSpeed = false;
i_recalculateSpeed = false;
Movement::MoveSplineInit init(unit);
if (m_precomputedPath.size() > 2) // pussywizard: for charge
init.MovebyPath(m_precomputedPath);
@@ -48,27 +48,27 @@ void PointMovementGenerator<T>::DoInitialize(T* unit)
}
else
{
// Xinef: fix strange client visual bug, moving on z coordinate only switches orientation by 180 degrees (visual only)
if (G3D::fuzzyEq(unit->GetPositionX(), i_x) && G3D::fuzzyEq(unit->GetPositionY(), i_y))
{
i_x += 0.2f*cos(unit->GetOrientation());
i_y += 0.2f*sin(unit->GetOrientation());
}
// Xinef: fix strange client visual bug, moving on z coordinate only switches orientation by 180 degrees (visual only)
if (G3D::fuzzyEq(unit->GetPositionX(), i_x) && G3D::fuzzyEq(unit->GetPositionY(), i_y))
{
i_x += 0.2f*cos(unit->GetOrientation());
i_y += 0.2f*sin(unit->GetOrientation());
}
init.MoveTo(i_x, i_y, i_z);
}
init.MoveTo(i_x, i_y, i_z);
}
}
else
{
// Xinef: fix strange client visual bug, moving on z coordinate only switches orientation by 180 degrees (visual only)
if (G3D::fuzzyEq(unit->GetPositionX(), i_x) && G3D::fuzzyEq(unit->GetPositionY(), i_y))
{
i_x += 0.2f*cos(unit->GetOrientation());
i_y += 0.2f*sin(unit->GetOrientation());
}
{
// Xinef: fix strange client visual bug, moving on z coordinate only switches orientation by 180 degrees (visual only)
if (G3D::fuzzyEq(unit->GetPositionX(), i_x) && G3D::fuzzyEq(unit->GetPositionY(), i_y))
{
i_x += 0.2f*cos(unit->GetOrientation());
i_y += 0.2f*sin(unit->GetOrientation());
}
init.MoveTo(i_x, i_y, i_z);
}
}
if (speed > 0.0f)
init.SetVelocity(speed);
init.Launch();
@@ -175,8 +175,8 @@ void EffectMovementGenerator::Finalize(Unit* unit)
if (unit->GetTypeId() != TYPEID_UNIT)
return;
if (unit->GetTypeId() == TYPEID_UNIT && unit->HasUnitMovementFlag(MOVEMENTFLAG_FALLING) && unit->movespline->isFalling()) // pussywizard
unit->RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING);
if (unit->GetTypeId() == TYPEID_UNIT && unit->HasUnitMovementFlag(MOVEMENTFLAG_FALLING) && unit->movespline->isFalling()) // pussywizard
unit->RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING);
// Need restore previous movement since we have no proper states system
//if (unit->IsAlive() && !unit->HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_FLEEING))

View File

@@ -49,7 +49,7 @@ class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementG
uint32 id;
float i_x, i_y, i_z;
float speed;
bool i_recalculateSpeed;
bool i_recalculateSpeed;
Movement::PointsArray m_precomputedPath;
bool _generatePath;
bool _forceDestination;

View File

@@ -16,278 +16,278 @@ REWRITTEN BY XINEF
template<>
void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
{
if (creature->_moveState != MAP_OBJECT_CELL_MOVE_NONE)
return;
if (creature->_moveState != MAP_OBJECT_CELL_MOVE_NONE)
return;
if (_validPointsVector[_currentPoint].empty())
{
if (_currentPoint == RANDOM_POINTS_NUMBER) // cant go anywhere from initial position, lets stay
return;
// go back to initial position and will never return to this point
_currentPoint = RANDOM_POINTS_NUMBER;
_currDestPosition.Relocate(_initialPosition);
creature->AddUnitState(UNIT_STATE_ROAMING_MOVE);
Movement::MoveSplineInit init(creature);
init.MoveTo(_currDestPosition.GetPositionX(), _currDestPosition.GetPositionY(), _currDestPosition.GetPositionZ());
init.SetWalk(true);
init.Launch();
if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature)
creature->GetFormation()->LeaderMoveTo(_currDestPosition.GetPositionX(), _currDestPosition.GetPositionY(), _currDestPosition.GetPositionZ(), false);
return;
}
if (_validPointsVector[_currentPoint].empty())
{
if (_currentPoint == RANDOM_POINTS_NUMBER) // cant go anywhere from initial position, lets stay
return;
// go back to initial position and will never return to this point
_currentPoint = RANDOM_POINTS_NUMBER;
_currDestPosition.Relocate(_initialPosition);
creature->AddUnitState(UNIT_STATE_ROAMING_MOVE);
Movement::MoveSplineInit init(creature);
init.MoveTo(_currDestPosition.GetPositionX(), _currDestPosition.GetPositionY(), _currDestPosition.GetPositionZ());
init.SetWalk(true);
init.Launch();
if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature)
creature->GetFormation()->LeaderMoveTo(_currDestPosition.GetPositionX(), _currDestPosition.GetPositionY(), _currDestPosition.GetPositionZ(), false);
return;
}
uint8 random = urand(0, _validPointsVector[_currentPoint].size()-1);
std::vector<uint8>::iterator randomIter = _validPointsVector[_currentPoint].begin() + random;
uint8 newPoint = *randomIter;
uint16 pathIdx = uint16(_currentPoint*RANDOM_POINTS_NUMBER + newPoint);
uint8 random = urand(0, _validPointsVector[_currentPoint].size()-1);
std::vector<uint8>::iterator randomIter = _validPointsVector[_currentPoint].begin() + random;
uint8 newPoint = *randomIter;
uint16 pathIdx = uint16(_currentPoint*RANDOM_POINTS_NUMBER + newPoint);
// cant go anywhere from new point, so dont go there to not be stuck
if (_validPointsVector[newPoint].empty())
{
_validPointsVector[_currentPoint].erase(randomIter);
return;
}
// cant go anywhere from new point, so dont go there to not be stuck
if (_validPointsVector[newPoint].empty())
{
_validPointsVector[_currentPoint].erase(randomIter);
return;
}
Movement::PointsArray& finalPath = _preComputedPaths[pathIdx];
if (finalPath.empty())
{
Map* map = creature->GetMap();
float x = _destinationPoints[newPoint].x, y = _destinationPoints[newPoint].y, z = _destinationPoints[newPoint].z;
// invalid coordinates
if (!Trinity::IsValidMapCoord(x, y))
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
Movement::PointsArray& finalPath = _preComputedPaths[pathIdx];
if (finalPath.empty())
{
Map* map = creature->GetMap();
float x = _destinationPoints[newPoint].x, y = _destinationPoints[newPoint].y, z = _destinationPoints[newPoint].z;
// invalid coordinates
if (!Trinity::IsValidMapCoord(x, y))
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
float ground = INVALID_HEIGHT;
float levelZ = map->GetWaterOrGroundLevel(x, y, z+4.0f, &ground);
float newZ = INVALID_HEIGHT;
float ground = INVALID_HEIGHT;
float levelZ = map->GetWaterOrGroundLevel(x, y, z+4.0f, &ground);
float newZ = INVALID_HEIGHT;
// flying creature
if (creature->CanFly())
newZ = std::max<float>(levelZ, z + rand_norm()*_wanderDistance/2.0f);
// point underwater
else if (ground < levelZ)
{
if (!creature->CanSwim())
{
if (ground < levelZ - 1.5f)
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
levelZ = ground;
}
else
{
if (levelZ > INVALID_HEIGHT)
newZ = std::min<float>(levelZ-2.0f, z + rand_norm()*_wanderDistance/2.0f);
newZ = std::max<float>(ground, newZ);
}
}
// point on ground
else
{
if (levelZ <= INVALID_HEIGHT || !creature->CanWalk())
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
}
// flying creature
if (creature->CanFly())
newZ = std::max<float>(levelZ, z + rand_norm()*_wanderDistance/2.0f);
// point underwater
else if (ground < levelZ)
{
if (!creature->CanSwim())
{
if (ground < levelZ - 1.5f)
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
levelZ = ground;
}
else
{
if (levelZ > INVALID_HEIGHT)
newZ = std::min<float>(levelZ-2.0f, z + rand_norm()*_wanderDistance/2.0f);
newZ = std::max<float>(ground, newZ);
}
}
// point on ground
else
{
if (levelZ <= INVALID_HEIGHT || !creature->CanWalk())
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
}
if (newZ > INVALID_HEIGHT)
{
// flying / swiming creature - dest not in los
if (!creature->IsWithinLOS(x, y, newZ))
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
if (newZ > INVALID_HEIGHT)
{
// flying / swiming creature - dest not in los
if (!creature->IsWithinLOS(x, y, newZ))
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
finalPath.push_back(G3D::Vector3(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ()));
finalPath.push_back(G3D::Vector3(x, y, newZ));
}
else // ground
{
bool result = _pathGenerator->CalculatePath(x, y, levelZ, false);
if (result && !(_pathGenerator->GetPathType() & PATHFIND_NOPATH))
{
// generated path is too long
float pathLen = _pathGenerator->getPathLength();
if (pathLen*pathLen > creature->GetExactDistSq(x, y, levelZ) * MAX_PATH_LENGHT_FACTOR*MAX_PATH_LENGHT_FACTOR)
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
finalPath.push_back(G3D::Vector3(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ()));
finalPath.push_back(G3D::Vector3(x, y, newZ));
}
else // ground
{
bool result = _pathGenerator->CalculatePath(x, y, levelZ, false);
if (result && !(_pathGenerator->GetPathType() & PATHFIND_NOPATH))
{
// generated path is too long
float pathLen = _pathGenerator->getPathLength();
if (pathLen*pathLen > creature->GetExactDistSq(x, y, levelZ) * MAX_PATH_LENGHT_FACTOR*MAX_PATH_LENGHT_FACTOR)
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
finalPath = _pathGenerator->GetPath();
Movement::PointsArray::iterator itr = finalPath.begin();
Movement::PointsArray::iterator itrNext = finalPath.begin()+1;
float zDiff, distDiff;
finalPath = _pathGenerator->GetPath();
Movement::PointsArray::iterator itr = finalPath.begin();
Movement::PointsArray::iterator itrNext = finalPath.begin()+1;
float zDiff, distDiff;
for (; itrNext != finalPath.end(); ++itr, ++itrNext)
{
distDiff = sqrt(((*itr).x-(*itrNext).x)*((*itr).x-(*itrNext).x) + ((*itr).y-(*itrNext).y)*((*itr).y-(*itrNext).y));
zDiff = fabs((*itr).z - (*itrNext).z);
for (; itrNext != finalPath.end(); ++itr, ++itrNext)
{
distDiff = sqrt(((*itr).x-(*itrNext).x)*((*itr).x-(*itrNext).x) + ((*itr).y-(*itrNext).y)*((*itr).y-(*itrNext).y));
zDiff = fabs((*itr).z - (*itrNext).z);
// Xinef: tree climbing, cut as much as we can
if (zDiff > 2.0f || G3D::fuzzyNe(zDiff, 0.0f) && distDiff / zDiff < 2.15f) // ~25°
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
// Xinef: tree climbing, cut as much as we can
if (zDiff > 2.0f || G3D::fuzzyNe(zDiff, 0.0f) && distDiff / zDiff < 2.15f) // ~25°
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
if (!map->isInLineOfSight((*itr).x, (*itr).y, (*itr).z+2.f, (*itrNext).x, (*itrNext).y, (*itrNext).z+2.f, creature->GetPhaseMask()))
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
}
if (!map->isInLineOfSight((*itr).x, (*itr).y, (*itr).z+2.f, (*itrNext).x, (*itrNext).y, (*itrNext).z+2.f, creature->GetPhaseMask()))
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
}
// no valid path
if (finalPath.size() < 2)
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
}
else
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
}
}
// no valid path
if (finalPath.size() < 2)
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
}
else
{
_validPointsVector[_currentPoint].erase(randomIter);
_preComputedPaths.erase(pathIdx);
return;
}
}
}
_currentPoint = newPoint;
G3D::Vector3& finalPoint = finalPath[finalPath.size()-1];
_currDestPosition.Relocate(finalPoint.x, finalPoint.y, finalPoint.z);
_currentPoint = newPoint;
G3D::Vector3& finalPoint = finalPath[finalPath.size()-1];
_currDestPosition.Relocate(finalPoint.x, finalPoint.y, finalPoint.z);
creature->AddUnitState(UNIT_STATE_ROAMING_MOVE);
++_moveCount;
if (roll_chance_i((int32)_moveCount * 25 + 10))
{
_moveCount = 0;
_nextMoveTime.Reset(urand(4000, 8000));
}
creature->AddUnitState(UNIT_STATE_ROAMING_MOVE);
++_moveCount;
if (roll_chance_i((int32)_moveCount * 25 + 10))
{
_moveCount = 0;
_nextMoveTime.Reset(urand(4000, 8000));
}
Movement::MoveSplineInit init(creature);
init.MovebyPath(finalPath);
init.SetWalk(true);
init.Launch();
Movement::MoveSplineInit init(creature);
init.MovebyPath(finalPath);
init.SetWalk(true);
init.Launch();
if (sWorld->getBoolConfig(CONFIG_DONT_CACHE_RANDOM_MOVEMENT_PATHS))
_preComputedPaths.erase(pathIdx);
if (sWorld->getBoolConfig(CONFIG_DONT_CACHE_RANDOM_MOVEMENT_PATHS))
_preComputedPaths.erase(pathIdx);
//Call for creature group update
if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature)
creature->GetFormation()->LeaderMoveTo(finalPoint.x, finalPoint.y, finalPoint.z, false);
//Call for creature group update
if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature)
creature->GetFormation()->LeaderMoveTo(finalPoint.x, finalPoint.y, finalPoint.z, false);
}
template<>
void RandomMovementGenerator<Creature>::DoInitialize(Creature* creature)
{
if (!creature->IsAlive())
return;
if (!creature->IsAlive())
return;
if (!_wanderDistance)
_wanderDistance = creature->GetRespawnRadius();
if (!_wanderDistance)
_wanderDistance = creature->GetRespawnRadius();
_nextMoveTime.Reset(creature->GetDBTableGUIDLow() && creature->GetRespawnRadius() == _wanderDistance ? urand(1, 5000) : 0);
_wanderDistance = std::max((creature->GetRespawnRadius() == _wanderDistance && creature->GetInstanceId() == 0) ? (creature->CanFly() ? MIN_WANDER_DISTANCE_AIR : MIN_WANDER_DISTANCE_GROUND) : 0.0f, _wanderDistance);
_nextMoveTime.Reset(creature->GetDBTableGUIDLow() && creature->GetRespawnRadius() == _wanderDistance ? urand(1, 5000) : 0);
_wanderDistance = std::max((creature->GetRespawnRadius() == _wanderDistance && creature->GetInstanceId() == 0) ? (creature->CanFly() ? MIN_WANDER_DISTANCE_AIR : MIN_WANDER_DISTANCE_GROUND) : 0.0f, _wanderDistance);
if (G3D::fuzzyEq(_initialPosition.GetExactDist2d(0.0f, 0.0f), 0.0f))
{
_initialPosition.Relocate(creature);
_destinationPoints.clear();
for (uint8 i = 0; i < RANDOM_POINTS_NUMBER; ++i)
{
float angle = (M_PI*2.0f/(float)RANDOM_POINTS_NUMBER)*i;
float factor = 0.5f + rand_norm()*0.5f;
_destinationPoints.push_back(G3D::Vector3(_initialPosition.GetPositionX() + _wanderDistance*cos(angle)*factor, _initialPosition.GetPositionY() + _wanderDistance*sin(angle)*factor, _initialPosition.GetPositionZ()));
}
}
if (G3D::fuzzyEq(_initialPosition.GetExactDist2d(0.0f, 0.0f), 0.0f))
{
_initialPosition.Relocate(creature);
_destinationPoints.clear();
for (uint8 i = 0; i < RANDOM_POINTS_NUMBER; ++i)
{
float angle = (M_PI*2.0f/(float)RANDOM_POINTS_NUMBER)*i;
float factor = 0.5f + rand_norm()*0.5f;
_destinationPoints.push_back(G3D::Vector3(_initialPosition.GetPositionX() + _wanderDistance*cos(angle)*factor, _initialPosition.GetPositionY() + _wanderDistance*sin(angle)*factor, _initialPosition.GetPositionZ()));
}
}
if (!_pathGenerator)
_pathGenerator = new PathGenerator(creature);
creature->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
if (!_pathGenerator)
_pathGenerator = new PathGenerator(creature);
creature->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
}
template<>
void RandomMovementGenerator<Creature>::DoReset(Creature* creature)
{
DoInitialize(creature);
DoInitialize(creature);
}
template<>
void RandomMovementGenerator<Creature>::DoFinalize(Creature* creature)
{
creature->ClearUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE);
creature->SetWalk(false);
creature->ClearUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE);
creature->SetWalk(false);
}
template<>
bool RandomMovementGenerator<Creature>::DoUpdate(Creature* creature, const uint32 diff)
{
if (creature->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED))
{
_nextMoveTime.Reset(0); // Expire the timer
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
return true;
}
if (creature->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED))
{
_nextMoveTime.Reset(0); // Expire the timer
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
return true;
}
// xinef: if we got disable move flag, do not remove default generator - just prevent movement
if (creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
{
_nextMoveTime.Reset(0); // Expire the timer
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
return true;
}
// xinef: if we got disable move flag, do not remove default generator - just prevent movement
if (creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
{
_nextMoveTime.Reset(0); // Expire the timer
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
return true;
}
// prevent movement while casting spells with cast time or channel time
if (creature->HasUnitState(UNIT_STATE_CASTING))
{
bool stop = true;
if (Spell* spell = creature->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
if (!(spell->GetSpellInfo()->ChannelInterruptFlags & (AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING)) && !(spell->GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT))
stop = false;
bool stop = true;
if (Spell* spell = creature->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
if (!(spell->GetSpellInfo()->ChannelInterruptFlags & (AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING)) && !(spell->GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT))
stop = false;
if (stop)
{
if (!creature->IsStopped())
creature->StopMoving();
if (stop)
{
if (!creature->IsStopped())
creature->StopMoving();
return true;
}
return true;
}
}
if (creature->movespline->Finalized())
{
_nextMoveTime.Update(diff);
if (_nextMoveTime.Passed())
_setRandomLocation(creature);
}
return true;
if (creature->movespline->Finalized())
{
_nextMoveTime.Update(diff);
if (_nextMoveTime.Passed())
_setRandomLocation(creature);
}
return true;
}
template<>
bool RandomMovementGenerator<Creature>::GetResetPosition(float& x, float& y, float& z)
{
if (_currentPoint < RANDOM_POINTS_NUMBER)
_currDestPosition.GetPosition(x, y, z);
else if (G3D::fuzzyNe(_initialPosition.GetExactDist2d(0.0f, 0.0f), 0.0f)) // if initial position is not 0.0f, 0.0f
_initialPosition.GetPosition(x, y, z);
else
return false;
return true;
if (_currentPoint < RANDOM_POINTS_NUMBER)
_currDestPosition.GetPosition(x, y, z);
else if (G3D::fuzzyNe(_initialPosition.GetExactDist2d(0.0f, 0.0f), 0.0f)) // if initial position is not 0.0f, 0.0f
_initialPosition.GetPosition(x, y, z);
else
return false;
return true;
}

View File

@@ -8,32 +8,32 @@ REWRITTEN BY XINEF
#include "MovementGenerator.h"
#include "PathGenerator.h"
#define RANDOM_POINTS_NUMBER 12
#define RANDOM_LINKS_COUNT 7
#define MIN_WANDER_DISTANCE_GROUND 6.0f
#define MIN_WANDER_DISTANCE_AIR 10.0f
#define MAX_PATH_LENGHT_FACTOR 1.85f
#define RANDOM_POINTS_NUMBER 12
#define RANDOM_LINKS_COUNT 7
#define MIN_WANDER_DISTANCE_GROUND 6.0f
#define MIN_WANDER_DISTANCE_AIR 10.0f
#define MAX_PATH_LENGHT_FACTOR 1.85f
template<class T>
class RandomMovementGenerator : public MovementGeneratorMedium< T, RandomMovementGenerator<T> >
{
public:
RandomMovementGenerator(float spawnDist = 0.0f) : _nextMoveTime(0), _moveCount(0), _wanderDistance(spawnDist), _pathGenerator(NULL), _currentPoint(RANDOM_POINTS_NUMBER)
{
_initialPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
_destinationPoints.reserve(RANDOM_POINTS_NUMBER);
{
_initialPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
_destinationPoints.reserve(RANDOM_POINTS_NUMBER);
for (uint8 i = 0; i < RANDOM_POINTS_NUMBER; ++i)
{
_validPointsVector[i].reserve(RANDOM_LINKS_COUNT);
for (uint8 j = 0; j < RANDOM_LINKS_COUNT; ++j)
_validPointsVector[i].push_back((i + j + RANDOM_POINTS_NUMBER/2 - RANDOM_LINKS_COUNT/2) % RANDOM_POINTS_NUMBER);
}
for (uint8 i = 0; i < RANDOM_POINTS_NUMBER; ++i)
{
_validPointsVector[i].reserve(RANDOM_LINKS_COUNT);
for (uint8 j = 0; j < RANDOM_LINKS_COUNT; ++j)
_validPointsVector[i].push_back((i + j + RANDOM_POINTS_NUMBER/2 - RANDOM_LINKS_COUNT/2) % RANDOM_POINTS_NUMBER);
}
_validPointsVector[RANDOM_POINTS_NUMBER].reserve(RANDOM_POINTS_NUMBER);
for (uint8 i = 0; i < RANDOM_POINTS_NUMBER; ++i)
_validPointsVector[RANDOM_POINTS_NUMBER].push_back(i);
}
_validPointsVector[RANDOM_POINTS_NUMBER].reserve(RANDOM_POINTS_NUMBER);
for (uint8 i = 0; i < RANDOM_POINTS_NUMBER; ++i)
_validPointsVector[RANDOM_POINTS_NUMBER].push_back(i);
}
void _setRandomLocation(T*);
void DoInitialize(T*);
@@ -45,13 +45,13 @@ class RandomMovementGenerator : public MovementGeneratorMedium< T, RandomMovemen
private:
TimeTrackerSmall _nextMoveTime;
uint8 _moveCount;
uint8 _moveCount;
float _wanderDistance;
PathGenerator* _pathGenerator;
std::vector<G3D::Vector3> _destinationPoints;
std::vector<uint8> _validPointsVector[RANDOM_POINTS_NUMBER+1];
uint8 _currentPoint;
std::map<uint16, Movement::PointsArray> _preComputedPaths;
Position _initialPosition, _currDestPosition;
std::vector<G3D::Vector3> _destinationPoints;
std::vector<uint8> _validPointsVector[RANDOM_POINTS_NUMBER+1];
uint8 _currentPoint;
std::map<uint16, Movement::PointsArray> _preComputedPaths;
Position _initialPosition, _currDestPosition;
};
#endif

View File

@@ -44,8 +44,8 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T* owner, bool ini
float x, y, z;
bool isPlayerPet = owner->IsPet() && IS_PLAYER_GUID(owner->GetOwnerGUID());
bool sameTransport = owner->GetTransport() && owner->GetTransport() == i_target->GetTransport();
if (owner->GetMapId() == 631 && owner->GetTransport() && owner->GetTransport()->IsMotionTransport() && i_target->GetTransport() && i_target->GetTransport()->IsMotionTransport()) // for ICC, if both on a motion transport => don't use mmaps
sameTransport = owner->GetTypeId() == TYPEID_UNIT && i_target->isInAccessiblePlaceFor(owner->ToCreature());
if (owner->GetMapId() == 631 && owner->GetTransport() && owner->GetTransport()->IsMotionTransport() && i_target->GetTransport() && i_target->GetTransport()->IsMotionTransport()) // for ICC, if both on a motion transport => don't use mmaps
sameTransport = owner->GetTypeId() == TYPEID_UNIT && i_target->isInAccessiblePlaceFor(owner->ToCreature());
bool useMMaps = MMAP::MMapFactory::IsPathfindingEnabled(owner->FindMap()) && !sameTransport;
bool forceDest = (owner->FindMap() && owner->FindMap()->IsDungeon() && !isPlayerPet) || // force in instances to prevent exploiting
(owner->GetTypeId() == TYPEID_UNIT && ((owner->IsPet() && owner->HasUnitState(UNIT_STATE_FOLLOW)) || // allow pets following their master to cheat while generating paths
@@ -60,7 +60,7 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T* owner, bool ini
if (!i_offset)
{
float allowedRange = MELEE_RANGE;
float allowedRange = MELEE_RANGE;
if ((!initial || (owner->movespline->Finalized() && this->GetMovementGeneratorType() == CHASE_MOTION_TYPE)) && i_target->IsWithinMeleeRange(owner, allowedRange) && i_target->IsWithinLOS(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ()))
return;
@@ -94,21 +94,21 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T* owner, bool ini
size = owner->GetObjectSize();
}
if ((!initial || (owner->movespline->Finalized() && this->GetMovementGeneratorType() == CHASE_MOTION_TYPE)) && i_target->IsWithinDistInMap(owner, dist) && i_target->IsWithinLOS(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ()))
if ((!initial || (owner->movespline->Finalized() && this->GetMovementGeneratorType() == CHASE_MOTION_TYPE)) && i_target->IsWithinDistInMap(owner, dist) && i_target->IsWithinLOS(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ()))
return;
// Xinef: Fix follow angle for hostile units
float angle = i_angle;
if (angle == 0.0f && owner->GetVictim() && owner->GetVictim()->GetGUID() == i_target->GetGUID())
angle = MapManager::NormalizeOrientation(i_target->GetAngle(owner)-i_target->GetOrientation());
// Xinef: Fix follow angle for hostile units
float angle = i_angle;
if (angle == 0.0f && owner->GetVictim() && owner->GetVictim()->GetGUID() == i_target->GetGUID())
angle = MapManager::NormalizeOrientation(i_target->GetAngle(owner)-i_target->GetOrientation());
// to at i_offset distance from target and i_angle from target facing
bool inRange = i_target->GetClosePoint(x, y, z, size, dist, angle, owner, forcePoint);
if (!inRange && (forceDest || !useMMaps) && owner->HasUnitState(UNIT_STATE_FOLLOW) && fabs(i_target->GetPositionZ() - z) > 25.0f)
{
x = i_target->GetPositionX();
y = i_target->GetPositionY();
z = i_target->GetPositionZ();
}
if (!inRange && (forceDest || !useMMaps) && owner->HasUnitState(UNIT_STATE_FOLLOW) && fabs(i_target->GetPositionZ() - z) > 25.0f)
{
x = i_target->GetPositionX();
y = i_target->GetPositionY();
z = i_target->GetPositionZ();
}
}
D::_addUnitStateMove(owner);
@@ -122,70 +122,70 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T* owner, bool ini
if (!i_path)
i_path = new PathGenerator(owner);
if (!forceDest)
{
if (owner->GetMapId() == 618) // pussywizard: 618 Ring of Valor
{
if (Map* map = owner->FindMap())
if (Battleground* bg = ((BattlegroundMap*)map)->GetBG())
{
Position dest = {x, y, z, 0.0f};
if (GameObject* pillar = ((BattlegroundRV*)bg)->GetPillarAtPosition(&dest))
{
if (pillar->GetGoState() == GO_STATE_READY && pillar->ToTransport()->GetPathProgress() == 0 || owner->GetPositionZ() > 31.0f || owner->GetTransGUID() == pillar->GetGUID())
{
if (pillar->GetGoState() == GO_STATE_READY && pillar->ToTransport()->GetPathProgress() == 0)
z = std::max(z, 28.28f);
else
z = i_target->GetPositionZ();
if (!forceDest)
{
if (owner->GetMapId() == 618) // pussywizard: 618 Ring of Valor
{
if (Map* map = owner->FindMap())
if (Battleground* bg = ((BattlegroundMap*)map)->GetBG())
{
Position dest = {x, y, z, 0.0f};
if (GameObject* pillar = ((BattlegroundRV*)bg)->GetPillarAtPosition(&dest))
{
if (pillar->GetGoState() == GO_STATE_READY && pillar->ToTransport()->GetPathProgress() == 0 || owner->GetPositionZ() > 31.0f || owner->GetTransGUID() == pillar->GetGUID())
{
if (pillar->GetGoState() == GO_STATE_READY && pillar->ToTransport()->GetPathProgress() == 0)
z = std::max(z, 28.28f);
else
z = i_target->GetPositionZ();
init.MoveTo(x,y,z);
if (i_angle == 0.f)
init.SetFacing(i_target.getTarget());
init.SetWalk(((D*)this)->EnableWalking());
init.Launch();
return;
}
if (pillar->GetGoState() == GO_STATE_ACTIVE || pillar->GetGoState() == GO_STATE_READY && pillar->ToTransport()->GetPathProgress() > 0)
{
Position pos;
owner->GetFirstCollisionPositionForTotem(pos, owner->GetExactDist2d(i_target.getTarget()), owner->GetAngle(i_target.getTarget())-owner->GetOrientation(), false);
x = pos.GetPositionX();
y = pos.GetPositionY();
z = 28.28f;
}
}
}
}
}
init.MoveTo(x,y,z);
if (i_angle == 0.f)
init.SetFacing(i_target.getTarget());
init.SetWalk(((D*)this)->EnableWalking());
init.Launch();
return;
}
if (pillar->GetGoState() == GO_STATE_ACTIVE || pillar->GetGoState() == GO_STATE_READY && pillar->ToTransport()->GetPathProgress() > 0)
{
Position pos;
owner->GetFirstCollisionPositionForTotem(pos, owner->GetExactDist2d(i_target.getTarget()), owner->GetAngle(i_target.getTarget())-owner->GetOrientation(), false);
x = pos.GetPositionX();
y = pos.GetPositionY();
z = 28.28f;
}
}
}
}
}
if (!forceDest && getMSTimeDiff(lastPathingFailMSTime, World::GetGameTimeMS()) < 1000)
{
lastOwnerXYZ.Relocate(-5000.0f, -5000.0f, -5000.0f);
return;
}
if (!forceDest && getMSTimeDiff(lastPathingFailMSTime, World::GetGameTimeMS()) < 1000)
{
lastOwnerXYZ.Relocate(-5000.0f, -5000.0f, -5000.0f);
return;
}
bool result = i_path->CalculatePath(x, y, z, forceDest);
if (result)
{
float maxDist = MELEE_RANGE + owner->GetMeleeReach() + i_target->GetMeleeReach();
if (!forceDest && (i_path->GetPathType() & PATHFIND_NOPATH || !i_offset && !isPlayerPet && i_target->GetExactDistSq(i_path->GetActualEndPosition().x, i_path->GetActualEndPosition().y, i_path->GetActualEndPosition().z) > maxDist*maxDist))
{
lastPathingFailMSTime = World::GetGameTimeMS();
owner->m_targetsNotAcceptable[i_target->GetGUID()] = MMapTargetData(sWorld->GetGameTime()+DISALLOW_TIME_AFTER_FAIL, owner, i_target.getTarget());
return;
}
else
{
owner->m_targetsNotAcceptable.erase(i_target->GetGUID());
float maxDist = MELEE_RANGE + owner->GetMeleeReach() + i_target->GetMeleeReach();
if (!forceDest && (i_path->GetPathType() & PATHFIND_NOPATH || !i_offset && !isPlayerPet && i_target->GetExactDistSq(i_path->GetActualEndPosition().x, i_path->GetActualEndPosition().y, i_path->GetActualEndPosition().z) > maxDist*maxDist))
{
lastPathingFailMSTime = World::GetGameTimeMS();
owner->m_targetsNotAcceptable[i_target->GetGUID()] = MMapTargetData(sWorld->GetGameTime()+DISALLOW_TIME_AFTER_FAIL, owner, i_target.getTarget());
return;
}
else
{
owner->m_targetsNotAcceptable.erase(i_target->GetGUID());
init.MovebyPath(i_path->GetPath());
if (i_angle == 0.f)
init.SetFacing(i_target.getTarget());
init.SetWalk(((D*)this)->EnableWalking());
init.Launch();
return;
}
init.MovebyPath(i_path->GetPath());
if (i_angle == 0.f)
init.SetFacing(i_target.getTarget());
init.SetWalk(((D*)this)->EnableWalking());
init.Launch();
return;
}
}
// if failed to generate, just use normal MoveTo
@@ -219,20 +219,20 @@ bool TargetedMovementGeneratorMedium<T,D>::DoUpdate(T* owner, uint32 time_diff)
// prevent movement while casting spells with cast time or channel time
if (owner->HasUnitState(UNIT_STATE_CASTING))
{
bool stop = true;
if (Spell* spell = owner->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
if (!(spell->GetSpellInfo()->ChannelInterruptFlags & (AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING)) && !(spell->GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT))
stop = false;
bool stop = true;
if (Spell* spell = owner->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
if (!(spell->GetSpellInfo()->ChannelInterruptFlags & (AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING)) && !(spell->GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT))
stop = false;
if (stop)
{
// Xinef: delay distance recheck in case of succeeding casts
i_recheckDistance.Reset(300);
if (!owner->IsStopped())
owner->StopMoving();
if (stop)
{
// Xinef: delay distance recheck in case of succeeding casts
i_recheckDistance.Reset(300);
if (!owner->IsStopped())
owner->StopMoving();
return true;
}
return true;
}
}
// prevent crash after creature killed pet
@@ -242,12 +242,12 @@ bool TargetedMovementGeneratorMedium<T,D>::DoUpdate(T* owner, uint32 time_diff)
return true;
}
i_recheckDistanceForced.Update(time_diff);
if (i_recheckDistanceForced.Passed())
{
i_recheckDistanceForced.Reset(2500);
lastOwnerXYZ.Relocate(-5000.0f, -5000.0f, -5000.0f);
}
i_recheckDistanceForced.Update(time_diff);
if (i_recheckDistanceForced.Passed())
{
i_recheckDistanceForced.Reset(2500);
lastOwnerXYZ.Relocate(-5000.0f, -5000.0f, -5000.0f);
}
i_recheckDistance.Update(time_diff);
if (i_recheckDistance.Passed())
@@ -256,14 +256,14 @@ bool TargetedMovementGeneratorMedium<T,D>::DoUpdate(T* owner, uint32 time_diff)
//More distance let have better performance, less distance let have more sensitive reaction at target move.
float allowed_dist_sq = i_target->GetObjectSize() + owner->GetObjectSize() + MELEE_RANGE - 0.5f;
// xinef: if offset is negative (follow distance is smaller than just object sizes), reduce minimum allowed distance which is based purely on object sizes
if (i_offset < 0.0f)
{
allowed_dist_sq += i_offset;
allowed_dist_sq = std::max<float>(0.0f, allowed_dist_sq);
}
// xinef: if offset is negative (follow distance is smaller than just object sizes), reduce minimum allowed distance which is based purely on object sizes
if (i_offset < 0.0f)
{
allowed_dist_sq += i_offset;
allowed_dist_sq = std::max<float>(0.0f, allowed_dist_sq);
}
allowed_dist_sq *= allowed_dist_sq;
allowed_dist_sq *= allowed_dist_sq;
G3D::Vector3 dest = owner->movespline->FinalDestination();
if (owner->movespline->onTransport)
@@ -369,7 +369,7 @@ void FollowMovementGenerator<Creature>::_updateSpeed(Creature* owner)
{
// pet only sync speed with owner
/// Make sure we are not in the process of a map change (IsInWorld)
if (!IS_PLAYER_GUID(owner->GetOwnerGUID()) || !owner->IsInWorld() || !i_target.isValid() || i_target->GetGUID() != owner->GetOwnerGUID())
if (!IS_PLAYER_GUID(owner->GetOwnerGUID()) || !owner->IsInWorld() || !i_target.isValid() || i_target->GetGUID() != owner->GetOwnerGUID())
return;
owner->UpdateSpeed(MOVE_RUN, true);

View File

@@ -101,9 +101,9 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
if (!i_path || i_path->empty())
return false;
// Xinef: Dont allow dead creatures to move
if (!creature->IsAlive())
return false;
// Xinef: Dont allow dead creatures to move
if (!creature->IsAlive())
return false;
if (Stopped())
return true;
@@ -112,7 +112,7 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
if (m_isArrivalDone)
{
// Xinef: not true... update this at every waypoint!
// Xinef: not true... update this at every waypoint!
//if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint
{
float x = i_path->at(i_currentNode)->x;
@@ -135,11 +135,11 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
transportPath = false;
// else if (vehicle) - this should never happen, vehicle offsets are const
}
}
}
// Xinef: moved the upper IF here
if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint
{
// Xinef: moved the upper IF here
if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint
{
creature->GetMotionMaster()->Initialize();
return false;
}
@@ -147,9 +147,9 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
i_currentNode = (i_currentNode+1) % i_path->size();
}
// xinef: do not initialize motion if we got stunned in movementinform
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE))
return true;
// xinef: do not initialize motion if we got stunned in movementinform
if (creature->HasUnitState(UNIT_STATE_NOT_MOVE))
return true;
WaypointData const* node = i_path->at(i_currentNode);
@@ -214,25 +214,25 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
if (!i_path || i_path->empty())
return false;
// Xinef: Dont allow dead creatures to move
if (!creature->IsAlive())
return false;
// Xinef: Dont allow dead creatures to move
if (!creature->IsAlive())
return false;
// prevent movement while casting spells with cast time or channel time
if (creature->HasUnitState(UNIT_STATE_CASTING))
{
bool stop = true;
if (Spell* spell = creature->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
if (!(spell->GetSpellInfo()->ChannelInterruptFlags & (AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING)) && !(spell->GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT))
stop = false;
bool stop = true;
if (Spell* spell = creature->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
if (!(spell->GetSpellInfo()->ChannelInterruptFlags & (AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING)) && !(spell->GetSpellInfo()->InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT))
stop = false;
if (stop)
{
Stop(1000);
if (!creature->IsStopped())
creature->StopMoving();
return true;
}
if (stop)
{
Stop(1000);
if (!creature->IsStopped())
creature->StopMoving();
return true;
}
}
if (Stopped())
@@ -246,17 +246,17 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
Stop(STOP_TIME_FOR_PLAYER);
else
{
// xinef: code to detect pre-empetively if we should start movement to next waypoint
// xinef: do not start pre-empetive movement if current node has delay or we are ending waypoint movement
bool finished = creature->movespline->Finalized();
if (!finished && !i_path->at(i_currentNode)->delay && ((i_currentNode != i_path->size() - 1) || repeating))
finished = (creature->movespline->_Spline().length(creature->movespline->_currentSplineIdx()+1) - creature->movespline->timePassed()) < 200;
// xinef: code to detect pre-empetively if we should start movement to next waypoint
// xinef: do not start pre-empetive movement if current node has delay or we are ending waypoint movement
bool finished = creature->movespline->Finalized();
if (!finished && !i_path->at(i_currentNode)->delay && ((i_currentNode != i_path->size() - 1) || repeating))
finished = (creature->movespline->_Spline().length(creature->movespline->_currentSplineIdx()+1) - creature->movespline->timePassed()) < 200;
if (finished)
{
OnArrived(creature);
return StartMove(creature);
}
if (finished)
{
OnArrived(creature);
return StartMove(creature);
}
}
}
return true;
@@ -318,7 +318,7 @@ void FlightPathMovementGenerator::DoFinalize(Player* player)
// remove flag to prevent send object build movement packets for flight state and crash (movement generator already not at top of stack)
player->ClearUnitState(UNIT_STATE_IN_FLIGHT);
// xinef: this should be cleaned by CleanupAfterTaxiFlight(); function!
// xinef: this should be cleaned by CleanupAfterTaxiFlight(); function!
player->Dismount();
player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
@@ -329,7 +329,7 @@ void FlightPathMovementGenerator::DoFinalize(Player* player)
// this prevent cheating with landing point at lags
// when client side flight end early in comparison server side
player->StopMoving();
player->SetFallInformation(time(NULL), player->GetPositionZ());
player->SetFallInformation(time(NULL), player->GetPositionZ());
}
player->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_TAXI_BENCHMARK);
@@ -358,13 +358,13 @@ void FlightPathMovementGenerator::DoReset(Player* player)
bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/)
{
// xinef: map was switched
if (_mapSwitch)
{
DoInitialize(player);
_mapSwitch = false;
return true;
}
// xinef: map was switched
if (_mapSwitch)
{
DoInitialize(player);
_mapSwitch = false;
return true;
}
uint32 pointId = (uint32)player->movespline->currentPathIdx();
if (pointId > i_currentNode)
@@ -372,30 +372,30 @@ bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/)
bool departureEvent = true;
do
{
if (i_currentNode >= i_path.size())
{
sLog->outMisc("TAXI NODE WAS GREATER THAN PATH SIZE, GUID: %u, POINTID: %u, NODESIZE: %u, CURRENT: %u", player->GetGUIDLow(), pointId, i_path.size(), i_currentNode);
player->CleanupAfterTaxiFlight();
return false;
}
if (i_currentNode >= i_path.size())
{
sLog->outMisc("TAXI NODE WAS GREATER THAN PATH SIZE, GUID: %u, POINTID: %u, NODESIZE: %u, CURRENT: %u", player->GetGUIDLow(), pointId, i_path.size(), i_currentNode);
player->CleanupAfterTaxiFlight();
return false;
}
if (i_path[i_currentNode]->mapid != player->GetMapId())
{
sLog->outMisc("Player on different map, curmap: %u, pointmap: %u, nodesize: %u, currentnode: %u", player->GetMapId(), i_path[i_currentNode]->mapid, i_path.size(), i_currentNode);
player->CleanupAfterTaxiFlight();
return false;
}
if (i_path[i_currentNode]->mapid != player->GetMapId())
{
sLog->outMisc("Player on different map, curmap: %u, pointmap: %u, nodesize: %u, currentnode: %u", player->GetMapId(), i_path[i_currentNode]->mapid, i_path.size(), i_currentNode);
player->CleanupAfterTaxiFlight();
return false;
}
DoEventIfAny(player, i_path[i_currentNode], departureEvent);
// xinef: erase any previous points
uint32 curSize = _pointsForPathSwitch.size();
// xinef: erase any previous points
uint32 curSize = _pointsForPathSwitch.size();
while (!_pointsForPathSwitch.empty() && _pointsForPathSwitch.front() <= i_currentNode)
_pointsForPathSwitch.pop_front();
// xinef: switch destination only once
if (curSize != _pointsForPathSwitch.size())
player->m_taxi.NextTaxiDestination();
// xinef: switch destination only once
if (curSize != _pointsForPathSwitch.size())
player->m_taxi.NextTaxiDestination();
if (pointId == i_currentNode)
break;
@@ -405,26 +405,26 @@ bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/)
i_currentNode += (uint32)departureEvent;
departureEvent = !departureEvent;
// xinef: map should be switched, do not rely on client packets QQ
if (i_currentNode + 1 < i_path.size() && i_path[i_currentNode+1]->mapid != player->GetMapId())
{
++i_currentNode;
_mapSwitch = true;
player->TeleportTo(i_path[i_currentNode]->mapid, i_path[i_currentNode]->x, i_path[i_currentNode]->y, i_path[i_currentNode]->z, player->GetOrientation(), TELE_TO_NOT_LEAVE_TAXI);
return true;
}
// xinef: map should be switched, do not rely on client packets QQ
if (i_currentNode + 1 < i_path.size() && i_path[i_currentNode+1]->mapid != player->GetMapId())
{
++i_currentNode;
_mapSwitch = true;
player->TeleportTo(i_path[i_currentNode]->mapid, i_path[i_currentNode]->x, i_path[i_currentNode]->y, i_path[i_currentNode]->z, player->GetOrientation(), TELE_TO_NOT_LEAVE_TAXI);
return true;
}
// xinef: reached the end
if (i_currentNode >= i_path.size() - 1)
{
player->CleanupAfterTaxiFlight();
player->SetFallInformation(time(NULL), player->GetPositionZ());
if (player->pvpInfo.IsHostile)
player->CastSpell(player, 2479, true);
// xinef: reached the end
if (i_currentNode >= i_path.size() - 1)
{
player->CleanupAfterTaxiFlight();
player->SetFallInformation(time(NULL), player->GetPositionZ());
if (player->pvpInfo.IsHostile)
player->CastSpell(player, 2479, true);
return false;
}
}
return false;
}
}
while (true);
}
@@ -463,17 +463,17 @@ void FlightPathMovementGenerator::InitEndGridInfo()
uint32 nodeCount = i_path.size(); //! Number of nodes in path.
_endMapId = i_path[nodeCount - 1]->mapid; //! MapId of last node
// pussywizard:
{
_preloadTargetNode = nodeCount - 1;
for (uint8 i = 3; i > 0; --i)
if (nodeCount >= i && _endMapId == i_path[nodeCount - i]->mapid)
{
_preloadTargetNode = nodeCount - i;
break;
}
//_preloadTargetNode = nodeCount - 3; // pussywizard: this can be on other map
}
// pussywizard:
{
_preloadTargetNode = nodeCount - 1;
for (uint8 i = 3; i > 0; --i)
if (nodeCount >= i && _endMapId == i_path[nodeCount - i]->mapid)
{
_preloadTargetNode = nodeCount - i;
break;
}
//_preloadTargetNode = nodeCount - 3; // pussywizard: this can be on other map
}
_endGridX = i_path[nodeCount - 1]->x;
_endGridY = i_path[nodeCount - 1]->y;

View File

@@ -113,7 +113,7 @@ class FlightPathMovementGenerator : public MovementGeneratorMedium< Player, Flig
_endGridY = 0.0f;
_endMapId = 0;
_preloadTargetNode = 0;
_mapSwitch = false;
_mapSwitch = false;
}
void LoadPath(Player* player);
void DoInitialize(Player*);
@@ -137,7 +137,7 @@ class FlightPathMovementGenerator : public MovementGeneratorMedium< Player, Flig
float _endGridY; //! Y coord of last node location
uint32 _endMapId; //! map Id of last node location
uint32 _preloadTargetNode; //! node index where preloading starts
bool _mapSwitch;
bool _mapSwitch;
std::deque<uint32> _pointsForPathSwitch; //! node indexes and costs where TaxiPath changes
};