/
_head.dm
76 lines (69 loc) · 3.36 KB
/
_head.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
/obj/item/clothing/head
name = BODY_ZONE_HEAD
icon = 'icons/obj/clothing/hats.dmi'
icon_state = "tophat"
inhand_icon_state = "that"
body_parts_covered = HEAD
slot_flags = ITEM_SLOT_HEAD
var/blockTracking = 0 //For AI tracking
var/can_toggle = null
dynamic_hair_suffix = "+generic"
/obj/item/clothing/head/Initialize()
. = ..()
if(ishuman(loc) && dynamic_hair_suffix)
var/mob/living/carbon/human/H = loc
H.update_hair()
///Special throw_impact for hats to frisbee hats at people to place them on their heads/attempt to de-hat them.
/obj/item/clothing/head/throw_impact(atom/hit_atom, datum/thrownthing/thrownthing)
. = ..()
///if the thrown object's target zone isn't the head
if(thrownthing.target_zone != BODY_ZONE_HEAD)
return
///ignore any hats with the tinfoil counter-measure enabled
if(clothing_flags & ANTI_TINFOIL_MANEUVER)
return
///if the hat happens to be capable of holding contents and has something in it. mostly to prevent super cheesy stuff like stuffing a mini-bomb in a hat and throwing it
if(LAZYLEN(contents))
return
if(iscarbon(hit_atom))
var/mob/living/carbon/H = hit_atom
if(istype(H.head, /obj/item))
var/obj/item/WH = H.head
///check if the item has NODROP
if(HAS_TRAIT(WH, TRAIT_NODROP))
H.visible_message("<span class='warning'>[src] bounces off [H]'s [WH.name]!</span>", "<span class='warning'>[src] bounces off your [WH.name], falling to the floor.</span>")
return
///check if the item is an actual clothing head item, since some non-clothing items can be worn
if(istype(WH, /obj/item/clothing/head))
var/obj/item/clothing/head/WHH = WH
///SNUG_FIT hats are immune to being knocked off
if(WHH.clothing_flags & SNUG_FIT)
H.visible_message("<span class='warning'>[src] bounces off [H]'s [WHH.name]!</span>", "<span class='warning'>[src] bounces off your [WHH.name], falling to the floor.</span>")
return
///if the hat manages to knock something off
if(H.dropItemToGround(WH))
H.visible_message("<span class='warning'>[src] knocks [WH] off [H]'s head!</span>", "<span class='warning'>[WH] is suddenly knocked off your head by [src]!</span>")
if(H.equip_to_slot_if_possible(src, ITEM_SLOT_HEAD, 0, 1, 1))
H.visible_message("<span class='notice'>[src] lands neatly on [H]'s head!</span>", "<span class='notice'>[src] lands perfectly onto your head!</span>")
return
if(iscyborg(hit_atom))
var/mob/living/silicon/robot/R = hit_atom
///hats in the borg's blacklist bounce off
if(is_type_in_typecache(src, GLOB.blacklisted_borg_hats))
R.visible_message("<span class='warning'>[src] bounces off [R]!</span>", "<span class='warning'>[src] bounces off you, falling to the floor.</span>")
return
else
R.visible_message("<span class='notice'>[src] lands neatly on top of [R]!</span>", "<span class='notice'>[src] lands perfectly on top of you.</span>")
R.place_on_head(src) //hats aren't designed to snugly fit borg heads or w/e so they'll always manage to knock eachother off
/obj/item/clothing/head/worn_overlays(isinhands = FALSE)
. = list()
if(!isinhands)
if(damaged_clothes)
. += mutable_appearance('icons/effects/item_damage.dmi', "damagedhelmet")
if(HAS_BLOOD_DNA(src))
. += mutable_appearance('icons/effects/blood.dmi', "helmetblood")
/obj/item/clothing/head/update_clothes_damaged_state(damaged_state = CLOTHING_DAMAGED)
..()
if(ismob(loc))
var/mob/M = loc
M.update_inv_head()