forked from goonstation/goonstation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
organ_holder.dm
1632 lines (1471 loc) · 48.6 KB
/
organ_holder.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
#define L_ORGAN 1
#define R_ORGAN 2
/datum/organHolder // you ever play fallout 3? you know those like sacks of gibs that were around? yeah
var/mob/living/donor = null
var/obj/item/organ/head/head = null
var/obj/item/skull/skull = null
var/obj/item/organ/brain/brain = null
var/obj/item/organ/eye/left_eye = null
var/obj/item/organ/eye/right_eye = null
var/obj/item/organ/chest/chest = null
var/obj/item/organ/heart/heart = null
var/obj/item/organ/lung/left_lung = null
var/obj/item/organ/lung/right_lung = null
var/obj/item/clothing/head/butt/butt = null
var/obj/item/organ/kidney/left_kidney = null
var/obj/item/organ/kidney/right_kidney = null
var/obj/item/organ/liver = null
var/obj/item/organ/spleen = null
var/obj/item/organ/pancreas = null
var/obj/item/organ/stomach = null
var/obj/item/organ/intestines = null
var/obj/item/organ/appendix = null
var/obj/item/organ/tail = null
var/lungs_changed = 2 //for changing lung stamina debuffs if it has changed since last cycle. starts at 2 for having 2 working lungs
var/list/organ_list = list("all", "head", "skull", "brain", "left_eye", "right_eye", "chest", "heart", "left_lung", "right_lung", "butt", "left_kidney", "right_kidney", "liver", "stomach", "intestines", "spleen", "pancreas", "appendix", "tail")
var/list/organ_type_list = list(
"head"="/obj/item/organ/head",
"skull"="/obj/item/skull",
"brain"="/obj/item/organ/brain",
"left_eye"="/obj/item/organ/eye",
"right_eye"="/obj/item/organ/eye",
"chest"="/obj/item/organ/chest",
"heart"="/obj/item/organ/heart",
"left_lung"="/obj/item/organ/lung/left",
"right_lung"="/obj/item/organ/lung/right",
"left_kidney"="/obj/item/organ/kidney/left",
"right_kidney"="/obj/item/organ/kidney/right",
"liver"="/obj/item/organ/liver",
"spleen"="/obj/item/organ/spleen",
"pancreas"="/obj/item/organ/pancreas",
"stomach"="/obj/item/organ/stomach",
"intestines"="/obj/item/organ/intestines",
"appendix"="/obj/item/organ/appendix",
"butt"="/obj/item/clothing/head/butt",
"tail"="/obj/item/organ/tail")
New(var/mob/living/L, var/ling)
..()
if (!ishuman(L))
return
if (istype(L))
src.donor = L
if (src.donor && !ling) // so changers just get the datum and not a metric fuckton of organs
src.create_organs()
disposing()
src.organ_list.len = 0
src.organ_list = null
if (head)
head.donor = null
chest?.bones?.donor = null
head.holder = null
if (skull)
skull.donor = null
skull.holder = null
if (brain)
brain.donor = null
brain.holder = null
if (left_eye)
left_eye.donor = null
left_eye.holder = null
if (right_eye)
right_eye.donor = null
right_eye.holder = null
if (chest)
chest.donor = null
chest?.bones?.donor = null
chest.holder = null
if (heart)
heart.donor = null
heart.holder = null
if (left_lung)
left_lung.donor = null
left_lung.holder = null
if (right_lung)
right_lung.donor = null
right_lung.holder = null
if (butt)
butt.donor = null
butt.holder = null
if (left_kidney)
left_kidney.donor = null
left_kidney.holder = null
if (right_kidney)
right_kidney.donor = null
right_kidney.holder = null
if (liver)
liver.donor = null
liver.holder = null
if (stomach)
stomach.donor = null
stomach.holder = null
if (intestines)
intestines.donor = null
intestines.holder = null
if (spleen)
spleen.donor = null
spleen.holder = null
if (pancreas)
pancreas.donor = null
pancreas.holder = null
if (appendix)
appendix.donor = null
appendix.holder = null
if (tail)
tail.donor = null
tail.holder = null
head = null
skull = null
brain = null
left_eye = null
right_eye = null
chest = null
heart = null
left_lung = null
right_lung = null
butt = null
left_kidney = null
right_kidney = null
liver = null
stomach = null
intestines = null
spleen = null
pancreas = null
appendix = null
tail = null
donor = null
..()
proc/handle_organs(var/mult = 1)
for(var/thing in src.organ_list)
if(thing == "all")
continue
var/obj/item/organ/O = organ_list[thing]
//Organ needs to be inside someone for it to function.
if(istype(O) && O.donor)
//in obj/item/organ/proc/on_life, It should return 1 on success and 0 on fail. And it will fail if the organ is damaged beyond repair or is broken. So...
if (!O.on_life(mult))
O.on_broken(mult)
else //The organ for this slot is missing. For our purposes here at least. Do bad effects, depending.
handle_missing(thing, mult)
handle_lungs_stamina(mult)
//What should happen on every tick when an organ is missing. Should be called above in /datum/organHolder/proc/handle_organs().
proc/handle_missing(var/organ_name as text, var/mult = 1)
switch (organ_name)
if ("liver")
donor.take_toxin_damage(2*mult, 1)
if ("spleen")
if (ishuman(donor))
var/mob/living/carbon/human/H = donor
H.blood_volume -= 2 * mult
if ("left_kidney") //I'm lazy... Not making this better right now -kyle
if (!get_working_kidney_amt())
donor.take_toxin_damage(2, 1)
if ("right_kidney")
if (!get_working_kidney_amt())
donor.take_toxin_damage(2, 1)
if ("tail")
if(ischangeling(donor) || src.donor?.reagents?.get_reagent_amount("ethanol") > 50) // drunkenness prevents tail-clumsiness
return
if (donor.mob_flags & SHOULD_HAVE_A_TAIL) // Only become clumsy if you should have a tail and are not a shapeshifting alien
donor.bioHolder?.AddEffect("clumsy", 0, 0, 0, 1)
//Missing lungs is handled in it's own proc right now. I'll probably move it here eventually, but that's how I did it originally before I thought of a thing for handling missing organs in the organholder and I'm not rewriting such a tedious thing now.
//loops through organ_list. returns a list of names of all missing organs instead, but I'm tired
proc/get_missing_organs()
RETURN_TYPE(/list)
var/list/organs = list()
// if (islist(organ_list))
for (var/i in organ_list)
if (!organ_list[i])
organs += i
return organs
//(damage|heal)_organs used for effecting a lot of organs at once just by supplying a list and a damage amount.
//probability, num 0-100 for whether or not to damage an organ found
//organs, list of organs to damage. give it individual organs like "left_lung", not "lungs"
proc/damage_organs(var/brute, var/burn, var/tox, var/list/organs, var/probability = 100)
if(check_target_immunity(donor))
return 0
for (var/organ in organs)
if (probability == 100 || prob(probability))
damage_organ(brute, burn, tox, organ)
proc/heal_organs(var/brute, var/burn, var/tox, var/list/organs, var/probability = 100)
for (var/organ in organs)
if (probability == 100 || prob(probability))
heal_organ(brute, burn, tox, organ)
//calls take_damage on the specified Organ attached to this organHolder
proc/damage_organ(var/brute, var/burn, var/tox, var/organ as text)
if(check_target_immunity(donor))
return 0
if (islist(src.organ_list))
var/obj/item/organ/O = src.organ_list[organ]
if (istype(O))
O.take_damage(brute, burn, tox)
return 1
return 0
//calls heal_damage on the specified Organ attached to this organHolder
proc/heal_organ(var/brute, var/burn, var/tox, var/organ as text)
if (islist(src.organ_list))
var/obj/item/organ/O = src.organ_list[organ]
if (istype(O))
O.heal_damage(brute, burn, tox)
return 1
return 0
//organs should not perform their functions if they have 100 damage
proc/get_working_kidney_amt()
var/count = 0
if (left_kidney && (!left_kidney.broken && left_kidney.get_damage() <= left_kidney.FAIL_DAMAGE))
count++
if (right_kidney && (!right_kidney.broken && right_kidney.get_damage() <= right_kidney.FAIL_DAMAGE))
count++
return count
proc/get_working_lung_amt()
var/count = 0
if (left_lung && (!left_lung.broken && left_lung.get_damage() <= left_lung.FAIL_DAMAGE))
count++
if (right_lung && (!right_lung.broken && right_lung.get_damage() <= right_lung.FAIL_DAMAGE))
count++
return count
proc/create_organs()
if (!src.donor)
return // vOv
if (!src.head)
src.head = new /obj/item/organ/head(src.donor, src)
organ_list["head"] = head
if (!src.skull)
src.skull = new /obj/item/skull(src.donor, src)
organ_list["skull"] = skull
// For variety and hunters (Convair880).
SPAWN(2.5 SECONDS) // Don't remove.
if (src.donor && src.donor.organHolder && src.donor.organHolder.skull)
src.donor.assign_gimmick_skull()
var/all_synth = (prob(1) && prob(1))
if (!src.brain)
if (prob(2) || all_synth)
src.brain = new /obj/item/organ/brain/synth(src.donor, src)
else
src.brain = new /obj/item/organ/brain(src.donor, src)
src.brain.setOwner(src.donor.mind)
organ_list["brain"] = brain
SPAWN(2 SECONDS)
if (src.brain && src.donor)
src.brain.name = "[src.donor.real_name]'s [initial(src.brain.name)]"
if (src.donor.mind)
src.brain.setOwner(src.donor.mind)
if (!src.left_eye)
if (prob(2) || all_synth)
src.left_eye = new /obj/item/organ/eye/synth(src.donor, src)
else
src.left_eye = new /obj/item/organ/eye/left(src.donor, src)
organ_list["left_eye"] = left_eye
if (!src.right_eye)
if (prob(2) || all_synth)
src.right_eye = new /obj/item/organ/eye/synth(src.donor, src)
else
src.right_eye = new /obj/item/organ/eye/right(src.donor, src)
organ_list["right_eye"] = right_eye
if (!src.chest)
src.chest = new /obj/item/organ/chest(src.donor, src)
organ_list["chest"] = chest
if (!src.heart)
if (prob(2) || all_synth)
src.heart = new /obj/item/organ/heart/synth(src.donor, src)
else
src.heart = new /obj/item/organ/heart(src.donor, src)
organ_list["heart"] = heart
if (!src.left_lung)
src.left_lung = new /obj/item/organ/lung/left(src.donor, src)
organ_list["left_lung"] = left_lung
if (!src.right_lung)
src.right_lung = new /obj/item/organ/lung/right(src.donor, src)
organ_list["right_lung"] = right_lung
if (!src.butt)
src.butt = new /obj/item/clothing/head/butt(src.donor, src)
organ_list["butt"] = butt
src.donor.butt_op_stage = 0.0
src.donor.update_body()
if (!src.left_kidney)
src.left_kidney = new /obj/item/organ/kidney/left(src.donor, src)
organ_list["left_kidney"] = left_kidney
if (!src.right_kidney)
src.right_kidney = new /obj/item/organ/kidney/right(src.donor, src)
organ_list["right_kidney"] = right_kidney
if (!src.liver)
src.liver = new /obj/item/organ/liver(src.donor, src)
organ_list["liver"] = liver
if (!src.stomach)
src.stomach = new /obj/item/organ/stomach(src.donor, src)
organ_list["stomach"] = stomach
if (!src.intestines)
src.intestines = new /obj/item/organ/intestines(src.donor, src)
organ_list["intestines"] = intestines
if (!src.spleen)
src.spleen = new /obj/item/organ/spleen(src.donor, src)
organ_list["spleen"] = spleen
if (!src.pancreas)
src.pancreas = new /obj/item/organ/pancreas(src.donor, src)
organ_list["pancreas"] = pancreas
if (!src.appendix)
src.appendix = new /obj/item/organ/appendix(src.donor, src)
organ_list["appendix"] = appendix
if (!src.tail)
src.tail = null // Humans dont have tailbones, fun fact
organ_list["tail"] = tail
//input organ = string value of organ_list assoc list
proc/get_organ(var/organ)
RETURN_TYPE(/obj/item)
if (!organ)
return null
var/obj/item/return_organ = organ_list[organ]
if (istype(return_organ))
return return_organ
return null
proc/drop_organ(var/organ, var/location)
if (!src.donor || !organ)
return
if (!location)
location = src.donor.loc
if(!istext(organ) && istype(organ, /obj/item))
// the organ is passed as a reference instead of a text description
if(organ == head)
organ = "head"
else if(organ == skull)
organ = "skull"
else if(organ == brain)
organ = "brain"
else if(organ == left_eye)
organ = "left_eye"
else if(organ == right_eye)
organ = "right_eye"
else if(organ == chest)
organ = "chest"
else if(organ == heart)
organ = "heart"
else if(organ == left_lung)
organ = "left_lung"
else if(organ == right_lung)
organ = "right_lung"
else if(organ == butt)
organ = "butt"
else if(organ == left_kidney)
organ = "left_kidney"
else if(organ == right_kidney)
organ = "right_kidney"
else if(organ == liver)
organ = "liver"
else if(organ == stomach)
organ = "stomach"
else if(organ == intestines)
organ = "intestines"
else if(organ == spleen)
organ = "spleen"
else if(organ == pancreas)
organ = "pancreas"
else if(organ == appendix)
organ = "appendix"
else if(organ == tail)
organ = "tail"
else
return 0 // what the fuck are you trying to remove
switch (lowertext(organ))
if ("all")
if (islist(src.organ_list))
for (var/thing in src.organ_list)
if (!src.organ_list[thing])
continue
src.drop_organ(thing, location)
return 1
/*src.drop_organ("brain", location)
src.drop_organ("head", location)
src.drop_organ("skull", location)
src.drop_organ("right_eye", location)
src.drop_organ("left_eye", location)
src.drop_organ("chest", location)
src.drop_organ("heart", location)
src.drop_organ("right_lung", location)
src.drop_organ("left_lung", location)
src.drop_organ("butt", location)
return 1*/
if ("head")
if (!src.head)
return 0
var/obj/item/organ/head/myHead = src.head
if (src.brain)
myHead.brain = src.drop_organ("brain", myHead)
if (src.skull)
myHead.skull = src.drop_organ("skull", myHead)
if (src.right_eye)
myHead.right_eye = src.drop_organ("right_eye", myHead)
if (src.left_eye)
myHead.left_eye = src.drop_organ("left_eye", myHead)
if (ishuman(src.donor))
var/mob/living/carbon/human/H = src.donor
if (H.glasses)
var/obj/item/W = H.glasses
H.u_equip(W)
W.set_loc(myHead)
myHead.glasses = W
if (H.head)
var/obj/item/W = H.head
H.u_equip(W)
W.set_loc(myHead)
myHead.head = W // blehhhh
if (H.ears)
var/obj/item/W = H.ears
H.u_equip(W)
W.set_loc(myHead)
myHead.ears = W
if (H.wear_mask)
var/obj/item/W = H.wear_mask
H.u_equip(W)
W.set_loc(myHead)
myHead.wear_mask = W
myHead.set_loc(location)
myHead.update_head_image()
myHead.on_removal()
myHead.holder = null
src.head = null
src.organ_list["head"] = null
src.donor.update_body()
src.donor.UpdateDamageIcon()
src.donor.update_clothing()
return myHead
if ("skull")
if (!src.skull)
return 0
var/obj/item/skull/mySkull = src.skull
mySkull.set_loc(location)
mySkull.holder = null
src.skull = null
src.organ_list["skull"] = null
src.head.skull = null
return mySkull
if ("brain")
if (!src.brain)
return 0
var/obj/item/organ/brain/myBrain = src.brain
if (!myBrain.owner) //Oh no, they have no mind!
if (src.donor.ghost)
if (src.donor.ghost.mind)
logTheThing("debug", null, null, "<b>Mind</b> drop_organ forced to retrieve mind for key \[[src.donor.key]] from ghost.")
myBrain.setOwner(src.donor.ghost.mind)
else if (src.donor.ghost.key)
logTheThing("debug", null, null, "<b>Mind</b> drop_organ forced to create new mind for key \[[src.donor.key]] from ghost.")
var/datum/mind/newmind = new
newmind.ckey = src.donor.ghost.ckey
newmind.key = src.donor.ghost.key
newmind.current = src.donor.ghost
src.donor.ghost.mind = newmind
myBrain.setOwner(newmind)
else if (src.donor.key)
logTheThing("debug", null, null, "<b>Mind</b> drop_organ forced to create new mind for key \[[src.donor.key]]")
var/datum/mind/newmind = new
newmind.ckey = src.donor.ckey
newmind.key = src.donor.key
newmind.current = src.donor
src.donor.mind = newmind
myBrain.setOwner(newmind)
myBrain.set_loc(location)
myBrain.on_removal()
myBrain.holder = null
src.brain = null
src.organ_list["brain"] = null
src.head?.brain = null
return myBrain
if ("left_eye")
if (!src.left_eye)
return 0
var/obj/item/organ/eye/myLeftEye = src.left_eye
myLeftEye.set_loc(location)
myLeftEye.on_removal()
myLeftEye.holder = null
src.left_eye = null
src.organ_list["left_eye"] = null
src.head.left_eye = null
return myLeftEye
if ("right_eye")
if (!src.right_eye)
return 0
var/obj/item/organ/eye/myRightEye = src.right_eye
myRightEye.set_loc(location)
myRightEye.on_removal()
myRightEye.holder = null
src.right_eye = null
src.organ_list["right_eye"] = null
src.head.right_eye = null
return myRightEye
if ("chest")
if (!src.chest)
return 0
var/obj/item/organ/chest/myChest = src.chest
myChest.set_loc(location)
myChest.on_removal()
myChest.holder = null
src.chest = null
src.organ_list["chest"] = null
return myChest
if ("heart")
if (!src.heart)
return 0
var/obj/item/organ/heart/myHeart = src.heart
//Commented this out for some reason I forget. I'm sure I'll remember what it is one day. -kyle
// if (src.heart.robotic)
// REMOVE_ATOM_PROPERTY(src.donor, PROP_MOB_STAMINA_REGEN_BONUS, "heart")
// src.donor.remove_stam_mod_max("heart")
myHeart.set_loc(location)
myHeart.on_removal()
myHeart.holder = null
src.heart = null
src.donor.update_body()
src.organ_list["heart"] = null
return myHeart
if ("left_lung")
if (!src.left_lung)
return 0
var/obj/item/organ/lung/left/myLeftLung = src.left_lung
myLeftLung.set_loc(location)
myLeftLung.on_removal()
myLeftLung.holder = null
src.left_lung = null
src.organ_list["left_lung"] = null
src.donor.update_body()
handle_lungs_stamina()
return myLeftLung
if ("right_lung")
if (!src.right_lung)
return 0
var/obj/item/organ/lung/right/myRightLung = src.right_lung
myRightLung.set_loc(location)
myRightLung.on_removal()
myRightLung.holder = null
src.right_lung = null
src.organ_list["right_lung"] = null
src.donor.update_body()
handle_lungs_stamina()
return myRightLung
if ("butt")
if (!src.butt)
return 0
var/obj/item/clothing/head/butt/myButt = src.butt
myButt.set_loc(location)
myButt.holder = null
src.butt = null
src.donor.butt_op_stage = 4.0
src.donor.update_body()
src.organ_list["butt"] = null
return myButt
if ("left_kidney")
if (!src.left_kidney)
return 0
var/obj/item/organ/kidney/left/myleft_kidney = src.left_kidney
myleft_kidney.set_loc(location)
myleft_kidney.on_removal()
myleft_kidney.holder = null
src.left_kidney = null
src.donor.update_body()
src.organ_list["left_kidney"] = null
return myleft_kidney
if ("right_kidney")
if (!src.right_kidney)
return 0
var/obj/item/organ/kidney/right/myright_kidney = src.right_kidney
myright_kidney.set_loc(location)
myright_kidney.on_removal()
myright_kidney.holder = null
src.right_kidney = null
src.donor.update_body()
src.organ_list["right_kidney"] = null
return myright_kidney
if ("liver")
if (!src.liver)
return 0
var/obj/item/organ/liver/myliver = src.liver
myliver.set_loc(location)
myliver.on_removal()
myliver.holder = null
src.liver = null
src.donor.update_body()
src.organ_list["liver"] = null
return myliver
if ("stomach")
if (!src.stomach)
return 0
var/obj/item/organ/stomach/mystomach = src.stomach
mystomach.set_loc(location)
mystomach.on_removal()
mystomach.holder = null
src.stomach = null
src.donor.update_body()
src.organ_list["stomach"] = null
return mystomach
if ("intestines")
if (!src.intestines)
return 0
var/obj/item/organ/intestines/myintestines = src.intestines
myintestines.set_loc(location)
myintestines.on_removal()
myintestines.holder = null
src.intestines = null
src.donor.update_body()
src.organ_list["intestines"] = null
return myintestines
if ("spleen")
if (!src.spleen)
return 0
var/obj/item/organ/spleen/myspleen = src.spleen
myspleen.set_loc(location)
myspleen.on_removal()
myspleen.holder = null
src.spleen = null
src.donor.update_body()
src.organ_list["spleen"] = null
return myspleen
if ("pancreas")
if (!src.pancreas)
return 0
var/obj/item/organ/pancreas/mypancreas = src.pancreas
mypancreas.set_loc(location)
mypancreas.on_removal()
mypancreas.holder = null
src.pancreas = null
src.donor.update_body()
src.organ_list["pancreas"] = null
return mypancreas
if ("appendix")
if (!src.appendix)
return 0
var/obj/item/organ/appendix/myappendix = src.appendix
myappendix.set_loc(location)
myappendix.on_removal()
myappendix.holder = null
src.appendix = null
src.donor.update_body()
src.organ_list["appendix"] = null
return myappendix
if ("tail")
if (!src.tail)
return 0
var/obj/item/organ/tail/mytail = src.tail
mytail.set_loc(location)
mytail.on_removal()
mytail.holder = null
src.tail = null
src.donor.update_body()
src.organ_list["tail"] = null
return mytail
/// drops the organ, then hurls it somewhere
proc/drop_and_throw_organ(var/organ, var/location, var/direction, var/dist, var/speed, var/showtext)
. = src.drop_organ(organ, location)
if(istype(., /obj))
var/obj/organ_toss = .
if (!location)
location = src.donor.loc
if(direction in alldirs)
var/atom/target = get_edge_target_turf(organ_toss, direction)
organ_toss.throw_at(target, dist, speed)
else
ThrowRandom(organ_toss, dist, speed)
if(showtext && ishuman(src.donor))
var/grody_arc = "bloody"
if(istype(organ_toss, /obj/item/parts))
var/obj/item/parts/limb = organ_toss
grody_arc = limb.streak_descriptor
else if(istype(organ_toss, /obj/item/organ))
var/obj/item/organ/orgn = organ_toss
if(orgn.robotic)
grody_arc = "oily"
else
grody_arc = "bloody"
else if(istype(organ_toss, /obj/item/clothing/head/butt))
if(istype(organ_toss, /obj/item/clothing/head/butt/cyberbutt))
grody_arc = "greasy"
else
grody_arc = "floppy"
src.donor.visible_message("<span class='alert'>[src.donor.name]'s [organ_toss.name] flies off in a [grody_arc] arc!</span>")
src.donor.emote("scream")
src.donor.update_clothing()
proc/receive_organ(var/obj/item/I, var/organ, var/op_stage = 0.0, var/force = 0)
if (!src.donor || !I || !organ)
return 0
var/success = 0
switch (lowertext(organ))
if ("head")
if (src.head)
if (force)
qdel(src.head)
else
return 0
var/obj/item/organ/head/newHead = I
if (src.donor.client)
src.donor.client.mob = new /mob/dead/observer(src)
if (newHead.brain && newHead.brain.owner)
newHead.brain.owner.transfer_to(src.donor)
newHead.op_stage = op_stage
src.head = newHead
newHead.set_loc(src.donor)
newHead.holder = src
if (newHead.skull)
if (src.skull) // how
src.drop_organ("skull") // I mean really, how
src.receive_organ(newHead.skull, "skull", newHead.skull.op_stage)
if (newHead.brain)
if (src.brain) // ???
src.drop_organ("brain") // god idfk
src.receive_organ(newHead.brain, "brain", newHead.brain.op_stage)
if (newHead.right_eye)
if (src.right_eye)
src.drop_organ("right_eye")
src.receive_organ(newHead.right_eye, "right_eye", newHead.right_eye.op_stage)
if (newHead.left_eye)
if (src.left_eye)
src.drop_organ("left_eye")
src.receive_organ(newHead.left_eye, "left_eye", newHead.left_eye.op_stage)
if (ishuman(src.donor))
var/mob/living/carbon/human/H = src.donor
if (newHead.glasses)
if (H.glasses)
H.glasses.set_loc(get_turf(H))
H.u_equip(H.glasses)
H.glasses = newHead.glasses
newHead.glasses.set_loc(H)
newHead.glasses = null
if (newHead.head)
if (H.head)
H.head.set_loc(get_turf(H))
H.u_equip(H.head)
H.head = newHead.head
newHead.head.set_loc(H)
newHead.head = null
if (newHead.ears)
if (H.ears)
H.ears.set_loc(get_turf(H))
H.u_equip(H.ears)
H.ears = newHead.ears
newHead.ears.set_loc(H)
newHead.ears = null
if (newHead.wear_mask)
if (H.wear_mask)
H.wear_mask.set_loc(get_turf(H))
H.u_equip(H.wear_mask)
H.wear_mask = newHead.wear_mask
newHead.wear_mask.set_loc(H)
newHead.wear_mask = null
src.donor.update_body()
src.donor.UpdateDamageIcon()
src.donor.update_clothing()
organ_list["head"] = newHead
success = 1
if ("skull")
if (src.skull)
if (force)
qdel(src.skull)
else
return 0
if (!src.head)
return 0
var/obj/item/skull/newSkull = I
newSkull.op_stage = op_stage
src.skull = newSkull
src.head.skull = newSkull
newSkull.set_loc(src.donor)
newSkull.holder = src
organ_list["skull"] = newSkull
success = 1
if ("brain")
if (src.brain)
if (force)
qdel(src.brain)
else
return 0
if (!src.skull)
return 0
var/obj/item/organ/brain/newBrain = I
if (src.donor.client)
src.donor.client.mob = new /mob/dead/observer(src)
if (newBrain.owner)
newBrain.owner.transfer_to(src.donor)
newBrain.op_stage = op_stage
src.brain = newBrain
src.head.brain = newBrain
newBrain.set_loc(src.donor)
newBrain.holder = src
organ_list["brain"] = newBrain
success = 1
if ("left_eye")
if (src.left_eye)
if (force)
qdel(src.left_eye)
else
return 0
if (!src.head)
return 0
var/obj/item/organ/eye/newLeftEye = I
newLeftEye.op_stage = op_stage
src.left_eye = newLeftEye
src.head.left_eye = newLeftEye
newLeftEye.body_side = L_ORGAN
newLeftEye.set_loc(src.donor)
newLeftEye.holder = src
organ_list["left_eye"] = newLeftEye
success = 1
if ("right_eye")
if (src.right_eye)
if (force)
qdel(src.right_eye)
else
return 0
if (!src.head)
return 0
var/obj/item/organ/eye/newRightEye = I
newRightEye.op_stage = op_stage
src.right_eye = newRightEye
src.head.right_eye = newRightEye
newRightEye.body_side = R_ORGAN
newRightEye.set_loc(src.donor)
newRightEye.holder = src
organ_list["right_eye"] = newRightEye
success = 1
if ("chest") // should never be this but vOv
if (src.chest)
if (force)
qdel(src.chest)
else
return 0
var/obj/item/organ/chest/newChest = I
newChest.op_stage = op_stage
src.chest = newChest
newChest.set_loc(src.donor)
newChest.holder = src
organ_list["chest"] = newChest
success = 1
if ("heart")
if (src.heart)
if (force)
qdel(src.heart)
else
return 0
var/obj/item/organ/heart/newHeart = I
if (newHeart.robotic)
if (src.donor.bioHolder.HasEffect("resist_electric"))
newHeart.breakme()
if (newHeart.broken)
src.donor.show_text("Something is wrong with [newHeart], it fails to start beating!", "red")
src.donor.contract_disease(/datum/ailment/malady/flatline,null,null,1)
//Like above, I commented this out for a reason I cannot remember. might just be because I changed how that stamina modifier works, I dunno.
// if (newHeart.emagged)
// APPLY_ATOM_PROPERTY(src.donor, PROP_MOB_STAMINA_REGEN_BONUS, "heart", 20)
// src.donor.add_stam_mod_max("heart", 100)
// else
// APPLY_ATOM_PROPERTY(src.donor, PROP_MOB_STAMINA_REGEN_BONUS, "heart", 10)
// src.donor.add_stam_mod_max("heart", 50)
newHeart.op_stage = op_stage
src.heart = newHeart
newHeart.set_loc(src.donor)
newHeart.holder = src
organ_list["heart"] = newHeart
success = 1
if ("left_lung")
if (src.left_lung)
if (force)
qdel(src.left_lung)
else
return 0
var/obj/item/organ/lung/newLeftLung = I
newLeftLung.op_stage = op_stage
src.left_lung = newLeftLung
newLeftLung.body_side = L_ORGAN
newLeftLung.set_loc(src.donor)
newLeftLung.holder = src
organ_list["left_lung"] = newLeftLung
handle_lungs_stamina()
success = 1
if ("right_lung")
if (src.right_lung)
if (force)
qdel(src.right_lung)
else
return 0
var/obj/item/organ/lung/newRightLung = I
newRightLung.op_stage = op_stage
src.right_lung = newRightLung
newRightLung.body_side = R_ORGAN
newRightLung.set_loc(src.donor)
newRightLung.holder = src
organ_list["right_lung"] = newRightLung
handle_lungs_stamina()
success = 1
if ("butt")
if (src.butt)
if (force)
qdel(src.butt)
else
return 0
var/obj/item/clothing/head/butt/newButt = I
newButt.op_stage = op_stage
src.butt = newButt
newButt.set_loc(src.donor)
newButt.holder = src
organ_list["butt"] = newButt
success = 1
if ("left_kidney")
if (src.left_kidney)
if (force)
qdel(src.left_kidney)
else
return 0
var/obj/item/organ/kidney/left/newleft_kidney = I
newleft_kidney.op_stage = op_stage
src.left_kidney = newleft_kidney
newleft_kidney.set_loc(src.donor)
newleft_kidney.holder = src
organ_list["left_kidney"] = newleft_kidney
success = 1