From 1a0a69a4a19b92290df33d8e50fafe498ccfe246 Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Sun, 25 Aug 2024 21:42:05 -0400 Subject: [PATCH] Core/Spells: Implemented SPELL_ATTR9_ONLY_WHEN_ILLEGALLY_MOUNTED Port From (https://github.com/TrinityCore/TrinityCore/commit/1f3af18e3a17096748a621c9171feb30047287be) --- Source/Framework/Constants/Spells/SpellConst.cs | 2 +- Source/Game/Spells/Spell.cs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index cf6eddefd..82e67fb80 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -1968,7 +1968,7 @@ namespace Framework.Constants { ForceDestLocation = 0x01, // Force Dest Location DESCRIPTION Ignores collision with terrain (unsure if it also ignores terrain height and can go under map) ModInvisIncludesParty = 0x02, // Mod Invis Includes Party 1@Attr9 DESCRIPTION Causes invisibility auras to ignore "can always see party member invis" rule - RestrictedFlightArea = 0x04, // 2 + OnlyWhenIllegallyMounted = 0x04, // Only When Illegally Mounted Unk3 = 0x08, // 3 SpecialDelayCalculation = 0x10, // 4 SummonPlayerTotem = 0x20, // 5 diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 0e66ad9e8..cf4f571cc 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -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