From 8d32849b3493d9e819be27945ef31488d8ba6dcf Mon Sep 17 00:00:00 2001 From: Giacomo Pozzoni Date: Mon, 30 Dec 2019 15:58:39 +0100 Subject: 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 272009ebeed80bc7749c004348fb1057761cf268 * Remove Z offset when charging a target as it never made sense (cherry picked from commit 88a14251e2765880e90cb41be7919cd39e3308e2) --- src/server/game/Spells/Spell.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/server/game/Spells/Spell.cpp') diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 338867b9a52..63c83148d53 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5680,23 +5680,15 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32 m_preGeneratedPath = std::make_unique(unitCaster); m_preGeneratedPath->SetPathLengthLimit(range); + // 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() + targetObjectSize, false, true); + bool result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false, false); 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) - return SPELL_FAILED_OUT_OF_RANGE; - else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE)) - return SPELL_FAILED_NOPATH; - else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if not in a straight line - return SPELL_FAILED_NOPATH; - } - else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if in a straight line - return SPELL_FAILED_NOPATH; + return SPELL_FAILED_NOPATH; + else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if not in a straight line + return SPELL_FAILED_NOPATH; m_preGeneratedPath->ShortenPathUntilDist(PositionToVector3(target), objSize); // move back } -- cgit v1.2.3