From 9a4a9026363389738e07fbdf7fc0443158947659 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Tue, 12 Dec 2023 20:56:33 +0100 Subject: [PATCH] Core/Units: also allow creatures to generate rage from auto attacks and use their base attack time as base to calculate the generated amount --- src/server/game/Entities/Unit/Unit.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index fdba12711a..95d94c38d1 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -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(weapon->GetTemplate()->GetDelay()); + 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); } - else if (SpellShapeshiftFormEntry const* shapeShiftFormEntry = sSpellShapeshiftFormStore.LookupEntry(playerAttacker->GetShapeshiftForm())) - return static_cast(shapeShiftFormEntry->CombatRoundTime); + else if (Creature const* creature = attacker->ToCreature()) + return static_cast(creature->GetCreatureTemplate()->BaseAttackTime); return 0.f;