From a4ffa701a56da4041bd3639d3f70c6b9112333df Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sat, 19 Aug 2023 22:39:23 +0200 Subject: [PATCH] Core/Spells: implement SPELL_ATTR0_CU_IS_TALENT --- src/server/game/Spells/SpellMgr.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 095b28e78e..840d293aa6 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -1086,7 +1086,8 @@ void SpellMgr::LoadSpellLearnSpells() node.active = fields[2].GetBool(); node.autoLearned = false; - if (!GetSpellInfo(spell_id)) + SpellInfo const* spellInfo = GetSpellInfo(spell_id); + if (!spellInfo) { TC_LOG_ERROR("sql.sql", "The spell %u listed in `spell_learn_spell` does not exist.", spell_id); continue; @@ -1098,7 +1099,7 @@ void SpellMgr::LoadSpellLearnSpells() continue; } - if (sDBCManager.GetTalentSpellCost(node.spell)) + if (spellInfo->HasAttribute(SPELL_ATTR0_CU_IS_TALENT)) { TC_LOG_ERROR("sql.sql", "The spell %u listed in `spell_learn_spell` attempts learning talent spell %u, skipped.", spell_id, node.spell); continue; @@ -1136,7 +1137,7 @@ void SpellMgr::LoadSpellLearnSpells() // talent or passive spells or skill-step spells auto-cast and not need dependent learning, // pet teaching spells must not be dependent learning (cast) // other required explicit dependent learning - dbc_node.autoLearned = entry->Effects[i].TargetA.GetTarget() == TARGET_UNIT_PET || sDBCManager.GetTalentSpellCost(spell) > 0 || entry->IsPassive() || entry->HasEffect(SPELL_EFFECT_SKILL_STEP); + dbc_node.autoLearned = entry->Effects[i].TargetA.GetTarget() == TARGET_UNIT_PET || entry->HasAttribute(SPELL_ATTR0_CU_IS_TALENT) || entry->IsPassive() || entry->HasEffect(SPELL_EFFECT_SKILL_STEP); SpellLearnSpellMapBounds db_node_bounds = dbSpellLearnSpells.equal_range(spell); @@ -2669,6 +2670,12 @@ void SpellMgr::LoadSpellInfoCustomAttributes() TC_LOG_INFO("server.loading", ">> Loaded %u spell custom attributes from DB in %u ms", count, GetMSTimeDiffToNow(oldMSTime2)); } + std::set talentSpells; + for (TalentEntry const* talentInfo : sTalentStore) + for (uint8 i = 0; i < MAX_TALENT_RANK; ++i) + if (uint32 spellId = talentInfo->SpellRank[i]) + talentSpells.insert(spellId); + for (SpellInfo* spellInfo : mSpellInfoMap) { if (!spellInfo) @@ -2879,6 +2886,9 @@ void SpellMgr::LoadSpellInfoCustomAttributes() spellInfo->_InitializeSpellPositivity(); + if (talentSpells.count(spellInfo->Id)) + spellInfo->AttributesCu |= SPELL_ATTR0_CU_IS_TALENT; + switch (spellInfo->SpellFamilyName) { case SPELLFAMILY_WARRIOR: