Core/MMaps: Fix charge underwater/falling (#24010)
* Core/MMaps: Fix charge underwater
Fix charge sometimes returning "no path available" when swimming/underwater.
Fix charge selecting a destination point 4 yards above swimming/underwater targets
* Allow falling units to charge targets that are below (lower Z coordinate)
* Disable "raycast" pathfinding as it's not blizzlike.
This might show some strange paths when charging with a target in front.
It also fixes some falling undermap issues.
This Reverts 272009ebee
* Remove Z offset when charging a target as it never made sense
This commit is contained in:
1 parent
d0f946f30a
commit
fbe4abf3be
2 files changed
+7
-16
No files matched your search
@@ -206,23 +206,22 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
|
|||||||
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: farFromPoly distToStartPoly=%.3f distToEndPoly=%.3f", distToStartPoly, distToEndPoly);
|
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: farFromPoly distToStartPoly=%.3f distToEndPoly=%.3f", distToStartPoly, distToEndPoly);
|
||||||
|
|
||||||
bool buildShotrcut = false;
|
bool buildShotrcut = false;
|
||||||
if (_sourceUnit->GetTypeId() == TYPEID_UNIT)
|
|
||||||
{
|
|
||||||
Creature* owner = (Creature*)_sourceUnit;
|
|
||||||
|
|
||||||
G3D::Vector3 const& p = (distToStartPoly > 7.0f) ? startPos : endPos;
|
G3D::Vector3 const& p = (distToStartPoly > 7.0f) ? startPos : endPos;
|
||||||
if (_sourceUnit->GetMap()->IsUnderWater(_sourceUnit->GetPhaseShift(), p.x, p.y, p.z))
|
if (_sourceUnit->GetMap()->IsUnderWater(_sourceUnit->GetPhaseShift(), p.x, p.y, p.z))
|
||||||
{
|
{
|
||||||
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: underWater case");
|
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: underWater case");
|
||||||
if (owner->CanSwim())
|
if (_sourceUnit->CanSwim())
|
||||||
buildShotrcut = true;
|
buildShotrcut = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: flying case");
|
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: flying case");
|
||||||
if (owner->CanFly())
|
if (_sourceUnit->CanFly())
|
||||||
|
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)
|
||||||
buildShotrcut = true;
|
buildShotrcut = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildShotrcut)
|
if (buildShotrcut)
|
||||||
|
|||||||
@@ -5710,23 +5710,15 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
|
|||||||
|
|
||||||
m_preGeneratedPath = Trinity::make_unique<PathGenerator>(m_caster);
|
m_preGeneratedPath = Trinity::make_unique<PathGenerator>(m_caster);
|
||||||
m_preGeneratedPath->SetPathLengthLimit(range);
|
m_preGeneratedPath->SetPathLengthLimit(range);
|
||||||
|
|
||||||
// first try with raycast, if it fails fall back to normal path
|
// first try with raycast, if it fails fall back to normal path
|
||||||
float targetObjectSize = std::min(target->GetCombatReach(), 4.0f);
|
bool result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false, false);
|
||||||
bool result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, true);
|
|
||||||
if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT)
|
|
||||||
return SPELL_FAILED_OUT_OF_RANGE;
|
|
||||||
else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
|
|
||||||
{
|
|
||||||
result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, false);
|
|
||||||
if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT)
|
if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT)
|
||||||
return SPELL_FAILED_OUT_OF_RANGE;
|
return SPELL_FAILED_OUT_OF_RANGE;
|
||||||
else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
|
else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
|
||||||
return SPELL_FAILED_NOPATH;
|
return SPELL_FAILED_NOPATH;
|
||||||
else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if not in a straight line
|
else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if not in a straight line
|
||||||
return SPELL_FAILED_NOPATH;
|
return SPELL_FAILED_NOPATH;
|
||||||
}
|
|
||||||
else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if in a straight line
|
|
||||||
return SPELL_FAILED_NOPATH;
|
|
||||||
|
|
||||||
m_preGeneratedPath->ShortenPathUntilDist(PositionToVector3(target), objSize); // move back
|
m_preGeneratedPath->ShortenPathUntilDist(PositionToVector3(target), objSize); // move back
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user