From 8613a5623c558af759072364ce00bd45c69cbf5e Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Mon, 11 Dec 2023 19:55:54 +0100 Subject: [PATCH] Core/Units: use the weapon's/druid's base attack speed to calculate melee rage amounts instead of plain attack swing timers The normalized rage calculation uses base speeds, which are the weapon's attack base attack speed and the druid's shapeshift base attack speed. The old implementation used plain swing timers which are affected by haste and thus resulting in negating any rage gains from faster attacks --- src/server/game/Entities/Unit/Unit.cpp | 27 ++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index a64634165c..68069b5ccd 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1903,17 +1903,36 @@ static float GetArmorReduction(float armor, uint8 attackerLevel) // Calculates the normalized rage amount per weapon swing inline static uint32 CalcMeleeAttackRageGain(Unit const* attacker, Unit const* victim, WeaponAttackType attType) { - uint32 rage = uint32((float)attacker->GetAttackTime(attType) / 1000 * 6.5f); + Player const* playerAttacker = attacker->ToPlayer(); + if (!playerAttacker) + return 0; + + float attackDelay = [&]() + { + if (!playerAttacker->IsInFeralForm()) + { + Item const* weapon = playerAttacker->GetWeaponForAttack(attType); + if (weapon) + return static_cast(weapon->GetTemplate()->GetDelay()); + } + else if (SpellShapeshiftFormEntry const* shapeShiftFormEntry = sSpellShapeshiftFormStore.LookupEntry(playerAttacker->GetShapeshiftForm())) + return static_cast(shapeShiftFormEntry->CombatRoundTime); + + return 0.f; + + }(); + + uint32 rageAmount = attackDelay / 1000 * 6.5f; // Sentinel if (victim->GetVictim() && victim->GetVictim() != attacker) if (AuraEffect* aurEff = attacker->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_GENERIC, 1916, EFFECT_1)) - rage += CalculatePct(rage, aurEff->GetAmount()); + rageAmount += CalculatePct(rageAmount, aurEff->GetAmount()); if (attType == OFF_ATTACK) - rage *= 0.5f; + rageAmount *= 0.5f; - return rage; + return rageAmount; } void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extra)