/
flash.dm
233 lines (206 loc) · 6.82 KB
/
flash.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
/obj/item/device/flash
name = "flash"
desc = "A device that produces a bright flash of light, designed to stun and disorient an attacker."
icon = 'icons/obj/tools/flash.dmi'
icon_state = "flash"
item_state = "flashtool"
throwforce = 5
w_class = ITEM_SIZE_SMALL
throw_speed = 4
throw_range = 10
obj_flags = OBJ_FLAG_CONDUCTIBLE
origin_tech = list(TECH_MAGNET = 2, TECH_COMBAT = 1)
var/times_used = 0 //Number of times it's been used.
var/broken = 0 //Is the flash burnt out?
var/last_used = 0 //last world.time it was used.
var/str_min = 2 //how weak the effect CAN be
var/str_max = 7 //how powerful the effect COULD be
/obj/item/device/flash/proc/clown_check(mob/user)
if(user && (MUTATION_CLUMSY in user.mutations) && prob(50))
to_chat(user, SPAN_WARNING("\The [src] slips out of your hand."))
user.unequip_item()
return 0
return 1
/obj/item/device/flash/proc/flash_recharge()
//capacitor recharges over time
for(var/i=0, i<3, i++)
if(last_used+600 > world.time)
break
last_used += 600
times_used -= 2
last_used = world.time
times_used = max(0,round(times_used)) //sanity
//attack_as_weapon
/obj/item/device/flash/use_before(mob/living/M, mob/living/user)
. = FALSE
if (!istype(M))
return FALSE
if (!clown_check(user))
return TRUE
if (broken)
to_chat(user, SPAN_WARNING("\The [src] is broken."))
return TRUE
flash_recharge()
//spamming the flash before it's fully charged (60seconds) increases the chance of it breaking
//It will never break on the first use.
switch (times_used)
if (0 to 5)
last_used = world.time
if (prob(times_used)) //if you use it 5 times in a minute it has a 10% chance to break!
broken = 1
to_chat(user, SPAN_WARNING("The bulb has burnt out!"))
icon_state = "[initial(icon_state)]_burnt"
return TRUE
times_used++
else //can only use it 5 times a minute
to_chat(user, SPAN_WARNING("*click* *click*"))
return TRUE
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
user.do_attack_animation(M)
admin_attack_log(user, M, "flashed their victim using \a [src].", "Was flashed by \a [src].", "used \a [src] to flash")
playsound(src.loc, 'sound/weapons/flash.ogg', 100, 1)
var/flashfail = do_flash(M)
if (isrobot(user))
spawn(0)
var/atom/movable/fake_overlay/animation = new(user)
animation.plane = user.plane
animation.layer = user.layer + 0.01
animation.icon_state = "blank"
animation.icon = 'icons/mob/mob.dmi'
flick("blspell", animation)
sleep(5)
qdel(animation)
if (!flashfail)
flick("[initial(icon_state)]_on", src)
if (!issilicon(M))
user.visible_message(SPAN_CLASS("disarm", "[user] blinds [M] with \the [src]!"))
else
user.visible_message(SPAN_NOTICE("[user] overloads [M]'s sensors with \the [src]!"))
else
user.visible_message(SPAN_NOTICE("[user] fails to blind [M] with \the [src]!"))
return TRUE
/**
* Handles applying flash effects to the targeted mob.
*
* **Parameters**:
* - `M` - The targeted mob to apply the flash effects to.
*
* Returns boolean. Whether or not the flash failed.
*/
/obj/item/device/flash/proc/do_flash(mob/living/M)
var/flash_strength = (rand(str_min,str_max))
if(iscarbon(M))
if(M.stat!=DEAD)
var/mob/living/carbon/C = M
var/safety = C.eyecheck()
if(safety < FLASH_PROTECTION_MODERATE)
if(ishuman(M))
var/mob/living/carbon/human/H = M
flash_strength = round(H.getFlashMod() * flash_strength)
if(safety > FLASH_PROTECTION_NONE)
flash_strength = (flash_strength / 2)
if(flash_strength > 0)
M.flash_eyes(FLASH_PROTECTION_MODERATE - safety)
M.Stun(flash_strength / 2)
M.eye_blurry = max(M.eye_blurry, flash_strength)
M.set_confused(flash_strength + 2)
if(flash_strength > 3)
M.drop_l_hand()
M.drop_r_hand()
if(flash_strength > 5)
M.Weaken(2)
else
return TRUE
else if(isanimal(M))
var/mob/living/simple_animal/SA = M
var/safety = SA.eyecheck()
if(safety < FLASH_PROTECTION_MAJOR)
SA.set_confused(flash_strength * 0.5)
if(safety < FLASH_PROTECTION_MODERATE)
SA.flash_eyes(2)
SA.eye_blurry = max(SA.eye_blurry, flash_strength)
SA.set_confused(flash_strength)
else
return TRUE
else if(issilicon(M))
if (M.status_flags & CANWEAKEN)
M.Weaken(rand(str_min,6))
else
return TRUE
else
return TRUE
return FALSE
/obj/item/device/flash/attack_self(mob/living/carbon/user as mob, flag = 0, emp = 0)
if(!user || !clown_check(user)) return 0
if(broken)
user.show_message(SPAN_WARNING("The [src.name] is broken"), 2)
return 0
flash_recharge()
//spamming the flash before it's fully charged (60seconds) increases the chance of it breaking
//It will never break on the first use.
switch(times_used)
if(0 to 5)
if(prob(2*times_used)) //if you use it 5 times in a minute it has a 10% chance to break!
broken = 1
to_chat(user, SPAN_WARNING("The bulb has burnt out!"))
icon_state = "[initial(icon_state)]_burnt"
return 0
times_used++
else //can only use it 5 times a minute
user.show_message(SPAN_WARNING("*click* *click*"), 2)
return 0
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
playsound(src.loc, 'sound/weapons/flash.ogg', 100, 1)
flick("[initial(icon_state)]_on", src)
if(user && isrobot(user))
spawn(0)
var/atom/movable/fake_overlay/animation = new(user.loc)
animation.plane = user.plane
animation.layer = user.layer + 0.01
animation.icon_state = "blank"
animation.icon = 'icons/mob/mob.dmi'
animation.master = user
flick("blspell", animation)
sleep(5)
qdel(animation)
for(var/mob/living/carbon/M in oviewers(3, null))
var/safety = M.eyecheck()
if(safety < FLASH_PROTECTION_MODERATE)
if(!M.blinded)
M.flash_eyes()
M.eye_blurry += 2
return 1
/obj/item/device/flash/emp_act(severity)
if(broken) return
flash_recharge()
switch(times_used)
if(0 to 5)
if(prob(2*times_used))
broken = 1
icon_state = "[initial(icon_state)]_burnt"
return
times_used++
if(istype(loc, /mob/living/carbon))
var/mob/living/carbon/M = loc
var/safety = M.eyecheck()
if(safety < FLASH_PROTECTION_MODERATE)
M.Weaken(10)
M.flash_eyes()
for(var/mob/O in viewers(M, null))
O.show_message(SPAN_CLASS("disarm", "[M] is blinded by the [name]!"))
..()
/obj/item/device/flash/synthetic //not for regular use, weaker effects
name = "modified flash"
desc = "A device that produces a bright flash of light. This is a specialized version designed specifically for use in camera systems."
icon = 'icons/obj/tools/flash_synthetic.dmi'
icon_state = "sflash"
str_min = 1
str_max = 4
/obj/item/device/flash/advanced
name = "advanced flash"
desc = "A device that produces a very bright flash of light. This is an advanced and expensive version often issued to VIPs."
icon = 'icons/obj/tools/flash_advanced.dmi'
icon_state = "advflash"
origin_tech = list(TECH_COMBAT = 2, TECH_MAGNET = 2)
str_min = 3
str_max = 8