aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2025-08-29 21:47:39 +0200
committerShauren <shauren.trinity@gmail.com>2025-08-29 21:47:39 +0200
commitb248e059064031fdbb75a863913d7d5eb461db41 (patch)
tree20ec6e07c22ff1107be9a21909bff98d1411b6d9 /src/server/game
parent8d8b0d1a3621e332e998007148c5a88f0dbf4212 (diff)
Core/Spells: Support spells that have both charge recovery and separate cooldown
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/Spells/SpellHistory.cpp40
-rw-r--r--src/server/game/Spells/SpellHistory.h2
2 files changed, 18 insertions, 24 deletions
diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp
index 10df8b51c0f..ac89b5ae396 100644
--- a/src/server/game/Spells/SpellHistory.cpp
+++ b/src/server/game/Spells/SpellHistory.cpp
@@ -252,8 +252,7 @@ void SpellHistory::HandleCooldowns(SpellInfo const* spellInfo, uint32 itemId, Sp
if (spell && spell->IsIgnoringCooldowns())
return;
- if (ConsumeCharge(spellInfo->ChargeCategoryId))
- return;
+ ConsumeCharge(spellInfo->ChargeCategoryId);
if (_owner->HasAuraTypeWithAffectMask(SPELL_AURA_IGNORE_SPELL_COOLDOWN, spellInfo))
return;
@@ -594,7 +593,7 @@ void SpellHistory::AddCooldown(uint32 spellId, uint32 itemId, TimePoint cooldown
void SpellHistory::ModifySpellCooldown(uint32 spellId, Duration cooldownMod, bool withoutCategoryCooldown)
{
auto itr = _spellCooldowns.find(spellId);
- if (!cooldownMod.count() || itr == _spellCooldowns.end())
+ if (itr == _spellCooldowns.end())
return;
ModifySpellCooldown(itr, cooldownMod, withoutCategoryCooldown);
@@ -665,10 +664,8 @@ void SpellHistory::ModifyCooldown(SpellInfo const* spellInfo, Duration cooldownM
if (!cooldownMod.count())
return;
- if (GetChargeRecoveryTime(spellInfo->ChargeCategoryId) > 0 && GetMaxCharges(spellInfo->ChargeCategoryId) > 0)
- ModifyChargeRecoveryTime(spellInfo->ChargeCategoryId, cooldownMod);
- else
- ModifySpellCooldown(spellInfo->Id, cooldownMod, withoutCategoryCooldown);
+ ModifyChargeRecoveryTime(spellInfo->ChargeCategoryId, cooldownMod);
+ ModifySpellCooldown(spellInfo->Id, cooldownMod, withoutCategoryCooldown);
}
void SpellHistory::ResetCooldown(uint32 spellId, bool update /*= false*/)
@@ -851,29 +848,26 @@ bool SpellHistory::IsSchoolLocked(SpellSchoolMask schoolMask) const
return false;
}
-bool SpellHistory::ConsumeCharge(uint32 chargeCategoryId)
+void SpellHistory::ConsumeCharge(uint32 chargeCategoryId)
{
if (!sSpellCategoryStore.LookupEntry(chargeCategoryId))
- return false;
+ return;
int32 chargeRecovery = GetChargeRecoveryTime(chargeCategoryId);
- if (chargeRecovery > 0 && GetMaxCharges(chargeCategoryId) > 0)
- {
- if (_owner->HasAuraTypeWithMiscvalue(SPELL_AURA_IGNORE_SPELL_CHARGE_COOLDOWN, chargeCategoryId))
- return true;
+ if (chargeRecovery <= 0 || GetMaxCharges(chargeCategoryId) <= 0)
+ return;
- TimePoint recoveryStart;
- std::deque<ChargeEntry>& charges = _categoryCharges[chargeCategoryId];
- if (charges.empty())
- recoveryStart = time_point_cast<Duration>(GameTime::GetTime<Clock>());
- else
- recoveryStart = charges.back().RechargeEnd;
+ if (_owner->HasAuraTypeWithMiscvalue(SPELL_AURA_IGNORE_SPELL_CHARGE_COOLDOWN, chargeCategoryId))
+ return;
- charges.emplace_back(recoveryStart, Milliseconds(chargeRecovery));
- return true;
- }
+ TimePoint recoveryStart;
+ std::deque<ChargeEntry>& charges = _categoryCharges[chargeCategoryId];
+ if (charges.empty())
+ recoveryStart = time_point_cast<Duration>(GameTime::GetTime<Clock>());
+ else
+ recoveryStart = charges.back().RechargeEnd;
- return false;
+ charges.emplace_back(recoveryStart, Milliseconds(chargeRecovery));
}
void SpellHistory::ModifyChargeRecoveryTime(uint32 chargeCategoryId, Duration cooldownMod)
diff --git a/src/server/game/Spells/SpellHistory.h b/src/server/game/Spells/SpellHistory.h
index 5deae792ba9..08879ae3785 100644
--- a/src/server/game/Spells/SpellHistory.h
+++ b/src/server/game/Spells/SpellHistory.h
@@ -182,7 +182,7 @@ public:
bool IsSchoolLocked(SpellSchoolMask schoolMask) const;
// Charges
- bool ConsumeCharge(uint32 chargeCategoryId);
+ void ConsumeCharge(uint32 chargeCategoryId);
void ModifyChargeRecoveryTime(uint32 chargeCategoryId, Duration cooldownMod);
void UpdateChargeRecoveryRate(uint32 chargeCategoryId, float modChange, bool apply);
void RestoreCharge(uint32 chargeCategoryId);