From a8d970caa77d4c0ef8935c294c5192b4f8792ccc Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Tue, 8 Oct 2024 21:44:32 +0200 Subject: [PATCH] fix(Core/Unit): add rage gain when attack is fully blocked, dodged or parried (#19377) * generate rage if victim fully block, dodge, parry * update rage calculation * calc pct at the end * update comment to link to Rage formulae and mention Bornak's bluepost archived link to Bornak's bluepost https://web.archive.org/web/20090604123729/http://forums.worldofwarcraft.com/thread.html?topicId=17367760070&pageNo=13#02500 --- src/server/game/Entities/Unit/Unit.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 97a7ecde5..694313015 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1893,6 +1893,23 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) Unit::DealDamage(this, victim, damageInfo->damages[i].damage, &cleanDamage, DIRECT_DAMAGE, SpellSchoolMask(damageInfo->damages[i].damageSchoolMask), nullptr, durabilityLoss); } + // gain rage if attack is fully blocked, dodged or parried + if (HasActivePowerType(POWER_RAGE) && (damageInfo->TargetState == VICTIMSTATE_BLOCKS || damageInfo->TargetState == VICTIMSTATE_DODGE || damageInfo->TargetState == VICTIMSTATE_PARRY)) + { + switch (damageInfo->attackType) + { + case BASE_ATTACK: + case OFF_ATTACK: + { + uint32 weaponSpeedHitFactor = uint32(GetAttackTime(damageInfo->attackType) / 1000.0f * (damageInfo->attackType == BASE_ATTACK ? 3.5f : 1.75f)); + RewardRage(damageInfo->cleanDamage, weaponSpeedHitFactor, true); + break; + } + default: + break; + } + } + // If this is a creature and it attacks from behind it has a probability to daze it's victim if ((damageInfo->damages[0].damage + damageInfo->damages[1].damage) && ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) && !IsPlayer() && !ToCreature()->IsControlledByPlayer() && !victim->HasInArc(M_PI, this) @@ -20112,6 +20129,7 @@ void Unit::SendRemoveFromThreatListOpcode(HostileReference* pHostileReference) void Unit::RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker) { + // Rage formulae https://wowwiki-archive.fandom.com/wiki/Rage#Formulae float addRage; float rageconversion = ((0.0091107836f * GetLevel() * GetLevel()) + 3.225598133f * GetLevel()) + 4.2652911f; @@ -20122,9 +20140,10 @@ void Unit::RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker) if (attacker) { - addRage = (damage / rageconversion * 7.5f + weaponSpeedHitFactor) / 2; - - // talent who gave more rage on attack + // see Bornak's bluepost explanation (05/29/2009) + float rageFromDamageDealt = damage / rageconversion * 7.5f; + addRage = (rageFromDamageDealt + weaponSpeedHitFactor) / 2.0f; + addRage = std::min(addRage, rageFromDamageDealt * 2.0f); AddPct(addRage, GetTotalAuraModifier(SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT)); } else