aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp2
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp8
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
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);