From 085c03e677e9937aca1efe17991ba153c47cabc4 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 4 Oct 2024 23:50:51 -0700 Subject: [PATCH] cancel hostile jobs when makeown'd --- changelog.txt | 1 + makeown.lua | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/changelog.txt b/changelog.txt index 6f889e816..3809982b0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -35,6 +35,7 @@ Template for new versions: ## Fixes - `gui/quickfort`: only print a help blueprint's text once even if the repeat setting is enabled - `makeown`: quell any active enemy or conflict relationships with converted creatures +- `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 diff --git a/makeown.lua b/makeown.lua index 5ffc4bf7c..526528725 100644 --- a/makeown.lua +++ b/makeown.lua @@ -100,6 +100,17 @@ local function sanitize_profession(prof) return prof_map[prof] or prof end +local hostile_jobs = utils.invert{ + df.job_type.Kidnap, + df.job_type.HeistItem, + df.job_type.AcceptHeistItem, +} + +local function cancel_hostile_jobs(job) + if not job or not hostile_jobs[job.job_type] then return end + dfhack.job.removeJob(job) +end + local function fix_unit(unit) unit.flags1.marauder = false; unit.flags1.merchant = false; @@ -151,6 +162,8 @@ local function fix_unit(unit) end clear_enemy_status(unit) + + cancel_hostile_jobs(unit.job.current_job) end local function add_to_entity(hf, eid)