From 170565a1b6be39346bcbda7d779671bf9796ce34 Mon Sep 17 00:00:00 2001 From: unboundlopez Date: Fri, 8 Aug 2025 17:46:21 -0500 Subject: [PATCH 1/4] Update exterminate script and documentation --- exterminate.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/exterminate.lua b/exterminate.lua index 0263fbe483..0784bda8f7 100644 --- a/exterminate.lua +++ b/exterminate.lua @@ -1,6 +1,8 @@ --@module = true local argparse = require('argparse') +-- for profession constants +local profession = df.profession local function spawnLiquid(position, liquid_level, liquid_type, update_liquids) local map_block = dfhack.maps.getTileBlock(position) @@ -28,9 +30,14 @@ local function checkUnit(opts, unit) if not opts.include_friendly and not dfhack.units.isDanger(unit) and not dfhack.units.isWildlife(unit) then return false end + -- filter by caste if specified if opts.selected_caste and opts.selected_caste ~= df.creature_raw.find(unit.race).caste[unit.caste].caste_id then return false end + -- filter only children if requested + if opts.children_only and unit.profession ~= profession.CHILD then + return false + end return true end @@ -167,6 +174,7 @@ local options, args = { only_visible = false, include_friendly = false, limit = -1, + children_only = false, }, {...} local positionals = argparse.processArgsGetopt(args, { @@ -174,6 +182,7 @@ local positionals = argparse.processArgsGetopt(args, { {'m', 'method', handler = function(arg) options.method = killMethod[arg:upper()] end, hasArg = true}, {'o', 'only-visible', handler = function() options.only_visible = true end}, {'f', 'include-friendly', handler = function() options.include_friendly = true end}, + {'c', 'children-only', handler = function() options.children_only = true end}, {'l', 'limit', handler = function(arg) options.limit = argparse.positiveInt(arg, 'limit') end, hasArg = true}, }) @@ -308,4 +317,4 @@ else end end -print(([[Exterminated %d %s.]]):format(count, target)) +print(([[Exterminated %d %s.]]):format(count, target)) \ No newline at end of file From c24b0d46f3aac0bbab5b5c9088d54b2e200520ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Aug 2025 23:24:06 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- exterminate.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exterminate.lua b/exterminate.lua index 0784bda8f7..f46726f32f 100644 --- a/exterminate.lua +++ b/exterminate.lua @@ -317,4 +317,4 @@ else end end -print(([[Exterminated %d %s.]]):format(count, target)) \ No newline at end of file +print(([[Exterminated %d %s.]]):format(count, target)) From 8311f22ef9f40ff097c9b73b3dc8fae19f48ecf3 Mon Sep 17 00:00:00 2001 From: unboundlopez <47876628+unboundlopez@users.noreply.github.com> Date: Sun, 16 Nov 2025 12:03:57 -0600 Subject: [PATCH 3/4] Update exterminate.rst --- docs/exterminate.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/exterminate.rst b/docs/exterminate.rst index 9ce66b9791..1b5f3e874d 100644 --- a/docs/exterminate.rst +++ b/docs/exterminate.rst @@ -36,6 +36,9 @@ Examples Kill all non-friendly creatures. ``exterminate all:MALE`` Kill all non-friendly male creatures. +``exterminate all --children-only`` + Kill only non-friendly child units. Helpful for automated cleanup routines + that run on a schedule. Options ------- @@ -49,6 +52,10 @@ Options Specifies the tool should also kill units friendly to the player. ``-l``, ``--limit `` Set the maximum number of units to exterminate. +``-c``, ``--children-only`` + Target only child units. Useful for timer-based automation scripts + that periodically remove wandering poults or other child creatures + that may endanger dwarven children. Methods ------- From 63701bd3072ba33b3504ad051a5fd0c7918206ab Mon Sep 17 00:00:00 2001 From: unboundlopez <47876628+unboundlopez@users.noreply.github.com> Date: Sun, 16 Nov 2025 12:09:57 -0600 Subject: [PATCH 4/4] Update exterminate.rst --- docs/exterminate.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/exterminate.rst b/docs/exterminate.rst index 1b5f3e874d..a1363a5593 100644 --- a/docs/exterminate.rst +++ b/docs/exterminate.rst @@ -36,9 +36,9 @@ Examples Kill all non-friendly creatures. ``exterminate all:MALE`` Kill all non-friendly male creatures. -``exterminate all --children-only`` - Kill only non-friendly child units. Helpful for automated cleanup routines - that run on a schedule. +``exterminate -f -c bird_turkey -m knockout` + Target all turkey children on the map, including friendly ones, and put them + into an unconscious state. Options -------