From 40afd8a20e06acc7a8fcd4638f431cbd2b275959 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Thu, 1 Oct 2020 17:00:51 +0200 Subject: [PATCH] Core/Units: prevent units from dropping under map surfaces when disabling hover movement --- src/server/game/Entities/Unit/Unit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 3d18506bfdf..221bcefe47f 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -14155,7 +14155,7 @@ bool Unit::SetHover(bool enable, bool packetOnly /*= false*/, bool /*updateAnima { //! No need to check height on ascent AddUnitMovementFlag(MOVEMENTFLAG_HOVER); - if (hoverHeight) + if (hoverHeight && GetPositionZ() - GetFloorZ() < hoverHeight) UpdateHeight(GetPositionZ() + hoverHeight); } else @@ -14164,7 +14164,7 @@ bool Unit::SetHover(bool enable, bool packetOnly /*= false*/, bool /*updateAnima //! Dying creatures will MoveFall from setDeathState if (hoverHeight && (!isDying() || GetTypeId() != TYPEID_UNIT)) { - float newZ = GetPositionZ() - hoverHeight; + float newZ = std::max(GetFloorZ(), GetPositionZ() - hoverHeight); UpdateAllowedPositionZ(GetPositionX(), GetPositionY(), newZ); UpdateHeight(newZ); }