mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Spells: Name SpellCategoryFlags with official names and implement ResetCooldownUponEndingEncounter flag (#31415)
This commit is contained in:
@@ -3804,6 +3804,8 @@ struct SpellCategoryEntry
|
||||
int32 MaxCharges;
|
||||
int32 ChargeRecoveryTime;
|
||||
int32 TypeMask;
|
||||
|
||||
EnumFlag<SpellCategoryFlags> GetFlags() const { return static_cast<SpellCategoryFlags>(Flags); }
|
||||
};
|
||||
|
||||
struct SpellClassOptionsEntry
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
return spellInfo->HasAttribute(SPELL_ATTR10_RESET_COOLDOWN_ON_ENCOUNTER_END);
|
||||
if (SpellCategoryEntry const* category = sSpellCategoryStore.LookupEntry(spellInfo->CategoryId))
|
||||
if (category->GetFlags().HasFlag(SpellCategoryFlags::ResetCooldownUponEndingEncounter))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Milliseconds>(Clock::from_time_t(sWorld->GetNextDailyQuestsResetTime()) - GameTime::GetTime<Clock>());
|
||||
}
|
||||
}
|
||||
@@ -1027,8 +1027,8 @@ int32 SpellHistory::GetChargeRecoveryTime(uint32 chargeCategoryId) const
|
||||
recoveryTimeF *= 100.0f / (std::max<float>(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));
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user