Core/Auras: Updated mount capability check and implemented SPELL_AURA_MOUNT_RESTRICTIONS
This commit is contained in:
1 parent
3147aab824
commit
088ce63ac7
10 files changed
+92
-37
No files matched your search
@@ -8085,18 +8085,35 @@ void Unit::Dismount()
|
||||
MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const
|
||||
{
|
||||
if (!mountType)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
MountTypeEntry const* mountTypeEntry = sMountTypeStore.LookupEntry(mountType);
|
||||
if (!mountTypeEntry)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
uint32 zoneId, areaId;
|
||||
GetZoneAndAreaId(zoneId, areaId);
|
||||
|
||||
uint32 areaId = GetAreaId();
|
||||
uint32 ridingSkill = 5000;
|
||||
uint32 mountFlags = 0;
|
||||
bool isSubmerged = false;
|
||||
bool isInWater = false;
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
ridingSkill = ToPlayer()->GetSkillValue(SKILL_RIDING);
|
||||
|
||||
if (HasAuraType(SPELL_AURA_MOUNT_RESTRICTIONS))
|
||||
{
|
||||
for (AuraEffect const* auraEffect : GetAuraEffectsByType(SPELL_AURA_MOUNT_RESTRICTIONS))
|
||||
mountFlags |= auraEffect->GetMiscValue();
|
||||
}
|
||||
else if (AreaTableEntry const* areaTable = sAreaTableStore.LookupEntry(areaId))
|
||||
mountFlags = areaTable->MountFlags;
|
||||
|
||||
LiquidData liquid;
|
||||
ZLiquidStatus liquidStatus = GetMap()->GetLiquidStatus(GetPositionX(), GetPositionY(), GetPositionZ(), MAP_ALL_LIQUIDS, &liquid);
|
||||
isSubmerged = (liquidStatus & LIQUID_MAP_UNDER_WATER) != 0 || HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
|
||||
isInWater = (liquidStatus & (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER)) != 0;
|
||||
|
||||
for (uint32 i = MAX_MOUNT_CAPABILITIES; i > 0; --i)
|
||||
{
|
||||
MountCapabilityEntry const* mountCapability = sMountCapabilityStore.LookupEntry(mountTypeEntry->MountCapability[i - 1]);
|
||||
@@ -8106,38 +8123,55 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const
|
||||
if (ridingSkill < mountCapability->RequiredRidingSkill)
|
||||
continue;
|
||||
|
||||
if (HasExtraUnitMovementFlag(MOVEMENTFLAG2_FULL_SPEED_PITCHING))
|
||||
if (!(mountCapability->Flags & MOUNT_CAPABIILTY_FLAG_IGNORE_RESTRICTIONS))
|
||||
{
|
||||
if (!(mountCapability->Flags & MOUNT_FLAG_CAN_PITCH))
|
||||
if (mountCapability->Flags & MOUNT_CAPABILITY_FLAG_GROUND && !(mountFlags & AREA_MOUNT_FLAG_GROUND_ALLOWED))
|
||||
continue;
|
||||
}
|
||||
else if (HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING))
|
||||
{
|
||||
if (!(mountCapability->Flags & MOUNT_FLAG_CAN_SWIM))
|
||||
if (mountCapability->Flags & MOUNT_CAPABILITY_FLAG_FLYING && !(mountFlags & AREA_MOUNT_FLAG_FLYING_ALLOWED))
|
||||
continue;
|
||||
}
|
||||
else if (!(mountCapability->Flags & 0x1)) // unknown flags, checked in 4.2.2 14545 client
|
||||
{
|
||||
if (!(mountCapability->Flags & 0x2))
|
||||
if (mountCapability->Flags & MOUNT_CAPABILITY_FLAG_FLOAT && !(mountFlags & AREA_MOUNT_FLAG_FLOAT_ALLOWED))
|
||||
continue;
|
||||
if (mountCapability->Flags & MOUNT_CAPABILITY_FLAG_UNDERWATER && !(mountFlags & AREA_MOUNT_FLAG_UNDERWATER_ALLOWED))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mountCapability->RequiredMap != -1 && int32(GetMapId()) != mountCapability->RequiredMap)
|
||||
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->RequiredArea && (mountCapability->RequiredArea != zoneId && mountCapability->RequiredArea != areaId))
|
||||
if (mountCapability->RequiredMap != -1 &&
|
||||
int32(GetMapId()) != mountCapability->RequiredMap &&
|
||||
GetMap()->GetEntry()->rootPhaseMap != mountCapability->RequiredMap)
|
||||
continue;
|
||||
|
||||
if (mountCapability->RequiredArea && !IsInArea(areaId, mountCapability->RequiredArea))
|
||||
continue;
|
||||
|
||||
if (mountCapability->RequiredAura && !HasAura(mountCapability->RequiredAura))
|
||||
continue;
|
||||
|
||||
if (mountCapability->RequiredSpell && (GetTypeId() != TYPEID_PLAYER || !ToPlayer()->HasSpell(mountCapability->RequiredSpell)))
|
||||
if (mountCapability->RequiredSpell && !HasSpell(mountCapability->RequiredSpell))
|
||||
continue;
|
||||
|
||||
return mountCapability;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Unit::IsServiceProvider() const
|
||||
|
||||
Reference in new issue
Block a user