Partial: Core/Entities: Reduce the probability of units dropping under the map

Port From (https://github.com/TrinityCore/TrinityCore/commit/69edf282fa777912385dbb4d921b9f3a8f92a00e)
This commit is contained in:
hondacrx
2021-08-08 23:16:19 -04:00
parent 7ffe2ee299
commit dac2b45ab8
4 changed files with 1072 additions and 1047 deletions
+2 -4
View File
@@ -2115,7 +2115,7 @@ namespace Game.Entities
else else
{ {
float ground_z = GetMapHeight(x, y, z); float ground_z = GetMapHeight(x, y, z);
if (z < ground_z) if (MathF.Abs(z - ground_z) < GetCollisionHeight())
z = ground_z; z = ground_z;
} }
break; break;
@@ -2138,7 +2138,7 @@ namespace Game.Entities
else else
{ {
float ground_z = GetMapHeight(x, y, z); float ground_z = GetMapHeight(x, y, z);
if (z < ground_z) if (MathF.Abs(z - ground_z) < GetCollisionHeight())
z = ground_z; z = ground_z;
} }
break; break;
@@ -2464,8 +2464,6 @@ namespace Game.Entities
jump.Reset(); jump.Reset();
} }
public struct TransportInfo public struct TransportInfo
{ {
public void Reset() public void Reset()
@@ -977,6 +977,7 @@ namespace Game.Movement
Detour.dtNavMesh _navMesh; Detour.dtNavMesh _navMesh;
} }
[Flags]
public enum PathType public enum PathType
{ {
Blank = 0x00, // path not built yet Blank = 0x00, // path not built yet
+28 -1
View File
@@ -882,6 +882,32 @@ namespace Game.Spells
dest = new SpellDestination(x, y, liquidLevel, m_caster.GetOrientation()); dest = new SpellDestination(x, y, liquidLevel, m_caster.GetOrientation());
break; break;
} }
case Targets.DestCasterFrontLeap:
{
float dist = m_spellInfo.GetEffect(effIndex).CalcRadius(m_caster);
float angle = targetType.CalcDirectionAngle();
Position pos = new(dest.Position);
m_caster.MovePositionToFirstCollision(pos, dist, angle);
// Generate path to that point.
if (m_preGeneratedPath == null)
m_preGeneratedPath = new(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().HasFlag(PathType.Normal | PathType.Shortcut))
{
pos.posX = m_preGeneratedPath.GetActualEndPosition().X;
pos.posY = m_preGeneratedPath.GetActualEndPosition().Y;
pos.posZ = m_preGeneratedPath.GetActualEndPosition().Z;
}
dest.Relocate(pos);
break;
}
case Targets.DestCasterGround: case Targets.DestCasterGround:
m_caster.UpdateAllowedPositionZ(dest.Position.GetPositionX(), dest.Position.GetPositionY(), ref dest.Position.posZ); m_caster.UpdateAllowedPositionZ(dest.Position.GetPositionX(), dest.Position.GetPositionY(), ref dest.Position.posZ);
break; break;
@@ -6113,7 +6139,8 @@ namespace Game.Spells
totems -= 1; totems -= 1;
continue; continue;
} }
} else }
else
totems -= 1; totems -= 1;
} }
if (totems != 0) if (totems != 0)
-1
View File
@@ -3722,7 +3722,6 @@ namespace Game.Spells
return; return;
Position pos = destTarget.GetPosition(); Position pos = destTarget.GetPosition();
pos = unitTarget.GetFirstCollisionPosition(unitTarget.GetDistance(pos.posX, pos.posY, pos.posZ + 2.0f), 0.0f);
unitTarget.NearTeleportTo(pos.posX, pos.posY, pos.posZ, pos.Orientation, unitTarget == m_caster); unitTarget.NearTeleportTo(pos.posX, pos.posY, pos.posZ, pos.Orientation, unitTarget == m_caster);
} }