Skip to content

Commit 6be5677

Browse files
authored
Merge branch 'DFHack:master' into adv-finder
2 parents 0c1a73f + 3220332 commit 6be5677

24 files changed

Lines changed: 1074 additions & 184 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.31.2
23+
rev: 0.32.1
2424
hooks:
2525
- id: check-github-workflows
2626
- repo: https://github.com/Lucas-C/pre-commit-hooks

changelog.txt

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,35 @@ Template for new versions:
2626

2727
# Future
2828

29+
## New Tools
30+
31+
## New Features
32+
33+
## Fixes
34+
- `list-agreements`: fix date math when determining petition age
35+
- `gui/petitions`: fix date math when determining petition age
36+
- `gui/rename`: fix commandline processing when manually specifying target ids
37+
- `gui/sandbox`: restore metal equipment options when spawning units
38+
39+
## Misc Improvements
40+
- `fix/loyaltycascade`: now also breaks up brawls and other intra-fort conflicts that *look* like loyalty cascades
41+
- `makeown`: remove selected unit from any current conflicts so they don't just start attacking other citizens when you make them a citizen of your fort
42+
43+
## Removed
44+
45+
# 51.09-r1
46+
47+
## New Features
48+
- `gui/mass-remove`: add a button to the bottom toolbar when eraser mode is active for launching `gui/mass-remove`
49+
- `idle-crafting`: default to only considering happy and ecstatic units for the highest need threshold
50+
- `gui/sitemap`: add a button to the toolbar at the bottom left corner of the screen for launching `gui/sitemap`
51+
52+
## Fixes
53+
- `idle-crafting`: check that units still have crafting needs before creating a job for them
54+
- `gui/journal`: prevent pause/unpause events from leaking through the UI when keys are mashed
55+
56+
# 51.07-r1
57+
2958
## New Tools
3059
- `devel/export-map`: export map tile data to a JSON file
3160
- `autocheese`: automatically make cheese using barrels that have accumulated sufficient milk
@@ -34,21 +63,18 @@ Template for new versions:
3463
- `gui/adv-finder`: UI for tracking historical figures and artifacts in adventure mode
3564
- `launch`: (reinstated) new adventurer fighting move: thrash your enemies with a flying suplex
3665
- `putontable`: (reinstated) make an item appear on a table
37-
- `devel/query`: support adventure mode
38-
- `devel/tree-info`: support adventure mode
39-
- `hfs-pit`: support adventure mode
40-
- `colonies`: support adventure mode
41-
- `toggle-kbd-cursor`: support adventure mode (Alt-k keybinding now toggles Look mode)
4266

4367
## New Features
44-
- `advtools`: new ``advtools.fastcombat`` overlay (enabled by default) allows you to skip combat animations and the announcement "More" button by mashing the movement keys
45-
- `gui/journal`: now working in adventure mode
68+
- `advtools`: ``advtools.fastcombat`` overlay (enabled by default) allows you to skip combat animations and the announcement "More" button by mashing the movement keys
69+
- `gui/journal`: now working in adventure mode -- journal is per-adventurer, so if you unretire an adventurer, you get the same journal
70+
- `emigration`: ``nobles`` command for sending freeloader barons back to the sites that they rule over
71+
- `toggle-kbd-cursor`: support adventure mode (Alt-k keybinding now toggles Look mode)
4672

4773
## Fixes
48-
- `position`: support for adv mode look cursor
4974
- `hfs-pit`: use correct wall types when making pits with walls
75+
- `gui/liquids`: don't add liquids to wall tiles
5076
- `gui/liquids`: using the remove tool with magma selected will no longer create unexpected unpathable tiles
51-
- `idle-crafting`: do not assign crafting jobs to nobles holding meetings (avoid dangling jobs)
77+
- `idle-crafting`: do not assign crafting jobs to nobles holding meetings (avoids dangling jobs)
5278
- `rejuvenate`: update unit portrait and sprite when aging up babies and children
5379
- `rejuvenate`: recalculate labor assignments for unit when aging up babies and children (so they can start accepting jobs)
5480

@@ -69,8 +95,11 @@ Template for new versions:
6995
- `prioritize`: when prioritizing jobs of a specified type, also output how many of those jobs were already prioritized before you ran the command
7096
- `prioritize`: don't include already-prioritized jobs in the output of ``prioritize -j``
7197
- `gui/design`: only display vanilla dimensions tooltip if the DFHack dimensions tooltip is disabled
72-
73-
## Removed
98+
- `devel/query`: support adventure mode
99+
- `devel/tree-info`: support adventure mode
100+
- `hfs-pit`: support adventure mode
101+
- `colonies`: support adventure mode
102+
- `position`: report position of the adventure mode look cursor, if active
74103

75104
# 51.04-r1.1
76105

docs/emigration.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,44 @@ even in the company of a visiting elven bard!
1616
The check is made monthly. A happy dwarf (i.e. with negative stress) will never
1717
emigrate.
1818

19+
The tool also supports ``nobles``, a manually-invoked command that makes nobles
20+
emigrate to their rightful land of rule. No more freeloaders making inane demands!
21+
Nobles assigned to squads or to fort administrator positions will not be emigrated.
22+
Remove their assignments before retrying. Nobles holding elected positions
23+
(i.e. mayors) may be emigrated, but will be marked with a ``*`` icon when listed.
24+
1925
Usage
2026
-----
2127

2228
::
2329

2430
enable emigration
31+
emigration nobles [--list]
32+
emigration nobles [<target>]
33+
34+
Examples
35+
--------
36+
37+
``emigration nobles``
38+
Emigrate the selected noble if it does not rule your fortress.
39+
If no unit is selected, list all nobles that do not rule your fortress.
40+
``emigration nobles --list``
41+
List all nobles that do not rule your fortress. Nobles that cannot be emigrated
42+
(see above) will have a ``!`` indicator while nobles holding elected positions
43+
will have a ``*`` indicator.
44+
``emigration nobles --all``
45+
Emigrate all nobles that do not rule your fortress.
46+
``emigration nobles --unit 34534``
47+
Emigrate a noble matching the specified unit ID that does not rule your fortress.
48+
49+
Options
50+
-------
51+
52+
These options are exclusive to the ``emigration nobles`` command.
53+
54+
``-l``, ``--list``
55+
List all nobles that do not rule your fortress
56+
``-a``, ``--all``
57+
Emigrate all nobles do not rule your fortress
58+
``-u``, ``--unit <id>``
59+
Emigrate noble matching specified unit ID that does not rule your fortress

docs/fix/loyaltycascade.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ fix/loyaltycascade
66
:tags: fort bugfix units
77

88
This tool neutralizes loyalty cascades by fixing units who consider their own
9-
civilization to be the enemy.
9+
civilization to be the enemy. It will also halt all fighting on the map that
10+
involves your citizens, though "real" enemies will re-engage in combat after a
11+
short delay.
1012

1113
Usage
1214
-----

docs/gui/mass-remove.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,16 @@ Usage
1919
::
2020

2121
gui/mass-remove
22+
23+
Overlay
24+
-------
25+
26+
This tool also provides one overlay that is managed by the `overlay`
27+
framework.
28+
29+
gui/mass-remove.toolbar
30+
~~~~~~~~~~~~~~~~~~~~~~~
31+
32+
The ``gui/mass-remove.toolbar`` overlay adds a button to the toolbar at the
33+
bottom of the screen when eraser mode is active. It allows you to conveniently
34+
open the ``gui/mass-remove`` interface.

docs/gui/sitemap.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,16 @@ Usage
2424
::
2525

2626
gui/sitemap
27+
28+
Overlay
29+
-------
30+
31+
This tool also provides one overlay that is managed by the `overlay`
32+
framework.
33+
34+
gui/sitemap.toolbar
35+
~~~~~~~~~~~~~~~~~~~
36+
37+
The ``gui/sitemap.toolbar`` overlay adds a button to the toolbar at the bottom left corner of the
38+
screen with the other menu buttons. It allows you to conveniently open the ``gui/sitemap``
39+
interface.

docs/idle-crafting.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ Usage
2626
given unit. Units meeting higher thresholds will be prioritized. Defaults
2727
to ``500,1000,10000``.
2828

29+
``idle-crafting happy [yes|no]``
30+
If set to ``no``, "happy" and "ecstatic" dwarves not suffering from
31+
long-term stress will only satisfy their crafting needs when meeting the
32+
highest configured threshold (eg. ``10000`` at default settings). Defaults
33+
to ``no``.
34+
2935
``disable idle-crafting``
3036
Disallow idle crafting at all workshops. You can re-enable idle crafting
3137
at individual Craftsdwarf's workshops.
@@ -34,7 +40,10 @@ Examples
3440
--------
3541

3642
``idle-crafting thresholds 500,1000,10000``
37-
Reset thresholds to defaults.
43+
Reset thresholds to defaults.
44+
45+
``idle-crafting happy yes``
46+
Treat happy and ecstatic dwarves the same as everyone else.
3847

3948
Overlay
4049
-------

docs/makeown.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ makeown
66
:tags: fort armok units
77

88
Select a unit in the UI and run this tool to converts that unit to be a fortress
9-
citizen (if sentient). It also removes their foreign affiliation, if any.
9+
citizen (if sentient). It also removes their foreign affiliation, if any, and
10+
removes the unit from any current conflict they are engaged in.
1011

1112
This tool also fixes :bug:`10921`, where you request workers from your
1213
holdings, but they come with the "Merchant" profession and are unable to

emigration.lua

Lines changed: 18 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
local utils = require('utils')
55

6+
local nobles = reqscript('internal/emigration/emigrate-nobles')
7+
local unit_link_utils = reqscript('internal/emigration/unit-link-utils')
8+
69
local GLOBAL_KEY = 'emigration' -- used for state change hooks and persistence
710

811
local function get_default_state()
@@ -37,121 +40,40 @@ function desert(u,method,civ)
3740
local line = dfhack.units.getReadableName(u) .. " has "
3841
if method == 'merchant' then
3942
line = line.."joined the merchants"
40-
u.flags1.merchant = true
41-
u.civ_id = civ
43+
unit_link_utils.markUnitForEmigration(u, civ, false)
4244
else
4345
line = line.."abandoned the settlement in search of a better life."
44-
u.civ_id = civ
45-
u.flags1.forest = true
46-
u.flags2.visitor = true
47-
u.animal.leave_countdown = 2
46+
unit_link_utils.markUnitForEmigration(u, civ, true)
4847
end
49-
local hf_id = u.hist_figure_id
48+
5049
local hf = df.historical_figure.find(u.hist_figure_id)
5150
local fort_ent = df.global.plotinfo.main.fortress_entity
5251
local civ_ent = df.historical_entity.find(hf.civ_id)
5352
local newent_id = -1
5453
local newsite_id = -1
5554

56-
-- free owned rooms
57-
for i = #u.owned_buildings-1, 0, -1 do
58-
local temp_bld = df.building.find(u.owned_buildings[i].id)
59-
dfhack.buildings.setOwner(temp_bld, nil)
60-
end
61-
62-
-- remove from workshop profiles
63-
for _, bld in ipairs(df.global.world.buildings.other.WORKSHOP_ANY) do
64-
for k, v in ipairs(bld.profile.permitted_workers) do
65-
if v == u.id then
66-
bld.profile.permitted_workers:erase(k)
67-
break
68-
end
69-
end
70-
end
71-
for _, bld in ipairs(df.global.world.buildings.other.FURNACE_ANY) do
72-
for k, v in ipairs(bld.profile.permitted_workers) do
73-
if v == u.id then
74-
bld.profile.permitted_workers:erase(k)
75-
break
76-
end
77-
end
78-
end
79-
80-
-- disassociate from work details
81-
for _, detail in ipairs(df.global.plotinfo.labor_info.work_details) do
82-
for k, v in ipairs(detail.assigned_units) do
83-
if v == u.id then
84-
detail.assigned_units:erase(k)
85-
break
86-
end
87-
end
88-
end
89-
90-
-- unburrow
91-
for _, burrow in ipairs(df.global.plotinfo.burrows.list) do
92-
dfhack.burrows.setAssignedUnit(burrow, u, false)
93-
end
94-
95-
-- erase the unit from the fortress entity
96-
for k,v in ipairs(fort_ent.histfig_ids) do
97-
if v == hf_id then
98-
df.global.plotinfo.main.fortress_entity.histfig_ids:erase(k)
99-
break
100-
end
101-
end
102-
for k,v in ipairs(fort_ent.hist_figures) do
103-
if v.id == hf_id then
104-
df.global.plotinfo.main.fortress_entity.hist_figures:erase(k)
105-
break
106-
end
107-
end
108-
for k,v in ipairs(fort_ent.nemesis) do
109-
if v.figure.id == hf_id then
110-
df.global.plotinfo.main.fortress_entity.nemesis:erase(k)
111-
df.global.plotinfo.main.fortress_entity.nemesis_ids:erase(k)
112-
break
113-
end
114-
end
115-
116-
-- remove the old entity link and create new one to indicate former membership
117-
hf.entity_links:insert("#", {new = df.histfig_entity_link_former_memberst, entity_id = fort_ent.id, link_strength = 100})
118-
for k,v in ipairs(hf.entity_links) do
119-
if v._type == df.histfig_entity_link_memberst and v.entity_id == fort_ent.id then
120-
hf.entity_links:erase(k)
121-
break
122-
end
123-
end
55+
unit_link_utils.removeUnitAssociations(u)
56+
unit_link_utils.removeHistFigFromEntity(hf, fort_ent)
12457

12558
-- try to find a new entity for the unit to join
126-
for k,v in ipairs(civ_ent.entity_links) do
127-
if v.type == df.entity_entity_link_type.CHILD and v.target ~= fort_ent.id then
128-
newent_id = v.target
59+
for _,entity_link in ipairs(civ_ent.entity_links) do
60+
if entity_link.type == df.entity_entity_link_type.CHILD and entity_link.target ~= fort_ent.id then
61+
newent_id = entity_link.target
12962
break
13063
end
13164
end
13265

13366
if newent_id > -1 then
134-
hf.entity_links:insert("#", {new = df.histfig_entity_link_memberst, entity_id = newent_id, link_strength = 100})
135-
13667
-- try to find a new site for the unit to join
137-
for k,v in ipairs(df.global.world.entities.all[hf.civ_id].site_links) do
68+
for _,site_link in ipairs(df.global.world.entities.all[hf.civ_id].site_links) do
13869
local site_id = df.global.plotinfo.site_id
139-
if v.type == df.entity_site_link_type.Claim and v.target ~= site_id then
140-
newsite_id = v.target
70+
if site_link.type == df.entity_site_link_type.Claim and site_link.target ~= site_id then
71+
newsite_id = site_link.target
14172
break
14273
end
14374
end
14475
local newent = df.historical_entity.find(newent_id)
145-
newent.histfig_ids:insert('#', hf_id)
146-
newent.hist_figures:insert('#', hf)
147-
local hf_event_id = df.global.hist_event_next_id
148-
df.global.hist_event_next_id = df.global.hist_event_next_id+1
149-
df.global.world.history.events:insert("#", {new = df.history_event_add_hf_entity_linkst, year = df.global.cur_year, seconds = df.global.cur_year_tick, id = hf_event_id, civ = newent_id, histfig = hf_id, link_type = 0})
150-
if newsite_id > -1 then
151-
local hf_event_id = df.global.hist_event_next_id
152-
df.global.hist_event_next_id = df.global.hist_event_next_id+1
153-
df.global.world.history.events:insert("#", {new = df.history_event_change_hf_statest, year = df.global.cur_year, seconds = df.global.cur_year_tick, id = hf_event_id, hfid = hf_id, state = 1, reason = -1, site = newsite_id})
154-
end
76+
unit_link_utils.addHistFigToSite(hf, newsite_id, newent)
15577
end
15678
print(dfhack.df2console(line))
15779
dfhack.gui.showAnnouncement(line, COLOR_WHITE)
@@ -251,6 +173,9 @@ if args[1] == "enable" then
251173
state.enabled = true
252174
elseif args[1] == "disable" then
253175
state.enabled = false
176+
elseif args[1] == "nobles" then
177+
table.remove(args, 1)
178+
nobles.run(args)
254179
else
255180
print('emigration is ' .. (state.enabled and 'enabled' or 'not enabled'))
256181
return

fix/loyaltycascade.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
-- Prevents a "loyalty cascade" (intra-fort civil war) when a citizen is killed.
2+
-- Also breaks up brawls and other conflicts.
23

34
local makeown = reqscript('makeown')
45

@@ -76,7 +77,7 @@ local function fixUnit(unit)
7677
makeown.clear_enemy_status(unit)
7778
end
7879

79-
return false
80+
return makeown.remove_from_conflict(unit) or fixed
8081
end
8182

8283
local count = 0
@@ -87,7 +88,7 @@ for _, unit in pairs(dfhack.units.getCitizens()) do
8788
end
8889

8990
if count > 0 then
90-
print(('Fixed %s units from a loyalty cascade.'):format(count))
91+
print(('Fixed %s units with loyalty issues.'):format(count))
9192
else
9293
print('No loyalty cascade found.')
9394
end

0 commit comments

Comments
 (0)