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
@@ -84,9 +84,10 @@ if unit then
8484 -- print("Refilling blood...")
8585 unit .body .blood_count = unit .body .blood_max
8686
87- -- print("Resetting grasp/stand status...")
87+ -- print("Resetting grasp/stand/fly status...")
8888 unit .status2 .limbs_stand_count = unit .status2 .limbs_stand_max
8989 unit .status2 .limbs_grasp_count = unit .status2 .limbs_grasp_max
90+ unit .status2 .limbs_fly_count = unit .status2 .limbs_fly_max
9091
9192 -- print("Resetting status flags...")
9293 unit .flags2 .has_breaks = false
@@ -101,7 +102,9 @@ if unit then
101102 unit .flags2 .calculated_nerves = false
102103 unit .flags2 .calculated_bodyparts = false
103104 unit .flags2 .calculated_insulation = false
105+ unit .flags3 .body_temp_in_range = false
104106 unit .flags3 .compute_health = true
107+ unit .flags3 .gelded = false
105108
106109 -- print("Resetting counters...")
107110 unit .counters .winded = 0
@@ -111,8 +114,16 @@ if unit then
111114 unit .counters .pain = 0
112115 unit .counters .nausea = 0
113116 unit .counters .dizziness = 0
117+ unit .counters .suffocation = 0
118+ unit .counters .guts_trail1 .x = - 30000
119+ unit .counters .guts_trail1 .y = - 30000
120+ unit .counters .guts_trail1 .z = - 30000
121+ unit .counters .guts_trail2 .x = - 30000
122+ unit .counters .guts_trail2 .y = - 30000
123+ unit .counters .guts_trail2 .z = - 30000
114124
115125 unit .counters2 .paralysis = 0
126+ unit .counters2 .numbness = 0
116127 unit .counters2 .fever = 0
117128 unit .counters2 .exhaustion = 0
118129 unit .counters2 .hunger_timer = 0
@@ -122,6 +133,8 @@ if unit then
122133
123134 unit .animal .vanish_countdown = 0
124135
136+ unit .body .infection_level = 0
137+
125138 -- print("Resetting body part status...")
126139 local comp = unit .body .components
127140 for i = 0 , # comp .nonsolid_remaining - 1 do
@@ -148,16 +161,68 @@ if unit then
148161 status .skin_damage = false
149162 status .motor_nerve_severed = false
150163 status .sensory_nerve_severed = false
164+ status .spilled_guts = false
165+ status .severed_or_jammed = false
151166 end
152167
153- for i , temp in ipairs (unit .status2 .body_part_temperature ) do
154- local bp = unit .body .body_plan .body_parts [i ]
155- temp .whole = math.floor ((bp .min_temp + bp .max_temp ) / 2 )
168+ for i = # unit .status2 .body_part_temperature - 1 ,0 ,- 1 do
169+ unit .status2 .body_part_temperature :erase (i ) -- attempting to rewrite temperature was causing body parts to melt for some reason; forcing repopulation in this manner appears to be safer
156170 end
157171
158- if unit .job .current_job and unit .job .current_job .job_type == df .job_type .Rest then
159- -- print("Wake from rest -> clean self...")
160- unit .job .current_job .job_type = df .job_type .CleanSelf
172+ for i = 0 ,# unit .enemy .body_part_8a8 - 1 ,1 do
173+ unit .enemy .body_part_8a8 [i ] = 1 -- not sure what this does, but values appear to change following injuries
174+ end
175+ for i = 0 ,# unit .enemy .body_part_8d8 - 1 ,1 do
176+ unit .enemy .body_part_8d8 [i ] = 0 -- same as above
177+ end
178+ for i = 0 ,# unit .enemy .body_part_878 - 1 ,1 do
179+ unit .enemy .body_part_878 [i ] = 3 -- as above
180+ end
181+ for i = 0 ,# unit .enemy .body_part_888 - 1 ,1 do
182+ unit .enemy .body_part_888 [i ] = 3 -- as above
183+ end
184+
185+ local histFig = df .historical_figure .find (unit .hist_figure_id )
186+ if histFig and histFig .info and histFig .info .wounds then
187+ -- print("Clearing historical wounds...")
188+ histFig .info .wounds = nil
189+ end
190+
191+ local health = unit .health
192+ if health then
193+ for i = 0 , # health .flags - 1 ,1 do
194+ health .flags [i ] = false
195+ end
196+ for _ ,bpFlags in ipairs (health .body_part_flags ) do
197+ for i = 0 , # bpFlags - 1 ,1 do
198+ bpFlags [i ] = false
199+ end
200+ end
201+ health .immobilize_cntdn = 0
202+ health .dressing_cntdn = 0
203+ health .suture_cntdn = 0
204+ health .crutch_cntdn = 0
205+ health .unk_18_cntdn = 0
206+ end
207+
208+ local job = unit .job .current_job
209+ if job and job .job_type == df .job_type .Rest then
210+ -- print("Wake from rest...")
211+ job .completion_timer = 0
212+ job .pos :assign (unit .pos )
213+ end
214+
215+ local job_link = df .global .world .jobs .list .next
216+ while job_link do
217+ local doctor_job = job_link .item
218+ if doctor_job then
219+ local patientRef = dfhack .job .getGeneralRef (doctor_job , df .general_ref_type [' UNIT_PATIENT' ])
220+ if patientRef and patientRef .unit_id == unit .id then
221+ patientRef .unit_id = - 1 -- causes active healthcare job to be cancelled, generating a job cancellation announcement indicating the lack of a patient
222+ break
223+ end
224+ end
225+ job_link = job_link .next
161226 end
162227end
163228
0 commit comments