Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 67 additions & 29 deletions src/Classes/ItemsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3342,6 +3342,8 @@ function ItemsTabClass:CorruptDisplayItem(modType)
main:OpenPopup(605, 103 + 20 * 2, modType .. " Item", controls)
end

local delveDropOnlyCategories = require("Data.DelveDropOnly")
local incursionDropOnlyCategories = require("Data.IncursionDropOnly")
-- Opens the custom modifier popup
function ItemsTabClass:AddCustomModifierToDisplayItem()
local controls = { }
Expand Down Expand Up @@ -3406,6 +3408,37 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
controls.modSelect:SetSel(1, true)
end
end
local function buildDropRestricted(baseCategories, modDb)
local base = self.displayItem.base
local subTypeName = base.subType and base.type .. ": " .. base.subType
for modId, entry in pairs(baseCategories) do
local mod = modDb[modId]
if not mod then
ConPrintf("Unknown drop-restricted mod id: %s", tostring(modId))
goto nextDrop
end
for _, cat in ipairs(entry.categories) do
if base.type == cat or subTypeName == cat then
t_insert(modList, {
label = table.concat(mod, "/") .. " (" .. mod.type .. ")",
mod = mod,
affixType = mod.type,
type = "custom",
defaultOrder = modId,
})
goto nextDrop
end
end
::nextDrop::
end
end
local function sortByPrefixSuffix(a, b)
if a.affixType ~= b.affixType then
return a.affixType == "Prefix" and b.affixType == "Suffix"
else
return a.defaultOrder < b.defaultOrder
end
end
---Mutates modList to contain mods from the specified source
---@param sourceId string @The crafting source id to build the list of mods for
local function buildMods(sourceId)
Expand Down Expand Up @@ -3441,12 +3474,14 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
for _, essence in pairs(self.build.data.essences) do
local modId = essence.mods[self.displayItem.type]
local mod = self.displayItem.affixes[modId]
t_insert(modList, {
label = essence.name .. " " .. "^8[" .. table.concat(mod, "/") .. "]" .. " (" .. mod.type .. ")",
mod = mod,
type = "custom",
essence = essence,
})
if mod then
t_insert(modList, {
label = essence.name .. " " .. "^8[" .. table.concat(mod, "/") .. "]" .. " (" .. mod.type .. ")",
mod = mod,
type = "custom",
essence = essence,
})
end
end
table.sort(modList, function(a, b)
if a.essence.type ~= b.essence.type then
Expand All @@ -3457,7 +3492,7 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
end)
elseif sourceId == "PREFIX" or sourceId == "SUFFIX" then
for _, mod in pairs(self.displayItem.affixes) do
if sourceId:lower() == mod.type:lower() and self.displayItem:GetModSpawnWeight(mod) > 0 then
if sourceId:lower() == (mod.type and mod.type:lower()) and self.displayItem:GetModSpawnWeight(mod) > 0 then
t_insert(modList, {
label = mod.affix .. " ^8[" .. table.concat(mod, "/") .. "]",
mod = mod,
Expand Down Expand Up @@ -3498,7 +3533,13 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
return a.defaultOrder < b.defaultOrder
end
end)
elseif sourceId == "INCURSION" then
buildDropRestricted(incursionDropOnlyCategories, data.itemMods.Explicit)
table.sort(modList, sortByPrefixSuffix)
elseif sourceId == "DELVE" then
buildDropRestricted(delveDropOnlyCategories, data.itemMods.Delve)
table.sort(modList, sortByPrefixSuffix)
elseif sourceId == "FOSSIL" then
for i, mod in pairs(self.displayItem.affixes) do
if self.displayItem:CheckIfModIsDelve(mod) and self.displayItem:GetModSpawnWeight(mod) > 0 then
t_insert(modList, {
Expand All @@ -3510,13 +3551,7 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
})
end
end
table.sort(modList, function(a, b)
if a.affixType ~= b.affixType then
return a.affixType == "Prefix" and b.affixType == "Suffix"
else
return a.defaultOrder < b.defaultOrder
end
end)
table.sort(modList, sortByPrefixSuffix)
elseif sourceId == "NECROPOLIS" then
for i, mod in pairs(self.build.data.necropolisMods) do
if self.displayItem:GetNecropolisModSpawnWeight(mod) > 0 then
Expand All @@ -3529,13 +3564,7 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
})
end
end
table.sort(modList, function(a, b)
if a.affixType ~= b.affixType then
return a.affixType == "Prefix" and b.affixType == "Suffix"
else
return a.defaultOrder < b.defaultOrder
end
end)
table.sort(modList, sortByPrefixSuffix)
elseif sourceId == "BEASTCRAFT" then
for i, mod in pairs(self.build.data.beastCraft) do
t_insert(modList, {
Expand All @@ -3546,13 +3575,7 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
defaultOrder = i,
})
end
table.sort(modList, function(a, b)
if a.affixType ~= b.affixType then
return a.affixType == "Prefix" and b.affixType == "Suffix"
else
return a.defaultOrder < b.defaultOrder
end
end)
table.sort(modList, sortByPrefixSuffix)
end
setDefaultSortOrder()
end
Expand All @@ -3569,7 +3592,9 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
t_insert(sourceList, { label = "Necropolis", sourceId = "NECROPOLIS"})
end
if not self.displayItem.clusterJewel and self.displayItem.type ~= "Flask" and self.displayItem.type ~= "Graft" then
t_insert(sourceList, { label = "Delve", sourceId = "DELVE"})
t_insert(sourceList, { label = "Fossil", sourceId = "FOSSIL" })
t_insert(sourceList, { label = "Delve Drop-restricted", sourceId = "DELVE" })
t_insert(sourceList, { label = "Incursion Drop-restricted", sourceId = "INCURSION" })
end
if not self.displayItem.crafted then
t_insert(sourceList, { label = "Prefix", sourceId = "PREFIX" })
Expand All @@ -3588,6 +3613,19 @@ function ItemsTabClass:AddCustomModifierToDisplayItem()
sourceList = newSourceList
end
end
-- test each category to see if they actually match any mods
-- TODO: given that we need to do this, it would be better to just keep a
-- list of matching mod ids, rather than building a list to check, and then
-- building it again when selecting it
local i = 1
while sourceList[i] do
buildMods(sourceList[i].sourceId)
if #modList == 0 then
table.remove(sourceList, i)
else
i = i + 1
end
end
t_insert(sourceList, { label = "Custom", sourceId = "CUSTOM" })
buildMods(sourceList[1].sourceId)
local function addModifier()
Expand Down
3 changes: 2 additions & 1 deletion src/Classes/TradeHelpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ function M.getTradeCategory(slotName, item)
elseif itemType == "Fishing Rod" then return "weapon.rod", "FishingRod"
elseif itemType == "One Handed Sword" then return "weapon.onesword", "1HSword"
elseif itemType == "One Handed Axe" then return "weapon.oneaxe", "1HAxe"
elseif itemType == "One Handed Mace" or itemType == "Sceptre" then return "weapon.onemace", "1HMace"
elseif itemType == "One Handed Mace" then return "weapon.onemace", "1HMace"
elseif itemType == "Sceptre" then return "weapon.sceptre", "Sceptre"
elseif itemType == "Wand" then return "weapon.wand", "Wand"
elseif itemType == "Dagger" then return "weapon.dagger", "Dagger"
elseif itemType == "Claw" then return "weapon.claw", "Claw"
Expand Down
32 changes: 30 additions & 2 deletions src/Classes/TradeQueryGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ local tradeCategoryNames = {
["1HSword"] = { "One Handed Sword", "One Handed Sword: Thrusting" },
["1HMace"] = { "One Handed Mace" },
["Sceptre"] = { "Sceptre" },
["Dagger"] = { "Dagger" },
["Dagger"] = { "Dagger", "Dagger: Rune Dagger" },
["Wand"] = { "Wand" },
["Claw"] = { "Claw" },
["Staff"] = { "Staff", "Staff: Warstaff" },
Expand Down Expand Up @@ -458,15 +458,43 @@ function TradeQueryGeneratorClass:InitMods()
{ ["AbyssJewel"] = true })
self:GenerateModData(data.itemMods.Flask, tradeQueryStatsParsed, { ["Flask"] = true })

-- translate base type name to trade category name for e.g. essences and drop-restricted mods
local function getTradeCategoryNamesForType(mask, cat)
for tradeName, typeNames in pairs(tradeCategoryNames) do
if tradeName == cat then
mask[tradeName] = true
end
for _, name in ipairs(typeNames) do
if cat == name then
mask[tradeName] = true
end
end
end
end

-- Special handling for essences
for _, essenceItem in pairs(data.essences) do
for itemType, modId in pairs(essenceItem.mods) do
local mask = {}
mask[itemType] = true
getTradeCategoryNamesForType(mask, itemType:gsub("Thrusting One Handed Sword", "One Handed Sword: Thrusting"))
self:ProcessMod(modId, data.itemMods.Item[modId], tradeQueryStatsParsed, regularItemMask, mask)
end
end

-- drop-restricted delve and temple mods
for _, list in ipairs({ require("Data.IncursionDropOnly"), require("Data.DelveDropOnly") }) do
for modId, entry in pairs(list) do
local mod = data.itemMods.Delve[modId] or data.itemMods.Explicit[modId]
local mask = {}
-- convert base type name to trade category
for _, cat in ipairs(entry.categories) do
getTradeCategoryNamesForType(mask, cat)
end
if next(mask) ~= nil then
self:ProcessMod(modId, mod, tradeQueryStatsParsed, regularItemMask, mask)
end
end
end
regularItemMask.Flask = true -- Update mask as flasks can have crafted mods.
self:GenerateModData(data.masterMods, tradeQueryStatsParsed, regularItemMask)
self:GenerateModData(data.veiledMods, tradeQueryStatsParsed, regularItemMask)
Expand Down
24 changes: 12 additions & 12 deletions src/Data/BeastCraft.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
-- Item data (c) Grinding Gear Games

return {
["GrantsCatAspectCrafted"] = { type = "Suffix", affix = "of Farrul", "Grants Level 20 Aspect of the Cat Skill", statOrder = { 711 }, level = 20, group = "GrantsCatAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [1265282021] = { "Grants Level 20 Aspect of the Cat Skill" }, } },
["GrantsBirdAspectCrafted"] = { type = "Suffix", affix = "of Saqawal", "Grants Level 20 Aspect of the Avian Skill", statOrder = { 705 }, level = 20, group = "GrantsBirdAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [3914740665] = { "Grants Level 20 Aspect of the Avian Skill" }, } },
["GrantsSpiderAspectCrafted"] = { type = "Suffix", affix = "of Fenumus", "Grants Level 20 Aspect of the Spider Skill", statOrder = { 740 }, level = 20, group = "GrantsSpiderAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [956546305] = { "Grants Level 20 Aspect of the Spider Skill" }, } },
["GrantsCrabAspectCrafted"] = { type = "Suffix", affix = "of Craiceann", "Grants Level 20 Aspect of the Crab Skill", statOrder = { 713 }, level = 20, group = "GrantsCrabAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "blue_herring", "skill" }, tradeHashes = { [4102318278] = { "Grants Level 20 Aspect of the Crab Skill" }, } },
["GrantsCatAspectCrafted30"] = { type = "Suffix", affix = "of Farrul", "Grants Level 30 Aspect of the Cat Skill", statOrder = { 711 }, level = 20, group = "GrantsCatAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [1265282021] = { "Grants Level 30 Aspect of the Cat Skill" }, } },
["GrantsBirdAspectCrafted30"] = { type = "Suffix", affix = "of Saqawal", "Grants Level 30 Aspect of the Avian Skill", statOrder = { 705 }, level = 20, group = "GrantsBirdAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [3914740665] = { "Grants Level 30 Aspect of the Avian Skill" }, } },
["GrantsSpiderAspectCrafted30"] = { type = "Suffix", affix = "of Fenumus", "Grants Level 30 Aspect of the Spider Skill", statOrder = { 740 }, level = 20, group = "GrantsSpiderAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [956546305] = { "Grants Level 30 Aspect of the Spider Skill" }, } },
["GrantsCrabAspectCrafted30"] = { type = "Suffix", affix = "of Craiceann", "Grants Level 30 Aspect of the Crab Skill", statOrder = { 713 }, level = 20, group = "GrantsCrabAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "blue_herring", "skill" }, tradeHashes = { [4102318278] = { "Grants Level 30 Aspect of the Crab Skill" }, } },
["GrantsBrineKingAspectCrafted"] = { type = "Suffix", affix = "of the Brine King", "Grants Level 20 Aspect of the Brine King Skill", statOrder = { 709 }, level = 20, group = "GrantsBrineKingAspect", weightKey = { "deepwater_pantheon_aspect", "default", }, weightVal = { 100, 0 }, modTags = { "skill" }, tradeHashes = { [3054487153] = { "Grants Level 20 Aspect of the Brine King Skill" }, } },
["GrantsLunarisAspectCrafted"] = { type = "Suffix", affix = "of Lunaris", "Grants Level 20 Aspect of Lunaris Skill", statOrder = { 730 }, level = 20, group = "GrantsLunarisAspect", weightKey = { "deepwater_pantheon_aspect", "default", }, weightVal = { 100, 0 }, modTags = { "skill" }, tradeHashes = { [937577116] = { "Grants Level 20 Aspect of Lunaris Skill" }, } },
["GrantsSolarisAspectCrafted"] = { type = "Suffix", affix = "of Solaris", "Grants Level 20 Aspect of Solaris Skill", statOrder = { 739 }, level = 20, group = "GrantsSolarisAspect", weightKey = { "deepwater_pantheon_aspect", "default", }, weightVal = { 100, 0 }, modTags = { "skill" }, tradeHashes = { [4280547417] = { "Grants Level 20 Aspect of Solaris Skill" }, } },
["GrantsArakaaliAspectCrafted"] = { type = "Suffix", affix = "of Arakaali", "Grants Level 20 Aspect of Arakaali Skill", statOrder = { 702 }, level = 20, group = "GrantsArakaaliAspect", weightKey = { "deepwater_pantheon_aspect", "default", }, weightVal = { 100, 0 }, modTags = { "skill" }, tradeHashes = { [1094971653] = { "Grants Level 20 Aspect of Arakaali Skill" }, } },
["GrantsCatAspectCrafted"] = { type = "Suffix", affix = "of Farrul", "Grants Level 20 Aspect of the Cat Skill", statOrder = { 712 }, level = 20, group = "GrantsCatAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [1265282021] = { "Grants Level 20 Aspect of the Cat Skill" }, } },
["GrantsBirdAspectCrafted"] = { type = "Suffix", affix = "of Saqawal", "Grants Level 20 Aspect of the Avian Skill", statOrder = { 706 }, level = 20, group = "GrantsBirdAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [3914740665] = { "Grants Level 20 Aspect of the Avian Skill" }, } },
["GrantsSpiderAspectCrafted"] = { type = "Suffix", affix = "of Fenumus", "Grants Level 20 Aspect of the Spider Skill", statOrder = { 741 }, level = 20, group = "GrantsSpiderAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [956546305] = { "Grants Level 20 Aspect of the Spider Skill" }, } },
["GrantsCrabAspectCrafted"] = { type = "Suffix", affix = "of Craiceann", "Grants Level 20 Aspect of the Crab Skill", statOrder = { 714 }, level = 20, group = "GrantsCrabAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "blue_herring", "skill" }, tradeHashes = { [4102318278] = { "Grants Level 20 Aspect of the Crab Skill" }, } },
["GrantsCatAspectCrafted30"] = { type = "Suffix", affix = "of Farrul", "Grants Level 30 Aspect of the Cat Skill", statOrder = { 712 }, level = 20, group = "GrantsCatAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [1265282021] = { "Grants Level 30 Aspect of the Cat Skill" }, } },
["GrantsBirdAspectCrafted30"] = { type = "Suffix", affix = "of Saqawal", "Grants Level 30 Aspect of the Avian Skill", statOrder = { 706 }, level = 20, group = "GrantsBirdAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [3914740665] = { "Grants Level 30 Aspect of the Avian Skill" }, } },
["GrantsSpiderAspectCrafted30"] = { type = "Suffix", affix = "of Fenumus", "Grants Level 30 Aspect of the Spider Skill", statOrder = { 741 }, level = 20, group = "GrantsSpiderAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "skill" }, tradeHashes = { [956546305] = { "Grants Level 30 Aspect of the Spider Skill" }, } },
["GrantsCrabAspectCrafted30"] = { type = "Suffix", affix = "of Craiceann", "Grants Level 30 Aspect of the Crab Skill", statOrder = { 714 }, level = 20, group = "GrantsCrabAspect", weightKey = { "default", }, weightVal = { 0 }, modTags = { "blue_herring", "skill" }, tradeHashes = { [4102318278] = { "Grants Level 30 Aspect of the Crab Skill" }, } },
["GrantsBrineKingAspectCrafted"] = { type = "Suffix", affix = "of the Brine King", "Grants Level 20 Aspect of the Brine King Skill", statOrder = { 710 }, level = 20, group = "GrantsBrineKingAspect", weightKey = { "deepwater_pantheon_aspect", "default", }, weightVal = { 100, 0 }, modTags = { "skill" }, tradeHashes = { [3054487153] = { "Grants Level 20 Aspect of the Brine King Skill" }, } },
["GrantsLunarisAspectCrafted"] = { type = "Suffix", affix = "of Lunaris", "Grants Level 20 Aspect of Lunaris Skill", statOrder = { 731 }, level = 20, group = "GrantsLunarisAspect", weightKey = { "deepwater_pantheon_aspect", "default", }, weightVal = { 100, 0 }, modTags = { "skill" }, tradeHashes = { [937577116] = { "Grants Level 20 Aspect of Lunaris Skill" }, } },
["GrantsSolarisAspectCrafted"] = { type = "Suffix", affix = "of Solaris", "Grants Level 20 Aspect of Solaris Skill", statOrder = { 740 }, level = 20, group = "GrantsSolarisAspect", weightKey = { "deepwater_pantheon_aspect", "default", }, weightVal = { 100, 0 }, modTags = { "skill" }, tradeHashes = { [4280547417] = { "Grants Level 20 Aspect of Solaris Skill" }, } },
["GrantsArakaaliAspectCrafted"] = { type = "Suffix", affix = "of Arakaali", "Grants Level 20 Aspect of Arakaali Skill", statOrder = { 703 }, level = 20, group = "GrantsArakaaliAspect", weightKey = { "deepwater_pantheon_aspect", "default", }, weightVal = { 100, 0 }, modTags = { "skill" }, tradeHashes = { [1094971653] = { "Grants Level 20 Aspect of Arakaali Skill" }, } },
}
Loading
Loading