-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathsignaler.dm
314 lines (265 loc) · 10.1 KB
/
signaler.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
/obj/item/assembly/signaler
name = "remote signaling device"
desc = "Used to remotely activate devices. Allows for syncing when using a secure signaler on another."
icon_state = "signaller"
item_state = "signaler"
lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi'
righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi'
materials = list(/datum/material/iron=400, /datum/material/glass=120)
wires = WIRE_RECEIVE | WIRE_PULSE | WIRE_RADIO_PULSE | WIRE_RADIO_RECEIVE
attachable = TRUE
var/code = DEFAULT_SIGNALER_CODE
var/frequency = FREQ_SIGNALER
var/delay = 0
var/datum/radio_frequency/radio_connection
var/suicider = null
var/hearing_range = 1
/obj/item/assembly/signaler/suicide_act(mob/living/carbon/user)
user.visible_message(span_suicide("[user] eats \the [src]! If it is signaled, [user.p_they()] will die!"))
playsound(src, 'sound/items/eatfood.ogg', 50, TRUE)
user.transferItemToLoc(src, user, TRUE)
suicider = user
return MANUAL_SUICIDE_NONLETHAL
/obj/item/assembly/signaler/proc/manual_suicide(mob/living/carbon/user)
user.visible_message(span_suicide("[user]'s [src] receives a signal, killing [user.p_them()] instantly!"))
user.adjustOxyLoss(200)//it sends an electrical pulse to their heart, killing them. or something.
user.death(0)
user.set_suicide(TRUE)
user.suicide_log()
/obj/item/assembly/signaler/Initialize(mapload)
. = ..()
set_frequency(frequency)
update_appearance(UPDATE_ICON)
/obj/item/assembly/signaler/Destroy()
SSradio.remove_object(src,frequency)
. = ..()
/obj/item/assembly/signaler/activate()
if(!..())//cooldown processing
return FALSE
signal()
return TRUE
/obj/item/assembly/signaler/update_icon(updates=ALL)
. = ..()
if(holder)
holder.update_icon(updates)
/obj/item/assembly/signaler/ui_status(mob/user)
if(is_secured(user))
return ..()
return UI_CLOSE
/obj/item/assembly/signaler/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Signaler", name)
ui.open()
/obj/item/assembly/signaler/ui_data(mob/user)
var/list/data = list()
data["frequency"] = frequency
data["code"] = code
data["minFrequency"] = MIN_FREE_FREQ
data["maxFrequency"] = MAX_FREE_FREQ
data["color"] = label_color
return data
/obj/item/assembly/signaler/ui_act(action, params)
if(..())
return
switch(action)
if("signal")
if(TIMER_COOLDOWN_CHECK(src, COOLDOWN_SIGNALLER_SEND))
to_chat(usr, span_warning("[src] is still recharging..."))
return
TIMER_COOLDOWN_START(src, COOLDOWN_SIGNALLER_SEND, 1 SECONDS)
INVOKE_ASYNC(src, PROC_REF(signal))
. = TRUE
if("freq")
frequency = unformat_frequency(params["freq"])
frequency = sanitize_frequency(frequency, TRUE)
set_frequency(frequency)
. = TRUE
if("code")
code = text2num(params["code"])
code = round(code)
. = TRUE
if("reset")
if(params["reset"] == "freq")
frequency = initial(frequency)
else
code = initial(code)
. = TRUE
if("color")
var/idx = label_colors.Find(label_color)
if(idx == label_colors.len || idx == 0)
idx = 1
else
idx++
label_color = label_colors[idx]
update_appearance(UPDATE_ICON)
update_appearance(UPDATE_ICON)
/obj/item/assembly/signaler/attackby(obj/item/W, mob/user, params)
if(issignaler(W))
var/obj/item/assembly/signaler/signaler2 = W
if(secured && signaler2.secured)
code = signaler2.code
set_frequency(signaler2.frequency)
// yogs start - signaller colors
label_color = signaler2.label_color
update_appearance(UPDATE_ICON)
// yogs end
to_chat(user, "You transfer the frequency and code of \the [signaler2.name] to \the [name]")
..()
/obj/item/assembly/signaler/proc/signal()
if(!radio_connection)
return
var/datum/signal/signal = new(list("code" = code))
radio_connection.post_signal(src, signal)
var/time = time2text(world.realtime,"hh:mm:ss")
var/turf/T = get_turf(src)
if(usr && T)
GLOB.lastsignalers.Add("[time] <B>:</B> [usr.key] used [src] @ location ([T.x],[T.y],[T.z]) <B>:</B> [format_frequency(frequency)]/[code]")
/obj/item/assembly/signaler/receive_signal(datum/signal/signal)
. = FALSE
if(!signal)
return
if(signal.data["code"] != code)
return
if(!(src.wires & WIRE_RADIO_RECEIVE))
return
if(suicider)
manual_suicide(suicider)
pulse(TRUE)
audible_message("[icon2html(src, hearers(src))] *beep* *beep* *beep*", null, hearing_range)
for(var/CHM in get_hearers_in_view(hearing_range, src))
if(ismob(CHM))
var/mob/LM = CHM
LM.playsound_local(get_turf(src), 'sound/machines/triple_beep.ogg', ASSEMBLY_BEEP_VOLUME, TRUE)
return TRUE
/obj/item/assembly/signaler/proc/set_frequency(new_frequency)
SSradio.remove_object(src, frequency)
frequency = new_frequency
radio_connection = SSradio.add_object(src, frequency, RADIO_SIGNALER)
return
// Embedded signaller used in grenade construction.
// It's necessary because the signaler doens't have an off state.
// Generated during grenade construction. -Sayu
/obj/item/assembly/signaler/receiver
var/on = FALSE
/obj/item/assembly/signaler/receiver/proc/toggle_safety()
on = !on
/obj/item/assembly/signaler/receiver/activate()
toggle_safety()
return TRUE
/obj/item/assembly/signaler/receiver/examine(mob/user)
. = ..()
. += span_notice("The radio receiver is [on?"on":"off"].")
/obj/item/assembly/signaler/receiver/receive_signal(datum/signal/signal)
if(!on)
return
return ..(signal)
// Embedded signaller used in anomalies.
/obj/item/assembly/signaler/anomaly
name = "anomaly core"
desc = "The neutralized core of an anomaly. It'd probably be valuable for research."
icon_state = "anomaly_core"
item_state = "electronic"
lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi'
righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi'
resistance_flags = FIRE_PROOF
var/anomaly_type = /obj/effect/anomaly
/obj/item/assembly/signaler/anomaly/receive_signal(datum/signal/signal)
if(!signal)
return FALSE
if(signal.data["code"] != code)
return FALSE
if(suicider)
manual_suicide(suicider)
for(var/obj/effect/anomaly/A in get_turf(src))
A.anomalyNeutralize()
return TRUE
/obj/item/assembly/signaler/anomaly/manual_suicide(mob/living/carbon/user)
user.visible_message(span_suicide("[user]'s [src] is reacting to the radio signal, warping [user.p_their()] body!"))
user.set_suicide(TRUE)
user.suicide_log()
user.gib()
/obj/item/assembly/signaler/anomaly/attackby(obj/item/I, mob/user, params)
if(I.tool_behaviour == TOOL_ANALYZER)
to_chat(user, span_notice("Analyzing... [src]'s stabilized field is fluctuating along frequency [format_frequency(frequency)], code [code]."))
..()
/obj/item/assembly/signaler/anomaly/attack_self()
return
//Anomaly cores
/obj/item/assembly/signaler/anomaly/pyro
name = "\improper pyroclastic anomaly core"
desc = "The neutralized core of a pyroclastic anomaly. It feels warm to the touch. It'd probably be valuable for research."
anomaly_type = /obj/effect/anomaly/pyro
/obj/item/assembly/signaler/anomaly/grav
name = "\improper gravitational anomaly core"
desc = "The neutralized core of a gravitational anomaly. It feels much heavier than it looks. It'd probably be valuable for research."
anomaly_type = /obj/effect/anomaly/grav
/obj/item/assembly/signaler/anomaly/flux
name = "\improper flux anomaly core"
desc = "The neutralized core of a flux anomaly. Touching it makes your skin tingle. It'd probably be valuable for research."
anomaly_type = /obj/effect/anomaly/flux
/obj/item/assembly/signaler/anomaly/bluespace
name = "\improper bluespace anomaly core"
desc = "The neutralized core of a bluespace anomaly. It keeps phasing in and out of view. It'd probably be valuable for research."
anomaly_type = /obj/effect/anomaly/bluespace
/obj/item/assembly/signaler/anomaly/vortex
name = "\improper vortex anomaly core"
desc = "The neutralized core of a vortex anomaly. It won't sit still, as if some invisible force is acting on it. It'd probably be valuable for research."
anomaly_type = /obj/effect/anomaly/bhole
/obj/item/assembly/signaler/anomaly/hallucination
name = "\improper hallucination anomaly core"
desc = "The neutralized core of a hallucination anomaly. It seems to be moving, but it's probably your imagination. It'd probably be valuable for research."
icon_state = "hallucination_core"
anomaly_type = /obj/effect/anomaly/hallucination
/obj/item/assembly/signaler/anomaly/radiation
name = "\improper radiation anomaly core"
desc = "The neutralized core of a radiation anomaly. It keeps pulsing an ominous green. It'd probably be valuable for research."
icon_state = "radiation_core"
anomaly_type = /obj/effect/anomaly/radiation
/obj/item/assembly/signaler/cyborg
/obj/item/assembly/signaler/cyborg/attackby(obj/item/W, mob/user, params)
return
/obj/item/assembly/signaler/cyborg/screwdriver_act(mob/living/user, obj/item/I)
return
/obj/item/assembly/signaler/internal
name = "internal remote signaling device"
/obj/item/assembly/signaler/internal/ui_state(mob/user)
return GLOB.inventory_state
/obj/item/assembly/signaler/internal/attackby(obj/item/W, mob/user, params)
return
/obj/item/assembly/signaler/internal/screwdriver_act(mob/living/user, obj/item/I)
return
/obj/item/assembly/signaler/internal/can_interact(mob/user)
if(ispAI(user))
return TRUE
. = ..()
/**
* Button signaler
*
* Activated by attack_self instead of UI
*
* UI is instead opened by multitool
*/
/obj/item/assembly/signaler/button
name = "remote signaling button"
desc = "A modern design of the remote signaling device, for when you need to signal NOW. Configured via multitool. Cannot receive signals."
icon = 'icons/obj/assemblies/new_assemblies.dmi'
icon_state = "radio"
item_state = "radio"
/obj/item/assembly/signaler/button/attack_self(mob/user, modifiers)
if(HAS_TRAIT(user, TRAIT_NOINTERACT))
to_chat(user, span_notice("You can't use things!"))
return
if(SEND_SIGNAL(src, COMSIG_ITEM_ATTACK_SELF, user, modifiers) & COMPONENT_NO_INTERACT)
return
if(!user)
return FALSE
activate()
pulse()
return TRUE
/obj/item/assembly/signaler/button/multitool_act(mob/living/user, obj/item/I)
. = ..()
user.set_machine(src)
interact(user)
/obj/item/assembly/signaler/button/receive_signal(datum/signal/signal)
return