Skip to content

Commit

Permalink
Now using quickfort, added zlevel option
Browse files Browse the repository at this point in the history
  • Loading branch information
tmqCypher committed Oct 12, 2023
1 parent 0b1dbac commit 218cae6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 30 deletions.
47 changes: 26 additions & 21 deletions burial.lua
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
-- Allows burial in unowned coffins.
-- Based on Putnam's work (https://gist.github.com/Putnam3145/e7031588f4d9b24b9dda)
local argparse = require('argparse')
local utils = require('utils')
local quickfort = reqscript('quickfort')

local args = argparse.processArgs({...}, utils.invert{'d', 'p'})
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 ''),
}

for i, c in pairs(df.global.world.buildings.other.COFFIN) do
-- Check for existing tomb
for i, z in pairs(c.relations) do
if z.type == df.civzone_type.Tomb then
local tomb_count = 0
for _, coffin in pairs(df.global.world.buildings.other.COFFIN) do

if cur_zlevel and not (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

dfhack.buildings.constructBuilding {
type = df.building_type.Civzone,
subtype = df.civzone_type.Tomb,
pos = xyz2pos(c.x1, c.y1, c.z),
abstract = true,
fields = {
is_active = 8,
zone_settings = {
tomb = {
no_pets = args.d and not args.p,
no_citizens = args.p and not args.d,
},
},
},
}
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 tombs.'):format(tomb_count))
38 changes: 29 additions & 9 deletions docs/burial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,42 @@ burial

.. dfhack-tool::
:summary: Allows burial in unowned coffins.
:tags: fort productivity buildings
:tags: fort | productivity | buildings

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

Usage
-----

``burial [-d] [-p]``
``burial [<options>]``

Created tombs allow both dwarves and pets by default. By specifying ``-d`` or
``-p``, they can be restricted to dwarves or pets, respectively.
Examples
--------

``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
-------

``-d``
Create dwarf-only tombs
``-p``
Create pet-only tombs
``-z``, ``--cur-zlevel``
Only create tombs on the current zlevel.

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

``-p``, ``--pets-only``
Only automatically bury pets.

0 comments on commit 218cae6

Please sign in to comment.