Core/Misc: don't allow players to use/activate/loot non-allowed gameobjects while under the effect of a damage immunity aura

Port From (https://github.com/TrinityCore/TrinityCore/commit/9d865f7536ae6feda6fba77785e4548f95ca5d03)
This commit is contained in:
hondacrx
2021-12-16 12:56:20 -05:00
parent 40f6c9a9fd
commit 736892998f
6 changed files with 57 additions and 2 deletions
+11
View File
@@ -2799,7 +2799,18 @@ namespace Game.Spells
}
if (apply)
{
target.AddUnitFlag(UnitFlags.Immune);
target.GetThreatManager().EvaluateSuppressed();
}
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit
if (target.HasAuraType(GetAuraType()))
return;
target.RemoveUnitFlag(UnitFlags.Immune);
}
}
[AuraEffectHandler(AuraType.DamageImmunity)]
+7
View File
@@ -4365,6 +4365,13 @@ namespace Game.Spells
if (m_caster.ToUnit() && !m_caster.ToUnit().IsAlive() && !m_spellInfo.IsPassive() && !(m_spellInfo.HasAttribute(SpellAttr0.CastableWhileDead) || (IsTriggered() && m_triggeredByAuraSpell == null)))
return SpellCastResult.CasterDead;
// Prevent cheating in case the player has an immunity effect and tries to interact with a non-allowed gameobject. The error message is handled by the client so we don't report anything here
if (m_caster.IsPlayer() && m_targets.GetGOTarget() != null)
{
if (m_targets.GetGOTarget().GetGoInfo().GetNoDamageImmune() != 0 && m_caster.ToUnit().HasUnitFlag(UnitFlags.Immune))
return SpellCastResult.DontReport;
}
// check cooldowns to prevent cheating
if (!m_spellInfo.IsPassive())
{
+4
View File
@@ -1324,6 +1324,10 @@ namespace Game.Spells
if (gameObjTarget != null)
{
GameObjectTemplate goInfo = gameObjTarget.GetGoInfo();
if (goInfo.GetNoDamageImmune() != 0 && player.HasUnitFlag(UnitFlags.Immune))
return;
// Arathi Basin banner opening. // @todo Verify correctness of this check
if ((goInfo.type == GameObjectTypes.Button && goInfo.Button.noDamageImmune != 0) ||
(goInfo.type == GameObjectTypes.Goober && goInfo.Goober.requireLOS != 0))