-
Notifications
You must be signed in to change notification settings - Fork 555
/
living_health_procs.dm
604 lines (503 loc) · 17.1 KB
/
living_health_procs.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
//procs directly related to mob health
/mob/living/getBruteLoss()
return bruteloss
/mob/living/proc/adjustBruteLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
bruteloss = min(max(bruteloss + amount, 0),(maxHealth*2))
/mob/living/getOxyLoss()
return oxyloss
/mob/living/proc/adjustOxyLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
oxyloss = min(max(oxyloss + amount, 0),(maxHealth*2))
/mob/living/proc/setOxyLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
oxyloss = amount
/mob/living/getToxLoss()
return toxloss
/mob/living/proc/adjustToxLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
toxloss = min(max(toxloss + amount, 0),(maxHealth*2))
/mob/living/proc/setToxLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
toxloss = amount
/mob/living/getFireLoss()
return fireloss
/mob/living/proc/adjustFireLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
fireloss = min(max(fireloss + amount, 0),(maxHealth*2))
/mob/living/getCloneLoss()
return cloneloss
/mob/living/proc/adjustCloneLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
cloneloss = min(max(cloneloss + amount, 0),(maxHealth*2))
/mob/living/proc/setCloneLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
cloneloss = amount
/mob/living/getBrainLoss()
return brainloss
/mob/living/proc/adjustBrainLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
if(ishuman(src))
var/mob/living/carbon/human/H = src
if(H.chem_effect_flags & CHEM_EFFECT_RESIST_NEURO)
return
brainloss = min(max(brainloss + amount, 0),(maxHealth*2))
/mob/living/proc/setBrainLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
brainloss = amount
/mob/living/getHalLoss()
return halloss
/mob/living/proc/adjustHalLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
halloss = min(max(halloss + amount, 0),(maxHealth*2))
/mob/living/proc/setHalLoss(amount)
if(status_flags & GODMODE) return 0 //godmode
halloss = amount
/mob/living/proc/getMaxHealth()
return maxHealth
/mob/living/proc/setMaxHealth(newMaxHealth)
maxHealth = newMaxHealth
/* STUN (Incapacitation) */
/// Overridable handler to adjust the numerical value of status effects. Expand as needed
/mob/living/proc/GetStunDuration(amount)
return amount * GLOBAL_STATUS_MULTIPLIER
/mob/living/proc/IsStun() //If we're stunned
return has_status_effect(/datum/status_effect/incapacitating/stun)
/mob/living/proc/AmountStun() //How much time remain in our stun - scaled by GLOBAL_STATUS_MULTIPLIER (normally in multiples of legacy 2 seconds)
var/datum/status_effect/incapacitating/stun/S = IsStun()
if(S)
return S.get_duration_left() / GLOBAL_STATUS_MULTIPLIER
return 0
/mob/living/proc/Stun(amount)
if(!(status_flags & CANSTUN))
return
amount = GetStunDuration(amount)
var/datum/status_effect/incapacitating/stun/S = IsStun()
if(S)
S.update_duration(amount, increment = TRUE)
else if(amount > 0)
S = apply_status_effect(/datum/status_effect/incapacitating/stun, amount)
return S
/mob/living/proc/SetStun(amount, ignore_canstun = FALSE) //Sets remaining duration
if(!(status_flags & CANSTUN))
return
amount = GetStunDuration(amount)
var/datum/status_effect/incapacitating/stun/S = IsStun()
if(amount <= 0)
if(S)
qdel(S)
else
if(S)
S.update_duration(amount)
else
S = apply_status_effect(/datum/status_effect/incapacitating/stun, amount)
return S
/mob/living/proc/AdjustStun(amount, ignore_canstun = FALSE) //Adds to remaining duration
if(!(status_flags & CANSTUN))
return
amount = GetStunDuration(amount)
var/datum/status_effect/incapacitating/stun/S = IsStun()
if(S)
S.adjust_duration(amount)
else if(amount > 0)
S = apply_status_effect(/datum/status_effect/incapacitating/stun, amount)
return S
/* ROOT (Immobilisation) */
/// Overridable handler to adjust the numerical value of status effects. Expand as needed
/mob/living/proc/GetRootDuration(amount)
return amount * GLOBAL_STATUS_MULTIPLIER
/mob/living/proc/IsRoot() //If we're stunned
return has_status_effect(/datum/status_effect/incapacitating/immobilized)
/mob/living/proc/AmountRoot() //How much time remain in our stun - scaled by GLOBAL_STATUS_MULTIPLIER (normally in multiples of legacy 2 seconds)
var/datum/status_effect/incapacitating/immobilized/root = IsRoot()
if(root)
return root.get_duration_left() / GLOBAL_STATUS_MULTIPLIER
return FALSE
/mob/living/proc/Root(amount)
if(!(status_flags & CANROOT))
return
amount = GetRootDuration(amount)
var/datum/status_effect/incapacitating/immobilized/root = IsRoot()
if(root)
root.update_duration(amount, increment = TRUE)
else if(amount > 0)
root = apply_status_effect(/datum/status_effect/incapacitating/immobilized, amount)
return root
/mob/living/proc/SetRoot(amount) //Sets remaining duration
if(!(status_flags & CANROOT))
return
amount = GetRootDuration(amount)
var/datum/status_effect/incapacitating/immobilized/root = IsRoot()
if(amount <= 0)
if(root)
qdel(root)
else
if(root)
root.update_duration(amount)
else
root = apply_status_effect(/datum/status_effect/incapacitating/immobilized, amount)
return root
/mob/living/proc/AdjustRoot(amount) //Adds to remaining duration
if(!(status_flags & CANROOT))
return
amount = GetRootDuration(amount)
var/datum/status_effect/incapacitating/immobilized/root = IsRoot()
if(root)
root.adjust_duration(amount)
else if(amount > 0)
root = apply_status_effect(/datum/status_effect/incapacitating/immobilized, amount)
return root
/* DAZE (Light incapacitation) */
/// Overridable handler to adjust the numerical value of status effects. Expand as needed
/mob/living/proc/GetDazeDuration(amount)
return amount * GLOBAL_STATUS_MULTIPLIER
/mob/living/proc/IsDaze() //If we're stunned
return has_status_effect(/datum/status_effect/incapacitating/dazed)
/mob/living/proc/AmountDaze() //How many deciseconds remains
var/datum/status_effect/incapacitating/dazed/dazed = IsDaze()
if(dazed)
return dazed.get_duration_left() / GLOBAL_STATUS_MULTIPLIER
return 0
/mob/living/proc/Daze(amount)
if(!(status_flags & CANDAZE))
return
amount = GetDazeDuration(amount)
var/datum/status_effect/incapacitating/dazed/dazed = IsDaze()
if(dazed)
dazed.update_duration(amount, increment = TRUE)
else if(amount > 0)
dazed = apply_status_effect(/datum/status_effect/incapacitating/dazed, amount)
return dazed
/mob/living/proc/SetDaze(amount, ignore_canstun = FALSE) //Sets remaining duration
if(!(status_flags & CANDAZE))
return
amount = GetDazeDuration(amount)
var/datum/status_effect/incapacitating/dazed/dazed = IsDaze()
if(amount <= 0)
if(dazed)
qdel(dazed)
else
if(dazed)
dazed.update_duration(amount)
else
dazed = apply_status_effect(/datum/status_effect/incapacitating/dazed, amount)
return dazed
/mob/living/proc/AdjustDaze(amount, ignore_canstun = FALSE) //Adds to remaining duration
if(!(status_flags & CANDAZE))
return
amount = GetStunDuration(amount)
var/datum/status_effect/incapacitating/dazed/dazed = IsDaze()
if(dazed)
dazed.adjust_duration(amount)
else if(amount > 0)
dazed = apply_status_effect(/datum/status_effect/incapacitating/dazed, amount)
return dazed
/mob/living/proc/Slow(amount)
if(status_flags & CANSLOW)
slowed = max(slowed, amount, 0)
return
/mob/living/proc/SetSlow(amount)
if(status_flags & CANSLOW)
slowed = max(amount,0)
return
/mob/living/proc/AdjustSlow(amount)
SetSlow(amount + slowed)
return
/mob/living/proc/Superslow(amount)
if(status_flags & CANSLOW)
superslowed = max(superslowed, amount, 0)
return
/mob/living/proc/SetSuperslow(amount)
if(status_flags & CANSLOW)
superslowed = max(amount,0)
return
/mob/living/proc/AdjustSuperslow(amount)
SetSuperslow(superslowed + amount)
return
/* KnockDown (Flooring) */
/// Overridable handler to adjust the numerical value of status effects. Expand as needed
/mob/living/proc/GetKnockDownDuration(amount)
return amount * GLOBAL_STATUS_MULTIPLIER
/mob/living/proc/IsKnockDown()
return has_status_effect(/datum/status_effect/incapacitating/knockdown)
///How much time remains - scaled by GLOBAL_STATUS_MULTIPLIER (normally in multiples of legacy 2 seconds)
/mob/living/proc/AmountKnockDown()
var/datum/status_effect/incapacitating/knockdown/S = IsKnockDown()
if(S)
return S.get_duration_left() / GLOBAL_STATUS_MULTIPLIER
return 0
/mob/living/proc/KnockDown(amount)
if(!(status_flags & CANKNOCKDOWN))
return
amount = GetKnockDownDuration(amount)
var/datum/status_effect/incapacitating/knockdown/S = IsKnockDown()
if(S)
S.update_duration(amount, increment = TRUE)
else if(amount > 0)
S = apply_status_effect(/datum/status_effect/incapacitating/knockdown, amount)
return S
///Sets exact remaining KnockDown duration
/mob/living/proc/SetKnockDown(amount, ignore_canstun = FALSE)
if(!(status_flags & CANKNOCKDOWN))
return
amount = GetKnockDownDuration(amount)
var/datum/status_effect/incapacitating/knockdown/S = IsKnockDown()
if(amount <= 0)
if(S)
qdel(S)
else
if(S)
S.update_duration(amount)
else
S = apply_status_effect(/datum/status_effect/incapacitating/knockdown, amount)
return S
///Adds to remaining Knockdown duration
/mob/living/proc/AdjustKnockDown(amount, ignore_canstun = FALSE)
if(!(status_flags & CANKNOCKDOWN))
return
amount = GetKnockDownDuration(amount)
var/datum/status_effect/incapacitating/knockdown/S = IsKnockDown()
if(S)
S.adjust_duration(amount)
else if(amount > 0)
S = apply_status_effect(/datum/status_effect/incapacitating/knockdown, amount)
return S
/* KnockOut (Unconscious) */
/// Overridable handler to adjust the numerical value of status effects. Expand as needed
/mob/living/proc/GetKnockOutDuration(amount)
return amount * GLOBAL_STATUS_MULTIPLIER
/mob/living/proc/IsKnockOut()
return has_status_effect(/datum/status_effect/incapacitating/unconscious)
/mob/living/proc/AmountKnockOut() //How much time remains - scaled by GLOBAL_STATUS_MULTIPLIER (normally in multiples of legacy 2 seconds)
var/datum/status_effect/incapacitating/unconscious/S = IsKnockOut()
if(S)
return S.get_duration_left() / GLOBAL_STATUS_MULTIPLIER
return 0
/// Sets Knockout duration to at least the amount provided
/mob/living/proc/KnockOut(amount)
if(!(status_flags & CANKNOCKOUT))
return
amount = GetKnockOutDuration(amount)
var/datum/status_effect/incapacitating/unconscious/S = IsKnockOut()
if(S)
S.update_duration(amount, increment = TRUE)
else if(amount > 0)
S = apply_status_effect(/datum/status_effect/incapacitating/unconscious, amount)
return S
/// Sets exact remaining Knockout duration
/mob/living/proc/SetKnockOut(amount, ignore_canstun = FALSE)
if(!(status_flags & CANKNOCKOUT))
return
amount = GetKnockOutDuration(amount)
var/datum/status_effect/incapacitating/unconscious/S = IsKnockOut()
if(amount <= 0)
if(S)
qdel(S)
else
if(S)
S.update_duration(amount)
else
S = apply_status_effect(/datum/status_effect/incapacitating/unconscious, amount)
return S
/// Adds to remaining Knockout duration
/mob/living/proc/AdjustKnockOut(amount, ignore_canstun = FALSE)
if(!(status_flags & CANKNOCKOUT))
return
amount = GetKnockOutDuration(amount)
var/datum/status_effect/incapacitating/unconscious/S = IsKnockOut()
if(S)
S.adjust_duration(amount)
else if(amount > 0)
S = apply_status_effect(/datum/status_effect/incapacitating/unconscious, amount)
return S
/mob/living/proc/Sleeping(amount)
sleeping = max(max(sleeping,amount),0)
return
/mob/living/proc/SetSleeping(amount)
sleeping = max(amount,0)
return
/mob/living/proc/AdjustSleeping(amount)
sleeping = max(sleeping + amount,0)
return
/mob/living/proc/EyeBlur(amount)
eye_blurry = max(max(eye_blurry, amount), 0)
update_eye_blur()
return
/mob/living/proc/SetEyeBlur(amount)
eye_blurry = max(amount, 0)
update_eye_blur()
return
/mob/living/proc/AdjustEyeBlur(amount)
eye_blurry = max(eye_blurry + amount, 0)
update_eye_blur()
return
/mob/living/proc/ReduceEyeBlur(amount)
eye_blurry = max(eye_blurry - amount, 0)
update_eye_blur()
return
///Apply the blurry overlays to a mobs clients screen
/mob/living/proc/update_eye_blur()
if(!client)
return
var/atom/movable/plane_master_controller/game_plane_master_controller = hud_used.plane_master_controllers[PLANE_MASTERS_GAME]
if(!eye_blurry)
clear_fullscreen("eye_blur", 0.5 SECONDS)
game_plane_master_controller.remove_filter("eye_blur")
return
switch(client.prefs?.pain_overlay_pref_level)
if(PAIN_OVERLAY_IMPAIR)
overlay_fullscreen("eye_blur", /atom/movable/screen/fullscreen/impaired, ceil(clamp(eye_blurry * 0.3, 1, 6)))
if(PAIN_OVERLAY_LEGACY)
overlay_fullscreen("eye_blur", /atom/movable/screen/fullscreen/blurry)
else // PAIN_OVERLAY_BLURRY
game_plane_master_controller.add_filter("eye_blur", 1, gauss_blur_filter(clamp(eye_blurry * 0.1, 0.6, 3)))
/mob/living/proc/TalkStutter(amount)
stuttering = max(max(stuttering, amount), 0)
return
/mob/living/proc/SetTalkStutter(amount)
stuttering = max(amount, 0)
return
/mob/living/proc/AdjustTalkStutter(amount)
stuttering = max(stuttering + amount,0)
return
/mob/living/proc/SetEyeBlind(amount)
eye_blind = max(amount, 0)
return
/mob/living/proc/AdjustEyeBlind(amount)
eye_blind = max(eye_blind + amount, 0)
return
/mob/living/proc/ReduceEyeBlind(amount)
eye_blind = max(eye_blind - amount, 0)
return
/mob/living/proc/AdjustEarDeafness(amount)
var/prev_deaf = ear_deaf
ear_deaf = clamp(ear_deaf + amount, 0, 30) //roughly 1 minute
if(prev_deaf)
if(ear_deaf == 0)
on_deafness_loss()
else if(ear_deaf)
on_deafness_gain()
/mob/living/proc/SetEarDeafness(amount)
var/prev_deaf = ear_deaf
ear_deaf = max(amount, 0)
if(prev_deaf)
if(ear_deaf == 0)
on_deafness_loss()
else if(ear_deaf)
on_deafness_gain()
/mob/living/proc/on_deafness_gain()
to_chat(src, SPAN_WARNING("You notice you can't hear anything... you're deaf!"))
// We should apply deafness here instead of in handle_regular_status_updates
SEND_SIGNAL(src, COMSIG_MOB_DEAFENED)
/mob/living/proc/on_deafness_loss()
to_chat(src, SPAN_WARNING("You start hearing things again!"))
SEND_SIGNAL(src, COMSIG_MOB_REGAINED_HEARING)
// Consider moving this to a signal on soundOutput. This is a fallback as handle_regular_status_updates SHOULD do the job.
if(!ear_deaf && (client?.soundOutput?.status_flags & EAR_DEAF_MUTE))
client.soundOutput.status_flags ^= EAR_DEAF_MUTE
client.soundOutput.apply_status()
// heal ONE limb, organ gets randomly selected from damaged ones.
/mob/living/proc/heal_limb_damage(brute, burn)
apply_damage(-brute, BRUTE)
apply_damage(-burn, BURN)
src.updatehealth()
// damage ONE limb, organ gets randomly selected from damaged ones.
/mob/living/proc/take_limb_damage(brute, burn)
if(status_flags & GODMODE) return 0 //godmode
apply_damage(brute, BRUTE)
apply_damage(burn, BURN)
src.updatehealth()
// heal MANY limbs, in random order
/mob/living/proc/heal_overall_damage(brute, burn)
apply_damage(-brute, BRUTE)
apply_damage(-burn, BURN)
src.updatehealth()
// damage MANY limbs, in random order
/mob/living/proc/take_overall_damage(brute, burn, used_weapon = null, limb_damage_chance = 80)
if(status_flags & GODMODE) return 0 //godmode
apply_damage(brute, BRUTE)
apply_damage(burn, BURN)
src.updatehealth()
/mob/living/proc/restore_all_organs()
return
/mob/living/proc/revive(keep_viruses)
rejuvenate()
/mob/living/proc/rejuvenate()
heal_all_damage()
// shut down ongoing problems
status_flags &= ~PERMANENTLY_DEAD
nutrition = NUTRITION_NORMAL
bodytemperature = T20C
recalculate_move_delay = TRUE
sdisabilities = 0
disabilities = 0
drowsyness = 0
hallucination = 0
jitteriness = 0
dizziness = 0
stamina.apply_damage(-stamina.max_stamina)
// restore all of a human's blood
if(ishuman(src))
var/mob/living/carbon/human/H = src
H.restore_blood()
H.reagents.clear_reagents() //and clear all reagents in them
SShuman.processable_human_list |= H
H.undefibbable = FALSE
H.chestburst = 0
H.update_headshot_overlay() //They don't have their brains blown out anymore, if they did.
// fix all of our organs
restore_all_organs()
//Reset any surgeries.
active_surgeries = DEFENSE_ZONES_LIVING
initialize_incision_depths()
// remove the character from the list of the dead
if(stat == DEAD)
GLOB.dead_mob_list -= src
GLOB.alive_mob_list += src
tod = null
timeofdeath = 0
// restore us to consciousness
set_stat(CONSCIOUS)
regenerate_all_icons()
SEND_SIGNAL(src, COMSIG_LIVING_REJUVENATED)
/mob/living/proc/heal_all_damage()
// shut down various types of badness
heal_overall_damage(getBruteLoss(), getFireLoss())
setToxLoss(0)
setOxyLoss(0)
setCloneLoss(0)
setBrainLoss(0)
set_effect(0, PARALYZE)
set_effect(0, STUN)
set_effect(0, DAZE)
set_effect(0, SLOW)
set_effect(0, SUPERSLOW)
set_effect(0, WEAKEN)
ExtinguishMob()
fire_stacks = 0
// fix blindness and deafness
blinded = FALSE
SetEyeBlind(0)
SetEyeBlur(0)
SetEarDeafness(0)
ear_damage = 0
paralyzed = 0
confused = 0
druggy = 0
/mob/living/proc/regenerate_all_icons()
// make the icons look correct
regenerate_icons()
med_hud_set_status()
med_hud_set_health()
med_hud_set_armor()
reload_fullscreens()
if(ishuman(src))
var/mob/living/carbon/human/H = src
H.update_body()
/mob/living/keybind_face_direction(direction)
if(!canface())
return
if(stat >= UNCONSCIOUS)
return
face_dir(direction)
return ..()