Skip to content

Commit df6b940

Browse files
authored
Merge branch 'master' into refactor/text-area-to-widgets
2 parents c42a23d + bbad80a commit df6b940

File tree

14 files changed

+322
-75
lines changed

14 files changed

+322
-75
lines changed

.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.29.3
23+
rev: 0.29.4
2424
hooks:
2525
- id: check-github-workflows
2626
- repo: https://github.com/Lucas-C/pre-commit-hooks

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Template for new versions:
2828

2929
## New Tools
3030
- `fix/wildlife`: prevent wildlife from getting stuck when trying to exit the map. This fix needs to be enabled manually in `gui/control-panel` on the Bug Fixes tab since not all players want this bug to be fixed.
31+
- `immortal-cravings`: allow immortals to satisfy their cravings for food and drink
3132

3233
## New Features
3334
- `force`: support the ``Wildlife`` event to allow additional wildlife to enter the map
@@ -38,6 +39,9 @@ Template for new versions:
3839
- `makeown`: halt any hostile jobs the unit may be engaged in, like kidnapping
3940
- `fix/loyaltycascade`: allow the fix to work on non-dwarven citizens
4041
- `control-panel`: fix setting numeric preferences from the commandline
42+
- `gui/quickfort`: fix build mode evluation rules to allow placement of various furniture and constructions on tiles with stair shapes or without orthagonal floor.
43+
- `emigration`: save-and-reload no longer resets the emigration cycle timeout, making gameplay more consistent
44+
- `rejuvenate`: ``--age`` no longer throws the error ``attempt to compare string with number``
4145

4246
## Misc Improvements
4347
- `control-panel`: Add realistic-melting tweak to control-panel registry

docs/immortal-cravings.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
immortal-cravings
2+
=================
3+
4+
.. dfhack-tool::
5+
:summary: Allow immortals to satisfy their cravings for food and drink.
6+
:tags: fort gameplay
7+
8+
When enabled, this script watches your fort for units that have no physiological
9+
need to eat or drink but still have personality needs that can only be satisfied
10+
by eating or drinking (e.g. necromancers). This enables those units to help
11+
themselves to a drink or a meal when they crave one and are not otherwise
12+
occupied.
13+
14+
Usage
15+
-----
16+
17+
::
18+
19+
enable immortal-cravings

emigration.lua

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
--@module = true
22
--@enable = true
33

4+
local utils = require('utils')
5+
46
local GLOBAL_KEY = 'emigration' -- used for state change hooks and persistence
57

6-
enabled = enabled or false
8+
local function get_default_state()
9+
return {enabled=false, last_cycle_tick=0}
10+
end
11+
12+
state = state or get_default_state()
713

814
function isEnabled()
9-
return enabled
15+
return state.enabled
1016
end
1117

1218
local function persist_state()
13-
dfhack.persistent.saveSiteData(GLOBAL_KEY, {enabled=enabled})
19+
dfhack.persistent.saveSiteData(GLOBAL_KEY, state)
1420
end
1521

22+
local TICKS_PER_MONTH = 33600
23+
local TICKS_PER_YEAR = 12 * TICKS_PER_MONTH
24+
1625
function desireToStay(unit,method,civ_id)
1726
-- on a percentage scale
1827
local value = 100 - unit.status.current_soul.personality.stress / 5000
@@ -191,27 +200,36 @@ function checkmigrationnow()
191200
else
192201
for _, civ_id in pairs(merchant_civ_ids) do checkForDeserters('merchant', civ_id) end
193202
end
203+
204+
state.last_cycle_tick = dfhack.world.ReadCurrentTick() + TICKS_PER_YEAR * dfhack.world.ReadCurrentYear()
194205
end
195206

196207
local function event_loop()
197-
if enabled then
198-
checkmigrationnow()
199-
dfhack.timeout(1, 'months', event_loop)
208+
if state.enabled then
209+
local current_tick = dfhack.world.ReadCurrentTick() + TICKS_PER_YEAR * dfhack.world.ReadCurrentYear()
210+
if current_tick - state.last_cycle_tick < TICKS_PER_MONTH then
211+
local timeout_ticks = state.last_cycle_tick - current_tick + TICKS_PER_MONTH
212+
dfhack.timeout(timeout_ticks, 'ticks', event_loop)
213+
else
214+
checkmigrationnow()
215+
dfhack.timeout(1, 'months', event_loop)
216+
end
200217
end
201218
end
202219

203220
dfhack.onStateChange[GLOBAL_KEY] = function(sc)
204221
if sc == SC_MAP_UNLOADED then
205-
enabled = false
222+
state.enabled = false
206223
return
207224
end
208225

209226
if sc ~= SC_MAP_LOADED or df.global.gamemode ~= df.game_mode.DWARF then
210227
return
211228
end
212229

213-
local persisted_data = dfhack.persistent.getSiteData(GLOBAL_KEY, {enabled=false})
214-
enabled = persisted_data.enabled
230+
state = get_default_state()
231+
utils.assign(state, dfhack.persistent.getSiteData(GLOBAL_KEY, state))
232+
215233
event_loop()
216234
end
217235

@@ -230,11 +248,11 @@ if dfhack_flags and dfhack_flags.enable then
230248
end
231249

232250
if args[1] == "enable" then
233-
enabled = true
251+
state.enabled = true
234252
elseif args[1] == "disable" then
235-
enabled = false
253+
state.enabled = false
236254
else
237-
print('emigration is ' .. (enabled and 'enabled' or 'not enabled'))
255+
print('emigration is ' .. (state.enabled and 'enabled' or 'not enabled'))
238256
return
239257
end
240258

geld.lua

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
-- Gelds or ungelds animals
2-
-- Written by Josh Cooper(cppcooper) on 2019-12-10, last modified: 2020-02-23
3-
41
utils = require('utils')
52

63
local validArgs = utils.invert({
@@ -11,29 +8,11 @@ local validArgs = utils.invert({
118
'find',
129
})
1310
local args = utils.processArgs({...}, validArgs)
14-
local help = [====[
15-
16-
geld
17-
====
18-
Geld allows the user to geld and ungeld animals.
19-
20-
Valid options:
21-
22-
``-unit <id>``: Gelds the unit with the specified ID.
23-
This is optional; if not specified, the selected unit is used instead.
24-
25-
``-ungeld``: Ungelds the specified unit instead (see also `ungeld`).
26-
27-
``-toggle``: Toggles the gelded status of the specified unit.
28-
29-
``-help``: Shows this help information
30-
31-
]====]
3211

3312
unit=nil
3413

3514
if args.help then
36-
print(help)
15+
print(dfhack.script_help())
3716
return
3817
end
3918

gui/manipulator.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,9 +1341,12 @@ function ManipulatorOverlay:init()
13411341
}
13421342
end
13431343

1344-
OVERLAY_WIDGETS = {
1345-
launcher=ManipulatorOverlay,
1346-
}
1344+
--
1345+
-- disable overlay widget while tool is still in dark launch mode
1346+
--
1347+
-- OVERLAY_WIDGETS = {
1348+
-- launcher=ManipulatorOverlay,
1349+
-- }
13471350

13481351
if dfhack_flags.module then return end
13491352

gui/notify.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ DwarfNotifyOverlay.ATTRS{
132132
}
133133

134134
local DWARFMODE_CONFLICTING_TOOLTIPS = utils.invert{
135-
df.main_hover_instruction.InfoUnits,
136-
df.main_hover_instruction.InfoJobs,
137-
df.main_hover_instruction.InfoPlaces,
138-
df.main_hover_instruction.InfoLabors,
139-
df.main_hover_instruction.InfoWorkOrders,
140-
df.main_hover_instruction.InfoNobles,
141-
df.main_hover_instruction.InfoObjects,
142-
df.main_hover_instruction.InfoJustice,
135+
df.main_hover_instruction.MAIN_OPEN_CREATURES,
136+
df.main_hover_instruction.MAIN_OPEN_TASKS,
137+
df.main_hover_instruction.MAIN_OPEN_PLACES,
138+
df.main_hover_instruction.MAIN_OPEN_LABOR,
139+
df.main_hover_instruction.MAIN_OPEN_WORK_ORDERS,
140+
df.main_hover_instruction.MAIN_OPEN_NOBLES,
141+
df.main_hover_instruction.MAIN_OPEN_OBJECTS,
142+
df.main_hover_instruction.MAIN_OPEN_JUSTICE,
143143
}
144144

145145
local mi = df.global.game.main_interface

0 commit comments

Comments
 (0)