From 8bec37e96e205db0bfce451f20852e31b23da568 Mon Sep 17 00:00:00 2001 From: Sistemas Date: Fri, 29 May 2026 22:47:37 +0200 Subject: [PATCH] Core/Spells: Arreglada Actitud defensiva del Guerrero --- src/server/scripts/Spells/spell_warrior.cpp | 75 ++++++++++++++++----- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index 13cd969d0..7d5b809c7 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -178,6 +178,8 @@ enum WarriorSpells SPELL_WARRIOR_FEARLESS = 1271925, SPELL_WARRIOR_WRECKING_THROW = 384110, SPELL_WARRIOR_WRECKING_THROW_DAMAGE = 394354, + SPELL_WARRIOR_DEFENSIVE_STANCE = 386208, + SPELL_WARRIOR_DEFENSIVE_STANCE_SPIKE_TALENT = 1280961, }; enum WarriorMisc @@ -2783,29 +2785,72 @@ class spell_warr_rend : public AuraScript } }; -// Defensive Stance - 71 +// Defensive Stance - 386208 class spell_warr_defensive_stance : public AuraScript +{ + bool Validate(SpellInfo const* /*spellInfo*/) override { - int32 damageTaken = 0; + return ValidateSpellInfo({ SPELL_WARRIOR_DEFENSIVE_STANCE, SPELL_WARRIOR_DEFENSIVE_STANCE_SPIKE_TALENT }); + } - void HandleProc(ProcEventInfo& eventInfo) + void HandleAbsorb(AuraEffect* aurEff, DamageInfo& /*dmgInfo*/, uint32& /*absorbAmount*/) + { + aurEff->SetAmount(-1); + } + + bool CheckProc(ProcEventInfo& eventInfo) + { + return eventInfo.GetDamageInfo() != nullptr && eventInfo.GetDamageInfo()->GetDamage() > 0; + } + + void PrepareProc(ProcEventInfo& /*eventInfo*/) + { + PreventDefaultAction(); + } + + void HandleProc(ProcEventInfo& eventInfo) + { + Unit* caster = GetCaster(); + if (!caster) + return; + + DamageInfo* damageInfo = eventInfo.GetDamageInfo(); + uint32 damageTaken = damageInfo->GetDamage(); + + if (caster->HasAura(SPELL_WARRIOR_DEFENSIVE_STANCE_SPIKE_TALENT)) { - Unit* caster = GetCaster(); - if (!caster) - return; - - damageTaken = eventInfo.GetDamageInfo() ? eventInfo.GetDamageInfo()->GetDamage() : 0; - if (damageTaken <= 0) - return; - - int32 rageAmount = (50.0f * (float)damageTaken) / (float)caster->GetMaxHealth(); - caster->ModifyPower(POWER_RAGE, 10 * uint32(rageAmount)); + AuraEffect const* thresholdEff = GetEffect(EFFECT_4); + AuraEffect const* reductionEff = GetEffect(EFFECT_5); + if (thresholdEff && reductionEff) + { + float thresholdPct = float(thresholdEff->GetAmount()); + float reductionPct = float(reductionEff->GetAmount()); + uint32 maxHealth = caster->GetMaxHealth(); + if (maxHealth > 0 && float(damageTaken) >= CalculatePct(float(maxHealth), thresholdPct)) + { + uint32 absorbAmount = uint32(CalculatePct(float(damageTaken), reductionPct)); + if (absorbAmount > 0) + damageInfo->AbsorbDamage(absorbAmount); + } + } } - void Register() override + damageTaken = damageInfo->GetDamage(); + if (damageTaken > 0) { - OnProc += AuraProcFn(spell_warr_defensive_stance::HandleProc); + int32 rageAmount = int32((50.0f * float(damageTaken)) / float(caster->GetMaxHealth())); + if (rageAmount > 0) + caster->ModifyPower(POWER_RAGE, 10 * rageAmount); } + } + + void Register() override + { + AfterEffectAbsorb += AuraEffectAbsorbFn(spell_warr_defensive_stance::HandleAbsorb, EFFECT_FIRST_FOUND); + DoCheckProc += AuraCheckProcFn(spell_warr_defensive_stance::CheckProc); + DoPrepareProc += AuraProcFn(spell_warr_defensive_stance::PrepareProc); + OnProc += AuraProcFn(spell_warr_defensive_stance::HandleProc); + } }; //Second wind - 29838 SPELL_WARRIOR_SECOND_WIND__HEALTH