mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Entities: move IsInAir tolerances to a default parameter, and reduce it to 0.1
This commit is contained in:
@@ -2644,7 +2644,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)
|
||||
bool isInAir = IsInAir(*this, GetFloorZ() + GROUND_HEIGHT_TOLERANCE) || IsInAir(*this, GetFloorZ() - GROUND_HEIGHT_TOLERANCE);
|
||||
bool isInAir = IsInAir(*this, GetFloorZ());
|
||||
|
||||
if (GetMovementTemplate().IsFlightAllowed() && isInAir && !IsFalling())
|
||||
{
|
||||
|
||||
@@ -3164,19 +3164,19 @@ bool Unit::IsUnderWater() const
|
||||
return GetLiquidStatus() & LIQUID_MAP_UNDER_WATER;
|
||||
}
|
||||
|
||||
bool Unit::IsInAir(Position const destination, float destinationFloor, bool honorHover/* = true*/) const
|
||||
bool Unit::IsInAir(Position const destination, float destinationFloor, bool honorHover/* = true*/, float tolerance/* = 0.1f*/) const
|
||||
{
|
||||
float z = destination.GetPositionZ();
|
||||
if (z < destinationFloor - 0.5f) // if really bellow ground, in air (caves,...)
|
||||
if (z < destinationFloor - tolerance) // if really bellow ground, in air (caves,...)
|
||||
return true;
|
||||
float hoverHeight = GetHoverOffset(); // height if currently hovering
|
||||
if (GetTypeId() == TYPEID_UNIT) {
|
||||
hoverHeight = ToCreature()->CanHover() ? GetFloatValue(UNIT_FIELD_HOVERHEIGHT) : 0.f; // height if could hover
|
||||
}
|
||||
z = destination.GetPositionZ() - (honorHover ? hoverHeight : 0.f);
|
||||
if (z <= destinationFloor + 0.5f) // if is bellow ground or slightly above it, not in air - should hover too
|
||||
if (z <= destinationFloor + tolerance) // if is bellow ground or slightly above it, not in air - should hover too
|
||||
return false;
|
||||
return std::fabs(z - destinationFloor) > 0.5f; // if the difference is higher than tolerance level, in air (todo: this should most likely take into account unit's "size")
|
||||
return std::fabs(z - destinationFloor) > tolerance; // if the difference is higher than tolerance level, in air (todo: this should most likely take into account unit's "size")
|
||||
}
|
||||
|
||||
void Unit::ProcessPositionDataChanged(PositionFullTerrainStatus const& data)
|
||||
|
||||
@@ -1171,7 +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 IsInAir(Position const destination, float destinationFloor, bool honorHover = true, float tolerance = 0.1f) const;
|
||||
bool isInAccessiblePlaceFor(Creature const* c) const;
|
||||
|
||||
void SendHealSpellLog(HealInfo& healInfo, bool critical = false);
|
||||
|
||||
Reference in New Issue
Block a user