diff options
| author | Shauren <shauren.trinity@gmail.com> | 2023-07-31 00:11:05 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2023-07-31 00:11:05 +0200 |
| commit | 9e68fd1458551ab0f007b6044c9220da8f7d4199 (patch) | |
| tree | 207602d7dc9b0231ee2c990478436fd6a0931787 /src/server/game/Spells | |
| parent | f5461a1161a5a9dfabe7a142ad84f8c900776c92 (diff) | |
Core/Spells: Fixed spell duration scaling with combo points
Diffstat (limited to 'src/server/game/Spells')
| -rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.cpp | 6 | ||||
| -rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.h | 2 | ||||
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 29 |
5 files changed, 14 insertions, 27 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index d511bc2dfa3..665e6fca4de 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -750,7 +750,7 @@ Optional<float> AuraEffect::CalculateEstimatedAmount(Unit const* caster, int32 a float AuraEffect::CalculateEstimatedfTotalPeriodicAmount(Unit* caster, Unit* target, SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, float amount, uint8 stack) { - int32 maxDuration = Aura::CalcMaxDuration(spellInfo, caster); + int32 maxDuration = Aura::CalcMaxDuration(spellInfo, caster, nullptr); if (maxDuration <= 0) return 0.0f; diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 59c54cd73df..7021f4a0367 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -859,10 +859,10 @@ void Aura::Update(uint32 diff, Unit* caster) int32 Aura::CalcMaxDuration(Unit* caster) const { - return Aura::CalcMaxDuration(GetSpellInfo(), caster); + return Aura::CalcMaxDuration(GetSpellInfo(), caster, nullptr); } -/*static*/ int32 Aura::CalcMaxDuration(SpellInfo const* spellInfo, WorldObject* caster) +/*static*/ int32 Aura::CalcMaxDuration(SpellInfo const* spellInfo, WorldObject const* caster, std::vector<SpellPowerCost> const* powerCosts) { Player* modOwner = nullptr; int32 maxDuration; @@ -870,7 +870,7 @@ int32 Aura::CalcMaxDuration(Unit* caster) const if (caster) { modOwner = caster->GetSpellModOwner(); - maxDuration = caster->CalcSpellDuration(spellInfo); + maxDuration = caster->CalcSpellDuration(spellInfo, powerCosts); } else maxDuration = spellInfo->GetDuration(); diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index aa9829401e0..b57958d003e 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -168,7 +168,7 @@ class TC_GAME_API Aura void SetMaxDuration(int32 duration) { m_maxDuration = duration; } int32 CalcMaxDuration() const { return CalcMaxDuration(GetCaster()); } int32 CalcMaxDuration(Unit* caster) const; - static int32 CalcMaxDuration(SpellInfo const* spellInfo, WorldObject* caster); + static int32 CalcMaxDuration(SpellInfo const* spellInfo, WorldObject const* caster, std::vector<SpellPowerCost> const* powerCosts); int32 GetDuration() const { return m_duration; } void SetDuration(int32 duration, bool withMods = false); void RefreshDuration(bool withMods = false); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 1cbc3817bdd..c4aa677563c 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3164,7 +3164,7 @@ SpellMissInfo Spell::PreprocessSpellHit(Unit* unit, TargetInfo& hitInfo) } } - hitInfo.AuraDuration = Aura::CalcMaxDuration(m_spellInfo, origCaster); + hitInfo.AuraDuration = Aura::CalcMaxDuration(m_spellInfo, origCaster, &m_powerCost); // unit is immune to aura if it was diminished to 0 duration if (!hitInfo.Positive && !unit->ApplyDiminishingToDuration(m_spellInfo, hitInfo.AuraDuration, origCaster, diminishLevel)) 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<SpellPowerCost> 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<SpellPowerCost> 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<SpellPowerCost> SpellInfo::CalcPowerCost(WorldObject const* caster, SpellSchoolMask schoolMask, Spell* spell) const @@ -4180,11 +4171,7 @@ std::vector<SpellPowerCost> 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<SpellPowerCost>({ .Power = powerType, .Amount = 0 }); }; for (SpellPowerEntry const* power : PowerCosts) |
