Skip to content

Commit 04ea7b8

Browse files
committed
idle-crafting: also support making shell crafts for workshops with linked input stockpiles
1 parent 7b8addd commit 04ea7b8

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Template for new versions:
7272
- `exterminate`: show descriptive names for the listed races in addition to their IDs
7373
- `exterminate`: show actual names for unique creatures such as forgotten beasts and titans
7474
- `fix/ownership`: now also checks and fixes room ownership links
75+
- `idle-crafting`: also support making shell crafts for workshops with linked input stockpiles
7576

7677
## Documentation
7778
- `gui/embark-anywhere`: add information about how the game determines world tile pathability and instructions for bridging two landmasses

docs/idle-crafting.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ supported, with stonecrafting being the default option. Thus, to designate a
5454
workshop for bone carving, disable the stonecrafting labor while keeping the
5555
bone carving labor enabled.
5656

57-
For workshops with input stockpile links, the creation of totems and horn crafts
58-
are supported as well. In this case, the choice of job is made randomly based on
59-
the resources available in the input stockpiles (respecting the permitted
60-
labors from the workshop profile).
57+
For workshops with input stockpile links, the creation of totems, shell crafts.
58+
and horn crafts are supported as well. In this case, the choice of job is made
59+
randomly based on the resources available in the input stockpiles (respecting
60+
the permitted labors from the workshop profile).

idle-crafting.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,31 @@ function makeBoneCraft(unit, workshop)
143143
return dfhack.job.addWorker(job, unit)
144144
end
145145

146+
---make shell crafts at specified workshop
147+
---@param unit df.unit
148+
---@param workshop df.building_workshopst
149+
---@return boolean
150+
function makeShellCraft(unit, workshop)
151+
local job = make_job()
152+
job.job_type = df.job_type.MakeCrafts
153+
job.mat_type = -1
154+
job.material_category.shell = true
155+
156+
local jitem = df.job_item:new()
157+
jitem.item_type = df.item_type.NONE
158+
jitem.mat_type = -1
159+
jitem.mat_index = -1
160+
jitem.quantity = 1
161+
jitem.vector_id = df.job_item_vector_id.ANY_REFUSE
162+
jitem.flags1.unrotten = true
163+
jitem.flags2.shell = true
164+
jitem.flags2.body_part = true
165+
job.job_items.elements:insert('#', jitem)
166+
167+
assignToWorkshop(job, workshop)
168+
return dfhack.job.addWorker(job, unit)
169+
end
170+
146171
---make rock crafts at specified workshop
147172
---@param unit df.unit
148173
---@param workshop df.building_workshopst
@@ -177,6 +202,8 @@ local function categorize_craft(tab,item)
177202
tab['skull'] = (tab['skull'] or 0) + 1
178203
elseif item.corpse_flags.horn then
179204
tab['horn'] = (tab['horn'] or 0) + item.material_amount.Horn
205+
elseif item.corpse_flags.shell then
206+
tab['shell'] = (tab['shell'] or 0) + 1
180207
end
181208
elseif df.item_boulderst:is_instance(item) then
182209
tab['boulder'] = (tab['boulder'] or 0) + 1
@@ -310,11 +337,13 @@ function select_crafting_job(workshop)
310337
tab['bone'] = nil
311338
tab['skull'] = nil
312339
tab['horn'] = nil
340+
tab['shell'] = nil
313341
end
314342
local material = weightedChoice(tab)
315343
if material == 'bone' then return makeBoneCraft
316344
elseif material == 'skull' then return makeTotem
317345
elseif material == 'horn' then return makeHornCrafts
346+
elseif material == 'shell' then return makeShellCraft
318347
elseif material == 'boulder' then return makeRockCraft
319348
else
320349
return nil

0 commit comments

Comments
 (0)