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
+55 -57
View File
@@ -575,7 +575,7 @@ namespace Game.Entities
// *data << *areaTrigger->GetMovementScript(); // AreaTriggerMovementScriptInfo // *data << *areaTrigger->GetMovementScript(); // AreaTriggerMovementScriptInfo
if (hasOrbit) if (hasOrbit)
areaTrigger.GetCircularMovementInfo().Value.Write(data); areaTrigger.GetCircularMovementInfo().Value.Write(data);
} }
if (flags.GameObject) if (flags.GameObject)
@@ -1011,8 +1011,8 @@ namespace Game.Entities
transport.RemovePassenger(this); transport.RemovePassenger(this);
} }
public uint GetZoneId() { return m_zoneId; } public uint GetZoneId() { return m_zoneId; }
public uint GetAreaId() { return m_areaId; } public uint GetAreaId() { return m_areaId; }
public void GetZoneAndAreaId(out uint zoneid, out uint areaid) { zoneid = m_zoneId; areaid = m_areaId; } public void GetZoneAndAreaId(out uint zoneid, out uint areaid) { zoneid = m_zoneId; areaid = m_areaId; }
@@ -1608,7 +1608,7 @@ namespace Game.Entities
return a != null && b != null && a.IsInPhase(b); return a != null && b != null && a.IsInPhase(b);
} }
public virtual float GetCombatReach() { return 0.0f; } // overridden (only) in Unit public virtual float GetCombatReach() { return 0.0f; } // overridden (only) in Unit
public PhaseShift GetPhaseShift() { return _phaseShift; } public PhaseShift GetPhaseShift() { return _phaseShift; }
public void SetPhaseShift(PhaseShift phaseShift) { _phaseShift = new PhaseShift(phaseShift); } public void SetPhaseShift(PhaseShift phaseShift) { _phaseShift = new PhaseShift(phaseShift); }
public PhaseShift GetSuppressedPhaseShift() { return _suppressedPhaseShift; } public PhaseShift GetSuppressedPhaseShift() { return _suppressedPhaseShift; }
@@ -1791,7 +1791,7 @@ namespace Game.Entities
public virtual float GetStationaryZ() { return GetPositionZ(); } public virtual float GetStationaryZ() { return GetPositionZ(); }
public virtual float GetStationaryO() { return GetOrientation(); } public virtual float GetStationaryO() { return GetOrientation(); }
public virtual float GetCollisionHeight() { return 0.0f; } public virtual float GetCollisionHeight() { return 0.0f; }
public float GetMidsectionHeight() { return GetCollisionHeight() / 2.0f; } public float GetMidsectionHeight() { return GetCollisionHeight() / 2.0f; }
public virtual bool IsNeverVisibleFor(WorldObject seer) { return !IsInWorld; } public virtual bool IsNeverVisibleFor(WorldObject seer) { return !IsInWorld; }
@@ -1941,7 +1941,7 @@ namespace Game.Entities
oz += GetCollisionHeight(); oz += GetCollisionHeight();
} }
else else
obj.GetHitSpherePointFor(new (GetPositionX(), GetPositionY(), GetPositionZ() + GetCollisionHeight()), out ox, out oy, out oz); obj.GetHitSpherePointFor(new(GetPositionX(), GetPositionY(), GetPositionZ() + GetCollisionHeight()), out ox, out oy, out oz);
float x, y, z; float x, y, z;
if (IsPlayer()) if (IsPlayer())
@@ -1950,7 +1950,7 @@ namespace Game.Entities
z += GetCollisionHeight(); z += GetCollisionHeight();
} }
else else
GetHitSpherePointFor(new (obj.GetPositionX(), obj.GetPositionY(), obj.GetPositionZ() + obj.GetCollisionHeight()), out x, out y, out z); GetHitSpherePointFor(new(obj.GetPositionX(), obj.GetPositionY(), obj.GetPositionZ() + obj.GetCollisionHeight()), out x, out y, out z);
return GetMap().IsInLineOfSight(GetPhaseShift(), x, y, z, ox, oy, oz, checks, ignoreFlags); return GetMap().IsInLineOfSight(GetPhaseShift(), x, y, z, ox, oy, oz, checks, ignoreFlags);
} }
@@ -2094,62 +2094,62 @@ namespace Game.Entities
switch (GetTypeId()) switch (GetTypeId())
{ {
case TypeId.Unit: case TypeId.Unit:
{
// non fly unit don't must be in air
// non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast
if (!ToCreature().CanFly())
{ {
// non fly unit don't must be in air bool canSwim = ToCreature().CanSwim();
// non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast float ground_z = z;
if (!ToCreature().CanFly()) float max_z = canSwim
? GetMapWaterOrGroundLevel(x, y, z, ref ground_z)
: (ground_z = GetMapHeight(x, y, z));
if (max_z > MapConst.InvalidHeight)
{ {
bool canSwim = ToCreature().CanSwim(); if (z > max_z)
float ground_z = z; z = max_z;
float max_z = canSwim else if (z < ground_z)
? GetMapWaterOrGroundLevel(x, y, z, ref ground_z)
: (ground_z = GetMapHeight(x, y, z));
if (max_z > MapConst.InvalidHeight)
{
if (z > max_z)
z = max_z;
else if (z < ground_z)
z = ground_z;
}
}
else
{
float ground_z = GetMapHeight(x, y, z);
if (z < ground_z)
z = ground_z; z = ground_z;
} }
break;
} }
case TypeId.Player: else
{
// for server controlled moves playr work same as creature (but it can always swim)
if (!ToPlayer().CanFly())
{
float ground_z = z;
float max_z = GetMapWaterOrGroundLevel(x, y, z, ref ground_z);
if (max_z > MapConst.InvalidHeight)
{
if (z > max_z)
z = max_z;
else if (z < ground_z)
z = ground_z;
}
}
else
{
float ground_z = GetMapHeight(x, y, z);
if (z < ground_z)
z = ground_z;
}
break;
}
default:
{ {
float ground_z = GetMapHeight(x, y, z); float ground_z = GetMapHeight(x, y, z);
if (ground_z > MapConst.InvalidHeight) if (MathF.Abs(z - ground_z) < GetCollisionHeight())
z = ground_z; z = ground_z;
break;
} }
break;
}
case TypeId.Player:
{
// for server controlled moves playr work same as creature (but it can always swim)
if (!ToPlayer().CanFly())
{
float ground_z = z;
float max_z = GetMapWaterOrGroundLevel(x, y, z, ref ground_z);
if (max_z > MapConst.InvalidHeight)
{
if (z > max_z)
z = max_z;
else if (z < ground_z)
z = ground_z;
}
}
else
{
float ground_z = GetMapHeight(x, y, z);
if (MathF.Abs(z - ground_z) < GetCollisionHeight())
z = ground_z;
}
break;
}
default:
{
float ground_z = GetMapHeight(x, y, z);
if (ground_z > MapConst.InvalidHeight)
z = ground_z;
break;
}
} }
} }
@@ -2390,7 +2390,7 @@ namespace Game.Entities
Transport m_transport; Transport m_transport;
Map _currMap; Map _currMap;
uint instanceId; uint instanceId;
PhaseShift _phaseShift= new(); PhaseShift _phaseShift = new();
PhaseShift _suppressedPhaseShift = new(); // contains phases for current area but not applied due to conditions PhaseShift _suppressedPhaseShift = new(); // contains phases for current area but not applied due to conditions
int _dbPhase; int _dbPhase;
public bool IsInWorld { get; set; } public bool IsInWorld { get; set; }
@@ -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
+1005 -978
View File
File diff suppressed because it is too large Load Diff
-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);
} }