From 25b27dcc72f48f073c359d07e618e44dca876b42 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 14 Sep 2023 06:57:52 -0400 Subject: [PATCH] Core/Auras: Allow effects of SPELL_AURA_SCHOOL_ABSORB_OVERKILL to be prevented by setting absorb value to 0 in script Port From (https://github.com/TrinityCore/TrinityCore/commit/7b9493eec7c937642243c5ab0367f5ac8643879e) --- Source/Game/Entities/Unit/Unit.cs | 23 +++++++++++------------ Source/Scripts/Spells/Priest.cs | 2 -- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index 48a73764d..71fa2468d 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -2752,24 +2752,23 @@ namespace Game.Entities if (damageTaken >= victim.CountPctFromMaxHealth(100 + absorbAurEff.GetMiscValueB())) continue; - // get amount which can be still absorbed by the aura - int currentAbsorb = absorbAurEff.GetAmount(); - // aura with infinite absorb amount - let the scripts handle absorbtion amount, set here to 0 for safety - if (currentAbsorb < 0) - currentAbsorb = 0; - - uint tempAbsorb = (uint)currentAbsorb; + // absorb all damage by default + uint currentAbsorb = damageInfo.GetDamage(); // This aura type is used both by Spirit of Redemption (death not really prevented, must grant all credit immediately) and Cheat Death (death prevented) // repurpose PreventDefaultAction for this bool deathFullyPrevented = false; - absorbAurEff.GetBase().CallScriptEffectAbsorbHandlers(absorbAurEff, aurApp, damageInfo, ref tempAbsorb, ref deathFullyPrevented); - currentAbsorb = (int)tempAbsorb; + absorbAurEff.GetBase().CallScriptEffectAbsorbHandlers(absorbAurEff, aurApp, damageInfo, ref currentAbsorb, ref deathFullyPrevented); // absorb must be smaller than the damage itself - currentAbsorb = MathFunctions.RoundToInterval(ref currentAbsorb, 0, (int)damageInfo.GetDamage()); - damageInfo.AbsorbDamage((uint)currentAbsorb); + currentAbsorb = Math.Min(currentAbsorb, damageInfo.GetDamage()); + + // if nothing is absorbed (for example because of a scripted cooldown) then skip this aura and proceed with dying + if (currentAbsorb == 0) + continue; + + damageInfo.AbsorbDamage(currentAbsorb); if (deathFullyPrevented) killed = false; @@ -2784,7 +2783,7 @@ namespace Game.Entities absorbLog.Caster = baseAura.GetCasterGUID(); absorbLog.AbsorbedSpellID = spellProto != null ? spellProto.Id : 0; absorbLog.AbsorbSpellID = baseAura.GetId(); - absorbLog.Absorbed = currentAbsorb; + absorbLog.Absorbed = (int)currentAbsorb; absorbLog.OriginalDamage = damageInfo.GetOriginalDamage(); absorbLog.LogData.Initialize(victim); victim.SendCombatLogMessage(absorbLog); diff --git a/Source/Scripts/Spells/Priest.cs b/Source/Scripts/Spells/Priest.cs index e9d9700f9..b83adbf0d 100644 --- a/Source/Scripts/Spells/Priest.cs +++ b/Source/Scripts/Spells/Priest.cs @@ -1573,8 +1573,6 @@ namespace Scripts.Spells.Priest Unit target = GetTarget(); target.CastSpell(target, SpellIds.SpiritOfRedemption, new CastSpellExtraArgs(aurEff)); target.SetFullHealth(); - - absorbAmount = dmgInfo.GetDamage(); } public override void Register()