diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index ff035f7d3e7..14d0106171b 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1663,28 +1663,33 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const if (Unit const* unit = ToUnit()) { - // Unit is flying, ignore. - if (unit->IsFlying()) - return; - - bool canSwim = unit->CanSwim(); - float ground_z = z; - float max_z; - if (canSwim) - max_z = GetMapWaterOrGroundLevel(x, y, z, &ground_z); - else - max_z = ground_z = GetMapHeight(x, y, z); - - if (max_z > INVALID_HEIGHT) + if (!unit->CanFly()) { - // hovering units cannot go below their hover height - float hoverOffset = unit->GetHoverOffset(); - max_z += hoverOffset; - ground_z += hoverOffset; + bool canSwim = unit->CanSwim(); + float ground_z = z; + float max_z; + if (canSwim) + max_z = GetMapWaterOrGroundLevel(x, y, z, &ground_z); + else + max_z = ground_z = GetMapHeight(x, y, z); - if (z > max_z && !unit->CanFly()) - z = max_z; - else if (z < ground_z) + if (max_z > INVALID_HEIGHT) + { + // hovering units cannot go below their hover height + float hoverOffset = unit->GetHoverOffset(); + max_z += hoverOffset; + ground_z += hoverOffset; + + if (z > max_z) + z = max_z; + else if (z < ground_z) + z = ground_z; + } + } + else + { + float ground_z = GetMapHeight(x, y, z) + unit->GetHoverOffset(); + if (z < ground_z) z = ground_z; } }