Core/Objects: fixed random destination selection for spells casted by flying units

* the path generator will now check for realtime movement flags instead of movement template data for units
This commit is contained in:
Ovahlord
2020-05-16 16:30:39 +02:00
parent bc57ecd3bd
commit d91fa5023e
2 changed files with 23 additions and 19 deletions

View File

@@ -2521,8 +2521,9 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
path.CalculatePath(destx, desty, destz, false);
// We have a invalid path result. Skip further processing.
if (path.GetPathType() & ~(PATHFIND_NORMAL | PATHFIND_SHORTCUT | PATHFIND_INCOMPLETE | PATHFIND_FARFROMPOLY_END | PATHFIND_NOT_USING_PATH))
return;
if (path.GetPathType() & ~(PATHFIND_NORMAL | PATHFIND_SHORTCUT | PATHFIND_INCOMPLETE | PATHFIND_FARFROMPOLY | PATHFIND_NOT_USING_PATH))
if (!(path.GetPathType() & PATHFIND_FARFROMPOLY) || ((path.GetPathType() & PATHFIND_FARFROMPOLY) && !(path.GetPathType() & PATHFIND_NOT_USING_PATH)))
return;
G3D::Vector3 result = path.GetPath().back();
destx = result.x;
@@ -2531,24 +2532,27 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
// Object is using a shortcut. Check static LOS
float halfHeight = GetCollisionHeight() * 0.5f;
bool col;
/*
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(GetPhaseShift(), GetMap(), pos.m_positionX, pos.m_positionY);
bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(terrainMapId,
pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight,
destx, desty, destz + halfHeight,
destx, desty, destz, -0.5f);
bool col = false;
destz -= halfHeight;
// Collided with static LOS object, move back to collision point
if (col)
// Unit is flying. Do a VMap check to avoid moving the position into walls or obstacles
if (path.GetPathType() & PATHFIND_NOT_USING_PATH)
{
destx -= CONTACT_DISTANCE * std::cos(angle);
desty -= CONTACT_DISTANCE * std::sin(angle);
dist = std::sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(GetPhaseShift(), GetMap(), pos.m_positionX, pos.m_positionY);
col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(terrainMapId,
pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight,
destx, desty, destz + halfHeight,
destx, desty, destz, -0.5f);
destz -= halfHeight;
// Collided with static LOS object, move back to collision point
if (col)
{
destx -= CONTACT_DISTANCE * std::cos(angle);
desty -= CONTACT_DISTANCE * std::sin(angle);
dist = std::sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
}
}
*/
// check dynamic collision
col = GetMap()->getObjectHitPos(GetPhaseShift(),

View File

@@ -180,7 +180,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
{
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: (startPoly == 0 || endPoly == 0)");
BuildShortcut();
bool path = _source->GetTypeId() == TYPEID_UNIT && _source->ToCreature()->CanFly();
bool path = _source->GetTypeId() == TYPEID_UNIT && _source->ToCreature()->IsFlying();
bool waterPath = _source->GetTypeId() == TYPEID_UNIT && _source->ToCreature()->CanSwim();
if (waterPath)
@@ -234,7 +234,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: flying case");
if (const Unit* _sourceUnit = _source->ToUnit())
{
if (_sourceUnit->CanFly())
if (_sourceUnit->IsFlying())
buildShotrcut = true;
// Allow to build a shortcut if the unit is falling and it's trying to move downwards towards a target (i.e. charging)
else if (_sourceUnit->IsFalling() && endPos.z < startPos.z)