Skip to content

Commit c28c7c3

Browse files
authored
Merge branch 'DFHack:master' into caravan-work
2 parents a5c1294 + f71c156 commit c28c7c3

22 files changed

Lines changed: 2117 additions & 176 deletions

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
args: ['--fix=lf']
2121
- id: trailing-whitespace
2222
- repo: https://github.com/python-jsonschema/check-jsonschema
23-
rev: 0.33.3
23+
rev: 0.34.1
2424
hooks:
2525
- id: check-github-workflows
2626
- repo: https://github.com/Lucas-C/pre-commit-hooks

autocheese.lua

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
--@module = true
22

3-
local ic = reqscript('idle-crafting')
4-
53
---make cheese using a specific barrel and workshop
64
---@param barrel df.item
75
---@param workshop df.building_workshopst
86
---@return df.job
97
function makeCheese(barrel, workshop)
108
---@type df.job
11-
local job = ic.make_job()
9+
local job = dfhack.job.createLinked()
1210
job.job_type = df.job_type.MakeCheese
1311

1412
local jitem = df.job_item:new()
@@ -22,29 +20,17 @@ function makeCheese(barrel, workshop)
2220
dfhack.error('could not attach item')
2321
end
2422

25-
ic.assignToWorkshop(job, workshop)
23+
dfhack.job.assignToWorkshop(job, workshop)
2624
return job
2725
end
2826

29-
30-
31-
---unit is ready to take jobs
27+
---checks that unit can path to workshop
3228
---@param unit df.unit
29+
---@param workshop df.building_workshopst
3330
---@return boolean
34-
function unitIsAvailable(unit)
35-
if unit.job.current_job then
36-
return false
37-
elseif #unit.individual_drills > 0 then
38-
return false
39-
elseif unit.flags1.caged or unit.flags1.chained then
40-
return false
41-
elseif unit.military.squad_id ~= -1 then
42-
local squad = df.squad.find(unit.military.squad_id)
43-
-- this lookup should never fail
44-
---@diagnostic disable-next-line: need-check-nil
45-
return #squad.orders == 0 and squad.activity == -1
46-
end
47-
return true
31+
function canAccessWorkshop(unit, workshop)
32+
local workshop_position = xyz2pos(workshop.centerx, workshop.centery, workshop.z)
33+
return dfhack.maps.canWalkBetween(unit.pos, workshop_position)
4834
end
4935

5036
---check if unit can perform labor at workshop
@@ -54,8 +40,8 @@ end
5440
---@return boolean
5541
function availableLaborer(unit, unit_labor, workshop)
5642
return unit.status.labors[unit_labor]
57-
and unitIsAvailable(unit)
58-
and ic.canAccessWorkshop(unit, workshop)
43+
and dfhack.units.isJobAvailable(unit)
44+
and canAccessWorkshop(unit, workshop)
5945
end
6046

6147
---find unit with a particular labor enabled

autotraining.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ end
139139

140140
function getTrainingSquads()
141141
local squads = {}
142-
for squad_id, _ in pairs(state.training_squads) do
142+
for squad_id, active in pairs(state.training_squads) do
143143
local squad = df.squad.find(squad_id)
144-
if squad then
144+
if active and squad then
145145
table.insert(squads, squad)
146146
else
147147
-- setting to nil during iteration is permitted by lua

ban-cooking.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,18 @@ funcs.booze = function()
8080
end
8181

8282
funcs.honey = function()
83-
local mat = dfhack.matinfo.find("CREATURE:HONEY_BEE:HONEY")
84-
if mat then
85-
ban_cooking('honey bee honey', mat.type, mat.index, df.item_type.LIQUID_MISC, -1)
83+
for _, c in ipairs(df.global.world.raws.creatures.all) do
84+
for _, m in ipairs(c.material) do
85+
if m.flags.EDIBLE_COOKED then
86+
for _, s in ipairs(m.reaction_product.id) do
87+
if s.value == "DRINK_MAT" then
88+
local matinfo = dfhack.matinfo.find(c.creature_id, m.id)
89+
ban_cooking(c.name[2] .. ' ' .. m.id, matinfo.type, matinfo.index, df.item_type.LIQUID_MISC, -1)
90+
break
91+
end
92+
end
93+
end
94+
end
8695
end
8796
end
8897

changelog.txt

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,64 @@ Template for new versions:
3838

3939
## Removed
4040

41+
# 53.01-r1
42+
43+
## New Tools
44+
- `fix/symbol-unstick`: unstick noble symbols that cannot be re-designated.
45+
- `resize-armor`: resize armor or clothing item to any creature size.
46+
47+
## New Features
48+
49+
## Fixes
50+
- `autotraining`: squads once used for training then disabled now properly are treated as disabled.
51+
52+
## Misc Improvements
53+
54+
## Removed
55+
- `fix/archery-practice`: removed from the control panel's bug fixes tab.
56+
57+
# 52.05-r2
58+
59+
## New Tools
60+
61+
## New Features
62+
63+
## Fixes
64+
- `fix/archery-practice`: now splits instead of combining ammo items in quivers, and moves quivers to end of unit's inventory list
65+
66+
## Misc Improvements
67+
68+
## Removed
69+
70+
# 52.05-r1
71+
72+
## New Tools
73+
- `fix/archery-practice`: combine ammo items in units' quivers to fix 'Soldier (no item)' issue
74+
- `gui/adv-finder`: UI for tracking historical figures and artifacts in adventure mode
75+
- `store-owned`: task owned items to be stored in the owner's room furniture
76+
77+
## New Features
78+
79+
## Fixes
80+
- `ban-cooking`: bans honey added by creatures other than vanilla honey bee
81+
- `uniform-unstick`: added quivers, backpacks, and flasks/waterskins to uniform analysis
82+
- `uniform-unstick`: the ``--drop`` option now only evaluates clothing as possible items to drop
83+
- `uniform-unstick`: the ``--free`` option no longer redundantly reports an improperly assigned item when that item is removed from a uniform
84+
- `uniform-unstick`: the ``--drop`` and ``--free`` options now only drop items which are actually in a unit's inventory
85+
- `uniform-unstick`: the ``--all`` and ``--drop`` options, when used together, now print the separator line between each unit's report in the proper place
86+
87+
## Misc Improvements
88+
- adapt Lua tools to use new API functionality for creating and assigning jobs
89+
- `idle-crafting`: properly interrupt interruptible (i.e. "green") social activities
90+
91+
## Removed
92+
4193
# 52.03-r2
4294

4395
## New Tools
4496
- `autotraining`: new tool to assign citizens to a military squad when they need Martial Training
4597
- `gui/autotraining`: configuration tool for autotraining
4698
- `entomb`: allow any unit that has a corpse or body parts to be assigned a tomb zone
47-
4899
- `husbandry`: Automatically milk and shear animals at nearby farmer's workshops
49100

50101
## New Features

docs/fix/archery-practice.rst

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
fix/archery-practice
2+
====================
3+
4+
.. dfhack-tool::
5+
:summary: Fix quivers and training ammo items to allow archery practice to take place.
6+
:tags: fort bugfix items
7+
8+
Make quivers the last item in the inventory of every ranged unit currently
9+
training and split stacks of ammo items assigned for training inside the
10+
quivers to ensure each training unit can have more than one stack to allow
11+
archery practice to take place.
12+
13+
Note
14+
----
15+
16+
The bug preventing units from initiating archery practice was fixed in
17+
DF version 53.01. See below for more information about the issue and how
18+
this tool works to mitigate it. Running this tool for any other archery
19+
related issues will not yield useful results.
20+
21+
Usage
22+
-----
23+
24+
``fix/archery-practice``
25+
Move quivers to the end of units' inventory list and split stacks of
26+
training ammo items inside the quivers.
27+
28+
``fix/archery-practice -q``, ``fix/archery-practice --quiet``
29+
Move quivers to the end of units' inventory list and split stacks of
30+
training ammo items inside the quivers. Do not print to console.
31+
32+
This tool will set quivers as the last item in the inventory of units in
33+
squads that are currently set to train as well as split ammo items inside
34+
their quivers into multiple stacks if a quiver contains only ammo item
35+
with a stack size of 25 or larger assigned for training. The original
36+
training ammo item with a reduced stack size will remain in the quiver
37+
while new ammo items split from it will be placed on the ground where
38+
the unit is located to be picked up later.
39+
40+
Why are archers not practicing archery?
41+
---------------------------------------
42+
43+
Due to a bug in the game, a unit that is scheduled to train will not be
44+
able to practice archery at the archery range when their quiver contains
45+
only one stack of ammo item assigned for training. This is sometimes
46+
indicated on the unit by the 'Soldier (no item)' status.
47+
48+
During versions 52.03 and 52.04, the issue was the complete reverse;
49+
units would not practice when their quivers contained more than one
50+
stack of ammo items assigned for training.
51+
52+
Another issue in 52.05 is that units will not practice archery if their
53+
quiver is not the last item in their inventory.
54+
55+
This tool provides an interim remedy by moving quivers to the end of
56+
every training unit's inventory list and splitting stacks of ammo items
57+
inside their quivers to prompt the game to give them multiple stacks
58+
of training ammo items.
59+
60+
Limitations
61+
-----------
62+
63+
The game has a tendency to reshuffle the squad's ammo/unit pairings if
64+
the newly split ammo items are force paired to the units holding the
65+
original ammo item. As a compromise, the new items are placed on the
66+
ground instead and added to the squad's training ammo assignment pool,
67+
so that the game can distribute the items normally without causing the
68+
pairing for ammo items already in quivers to be reshuffled.
69+
70+
Although this tool would allow units to practice archery, the activity
71+
will still be aborted once they have only one stack of training ammo
72+
item remaining in their quivers. Practicing units will gain skill from
73+
practice, but not the positive thought they would have gained from
74+
having completed the activity. Once the game assigns more training
75+
ammo items to them, they can continue practicing archery.

docs/fix/symbol-unstick.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
fix/symbol-unstick
2+
==================
3+
4+
.. dfhack-tool::
5+
:summary: Unstick noble symbols that cannot be re-designated.
6+
:tags: fort bugfix items
7+
8+
Remove symbol designation from artifacts that cannot be re-designated
9+
after the noble's promotion to a higher position.
10+
11+
Usage
12+
-----
13+
14+
``fix/symbol-unstick``
15+
16+
Select an artifact that was designated as a noble's symbol and run the
17+
command to remove its designation as a symbol. The operation will only
18+
be performed if the symbol is claimed by a vacated noble position.

docs/gui/adv-finder.rst

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
gui/adv-finder
2+
==============
3+
4+
.. dfhack-tool::
5+
:summary: Find and track historical figures and artifacts
6+
:tags: adventure armok inspection items units
7+
8+
A real-time tracker for historical figures and artifacts. Select a target by
9+
clicking the settings icon [☼] and selecting an entry from the list in the
10+
relevant tab. The list can be filtered by search string, as well as by
11+
excluding dead figures (displayed in red text). Artifacts can exclude books,
12+
and the "dead" option excludes artifacts held by dead figures (which are
13+
generally unrecoverable). Dismissing the screen (e.g., right-click) will
14+
close the target search window first. A second dismissal will close the
15+
finder window, but target settings will be preserved until the world is
16+
unloaded.
17+
18+
Your coordinates will be kept up to date alongside your target's. There are
19+
two types of coordinates, and they will be displayed as long as they can be
20+
determined.
21+
22+
========== ==========
23+
Coord Type Meaning
24+
========== ==========
25+
Global Distance in map blocks from the world origin (northwest corner).
26+
The adventurer usually moves by 3 blocks during fast travel, but
27+
slows to 1 when the zoomed site map is displayed. Equivalent to
28+
16 local tiles. Always available except for targets with an
29+
indeterminate location.
30+
Local Tile coordinates, available outside of fast travel and sleeping.
31+
Your target's local coordinates are displayed when nearby and
32+
loaded. Local coordinates will remain consistent within a site, but
33+
may jump around in the wilderness as areas of the world are loaded.
34+
========== ==========
35+
36+
For global coordinates, the Z component will only be displayed if it can be
37+
specifically determined by the location type. This represents an underground
38+
layer depth, so the surface is indicated by ``Z0`` and the first cavern layer
39+
is ``Z-1``.
40+
41+
A compass and relative coordinates will be displayed. The relative coordinate
42+
display uses the most precise coordinate type shared between you and your
43+
target.
44+
45+
There are six types of location types displayed for targets:
46+
47+
============= ==========
48+
Location Type Meaning
49+
============= ==========
50+
Nearby The target is loaded into the map area and the local
51+
coordinates will be displayed. If you don't see this when you're
52+
in the correct area and outside fast travel, then the target
53+
isn't loading for some reason and you'll never be able to find
54+
them.
55+
Site The target is located within a site. The text displays
56+
"At <Sitename>" and the global coords will represent the center
57+
of the site if the target doesn't track its own precise
58+
coordinates (e.g., worldgen being vague).
59+
Traveling The target is traveling around the world map like an army.
60+
Wilderness The target is somewhere on the surface not in a site.
61+
Underground The target is somewhere in the caverns not in a site.
62+
None The target's location isn't defined in the game world.
63+
Maybe they're a deity. Maybe they got dropped off in limbo
64+
after their army disbanded. If they're dead, the location
65+
wasn't recorded properly in history. The text displays "Missing"
66+
if they're dead or can die of old age, else "Transcendent"
67+
because nothing can touch them.
68+
============= ==========
69+
70+
Dead figures generally can't be encountered at all, and they take their items
71+
with them if they weren't separated properly by worldgen. The coord given is
72+
usually a death or abstract burial location, but the corpse isn't guaranteed to
73+
exist. Generally, wilderness and underground locations only have coords if you
74+
left something there in adventure mode. Anything lost there during worldgen or a
75+
fort mode mission likely can't be located. Anything in a site is usually a safe
76+
bet, but sometimes items won't load. (Fort missions can be used to acquire these
77+
for later retrieval, however.) Traveling targets are always valid.
78+
79+
Usage
80+
-----
81+
82+
::
83+
84+
gui/adv-finder [<options>]
85+
86+
Examples
87+
--------
88+
89+
``gui/adv-finder``
90+
Open the finder window (unless already open). Target will be blank on first
91+
use, but maintained on future invocations.
92+
``gui/adv-finder --histfig 1234``
93+
Track the historical figure with ID #1234. Finder will be opened if not
94+
already.
95+
``gui/adv-finder -h -1 -a -1``
96+
Clear any target so it's just the adventurer. Finder will be opened if not
97+
already.
98+
``gui/adv-finder --debug``
99+
Display selected target IDs in the finder window title bar. Finder will be
100+
opened if not already. This setting isn't saved, so it can be disabled by
101+
invoking ``gui/adv-finder`` again without the option.
102+
103+
Options
104+
-------
105+
106+
``-h``, ``--histfig <id>``
107+
Set the target to the historical figure with the given ID.
108+
``-a``, ``--artifact <id>``
109+
Set the target to the artifact record with the given ID. (Not an item ID!)
110+
``-d``, ``--debug``
111+
Display selected target IDs in the finder window title bar. Doesn't persist
112+
between invocations.

docs/gui/aquifer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tiles or warm tiles). Note that "just damp" tiles will still be highlighted if
1212
they are otherwise already visible.
1313

1414
You can draw boxes around areas of tiles to alter their aquifer properties, or
15-
you can use the :kbd:`Ctrl`:kbd:`A`` shortcut to affect entire layers at a time.
15+
you can use the :kbd:`Ctrl`:kbd:`A` shortcut to affect entire layers at a time.
1616

1717
If you want to see where the aquifer tiles are so you can designate digging,
1818
please run `gui/reveal`. If you only want to see the aquifer tiles and not

0 commit comments

Comments
 (0)