Core/Units: also allow creatures to generate rage from auto attacks and use their base attack time as base to calculate the generated amount

This commit is contained in:
Ovahlord committed 2023-12-12 20:56:33 +01:00
1 parent ba10718ea7
commit 9a4a902636
1 file changed
+11 -10
+11 -10
View File
@@ -1903,20 +1903,21 @@ 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)
{
Player const* playerAttacker = attacker->ToPlayer();
if (!playerAttacker)
return 0;
float attackDelay = [&]()
{
if (!playerAttacker->IsInFeralForm())
if (Player const* playerAttacker = attacker->ToPlayer())
{
Item const* weapon = playerAttacker->GetWeaponForAttack(attType);
if (weapon)
return static_cast<float>(weapon->GetTemplate()->GetDelay());
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);
}
else if (SpellShapeshiftFormEntry const* shapeShiftFormEntry = sSpellShapeshiftFormStore.LookupEntry(playerAttacker->GetShapeshiftForm()))
return static_cast<float>(shapeShiftFormEntry->CombatRoundTime);
else if (Creature const* creature = attacker->ToCreature())
return static_cast<float>(creature->GetCreatureTemplate()->BaseAttackTime);
return 0.f;