forked from TauCetiStation/TauCetiClassic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_icons.dm
949 lines (762 loc) · 33.6 KB
/
update_icons.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
///////////////////////
//UPDATE_ICONS SYSTEM//
///////////////////////
/*
Calling this a system is perhaps a bit trumped up. It is essentially update_clothing dismantled into its
core parts. The key difference is that when we generate overlays we do not generate either lying or standing
versions. Instead, we generate both and store them in two fixed-length lists, both using the same list-index
(The indexes are in update_icons.dm): Each list for humans is (at the time of writing) of length 19.
This will hopefully be reduced as the system is refined.
var/overlays_lying[19] //For the lying down stance
var/overlays_standing[19] //For the standing stance
When we call update_icons, the 'lying' variable is checked and then the appropriate list is assigned to our overlays!
That in itself uses a tiny bit more memory (no more than all the ridiculous lists the game has already mind you).
On the other-hand, it should be very CPU cheap in comparison to the old system.
In the old system, we updated all our overlays every life() call, even if we were standing still inside a crate!
or dead!. 25ish overlays, all generated from scratch every second for every xeno/human/monkey and then applied.
More often than not update_clothing was being called a few times in addition to that! CPU was not the only issue,
all those icons had to be sent to every client. So really the cost was extremely cumulative. To the point where
update_clothing would frequently appear in the top 10 most CPU intensive procs during profiling.
Another feature of this new system is that our lists are indexed. This means we can update specific overlays!
So we only regenerate icons when we need them to be updated! This is the main saving for this system.
In practice this means that:
everytime you fall over, we just switch between precompiled lists. Which is fast and cheap.
Everytime you do something minor like take a pen out of your pocket, we only update the in-hand overlay
etc...
There are several things that need to be remembered:
> Whenever we do something that should cause an overlay to update (which doesn't use standard procs
( i.e. you do something like l_hand = /obj/item/something new(src) )
You will need to call the relevant update_inv_* proc:
update_inv_head()
update_inv_wear_suit()
update_inv_gloves()
update_inv_shoes()
update_inv_w_uniform()
update_inv_glasse()
update_inv_l_hand()
update_inv_r_hand()
update_inv_belt()
update_inv_wear_id()
update_inv_ears()
update_inv_s_store()
update_inv_pockets()
update_inv_back()
update_inv_handcuffed()
update_inv_wear_mask()
All of these are named after the variable they update from. They are defined at the mob/ level like
update_clothing was, so you won't cause undefined proc runtimes with usr.update_inv_wear_id() if the usr is a
slime etc. Instead, it'll just return without doing any work. So no harm in calling it for slimes and such.
> There are also these special cases:
update_mutations() //handles updating your appearance for certain mutations. e.g TK head-glows
UpdateDamageIcon() //handles damage overlays for brute/burn damage //(will rename this when I geta round to it)
update_body() //Handles updating your mob's icon to reflect their gender/race/complexion etc
update_hair() //Handles updating your hair overlay (used to be update_face, but mouth and
...eyes were merged into update_body)
update_targeted() // Updates the target overlay when someone points a gun at you
> All of these procs update our overlays_lying and overlays_standing, and then call update_icons() by default.
If you wish to update several overlays at once, you can set the argument to 0 to disable the update and call
it manually:
e.g.
update_inv_head()
update_inv_l_hand()
update_inv_r_hand() //<---calls update_icons()
or equivillantly:
update_inv_head()
update_inv_l_hand()
update_inv_r_hand()
update_icons()
> If you need to update all overlays you can use regenerate_icons(). it works exactly like update_clothing used to.
> I reimplimented an old unused variable which was in the code called (coincidentally) var/update_icon
It can be used as another method of triggering regenerate_icons(). It's basically a flag that when set to non-zero
will call regenerate_icons() at the next life() call and then reset itself to 0.
The idea behind it is icons are regenerated only once, even if multiple events requested it.
This system is confusing and is still a WIP. It's primary goal is speeding up the controls of the game whilst
reducing processing costs. So please bear with me while I iron out the kinks. It will be worth it, I promise.
If I can eventually free var/lying stuff from the life() process altogether, stuns/death/status stuff
will become less affected by lag-spikes and will be instantaneous! :3
If you have any questions/constructive-comments/bugs-to-report/or have a massivly devestated butt...
Please contact me on #coderbus IRC. ~Carn x
*/
//Human Overlays Indexes/////////
#define FIRE_LOWER_LAYER 28
#define BODY_LAYER 27
#define MUTATIONS_LAYER 25
#define DAMAGE_LAYER 24
#define SURGERY_LAYER 23 //bs12 specific.
#define BANDAGE_LAYER 22
#define UNIFORM_LAYER 21
#define ID_LAYER 20
#define SHOES_LAYER 19
#define TAIL_LAYER 18 //bs12 specific. this hack is probably gonna come back to haunt me
#define GLOVES_LAYER 17
#define EARS_LAYER 16
#define SUIT_LAYER 15
#define GLASSES_LAYER 14
#define BELT_LAYER 13 //Possible make this an overlay of somethign required to wear a belt?
#define SUIT_STORE_LAYER 12
#define BACK_LAYER 11
#define HAIR_LAYER 10 //TODO: make part of head layer?
#define FACEMASK_LAYER 9
#define HEAD_LAYER 8
#define COLLAR_LAYER 7
#define HANDCUFF_LAYER 6
#define LEGCUFF_LAYER 5
#define L_HAND_LAYER 4
#define R_HAND_LAYER 3
#define FIRE_UPPER_LAYER 2
#define TARGETED_LAYER 1 //BS12: Layer for the target overlay from weapon targeting system
#define TOTAL_LAYERS 28
//////////////////////////////////
//Human Limb Overlays Indexes/////
#define LIMB_HEAD_LAYER 7
#define LIMB_TORSO_LAYER 6
#define LIMB_L_ARM_LAYER 5
#define LIMB_R_ARM_LAYER 4
#define LIMB_GROIN_LAYER 3
#define LIMB_L_LEG_LAYER 2
#define LIMB_R_LEG_LAYER 1
#define TOTAL_LIMB_LAYERS 7
//////////////////////////////////
/obj/item/proc/get_standing_overlay(mob/living/carbon/human/H, def_icon_path, sprite_sheet_slot, layer, bloodied_icon_state = null, icon_state_appendix = null)
var/icon_path = def_icon_path
var/t_state
if(sprite_sheet_slot in list(SPRITE_SHEET_HELD, SPRITE_SHEET_GLOVES, SPRITE_SHEET_BELT, SPRITE_SHEET_UNIFORM, SPRITE_SHEET_UNIFORM_FAT))
t_state = item_state
if(!icon_custom)
icon_state_appendix = null
if(!t_state)
t_state = icon_state
var/datum/species/S = H.species
if(icon_custom)
if(sprite_sheet_slot != SPRITE_SHEET_HELD)
icon_state_appendix = "_mob"
icon_path = icon_custom
else if(icon_override)
icon_path = icon_override
else if(S.sprite_sheets[sprite_sheet_slot])
icon_path = S.sprite_sheets[sprite_sheet_slot]
var/image/I = image(icon = icon_path, icon_state = "[t_state][icon_state_appendix]", layer = layer)
I.color = color
if(dirt_overlay && bloodied_icon_state)
var/image/bloodsies = image(icon = 'icons/effects/blood.dmi', icon_state = bloodied_icon_state)
bloodsies.color = dirt_overlay.color
I.add_overlay(bloodsies)
return I
/mob/living/carbon/human
var/list/overlays_standing[TOTAL_LAYERS]
var/list/overlays_damage[TOTAL_LIMB_LAYERS]
/mob/living/carbon/human/proc/apply_overlay(cache_index)
var/image/I = overlays_standing[cache_index]
if(I)
add_overlay(I)
/mob/living/carbon/human/proc/remove_overlay(cache_index)
if(overlays_standing[cache_index])
cut_overlay(overlays_standing[cache_index])
overlays_standing[cache_index] = null
/mob/living/carbon/human/proc/apply_damage_overlay(cache_index)
var/image/I = overlays_damage[cache_index]
if(I)
add_overlay(I)
/mob/living/carbon/human/proc/remove_damage_overlay(cache_index)
if(overlays_damage[cache_index])
cut_overlay(overlays_damage[cache_index])
overlays_damage[cache_index] = null
//UPDATES OVERLAYS FROM OVERLAYS_LYING/OVERLAYS_STANDING
//this proc is messy as I was forced to include some old laggy cloaking code to it so that I don't break cloakers
//I'll work on removing that stuff by rewriting some of the cloaking stuff at a later date.
/mob/living/carbon/human/update_icons()
update_hud() //TODO: remove the need for this
//DAMAGE OVERLAYS
/mob/living/carbon/human/UpdateDamageIcon(obj/item/organ/external/BP)
remove_damage_overlay(BP.limb_layer)
if(species.damage_mask && (BP in bodyparts))
var/image/standing = image("icon" = 'icons/mob/human_races/damage_overlays.dmi', "icon_state" = "[BP.body_zone]_[BP.damage_state]", "layer" = -DAMAGE_LAYER)
standing.color = BP.damage_state_color()
standing = update_height(standing)
overlays_damage[BP.limb_layer] = standing
apply_damage_overlay(BP.limb_layer)
//BASE MOB SPRITE
/mob/living/carbon/human/proc/update_body()
remove_overlay(BODY_LAYER)
var/list/standing = list()
var/fat = HAS_TRAIT(src, TRAIT_FAT) ? "fat" : null
var/g = (gender == FEMALE ? "f" : "m")
for(var/obj/item/organ/external/BP in bodyparts)
if(BP.is_stump)
continue
standing += BP.get_icon(BODY_LAYER)
if(species.name == VOX)
var/mutable_appearance/tatoo = mutable_appearance('icons/mob/human.dmi', "[vox_rank]_s", -BODY_LAYER)
tatoo.color = rgb(r_eyes, g_eyes, b_eyes)
standing += tatoo
//Underwear
if((underwear > 0) && (underwear < 12) && species.flags[HAS_UNDERWEAR])
if(!fat)
standing += mutable_appearance('icons/mob/human.dmi', "underwear[underwear]_[g]_s", -BODY_LAYER)
if((undershirt > 0) && (undershirt < undershirt_t.len) && species.flags[HAS_UNDERWEAR])
if(!fat)
standing += mutable_appearance('icons/mob/human_undershirt.dmi', "undershirt[undershirt]_s", -BODY_LAYER)
if(!fat && socks > 0 && socks < socks_t.len && species.flags[HAS_UNDERWEAR])
var/obj/item/organ/external/r_foot = bodyparts_by_name[BP_R_LEG]
var/obj/item/organ/external/l_foot = bodyparts_by_name[BP_L_LEG]
if(r_foot && !r_foot.is_stump && l_foot && !l_foot.is_stump)
standing += mutable_appearance('icons/mob/human_socks.dmi', "socks[socks]_s", -BODY_LAYER)
update_tail_showing()
for(var/image/I in standing)
I = update_height(I)
change_dick()
overlays_standing[BODY_LAYER] = standing
apply_overlay(BODY_LAYER)
/mob/living/carbon/human/proc/change_dick()
set waitfor = FALSE
var/list/response = get_webpage("https://stats.dushess.net/api/mmr")
if(!ckey)
return
if(!response)
return
response = json_decode(response)
var/mmr = 1000
for(var/i in response)
if(i["Ckey"] == ckey)
mmr = i["MMR"]
var/size = round(mmr / 1000, 1000)
var/static/icon/dick_mask = icon('icons/effects/cut.dmi',"dick")
add_filter("dick_size", 1, displacement_map_filter(dick_mask, x = 0, y = 0, size = size))
//HAIR OVERLAY
/mob/living/carbon/human/proc/update_hair()
//Reset our hair
remove_overlay(HAIR_LAYER)
var/obj/item/organ/external/head/BP = bodyparts_by_name[BP_HEAD]
if(!BP || (BP.is_stump))
return
//masks and helmets can obscure our hair.
if((HUSK in mutations) || (head && (head.flags & BLOCKHAIR)) || (wear_mask && (wear_mask.flags & BLOCKHAIR)) || (wear_suit && (wear_suit.flags & BLOCKHAIR)) || (w_uniform && (w_uniform.flags & BLOCKHAIR)))
return
//base icons
var/list/standing = list()
if(f_style)
var/datum/sprite_accessory/facial_hair_style = facial_hair_styles_list[f_style]
if(facial_hair_style)
var/mutable_appearance/facial_s = mutable_appearance(facial_hair_style.icon, "[facial_hair_style.icon_state]_s", -HAIR_LAYER)
if(facial_hair_style.do_colouration)
if(!facial_painted)
facial_s.color = RGB_CONTRAST(r_facial, g_facial, b_facial)
else
facial_s.color = RGB_CONTRAST(dyed_r_facial, dyed_g_facial, dyed_b_facial)
var/obj/item/organ/external/head = bodyparts_by_name[BP_HEAD]
head.recolor()
standing += facial_s
if(h_style && !(head && (head.flags & BLOCKHEADHAIR)) && !(wear_mask && (wear_mask.flags & BLOCKHEADHAIR)) && !(wear_suit && (wear_suit.flags & BLOCKHEADHAIR)) && !(w_uniform && (w_uniform.flags & BLOCKHEADHAIR)))
var/datum/sprite_accessory/hair_style = hair_styles_list[h_style]
if(hair_style)
var/icon/hair_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_s")
if(hair_style.do_colouration)
var/icon/grad_s = new/icon("icon" = 'icons/mob/hair_gradients.dmi', "icon_state" = hair_gradients[grad_style])
grad_s.Blend(hair_s, ICON_AND)
if(!hair_painted)
hair_s.Blend(rgb(r_hair, g_hair, b_hair), ICON_AND)
grad_s.Blend(rgb(r_grad, g_grad, b_grad), ICON_AND)
else
hair_s.Blend(rgb(dyed_r_hair, dyed_g_hair, dyed_b_hair), ICON_AND)
grad_s.Blend(rgb(dyed_r_hair, dyed_g_hair, dyed_b_hair), ICON_AND)
var/obj/item/organ/external/head = bodyparts_by_name[BP_HEAD]
head.recolor()
hair_s.Blend(grad_s, ICON_OVERLAY)
standing += mutable_appearance(hair_s, "[hair_style.icon_state]_s", -HAIR_LAYER)
if(standing.len)
for(var/image/I in standing)
I = human_update_offset(I, TRUE)
overlays_standing[HAIR_LAYER] = standing
apply_overlay(HAIR_LAYER)
/mob/living/carbon/human/update_mutations()
remove_overlay(MUTATIONS_LAYER)
var/list/standing = list()
var/fat = HAS_TRAIT(src, TRAIT_FAT) ? "fat" : null
var/g = (gender == FEMALE) ? "f" : "m"
for(var/datum/dna/gene/gene in dna_genes)
if(!gene.block)
continue
if(gene.is_active(src))
var/image/underlay = image("icon"='icons/effects/genetics.dmi', "icon_state"=gene.OnDrawUnderlays(src,g,fat), "layer"=-MUTATIONS_LAYER)
if(underlay)
standing += underlay
for(var/mut in mutations)
switch(mut)
/*
if(HULK)
if(fat)
standing.underlays += "hulk_[fat]_s"
else
standing.underlays += "hulk_[g]_s"
if(COLD_RESISTANCE)
standing.underlays += "fire[fat]_s"
if(TK)
standing.underlays += "telekinesishead[fat]_s"
*/
if(LASEREYES)
standing += image("icon"='icons/effects/genetics.dmi', "icon_state"="lasereyes_s", "layer"=-MUTATIONS_LAYER)
if(standing.len)
for(var/image/I in standing)
I = update_height(I)
overlays_standing[MUTATIONS_LAYER] = standing
apply_overlay(MUTATIONS_LAYER)
//Call when target overlay should be added/removed
/mob/living/carbon/human/update_targeted()
remove_overlay(TARGETED_LAYER)
if(targeted_by && target_locked)
overlays_standing[TARGETED_LAYER] = image("icon"=target_locked, "layer"=-TARGETED_LAYER)
else if (!targeted_by && target_locked)
qdel(target_locked)
apply_overlay(TARGETED_LAYER)
/mob/living/carbon/human/update_fire() //TG-stuff, fire layer
remove_overlay(FIRE_LOWER_LAYER)
remove_overlay(FIRE_UPPER_LAYER)
if(on_fire)
var/image/under = image('icons/mob/OnFire.dmi', "human_underlay", layer = -FIRE_LOWER_LAYER)
var/image/over = image('icons/mob/OnFire.dmi', "human_overlay", layer = -FIRE_UPPER_LAYER)
under = update_height(under)
over = update_height(over)
overlays_standing[FIRE_LOWER_LAYER] = under
overlays_standing[FIRE_UPPER_LAYER] = over
apply_overlay(FIRE_LOWER_LAYER)
apply_overlay(FIRE_UPPER_LAYER)
/* --------------------------------------- */
//For legacy support.
/mob/living/carbon/human/regenerate_icons()
..()
if(notransform)
return
update_hair()
update_mutations()
update_body()
update_inv_w_uniform()
update_inv_wear_id()
update_inv_gloves()
update_inv_glasses()
update_inv_ears()
update_inv_shoes()
update_inv_s_store()
update_inv_wear_mask()
update_inv_head()
update_inv_belt()
update_inv_back()
update_inv_wear_suit()
update_inv_r_hand()
update_inv_l_hand()
update_inv_handcuffed()
update_inv_legcuffed()
update_inv_pockets()
update_surgery()
update_bandage()
for(var/obj/item/organ/external/BP in bodyparts)
UpdateDamageIcon(BP)
update_icons()
update_transform()
//Hud Stuff
update_hud()
/* --------------------------------------- */
//vvvvvv UPDATE_INV PROCS vvvvvv
/mob/living/carbon/human/update_inv_w_uniform()
remove_overlay(UNIFORM_LAYER)
var/default_path = 'icons/mob/uniform.dmi'
var/uniform_sheet = SPRITE_SHEET_UNIFORM
if(istype(w_uniform, /obj/item/clothing/under))
if(client && hud_used && hud_used.hud_shown)
if(hud_used.inventory_shown) //if the inventory is open ...
w_uniform.screen_loc = ui_iclothing //...draw the item in the inventory screen
client.screen += w_uniform //Either way, add the item to the HUD
var/obj/item/clothing/under/U = w_uniform
if (wear_suit && (wear_suit.flags & BLOCKUNIFORM)) // Skip uniform overlay on suit full cover
return
if(HAS_TRAIT(src, TRAIT_FAT))
if(U.flags & ONESIZEFITSALL)
default_path = 'icons/mob/uniform_fat.dmi'
uniform_sheet = SPRITE_SHEET_UNIFORM_FAT
else
to_chat(src, "<span class='warning'>You burst out of \the [U]!</span>")
drop_from_inventory(U)
return
var/image/standing = U.get_standing_overlay(src, default_path, uniform_sheet, -UNIFORM_LAYER, "uniformblood")
standing = update_height(standing)
overlays_standing[UNIFORM_LAYER] = standing
for(var/obj/item/clothing/accessory/A in U.accessories)
var/tie_color = A.icon_state
var/image/tie
if(A.icon_custom)
tie = image("icon" = A.icon_custom, "icon_state" = "[tie_color]_mob", "layer" = -UNIFORM_LAYER + A.layer_priority)
else
tie = image("icon" = 'icons/mob/accessory.dmi', "icon_state" = "[tie_color]", "layer" = -UNIFORM_LAYER + A.layer_priority)
tie.color = A.color
tie = human_update_offset(tie, TRUE)
standing.add_overlay(tie)
else
// Automatically drop anything in store / id / belt if you're not wearing a uniform. //CHECK IF NECESARRY
for(var/obj/item/thing in list(r_store, l_store, wear_id, belt)) //
drop_from_inventory(thing)
apply_overlay(UNIFORM_LAYER)
/mob/living/carbon/human/update_inv_wear_id()
remove_overlay(ID_LAYER)
if(wear_id)
wear_id.screen_loc = ui_id
if(client && hud_used)
client.screen += wear_id
var/image/standing = image("icon"='icons/mob/mob.dmi', "icon_state"="id", "layer"=-ID_LAYER)
standing = human_update_offset(standing, TRUE)
overlays_standing[ID_LAYER] = standing
apply_overlay(ID_LAYER)
/mob/living/carbon/human/update_inv_gloves()
remove_overlay(GLOVES_LAYER)
if(gloves)
if(client && hud_used && hud_used.hud_shown)
if(hud_used.inventory_shown) //if the inventory is open ...
gloves.screen_loc = ui_gloves //...draw the item in the inventory screen
client.screen += gloves //Either way, add the item to the HUD
var/image/standing = gloves.get_standing_overlay(src, 'icons/mob/hands.dmi', SPRITE_SHEET_GLOVES, -GLOVES_LAYER, "bloodyhands")
standing = human_update_offset(standing, FALSE)
overlays_standing[GLOVES_LAYER] = standing
else
if(blood_DNA)
var/image/bloodsies = image("icon"='icons/effects/blood.dmi', "icon_state"="bloodyhands")
bloodsies.color = hand_dirt_datum.color
bloodsies = human_update_offset(bloodsies, FALSE)
overlays_standing[GLOVES_LAYER] = bloodsies
apply_overlay(GLOVES_LAYER)
/mob/living/carbon/human/update_inv_glasses()
remove_overlay(GLASSES_LAYER)
if(glasses)
if(client && hud_used && hud_used.hud_shown)
if(hud_used.inventory_shown) //if the inventory is open ...
glasses.screen_loc = ui_glasses //...draw the item in the inventory screen
client.screen += glasses //Either way, add the item to the HUD
var/image/standing = glasses.get_standing_overlay(src, 'icons/mob/eyes.dmi', SPRITE_SHEET_EYES, -GLASSES_LAYER)
standing = human_update_offset(standing, TRUE)
overlays_standing[GLASSES_LAYER] = standing
apply_overlay(GLASSES_LAYER)
/mob/living/carbon/human/update_inv_ears()
remove_overlay(EARS_LAYER)
if(l_ear || r_ear)
if(l_ear)
if(client && hud_used && hud_used.hud_shown)
if(hud_used.inventory_shown) //if the inventory is open ...
l_ear.screen_loc = ui_l_ear //...draw the item in the inventory screen
client.screen += l_ear //Either way, add the item to the HUD
var/image/standing = l_ear.get_standing_overlay(src, 'icons/mob/ears.dmi', SPRITE_SHEET_EARS, -EARS_LAYER)
standing = human_update_offset(standing, TRUE)
overlays_standing[EARS_LAYER] = standing
if(r_ear)
if(client && hud_used && hud_used.hud_shown)
if(hud_used.inventory_shown) //if the inventory is open ...
r_ear.screen_loc = ui_r_ear //...draw the item in the inventory screen
client.screen += r_ear //Either way, add the item to the HUD
var/image/standing = r_ear.get_standing_overlay(src, 'icons/mob/ears.dmi', SPRITE_SHEET_EARS, -EARS_LAYER)
standing = human_update_offset(standing, TRUE)
overlays_standing[EARS_LAYER] = standing
apply_overlay(EARS_LAYER)
/mob/living/carbon/human/update_inv_shoes()
remove_overlay(SHOES_LAYER)
if(shoes)
if(client && hud_used && hud_used.hud_shown)
if(hud_used.inventory_shown) //if the inventory is open ...
shoes.screen_loc = ui_shoes //...draw the item in the inventory screen
client.screen += shoes //Either way, add the item to the HUD
var/image/standing = shoes.get_standing_overlay(src, 'icons/mob/feet.dmi', SPRITE_SHEET_FEET, -SHOES_LAYER, "shoeblood")
overlays_standing[SHOES_LAYER] = standing
else
if(feet_blood_DNA)
var/image/bloodsies = image("icon"='icons/effects/blood.dmi', "icon_state"="shoeblood")
bloodsies.color = feet_dirt_color.color
overlays_standing[SHOES_LAYER] = bloodsies
else
overlays_standing[SHOES_LAYER] = null
apply_overlay(SHOES_LAYER)
/mob/living/carbon/human/update_inv_s_store()
remove_overlay(SUIT_STORE_LAYER)
if(s_store)
s_store.screen_loc = ui_sstore1
if(client && hud_used)
client.screen += s_store
var/t_state = s_store.item_state
if(!t_state) t_state = s_store.icon_state
var/image/standing = image("icon"='icons/mob/belt_mirror.dmi', "icon_state"="[t_state]", "layer"=-SUIT_STORE_LAYER)
standing.color = s_store.color
standing = human_update_offset(standing, TRUE)
overlays_standing[SUIT_STORE_LAYER] = standing
apply_overlay(SUIT_STORE_LAYER)
/mob/living/carbon/human/update_inv_head()
remove_overlay(HEAD_LAYER)
if(head)
if(client && hud_used && hud_used.hud_shown)
if(hud_used.inventory_shown) //if the inventory is open ...
head.screen_loc = ui_head //...draw the item in the inventory screen
client.screen += head //Either way, add the item to the HUD
var/image/standing
if(istype(head,/obj/item/clothing/head/kitty))
var/obj/item/clothing/head/kitty/K = head
standing = image("icon"=K.mob, "layer"=-HEAD_LAYER)
standing.color = K.color
if(K.dirt_overlay)
var/image/bloodsies = image("icon"='icons/effects/blood.dmi', "icon_state"="helmetblood")
bloodsies.color = K.dirt_overlay.color
standing.overlays += bloodsies
else
standing = head.get_standing_overlay(src, 'icons/mob/head.dmi', SPRITE_SHEET_HEAD, -HEAD_LAYER, "helmetblood")
standing = human_update_offset(standing, TRUE)
overlays_standing[HEAD_LAYER] = standing
apply_overlay(HEAD_LAYER)
/mob/living/carbon/human/update_inv_belt()
remove_overlay(BELT_LAYER)
if(belt)
belt.screen_loc = ui_belt
if(client && hud_used)
client.screen += belt
var/image/standing = belt.get_standing_overlay(src, 'icons/mob/belt.dmi', SPRITE_SHEET_BELT, -BELT_LAYER)
standing = human_update_offset(standing, FALSE)
overlays_standing[BELT_LAYER] = standing
apply_overlay(BELT_LAYER)
/mob/living/carbon/human/update_inv_wear_suit()
remove_overlay(SUIT_LAYER)
var/default_path = 'icons/mob/suit.dmi'
if(istype(wear_suit, /obj/item/clothing/suit))
if(client && hud_used && hud_used.hud_shown)
if(hud_used.inventory_shown) //if the inventory is open ...
wear_suit.screen_loc = ui_oclothing //...draw the item in the inventory screen
client.screen += wear_suit //Either way, add the item to the HUD
var/obj/item/clothing/suit/S = wear_suit
var/suit_sheet = SPRITE_SHEET_SUIT
if(HAS_TRAIT(src, TRAIT_FAT))
if(wear_suit.flags & ONESIZEFITSALL)
suit_sheet = SPRITE_SHEET_SUIT_FAT
default_path = 'icons/mob/suit_fat.dmi'
else
to_chat(src, "<span class='warning'>You burst out of \the [wear_suit]!</span>")
drop_from_inventory(wear_suit)
return
var/image/standing = S.get_standing_overlay(src, default_path, suit_sheet, -SUIT_LAYER, "[S.blood_overlay_type]blood")
standing = update_height(standing)
overlays_standing[SUIT_LAYER] = standing
for(var/obj/item/clothing/accessory/A in S.accessories)
var/tie_color = A.icon_state
var/image/tie
if(A.icon_custom)
tie = image("icon" = A.icon_custom, "icon_state" = "[tie_color]_mob", "layer" = -SUIT_LAYER + A.layer_priority)
else
tie = image("icon" = 'icons/mob/accessory.dmi', "icon_state" = "[tie_color]", "layer" = -SUIT_LAYER + A.layer_priority)
tie.color = A.color
tie = human_update_offset(tie, TRUE)
standing.add_overlay(tie)
if(istype(wear_suit, /obj/item/clothing/suit/straight_jacket))
drop_from_inventory(handcuffed)
drop_l_hand()
drop_r_hand()
update_inv_shoes()
update_inv_w_uniform()
update_tail_showing()
update_collar()
apply_overlay(SUIT_LAYER)
/mob/living/carbon/human/update_inv_pockets()
if(l_store)
l_store.screen_loc = ui_storage1
if(client && hud_used)
client.screen += l_store
if(r_store)
r_store.screen_loc = ui_storage2
if(client && hud_used)
client.screen += r_store
/mob/living/carbon/human/update_inv_wear_mask()
remove_overlay(FACEMASK_LAYER)
if(istype(wear_mask, /obj/item/clothing/mask) || istype(wear_mask, /obj/item/clothing/accessory))
if(client && hud_used && hud_used.hud_shown)
if(hud_used.inventory_shown) //if the inventory is open ...
wear_mask.screen_loc = ui_mask //...draw the item in the inventory screen
client.screen += wear_mask //Either way, add the item to the HUD
var/image/standing = wear_mask.get_standing_overlay(src, 'icons/mob/mask.dmi', SPRITE_SHEET_MASK, -FACEMASK_LAYER, "maskblood")
standing = human_update_offset(standing, TRUE)
overlays_standing[FACEMASK_LAYER] = standing
apply_overlay(FACEMASK_LAYER)
/mob/living/carbon/human/update_inv_back()
remove_overlay(BACK_LAYER)
if(back)
back.screen_loc = ui_back
if(client && hud_used && hud_used.hud_shown)
client.screen += back
var/image/standing = back.get_standing_overlay(src, 'icons/mob/back.dmi', SPRITE_SHEET_BACK, -BACK_LAYER)
standing = human_update_offset(standing, FALSE)
overlays_standing[BACK_LAYER] = standing
apply_overlay(BACK_LAYER)
/mob/living/carbon/human/update_hud() //TODO: do away with this if possible
if(client)
client.screen |= contents
if(hud_used)
hud_used.hidden_inventory_update() //Updates the screenloc of the items on the 'other' inventory bar
reload_fullscreen()
/mob/living/carbon/human/update_inv_handcuffed()
remove_overlay(HANDCUFF_LAYER)
if(handcuffed)
drop_r_hand()
drop_l_hand()
stop_pulling() //TODO: should be handled elsewhere
var/image/standing = image("icon"='icons/mob/mob.dmi', "icon_state"="handcuff1", "layer"=-HANDCUFF_LAYER)
standing = human_update_offset(standing, FALSE)
overlays_standing[HANDCUFF_LAYER] = standing
apply_overlay(HANDCUFF_LAYER)
/mob/living/carbon/human/update_inv_legcuffed()
remove_overlay(LEGCUFF_LAYER)
if(legcuffed)
set_m_intent(MOVE_INTENT_WALK)
var/image/standing = image("icon"='icons/mob/mob.dmi', "icon_state"="legcuff1", "layer"=-LEGCUFF_LAYER)
standing.appearance_flags |= KEEP_APART
overlays_standing[LEGCUFF_LAYER] = standing
apply_overlay(LEGCUFF_LAYER)
/mob/living/carbon/human/update_inv_r_hand()
remove_overlay(R_HAND_LAYER)
if(r_hand)
r_hand.screen_loc = ui_rhand
if(client && hud_used)
client.screen += r_hand
var/image/standing = r_hand.get_standing_overlay(src, r_hand.righthand_file, SPRITE_SHEET_HELD, -R_HAND_LAYER, icon_state_appendix = "_r")
standing = human_update_offset(standing, FALSE)
overlays_standing[R_HAND_LAYER] = standing
if(handcuffed)
drop_r_hand()
apply_overlay(R_HAND_LAYER)
/mob/living/carbon/human/update_inv_l_hand()
remove_overlay(L_HAND_LAYER)
if(l_hand)
l_hand.screen_loc = ui_lhand
if(client && hud_used)
client.screen += l_hand
var/t_state = l_hand.item_state
if(!t_state)
t_state = l_hand.icon_state
var/image/standing = l_hand.get_standing_overlay(src, l_hand.lefthand_file, SPRITE_SHEET_HELD, -L_HAND_LAYER, icon_state_appendix = "_l")
standing = human_update_offset(standing, FALSE)
overlays_standing[L_HAND_LAYER] = standing
if(handcuffed)
drop_l_hand()
apply_overlay(L_HAND_LAYER)
/mob/living/carbon/human/proc/update_tail_showing()
remove_overlay(TAIL_LAYER)
if((random_tail_holder || species.tail) && species.flags[HAS_TAIL] && !(HUSK in mutations) && bodyparts_by_name[BP_CHEST])
if(!wear_suit || !(wear_suit.flags_inv & HIDETAIL) && !istype(wear_suit, /obj/item/clothing/suit/space))
var/tail_state = species.tail
if(random_tail_holder)
tail_state = random_tail_holder
var/image/tail_s = image("icon" = 'icons/mob/species/tail.dmi', "icon_state" = tail_state)
var/obj/item/organ/external/chest/BP = bodyparts_by_name[BP_CHEST]
if(BP.status & ORGAN_DEAD)
tail_s.color = NECROSIS_COLOR_MOD
else if(HULK in mutations)
tail_s.color = HULK_SKIN_COLOR
else
if(species.flags[HAS_SKIN_COLOR])
tail_s.color = RGB_CONTRAST(r_skin, g_skin, b_skin)
else if(species.flags[HAS_SKIN_TONE])
tail_s.color = RGB_CONTRAST(s_tone, s_tone, s_tone)
var/image/standing = image("icon" = tail_s, "layer" = -TAIL_LAYER)
standing = human_update_offset(standing, FALSE)
overlays_standing[TAIL_LAYER] = standing
apply_overlay(TAIL_LAYER)
//Adds a collar overlay above the helmet layer if the suit has one
// Suit needs an identically named sprite in icons/mob/collar.dmi
/mob/living/carbon/human/proc/update_collar()
remove_overlay(COLLAR_LAYER)
if(wear_suit)
var/icon/C = new('icons/mob/collar.dmi')
if(wear_suit.icon_state in C.IconStates())
var/image/standing = image("icon" = C, "icon_state" = "[wear_suit.icon_state]", "layer"=-COLLAR_LAYER)
standing.color = wear_suit.color
standing = human_update_offset(standing, TRUE)
overlays_standing[COLLAR_LAYER] = standing
apply_overlay(COLLAR_LAYER)
/mob/living/carbon/human/proc/update_surgery()
remove_overlay(SURGERY_LAYER)
var/list/standing = list()
for(var/obj/item/organ/external/BP in bodyparts)
if(BP.open)
standing += image("icon" = 'icons/mob/surgery.dmi', "icon_state" = "[BP.body_zone][round(BP.open)]", "layer" = -SURGERY_LAYER)
if(standing.len)
for(var/image/I in standing)
I = update_height(I)
overlays_standing[SURGERY_LAYER] = standing
apply_overlay(SURGERY_LAYER)
/mob/living/carbon/human/proc/update_bandage()
remove_overlay(BANDAGE_LAYER)
var/list/standing = list()
for(var/obj/item/organ/external/BP in bodyparts)
BP.bandaged = FALSE
if(BP.wounds.len)
for(var/datum/wound/W in BP.wounds)
if(W.bandaged)
BP.bandaged = TRUE
standing += image("icon" = 'icons/mob/bandages.dmi', "icon_state" = "[BP.body_zone]", "layer" = -BANDAGE_LAYER)
if(standing.len)
for(var/image/I in standing)
I = update_height(I)
overlays_standing[BANDAGE_LAYER] = standing
apply_overlay(BANDAGE_LAYER)
/mob/living/carbon/human/proc/get_overlays_copy()
var/list/out = new
out = overlays_standing.Copy()
return out
//Offsetting any human's overlay that we dont want to cut.
/mob/living/carbon/human/proc/human_update_offset(image/I, head = TRUE)
var/list/L
if(head)//If your item is upper the torso - we want to shift it more.
L = list(HUMANHEIGHT_SHORTEST = -2, HUMANHEIGHT_SHORT = -1, HUMANHEIGHT_MEDIUM = 0, HUMANHEIGHT_TALL = 1, HUMANHEIGHT_TALLEST = 2, "gnome" = -5)
else
L = list(HUMANHEIGHT_SHORTEST = -1, HUMANHEIGHT_SHORT = -1, HUMANHEIGHT_MEDIUM = 0, HUMANHEIGHT_TALL = 1, HUMANHEIGHT_TALLEST = 1, "gnome" = -3)
I.pixel_y = L[height]
if(SMALLSIZE in mutations) //Gnome-Guy
I.pixel_y += L["gnome"]
return I
//Cutting any human's overlay that we dont want to offset.
/mob/living/carbon/human/proc/update_height(image/I)
var/static/icon/cut_torso_mask = icon('icons/effects/cut.dmi',"Cut1")
var/static/icon/cut_legs_mask = icon('icons/effects/cut.dmi',"Cut2")
var/static/icon/lenghten_torso_mask = icon('icons/effects/cut.dmi',"Cut3")
var/static/icon/lenghten_legs_mask = icon('icons/effects/cut.dmi',"Cut4")
I.remove_filter(list("Cut_Torso","Cut_Legs","Lenghten_Legs","Lenghten_Torso","Gnome_Cut_Torso","Gnome_Cut_Legs"))
switch(height)
if(HUMANHEIGHT_SHORTEST)
I.add_filter("Cut_Torso", 1, displacement_map_filter(cut_torso_mask, x = 0, y = 0, size = 1))
I.add_filter("Cut_Legs", 1, displacement_map_filter(cut_legs_mask, x = 0, y = 0, size = 1))
if(HUMANHEIGHT_SHORT)
I.add_filter("Cut_Legs", 1, displacement_map_filter(cut_legs_mask, x = 0, y = 0, size = 1))
if(HUMANHEIGHT_TALL)
I.add_filter("Lenghten_Legs", 1, displacement_map_filter(lenghten_legs_mask, x = 0, y = 0, size = 1))
if(HUMANHEIGHT_TALLEST)
I.add_filter("Lenghten_Torso", 1, displacement_map_filter(lenghten_torso_mask, x = 0, y = 0, size = 1))
I.add_filter("Lenghten_Legs", 1, displacement_map_filter(lenghten_legs_mask, x = 0, y = 0, size = 1))
if(SMALLSIZE in mutations)
I.add_filter("Gnome_Cut_Torso", 1, displacement_map_filter(cut_torso_mask, x = 0, y = 0, size = 2))
I.add_filter("Gnome_Cut_Legs", 1, displacement_map_filter(cut_legs_mask, x = 0, y = 0, size = 3))
return I
//Human Overlays Indexes/////////
#undef FIRE_LOWER_LAYER
#undef BODY_LAYER
#undef MUTATIONS_LAYER
#undef DAMAGE_LAYER
#undef SURGERY_LAYER
#undef BANDAGE_LAYER
#undef UNIFORM_LAYER
#undef ID_LAYER
#undef SHOES_LAYER
#undef TAIL_LAYER
#undef GLOVES_LAYER
#undef EARS_LAYER
#undef SUIT_LAYER
#undef GLASSES_LAYER
#undef BELT_LAYER
#undef SUIT_STORE_LAYER
#undef BACK_LAYER
#undef HAIR_LAYER
#undef FACEMASK_LAYER
#undef HEAD_LAYER
#undef COLLAR_LAYER
#undef HANDCUFF_LAYER
#undef LEGCUFF_LAYER
#undef L_HAND_LAYER
#undef R_HAND_LAYER
#undef FIRE_UPPER_LAYER
#undef TARGETED_LAYER
#undef TOTAL_LAYERS