Core/Movement: ported mount capability updating from master branch and replaced old implementation with it
This commit is contained in:
1 parent
3d8762297c
commit
0a7dfc15e2
7 files changed
+94
-92
No files matched your search
@@ -3219,7 +3219,7 @@ void Unit::ProcessPositionDataChanged(PositionFullTerrainStatus const& data)
|
||||
|
||||
void Unit::ProcessTerrainStatusUpdate(ZLiquidStatus status, Optional<LiquidData> const& liquidData)
|
||||
{
|
||||
if (IsFlying() || (!IsControlledByPlayer()))
|
||||
if (!IsControlledByPlayer())
|
||||
return;
|
||||
|
||||
// remove appropriate auras if we are swimming/not swimming respectively
|
||||
@@ -3243,6 +3243,9 @@ void Unit::ProcessTerrainStatusUpdate(ZLiquidStatus status, Optional<LiquidData>
|
||||
|
||||
if (curLiquid && curLiquid->SpellID && (!player || !player->IsGameMaster()))
|
||||
CastSpell(this, curLiquid->SpellID, true);
|
||||
|
||||
// mount capability depends on liquid state change
|
||||
UpdateMountCapability();
|
||||
}
|
||||
}
|
||||
void Unit::DeMorph()
|
||||
@@ -8290,7 +8293,7 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const
|
||||
uint32 areaId = GetAreaId();
|
||||
uint32 ridingSkill = 5000;
|
||||
uint32 mountFlags = 0;
|
||||
bool isUnderwater = false;
|
||||
bool isSubmerged = false;
|
||||
bool isInWater = false;
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -8305,7 +8308,7 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const
|
||||
mountFlags = areaTable->MountFlags;
|
||||
|
||||
ZLiquidStatus liquidStatus = GetLiquidStatus();
|
||||
isUnderwater = (liquidStatus & LIQUID_MAP_UNDER_WATER) != 0;
|
||||
isSubmerged = (liquidStatus & LIQUID_MAP_UNDER_WATER) != 0 || HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
|
||||
isInWater = (liquidStatus & LIQUID_MAP_IN_WATER) != 0;
|
||||
|
||||
for (uint32 i = MAX_MOUNT_CAPABILITIES; i > 0; --i)
|
||||
@@ -8329,16 +8332,24 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const
|
||||
continue;
|
||||
}
|
||||
|
||||
// Do not allow underwater restricted capabilities when not underwater
|
||||
if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_UNDERWATER) && isUnderwater)
|
||||
continue;
|
||||
|
||||
// Do not allow water surface restricted capabilities when not on water surface
|
||||
if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_FLOAT) && isInWater)
|
||||
continue;
|
||||
|
||||
// Do not allow liquid restricted mounts on ground or in air
|
||||
if (!(mountCapability->Flags & (MOUNT_CAPABILITY_FLAG_GROUND | MOUNT_CAPABILITY_FLAG_FLYING)) && !isUnderwater && !isInWater)
|
||||
if (!isSubmerged)
|
||||
{
|
||||
if (!isInWater)
|
||||
{
|
||||
// player is completely out of water
|
||||
if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_GROUND))
|
||||
continue;
|
||||
}
|
||||
else if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_UNDERWATER))
|
||||
continue;
|
||||
}
|
||||
else if (isInWater)
|
||||
{
|
||||
if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_UNDERWATER))
|
||||
continue;
|
||||
}
|
||||
else if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_FLOAT))
|
||||
continue;
|
||||
|
||||
if (mountCapability->ReqMapID != -1 &&
|
||||
@@ -8361,6 +8372,20 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Unit::UpdateMountCapability()
|
||||
{
|
||||
AuraEffectList mounts = GetAuraEffectsByType(SPELL_AURA_MOUNTED);
|
||||
for (AuraEffect* aurEff : mounts)
|
||||
{
|
||||
aurEff->RecalculateAmount();
|
||||
if (!aurEff->GetAmount())
|
||||
aurEff->GetBase()->Remove();
|
||||
else if (MountCapabilityEntry const* capability = sMountCapabilityStore.LookupEntry(aurEff->GetAmount())) // aura may get removed by interrupt flag, reapply
|
||||
if (!HasAura(capability->ModSpellAuraID))
|
||||
CastSpell(this, capability->ModSpellAuraID, aurEff);
|
||||
}
|
||||
}
|
||||
|
||||
bool Unit::IsServiceProvider() const
|
||||
{
|
||||
return HasFlag(UNIT_NPC_FLAGS,
|
||||
@@ -14259,10 +14284,12 @@ bool Unit::SetCanFly(bool enable, bool packetOnly)
|
||||
player->SendMovementSetCanTransitionBetweenSwimAndFly(enable);
|
||||
}
|
||||
|
||||
if (enable)
|
||||
Movement::PacketSender(this, SMSG_SPLINE_MOVE_SET_FLYING, SMSG_MOVE_SET_CAN_FLY).Send();
|
||||
else
|
||||
Movement::PacketSender(this, SMSG_SPLINE_MOVE_UNSET_FLYING, SMSG_MOVE_UNSET_CAN_FLY).Send();
|
||||
if (IsCreature())
|
||||
{
|
||||
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_FLYING : SMSG_SPLINE_MOVE_UNSET_FLYING);
|
||||
WriteMovementInfo(data);
|
||||
SendMessageToSet(&data, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user