Core/Spells: Implemented SPELL_ATTR9_ONLY_WHEN_ILLEGALLY_MOUNTED

Port From (https://github.com/TrinityCore/TrinityCore/commit/1f3af18e3a17096748a621c9171feb30047287be)
This commit is contained in:
Hondacrx
2024-08-25 21:42:05 -04:00
parent 5874294745
commit 1a0a69a4a1
2 changed files with 18 additions and 1 deletions
+17
View File
@@ -5148,6 +5148,23 @@ namespace Game.Spells
if (unitCaster.IsInCombat() && !m_spellInfo.CanBeUsedInCombat(unitCaster))
return SpellCastResult.AffectingCombat;
if (m_spellInfo.HasAttribute(SpellAttr9.OnlyWhenIllegallyMounted))
{
bool hasInvalidMountAura = unitCaster.GetAuraEffectsByType(AuraType.Mounted).Any(mountEffect =>
{
uint mountType = (uint)mountEffect.GetSpellEffectInfo().MiscValueB;
var mountEntry = Global.DB2Mgr.GetMount(mountEffect.GetId());
if (mountEntry != null)
mountType = mountEntry.MountTypeID;
var mountCapability = unitCaster.GetMountCapability(mountType);
return mountCapability == null || mountCapability.Id != mountEffect.GetAmount();
});
if (!hasInvalidMountAura)
return SpellCastResult.OnlyMounted;
}
}
// Check vehicle flags