Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[timestream] appropriately speed up eating and drinking #1247

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Template for new versions:
- `full-heal`: fix ``-r --all_citizens`` option combination not resurrecting citizens
- `open-legends`: don't intercept text bound for vanilla search widgets
- `gui/unit-info-viewer`: correctly display skill levels when rust is involved
- `timestream`: fix dwarves spending too long eating and drinking
- `build-now`: fix error when building buildings that (in previous DF versions) required the architecture labor
- `prioritize`: fix incorrect loading of persisted data on some OS types
- `list-waves`: no longer gets confused by units that leave the map and then return (e.g. squads who go out on raids)
Expand Down
14 changes: 14 additions & 0 deletions timestream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ local function adjust_unit_counters(unit, timeskip)
-- stored_fat wanders about based on other state; we can probably leave it alone
end

-- TODO: the rquired algorithm is not yet fully known. for many job types, the decrement per
-- tick is <= 1 and depends on unit skills
local function adjust_job_counter(unit, timeskip)
local job = unit.job.current_job
if not job then return end
local job_type = job.job_type
if job_type == df.job_type.Eat or
job_type == df.job_type.Drink
then
decrement_counter(job, 'completion_timer', timeskip)
end
end

-- unit needs appear to be incremented on season ticks, so we don't need to worry about those
local function adjust_units(timeskip)
for _, unit in ipairs(df.global.world.units.active) do
Expand All @@ -146,6 +159,7 @@ local function adjust_units(timeskip)
dfhack.units.subtractGroupActionTimers(unit, timeskip, df.unit_action_type_group.All)
if not dfhack.units.isOwnGroup(unit) then goto continue end
adjust_unit_counters(unit, timeskip)
adjust_job_counter(unit, timeskip)
::continue::
end
end
Expand Down