Skip to content

Commit

Permalink
Merge pull request #1322 from myk002/myk_makeown_jobs
Browse files Browse the repository at this point in the history
[makeown] cancel hostile jobs
  • Loading branch information
myk002 authored Oct 5, 2024
2 parents 117a1e9 + 085c03e commit 174d303
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions makeown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 174d303

Please sign in to comment.