Skip to content

Commit

Permalink
Merge branch 'master' into refactor/text-area-to-widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 authored Nov 28, 2024
2 parents c42a23d + bbad80a commit df6b940
Show file tree
Hide file tree
Showing 14 changed files with 322 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
args: ['--fix=lf']
- id: trailing-whitespace
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.3
rev: 0.29.4
hooks:
- id: check-github-workflows
- repo: https://github.com/Lucas-C/pre-commit-hooks
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Template for new versions:

## New Tools
- `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.
- `immortal-cravings`: allow immortals to satisfy their cravings for food and drink

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

## Misc Improvements
- `control-panel`: Add realistic-melting tweak to control-panel registry
Expand Down
19 changes: 19 additions & 0 deletions docs/immortal-cravings.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
immortal-cravings
=================

.. dfhack-tool::
:summary: Allow immortals to satisfy their cravings for food and drink.
:tags: fort gameplay

When enabled, this script watches your fort for units that have no physiological
need to eat or drink but still have personality needs that can only be satisfied
by eating or drinking (e.g. necromancers). This enables those units to help
themselves to a drink or a meal when they crave one and are not otherwise
occupied.

Usage
-----

::

enable immortal-cravings
42 changes: 30 additions & 12 deletions emigration.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
--@module = true
--@enable = true

local utils = require('utils')

local GLOBAL_KEY = 'emigration' -- used for state change hooks and persistence

enabled = enabled or false
local function get_default_state()
return {enabled=false, last_cycle_tick=0}
end

state = state or get_default_state()

function isEnabled()
return enabled
return state.enabled
end

local function persist_state()
dfhack.persistent.saveSiteData(GLOBAL_KEY, {enabled=enabled})
dfhack.persistent.saveSiteData(GLOBAL_KEY, state)
end

local TICKS_PER_MONTH = 33600
local TICKS_PER_YEAR = 12 * TICKS_PER_MONTH

function desireToStay(unit,method,civ_id)
-- on a percentage scale
local value = 100 - unit.status.current_soul.personality.stress / 5000
Expand Down Expand Up @@ -191,27 +200,36 @@ function checkmigrationnow()
else
for _, civ_id in pairs(merchant_civ_ids) do checkForDeserters('merchant', civ_id) end
end

state.last_cycle_tick = dfhack.world.ReadCurrentTick() + TICKS_PER_YEAR * dfhack.world.ReadCurrentYear()
end

local function event_loop()
if enabled then
checkmigrationnow()
dfhack.timeout(1, 'months', event_loop)
if state.enabled then
local current_tick = dfhack.world.ReadCurrentTick() + TICKS_PER_YEAR * dfhack.world.ReadCurrentYear()
if current_tick - state.last_cycle_tick < TICKS_PER_MONTH then
local timeout_ticks = state.last_cycle_tick - current_tick + TICKS_PER_MONTH
dfhack.timeout(timeout_ticks, 'ticks', event_loop)
else
checkmigrationnow()
dfhack.timeout(1, 'months', event_loop)
end
end
end

dfhack.onStateChange[GLOBAL_KEY] = function(sc)
if sc == SC_MAP_UNLOADED then
enabled = false
state.enabled = false
return
end

if sc ~= SC_MAP_LOADED or df.global.gamemode ~= df.game_mode.DWARF then
return
end

local persisted_data = dfhack.persistent.getSiteData(GLOBAL_KEY, {enabled=false})
enabled = persisted_data.enabled
state = get_default_state()
utils.assign(state, dfhack.persistent.getSiteData(GLOBAL_KEY, state))

event_loop()
end

Expand All @@ -230,11 +248,11 @@ if dfhack_flags and dfhack_flags.enable then
end

if args[1] == "enable" then
enabled = true
state.enabled = true
elseif args[1] == "disable" then
enabled = false
state.enabled = false
else
print('emigration is ' .. (enabled and 'enabled' or 'not enabled'))
print('emigration is ' .. (state.enabled and 'enabled' or 'not enabled'))
return
end

Expand Down
23 changes: 1 addition & 22 deletions geld.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- Gelds or ungelds animals
-- Written by Josh Cooper(cppcooper) on 2019-12-10, last modified: 2020-02-23

utils = require('utils')

local validArgs = utils.invert({
Expand All @@ -11,29 +8,11 @@ local validArgs = utils.invert({
'find',
})
local args = utils.processArgs({...}, validArgs)
local help = [====[
geld
====
Geld allows the user to geld and ungeld animals.
Valid options:
``-unit <id>``: Gelds the unit with the specified ID.
This is optional; if not specified, the selected unit is used instead.
``-ungeld``: Ungelds the specified unit instead (see also `ungeld`).
``-toggle``: Toggles the gelded status of the specified unit.
``-help``: Shows this help information
]====]

unit=nil

if args.help then
print(help)
print(dfhack.script_help())
return
end

Expand Down
9 changes: 6 additions & 3 deletions gui/manipulator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1341,9 +1341,12 @@ function ManipulatorOverlay:init()
}
end

OVERLAY_WIDGETS = {
launcher=ManipulatorOverlay,
}
--
-- disable overlay widget while tool is still in dark launch mode
--
-- OVERLAY_WIDGETS = {
-- launcher=ManipulatorOverlay,
-- }

if dfhack_flags.module then return end

Expand Down
16 changes: 8 additions & 8 deletions gui/notify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ DwarfNotifyOverlay.ATTRS{
}

local DWARFMODE_CONFLICTING_TOOLTIPS = utils.invert{
df.main_hover_instruction.InfoUnits,
df.main_hover_instruction.InfoJobs,
df.main_hover_instruction.InfoPlaces,
df.main_hover_instruction.InfoLabors,
df.main_hover_instruction.InfoWorkOrders,
df.main_hover_instruction.InfoNobles,
df.main_hover_instruction.InfoObjects,
df.main_hover_instruction.InfoJustice,
df.main_hover_instruction.MAIN_OPEN_CREATURES,
df.main_hover_instruction.MAIN_OPEN_TASKS,
df.main_hover_instruction.MAIN_OPEN_PLACES,
df.main_hover_instruction.MAIN_OPEN_LABOR,
df.main_hover_instruction.MAIN_OPEN_WORK_ORDERS,
df.main_hover_instruction.MAIN_OPEN_NOBLES,
df.main_hover_instruction.MAIN_OPEN_OBJECTS,
df.main_hover_instruction.MAIN_OPEN_JUSTICE,
}

local mi = df.global.game.main_interface
Expand Down
Loading

0 comments on commit df6b940

Please sign in to comment.