From ff256d20e52b980cde0000f0f7cfc947868c80dd Mon Sep 17 00:00:00 2001 From: Aqua Deus <95978183+aquadeus@users.noreply.github.com> Date: Wed, 29 Oct 2025 16:04:11 +0100 Subject: Core/Spells: Name SpellCategoryFlags with official names and implement ResetCooldownUponEndingEncounter flag (#31415) --- src/server/game/DataStores/DB2Structure.h | 2 ++ src/server/game/DataStores/DBCEnums.h | 16 +++++++++++----- src/server/game/Entities/Unit/Unit.cpp | 8 +++++++- src/server/game/Spells/SpellHistory.cpp | 6 +++--- src/server/game/Spells/SpellInfo.cpp | 2 +- 5 files changed, 24 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/server/game/DataStores/DB2Structure.h b/src/server/game/DataStores/DB2Structure.h index 15216bd4486..0a5b8e866a4 100644 --- a/src/server/game/DataStores/DB2Structure.h +++ b/src/server/game/DataStores/DB2Structure.h @@ -3804,6 +3804,8 @@ struct SpellCategoryEntry int32 MaxCharges; int32 ChargeRecoveryTime; int32 TypeMask; + + EnumFlag GetFlags() const { return static_cast(Flags); } }; struct SpellClassOptionsEntry diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h index 35e9b52be9f..247c73004d5 100644 --- a/src/server/game/DataStores/DBCEnums.h +++ b/src/server/game/DataStores/DBCEnums.h @@ -2278,14 +2278,20 @@ enum SkillRaceClassInfoFlags SKILL_FLAG_MONO_VALUE = 0x400 // Skill always has value 1 - clientside display flag, real value can be different }; -enum SpellCategoryFlags +enum class SpellCategoryFlags { - SPELL_CATEGORY_FLAG_COOLDOWN_SCALES_WITH_WEAPON_SPEED = 0x01, // unused - SPELL_CATEGORY_FLAG_COOLDOWN_STARTS_ON_EVENT = 0x04, - SPELL_CATEGORY_FLAG_COOLDOWN_EXPIRES_AT_DAILY_RESET = 0x08, - SPELL_CATEGORY_FLAG_IGNORE_FOR_MOD_TIME_RATE = 0x40 + CooldownModifiesItem = 0x01, // NYI + CooldownIsGlobal = 0x02, // NYI + CooldownEventOnLeaveCombat = 0x04, + CooldownInDays = 0x08, + ResetChargesUponEndingEncounter = 0x10, // NYI + ResetCooldownUponEndingEncounter = 0x20, + IgnoreForModTimeRate = 0x40, + Unknown = 0x80 // NYI }; +DEFINE_ENUM_FLAG(SpellCategoryFlags); + enum class SpellEffectAttributes { None = 0, diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 116d81d9f38..c6466bba6b4 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -581,8 +581,14 @@ void Unit::AtEndOfEncounter(EncounterType type) GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownEntry const& cooldown) { SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(cooldown.SpellId, DIFFICULTY_NONE); + if (spellInfo->HasAttribute(SPELL_ATTR10_RESET_COOLDOWN_ON_ENCOUNTER_END)) + return true; + + if (SpellCategoryEntry const* category = sSpellCategoryStore.LookupEntry(spellInfo->CategoryId)) + if (category->GetFlags().HasFlag(SpellCategoryFlags::ResetCooldownUponEndingEncounter)) + return true; - return spellInfo->HasAttribute(SPELL_ATTR10_RESET_COOLDOWN_ON_ENCOUNTER_END); + return false; }, true); } diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp index ac89b5ae396..bfa2d769b3c 100644 --- a/src/server/game/Spells/SpellHistory.cpp +++ b/src/server/game/Spells/SpellHistory.cpp @@ -506,7 +506,7 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel } SpellCategoryEntry const* categoryEntry = sSpellCategoryStore.AssertEntry(categoryId); - if (categoryEntry->Flags & SPELL_CATEGORY_FLAG_COOLDOWN_EXPIRES_AT_DAILY_RESET) + if (categoryEntry->GetFlags().HasFlag(SpellCategoryFlags::CooldownInDays)) categoryCooldown = duration_cast(Clock::from_time_t(sWorld->GetNextDailyQuestsResetTime()) - GameTime::GetTime()); } } @@ -1027,8 +1027,8 @@ int32 SpellHistory::GetChargeRecoveryTime(uint32 chargeCategoryId) const recoveryTimeF *= 100.0f / (std::max(modRecoveryRate->GetAmount(), -99.0f) + 100.0f); if (Milliseconds(chargeCategoryEntry->ChargeRecoveryTime) <= 1h - && !(chargeCategoryEntry->Flags & SPELL_CATEGORY_FLAG_IGNORE_FOR_MOD_TIME_RATE) - && !(chargeCategoryEntry->Flags & SPELL_CATEGORY_FLAG_COOLDOWN_EXPIRES_AT_DAILY_RESET)) + && !(chargeCategoryEntry->GetFlags().HasFlag(SpellCategoryFlags::IgnoreForModTimeRate)) + && !(chargeCategoryEntry->GetFlags().HasFlag(SpellCategoryFlags::CooldownInDays))) recoveryTimeF *= *_owner->m_unitData->ModTimeRate; return int32(std::floor(recoveryTimeF)); diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 4eaca9be938..968202593eb 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1763,7 +1763,7 @@ bool SpellInfo::IsCooldownStartedOnEvent() const return true; SpellCategoryEntry const* category = sSpellCategoryStore.LookupEntry(CategoryId); - return category && category->Flags & SPELL_CATEGORY_FLAG_COOLDOWN_STARTS_ON_EVENT; + return category && category->GetFlags().HasFlag(SpellCategoryFlags::CooldownEventOnLeaveCombat); } bool SpellInfo::IsDeathPersistent() const -- cgit v1.2.3