From b071efe10508617c1ace97c6005aa452a299f9ed Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 8 Sep 2021 23:35:22 -0400 Subject: [PATCH] Core/Spell: fix LoS checks for GameObject spells Port From (https://github.com/TrinityCore/TrinityCore/commit/50fe2dc7e305fa32d30bac6ad0ced2e5647ac02b) --- Source/Framework/Constants/Spells/SpellConst.cs | 2 +- Source/Game/Entities/GameObject/GameObjectData.cs | 13 +++++++++++++ Source/Game/Spells/Spell.cs | 6 ++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index 694420199..efbe63059 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -1464,7 +1464,7 @@ namespace Framework.Constants All = (Normal | Magic), } - [System.Flags] + [Flags] public enum SpellCastFlags : uint { None = 0x0, diff --git a/Source/Game/Entities/GameObject/GameObjectData.cs b/Source/Game/Entities/GameObject/GameObjectData.cs index cd6868326..68185b92d 100644 --- a/Source/Game/Entities/GameObject/GameObjectData.cs +++ b/Source/Game/Entities/GameObject/GameObjectData.cs @@ -275,6 +275,19 @@ namespace Game.Entities } } + public uint GetRequireLOS() => type switch + { + GameObjectTypes.Button => Button.requireLOS, + GameObjectTypes.QuestGiver => QuestGiver.requireLOS, + GameObjectTypes.Chest => Chest.requireLOS, + GameObjectTypes.Trap => Trap.requireLOS, + GameObjectTypes.Goober => Goober.requireLOS, + GameObjectTypes.FlagStand => FlagStand.requireLOS, + GameObjectTypes.NewFlag => NewFlag.requireLOS, + GameObjectTypes.GatheringNode => GatheringNode.requireLOS, + _ => 0, + }; + public uint GetLockId() { switch (type) diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index bb20424a6..37942aa5a 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -6557,6 +6557,12 @@ namespace Game.Spells if (m_spellInfo.HasAttribute(SpellAttr2.CanTargetNotInLos) || Global.DisableMgr.IsDisabledFor(DisableType.Spell, m_spellInfo.Id, null, (byte)DisableFlags.SpellLOS)) return true; + // check if gameobject ignores LOS + GameObject gobCaster = m_caster.ToGameObject(); + if (gobCaster != null) + if (!gobCaster.GetGoInfo().GetRequireLOS()) + return true; + // if spell is triggered, need to check for LOS disable on the aura triggering it and inherit that behaviour if (IsTriggered() && m_triggeredByAuraSpell != null && (m_triggeredByAuraSpell.HasAttribute(SpellAttr2.CanTargetNotInLos) || Global.DisableMgr.IsDisabledFor(DisableType.Spell, m_triggeredByAuraSpell.Id, null, (byte)DisableFlags.SpellLOS))) return true;