Core/Creatures: improved movement flag updating for creatures by taking db values more serious
This commit is contained in:
1 parent
ee4807ce28
commit
217299beed
3 files changed
+23
-13
No files matched your search
@@ -3011,26 +3011,33 @@ void Creature::UpdateMovementFlags()
|
||||
|
||||
// Set the movement flags if the creature is in that mode. (Only fly if actually in air, only swim if in water, etc)
|
||||
float ground = GetFloorZ();
|
||||
bool isInAir = (G3D::fuzzyGt(GetPositionZ(), ground + (IsHovering() ? GetFloatValue(UNIT_FIELD_HOVERHEIGHT) : 0.0f) + GROUND_HEIGHT_TOLERANCE) || G3D::fuzzyLt(GetPositionZ(), ground - GROUND_HEIGHT_TOLERANCE)); // Can be underground too, prevent the falling
|
||||
|
||||
bool canHover = CanHover();
|
||||
bool isInAir = (G3D::fuzzyGt(GetPositionZ(), ground + (canHover ? GetFloatValue(UNIT_FIELD_HOVERHEIGHT) : 0.0f) + GROUND_HEIGHT_TOLERANCE) || G3D::fuzzyLt(GetPositionZ(), ground - GROUND_HEIGHT_TOLERANCE)); // Can be underground too, prevent the falling
|
||||
|
||||
// Creature has a flight state enabled in db
|
||||
if (GetMovementTemplate().IsFlightAllowed() && isInAir && !IsFalling())
|
||||
{
|
||||
if (GetMovementTemplate().Flight == CreatureFlightMovementType::CanFly)
|
||||
SetCanFly(true);
|
||||
else
|
||||
SetDisableGravity(true, false, false);
|
||||
if (GetMovementTemplate().IsGravityDisabled())
|
||||
SetDisableGravity(true);
|
||||
|
||||
if (!HasAuraType(SPELL_AURA_HOVER))
|
||||
SetHover(false);
|
||||
if (GetMovementTemplate().CanFly())
|
||||
SetCanFly(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// @todo: this interferes with scripted flight movement so let's reevaluate if we want to stick with CREATURE_FLAG_EXTRA_NO_MOVE_FLAGS_UPDATE to avoid that or if we want to drop that all together.
|
||||
SetCanFly(false);
|
||||
SetDisableGravity(false, false, false);
|
||||
if ((IsAlive() && CanHover()) || HasAuraType(SPELL_AURA_HOVER))
|
||||
SetHover(true, false, false);
|
||||
SetDisableGravity(false);
|
||||
}
|
||||
|
||||
// Creature has a special ground state enabled in db or has a movement hover aura applied
|
||||
if (GetMovementTemplate().IsGroundAllowed())
|
||||
{
|
||||
// Hovering always requires the creature to be alive to avoid visual issues
|
||||
// @todo: sniffed spawn locations have applied hover offsets to the position z value so either substract them when parsing sniffs or skip the initial relocation from Unit::SetHover
|
||||
if (IsAlive() && (GetMovementTemplate().IsHoverEnabled() || HasAuraType(SPELL_AURA_HOVER)))
|
||||
SetHover(true);
|
||||
else
|
||||
SetHover(false);
|
||||
}
|
||||
|
||||
if (!isInAir)
|
||||
|
||||
@@ -98,7 +98,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
bool CanSwim() const override;
|
||||
bool CanEnterWater() const override;
|
||||
bool CanFly() const override { return GetMovementTemplate().IsFlightAllowed() || IsFlying(); }
|
||||
bool CanHover() const { return GetMovementTemplate().Ground == CreatureGroundMovementType::Hover || IsHovering(); }
|
||||
bool CanHover() const { return GetMovementTemplate().IsHoverEnabled() || IsHovering(); }
|
||||
bool SetDisableGravity(bool disable, bool packetOnly = false, bool updateAnimationTier = true) override;
|
||||
bool SetHover(bool enable, bool packetOnly = false, bool updateAnimationTier = true) override;
|
||||
|
||||
|
||||
@@ -118,6 +118,9 @@ struct TC_GAME_API CreatureMovementData
|
||||
bool IsSwimAllowed() const { return Swim; }
|
||||
bool IsFlightAllowed() const { return Flight != CreatureFlightMovementType::None; }
|
||||
bool IsRooted() const { return Rooted; }
|
||||
bool IsGravityDisabled() const { return Flight == CreatureFlightMovementType::DisableGravity; }
|
||||
bool CanFly() const { return Flight == CreatureFlightMovementType::CanFly; }
|
||||
bool IsHoverEnabled() const { return Ground == CreatureGroundMovementType::Hover; }
|
||||
|
||||
CreatureRandomMovementType GetRandom() const { return Random; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user