From 09ef904fa6348528fcc272861f430b6ba1d529ec Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 5 Jan 2022 17:47:29 -0500 Subject: [PATCH] Core/GameObjects: Skip LoS checks for traps Port From (https://github.com/TrinityCore/TrinityCore/commit/9bede687ce3d291c8af8f4deb3f1dcebba1a315d) --- Source/Game/Entities/GameObject/GameObject.cs | 15 +++++++++++++++ Source/Scripts/Spells/Generic.cs | 14 +++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Source/Game/Entities/GameObject/GameObject.cs b/Source/Game/Entities/GameObject/GameObject.cs index e5b1a1426..6006ca600 100644 --- a/Source/Game/Entities/GameObject/GameObject.cs +++ b/Source/Game/Entities/GameObject/GameObject.cs @@ -2999,6 +2999,21 @@ namespace Game.Entities if (owner != null) return owner.GetLevelForTarget(target); + if (GetGoType() == GameObjectTypes.Trap) + { + Player player = target.ToPlayer(); + if (player != null) + { + var userLevels = Global.DB2Mgr.GetContentTuningData(GetGoInfo().ContentTuningId, player.m_playerData.CtrOptions.GetValue().ContentTuningConditionMask); + if (userLevels.HasValue) + return (byte)Math.Clamp(player.GetLevel(), userLevels.Value.MinLevel, userLevels.Value.MaxLevel); + } + + Unit targetUnit = target.ToUnit(); + if (targetUnit != null) + return targetUnit.GetLevel(); + } + return 1; } diff --git a/Source/Scripts/Spells/Generic.cs b/Source/Scripts/Spells/Generic.cs index 0580cb081..3a9cc1f46 100644 --- a/Source/Scripts/Spells/Generic.cs +++ b/Source/Scripts/Spells/Generic.cs @@ -2503,20 +2503,20 @@ namespace Scripts.Spells.Generic { PreventDefaultAction(); - Unit caster = GetCaster(); - if (caster == null) + Unit target = GetTarget(); + if (target == null) return; - uint heal = (uint)caster.CountPctFromMaxHealth(10); - HealInfo healInfo = new(caster, GetTarget(), heal, GetSpellInfo(), GetSpellInfo().GetSchoolMask()); - caster.HealBySpell(healInfo); + uint heal = (uint)target.CountPctFromMaxHealth(10); + HealInfo healInfo = new(target, target, heal, GetSpellInfo(), GetSpellInfo().GetSchoolMask()); + target.HealBySpell(healInfo); /// @todo: should proc other auras? - int mana = caster.GetMaxPower(PowerType.Mana); + int mana = target.GetMaxPower(PowerType.Mana); if (mana != 0) { mana /= 10; - caster.EnergizeBySpell(caster, GetSpellInfo(), mana, PowerType.Mana); + target.EnergizeBySpell(target, GetSpellInfo(), mana, PowerType.Mana); } }