From 7edcdb6ea2be9238468a2b1d37627706fc10d741 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 13 Nov 2017 13:12:07 -0500 Subject: [PATCH] workaround stealth interaction with Death and Decay and GameObject casts --- Source/Game/Entities/Unit/Unit.Combat.cs | 3 ++- Source/Game/Spells/Spell.cs | 22 +++++++++++++++------- Source/Game/Spells/SpellManager.cs | 6 +++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Source/Game/Entities/Unit/Unit.Combat.cs b/Source/Game/Entities/Unit/Unit.Combat.cs index 26f320bf3..a36e46a81 100644 --- a/Source/Game/Entities/Unit/Unit.Combat.cs +++ b/Source/Game/Entities/Unit/Unit.Combat.cs @@ -2916,7 +2916,8 @@ namespace Game.Entities return false; // can't attack invisible (ignore stealth for aoe spells) also if the area being looked at is from a spell use the dynamic object created instead of the casting unit. Ignore stealth if target is player and unit in combat with same player - if ((bySpell == null || !bySpell.HasAttribute(SpellAttr6.CanTargetInvisible)) && (obj ? !obj.CanSeeOrDetect(target, bySpell != null && bySpell.IsAffectingArea(GetMap().GetDifficultyID())) : !CanSeeOrDetect(target, (bySpell != null && bySpell.IsAffectingArea(GetMap().GetDifficultyID())) || (target.IsTypeId(TypeId.Player) && target.HasStealthAura() && target.IsInCombat() && IsInCombatWith(target))))) + // skip visibility check for GO casts, needs removal when go cast is implemented + if (GetEntry() != SharedConst.WorldTrigger && (bySpell == null || !bySpell.HasAttribute(SpellAttr6.CanTargetInvisible)) && (obj ? !obj.CanSeeOrDetect(target, bySpell != null && bySpell.IsAffectingArea(GetMap().GetDifficultyID())) : !CanSeeOrDetect(target, (bySpell != null && bySpell.IsAffectingArea(GetMap().GetDifficultyID())) || (target.GetTypeId() == TypeId.Player && target.HasStealthAura() && target.IsInCombat() && IsInCombatWith(target))))) return false; // can't attack dead diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 10804702e..140a0a9f6 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -1549,13 +1549,17 @@ namespace Game.Spells m_hitMask = ProcFlagsHit.None; // Hunter trap spells - activation proc for Lock and Load, Entrapment and Misdirection - if (m_spellInfo.SpellFamilyName == SpellFamilyNames.Hunter && - (m_spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x18u) || // Freezing and Frost Trap, Freezing Arrow - m_spellInfo.Id == 57879 || // Snake Trap - done this way to avoid double proc + if (m_spellInfo.SpellFamilyName == SpellFamilyNames.Hunter && (m_spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x18u) || // Freezing and Frost Trap, Freezing Arrow + m_spellInfo.Id == 57879 || // Snake Trap - done this way to avoid double proc m_spellInfo.SpellFamilyFlags[2].HasAnyFlag(0x00024000u))) // Explosive and Immolation Trap - + { m_procAttacker |= ProcFlags.DoneTrapActivation; + // also fill up other flags (DoAllEffectOnTarget only fills up flag if both are not set) + m_procAttacker |= ProcFlags.DoneSpellMagicDmgClassNeg; + m_procVictim |= ProcFlags.TakenSpellMagicDmgClassNeg; + } + // Hellfire Effect - trigger as DOT if (m_spellInfo.SpellFamilyName == SpellFamilyNames.Warlock && m_spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00000040u)) { @@ -1586,7 +1590,7 @@ namespace Game.Spells return; if (checkIfValid) - if (m_spellInfo.CheckTarget(m_caster, target, Implicit) != SpellCastResult.SpellCastOk) + if (m_spellInfo.CheckTarget(m_caster, target, Implicit || m_caster.GetEntry() == SharedConst.WorldTrigger) != SpellCastResult.SpellCastOk) // skip stealth checks for GO casts return; // Check for effect immune skip if immuned @@ -4485,7 +4489,11 @@ namespace Game.Spells if (!(m_spellInfo.IsPassive() && (m_targets.GetUnitTarget() == null || m_targets.GetUnitTarget() == m_caster))) { // Check explicit target for m_originalCaster - todo: get rid of such workarounds - castResult = m_spellInfo.CheckExplicitTarget(m_originalCaster ?? m_caster, m_targets.GetObjectTarget(), m_targets.GetItemTarget()); + Unit caster = m_caster; + if (m_originalCaster && m_caster.GetEntry() != SharedConst.WorldTrigger) // Do a simplified check for gameobject casts + caster = m_originalCaster; + + castResult = m_spellInfo.CheckExplicitTarget(caster, m_targets.GetObjectTarget(), m_targets.GetItemTarget()); if (castResult != SpellCastResult.SpellCastOk) return castResult; } @@ -4493,7 +4501,7 @@ namespace Game.Spells Unit unitTarget = m_targets.GetUnitTarget(); if (unitTarget != null) { - castResult = m_spellInfo.CheckTarget(m_caster, unitTarget, false); + castResult = m_spellInfo.CheckTarget(m_caster, unitTarget, m_caster.GetEntry() == SharedConst.WorldTrigger); // skip stealth checks for GO casts if (castResult != SpellCastResult.SpellCastOk) return castResult; diff --git a/Source/Game/Spells/SpellManager.cs b/Source/Game/Spells/SpellManager.cs index 70b8a58d9..760858102 100644 --- a/Source/Game/Spells/SpellManager.cs +++ b/Source/Game/Spells/SpellManager.cs @@ -2330,6 +2330,9 @@ namespace Game.Entities case 44544: // Fingers of Frost spellInfo.GetEffect(0).SpellClassMask = new FlagArray128(685904631, 1151048, 0, 0); break; + case 52212: // Death and Decay + spellInfo.AttributesEx6 |= SpellAttr6.CanTargetInvisible; + break; case 37408: // Oscillation Field spellInfo.AttributesEx3 |= SpellAttr3.StackForDiffCasters; break; @@ -2839,13 +2842,14 @@ namespace Game.Entities switch (type) { case AuraType.OverrideClassScripts: + case AuraType.ModStealth: + case AuraType.ModConfuse: case AuraType.ModFear: case AuraType.ModRoot: case AuraType.ModStun: case AuraType.Transform: case AuraType.SpellMagnet: case AuraType.SchoolAbsorb: - case AuraType.ModStealth: case AuraType.ModRoot2: return true; }