Skip to content

Commit

Permalink
Merge branch 'master' into corrupt_job_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 authored Oct 14, 2023
2 parents 6259231 + 9c77c52 commit 12961d1
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 44 deletions.
51 changes: 31 additions & 20 deletions burial.lua
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
-- allows burial in unowned coffins
-- by Putnam https://gist.github.com/Putnam3145/e7031588f4d9b24b9dda
--[====[
-- Allows burial in unowned coffins.
-- Based on Putnam's work (https://gist.github.com/Putnam3145/e7031588f4d9b24b9dda)
local argparse = require('argparse')
local quickfort = reqscript('quickfort')

burial
======
Sets all unowned coffins to allow burial. ``burial -pets`` also allows burial
of pets.
]====]

local utils=require('utils')

local validArgs = utils.invert({
'pets'
local cur_zlevel, citizens, pets = false, true, true
argparse.processArgsGetopt({...}, {
{'z', 'cur-zlevel', handler=function() cur_zlevel = true end},
{'c', 'citizens-only', handler=function() pets = false end},
{'p', 'pets-only', handler=function() citizens = false end},
})
local tomb_blueprint = {
mode = 'zone',
pos = nil,
-- Don't pass properties with default values to avoid 'unhandled property' warning
data = ('T{%s %s}'):format(citizens and '' or 'citizens=false', pets and 'pets=true' or ''),
}

local args = utils.processArgs({...}, validArgs)
local tomb_count = 0
for _, coffin in pairs(df.global.world.buildings.other.COFFIN) do

for k,v in ipairs(df.global.world.buildings.other.COFFIN) do --as:df.building_coffinst
if v.owner_id==-1 then
v.burial_mode.allow_burial=true
if not args.pets then
v.burial_mode.no_pets=true
if cur_zlevel and coffin.z ~= df.global.window_z then
goto skip
end
for _, zone in pairs(coffin.relations) do
if zone.type == df.civzone_type.Tomb then
goto skip
end
end

tomb_blueprint.pos = xyz2pos(coffin.x1, coffin.y1, coffin.z)
quickfort.apply_blueprint(tomb_blueprint)
tomb_count = tomb_count + 1

::skip::
end

print(('Created %s tomb(s).'):format(tomb_count))
5 changes: 4 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@ Template for new versions:

## New Tools
- `add-recipe`: (reinstated) add reactions to your civ (e.g. for high boots if your civ didn't start with the ability to make high boots)
- `fix/corrupt-jobs`: removes corrupted jobs from units at world load
- `fix/corrupt-jobs`: prevents crashes by automatically removing corrupted jobs
- `burial`: (reinstated) create tomb zones for unzoned coffins

## New Features
- `burial`: new options to configure automatic burial and limit scope to the current z-level
- `drain-aquifer`: gained ability to drain just above or below a certain z-level
- `drain-aquifer`: new option to drain all layers except for the first N aquifer layers, in case you want some aquifer layers but not too many
- `gui/control-panel`: ``drain-aquifer --top 2`` added as an autostart option

## Fixes
- `suspendmanager`: fix errors when constructing near the map edge
- `gui/sandbox`: fix scrollbar moving double distance on click
- `hide-tutorials`: fix the embark tutorial prompt sometimes not being skipped

## Misc Improvements

Expand Down
41 changes: 32 additions & 9 deletions docs/burial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,43 @@ burial
======

.. dfhack-tool::
:summary: Configures all unowned coffins to allow burial.
:tags: unavailable fort productivity buildings
:summary: Create tomb zones for unzoned coffins.
:tags: fort productivity buildings

Creates a 1x1 tomb zone for each built coffin that isn't already in a tomb.

Usage
-----

::

burial [--pets]

if the ``--pets`` option is passed, coffins will also allow burial of pets.
``burial [<options>]``

Examples
--------

``burial --pets``
Configures all unowned coffins to allow burial, including pets.
``burial``
Create a tomb for every coffin on the map with automatic burial enabled.

``burial -z``
Create tombs only on the current zlevel.

``burial -c``
Create tombs designated for automatic burial of citizens only.

``burial -p``
Create tombs designated for automatic burial of pets only.

``burial -cp``
Create tombs with automatic burial disabled for both citizens and pets,
requiring manual assignment of deceased units to each tomb.

Options
-------

``-z``, ``--cur-zlevel``
Only create tombs on the current zlevel.

``-c``, ``--citizens-only``
Only automatically bury citizens.

``-p``, ``--pets-only``
Only automatically bury pets.
2 changes: 1 addition & 1 deletion forbid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ end
if positionals[1] == "unreachable" then
print("Forbidding all unreachable items on the map...")

local citizens = dfhack.units.getCitizens()
local citizens = dfhack.units.getCitizens(true)
local count = 0

for _, item in pairs(df.global.world.items.all) do
Expand Down
12 changes: 10 additions & 2 deletions hide-tutorials.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ local function close_help()
help.open = false
end

function skip_tutorial_prompt(scr)
function skip_tutorial_prompt()
if not help.open then return end
local scr = dfhack.gui.getDFViewscreen(true)
local mouse_y = 23
if help.context == df.help_context_type.EMBARK_TUTORIAL_CHOICE then
help.context = df.help_context_type.EMBARK_MESSAGE
Expand All @@ -36,6 +37,10 @@ function skip_tutorial_prompt(scr)
df.global.gps.mouse_y = mouse_y
gui.simulateInput(scr, '_MOUSE_L')
end
if help.open then
-- retry later
help.context = df.help_context_type.EMBARK_TUTORIAL_CHOICE
end
end

local function hide_all_popups()
Expand All @@ -55,7 +60,10 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc)
if df.viewscreen_new_regionst:is_instance(scr) then
close_help()
elseif df.viewscreen_choose_start_sitest:is_instance(scr) then
skip_tutorial_prompt(scr)
skip_tutorial_prompt()
dfhack.timeout(10, 'frames', skip_tutorial_prompt)
dfhack.timeout(100, 'frames', skip_tutorial_prompt)
dfhack.timeout(1000, 'frames', skip_tutorial_prompt)
end
elseif sc == SC_MAP_LOADED and df.global.gamemode == df.game_mode.DWARF then
hide_all_popups()
Expand Down
26 changes: 16 additions & 10 deletions modtools/transform-unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,17 @@ if args.clear then
return
end

if not args.unit then
error 'Specify a unit.'
local unit
if args.unit then
unit = df.unit.find(tonumber(args.unit))
else
unit = dfhack.gui.getSelectedUnit(true)
end
if not unit then
error 'Select or specify a valid unit'
return
end
local unit_id = unit.id

if not args.duration then
args.duration = 'forever'
Expand All @@ -78,11 +86,10 @@ local raceIndex
local race
local caste
if args.untransform then
local unit = df.unit.find(tonumber(args.unit))
raceIndex = normalRace[args.unit].race
raceIndex = normalRace[unit_id].race
race = df.creature_raw.find(raceIndex)
caste = normalRace[args.unit].caste
normalRace[args.unit] = nil
caste = normalRace[unit_id].caste
normalRace[unit_id] = nil
else
if not args.race or not args.caste then
error 'Specficy a target form.'
Expand Down Expand Up @@ -113,13 +120,12 @@ else
end
end

local unit = df.unit.find(tonumber(args.unit))
local oldRace = unit.enemy.normal_race
local oldCaste = unit.enemy.normal_caste
if args.setPrevRace then
normalRace[args.unit] = {}
normalRace[args.unit].race = oldRace
normalRace[args.unit].caste = oldCaste
normalRace[unit_id] = {}
normalRace[unit_id].race = oldRace
normalRace[unit_id].caste = oldCaste
end
transform(unit,raceIndex,caste,args.setPrevRace)

Expand Down
2 changes: 1 addition & 1 deletion unforbid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local argparse = require('argparse')
local function unforbid_all(include_unreachable, quiet)
if not quiet then print('Unforbidding all items...') end

local citizens = dfhack.units.getCitizens()
local citizens = dfhack.units.getCitizens(true)
local count = 0
for _, item in pairs(df.global.world.items.all) do
if item.flags.forbid then
Expand Down

0 comments on commit 12961d1

Please sign in to comment.