Core/Maps: implement LIQUID_MAP_OCEAN_FLOOR to identify units that are on the bottom of a liquid
Port From (https://github.com/TrinityCore/TrinityCore/commit/97af0c31af13de23eabe4eb22ed3e71dd5602531)
This commit is contained in:
@@ -121,6 +121,7 @@ namespace Framework.Constants
|
||||
WaterWalk = 0x02,
|
||||
InWater = 0x04,
|
||||
UnderWater = 0x08,
|
||||
OceanFloor = 0x10,
|
||||
|
||||
Swimming = InWater | UnderWater,
|
||||
InContact = Swimming | WaterWalk
|
||||
|
||||
@@ -21,21 +21,31 @@ namespace Game.Entities
|
||||
{
|
||||
return m_movementInfo.HasMovementFlag(MovementFlag.DisableGravity);
|
||||
}
|
||||
|
||||
public bool IsWalking()
|
||||
{
|
||||
return m_movementInfo.HasMovementFlag(MovementFlag.Walking);
|
||||
}
|
||||
|
||||
public bool IsHovering() { return m_movementInfo.HasMovementFlag(MovementFlag.Hover); }
|
||||
|
||||
public bool IsStopped() { return !HasUnitState(UnitState.Moving); }
|
||||
|
||||
public bool IsMoving() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskMoving); }
|
||||
|
||||
public bool IsTurning() { return m_movementInfo.HasMovementFlag(MovementFlag.MaskTurning); }
|
||||
|
||||
public virtual bool CanFly() { return false; }
|
||||
|
||||
public bool IsFlying() { return m_movementInfo.HasMovementFlag(MovementFlag.Flying | MovementFlag.DisableGravity); }
|
||||
|
||||
public bool IsFalling()
|
||||
{
|
||||
return m_movementInfo.HasMovementFlag(MovementFlag.Falling | MovementFlag.FallingFar) || MoveSpline.IsFalling();
|
||||
}
|
||||
|
||||
public virtual bool CanEnterWater() { return false; }
|
||||
|
||||
public virtual bool CanSwim()
|
||||
{
|
||||
// Mirror client behavior, if this method returns false then client will not use swimming animation and for players will apply gravity as if there was no water
|
||||
@@ -50,15 +60,22 @@ namespace Game.Entities
|
||||
|
||||
return HasUnitFlag(UnitFlags.Rename | UnitFlags.CanSwim);
|
||||
}
|
||||
|
||||
public bool IsInWater()
|
||||
{
|
||||
return GetLiquidStatus().HasAnyFlag(ZLiquidStatus.InWater | ZLiquidStatus.UnderWater);
|
||||
}
|
||||
|
||||
public bool IsUnderWater()
|
||||
{
|
||||
return GetLiquidStatus().HasFlag(ZLiquidStatus.UnderWater);
|
||||
}
|
||||
|
||||
public bool IsOnOceanFloor()
|
||||
{
|
||||
return GetLiquidStatus().HasFlag(ZLiquidStatus.OceanFloor);
|
||||
}
|
||||
|
||||
void PropagateSpeedChange() { GetMotionMaster().PropagateSpeedChange(); }
|
||||
|
||||
public float GetSpeed(UnitMoveType mtype)
|
||||
|
||||
@@ -598,14 +598,20 @@ namespace Game.Maps
|
||||
// For speed check as int values
|
||||
float delta = liquid_level - z;
|
||||
|
||||
ZLiquidStatus status = ZLiquidStatus.AboveWater; // Above water
|
||||
|
||||
if (delta > collisionHeight) // Under water
|
||||
return ZLiquidStatus.UnderWater;
|
||||
status = ZLiquidStatus.UnderWater;
|
||||
if (delta > 0.0f) // In water
|
||||
return ZLiquidStatus.InWater;
|
||||
status = ZLiquidStatus.InWater;
|
||||
if (delta > -0.1f) // Walk on water
|
||||
return ZLiquidStatus.WaterWalk;
|
||||
// Above water
|
||||
return ZLiquidStatus.AboveWater;
|
||||
status = ZLiquidStatus.WaterWalk;
|
||||
|
||||
if (status != ZLiquidStatus.AboveWater)
|
||||
if (MathF.Abs(ground_level - z) <= MapConst.GroundHeightTolerance)
|
||||
status |= ZLiquidStatus.OceanFloor;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public float GetHeight(float x, float y) { return _gridGetHeight(x, y); }
|
||||
|
||||
@@ -551,14 +551,19 @@ namespace Game.Maps
|
||||
data.LiquidInfo.type_flags = (LiquidHeaderTypeFlags)(1 << (int)liquidFlagType);
|
||||
|
||||
float delta = wmoData.liquidInfo.Value.Level - z;
|
||||
ZLiquidStatus status = ZLiquidStatus.AboveWater;
|
||||
if (delta > collisionHeight)
|
||||
data.LiquidStatus = ZLiquidStatus.UnderWater;
|
||||
status = ZLiquidStatus.UnderWater;
|
||||
else if (delta > 0.0f)
|
||||
data.LiquidStatus = ZLiquidStatus.InWater;
|
||||
status = ZLiquidStatus.InWater;
|
||||
else if (delta > -0.1f)
|
||||
data.LiquidStatus = ZLiquidStatus.WaterWalk;
|
||||
else
|
||||
data.LiquidStatus = ZLiquidStatus.AboveWater;
|
||||
status = ZLiquidStatus.WaterWalk;
|
||||
|
||||
if (status != ZLiquidStatus.AboveWater)
|
||||
if (MathF.Abs(wmoData.floorZ - z) <= MapConst.GroundHeightTolerance)
|
||||
status |= ZLiquidStatus.OceanFloor;
|
||||
|
||||
data.LiquidStatus = status;
|
||||
}
|
||||
// look up liquid data from grid map
|
||||
if (gmap != null && useGridLiquid)
|
||||
@@ -636,13 +641,23 @@ namespace Game.Maps
|
||||
|
||||
float delta = liquid_level - z;
|
||||
|
||||
// Get position delta
|
||||
ZLiquidStatus status = ZLiquidStatus.AboveWater; // Above water
|
||||
|
||||
if (delta > collisionHeight) // Under water
|
||||
return ZLiquidStatus.UnderWater;
|
||||
status = ZLiquidStatus.UnderWater;
|
||||
if (delta > 0.0f) // In water
|
||||
return ZLiquidStatus.InWater;
|
||||
status = ZLiquidStatus.InWater;
|
||||
if (delta > -0.1f) // Walk on water
|
||||
return ZLiquidStatus.WaterWalk;
|
||||
status = ZLiquidStatus.WaterWalk;
|
||||
|
||||
if (status != ZLiquidStatus.AboveWater)
|
||||
{
|
||||
if (MathF.Abs(ground_level - z) <= MapConst.GroundHeightTolerance)
|
||||
status |= ZLiquidStatus.OceanFloor;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
result = ZLiquidStatus.AboveWater;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user