diff --git a/modules/mod-Forge/src/ForgeCache.cpp b/modules/mod-Forge/src/ForgeCache.cpp index 9d5889997d4fb0..60b02ed60c9ebe 100644 --- a/modules/mod-Forge/src/ForgeCache.cpp +++ b/modules/mod-Forge/src/ForgeCache.cpp @@ -25,6 +25,13 @@ enum CharacterPointType LEVEL_10_TAB = 7 }; +enum NodeType +{ + AURA = 0, + SPELL = 1, + CHOICE = 2 +}; + enum ForgeSettingIndex { FORGE_SETTING_SPEC_SLOTS = 0 @@ -90,10 +97,17 @@ struct ForgeCharacterSpec uint32 CharacterSpecTabId; // like holy ret pro // TabId, Spellid std::unordered_map> Talents; + std::unordered_map ChoiceNodesChosen; // tabId std::unordered_map PointsSpent; }; +struct ForgeTalentChoice +{ + uint32 spellId; + bool active; +}; + struct ForgeTalent { uint32 SpellId; @@ -104,10 +118,11 @@ struct ForgeTalent uint16 TabPointReq; uint8 RequiredLevel; CharacterPointType TalentType; + NodeType nodeType; uint8 NumberOfRanks; PereqReqirementType PreReqType; std::list Prereqs; - std::list ExclusiveWith; + std::list Choices; std::list UnlearnSpells; // rank number, spellId std::unordered_map Ranks; @@ -854,6 +869,9 @@ class ForgeCache : public DatabaseScript // tabId std::unordered_map TalentTabs; + // choiceNodeId is the id of the node in forge_talents + std::unordered_map> _choiceNodes; + private: std::unordered_map CharacterActiveSpecs; std::unordered_map CONFIG; @@ -920,12 +938,13 @@ class ForgeCache : public DatabaseScript AddTalentTrees(); AddTalentsToTrees(); AddTalentPrereqs(); - AddTalentExclusiveness(); + AddTalentChoiceNodes(); AddTalentRanks(); AddTalentUnlearn(); AddCharacterSpecs(); AddTalentSpent(); AddCharacterTalents(); + AddCharacterChoiceNodes(); LOG_INFO("server.load", "Loading characters points..."); AddCharacterPointsFromDB(); AddCharacterClassSpecs(); @@ -1206,12 +1225,13 @@ class ForgeCache : public DatabaseScript newTalent->NumberOfRanks = talentFields[7].Get(); newTalent->PreReqType = (PereqReqirementType)talentFields[8].Get(); newTalent->TabPointReq = talentFields[9].Get(); + newTalent->nodeType = NodeType(talentFields[10].Get()); auto tabItt = TalentTabs.find(newTalent->TalentTabId); if (tabItt == TalentTabs.end()) { - LOG_ERROR("FORGE.ForgeCache", "Error loading talents, invaild tab id: " + std::to_string(newTalent->TalentTabId)); + LOG_ERROR("FORGE.ForgeCache", "Error loading talents, invalid tab id: " + std::to_string(newTalent->TalentTabId)); } else tabItt->second->Talents[newTalent->SpellId] = newTalent; @@ -1249,9 +1269,11 @@ class ForgeCache : public DatabaseScript } while (preReqTalents->NextRow()); } - void AddTalentExclusiveness() + void AddTalentChoiceNodes() { - QueryResult exclTalents = WorldDatabase.Query("SELECT * FROM forge_talent_exclusive"); + QueryResult exclTalents = WorldDatabase.Query("SELECT * FROM forge_talent_choice_nodes"); + + _choiceNodes.clear(); if (!exclTalents) return; @@ -1259,18 +1281,24 @@ class ForgeCache : public DatabaseScript do { Field* talentFields = exclTalents->Fetch(); - uint32 spellId = talentFields[0].Get(); + uint32 choiceNodeId = talentFields[0].Get(); uint32 talentTabId = talentFields[1].Get(); - uint32 exclusiveSpellId = talentFields[2].Get(); + uint32 spellChoice = talentFields[2].Get(); - ForgeTalent* lt = TalentTabs[talentTabId]->Talents[spellId]; + ForgeTalentChoice* choice = new ForgeTalentChoice(); + choice->active = false; + choice->spellId = spellChoice; + + _choiceNodes[choiceNodeId].push_back(spellChoice); + + ForgeTalent* lt = TalentTabs[talentTabId]->Talents[choiceNodeId]; if (lt != nullptr) { - lt->ExclusiveWith.push_back(exclusiveSpellId); + lt->Choices.push_back(choice); } else { - LOG_ERROR("FORGE.ForgeCache", "Error loading AddTalentExclusiveness, invaild exclusiveSpellId id: " + std::to_string(exclusiveSpellId)); + LOG_ERROR("FORGE.ForgeCache", "Error loading AddTalentChoiceNodes, invaild choiceNodeId id: " + std::to_string(choiceNodeId)); } } while (exclTalents->NextRow()); @@ -1439,6 +1467,31 @@ class ForgeCache : public DatabaseScript } while (talentsQuery->NextRow()); } + void AddCharacterChoiceNodes() { + QueryResult choiceQuery = CharacterDatabase.Query("SELECT * FROM forge_character_node_choices"); + + if (!choiceQuery) + return; + + do + { + Field* fields = choiceQuery->Fetch(); + uint32 id = fields[0].Get(); + ObjectGuid characterGuid = ObjectGuid::Create(id); + uint32 specId = fields[1].Get(); + uint32 TabId = fields[2].Get(); + uint32 nodeId = fields[3].Get(); + uint32 chosenSpell = fields[4].Get(); + + ForgeTalent* ft = TalentTabs[TabId]->Talents[nodeId]; + if (ft->nodeType == NodeType::CHOICE) { + ForgeCharacterSpec* spec = CharacterSpecs[characterGuid][specId]; + spec->ChoiceNodesChosen[nodeId] = chosenSpell; + } + + } while (choiceQuery->NextRow()); + } + void AddCharacterPointsFromDB() { QueryResult pointsQuery = CharacterDatabase.Query("SELECT * FROM forge_character_points"); diff --git a/modules/mod-Forge/src/ForgeCommonMessage.cpp b/modules/mod-Forge/src/ForgeCommonMessage.cpp index bcf77d3f37215f..a99579e125d5e8 100644 --- a/modules/mod-Forge/src/ForgeCommonMessage.cpp +++ b/modules/mod-Forge/src/ForgeCommonMessage.cpp @@ -94,14 +94,15 @@ std::string ForgeCommonMessage::BuildTree(Player* player, CharacterPointType poi j = 0; - for (auto& preReq : talentKvp.second->ExclusiveWith) + for (auto& preReq : talentKvp.second->Ranks) { - std::string reqDel = "!"; + std::string reqDel = "%"; if (j == 0) reqDel = ""; - msg = msg + reqDel + std::to_string(preReq); + msg = msg + reqDel + std::to_string(preReq.first) + "~" + + std::to_string(preReq.second); j++; } @@ -110,31 +111,33 @@ std::string ForgeCommonMessage::BuildTree(Player* player, CharacterPointType poi j = 0; - for (auto& preReq : talentKvp.second->Ranks) + for (auto& preReq : talentKvp.second->UnlearnSpells) { - std::string reqDel = "%"; + std::string reqDel = "`"; if (j == 0) reqDel = ""; - msg = msg + reqDel + std::to_string(preReq.first) + "~" + - std::to_string(preReq.second); + msg = msg + reqDel + std::to_string(preReq); j++; } + msg = msg + "&" + std::to_string(talentKvp.second->nodeType); + msg = msg + "&"; // delimit the field j = 0; - for (auto& preReq : talentKvp.second->UnlearnSpells) + // TODO: SET THIS TO BE CHOICE NODE + for (auto& choice : talentKvp.second->Choices) { - std::string reqDel = "`"; + std::string choiceDel = "!"; if (j == 0) - reqDel = ""; + choiceDel = ""; - msg = msg + reqDel + std::to_string(preReq); + msg = msg + choiceDel + std::to_string(choice->spellId); j++; } @@ -313,14 +316,6 @@ bool ForgeCommonMessage::CanLearnTalent(Player* player, uint32 tabId, uint32 spe } } - for (auto& exclu : ft->ExclusiveWith) - { - auto typeItt = skillTabs.find(exclu); - - if (typeItt != skillTabs.end() && (typeItt->second->CurrentRank > 0)) - return false; - } - return true; } diff --git a/modules/mod-Forge/src/TopicHandlers/LearnTalentHandler.cpp b/modules/mod-Forge/src/TopicHandlers/LearnTalentHandler.cpp index 8ab95f5dd86285..fa0fbc2faa0e08 100644 --- a/modules/mod-Forge/src/TopicHandlers/LearnTalentHandler.cpp +++ b/modules/mod-Forge/src/TopicHandlers/LearnTalentHandler.cpp @@ -184,17 +184,6 @@ class LearnTalentHandler : public ForgeTopicHandler } } - for (auto& exclu : ft->ExclusiveWith) - { - auto typeItt = skillTabs.find(exclu); - - if (typeItt != skillTabs.end() && typeItt->second->CurrentRank > 0) - { - RequirementsNotMet(iam); - return; - } - } - auto spellItter = skillTabs.find(ft->SpellId); ForgeCharacterTalent* ct = new ForgeCharacterTalent();