-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathcamera_advanced.dm
451 lines (389 loc) · 15.4 KB
/
camera_advanced.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
/obj/machinery/computer/camera_advanced
name = "advanced camera console"
desc = "Used to access the various cameras on the station."
icon_screen = "cameras"
icon_keyboard = "security_key"
light_color = COLOR_SOFT_RED
var/list/z_lock = list() // Lock use to these z levels
var/lock_override = NONE
var/mob/camera/ai_eye/remote/eyeobj
var/mob/living/current_user = null
var/list/networks = list("ss13")
/// Typepath of the action button we use as "off"
/// It's a typepath so subtypes can give it fun new names
var/datum/action/innate/camera_off/off_action = /datum/action/innate/camera_off
/// Typepath for jumping
var/datum/action/innate/camera_jump/jump_action = /datum/action/innate/camera_jump
/// Typepath of the move up action
var/datum/action/innate/camera_multiz_up/move_up_action = /datum/action/innate/camera_multiz_up
/// Typepath of the move down action
var/datum/action/innate/camera_multiz_down/move_down_action = /datum/action/innate/camera_multiz_down
/// List of all actions to give to a user when they're well, granted actions
var/list/actions = list()
var/datum/cameranet/camnet //the net it's looking at
///Should we supress any view changes?
var/should_supress_view_changes = TRUE
interaction_flags_machine = INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_REQUIRES_SIGHT
/obj/machinery/computer/camera_advanced/Initialize(mapload)
. = ..()
for(var/i in networks)
networks -= i
networks += lowertext(i)
if(lock_override)
if(lock_override & CAMERA_LOCK_STATION)
z_lock |= SSmapping.levels_by_trait(ZTRAIT_STATION)
if(lock_override & CAMERA_LOCK_MINING)
z_lock |= SSmapping.levels_by_trait(ZTRAIT_MINING)
if(lock_override & CAMERA_LOCK_CENTCOM)
z_lock |= SSmapping.levels_by_trait(ZTRAIT_CENTCOM)
if(off_action)
actions += new off_action(src)
if(jump_action)
actions += new jump_action(src)
//Camera action button to move up a Z level
if(move_up_action)
actions += new move_up_action(src)
//Camera action button to move down a Z level
if(move_down_action)
actions += new move_down_action(src)
camnet = GLOB.cameranet //the default cameranet
/obj/machinery/computer/camera_advanced/connect_to_shuttle(mapload, obj/docking_port/mobile/port, obj/docking_port/stationary/dock)
for(var/i in networks)
networks -= i
networks += "[port.shuttle_id]_[i]"
/obj/machinery/computer/camera_advanced/syndie
icon_keyboard = "syndie_key"
/obj/machinery/computer/camera_advanced/syndie/connect_to_shuttle(mapload, obj/docking_port/mobile/port, obj/docking_port/stationary/dock)
return //For syndie nuke shuttle, to spy for station.
/obj/machinery/computer/camera_advanced/proc/CreateEye()
eyeobj = new()
eyeobj.origin = src
eyeobj.networks = networks
/obj/machinery/computer/camera_advanced/proc/GrantActions(mob/living/user)
for(var/datum/action/to_grant as anything in actions)
to_grant.Grant(user)
/obj/machinery/proc/remove_eye_control(mob/living/user)
CRASH("[type] does not implement ai eye handling")
/obj/machinery/computer/camera_advanced/remove_eye_control(mob/living/user)
if(isnull(user?.client))
return
for(var/datum/action/actions_removed as anything in actions)
actions_removed.Remove(user)
for(var/datum/camerachunk/camerachunks_gone as anything in eyeobj.visibleCameraChunks)
camerachunks_gone.remove(eyeobj)
user.reset_perspective(null)
if(eyeobj.visible_icon)
user.client.images -= eyeobj.user_image
user.client.view_size.unsupress()
eyeobj.eye_user = null
user.remote_control = null
current_user = null
unset_machine(user)
playsound(src, 'sound/machines/terminal_off.ogg', 25, FALSE)
/obj/machinery/computer/camera_advanced/check_eye(mob/user)
if(!can_use(user) || (issilicon(user) && !user.has_unlimited_silicon_privilege))
unset_machine(user)
/obj/machinery/computer/camera_advanced/Destroy()
if(eyeobj)
QDEL_NULL(eyeobj)
QDEL_LIST(actions)
current_user = null
return ..()
/obj/machinery/computer/camera_advanced/proc/unset_machine(mob/M)
if(M == current_user)
remove_eye_control(M)
/obj/machinery/computer/camera_advanced/proc/can_use(mob/living/user)
return can_interact(user)
/obj/machinery/computer/camera_advanced/abductor/can_use(mob/user)
if(!isabductor(user))
return FALSE
return ..()
/obj/machinery/computer/camera_advanced/attack_hand(mob/user, list/modifiers)
. = ..()
if(.)
return
if(!can_use(user))
return
if(isnull(user.client))
return
if(current_user)
to_chat(user, span_warning("The console is already in use!"))
return
var/mob/living/L = user
if(!eyeobj)
CreateEye()
if(!eyeobj) //Eye creation failed
return
if(!eyeobj.eye_initialized)
var/camera_location
var/turf/myturf = get_turf(src)
if(eyeobj.use_static != FALSE)
if((!length(z_lock) || (myturf.z in z_lock)) && camnet.checkTurfVis(myturf))
camera_location = myturf
else
for(var/obj/machinery/camera/C as anything in camnet.cameras)
if(!C.can_use() || length(z_lock) && !(C.z in z_lock))
continue
var/list/network_overlap = networks & C.network
if(length(network_overlap))
camera_location = get_turf(C)
break
else
camera_location = myturf
if(length(z_lock) && !(myturf.z in z_lock))
camera_location = locate(round(world.maxx/2), round(world.maxy/2), z_lock[1])
if(camera_location)
eyeobj.eye_initialized = TRUE
give_eye_control(L)
eyeobj.setLoc(camera_location)
else
unset_machine(user)
else
give_eye_control(L)
eyeobj.setLoc(eyeobj.loc)
/obj/machinery/computer/camera_advanced/attack_robot(mob/user)
return attack_hand(user)
/obj/machinery/computer/camera_advanced/attack_ai(mob/user)
return //AIs would need to disable their own camera procs to use the console safely. Bugs happen otherwise.
/obj/machinery/computer/camera_advanced/proc/give_eye_control(mob/user)
if(isnull(user?.client))
return
GrantActions(user)
current_user = user
eyeobj.eye_user = user
eyeobj.name = "Camera Eye ([user.name])"
user.remote_control = eyeobj
user.reset_perspective(eyeobj)
eyeobj.setLoc(eyeobj.loc)
if(should_supress_view_changes)
user.client.view_size.supress()
/mob/camera/ai_eye/remote
name = "Inactive Camera Eye"
ai_detector_visible = FALSE
var/sprint = 10
var/cooldown = 0
var/acceleration = 1
var/mob/living/eye_user = null
var/obj/machinery/computer/camera_advanced/origin
var/eye_initialized = 0
var/visible_icon = 0
var/image/user_image = null
/mob/camera/ai_eye/remote/update_remote_sight(mob/living/user)
user.set_invis_see(SEE_INVISIBLE_LIVING) //can't see ghosts through cameras
user.set_sight(SEE_TURFS)
return TRUE
/mob/camera/ai_eye/remote/Destroy()
if(origin && eye_user)
origin.remove_eye_control(eye_user,src)
origin = null
. = ..()
eye_user = null
/mob/camera/ai_eye/remote/GetViewerClient()
if(eye_user)
return eye_user.client
return null
/mob/camera/ai_eye/remote/setLoc(turf/destination, force_update = FALSE)
if(eye_user)
destination = get_turf(destination)
if (destination)
abstract_move(destination)
else
moveToNullspace()
update_ai_detect_hud()
if(use_static)
origin.camnet.visibility(src, GetViewerClient(), null, use_static)
if(visible_icon)
if(eye_user.client)
eye_user.client.images -= user_image
user_image = image(icon,loc,icon_state, FLY_LAYER)
SET_PLANE(user_image, ABOVE_GAME_PLANE, destination)
eye_user.client.images += user_image
/mob/camera/ai_eye/remote/relaymove(mob/living/user, direction)
var/initial = initial(sprint)
var/max_sprint = 50
if(cooldown && cooldown < world.timeofday) // 3 seconds
sprint = initial
for(var/i = 0; i < max(sprint, initial); i += 20)
var/turf/step = get_turf(get_step(src, direction))
if(step)
setLoc(step)
cooldown = world.timeofday + 5
if(acceleration)
sprint = min(sprint + 0.5, max_sprint)
else
sprint = initial
/datum/action/innate/camera_off
name = "End Camera View"
button_icon = 'icons/mob/actions/actions_silicon.dmi'
button_icon_state = "camera_off"
/datum/action/innate/camera_off/Activate()
if(!owner || !isliving(owner))
return
var/mob/camera/ai_eye/remote/remote_eye = owner.remote_control
var/obj/machinery/computer/camera_advanced/console = remote_eye.origin
console.remove_eye_control(owner)
/datum/action/innate/camera_jump
name = "Jump To Camera"
button_icon = 'icons/mob/actions/actions_silicon.dmi'
button_icon_state = "camera_jump"
/datum/action/innate/camera_jump/Activate()
if(!owner || !isliving(owner))
return
var/mob/camera/ai_eye/remote/remote_eye = owner.remote_control
var/obj/machinery/computer/camera_advanced/origin = remote_eye.origin
var/list/L = list()
for (var/obj/machinery/camera/cam as anything in origin.camnet.cameras)
if(length(origin.z_lock) && !(cam.z in origin.z_lock))
continue
L.Add(cam)
camera_sort(L)
var/list/T = list()
for (var/obj/machinery/camera/netcam in L)
var/list/tempnetwork = netcam.network & origin.networks
if (length(tempnetwork))
if(!netcam.c_tag)
continue
T["[netcam.c_tag][netcam.can_use() ? null : " (Deactivated)"]"] = netcam
playsound(origin, 'sound/machines/terminal_prompt.ogg', 25, FALSE)
var/camera = tgui_input_list(usr, "Camera to view", "Cameras", T)
if(isnull(camera))
return
if(isnull(T[camera]))
return
var/obj/machinery/camera/final = T[camera]
playsound(src, SFX_TERMINAL_TYPE, 25, FALSE)
if(final)
playsound(origin, 'sound/machines/terminal_prompt_confirm.ogg', 25, FALSE)
remote_eye.setLoc(get_turf(final))
owner.overlay_fullscreen("flash", /atom/movable/screen/fullscreen/flash/static)
owner.clear_fullscreen("flash", 3) //Shorter flash than normal since it's an ~~advanced~~ console!
else
playsound(origin, 'sound/machines/terminal_prompt_deny.ogg', 25, FALSE)
/datum/action/innate/camera_multiz_up
name = "Move up a floor"
button_icon = 'icons/mob/actions/actions_silicon.dmi'
button_icon_state = "move_up"
/datum/action/innate/camera_multiz_up/Activate()
if(!owner || !isliving(owner))
return
var/mob/camera/ai_eye/remote/remote_eye = owner.remote_control
if(remote_eye.zMove(UP))
to_chat(owner, span_notice("You move upwards."))
else
to_chat(owner, span_notice("You couldn't move upwards!"))
/datum/action/innate/camera_multiz_down
name = "Move down a floor"
button_icon = 'icons/mob/actions/actions_silicon.dmi'
button_icon_state = "move_down"
/datum/action/innate/camera_multiz_down/Activate()
if(!owner || !isliving(owner))
return
var/mob/camera/ai_eye/remote/remote_eye = owner.remote_control
if(remote_eye.zMove(DOWN))
to_chat(owner, span_notice("You move downwards."))
else
to_chat(owner, span_notice("You couldn't move downwards!"))
//Used by servants of Ratvar! They let you beam to the station.
/obj/machinery/computer/camera_advanced/ratvar
name = "ratvarian camera observer"
desc = "A console used to snoop on the station's goings-on. A jet of steam occasionally whooshes out from slats on its sides."
use_power = FALSE
networks = list("ss13", "minisat") //:eye:
var/datum/action/innate/servant_warp/warp_action = /datum/action/innate/servant_warp
/obj/machinery/computer/camera_advanced/ratvar/Initialize(mapload)
. = ..()
if(warp_action)
actions += new warp_action(src)
ratvar_act()
/obj/machinery/computer/camera_advanced/ratvar/process()
if(prob(1))
playsound(src, 'sound/machines/clockcult/steam_whoosh.ogg', 25, TRUE)
new/obj/effect/temp_visual/steam_release(get_turf(src))
/obj/machinery/computer/camera_advanced/ratvar/CreateEye()
..()
eyeobj.visible_icon = TRUE
eyeobj.icon = 'icons/mob/cameramob.dmi' //in case you still had any doubts
eyeobj.icon_state = "generic_camera"
/obj/machinery/computer/camera_advanced/ratvar/can_use(mob/living/user)
if(!is_servant_of_ratvar(user))
to_chat(user, span_warning("[src]'s keys are in a language foreign to you, and you don't understand anything on its screen."))
return
if(clockwork_ark_active())
to_chat(user, span_warning("The Ark is active, and [src] has shut down."))
return
. = ..()
/datum/action/innate/servant_warp
name = "Warp"
desc = "Warps to the tile you're viewing. You can use the Abscond scripture to return. Clicking this button again cancels the warp."
button_icon = 'icons/mob/actions/actions_clockcult.dmi'
button_icon_state = "warp_down"
background_icon_state = "bg_clock"
buttontooltipstyle = "clockcult"
var/cancel = FALSE //if TRUE, an active warp will be canceled
var/obj/effect/temp_visual/ratvar/warp_marker/warping
/datum/action/innate/servant_warp/Activate()
if(QDELETED(target) || !(ishuman(owner) || iscyborg(owner)) || !owner.canUseTopic(target))
return
if(!GLOB.servants_active) //No leaving unless there's servants from the get-go
to_chat(owner, "[span_sevtug_small("The Ark doesn't let you leave!")]")
return
if(warping)
cancel = TRUE
return
var/mob/living/carbon/human/user = owner
var/mob/camera/ai_eye/remote/remote_eye = user.remote_control
var/obj/machinery/computer/camera_advanced/ratvar/camera_console = target
var/turf/teleport_turf = get_turf(remote_eye)
if(!is_reebe(user.z) || !is_station_level(teleport_turf.z))
return
if(isclosedturf(teleport_turf))
to_chat(user, "[span_sevtug_small("You can't teleport into a wall.")]")
return
else if(isspaceturf(teleport_turf))
to_chat(user, "[span_sevtug_small("[prob(1) ? "Servant cannot into space." : "You can't teleport into space."]")]")
return
else if(teleport_turf.turf_flags & NOJAUNT)
to_chat(user, "[span_sevtug_small("This tile is blessed by strange energies and deflects the warp.")]")
return
else if(locate(/obj/effect/blessing, teleport_turf))
to_chat(user, "[span_sevtug_small("This tile is blessed by holy water and deflects the warp.")]")
return
var/area/teleport_area = get_area(teleport_turf)
if(!teleport_area.clockwork_warp_allowed)
to_chat(user, "[span_sevtug_small("[teleport_area.clockwork_warp_fail]")]")
return
if(user.w_uniform && user.w_uniform.name == initial(user.w_uniform.name))
if(tgui_alert(user, "ARE YOU SURE YOU WANT TO WARP WITHOUT CAMOUFLAGING YOUR JUMPSUIT?", "Preflight Check", list("Yes", "No")) == "No" )
return
if(tgui_alert(user, "Are you sure you want to warp to [teleport_area]?", camera_console.name, list("Warp", "Cancel")) == \
"Cancel" || QDELETED(camera_console) || !user.canUseTopic(camera_console))
return
do_sparks(5, TRUE, user)
do_sparks(5, TRUE, teleport_turf)
user.visible_message(span_warning("[user]'s [camera_console.name] flares!"), "<span class='bold sevtug_small'>You begin warping to [teleport_area]...</span>")
button_icon_state = "warp_cancel"
owner.update_action_buttons()
var/warp_time = 5 SECONDS
if(!istype(teleport_turf, /turf/open/floor/clockwork) && GLOB.clockwork_hardmode_active)
to_chat(user, "[span_sevtug_small("The [camera_console.name]'s inner machinery protests vehemently as it attempts to warp you to a non-brass tile, this will take time...")]")
warp_time = 30 SECONDS
warping = new(teleport_turf, user, warp_time)
if(!do_after(user, warp_time, warping, extra_checks = CALLBACK(src, PROC_REF(is_canceled))))
to_chat(user, "<span class='bold sevtug_small'>Warp interrupted.</span>")
QDEL_NULL(warping)
button_icon_state = "warp_down"
owner.update_action_buttons()
cancel = FALSE
return
button_icon_state = "warp_down"
owner.update_action_buttons()
teleport_turf.visible_message(span_warning("[user] warps in!"))
playsound(user, 'sound/magic/magic_missile.ogg', 15, TRUE)
playsound(teleport_turf, 'sound/magic/magic_missile.ogg', 15, TRUE)
user.forceMove(get_turf(teleport_turf))
user.setDir(SOUTH)
flash_color(user, flash_color = "#AF0AAF", flash_time = 5)
camera_console.remove_eye_control(user)
QDEL_NULL(warping)
/datum/action/innate/servant_warp/proc/is_canceled()
return !cancel