Skip to content

Commit 9e36b00

Browse files
authored
Fix user-friendly job names so that they are the same as in the manager menu
- Add support for ConstructBoltThrowerParts (job 245) for new siege weapon - Fix bags using wrong job type: ConstructBag instead of ConstructChest - Add encrust finished goods, furniture, ammo with gems, glass and stones (with material) - Update "Make" to "Construct"
1 parent dd60bf2 commit 9e36b00

File tree

1 file changed

+123
-104
lines changed

1 file changed

+123
-104
lines changed

internal/quickfort/stockflow.lua

Lines changed: 123 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,33 @@ function collect_reactions()
8888
-- Caching the enumeration might not be important, but saves lookups.
8989
local job_types = df.job_type
9090

91+
-- Materials that have dedicated definitions
92+
local material_names = {"wood", "cloth", "leather", "silk", "yarn", "bone", "shell", "tooth", "horn", "pearl"}
93+
-- Additional flags used by game but without dedicated materials
94+
local extra_material_flags = {"plant", "soap", "strand", "wood2"}
95+
96+
local function make_material_category(active_flag)
97+
local cat = {}
98+
for _, flag in ipairs(material_names) do
99+
cat[flag] = (flag == active_flag)
100+
end
101+
for _, flag in ipairs(extra_material_flags) do
102+
cat[flag] = false
103+
end
104+
return cat
105+
end
106+
91107
local materials = {
92108
rock = {
93109
adjective = "rock",
94110
management = {mat_type = 0},
95111
},
96112
}
97113

98-
for _, name in ipairs{"wood", "cloth", "leather", "silk", "yarn", "bone", "shell", "tooth", "horn", "pearl"} do
114+
for _, name in ipairs(material_names) do
99115
materials[name] = {
100116
adjective = name,
101-
management = {material_category = {[name] = true}},
117+
management = {material_category = make_material_category(name)},
102118
}
103119
end
104120

@@ -115,7 +131,28 @@ function collect_reactions()
115131
reaction_entry(result, job_types.CatchLiveLandAnimal)
116132
reaction_entry(result, job_types.CatchLiveFish)
117133

134+
-- Helper function for encrusting reactions
135+
local function add_encrust_reactions(job_type, material_desc, base_values)
136+
for _, variant in ipairs{
137+
{flag='finished_goods', name='Finished Goods'},
138+
{flag='furniture', name='Furniture'},
139+
{flag='ammo', name='Ammo'},
140+
} do
141+
local values = {}
142+
if base_values then
143+
if base_values.mat_type then values.mat_type = base_values.mat_type end
144+
if base_values.mat_index then values.mat_index = base_values.mat_index end
145+
end
146+
values.specflag = {encrust_flags={[variant.flag]=true}}
147+
reaction_entry(result, job_type, values, 'Encrust ' .. variant.name .. ' With ' .. material_desc)
148+
end
149+
end
150+
118151
-- Cutting, encrusting, and metal extraction.
152+
reaction_entry(result, job_types.CutGems, nil, 'Cut Gems')
153+
add_encrust_reactions(job_types.EncrustWithGems, 'Cut Gems')
154+
add_encrust_reactions(job_types.EncrustWithStones, 'Polished Stones')
155+
119156
local rock_types = df.global.world.raws.inorganics.all
120157
for rock_id = #rock_types-1, 0, -1 do
121158
local material = rock_types[rock_id].material
@@ -126,23 +163,15 @@ function collect_reactions()
126163
mat_index = rock_id,
127164
}, "Cut "..rock_name)
128165

129-
reaction_entry(result, job_types.EncrustWithGems, {
130-
mat_type = 0,
131-
mat_index = rock_id,
132-
specflag = {encrust_flags={finished_goods=true}},
133-
}, "Encrust Finished Goods With "..rock_name)
134-
135-
reaction_entry(result, job_types.EncrustWithGems, {
136-
mat_type = 0,
137-
mat_index = rock_id,
138-
specflag = {encrust_flags={furniture=true}},
139-
}, "Encrust Furniture With "..rock_name)
166+
-- Encrust with cut gems
167+
if material.flags.IS_GEM then
168+
add_encrust_reactions(job_types.EncrustWithGems, rock_name, {mat_type = 0, mat_index = rock_id})
169+
end
140170

141-
reaction_entry(result, job_types.EncrustWithGems, {
142-
mat_type = 0,
143-
mat_index = rock_id,
144-
specflag = {encrust_flags={ammo=true}},
145-
}, "Encrust Ammo With "..rock_name)
171+
-- Encrust with polished stones
172+
if material.flags.IS_STONE and not material.flags.IS_GEM then
173+
add_encrust_reactions(job_types.EncrustWithStones, rock_name, {mat_type = 0, mat_index = rock_id})
174+
end
146175
end
147176

148177
if #rock_types[rock_id].metal_ore.mat_index > 0 then
@@ -156,6 +185,8 @@ function collect_reactions()
156185

157186
-- Glass cutting and encrusting, with different job numbers.
158187
-- We could search the entire table, but glass is less subject to raws.
188+
add_encrust_reactions(job_types.EncrustWithGlass, 'Cut Glass')
189+
159190
local glass_types = df.global.world.raws.mat_table.builtin
160191
local glasses = {}
161192
for glass_id = 3, 5 do
@@ -170,20 +201,7 @@ function collect_reactions()
170201

171202
reaction_entry(result, job_types.CutGlass, {mat_type = glass_id}, "Cut "..glass_name)
172203

173-
reaction_entry(result, job_types.EncrustWithGlass, {
174-
mat_type = glass_id,
175-
specflag = {encrust_flags={finished_goods=true}},
176-
}, "Encrust Finished Goods With "..glass_name)
177-
178-
reaction_entry(result, job_types.EncrustWithGlass, {
179-
mat_type = glass_id,
180-
specflag = {encrust_flags={furniture=true}},
181-
}, "Encrust Furniture With "..glass_name)
182-
183-
reaction_entry(result, job_types.EncrustWithGlass, {
184-
mat_type = glass_id,
185-
specflag = {encrust_flags={ammo=true}},
186-
}, "Encrust Ammo With "..glass_name)
204+
add_encrust_reactions(job_types.EncrustWithGlass, glass_name, {mat_type = glass_id})
187205
end
188206
end
189207

@@ -228,7 +246,7 @@ function collect_reactions()
228246
reaction_entry(result, job_types.PrepareRawFish)
229247
reaction_entry(result, job_types.MakeCheese)
230248
reaction_entry(result, job_types.MilkCreature)
231-
reaction_entry(result, job_types.ShearCreature)
249+
reaction_entry(result, job_types.ShearCreature, nil, 'Shear Animal')
232250
reaction_entry(result, job_types.SpinThread, {material_category = {strand = true}})
233251
reaction_entry(result, job_types.MakeLye)
234252
reaction_entry(result, job_types.ProcessPlants)
@@ -335,31 +353,31 @@ function collect_reactions()
335353

336354
if material.flags.ITEMS_HARD then
337355
material_reactions(result, {
338-
{job_types.ConstructDoor, "Construct", "Door"},
339-
{job_types.ConstructFloodgate, "Construct", "Floodgate"},
340-
{job_types.ConstructHatchCover, "Construct", "Hatch Cover"},
341-
{job_types.ConstructGrate, "Construct", "Grate"},
342-
{job_types.ConstructThrone, "Construct", "Throne"},
343-
{job_types.ConstructCoffin, "Construct", "Sarcophagus"},
344-
{job_types.ConstructTable, "Construct", "Table"},
345-
{job_types.ConstructSplint, "Construct", "Splint"},
346-
{job_types.ConstructCrutch, "Construct", "Crutch"},
347-
{job_types.ConstructArmorStand, "Construct", "Armor Stand"},
348-
{job_types.ConstructWeaponRack, "Construct", "Weapon Rack"},
349-
{job_types.ConstructCabinet, "Construct", "Cabinet"},
356+
{job_types.ConstructDoor, "Make", "Door"},
357+
{job_types.ConstructFloodgate, "Make", "Floodgate"},
358+
{job_types.ConstructHatchCover, "Make", "Hatch Cover"},
359+
{job_types.ConstructGrate, "Make", "Grate"},
360+
{job_types.ConstructThrone, "Make", "Throne"},
361+
{job_types.ConstructCoffin, "Make", "Sarcophagus"},
362+
{job_types.ConstructTable, "Make", "Table"},
363+
{job_types.ConstructSplint, "Make", "Splint"},
364+
{job_types.ConstructCrutch, "Make", "Crutch"},
365+
{job_types.ConstructArmorStand, "Make", "Armor Stand"},
366+
{job_types.ConstructWeaponRack, "Make", "Weapon Rack"},
367+
{job_types.ConstructCabinet, "Make", "Cabinet"},
350368
{job_types.MakeGoblet, "Forge", "Goblet"},
351369
{job_types.MakeInstrument, "Forge", "Instrument"},
352370
{job_types.MakeToy, "Forge", "Toy"},
353-
{job_types.ConstructStatue, "Construct", "Statue"},
354-
{job_types.ConstructBlocks, "Construct", "Blocks"},
371+
{job_types.ConstructStatue, "Make", "Statue"},
372+
{job_types.ConstructBlocks, "Make", "Blocks"},
355373
{job_types.MakeAnimalTrap, "Forge", "Animal Trap"},
356374
{job_types.MakeBarrel, "Forge", "Barrel"},
357375
{job_types.MakeBucket, "Forge", "Bucket"},
358-
{job_types.ConstructBin, "Construct", "Bin"},
376+
{job_types.ConstructBin, "Make", "Bin"},
359377
{job_types.MakePipeSection, "Forge", "Pipe Section"},
360378
{job_types.MakeCage, "Forge", "Cage"},
361379
{job_types.MintCoins, "Mint", "Coins"},
362-
{job_types.ConstructChest, "Construct", "Chest"},
380+
{job_types.ConstructChest, "Make", "Chest"},
363381
{job_types.MakeFlask, "Forge", "Flask"},
364382
{job_types.MakeChain, "Forge", "Chain"},
365383
{job_types.MakeCrafts, "Make", "Crafts"},
@@ -371,16 +389,16 @@ function collect_reactions()
371389
{job_types.MakeEarring, "Make", "Earring"},
372390
{job_types.MakeBracelet, "Make", "Bracelet"},
373391
{job_types.MakeGem, "Make Large", "Gem"},
374-
{job_types.ConstructMechanisms, "Construct", "Mechanisms"},
392+
{job_types.ConstructMechanisms, "Make", "Mechanisms"},
375393
}, mat_flags)
376394
end
377395

378396
if material.flags.ITEMS_SOFT then
379397
material_reactions(result, {
380398
{job_types.MakeBackpack, "Make", "Backpack"},
381399
{job_types.MakeQuiver, "Make", "Quiver"},
382-
{job_types.ConstructCatapultParts, "Construct", "Catapult Parts"},
383-
{job_types.ConstructBallistaParts, "Construct", "Ballista Parts"},
400+
{job_types.ConstructCatapultParts, "Make", "Catapult Parts"},
401+
{job_types.ConstructBallistaParts, "Make", "Ballista Parts"},
384402
}, mat_flags)
385403
end
386404
end
@@ -408,16 +426,16 @@ function collect_reactions()
408426
-- Wooden items
409427
-- Closely related to the ITEMS_HARD list.
410428
material_reactions(result, {
411-
{job_types.ConstructDoor, "Construct", "Door"},
412-
{job_types.ConstructFloodgate, "Construct", "Floodgate"},
413-
{job_types.ConstructHatchCover, "Construct", "Hatch Cover"},
414-
{job_types.ConstructGrate, "Construct", "Grate"},
415-
{job_types.ConstructThrone, "Construct", "Chair"},
416-
{job_types.ConstructCoffin, "Construct", "Casket"},
417-
{job_types.ConstructTable, "Construct", "Table"},
418-
{job_types.ConstructArmorStand, "Construct", "Armor Stand"},
419-
{job_types.ConstructWeaponRack, "Construct", "Weapon Rack"},
420-
{job_types.ConstructCabinet, "Construct", "Cabinet"},
429+
{job_types.ConstructDoor, "Make", "Door"},
430+
{job_types.ConstructFloodgate, "Make", "Floodgate"},
431+
{job_types.ConstructHatchCover, "Make", "Hatch Cover"},
432+
{job_types.ConstructGrate, "Make", "Grate"},
433+
{job_types.ConstructThrone, "Make", "Chair"},
434+
{job_types.ConstructCoffin, "Make", "Casket"},
435+
{job_types.ConstructTable, "Make", "Table"},
436+
{job_types.ConstructArmorStand, "Make", "Armor Stand"},
437+
{job_types.ConstructWeaponRack, "Make", "Weapon Rack"},
438+
{job_types.ConstructCabinet, "Make", "Cabinet"},
421439
{job_types.MakeGoblet, "Make", "Cup"},
422440
{job_types.MakeInstrument, "Make", "Instrument"},
423441
}, materials.wood)
@@ -430,13 +448,13 @@ function collect_reactions()
430448

431449
material_reactions(result, {
432450
{job_types.MakeToy, "Make", "Toy"},
433-
{job_types.ConstructBlocks, "Construct", "Blocks"},
434-
{job_types.ConstructSplint, "Construct", "Splint"},
435-
{job_types.ConstructCrutch, "Construct", "Crutch"},
451+
{job_types.ConstructBlocks, "Make", "Blocks"},
452+
{job_types.ConstructSplint, "Make", "Splint"},
453+
{job_types.ConstructCrutch, "Make", "Crutch"},
436454
{job_types.MakeAnimalTrap, "Make", "Animal Trap"},
437455
{job_types.MakeBarrel, "Make", "Barrel"},
438456
{job_types.MakeBucket, "Make", "Bucket"},
439-
{job_types.ConstructBin, "Construct", "Bin"},
457+
{job_types.ConstructBin, "Make", "Bin"},
440458
{job_types.MakeCage, "Make", "Cage"},
441459
{job_types.MakePipeSection, "Make", "Pipe Section"},
442460
}, materials.wood)
@@ -448,16 +466,16 @@ function collect_reactions()
448466

449467
-- Rock items
450468
material_reactions(result, {
451-
{job_types.ConstructDoor, "Construct", "Door"},
452-
{job_types.ConstructFloodgate, "Construct", "Floodgate"},
453-
{job_types.ConstructHatchCover, "Construct", "Hatch Cover"},
454-
{job_types.ConstructGrate, "Construct", "Grate"},
455-
{job_types.ConstructThrone, "Construct", "Throne"},
456-
{job_types.ConstructCoffin, "Construct", "Coffin"},
457-
{job_types.ConstructTable, "Construct", "Table"},
458-
{job_types.ConstructArmorStand, "Construct", "Armor Stand"},
459-
{job_types.ConstructWeaponRack, "Construct", "Weapon Rack"},
460-
{job_types.ConstructCabinet, "Construct", "Cabinet"},
469+
{job_types.ConstructDoor, "Make", "Door"},
470+
{job_types.ConstructFloodgate, "Make", "Floodgate"},
471+
{job_types.ConstructHatchCover, "Make", "Hatch Cover"},
472+
{job_types.ConstructGrate, "Make", "Grate"},
473+
{job_types.ConstructThrone, "Make", "Throne"},
474+
{job_types.ConstructCoffin, "Make", "Coffin"},
475+
{job_types.ConstructTable, "Make", "Table"},
476+
{job_types.ConstructArmorStand, "Make", "Armor Stand"},
477+
{job_types.ConstructWeaponRack, "Make", "Weapon Rack"},
478+
{job_types.ConstructCabinet, "Make", "Cabinet"},
461479
{job_types.MakeGoblet, "Make", "Mug"},
462480
{job_types.MakeInstrument, "Make", "Instrument"},
463481
}, materials.rock)
@@ -469,26 +487,26 @@ function collect_reactions()
469487

470488
material_reactions(result, {
471489
{job_types.MakeToy, "Make", "Toy"},
472-
{job_types.ConstructQuern, "Construct", "Quern"},
473-
{job_types.ConstructMillstone, "Construct", "Millstone"},
474-
{job_types.ConstructSlab, "Construct", "Slab"},
475-
{job_types.ConstructStatue, "Construct", "Statue"},
476-
{job_types.ConstructBlocks, "Construct", "Blocks"},
490+
{job_types.ConstructQuern, "Make", "Quern"},
491+
{job_types.ConstructMillstone, "Make", "Millstone"},
492+
{job_types.ConstructSlab, "Make", "Slab"},
493+
{job_types.ConstructStatue, "Make", "Statue"},
494+
{job_types.ConstructBlocks, "Make", "Blocks"},
477495
}, materials.rock)
478496

479497
-- Glass items
480498
for _, mat_info in ipairs(glasses) do
481499
material_reactions(result, {
482-
{job_types.ConstructDoor, "Construct", "Portal"},
483-
{job_types.ConstructFloodgate, "Construct", "Floodgate"},
484-
{job_types.ConstructHatchCover, "Construct", "Hatch Cover"},
485-
{job_types.ConstructGrate, "Construct", "Grate"},
486-
{job_types.ConstructThrone, "Construct", "Throne"},
487-
{job_types.ConstructCoffin, "Construct", "Coffin"},
488-
{job_types.ConstructTable, "Construct", "Table"},
489-
{job_types.ConstructArmorStand, "Construct", "Armor Stand"},
490-
{job_types.ConstructWeaponRack, "Construct", "Weapon Rack"},
491-
{job_types.ConstructCabinet, "Construct", "Cabinet"},
500+
{job_types.ConstructDoor, "Make", "Portal"},
501+
{job_types.ConstructFloodgate, "Make", "Floodgate"},
502+
{job_types.ConstructHatchCover, "Make", "Hatch Cover"},
503+
{job_types.ConstructGrate, "Make", "Grate"},
504+
{job_types.ConstructThrone, "Make", "Throne"},
505+
{job_types.ConstructCoffin, "Make", "Coffin"},
506+
{job_types.ConstructTable, "Make", "Table"},
507+
{job_types.ConstructArmorStand, "Make", "Armor Stand"},
508+
{job_types.ConstructWeaponRack, "Make", "Weapon Rack"},
509+
{job_types.ConstructCabinet, "Make", "Cabinet"},
492510
{job_types.MakeGoblet, "Make", "Goblet"},
493511
{job_types.MakeInstrument, "Make", "Instrument"},
494512
}, mat_info)
@@ -500,8 +518,8 @@ function collect_reactions()
500518

501519
material_reactions(result, {
502520
{job_types.MakeToy, "Make", "Toy"},
503-
{job_types.ConstructStatue, "Construct", "Statue"},
504-
{job_types.ConstructBlocks, "Construct", "Blocks"},
521+
{job_types.ConstructStatue, "Make", "Statue"},
522+
{job_types.ConstructBlocks, "Make", "Blocks"},
505523
{job_types.MakeCage, "Make", "Terrarium"},
506524
{job_types.MakePipeSection, "Make", "Tube"},
507525
}, mat_info)
@@ -512,7 +530,7 @@ function collect_reactions()
512530
end
513531

514532
-- Bed, specified as wooden.
515-
reaction_entry(result, job_types.ConstructBed, materials.wood.management)
533+
reaction_entry(result, job_types.ConstructBed, materials.wood.management, 'Make Bed')
516534

517535
-- Windows
518536
for _, mat_info in ipairs(glasses) do
@@ -522,7 +540,7 @@ function collect_reactions()
522540
end
523541

524542
-- Rock Mechanisms
525-
reaction_entry(result, job_types.ConstructMechanisms, materials.rock.management)
543+
reaction_entry(result, job_types.ConstructMechanisms, materials.rock.management, 'Make Rock Mechanisms')
526544

527545
resource_reactions(result, job_types.AssembleSiegeAmmo, materials.wood, entity.resources.siegeammo_type, itemdefs.siege_ammo, {
528546
verb = "Assemble",
@@ -545,16 +563,16 @@ function collect_reactions()
545563

546564
-- Boxes, Bags, and Ropes
547565
local boxmats = {
548-
{mats = {materials.wood}, box = "Chest"},
549-
{mats = {materials.rock}, box = "Coffer"},
550-
{mats = glasses, box = "Box", flask = "Vial"},
551-
{mats = {materials.cloth}, box = "Bag", chain = "Rope"},
552-
{mats = {materials.leather}, box = "Bag", flask = "Waterskin"},
553-
{mats = {materials.silk, materials.yarn}, box = "Bag", chain = "Rope"},
566+
{mats = {materials.wood}, box = "Chest", job = job_types.ConstructChest},
567+
{mats = {materials.rock}, box = "Coffer", job = job_types.ConstructChest},
568+
{mats = glasses, box = "Box", flask = "Vial", job = job_types.ConstructChest},
569+
{mats = {materials.cloth}, box = "Bag", chain = "Rope", job = job_types.ConstructBag},
570+
{mats = {materials.leather}, box = "Bag", flask = "Waterskin", job = job_types.ConstructBag},
571+
{mats = {materials.silk, materials.yarn}, box = "Bag", chain = "Rope", job = job_types.ConstructBag},
554572
}
555573
for _, boxmat in ipairs(boxmats) do
556574
for _, mat in ipairs(boxmat.mats) do
557-
material_reactions(result, {{job_types.ConstructChest, "Construct", boxmat.box}}, mat)
575+
material_reactions(result, {{boxmat.job, "Make", boxmat.box}}, mat)
558576
if boxmat.chain then
559577
material_reactions(result, {{job_types.MakeChain, "Make", boxmat.chain}}, mat)
560578
end
@@ -602,8 +620,9 @@ function collect_reactions()
602620
end
603621

604622
-- Siege engine parts
605-
reaction_entry(result, job_types.ConstructCatapultParts, materials.wood.management)
606-
reaction_entry(result, job_types.ConstructBallistaParts, materials.wood.management)
623+
reaction_entry(result, job_types.ConstructCatapultParts, materials.wood.management, 'Make Catapult Parts')
624+
reaction_entry(result, job_types.ConstructBallistaParts, materials.wood.management, 'Make Ballista Parts')
625+
reaction_entry(result, job_types.ConstructBoltThrowerParts, materials.wood.management, 'Make Bolt Thrower Parts')
607626

608627
for _, mat in ipairs{materials.wood, materials.bone} do
609628
resource_reactions(result, job_types.MakeAmmo, mat, entity.resources.ammo_type, itemdefs.ammo, {

0 commit comments

Comments
 (0)