mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Entities: implement IsInAir
This commit is contained in:
@@ -2663,10 +2663,7 @@ void Creature::UpdateMovementFlags()
|
||||
return;
|
||||
|
||||
// Set the movement flags if the creature is in that mode. (Only fly if actually in air, only swim if in water, etc)
|
||||
float ground = GetFloorZ();
|
||||
|
||||
bool canHover = CanHover();
|
||||
bool isInAir = (G3D::fuzzyGt(GetPositionZ(), ground + (canHover ? GetFloatValue(UNIT_FIELD_HOVERHEIGHT) : 0.0f) + GROUND_HEIGHT_TOLERANCE) || G3D::fuzzyLt(GetPositionZ(), ground - GROUND_HEIGHT_TOLERANCE)); // Can be underground too, prevent the falling
|
||||
bool isInAir = IsInAir(*this, GetFloorZ() + GROUND_HEIGHT_TOLERANCE) || IsInAir(*this, GetFloorZ() - GROUND_HEIGHT_TOLERANCE);
|
||||
|
||||
if (GetMovementTemplate().IsFlightAllowed() && isInAir && !IsFalling())
|
||||
{
|
||||
|
||||
@@ -3164,6 +3164,11 @@ bool Unit::IsUnderWater() const
|
||||
return GetLiquidStatus() & LIQUID_MAP_UNDER_WATER;
|
||||
}
|
||||
|
||||
bool Unit::IsInAir(Position const destination, float destinationFloor, bool honorHover/* = true*/) const
|
||||
{
|
||||
return std::fabs(destination.GetPositionZ() - (honorHover ? GetHoverOffset() : 0.f) - destinationFloor) > 0.1f;
|
||||
}
|
||||
|
||||
void Unit::ProcessPositionDataChanged(PositionFullTerrainStatus const& data)
|
||||
{
|
||||
ZLiquidStatus oldLiquidStatus = GetLiquidStatus();
|
||||
|
||||
@@ -1171,6 +1171,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
|
||||
bool IsInWater() const;
|
||||
bool IsUnderWater() const;
|
||||
bool IsInAir(Position const destination, float destinationFloor, bool honorHover = true) const;
|
||||
bool isInAccessiblePlaceFor(Creature const* c) const;
|
||||
|
||||
void SendHealSpellLog(HealInfo& healInfo, bool critical = false);
|
||||
|
||||
Reference in New Issue
Block a user