Core/Units: flight and hover checks will now consider movement template data as well as manually set flight states

- manually set flight states via auras and scripts will no longer be ignored
- restored movement template consideration when generating pathings
- renamed IsLevitating to IsGravityDisabled to reflect the referenced movement flag's name
This commit is contained in:
Ovah
2020-06-01 15:58:31 +02:00
committed by GitHub
parent 48c5c0d7a2
commit 43ef610fe0
5 changed files with 8 additions and 8 deletions

View File

@@ -98,8 +98,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(); }
bool CanHover() const { return GetMovementTemplate().Ground == CreatureGroundMovementType::Hover || IsHovering(); }
MovementGeneratorType GetDefaultMovementType() const override { return m_defaultMovementType; }
void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }

View File

@@ -13090,7 +13090,7 @@ bool Unit::SetWalk(bool enable)
bool Unit::SetDisableGravity(bool disable, bool /*packetOnly = false*/)
{
if (disable == IsLevitating())
if (disable == IsGravityDisabled())
return false;
if (disable)

View File

@@ -1118,7 +1118,7 @@ class TC_GAME_API Unit : public WorldObject
//void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = nullptr);
void SendMovementFlagUpdate(bool self = false);
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); }
virtual bool SetWalk(bool enable);

View File

@@ -178,7 +178,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)
@@ -232,7 +232,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: flying case");
if (Unit const* _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)

View File

@@ -2635,7 +2635,7 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode
if (target->SetCanFly(apply))
{
if (!apply && !target->IsLevitating())
if (!apply && !target->IsGravityDisabled())
target->GetMotionMaster()->MoveFall();
}
}
@@ -3023,7 +3023,7 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp,
if (mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK && (apply || (!target->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !target->HasAuraType(SPELL_AURA_FLY))))
{
if (target->SetCanFly(apply))
if (!apply && !target->IsLevitating())
if (!apply && !target->IsGravityDisabled())
target->GetMotionMaster()->MoveFall();
}