diff options
author | Jeremy <Golrag@users.noreply.github.com> | 2018-02-16 20:59:19 +0100 |
---|---|---|
committer | funjoker <funjoker109@gmail.com> | 2021-08-08 21:21:34 +0200 |
commit | 69edf282fa777912385dbb4d921b9f3a8f92a00e (patch) | |
tree | 986a2f8c5037182b04a3f3cc035bbc1d77efdc41 /src | |
parent | fcead0b4eae298c1a46c42fea56a3b3b9ae2bf8f (diff) |
Partial: Core/Entities: Reduce the probability of units dropping under the map (#21322)
Reduce the probabilty of going under the map
(cherry picked from commit 9e0faace9a5114fc2324c2c601ba943272e0d6ff)
Revert "Core/Entities: Reduce the probability of units dropping under the map (#21322)"
(cherry picked from commit 2dadbda24ac1c2e6ff3dad650c7e25f4b3322342)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 26 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 1 |
3 files changed, 28 insertions, 3 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 549fadc0a6d..564bcac77cf 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1327,7 +1327,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const else { float ground_z = GetMapHeight(x, y, z); - if (z < ground_z) + if (std::fabs(z - ground_z) < GetCollisionHeight()) z = ground_z; } break; @@ -1350,7 +1350,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const else { float ground_z = GetMapHeight(x, y, z); - if (z < ground_z) + if (std::fabs(z - ground_z) < GetCollisionHeight()) z = ground_z; } break; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 44bff9f6932..094cbb2045a 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1377,6 +1377,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->GetEffect(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<PathGenerator>(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; + } case TARGET_DEST_CASTER_GROUND: m_caster->UpdateAllowedPositionZ(dest._position.GetPositionX(), dest._position.GetPositionY(), dest._position.m_positionZ); break; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 25a79b4f50b..63319f25b84 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -3928,7 +3928,6 @@ void Spell::EffectLeap(SpellEffIndex /*effIndex*/) return; Position pos = destTarget->GetPosition(); - pos = unitTarget->GetFirstCollisionPosition(unitTarget->GetDistance(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()), 0.0f); unitTarget->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), unitTarget == m_caster); } |