From 812d98f5b50532d67ad3909b7f66294ee7b8e73b Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 1 Jun 2022 15:40:38 -0400 Subject: [PATCH] Core/Spells: Implemented SPELL_ATTR5_NOT_AVAILABLE_WHILE_CHARMED Port From (https://github.com/TrinityCore/TrinityCore/commit/076c63c766d10697cea17da8bd5194862a682cbe) --- Source/Framework/Constants/Spells/SpellConst.cs | 2 +- Source/Game/Entities/Player/Player.cs | 3 +++ Source/Game/Entities/Unit/CharmInfo.cs | 6 ++++++ Source/Game/Spells/Spell.cs | 7 +++++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index 262f19a33..1e05872c8 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -1771,7 +1771,7 @@ namespace Framework.Constants ImpliedTargeting = 0x800, // Implied Targeting (Client Only) MeleeChainTargeting = 0x1000, // Melee Chain Targeting SpellHasteAffectsPeriodic = 0x2000, // Spell Haste Affects Periodic - NotAvailableWhileCharmed = 0x4000, /*Nyi*/ // Not Available While Charmed + NotAvailableWhileCharmed = 0x4000, // Not Available While Charmed TreatAsAreaEffect = 0x8000, /*Nyi*/ // Treat As Area Effect AuraAffectsNotJustReqEquippedItem = 0x10000, // Aura Affects Not Just Req. Equipped Item AllowWhileFleeing = 0x20000, // Allow While Fleeing diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index ee2017fdc..881c79421 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -1096,6 +1096,9 @@ namespace Game.Entities if (spellInfo == null) continue; + if (spellInfo.HasAttribute(SpellAttr5.NotAvailableWhileCharmed)) + continue; + if (!Global.ConditionMgr.IsObjectMeetingVehicleSpellConditions(vehicle.GetEntry(), spellId, this, vehicle)) { Log.outDebug(LogFilter.Condition, "VehicleSpellInitialize: conditions not met for Vehicle entry {0} spell {1}", vehicle.ToCreature().GetEntry(), spellId); diff --git a/Source/Game/Entities/Unit/CharmInfo.cs b/Source/Game/Entities/Unit/CharmInfo.cs index 08c18dc22..20d978b56 100644 --- a/Source/Game/Entities/Unit/CharmInfo.cs +++ b/Source/Game/Entities/Unit/CharmInfo.cs @@ -110,6 +110,9 @@ namespace Game.Entities SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, _unit.GetMap().GetDifficultyID()); if (spellInfo != null) { + if (spellInfo.HasAttribute(SpellAttr5.NotAvailableWhileCharmed)) + continue; + if (spellInfo.IsPassive()) _unit.CastSpell(_unit, spellInfo.Id, new CastSpellExtraArgs(true)); else @@ -142,6 +145,9 @@ namespace Game.Entities continue; } + if (spellInfo.HasAttribute(SpellAttr5.NotAvailableWhileCharmed)) + continue; + if (spellInfo.IsPassive()) { _unit.CastSpell(_unit, spellInfo.Id, new CastSpellExtraArgs(true)); diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 1486eda2f..9c3001a84 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -4703,6 +4703,9 @@ namespace Game.Spells Unit unitCaster = m_caster.ToUnit(); if (unitCaster != null) { + if (m_spellInfo.HasAttribute(SpellAttr5.NotAvailableWhileCharmed) && unitCaster.IsCharmed()) + return SpellCastResult.Charmed; + // only check at first call, Stealth auras are already removed at second call // for now, ignore triggered spells if (strict && !_triggeredCastFlags.HasFlag(TriggerCastFlags.IgnoreShapeshift)) @@ -5659,7 +5662,7 @@ namespace Game.Spells return SpellCastResult.NoPet; if (!pet.GetCharmerGUID().IsEmpty()) - return SpellCastResult.Charmed; + return SpellCastResult.AlreadyHaveCharm; break; } case AuraType.ModPossess: @@ -5671,7 +5674,7 @@ namespace Game.Spells return SpellCastResult.BadTargets; if (!unitCaster1.GetCharmerGUID().IsEmpty()) - return SpellCastResult.Charmed; + return SpellCastResult.AlreadyHaveCharm; if (spellEffectInfo.ApplyAuraName == AuraType.ModCharm || spellEffectInfo.ApplyAuraName == AuraType.ModPossess) {