@@ -23,74 +23,61 @@ local tradeCategoryNames = {
23
23
[" Shield" ] = { " Shield" },
24
24
[" Focus" ] = { " Focus" },
25
25
[" 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" },
27
27
-- ["1HAxe"] = { "One Handed Axe" },
28
28
-- ["1HSword"] = { "One Handed Sword", "Thrusting One Handed Sword" },
29
29
[" 1HMace" ] = { " One Handed Mace" },
30
30
[" Sceptre" ] = { " Sceptre" },
31
31
-- ["Dagger"] = { "Dagger" },
32
32
[" Wand" ] = { " Wand" },
33
33
-- ["Claw"] = { "Claw" },
34
- [" Staff" ] = { { " Staff" } },
35
- [" Quarterstaff" ] = { { " Staff" , " Warstaff" } },
34
+ [" Staff" ] = { " Staff" },
35
+ [" Quarterstaff" ] = { " Staff: Warstaff" },
36
36
[" Bow" ] = { " Bow" },
37
37
[" Crossbow" ] = { " Crossbow" },
38
38
-- ["2HAxe"] = { "Two Handed Axe" },
39
39
-- ["2HSword"] = { "Two Handed Sword" },
40
40
[" 2HMace" ] = { " Two Handed Mace" },
41
41
-- ["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" },
46
46
[" Charm" ] = { " Charm" },
47
47
-- doesn't have trade mods
48
- -- ["RadiusJewel"] = { { "Jewel", " Radius"} },
48
+ -- ["RadiusJewel"] = { "Jewel: Radius" },
49
49
-- not in the game yet.
50
50
-- ["TrapTool"] = { "TrapTool"}, Unsure if correct
51
51
-- ["Flail"] = { "Flail" },
52
52
-- ["Spear"] = { "Spear" }
53
53
}
54
54
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
94
81
95
82
local tradeStatCategoryIndices = {
96
83
[" Explicit" ] = 1 ,
@@ -129,13 +116,14 @@ end
129
116
130
117
local function canModSpawnForItemCategory (mod , names )
131
118
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
139
127
end
140
128
end
141
129
end
@@ -405,7 +393,11 @@ function TradeQueryGeneratorClass:InitMods()
405
393
local maskOverride = {}
406
394
for tradeName , typeNames in pairs (tradeCategoryNames ) do
407
395
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
409
401
maskOverride [tradeName ] = true ;
410
402
break
411
403
end
0 commit comments