Core/Spells: added and updated SpellCategoryFlags and implemented SpellCategoryFlags::CooldownInDays

This commit is contained in:
Ovahlord
2021-03-25 17:10:51 +01:00
parent 83298b52a2
commit 6301a324cd
6 changed files with 18 additions and 30 deletions

View File

@@ -496,13 +496,17 @@ 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 : uint8
{
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
None = 0,
CooldownModifiesItem = 0x1, // NYI
GlobalCooldown = 0x2, // NYI
CooldownEventOnLeaveCombat = 0x4,
CooldownInDays = 0x8,
};
DEFINE_ENUM_FLAG(SpellCategoryFlags);
#define MAX_SPELL_EFFECTS 3
#define MAX_EFFECT_MASK 7
#define MAX_SPELL_REAGENTS 8

View File

@@ -1315,23 +1315,6 @@ EmotesTextSoundEntry const* DBCManager::FindTextSoundEmoteFor(uint32 emote, uint
return itr != sEmotesTextSoundMap.end() ? itr->second : nullptr;
}
uint32 DBCManager::GetParentSpellCategoryId(uint32 childCategory)
{
// Weekly profession reset linking
switch (childCategory)
{
case 1278: // Dream of Skywall
case 1279: // Dream of Azshara
case 1280: // Dream of Ragnaros
case 1281: // Dream of Deepholm
case 1282: // Dream of Hyjal
return 1328;
default:
return 0;
}
return 0;
}
bool DBCManager::IsInArea(uint32 objectAreaId, uint32 areaId)
{
do

View File

@@ -248,7 +248,6 @@ public:
SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_);
ResponseCodes ValidateName(std::wstring const& name, LocaleConstant locale);
EmotesTextSoundEntry const* FindTextSoundEmoteFor(uint32 emote, uint32 race, uint32 gender);
static uint32 GetParentSpellCategoryId(uint32 childCategory);
};
#define sDBCManager DBCManager::Instance()

View File

@@ -2145,6 +2145,8 @@ struct SpellCategoryEntry
uint32 Flags; // 1
uint32 UsesPerWeek; // 2
// char* Name; // 3
EnumFlag<SpellCategoryFlags> GetFlags() const { return static_cast<SpellCategoryFlags>(Flags); }
};
struct SpellDifficultyEntry

View File

@@ -340,15 +340,15 @@ 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))
{
uint32 parentCategoryId = DBCManager::GetParentSpellCategoryId(categoryEntry->ID);
SpellCategoryEntry const* parentCategory = sSpellCategoryStore.LookupEntry(parentCategoryId);
uint32 days = std::max<int32>((categoryCooldown / 1000) - 1, 0);
if (parentCategory && parentCategory->UsesPerWeek)
categoryCooldown = WEEK * IN_MILLISECONDS;
else
categoryCooldown = int32(std::chrono::duration_cast<std::chrono::milliseconds>(Clock::from_time_t(sWorld->GetNextDailyQuestsResetTime()) - Clock::now()).count());
// Initially start with the cooldown in plain days. Substract one day as we add the remaining cooldown until daily reset in the next step
categoryCooldown += int32(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::hours(days * 24)).count());
// Day based cooldowns have their reset at daily reset times so we now apply the remaining cooldown
categoryCooldown += int32(std::chrono::duration_cast<std::chrono::milliseconds>(Clock::from_time_t(sWorld->GetNextDailyQuestsResetTime()) - Clock::now()).count());
}
}

View File

@@ -1377,7 +1377,7 @@ bool SpellInfo::IsCooldownStartedOnEvent() const
if (HasAttribute(SPELL_ATTR0_DISABLED_WHILE_ACTIVE))
return true;
return CategoryEntry && CategoryEntry->Flags & SPELL_CATEGORY_FLAG_COOLDOWN_STARTS_ON_EVENT;
return CategoryEntry && CategoryEntry->GetFlags().HasFlag(SpellCategoryFlags::CooldownEventOnLeaveCombat);
}
bool SpellInfo::IsDeathPersistent() const