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
+1 -1
View File
@@ -79,7 +79,7 @@ namespace Framework.Constants
Unk28 = 0x10000000,
Unk29 = 0x20000000,
Sheathe = 0x40000000,
Unk31 = 0x80000000
Immune = 0x80000000
}
public enum UnitFlags2 : uint
@@ -1448,6 +1448,9 @@ namespace Game.Entities
Player playerUser = user.ToPlayer();
if (playerUser != null)
{
if (m_goInfo.GetNoDamageImmune() != 0 && playerUser.HasUnitFlag(UnitFlags.Immune))
return;
if (!m_goInfo.IsUsableMounted())
playerUser.RemoveAurasByType(AuraType.Mounted);
@@ -352,7 +352,37 @@ namespace Game.Entities
}
}
// despawn at uses amount
/// <summary>
/// Cannot be used/activated/looted by players under immunity effects (example: Divine Shield)
/// </summary>
/// <returns></returns>
public uint GetNoDamageImmune()
{
switch (type)
{
case GameObjectTypes.Door:
return Door.noDamageImmune;
case GameObjectTypes.Button:
return Button.noDamageImmune;
case GameObjectTypes.QuestGiver:
return QuestGiver.noDamageImmune;
case GameObjectTypes.Chest:
return 1;
case GameObjectTypes.Goober:
return Goober.noDamageImmune;
case GameObjectTypes.FlagStand:
return FlagStand.noDamageImmune;
case GameObjectTypes.FlagDrop:
return FlagDrop.noDamageImmune;
default:
return 0;
}
}
/// <summary>
/// despawn at uses amount
/// </summary>
/// <returns></returns>
public uint GetCharges()
{
switch (type)
+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))