Core/Units: prevent units from dropping under map surfaces when disabling hover movement

This commit is contained in:
Ovahlord
2020-10-01 17:00:51 +02:00
parent e04389e539
commit 40afd8a20e

View File

@@ -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<float>(GetFloorZ(), GetPositionZ() - hoverHeight);
UpdateAllowedPositionZ(GetPositionX(), GetPositionY(), newZ);
UpdateHeight(newZ);
}