Core/Units: CanFly and CanHover will now return positive results when the creature has the according movement flags dispite not having the template movement field set as enabled. This fixes several edge cases with manually enabled flight movement

* renamed IsLevitating to IsGravityDisabled for consistency
This commit is contained in:
Ovahlord committed 2020-05-16 19:21:27 +02:00
1 parent 4a25282f51
commit 813b82efa3
5 files changed
+9 -9

No files matched your search

+2 -2
View File
@@ -94,8 +94,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
CreatureMovementData const& GetMovementTemplate() const;
bool CanWalk() const { return GetMovementTemplate().IsGroundAllowed(); }
bool CanSwim() const override { return GetMovementTemplate().IsSwimAllowed() || IsPet(); }
bool CanFly() const override { return GetMovementTemplate().IsFlightAllowed(); }
bool CanHover() const { return GetMovementTemplate().Ground == CreatureGroundMovementType::Hover; }
bool CanFly() const override { return GetMovementTemplate().IsFlightAllowed() || IsFlying() || IsGravityDisabled(); };
bool CanHover() const { return GetMovementTemplate().Ground == CreatureGroundMovementType::Hover || IsHovering(); };
bool IsDungeonBoss() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS) != 0; }
bool IsAffectedByDiminishingReturns() const override { return Unit::IsAffectedByDiminishingReturns() || (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH) != 0; }
+2 -2
View File
@@ -14377,7 +14377,7 @@ bool Unit::SetDisableGravity(bool disable, bool packetOnly /*= false*/)
{
if (!packetOnly)
{
if (disable == IsLevitating())
if (disable == IsGravityDisabled())
return false;
if (disable)
@@ -14454,7 +14454,7 @@ bool Unit::SetCanFly(bool enable, bool packetOnly)
}
else
{
if (IsFlying() && !IsLevitating())
if (IsFlying() && !IsGravityDisabled())
SetFall(true);
RemoveUnitMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_MASK_MOVING_FLY);
+1 -1
View File
@@ -1344,7 +1344,7 @@ class TC_GAME_API Unit : public WorldObject
void SendSetPlayHoverAnim(bool enable);
void SendMovementSetSplineAnim(Movement::AnimType anim);
bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); }
bool IsGravityDisabled() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); }
bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING); }
bool IsHovering() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_HOVER); }
bool SetWalk(bool enable);
+2 -2
View File
@@ -180,7 +180,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
{
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: (startPoly == 0 || endPoly == 0)");
BuildShortcut();
bool path = _source->GetTypeId() == TYPEID_UNIT && _source->ToCreature()->IsFlying();
bool path = _source->GetTypeId() == TYPEID_UNIT && _source->ToCreature()->CanFly();
bool waterPath = _source->GetTypeId() == TYPEID_UNIT && _source->ToCreature()->CanSwim();
if (waterPath)
@@ -234,7 +234,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: flying case");
if (const Unit* _sourceUnit = _source->ToUnit())
{
if (_sourceUnit->IsFlying())
if (_sourceUnit->CanFly())
buildShotrcut = true;
// Allow to build a shortcut if the unit is falling and it's trying to move downwards towards a target (i.e. charging)
else if (_sourceUnit->IsFalling() && endPos.z < startPos.z)
@@ -2737,7 +2737,7 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode
target->SetCanFly(apply);
if (!apply && target->GetTypeId() == TYPEID_UNIT && !target->IsLevitating())
if (!apply && target->GetTypeId() == TYPEID_UNIT && !target->IsGravityDisabled())
target->GetMotionMaster()->MoveFall();
}
@@ -3097,7 +3097,7 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp,
{
target->SetCanFly(apply);
if (!apply && target->GetTypeId() == TYPEID_UNIT && !target->IsLevitating())
if (!apply && target->GetTypeId() == TYPEID_UNIT && !target->IsGravityDisabled())
target->GetMotionMaster()->MoveFall();
}