@@ -23,74 +23,61 @@ local tradeCategoryNames = {
2323 [" Shield" ] = { " Shield" },
2424 [" Focus" ] = { " Focus" },
2525 [" 1HWeapon" ] = { " One Handed Mace" , " Wand" , " Sceptre" },
26- [" 2HWeapon" ] = { { " Staff" }, { " Staff" , " Warstaff" } , " Two Handed Mace" , " Crossbow" , " Bow" },
26+ [" 2HWeapon" ] = { " Staff" , " Staff: Warstaff" , " Two Handed Mace" , " Crossbow" , " Bow" },
2727 -- ["1HAxe"] = { "One Handed Axe" },
2828 -- ["1HSword"] = { "One Handed Sword", "Thrusting One Handed Sword" },
2929 [" 1HMace" ] = { " One Handed Mace" },
3030 [" Sceptre" ] = { " Sceptre" },
3131 -- ["Dagger"] = { "Dagger" },
3232 [" Wand" ] = { " Wand" },
3333 -- ["Claw"] = { "Claw" },
34- [" Staff" ] = { { " Staff" } },
35- [" Quarterstaff" ] = { { " Staff" , " Warstaff" } },
34+ [" Staff" ] = { " Staff" },
35+ [" Quarterstaff" ] = { " Staff: Warstaff" },
3636 [" Bow" ] = { " Bow" },
3737 [" Crossbow" ] = { " Crossbow" },
3838 -- ["2HAxe"] = { "Two Handed Axe" },
3939 -- ["2HSword"] = { "Two Handed Sword" },
4040 [" 2HMace" ] = { " Two Handed Mace" },
4141 -- ["FishingRod"] = { "Fishing Rod" },
42- [" BaseJewel" ] = { { " Jewel" } },
43- [" AnyJewel" ] = { { " Jewel" } },
44- [" LifeFlask" ] = { { " Flask" , " Life" } },
45- [" ManaFlask" ] = { { " Flask" , " Mana" } },
42+ [" BaseJewel" ] = { " Jewel" },
43+ [" AnyJewel" ] = { " Jewel" },
44+ [" LifeFlask" ] = { " Flask: Life" },
45+ [" ManaFlask" ] = { " Flask: Mana" },
4646 [" Charm" ] = { " Charm" },
4747 -- doesn't have trade mods
48- -- ["RadiusJewel"] = { { "Jewel", " Radius"} },
48+ -- ["RadiusJewel"] = { "Jewel: Radius" },
4949 -- not in the game yet.
5050 -- ["TrapTool"] = { "TrapTool"}, Unsure if correct
5151 -- ["Flail"] = { "Flail" },
5252 -- ["Spear"] = { "Spear" }
5353}
5454
55- -- TODO generate these from data files
56- local tradeCategoryTags = {
57- [" Ring" ] = { [" ring" ] = true },
58- [" Amulet" ] = { [" amulet" ] = true },
59- [" Belt" ] = { [" belt" ] = true },
60- [" Body Armour" ] = { [" body_armour" ] = true , [" str_armour" ] = true , [" dex_armour" ] = true , [" int_armour" ] = true , [" str_int_armour" ] = true , [" str_dex_armour" ] = true , [" str_dex_int_armour" ] = true },
61- [" Helmet" ] = { [" helmet" ] = true , [" str_armour" ] = true , [" dex_armour" ] = true , [" int_armour" ] = true , [" str_int_armour" ] = true , [" str_dex_armour" ] = true , [" str_dex_int_armour" ] = true },
62- [" Gloves" ] = { [" gloves" ] = true , [" str_armour" ] = true , [" dex_armour" ] = true , [" int_armour" ] = true , [" str_int_armour" ] = true , [" str_dex_armour" ] = true , [" str_dex_int_armour" ] = true },
63- [" Boots" ] = { [" boots" ] = true , [" str_armour" ] = true , [" dex_armour" ] = true , [" int_armour" ] = true , [" str_int_armour" ] = true , [" str_dex_armour" ] = true , [" str_dex_int_armour" ] = true },
64- [" Quiver" ] = { [" quiver" ] = true },
65- [" Shield" ] = { [" shield" ] = true , [" energy_shield" ] = true , [" dex_shield" ] = true , [" str_shield" ] = true , [" str_int_shield" ] = true , [" dex_int_shield" ] = true , [" str_dex_shield" ] = true },
66- -- ["1HAxe"] = { ["weapon"] = true, ["one_hand_weapon"] = true, ["onehand"] = true, ["axe"] = true},
67- -- ["1HSword"] = { ["weapon"] = true, ["one_hand_weapon"] = true, ["onehand"] = true, ["sword"] = true, ["rapier"] = true },
68- [" One Handed Mace" ] = { [" weapon" ] = true , [" one_hand_weapon" ] = true , [" onehand" ] = true , [" mace" ] = true },
69- [" Sceptre" ] = { [" onehand" ] = true , [" sceptre" ] = true },
70- -- ["Dagger"] = { ["weapon"] = true, ["one_hand_weapon"] = true, ["onehand"] = true, ["attack_dagger"] = true, ["dagger"] = true, ["rune_dagger"] = true },
71- [" Wand" ] = { [" weapon" ] = true , [" one_hand_weapon" ] = true , [" onehand" ] = true , [" wand" ] = true },
72- -- ["Claw"] = { ["weapon"] = true, ["one_hand_weapon"] = true, ["onehand"] = true, ["claw"] = true },
73- [table.concat (tradeCategoryNames .Staff [1 ],' \0 ' )] = { [" twohand" ] = true , [" staff" ] = true , },
74- [table.concat (tradeCategoryNames .Quarterstaff [1 ],' \0 ' )] = { [" weapon" ] = true , [" two_hand_weapon" ] = true , [" twohand" ] = true , [" warstaff" ] = true },
75- [" Bow" ] = { [" weapon" ] = true , [" two_hand_weapon" ] = true , [" twohand" ] = true , [" bow" ] = true },
76- -- ["2HAxe"] = { ["weapon"] = true, ["two_hand_weapon"] = true, ["twohand"] = true, ["axe"] = true },
77- -- ["2HSword"] = { ["weapon"] = true, ["two_hand_weapon"] = true, ["twohand"] = true, ["sword"] = true },
78- [" Two Handed Mace" ] = { [" weapon" ] = true , [" two_hand_weapon" ] = true , [" twohand" ] = true , [" mace" ] = true },
79- -- ["FishingRod"] = { ["fishing_rod"] = true },
80- [" Focus" ] = { [" focus" ] = true },
81- [" Crossbow" ] = { [" crossbow" ] = true },
82- [table.concat (tradeCategoryNames .BaseJewel [1 ],' \0 ' )] = { [" jewel" ] = true , [" strjewel" ] = true , [" dexjewel" ] = true , [" intjewel" ] = true },
83- [table.concat (tradeCategoryNames .LifeFlask [1 ],' \0 ' )] = { [" flask" ] = true , [" life_flask" ] = true },
84- [table.concat (tradeCategoryNames .ManaFlask [1 ],' \0 ' )] = { [" flask" ] = true , [" mana_flask" ] = true },
85- [" Charm" ] = { [" flask" ] = true , [" utility_flask" ] = true },
86- -- doesn't have trade mod and incorrect mod formatting
87- -- ["RadiusJewel"] = { ["jewel"] = true, ["radius_jewel"] = true, ["str_radius_jewel"] = true, ["dex_radius_jewel"] = true, ["int_radius_jewel"] = true },
88- -- not in the game yet.
89- -- ["TrapTool"] = { ["trap"] = true},
90- -- ["Flail"] = { ["flail"] = true},
91- -- ["Spear"] = { ["spear"] = true}
92-
93- }
55+ -- Build lists of tags present on a given item category
56+ local tradeCategoryTags = { }
57+ for type , bases in pairs (data .itemBaseLists ) do
58+ for _ , base in ipairs (bases ) do
59+ if not base .hidden then
60+ if not tradeCategoryTags [type ] then
61+ tradeCategoryTags [type ] = { }
62+ end
63+ local baseTags = { }
64+ for tag , _ in pairs (base .base .tags ) do
65+ if tag ~= " default" and tag ~= " demigods" and not tag :match (" _basetype" ) and tag ~= " not_for_sale" then -- filter fluff tags not used on mods.
66+ baseTags [tag ] = true
67+ end
68+ end
69+ local present = false
70+ for i , tags in ipairs (tradeCategoryTags [type ]) do
71+ if tableDeepEquals (baseTags , tags ) then
72+ present = true
73+ end
74+ end
75+ if not present then
76+ t_insert (tradeCategoryTags [type ], baseTags )
77+ end
78+ end
79+ end
80+ end
9481
9582local tradeStatCategoryIndices = {
9683 [" Explicit" ] = 1 ,
@@ -129,13 +116,14 @@ end
129116
130117local function canModSpawnForItemCategory (mod , names )
131118 for _ , name in pairs (tradeCategoryNames [names ]) do
132- local tags = tradeCategoryTags [type (name ) == " table" and table.concat (name ,' \0 ' ) or name ]
133- for i , key in ipairs (mod .weightKey ) do
134- if tags [key ] == true then
135- if mod .weightVal [i ] > 0 then
136- return true
137- else
138- break
119+ for _ , tags in ipairs (tradeCategoryTags [name ]) do
120+ for i , key in ipairs (mod .weightKey ) do
121+ if tags [key ] then
122+ if mod .weightVal [i ] > 0 then
123+ return true
124+ else
125+ break
126+ end
139127 end
140128 end
141129 end
@@ -405,7 +393,11 @@ function TradeQueryGeneratorClass:InitMods()
405393 local maskOverride = {}
406394 for tradeName , typeNames in pairs (tradeCategoryNames ) do
407395 for _ , typeName in ipairs (typeNames ) do
408- if type (typeName ) == " table" and typeName [2 ] == entry .subType and typeName [1 ] == entry .type or typeName == entry .type then
396+ local entryName = entry .type
397+ if entry .subType then
398+ entryName = entryName .. " : " .. entry .subType
399+ end
400+ if typeName == entryName then
409401 maskOverride [tradeName ] = true ;
410402 break
411403 end
0 commit comments