/
carbon.dm
1492 lines (1264 loc) · 49.1 KB
/
carbon.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
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/mob/living/carbon/Initialize(mapload)
. = ..()
create_carbon_reagents()
update_body_parts() //to update the carbon's new bodyparts appearance
register_context()
GLOB.carbon_list += src
ADD_TRAIT(src, TRAIT_CAN_HOLD_ITEMS, INNATE_TRAIT) // Carbons are assumed to be innately capable of having arms, we check their arms count instead
/mob/living/carbon/Destroy()
//This must be done first, so the mob ghosts correctly before DNA etc is nulled
. = ..()
QDEL_LIST(hand_bodyparts)
QDEL_LIST(organs)
QDEL_LIST(bodyparts)
QDEL_LIST(implants)
for(var/wound in all_wounds) // these LAZYREMOVE themselves when deleted so no need to remove the list here
qdel(wound)
for(var/scar in all_scars)
qdel(scar)
remove_from_all_data_huds()
QDEL_NULL(dna)
GLOB.carbon_list -= src
/mob/living/carbon/item_tending(mob/living/user, obj/item/tool, list/modifiers)
. = ..()
if(. & ITEM_INTERACT_ANY_BLOCKER)
return .
for(var/datum/wound/wound as anything in shuffle(all_wounds))
if(wound.try_treating(tool, user))
return ITEM_INTERACT_SUCCESS
return .
/mob/living/carbon/CtrlShiftClick(mob/user)
..()
if(iscarbon(user))
var/mob/living/carbon/carbon_user = user
carbon_user.give(src)
/mob/living/carbon/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum)
. = ..()
var/hurt = TRUE
var/extra_speed = 0
var/oof_noise = FALSE //We smacked something with denisty, so play a noise
var/mob/thrower = throwingdatum?.get_thrower()
if(thrower != src)
extra_speed = min(max(0, throwingdatum.speed - initial(throw_speed)), CARBON_MAX_IMPACT_SPEED_BONUS)
if(istype(throwingdatum))
hurt = !throwingdatum.gentle
if(hurt && hit_atom.density)
if(isturf(hit_atom))
Paralyze(2 SECONDS)
take_bodypart_damage(10 + 5 * extra_speed, check_armor = TRUE, wound_bonus = extra_speed * 5)
else if(isstructure(hit_atom) && extra_speed)
Paralyze(1 SECONDS)
take_bodypart_damage(5 + 5 * extra_speed, check_armor = TRUE, wound_bonus = extra_speed * 5)
else if(!iscarbon(hit_atom) && extra_speed)
take_bodypart_damage(5 * extra_speed, check_armor = TRUE, wound_bonus = extra_speed * 5)
visible_message(span_danger("[src] crashes into [hit_atom][extra_speed ? " really hard" : ""]!"),\
span_userdanger("You violently crash into [hit_atom][extra_speed ? " extra hard" : ""]!"))
log_combat(hit_atom, src, "crashes ")
oof_noise = TRUE
if(iscarbon(hit_atom) && hit_atom != src)
var/mob/living/carbon/victim = hit_atom
var/blocked = FALSE
if(victim.movement_type & FLYING)
return
if(!hurt)
return
if(victim.check_block(src, 0, "[name]", LEAP_ATTACK))
blocked = TRUE
take_bodypart_damage(10 + 5 * extra_speed, check_armor = TRUE, wound_bonus = extra_speed * 5)
Paralyze(2 SECONDS)
oof_noise = TRUE
if(blocked)
visible_message(span_danger("[src] crashes into [victim][extra_speed ? " really hard" : ""], but [victim] blocked the worst of it!"),\
span_userdanger("You violently crash into [victim][extra_speed ? " extra hard" : ""], but [victim] managed to block the worst of it!"))
log_combat(src, victim, "crashed into and was blocked by")
return
else if(HAS_TRAIT(victim, TRAIT_BRAWLING_KNOCKDOWN_BLOCKED))
victim.take_bodypart_damage(10 + 5 * extra_speed, check_armor = TRUE, wound_bonus = extra_speed * 5)
victim.apply_damage(10 + 10 * extra_speed, STAMINA)
victim.adjust_staggered_up_to(STAGGERED_SLOWDOWN_LENGTH * 2, 10 SECONDS)
visible_message(span_danger("[src] crashes into [victim][extra_speed ? " really hard" : ""], but [victim] was able to stay on their feet!"),\
span_userdanger("You violently crash into [victim][extra_speed ? " extra hard" : ""], but [victim] managed to stay on their feet!"))
else
victim.Paralyze(2 SECONDS)
victim.take_bodypart_damage(10 + 5 * extra_speed, check_armor = TRUE, wound_bonus = extra_speed * 5)
visible_message(span_danger("[src] crashes into [victim][extra_speed ? " really hard" : ""], knocking them both over!"),\
span_userdanger("You violently crash into [victim][extra_speed ? " extra hard" : ""]!"))
log_combat(src, victim, "crashed into")
if(oof_noise)
playsound(src,'sound/weapons/punch1.ogg',50,TRUE)
//Throwing stuff
/mob/living/carbon/proc/toggle_throw_mode()
if(stat)
return
if(throw_mode)
throw_mode_off(THROW_MODE_TOGGLE)
else
throw_mode_on(THROW_MODE_TOGGLE)
/mob/living/carbon/proc/throw_mode_off(method)
if(throw_mode > method) //A toggle doesnt affect a hold
return
throw_mode = THROW_MODE_DISABLED
if(hud_used)
hud_used.throw_icon.icon_state = "act_throw_off"
/mob/living/carbon/proc/throw_mode_on(mode = THROW_MODE_TOGGLE)
throw_mode = mode
if(hud_used)
hud_used.throw_icon.icon_state = "act_throw_on"
/mob/proc/throw_item(atom/target)
SEND_SIGNAL(src, COMSIG_MOB_THROW, target)
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CARBON_THROW_THING, src, target)
return TRUE
/mob/living/carbon/throw_item(atom/target)
. = ..()
throw_mode_off(THROW_MODE_TOGGLE)
if(!target || !isturf(loc))
return FALSE
if(istype(target, /atom/movable/screen))
return FALSE
var/atom/movable/thrown_thing
var/obj/item/held_item = get_active_held_item()
var/verb_text = pick("throw", "toss", "hurl", "chuck", "fling")
if(prob(0.5))
verb_text = "yeet"
var/neckgrab_throw = FALSE // we can't check for if it's a neckgrab throw when totaling up power_throw since we've already stopped pulling them by then, so get it early
var/frequency_number = 1 //We assign a default frequency number for the sound of the throw.
if(!held_item)
if(pulling && isliving(pulling) && grab_state >= GRAB_AGGRESSIVE)
var/mob/living/throwable_mob = pulling
if(!throwable_mob.buckled)
thrown_thing = throwable_mob
if(grab_state >= GRAB_NECK)
neckgrab_throw = TRUE
stop_pulling()
if(HAS_TRAIT(src, TRAIT_PACIFISM))
to_chat(src, span_notice("You gently let go of [throwable_mob]."))
return FALSE
else
thrown_thing = held_item.on_thrown(src, target)
if(!thrown_thing)
return FALSE
if(isliving(thrown_thing))
var/turf/start_T = get_turf(loc) //Get the start and target tile for the descriptors
var/turf/end_T = get_turf(target)
if(start_T && end_T)
log_combat(src, thrown_thing, "thrown", addition="grab from tile in [AREACOORD(start_T)] towards tile at [AREACOORD(end_T)]")
var/power_throw = 0
if(HAS_TRAIT(src, TRAIT_HULK))
power_throw++
if(HAS_TRAIT(src, TRAIT_DWARF))
power_throw--
if(HAS_TRAIT(thrown_thing, TRAIT_DWARF))
power_throw++
if(neckgrab_throw)
power_throw++
if(isitem(thrown_thing))
var/obj/item/thrown_item = thrown_thing
frequency_number = 1-(thrown_item.w_class-3)/8 //At normal weight, the frequency is at 1. For tiny, it is 1.25. For huge, it is 0.75.
if(thrown_item.throw_verb)
verb_text = thrown_item.throw_verb
do_attack_animation(target, no_effect = 1)
var/sound/throwsound = 'sound/weapons/throw.ogg'
var/power_throw_text = "."
if(power_throw > 0) //If we have anything that boosts our throw power like hulk, we use the rougher heavier variant.
throwsound = 'sound/weapons/throwhard.ogg'
power_throw_text = " really hard!"
if(power_throw < 0) //if we have anything that weakens our throw power like dward, we use a slower variant.
throwsound = 'sound/weapons/throwsoft.ogg'
power_throw_text = " flimsily."
frequency_number = frequency_number + (rand(-5,5)/100); //Adds a bit of randomness in the frequency to not sound exactly the same.
//The volume of the sound takes the minimum between the distance thrown or the max range an item, but no more than 50. Short throws are quieter. A fast throwing speed also makes the noise sharper.
playsound(src, throwsound, min(8*min(get_dist(loc,target),thrown_thing.throw_range), 50), vary = TRUE, extrarange = -1, frequency = frequency_number)
visible_message(span_danger("[src] [verb_text][plural_s(verb_text)] [thrown_thing][power_throw_text]"), \
span_danger("You [verb_text] [thrown_thing][power_throw_text]"))
log_message("has thrown [thrown_thing] [power_throw_text]", LOG_ATTACK)
var/extra_throw_range = HAS_TRAIT(src, TRAIT_THROWINGARM) ? 2 : 0
newtonian_move(get_dir(target, src))
thrown_thing.safe_throw_at(target, thrown_thing.throw_range + extra_throw_range, max(1,thrown_thing.throw_speed + power_throw), src, null, null, null, move_force)
/mob/living/carbon/proc/canBeHandcuffed()
return FALSE
/mob/living/carbon/proc/create_carbon_reagents()
if (!isnull(reagents))
return
create_reagents(1000, REAGENT_HOLDER_ALIVE)
/mob/living/carbon/Topic(href, href_list)
..()
if(href_list["embedded_object"])
var/obj/item/bodypart/L = locate(href_list["embedded_limb"]) in bodyparts
if(!L)
return
var/obj/item/I = locate(href_list["embedded_object"]) in L.embedded_objects
if(!I || I.loc != src) //no item, no limb, or item is not in limb or in the person anymore
return
SEND_SIGNAL(src, COMSIG_CARBON_EMBED_RIP, I, L)
return
if(href_list["show_paper_note"])
var/obj/item/paper/paper_note = locate(href_list["show_paper_note"])
if(!paper_note)
return
paper_note.show_through_camera(usr)
/mob/living/carbon/on_fall()
. = ..()
loc.handle_fall(src)//it's loc so it doesn't call the mob's handle_fall which does nothing
/mob/living/carbon/is_muzzled()
for (var/obj/item/clothing/clothing in get_equipped_items())
if(clothing.clothing_flags & BLOCKS_SPEECH)
return TRUE
return FALSE
/mob/living/carbon/resist_buckle()
if(!HAS_TRAIT(src, TRAIT_RESTRAINED))
buckled.user_unbuckle_mob(src, src)
return
changeNext_move(CLICK_CD_BREAKOUT)
last_special = world.time + CLICK_CD_BREAKOUT
var/buckle_cd = 1 MINUTES
if(handcuffed)
var/obj/item/restraints/cuffs = src.get_item_by_slot(ITEM_SLOT_HANDCUFFED)
buckle_cd = cuffs.breakouttime
visible_message(span_warning("[src] attempts to unbuckle [p_them()]self!"),
span_notice("You attempt to unbuckle yourself... \
(This will take around [DisplayTimeText(buckle_cd)] and you must stay still.)"))
if(!do_after(src, buckle_cd, target = src, timed_action_flags = IGNORE_HELD_ITEM, hidden = TRUE))
if(buckled)
to_chat(src, span_warning("You fail to unbuckle yourself!"))
return
if(QDELETED(src) || isnull(buckled))
return
buckled.user_unbuckle_mob(src, src)
/mob/living/carbon/resist_fire()
return !!apply_status_effect(/datum/status_effect/stop_drop_roll)
/mob/living/carbon/resist_restraints()
var/obj/item/I = null
var/type = 0
if(handcuffed)
I = handcuffed
type = 1
else if(legcuffed)
I = legcuffed
type = 2
if(I)
if(type == 1)
changeNext_move(I.resist_cooldown)
last_special = world.time + I.resist_cooldown
if(type == 2)
changeNext_move(CLICK_CD_RANGE)
last_special = world.time + CLICK_CD_RANGE
cuff_resist(I)
/**
* Helper to break the cuffs from hands
* @param {obj/item} cuffs - The cuffs to break
* @param {number} breakouttime - The time it takes to break the cuffs. Use SECONDS/MINUTES defines
* @param {number} cuff_break - Speed multiplier, 0 is default, see _DEFINES\combat.dm
*/
/mob/living/carbon/proc/cuff_resist(obj/item/cuffs, breakouttime = 1 MINUTES, cuff_break = 0)
if((cuff_break != INSTANT_CUFFBREAK) && (SEND_SIGNAL(src, COMSIG_MOB_REMOVING_CUFFS, cuffs) & COMSIG_MOB_BLOCK_CUFF_REMOVAL))
return //The blocking object should sent a fluff-appropriate to_chat about cuff removal being blocked
if(cuffs.item_flags & BEING_REMOVED)
to_chat(src, span_warning("You're already attempting to remove [cuffs]!"))
return
cuffs.item_flags |= BEING_REMOVED
breakouttime = cuffs.breakouttime
if(!cuff_break)
visible_message(span_warning("[src] attempts to remove [cuffs]!"))
to_chat(src, span_notice("You attempt to remove [cuffs]... (This will take around [DisplayTimeText(breakouttime)] and you need to stand still.)"))
if(do_after(src, breakouttime, target = src, timed_action_flags = IGNORE_HELD_ITEM, hidden = TRUE))
. = clear_cuffs(cuffs, cuff_break)
else
to_chat(src, span_warning("You fail to remove [cuffs]!"))
else if(cuff_break == FAST_CUFFBREAK)
breakouttime = 5 SECONDS
visible_message(span_warning("[src] is trying to break [cuffs]!"))
to_chat(src, span_notice("You attempt to break [cuffs]... (This will take around 5 seconds and you need to stand still.)"))
if(do_after(src, breakouttime, target = src, timed_action_flags = IGNORE_HELD_ITEM))
. = clear_cuffs(cuffs, cuff_break)
else
to_chat(src, span_warning("You fail to break [cuffs]!"))
else if(cuff_break == INSTANT_CUFFBREAK)
. = clear_cuffs(cuffs, cuff_break)
cuffs.item_flags &= ~BEING_REMOVED
/mob/living/carbon/proc/uncuff()
if (handcuffed)
var/obj/item/W = handcuffed
set_handcuffed(null)
if (buckled?.buckle_requires_restraints)
buckled.unbuckle_mob(src)
update_handcuffed()
if (client)
client.screen -= W
if (W)
W.forceMove(drop_location())
W.dropped(src)
if (W)
W.layer = initial(W.layer)
SET_PLANE_EXPLICIT(W, initial(W.plane), src)
changeNext_move(0)
if (legcuffed)
var/obj/item/W = legcuffed
legcuffed = null
update_worn_legcuffs()
if (client)
client.screen -= W
if (W)
W.forceMove(drop_location())
W.dropped(src)
if (W)
W.layer = initial(W.layer)
SET_PLANE_EXPLICIT(W, initial(W.plane), src)
changeNext_move(0)
update_equipment_speed_mods() // In case cuffs ever change speed
/mob/living/carbon/proc/clear_cuffs(obj/item/I, cuff_break)
if(!I.loc || buckled)
return FALSE
if(I != handcuffed && I != legcuffed)
return FALSE
visible_message(span_danger("[src] manages to [cuff_break ? "break" : "remove"] [I]!"))
to_chat(src, span_notice("You successfully [cuff_break ? "break" : "remove"] [I]."))
if(cuff_break)
. = !((I == handcuffed) || (I == legcuffed))
qdel(I)
return TRUE
else
if(I == handcuffed)
handcuffed.forceMove(drop_location())
set_handcuffed(null)
I.dropped(src)
if(buckled?.buckle_requires_restraints)
buckled.unbuckle_mob(src)
update_handcuffed()
return TRUE
if(I == legcuffed)
legcuffed.forceMove(drop_location())
legcuffed = null
I.dropped(src)
update_worn_legcuffs()
return TRUE
/mob/living/carbon/proc/accident(obj/item/I)
if(!I || (I.item_flags & ABSTRACT) || HAS_TRAIT(I, TRAIT_NODROP))
return
dropItemToGround(I)
var/modifier = 0
if(HAS_TRAIT(src, TRAIT_CLUMSY))
modifier -= 40 //Clumsy people are more likely to hit themselves -Honk!
switch(rand(1,100)+modifier) //91-100=Nothing special happens
if(-INFINITY to 0) //attack yourself
INVOKE_ASYNC(I, TYPE_PROC_REF(/obj/item, attack), src, src)
if(1 to 30) //throw it at yourself
I.throw_impact(src)
if(31 to 60) //Throw object in facing direction
var/turf/target = get_turf(loc)
var/range = rand(2,I.throw_range)
for(var/i in 1 to range-1)
var/turf/new_turf = get_step(target, dir)
target = new_turf
if(new_turf.density)
break
I.throw_at(target,I.throw_range,I.throw_speed,src)
if(61 to 90) //throw it down to the floor
var/turf/target = get_turf(loc)
I.safe_throw_at(target,I.throw_range,I.throw_speed,src, force = move_force)
/mob/living/carbon/attack_ui(slot, params)
if(!has_hand_for_held_index(active_hand_index))
return 0
return ..()
/// Proc that compels the mob to throw up. Returns TRUE if the mob actually threw up.
/mob/living/carbon/proc/vomit(vomit_flags = VOMIT_CATEGORY_DEFAULT, vomit_type = /obj/effect/decal/cleanable/vomit/toxic, lost_nutrition = 10, distance = 1, purge_ratio = 0.1)
var/force = (vomit_flags & MOB_VOMIT_FORCE)
if((HAS_TRAIT(src, TRAIT_NOHUNGER) || HAS_TRAIT(src, TRAIT_TOXINLOVER)) && !force)
return TRUE
if(!force && HAS_TRAIT(src, TRAIT_STRONG_STOMACH))
lost_nutrition *= 0.5
SEND_SIGNAL(src, COMSIG_CARBON_VOMITED, distance, force)
// cache some stuff that we'll need later (at least multiple times)
var/starting_dir = dir
var/message = (vomit_flags & MOB_VOMIT_MESSAGE)
var/stun = (vomit_flags & MOB_VOMIT_STUN)
var/knockdown = (vomit_flags & MOB_VOMIT_KNOCKDOWN)
var/blood = (vomit_flags & MOB_VOMIT_BLOOD)
if(!force && !blood && (nutrition < 100))
if(message)
visible_message(
span_warning("[src] dry heaves!"),
span_userdanger("You try to throw up, but there's nothing in your stomach!"),
)
if(stun)
var/stun_time = 20 SECONDS
if(HAS_TRAIT(src, TRAIT_STRONG_STOMACH))
stun_time *= 0.5
Stun(stun_time)
if(knockdown)
Knockdown(20 SECONDS)
return TRUE
if(is_mouth_covered()) //make this add a blood/vomit overlay later it'll be hilarious
if(message)
visible_message(
span_danger("[src] throws up all over [p_them()]self!"),
span_userdanger("You throw up all over yourself!"),
)
add_mood_event("vomit", /datum/mood_event/vomitself)
distance = 0
else
if(message)
visible_message(
span_danger("[src] throws up!"),
span_userdanger("You throw up!"),
)
if(!isflyperson(src))
add_mood_event("vomit", /datum/mood_event/vomit)
if(stun)
var/stun_time = 8 SECONDS
if(!blood && HAS_TRAIT(src, TRAIT_STRONG_STOMACH))
stun_time *= 0.5
Stun(stun_time)
if(knockdown)
Knockdown(8 SECONDS)
playsound(src, 'sound/effects/splat.ogg', 50, TRUE)
var/need_mob_update = FALSE
var/turf/location = get_turf(src)
if(!blood)
adjust_nutrition(-lost_nutrition)
need_mob_update += adjustToxLoss(-3, updating_health = FALSE)
for(var/i = 0 to distance)
if(blood)
if(location)
add_splatter_floor(location)
if(vomit_flags & MOB_VOMIT_HARM)
need_mob_update += adjustBruteLoss(3, updating_health = FALSE)
else
if(location)
location.add_vomit_floor(src, vomit_type, vomit_flags, purge_ratio) // call purge when doing detoxicfication to pump more chems out of the stomach.
location = get_step(location, starting_dir)
if (location?.is_blocked_turf())
break
if(need_mob_update) // so we only have to call updatehealth() once as opposed to n times
updatehealth()
return TRUE
/**
* Expel the reagents you just tried to ingest
*
* When you try to ingest reagents but you do not have a stomach
* you will spew the reagents on the floor.
*
* Vars:
* * bite: /atom the reagents to expel
* * amount: int The amount of reagent
*/
/mob/living/carbon/proc/expel_ingested(atom/bite, amount)
visible_message(span_danger("[src] throws up all over [p_them()]self!"), \
span_userdanger("You are unable to keep the [bite] down without a stomach!"))
var/turf/floor = get_turf(src)
var/obj/effect/decal/cleanable/vomit/spew = new(floor, get_static_viruses())
bite.reagents.trans_to(spew, amount, transferred_by = src)
/mob/living/carbon/proc/spew_organ(power = 5, amt = 1)
for(var/i in 1 to amt)
if(!organs.len)
break //Guess we're out of organs!
var/obj/item/organ/guts = pick(organs)
var/turf/T = get_turf(src)
guts.Remove(src)
guts.forceMove(T)
var/atom/throw_target = get_edge_target_turf(guts, dir)
guts.throw_at(throw_target, power, 4, src)
/mob/living/carbon/fully_replace_character_name(oldname,newname)
. = ..()
if(dna)
dna.real_name = real_name
var/obj/item/bodypart/head/my_head = get_bodypart(BODY_ZONE_HEAD)
if(my_head)
my_head.real_name = real_name
/mob/living/carbon/set_body_position(new_value)
. = ..()
if(isnull(.))
return
if(new_value == LYING_DOWN)
add_movespeed_modifier(/datum/movespeed_modifier/carbon_crawling)
else
remove_movespeed_modifier(/datum/movespeed_modifier/carbon_crawling)
//Updates the mob's health from bodyparts and mob damage variables
/mob/living/carbon/updatehealth()
if(status_flags & GODMODE)
return
var/total_burn = 0
var/total_brute = 0
for(var/X in bodyparts) //hardcoded to streamline things a bit
var/obj/item/bodypart/BP = X
total_brute += (BP.brute_dam * BP.body_damage_coeff)
total_burn += (BP.burn_dam * BP.body_damage_coeff)
set_health(round(maxHealth - getOxyLoss() - getToxLoss() - total_burn - total_brute, DAMAGE_PRECISION))
update_stat()
update_stamina()
if(((maxHealth - total_burn) < HEALTH_THRESHOLD_DEAD*2) && stat == DEAD )
become_husk(BURN)
med_hud_set_health()
if(stat == SOFT_CRIT)
add_movespeed_modifier(/datum/movespeed_modifier/carbon_softcrit)
else
remove_movespeed_modifier(/datum/movespeed_modifier/carbon_softcrit)
SEND_SIGNAL(src, COMSIG_LIVING_HEALTH_UPDATE)
/mob/living/carbon/update_stamina()
var/stam = getStaminaLoss()
if(stam > DAMAGE_PRECISION && (maxHealth - stam) <= crit_threshold)
if (!stat)
enter_stamcrit()
else if(HAS_TRAIT_FROM(src, TRAIT_INCAPACITATED, STAMINA))
REMOVE_TRAIT(src, TRAIT_INCAPACITATED, STAMINA)
REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, STAMINA)
REMOVE_TRAIT(src, TRAIT_FLOORED, STAMINA)
else
return
update_stamina_hud()
/mob/living/carbon/update_sight()
if(!client)
return
if(stat == DEAD)
if(SSmapping.level_trait(z, ZTRAIT_NOXRAY))
set_sight(null)
else if(is_secret_level(z))
set_sight(initial(sight))
else
set_sight(SEE_TURFS|SEE_MOBS|SEE_OBJS)
set_invis_see(SEE_INVISIBLE_OBSERVER)
return
var/new_sight = initial(sight)
lighting_cutoff = initial(lighting_cutoff)
lighting_color_cutoffs = list(lighting_cutoff_red, lighting_cutoff_green, lighting_cutoff_blue)
var/obj/item/organ/internal/eyes/eyes = get_organ_slot(ORGAN_SLOT_EYES)
if(eyes)
set_invis_see(eyes.see_invisible)
new_sight |= eyes.sight_flags
if(!isnull(eyes.lighting_cutoff))
lighting_cutoff = eyes.lighting_cutoff
if(!isnull(eyes.color_cutoffs))
lighting_color_cutoffs = blend_cutoff_colors(lighting_color_cutoffs, eyes.color_cutoffs)
if(client.eye && client.eye != src)
var/atom/A = client.eye
if(A.update_remote_sight(src)) //returns 1 if we override all other sight updates.
return
if(glasses)
new_sight |= glasses.vision_flags
if(glasses.invis_override)
set_invis_see(glasses.invis_override)
else
set_invis_see(min(glasses.invis_view, see_invisible))
if(!isnull(glasses.lighting_cutoff))
lighting_cutoff = max(lighting_cutoff, glasses.lighting_cutoff)
if(length(glasses.color_cutoffs))
lighting_color_cutoffs = blend_cutoff_colors(lighting_color_cutoffs, glasses.color_cutoffs)
if(HAS_TRAIT(src, TRAIT_TRUE_NIGHT_VISION))
lighting_cutoff = max(lighting_cutoff, LIGHTING_CUTOFF_HIGH)
if(HAS_TRAIT(src, TRAIT_MESON_VISION))
new_sight |= SEE_TURFS
lighting_cutoff = max(lighting_cutoff, LIGHTING_CUTOFF_MEDIUM)
if(HAS_TRAIT(src, TRAIT_THERMAL_VISION))
new_sight |= SEE_MOBS
lighting_cutoff = max(lighting_cutoff, LIGHTING_CUTOFF_MEDIUM)
if(HAS_TRAIT(src, TRAIT_XRAY_VISION))
new_sight |= SEE_TURFS|SEE_MOBS|SEE_OBJS
if(SSmapping.level_trait(z, ZTRAIT_NOXRAY))
new_sight = NONE
set_sight(new_sight)
return ..()
/**
* Calculates how visually impaired the mob is by their equipment and other factors
*
* This is where clothing adds its various vision limiting effects, such as welding helmets
*/
/mob/living/carbon/proc/update_tint()
var/tint = 0
for(var/obj/item/clothing/worn_item in get_equipped_items())
tint += worn_item.tint
var/obj/item/organ/internal/eyes/eyes = get_organ_slot(ORGAN_SLOT_EYES)
if(eyes)
tint += eyes.tint
if(tint >= TINT_BLIND)
become_blind(EYES_COVERED)
else if(tint >= TINT_DARKENED)
cure_blind(EYES_COVERED)
overlay_fullscreen("tint", /atom/movable/screen/fullscreen/impaired, 2)
else
cure_blind(EYES_COVERED)
clear_fullscreen("tint", 0 SECONDS)
//this handles hud updates
/mob/living/carbon/update_damage_hud()
if(!client)
return
if(health <= crit_threshold && !HAS_TRAIT(src, TRAIT_NOCRITOVERLAY))
var/severity = 0
switch(health)
if(-20 to -10)
severity = 1
if(-30 to -20)
severity = 2
if(-40 to -30)
severity = 3
if(-50 to -40)
severity = 4
if(-50 to -40)
severity = 5
if(-60 to -50)
severity = 6
if(-70 to -60)
severity = 7
if(-90 to -70)
severity = 8
if(-95 to -90)
severity = 9
if(-INFINITY to -95)
severity = 10
if(stat != HARD_CRIT)
var/visionseverity = 4
switch(health)
if(-8 to -4)
visionseverity = 5
if(-12 to -8)
visionseverity = 6
if(-16 to -12)
visionseverity = 7
if(-20 to -16)
visionseverity = 8
if(-24 to -20)
visionseverity = 9
if(-INFINITY to -24)
visionseverity = 10
overlay_fullscreen("critvision", /atom/movable/screen/fullscreen/crit/vision, visionseverity)
else
clear_fullscreen("critvision")
overlay_fullscreen("crit", /atom/movable/screen/fullscreen/crit, severity)
else
clear_fullscreen("crit")
clear_fullscreen("critvision")
//Oxygen damage overlay
if(oxyloss)
var/severity = 0
switch(oxyloss)
if(10 to 20)
severity = 1
if(20 to 25)
severity = 2
if(25 to 30)
severity = 3
if(30 to 35)
severity = 4
if(35 to 40)
severity = 5
if(40 to 45)
severity = 6
if(45 to INFINITY)
severity = 7
overlay_fullscreen("oxy", /atom/movable/screen/fullscreen/oxy, severity)
else
clear_fullscreen("oxy")
//Fire and Brute damage overlay (BSSR)
var/hurtdamage = getBruteLoss() + getFireLoss() + damageoverlaytemp
if(hurtdamage)
var/severity = 0
switch(hurtdamage)
if(5 to 15)
severity = 1
if(15 to 30)
severity = 2
if(30 to 45)
severity = 3
if(45 to 70)
severity = 4
if(70 to 85)
severity = 5
if(85 to INFINITY)
severity = 6
overlay_fullscreen("brute", /atom/movable/screen/fullscreen/brute, severity)
else
clear_fullscreen("brute")
/mob/living/carbon/update_health_hud(shown_health_amount)
if(!client || !hud_used?.healths)
return
if(stat == DEAD)
hud_used.healths.icon_state = "health7"
return
if(SEND_SIGNAL(src, COMSIG_CARBON_UPDATING_HEALTH_HUD, shown_health_amount) & COMPONENT_OVERRIDE_HEALTH_HUD)
return
if(shown_health_amount == null)
shown_health_amount = health
if(shown_health_amount >= maxHealth)
hud_used.healths.icon_state = "health0"
else if(shown_health_amount > maxHealth * 0.8)
hud_used.healths.icon_state = "health1"
else if(shown_health_amount > maxHealth * 0.6)
hud_used.healths.icon_state = "health2"
else if(shown_health_amount > maxHealth * 0.4)
hud_used.healths.icon_state = "health3"
else if(shown_health_amount > maxHealth*0.2)
hud_used.healths.icon_state = "health4"
else if(shown_health_amount > 0)
hud_used.healths.icon_state = "health5"
else
hud_used.healths.icon_state = "health6"
/mob/living/carbon/update_stamina_hud(shown_stamina_loss)
if(!client || !hud_used?.stamina)
return
var/stam_crit_threshold = maxHealth - crit_threshold
if(stat == DEAD)
hud_used.stamina.icon_state = "stamina_dead"
else
if(shown_stamina_loss == null)
shown_stamina_loss = getStaminaLoss()
if(shown_stamina_loss >= stam_crit_threshold)
hud_used.stamina.icon_state = "stamina_crit"
else if(shown_stamina_loss > maxHealth*0.8)
hud_used.stamina.icon_state = "stamina_5"
else if(shown_stamina_loss > maxHealth*0.6)
hud_used.stamina.icon_state = "stamina_4"
else if(shown_stamina_loss > maxHealth*0.4)
hud_used.stamina.icon_state = "stamina_3"
else if(shown_stamina_loss > maxHealth*0.2)
hud_used.stamina.icon_state = "stamina_2"
else if(shown_stamina_loss > 0)
hud_used.stamina.icon_state = "stamina_1"
else
hud_used.stamina.icon_state = "stamina_full"
/mob/living/carbon/proc/update_spacesuit_hud_icon(cell_state = "empty")
hud_used?.spacesuit?.icon_state = "spacesuit_[cell_state]"
/mob/living/carbon/set_health(new_value)
. = ..()
if(. > hardcrit_threshold)
if(health <= hardcrit_threshold && !HAS_TRAIT(src, TRAIT_NOHARDCRIT))
ADD_TRAIT(src, TRAIT_KNOCKEDOUT, CRIT_HEALTH_TRAIT)
else if(health > hardcrit_threshold)
REMOVE_TRAIT(src, TRAIT_KNOCKEDOUT, CRIT_HEALTH_TRAIT)
if(CONFIG_GET(flag/near_death_experience))
if(. > HEALTH_THRESHOLD_NEARDEATH)
if(health <= HEALTH_THRESHOLD_NEARDEATH && !HAS_TRAIT(src, TRAIT_NODEATH))
ADD_TRAIT(src, TRAIT_SIXTHSENSE, "near-death")
else if(health > HEALTH_THRESHOLD_NEARDEATH)
REMOVE_TRAIT(src, TRAIT_SIXTHSENSE, "near-death")
/mob/living/carbon/update_stat()
if(status_flags & GODMODE)
return
if(stat != DEAD)
if(health <= HEALTH_THRESHOLD_DEAD && !HAS_TRAIT(src, TRAIT_NODEATH))
death()
return
if(HAS_TRAIT_FROM(src, TRAIT_DISSECTED, AUTOPSY_TRAIT))
REMOVE_TRAIT(src, TRAIT_DISSECTED, AUTOPSY_TRAIT)
if(health <= hardcrit_threshold && !HAS_TRAIT(src, TRAIT_NOHARDCRIT))
set_stat(HARD_CRIT)
else if(HAS_TRAIT(src, TRAIT_KNOCKEDOUT))
set_stat(UNCONSCIOUS)
else if(health <= crit_threshold && !HAS_TRAIT(src, TRAIT_NOSOFTCRIT))
set_stat(SOFT_CRIT)
else
set_stat(CONSCIOUS)
update_damage_hud()
update_health_hud()
update_stamina_hud()
med_hud_set_status()
//called when we get cuffed/uncuffed
/mob/living/carbon/proc/update_handcuffed()
if(handcuffed)
drop_all_held_items()
stop_pulling()
throw_alert(ALERT_HANDCUFFED, /atom/movable/screen/alert/restrained/handcuffed, new_master = src.handcuffed)
add_mood_event("handcuffed", /datum/mood_event/handcuffed)
else
clear_alert(ALERT_HANDCUFFED)
clear_mood_event("handcuffed")
update_mob_action_buttons() //some of our action buttons might be unusable when we're handcuffed.
update_worn_handcuffs()
update_hud_handcuffed()
/mob/living/carbon/revive(full_heal_flags = NONE, excess_healing = 0, force_grab_ghost = FALSE)
if(excess_healing)
if(dna && !HAS_TRAIT(src, TRAIT_NOBLOOD))
blood_volume += (excess_healing * 2) //1 excess = 10 blood
for(var/obj/item/organ/target_organ as anything in organs)
if(!target_organ.damage)
continue
target_organ.apply_organ_damage(excess_healing * -1, required_organ_flag = ORGAN_ORGANIC) //1 excess = 5 organ damage healed
return ..()
/mob/living/carbon/heal_and_revive(heal_to = 75, revive_message)
// We can't heal them if they're missing a heart
if(needs_heart() && !get_organ_slot(ORGAN_SLOT_HEART))
return FALSE
// We can't heal them if they're missing their lungs
if(!HAS_TRAIT(src, TRAIT_NOBREATH) && !isnull(dna?.species.mutantlungs) && !get_organ_slot(ORGAN_SLOT_LUNGS))
return FALSE
// And we can't heal them if they're missing their liver
if(!HAS_TRAIT(src, TRAIT_LIVERLESS_METABOLISM) && !isnull(dna?.species.mutantliver) && !get_organ_slot(ORGAN_SLOT_LIVER))
return FALSE
. = ..()
if(.) // if revived successfully
set_heartattack(FALSE)
return .
/mob/living/carbon/fully_heal(heal_flags = HEAL_ALL)
// Should be handled via signal on embedded, or via heal on bodypart
// Otherwise I don't care to give it a separate flag
remove_all_embedded_objects()
if(heal_flags & HEAL_NEGATIVE_DISEASES)
for(var/datum/disease/disease as anything in diseases)
if(disease.severity != DISEASE_SEVERITY_POSITIVE)
disease.cure(FALSE)
if(heal_flags & HEAL_WOUNDS)
for(var/datum/wound/wound as anything in all_wounds)
wound.remove_wound()
if(heal_flags & HEAL_LIMBS)
regenerate_limbs()
if(heal_flags & (HEAL_REFRESH_ORGANS|HEAL_ORGANS))
regenerate_organs(regenerate_existing = (heal_flags & HEAL_REFRESH_ORGANS))
if(heal_flags & HEAL_TRAUMAS)
cure_all_traumas(TRAUMA_RESILIENCE_MAGIC)
// Addictions are like traumas
if(mind)
for(var/addiction_type in subtypesof(/datum/addiction))
mind.remove_addiction_points(addiction_type, MAX_ADDICTION_POINTS) //Remove the addiction!
if(heal_flags & HEAL_RESTRAINTS)
QDEL_NULL(handcuffed)
QDEL_NULL(legcuffed)
set_handcuffed(null)
update_handcuffed()
return ..()
/mob/living/carbon/do_strange_reagent_revival(healing_amount)
set_heartattack(FALSE)
return ..()
/mob/living/carbon/can_be_revived()
if(!get_organ_by_type(/obj/item/organ/internal/brain) && (!IS_CHANGELING(src)) || HAS_TRAIT(src, TRAIT_HUSK))
return FALSE
return ..()
/mob/living/carbon/proc/can_defib()
if (HAS_TRAIT(src, TRAIT_SUICIDED))
return DEFIB_FAIL_SUICIDE
if (HAS_TRAIT(src, TRAIT_HUSK))
return DEFIB_FAIL_HUSK
if (HAS_TRAIT(src, TRAIT_DEFIB_BLACKLISTED))
return DEFIB_FAIL_BLACKLISTED
if ((getBruteLoss() >= MAX_REVIVE_BRUTE_DAMAGE) || (getFireLoss() >= MAX_REVIVE_FIRE_DAMAGE))
return DEFIB_FAIL_TISSUE_DAMAGE
// Only check for a heart if they actually need a heart. Who would've thunk
if (needs_heart())
var/obj/item/organ/internal/heart = get_organ_by_type(/obj/item/organ/internal/heart)
if (!heart)
return DEFIB_FAIL_NO_HEART
if (heart.organ_flags & ORGAN_FAILING)
return DEFIB_FAIL_FAILING_HEART
var/obj/item/organ/internal/brain/current_brain = get_organ_by_type(/obj/item/organ/internal/brain)
if (QDELETED(current_brain))
return DEFIB_FAIL_NO_BRAIN
if (current_brain.organ_flags & ORGAN_FAILING)
return DEFIB_FAIL_FAILING_BRAIN
if (current_brain.suicided || (current_brain.brainmob && HAS_TRAIT(current_brain.brainmob, TRAIT_SUICIDED)))
return DEFIB_FAIL_NO_INTELLIGENCE
if(key && key[1] == "@") // Adminghosts
return DEFIB_NOGRAB_AGHOST
return DEFIB_POSSIBLE