diff options
| author | ccrs <ccrs@users.noreply.github.com> | 2025-10-25 23:45:16 +0200 |
|---|---|---|
| committer | ccrs <ccrs@users.noreply.github.com> | 2025-10-25 23:45:16 +0200 |
| commit | c3d3fb1eb3abfe0a2d396e446486628059f3e62f (patch) | |
| tree | 9375ce4f44c8564df6653d65f63dd37a3a954077 /src | |
| parent | 00ddc355686e7d300f0cd2fcfd1a9b0c97aeb07f (diff) | |
Core/Entities: move IsInAir tolerances to a default parameter, and reduce it to 0.1
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 8 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 0824a95f3c2..a7d69ecaa74 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -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()) { diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 4d118525e77..ab168c7dddc 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -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) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index e028ace4720..3dceeeb1f76 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -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); |
