Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Core/Units: use the weapon's/druid's base attack speed to calculate m…
Browse files Browse the repository at this point in the history
…elee 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
  • Loading branch information
Ovahlord committed Dec 11, 2023
1 parent 96e9b61 commit 8613a56
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(weapon->GetTemplate()->GetDelay());
}
else if (SpellShapeshiftFormEntry const* shapeShiftFormEntry = sSpellShapeshiftFormStore.LookupEntry(playerAttacker->GetShapeshiftForm()))
return static_cast<float>(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)
Expand Down

0 comments on commit 8613a56

Please sign in to comment.