|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
local DEFAULT_SELECTED_QUEST_INDEX = 1 return managerend EVENT_MANAGER:RegisterForEvent("ZO_CraftAdvisorManager", EVENT_CRAFTING_STATION_INTERACT, function(eventCode, craftingType, sameStation, craftingMode) --If we are at a different type of crafting station, we need to update the list --Otherwise, if anything has changed, we will have already attempted to refresh via the quest events --We also need to refresh if the player goes to a new smithing station, since they might be changing to a new set station --We always need to refresh the list if we are interacting with a consolidated station, as the available sets at the station could have changed if craftingMode == CRAFTING_INTERACTION_MODE_CONSOLIDATED_STATION or craftingType ~= self.craftingInteractionType or (not sameStation and IsSmithingCraftingType(craftingType)) then end end) if mainStepChanged then end if currentlySelectedQuest and currentlySelectedQuest.questIndex == questIndex then --Tell the craft advisor that it needs to refresh the quest display end end --Register for the various quest change events EVENT_MANAGER:RegisterForEvent("ZO_CraftAdvisorManager", EVENT_QUEST_CONDITION_COUNTER_CHANGED, function(_, questIndex) UpdateQuestConditions(questIndex) end) EVENT_MANAGER:RegisterForEvent("ZO_CraftAdvisorManager", EVENT_QUEST_ADVANCED, function(_, questIndex, questName, isPushed, isComplete, mainStepChanged) UpdateQuestConditions(questIndex, mainStepChanged) end) --We need to register for this event to detect if a new translation has been discovered --Presumably, this can only happen while enchanting, so if the enchanting scene is not showing, we shouldn't care end end) --We need to rebuild when the inventory changes so we can make sure we display the proper messaging if there are missing materials/runes/reagents/etc EVENT_MANAGER:RegisterForEvent("ZO_CraftAdvisorManager", EVENT_INVENTORY_FULL_UPDATE, function() self:FireCallbacks("SelectedQuestConditionsUpdated") end) EVENT_MANAGER:RegisterForEvent("ZO_CraftAdvisorManager", EVENT_INVENTORY_SINGLE_SLOT_UPDATE, function() self:FireCallbacks("SelectedQuestConditionsUpdated") end) --We need to rebuild when we learn a new recipe so we can make sure we display the proper messaging for missing recipes EVENT_MANAGER:RegisterForEvent("ZO_CraftAdvisorManager", EVENT_RECIPE_LEARNED, function() self:FireCallbacks("SelectedQuestConditionsUpdated") end) EVENT_MANAGER:RegisterForEvent("ZO_CraftAdvisorManager", EVENT_MULTIPLE_RECIPES_LEARNED, function() self:FireCallbacks("SelectedQuestConditionsUpdated") end) --We need to rebuild if the player's solvent proficiency changed or they got the Laboratory Use skill, to ensure the error messaging refreshes EVENT_MANAGER:RegisterForEvent("ZO_CraftAdvisorManager", EVENT_NON_COMBAT_BONUS_CHANGED, function(eventCode, nonCombatBonusType) if nonCombatBonusType == NON_COMBAT_BONUS_ALCHEMY_THIRD_SLOT or nonCombatBonusType == NON_COMBAT_BONUS_ALCHEMY_LEVEL then end end) --We need to rebuild when the active set changes since it will result in different patterns being available EVENT_MANAGER:RegisterForEvent("ZO_CraftAdvisorManager", EVENT_CONSOLIDATED_STATION_ACTIVE_SET_UPDATED, function() end) --We need to rebuild the whole list when the unlocked consolidated sets change, as it could impact what quests are valid at this station EVENT_MANAGER:RegisterForEvent("ZO_CraftAdvisorManager", EVENT_CONSOLIDATED_STATION_SETS_UPDATED, function() self:RefreshQuestMasterList() end) QUEST_JOURNAL_MANAGER:RegisterCallback("QuestListUpdated", function() self:RefreshQuestMasterList() end)endend --Grab the current quest information from the journal --Clear out the current quest pin data self:FireCallbacks("QuestInformationUpdated", {patternIndices = {}, materialIndex = nil, traitId = nil, styleId = nil, recipeItemIds = {}, runeIds = {}, alchemyInfo = {}, improvementInfo = {}}) --Filter out any non-crafting quests from the list local conditionCount = select(5, GetJournalQuestStepInfo(questInfo.questIndex, QUEST_MAIN_STEP_INDEX)) local conditionInfo = {} for conditionIndex = 1, conditionCount do local conditionType = select(8, GetJournalQuestConditionInfo(questInfo.questIndex, QUEST_MAIN_STEP_INDEX, conditionIndex)) if conditionType == QUEST_CONDITION_TYPE_GATHER_ITEM or conditionType == QUEST_CONDITION_TYPE_CRAFT_ITEM then local itemId, materialItemId, craftingType, itemFunctionalQuality = GetQuestConditionItemInfo(questInfo.questIndex, QUEST_MAIN_STEP_INDEX, conditionIndex) --If any of the condition crafting types match the current interaction type, we want to include this quest --Provisioning is special in that in can be done at any crafting station type, so we need to do a slightly different check for it if craftingType == CRAFTING_TYPE_PROVISIONING then end if shouldShowQuest then { conditionIndex = conditionIndex, itemId = itemId, materialItemId = materialItemId, craftingType = craftingType, itemFunctionalQuality = itemFunctionalQuality, isMasterWrit = false, } end elseif conditionType == QUEST_CONDITION_TYPE_CRAFT_RANDOM_WRIT_ITEM then local itemId, materialItemId, craftingType, itemFunctionalQuality, itemTemplateId, itemSetId, itemTraitType, itemStyleId, encodedAlchemyTraits = GetQuestConditionMasterWritInfo(questInfo.questIndex, QUEST_MAIN_STEP_INDEX, conditionIndex) --If any of the condition crafting types match the current interaction type, we want to include this quest --Provisioning is special in that in can be done at any crafting station type, so we need to do a slightly different check for it if craftingType == CRAFTING_TYPE_PROVISIONING then end if shouldShowQuest then { conditionIndex = conditionIndex, itemId = itemId, materialItemId = materialItemId, craftingType = craftingType, itemFunctionalQuality = itemFunctionalQuality, itemTemplateId = itemTemplateId, itemSetId = itemSetId, itemTraitType = itemTraitType, itemStyleId = itemStyleId, encodedAlchemyTraits = encodedAlchemyTraits, isMasterWrit = true, } --Smithing master writs should only show up at their specific set station end else end end end end if #conditionInfo > 0 then questInfo.conditionData = conditionInfo end endend --If we have already met the condition requirements, we no longer care about what components we have if currentCount < maxCount then if conditionInfo.craftingType == CRAFTING_TYPE_ENCHANTING then local potencyRune, essenceRune, aspectRune = GetRunesForItemIdIfKnown(conditionInfo.itemId, conditionInfo.materialItemId, conditionInfo.itemFunctionalQuality) --GetRunesForItemIdIfKnown will return nil for all values if any of the runes are unknown --Therefore, checking any of them for nil would be sufficient, it doesn't have to be potency if potencyRune == nil then return GetString(SI_CRAFTING_MISSING_ITEMS), GetString(SI_CRAFT_ADVISOR_ENCHANTING_MISSING_ITEMS_TOOLTIP) end elseif conditionInfo.craftingType == CRAFTING_TYPE_PROVISIONING then --Look for a matching recipe --If we have a match, then we're done, return early if recipe.resultItemId == conditionInfo.itemId then return end end end --If we get here, that means we are missing the recipe return GetString(SI_PROVISIONER_MISSING_RECIPE), GetString(SI_CRAFT_ADVISOR_PROVISIONING_MISSING_RECIPE_TOOLTIP) elseif conditionInfo.craftingType == CRAFTING_TYPE_ALCHEMY then local validCombinationFound = false local needsThirdSlot = conditionInfo.isMasterWrit and GetNonCombatBonus(NON_COMBAT_BONUS_ALCHEMY_THIRD_SLOT) == 0 --Check and see if the alchemy logic has found any valid combinations else end if needsThirdSlot then return GetString(SI_ALCHEMY_REQUIRES_THIRD_SLOT), GetString(SI_CRAFT_ADVISOR_ALCHEMY_REQUIRES_THIRD_SLOT_TOOLTIP) elseif not validCombinationFound then return GetString(SI_ALCHEMY_MISSING_OR_UNKNOWN), GetString(SI_CRAFT_ADVISOR_ALCHEMY_MISSING_OR_UNKNOWN_TOOLTIP) end end endend local craftingQuestIndices = { patternIndices = {}, materialIndex = nil, traitId = nil, styleId = nil, recipeItemIds = {}, runeIds = {}, alchemyInfo = {}, improvementInfo = {}, } if questInfo then --Determine the pattern and material information for each relevant condition local _, curCount, maxCount = GetJournalQuestConditionInfo(questInfo.questIndex, QUEST_MAIN_STEP_INDEX, conditionInfo.conditionIndex) --If this is a master writ, we need different information from normal ones if conditionInfo.isMasterWrit then if curCount < maxCount then local patternIndex, materialIndex, desiredItemId = GetSmithingPatternInfoForItemSet(conditionInfo.itemTemplateId, conditionInfo.itemSetId, conditionInfo.materialItemId, conditionInfo.itemTraitType) if patternIndex and materialIndex then craftingQuestIndices.patternIndices[patternIndex] = true craftingQuestIndices.materialIndex = materialIndex craftingQuestIndices.traitId = conditionInfo.itemTraitType craftingQuestIndices.styleId = conditionInfo.itemStyleId craftingQuestIndices.hasPatterns = true end if desiredItemId and conditionInfo.itemFunctionalQuality and conditionInfo.materialItemId and conditionInfo.itemTraitType and conditionInfo.itemStyleId then craftingQuestIndices.improvementInfo = { desiredItemId = desiredItemId, desiredQuality = conditionInfo.itemFunctionalQuality, desiredMaterial = conditionInfo.materialItemId, desiredTrait = conditionInfo.itemTraitType, desiredStyle = conditionInfo.itemStyleId, } craftingQuestIndices.hasItemToImproveForWrit = HasItemToImproveForWrit(desiredItemId, conditionInfo.materialItemId, conditionInfo.itemTraitType, conditionInfo.itemStyleId, conditionInfo.itemFunctionalQuality) end craftingQuestIndices.consolidatedItemSetId = conditionInfo.itemSetId end end else local patternIndex, materialIndex = GetSmithingPatternInfoForItemId(conditionInfo.itemId, conditionInfo.materialItemId, conditionInfo.craftingType) if patternIndex and materialIndex and curCount < maxCount then craftingQuestIndices.patternIndices[patternIndex] = true craftingQuestIndices.materialIndex = materialIndex craftingQuestIndices.hasPatterns = true elseif curCount < maxCount then craftingQuestIndices.smithingItemId = conditionInfo.itemId end end elseif conditionInfo.craftingType == CRAFTING_TYPE_PROVISIONING then local _, curCount, maxCount = GetJournalQuestConditionInfo(questInfo.questIndex, QUEST_MAIN_STEP_INDEX, conditionInfo.conditionIndex) if curCount < maxCount then craftingQuestIndices.recipeItemIds[conditionInfo.itemId] = true craftingQuestIndices.hasRecipesForQuest = true end elseif conditionInfo.craftingType == CRAFTING_TYPE_ENCHANTING then local _, curCount, maxCount = GetJournalQuestConditionInfo(questInfo.questIndex, QUEST_MAIN_STEP_INDEX, conditionInfo.conditionIndex) local potencyRune, essenceRune, aspectRune = GetRunesForItemIdIfKnown(conditionInfo.itemId, conditionInfo.materialItemId, conditionInfo.itemFunctionalQuality) if potencyRune and essenceRune and aspectRune and curCount < maxCount then craftingQuestIndices.runeIds = { potency = potencyRune, essence = essenceRune, aspect = aspectRune } else craftingQuestIndices.runeIds = { hasRequiredGlyph = curCount >= maxCount } end elseif conditionInfo.craftingType == CRAFTING_TYPE_ALCHEMY then local _, curCount, maxCount = GetJournalQuestConditionInfo(questInfo.questIndex, QUEST_MAIN_STEP_INDEX, conditionInfo.conditionIndex) --If this is a master writ, we need different alchemy information than for normal writs if conditionInfo.isMasterWrit then if conditionInfo.encodedAlchemyTraits and curCount < maxCount then craftingQuestIndices.alchemyInfo = { basePotionItemId = conditionInfo.itemId, materialItemId = conditionInfo.materialItemId, encodedTraits = conditionInfo.encodedAlchemyTraits, isMasterWrit = true } else craftingQuestIndices.alchemyInfo = { hasDesiredPotion = curCount >= maxCount } end else if desiredTraitId ~= 0 and curCount < maxCount then craftingQuestIndices.alchemyInfo = { basePotionItemId = conditionInfo.itemId, materialItemId = conditionInfo.materialItemId, desiredTrait = desiredTraitId } else craftingQuestIndices.alchemyInfo = { hasDesiredPotion = curCount >= maxCount } end end end end end --Send out the updated data necessary for the quest pinsend --Locate the newly selected quest if questInfo.questIndex == questIndex then return end endendend |