-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathhot_potato.dm
175 lines (157 loc) · 6.52 KB
/
hot_potato.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
//CREATOR'S NOTE: DO NOT FUCKING GIVE THIS TO BOTANY!
/obj/item/hot_potato
name = "hot potato"
desc = "A label on the side of this potato reads \"Product of DonkCo Service Wing. Activate far away from populated areas. Device will only attach to sapient creatures.\" <span class='boldnotice'>You can attack anyone with it to force it on them instead of yourself!</span>"
icon = 'icons/obj/hydroponics/harvest.dmi'
icon_state = "potato"
item_flags = NOBLUDGEON
force = 0
/// How long you can hold it before you detontae
var/timer = 10 SECONDS
/// Show timer to user
var/show_timer = TRUE
/// Is it droppable
var/sticky = TRUE
/// Will it rip an item out of their hand to put it on?
var/forceful_attachment = TRUE
/// Will it prevent stuns
var/stimulant = TRUE
/// Will it explode
var/detonate_explosion = TRUE
var/detonate_dev_range = 1
var/detonate_heavy_range = 2
var/detonate_light_range = 3
var/detonate_flash_range = 5
var/detonate_fire_range = 5
/// Is it primed
var/active = FALSE
var/color_val = FALSE
var/datum/weakref/current
/obj/item/hot_potato/Destroy()
if(active)
deactivate()
return ..()
/obj/item/hot_potato/proc/colorize(mob/target)
//Clear color from old target
if(current)
var/mob/M = current.resolve()
if(istype(M))
M.remove_atom_colour(FIXED_COLOUR_PRIORITY)
//Give to new target
current = null
//Swap colors
color_val = !color_val
if(istype(target))
current = WEAKREF(target)
target.add_atom_colour(color_val? "#ff0000" : "#ffff00", FIXED_COLOUR_PRIORITY)
/obj/item/hot_potato/proc/detonate()
var/atom/location = loc
location.visible_message(span_userdanger("[src] [detonate_explosion? "explodes" : "activates"]!"), span_userdanger("[src] activates! You've ran out of time!"))
if(detonate_explosion)
explosion(src, detonate_dev_range, detonate_heavy_range, detonate_light_range, detonate_flash_range, flame_range = detonate_fire_range)
qdel(src)
deactivate()
var/mob/M = loc
if(istype(M))
M.dropItemToGround(src, TRUE)
/obj/item/hot_potato/attack_self(mob/user)
if(activate(timer, user))
user.visible_message(span_boldwarning("[user] squeezes [src], which promptly starts to flash red-hot colors!"), span_boldwarning("You squeeze [src], activating its countdown and attachment mechanism!"),
span_boldwarning("You hear a mechanical click and a loud beeping!"))
return
return ..()
/obj/item/hot_potato/process()
if(timer <= 0)
detonate() // Bye Bye
timer -= 1 // SSfastprocessing
if(isliving(loc))
var/mob/living/L = loc
if(stimulant)
L.SetStun(0)
L.SetKnockdown(0)
L.SetSleeping(0)
L.SetImmobilized(0)
L.SetParalyzed(0)
L.SetUnconscious(0)
L.reagents.add_reagent(/datum/reagent/medicine/muscle_stimulant, clamp(5 - L.reagents.get_reagent_amount(/datum/reagent/medicine/muscle_stimulant), 0, 5)) //If you don't have legs or get bola'd, tough luck!
colorize(L)
/obj/item/hot_potato/examine(mob/user)
. = ..()
if(active)
. += span_warning("[src] is flashing red-hot! You should probably get rid of it!")
if(show_timer)
. += span_warning("[src]'s timer looks to be at [DisplayTimeText(timer)]!")
/obj/item/hot_potato/equipped(mob/user)
. = ..()
if(active)
to_chat(user, span_userdanger("You have a really bad feeling about [src]!"))
/obj/item/hot_potato/afterattack(atom/target, mob/user, adjacent, params)
. = ..()
if(!adjacent || !ismob(target))
return
force_onto(target, user)
/obj/item/hot_potato/proc/force_onto(mob/living/victim, mob/user)
timer = initial(timer)
if(!istype(victim) || user != loc || victim == user)
return FALSE
if(!victim.client)
to_chat(user, span_boldwarning("[src] refuses to attach to a non-sapient creature!"))
if(victim.stat != CONSCIOUS || !victim.get_num_legs())
to_chat(user, span_boldwarning("[src] refuses to attach to someone incapable of using it!"))
user.temporarilyRemoveItemFromInventory(src, TRUE)
. = FALSE
if(!victim.put_in_hands(src))
if(forceful_attachment)
victim.dropItemToGround(victim.get_inactive_held_item())
if(!victim.put_in_hands(src))
victim.dropItemToGround(victim.get_active_held_item())
if(victim.put_in_hands(src))
. = TRUE
else
. = TRUE
else
. = TRUE
if(.)
log_combat(user, victim, "forced a hot potato with explosive variables ([detonate_explosion]-[detonate_dev_range]/[detonate_heavy_range]/[detonate_light_range]/[detonate_flash_range]/[detonate_fire_range]) onto")
user.visible_message(span_userdanger("[user] forces [src] onto [victim]!"), span_userdanger("You force [src] onto [victim]!"), span_boldwarning("You hear a mechanical click and a beep."))
colorize(null)
else
log_combat(user, victim, "tried to force a hot potato with explosive variables ([detonate_explosion]-[detonate_dev_range]/[detonate_heavy_range]/[detonate_light_range]/[detonate_flash_range]/[detonate_fire_range]) onto")
user.visible_message(span_boldwarning("[user] tried to force [src] onto [victim], but it could not attach!"), span_boldwarning("You try to force [src] onto [victim], but it is unable to attach!"), span_boldwarning("You hear a mechanical click and two buzzes."))
user.put_in_hands(src)
/obj/item/hot_potato/dropped(mob/user)
. = ..()
colorize(null)
/obj/item/hot_potato/proc/activate(delay, mob/user)
if(active)
return
update_appearance(UPDATE_ICON)
if(sticky)
ADD_TRAIT(src, TRAIT_NODROP, HOT_POTATO_TRAIT)
name = "primed [name]"
START_PROCESSING(SSfastprocess, src)
if(user)
log_bomber(user, "has primed a", src, "for detonation (Timer:[delay],Explosive:[detonate_explosion],Range:[detonate_dev_range]/[detonate_heavy_range]/[detonate_light_range]/[detonate_fire_range])")
else
log_bomber(null, null, src, "was primed for detonation (Timer:[delay],Explosive:[detonate_explosion],Range:[detonate_dev_range]/[detonate_heavy_range]/[detonate_light_range]/[detonate_fire_range])")
active = TRUE
/obj/item/hot_potato/proc/deactivate()
update_appearance(UPDATE_ICON)
name = initial(name)
REMOVE_TRAIT(src, TRAIT_NODROP, HOT_POTATO_TRAIT)
STOP_PROCESSING(SSfastprocess, src)
colorize(null)
active = FALSE
/obj/item/hot_potato/update_icon_state()
. = ..()
icon_state = "[initial(icon_state)]" + "[active ? "_active" : ""]"
/obj/item/hot_potato/syndicate
detonate_light_range = 4
detonate_fire_range = 5
/obj/item/hot_potato/harmless
stimulant = FALSE
detonate_explosion = FALSE
/obj/item/hot_potato/harmless/toy
desc = "A label on the side of this potato reads \"Product of DonkCo Toys and Recreation department.\" <span class='boldnotice'>You can attack anyone with it to put it on them instead, if they have a free hand to take it!</span>"
sticky = FALSE
forceful_attachment = FALSE