From 063c8b3b894394afb7e8239fb4f44c53d7aa0f2a Mon Sep 17 00:00:00 2001 From: Kevin Krol Date: Tue, 13 Dec 2022 23:30:58 +0100 Subject: [PATCH] Fix talent load condition with automatically granted talents --- CHANGELOG.md | 1 + Clicked/Core/BindingProcessor.lua | 33 +++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58de33ed..7a287b04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel * Fix talent selection input on non-English locales [#146] * Fix a Lua error when selecting spell from the spellbook +* Fix talent known condition not working with talents granted automatically * Improve performance when switching specializations or talent loadouts ## [1.10.1] - 2022-11-28 diff --git a/Clicked/Core/BindingProcessor.lua b/Clicked/Core/BindingProcessor.lua index aed5c7d5..999cab3a 100644 --- a/Clicked/Core/BindingProcessor.lua +++ b/Clicked/Core/BindingProcessor.lua @@ -801,14 +801,31 @@ function Addon:CanBindingLoad(binding) for _, nodeId in ipairs(nodes) do local nodeInfo = C_Traits.GetNodeInfo(configId, nodeId) - if nodeInfo.ID ~= 0 and nodeInfo.currentRank > 0 then - local entryId = nodeInfo.activeEntry ~= nil and nodeInfo.activeEntry.entryID - local entryInfo = entryId ~= nil and C_Traits.GetEntryInfo(configId, entryId) - local definitionInfo = entryInfo ~= nil and C_Traits.GetDefinitionInfo(entryInfo.definitionID) - - if definitionInfo ~= nil then - local name = StripColorCodes(TalentUtil.GetTalentNameFromInfo(definitionInfo)) - talents[name] = true + if nodeInfo.ID ~= 0 then + -- check if the node was manually selected by the player, the easy way + local isValid = nodeInfo.currentRank > 0 + + -- check if the node was granted to the player automatically + if not isValid then + for _, conditionId in ipairs(nodeInfo.conditionIDs) do + local conditionInfo = C_Traits.GetConditionInfo(configId, conditionId) + + if conditionInfo.isMet and conditionInfo.ranksGranted ~= nil and conditionInfo.ranksGranted > 0 then + isValid = true + break + end + end + end + + if isValid then + local entryId = nodeInfo.activeEntry ~= nil and nodeInfo.activeEntry.entryID or 0 + local entryInfo = entryId ~= nil and C_Traits.GetEntryInfo(configId, entryId) or nil + local definitionInfo = entryInfo ~= nil and C_Traits.GetDefinitionInfo(entryInfo.definitionID) or nil + + if definitionInfo ~= nil then + local name = StripColorCodes(TalentUtil.GetTalentNameFromInfo(definitionInfo)) + talents[name] = true + end end end end