From 9e68fd1458551ab0f007b6044c9220da8f7d4199 Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 31 Jul 2023 00:11:05 +0200 Subject: Core/Spells: Fixed spell duration scaling with combo points --- src/server/game/Spells/SpellInfo.cpp | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'src/server/game/Spells/SpellInfo.cpp') diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 2d92b671ba3..b0cef2841d6 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -3959,22 +3959,16 @@ Optional SpellInfo::CalcPowerCost(SpellPowerEntry const* power, // Spell drain all exist power on cast (Only paladin lay of Hands) if (HasAttribute(SPELL_ATTR1_USE_ALL_MANA)) { + if (optionalCost) + return {}; + // If power type - health drain all if (power->PowerType == POWER_HEALTH) - { - SpellPowerCost cost; - cost.Power = POWER_HEALTH; - cost.Amount = unitCaster->GetHealth(); - return cost; - } + return SpellPowerCost{ .Power = POWER_HEALTH, .Amount = int32(unitCaster->GetHealth()) }; + // Else drain all power if (power->PowerType < MAX_POWERS) - { - SpellPowerCost cost; - cost.Power = Powers(power->PowerType); - cost.Amount = unitCaster->GetPower(cost.Power); - return cost; - } + return SpellPowerCost{ .Power = Powers(power->PowerType), .Amount = unitCaster->GetPower(Powers(power->PowerType)) }; TC_LOG_ERROR("spells", "SpellInfo::CalcPowerCost: Unknown power type '{}' in spell {}", power->PowerType, Id); return {}; @@ -4158,10 +4152,7 @@ Optional SpellInfo::CalcPowerCost(SpellPowerEntry const* power, if (initiallyNegative != (powerCost < 0)) powerCost = 0; - SpellPowerCost cost; - cost.Power = Powers(power->PowerType); - cost.Amount = powerCost; - return cost; + return SpellPowerCost{ .Power = Powers(power->PowerType), .Amount = powerCost }; } std::vector SpellInfo::CalcPowerCost(WorldObject const* caster, SpellSchoolMask schoolMask, Spell* spell) const @@ -4180,11 +4171,7 @@ std::vector SpellInfo::CalcPowerCost(WorldObject const* caster, if (itr != costs.end()) return *itr; - SpellPowerCost cost; - cost.Power = powerType; - cost.Amount = 0; - costs.push_back(cost); - return costs.back(); + return costs.emplace_back({ .Power = powerType, .Amount = 0 }); }; for (SpellPowerEntry const* power : PowerCosts) -- cgit v1.2.3