Skip to content

Commit 9c11f53

Browse files
cancel active healthcare jobs
so as to prevent the buggy behaviour that is produced by healing a unit whilst it is the target of medical jobs
1 parent b13cd4d commit 9c11f53

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

full-heal.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- Attempts to fully heal the selected unit
22
--author Kurik Amudnil, Urist DaVinci
3-
--edited by expwnent
3+
--edited by expwnent and AtomicChicken
44

55
--[====[
66
@@ -188,5 +188,18 @@ if unit then
188188
job.completion_timer = 0
189189
job.pos:assign(unit.pos)
190190
end
191+
192+
local job_link = df.global.world.jobs.list.next
193+
while job_link do
194+
local doctor_job = job_link.item
195+
if doctor_job then
196+
local patientRef = dfhack.job.getGeneralRef(doctor_job, df.general_ref_type['UNIT_PATIENT'])
197+
if patientRef and patientRef.unit_id == unit.id then
198+
patientRef.unit_id = -1 -- causes active healthcare job to be cancelled, generating a job cancellation announcement indicating the lack of a patient
199+
break
200+
end
201+
end
202+
job_link = job_link.next
203+
end
191204
end
192205

0 commit comments

Comments
 (0)