From 9e0faace9a5114fc2324c2c601ba943272e0d6ff Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 16 Feb 2018 20:59:19 +0100 Subject: Core/Entities: Reduce the probability of units dropping under the map (#21322) Reduce the probabilty of going under the map --- src/server/game/Spells/Spell.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (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 b6b5c22b6e1..7eaad1835ec 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1359,6 +1359,32 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici dest = SpellDestination(x, y, liquidLevel, m_caster->GetOrientation()); break; } + case TARGET_DEST_CASTER_FRONT_LEAP: + { + float dist = m_spellInfo->Effects[effIndex].CalcRadius(m_caster); + float angle = targetType.CalcDirectionAngle(); + + Position pos = dest._position; + + m_caster->MovePositionToFirstCollision(pos, dist, angle); + // Generate path to that point. + if (!m_preGeneratedPath) + m_preGeneratedPath = std::make_unique(m_caster); + + m_preGeneratedPath->SetPathLengthLimit(dist); + + // Should we use straightline here ? What do we do when we don't have a full path ? + bool pathResult = m_preGeneratedPath->CalculatePath(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), false, true); + if (pathResult && m_preGeneratedPath->GetPathType() & (PATHFIND_NORMAL | PATHFIND_SHORTCUT)) + { + pos.m_positionX = m_preGeneratedPath->GetActualEndPosition().x; + pos.m_positionY = m_preGeneratedPath->GetActualEndPosition().y; + pos.m_positionZ = m_preGeneratedPath->GetActualEndPosition().z; + } + + dest.Relocate(pos); + break; + } default: { float dist = m_spellInfo->Effects[effIndex].CalcRadius(m_caster); -- cgit v1.2.3