-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathradar.dm
369 lines (332 loc) · 11.5 KB
/
radar.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
/datum/computer_file/program/radar //generic parent that handles most of the process
filename = "genericfinder"
filedesc = "debug_finder"
ui_header = "borg_mon.gif" //DEBUG -- new icon before PR
program_icon_state = "radarntos"
requires_ntnet = TRUE
transfer_access = null
available_on_ntnet = FALSE
usage_flags = PROGRAM_LAPTOP | PROGRAM_TABLET | PROGRAM_PHONE | PROGRAM_PDA | PROGRAM_INTEGRATED
network_destination = "tracking program"
size = 5
tgui_id = "NtosRadar"
///List of trackable entities. Updated by the scan() proc.
var/list/objects
///Ref of the last trackable object selected by the user in the tgui window. Updated in the ui_act() proc.
var/atom/selected
///Used to store when the next scan is available. Updated by the scan() proc.
var/next_scan = 0
///Used to keep track of the last value program_icon_state was set to, to prevent constant unnecessary update_appearance(UPDATE_ICON) calls
var/last_icon_state = ""
///Used by the tgui interface, themed NT or Syndicate.
var/arrowstyle = "ntosradarpointer.png"
///Used by the tgui interface, themed for NT or Syndicate colors.
var/pointercolor = "green"
/datum/computer_file/program/radar/run_program(mob/living/user)
. = ..()
if(.)
START_PROCESSING(SSfastprocess, src)
return
return FALSE
/datum/computer_file/program/radar/kill_program(forced = FALSE)
objects = list()
selected = null
STOP_PROCESSING(SSfastprocess, src)
return ..()
/datum/computer_file/program/radar/Destroy()
STOP_PROCESSING(SSfastprocess, src)
return ..()
/datum/computer_file/program/radar/Destroy()
STOP_PROCESSING(SSfastprocess, src)
return ..()
/datum/computer_file/program/radar/ui_assets(mob/user)
return list(
get_asset_datum(/datum/asset/simple/radar_assets),
)
/datum/computer_file/program/radar/ui_data(mob/user)
var/list/data = get_header_data()
data["selected"] = selected
data["objects"] = list()
data["scanning"] = (world.time < next_scan)
for(var/list/i in objects)
var/list/objectdata = list(
ref = i["ref"],
name = i["name"],
)
data["object"] += list(objectdata)
data["target"] = list()
var/list/trackinfo = track()
if(trackinfo)
data["target"] = trackinfo
return data
/datum/computer_file/program/radar/ui_act(action, params)
if(..())
return
computer.play_interact_sound()
switch(action)
if("selecttarget")
selected = params["ref"]
if("scan")
scan()
/**
*Updates tracking information of the selected target.
*
*The track() proc updates the entire set of information about the location
*of the target, including whether the Ntos window should use a pinpointer
*crosshair over the up/down arrows, or none in favor of a rotating arrow
*for far away targets. This information is returned in the form of a list.
*
*/
/datum/computer_file/program/radar/proc/track()
var/atom/movable/signal = find_atom()
if(!trackable(signal))
return
var/turf/here_turf = (get_turf(computer))
var/turf/target_turf = (get_turf(signal))
var/userot = FALSE
var/rot = 0
var/pointer="crosshairs"
var/locx = (target_turf.x - here_turf.x) + 24
var/locy = (here_turf.y - target_turf.y) + 24
if(get_dist_euclidian(here_turf, target_turf) > 24)
userot = TRUE
rot = round(Get_Angle(here_turf, target_turf))
else
if(target_turf.z > here_turf.z)
pointer="caret-up"
else if(target_turf.z < here_turf.z)
pointer="caret-down"
var/list/trackinfo = list(
"locx" = locx,
"locy" = locy,
"userot" = userot,
"rot" = rot,
"arrowstyle" = arrowstyle,
"color" = pointercolor,
"pointer" = pointer,
)
return trackinfo
/**
*
*Checks the trackability of the selected target.
*
*If the target is on the computer's Z level, or both are on station Z
*levels, and the target isn't untrackable, return TRUE.
*Arguments:
**arg1 is the atom being evaluated.
*/
/datum/computer_file/program/radar/proc/trackable(atom/movable/signal)
if(!signal || !computer)
return FALSE
var/turf/here = get_turf(computer)
var/turf/there = get_turf(signal)
if(!here || !there)
return FALSE //I was still getting a runtime even after the above check while scanning, so fuck it
return (there.z in SSmapping.get_connected_levels(here))
/**
*
*Runs a scan of all the trackable atoms.
*
*Checks each entry in the GLOB of the specific trackable atoms against
*the track() proc, and fill the objects list with lists containing the
*atoms' names and REFs. The objects list is handed to the tgui screen
*for displaying to, and being selected by, the user. A two second
*sleep is used to delay the scan, both for thematical reasons as well
*as to limit the load players may place on the server using these
*somewhat costly loops.
*/
/datum/computer_file/program/radar/proc/scan()
return
/**
*
*Finds the atom in the appropriate list that the `selected` var indicates
*
*The `selected` var holds a REF, which is a string. A mob REF may be
*something like "mob_209". In order to find the actual atom, we need
*to search the appropriate list for the REF string. This is dependant
*on the program (Lifeline uses GLOB.human_list, while Fission360 uses
*GLOB.poi_list), but the result will be the same; evaluate the string and
*return an atom reference.
*/
/datum/computer_file/program/radar/proc/find_atom()
return
//We use SSfastprocess for the program icon state because it runs faster than process_tick() does.
/datum/computer_file/program/radar/process()
if(computer.active_program != src)
STOP_PROCESSING(SSfastprocess, src) //We're not the active program, it's time to stop.
return
if(!selected)
return
var/atom/movable/signal = find_atom()
if(!trackable(signal))
program_icon_state = "[initial(program_icon_state)]lost"
if(last_icon_state != program_icon_state)
computer.update_appearance(UPDATE_ICON)
last_icon_state = program_icon_state
return
var/here_turf = get_turf(computer)
var/target_turf = get_turf(signal)
var/trackdistance = get_dist_euclidian(here_turf, target_turf)
switch(trackdistance)
if(0)
program_icon_state = "[initial(program_icon_state)]direct"
if(1 to 12)
program_icon_state = "[initial(program_icon_state)]close"
if(13 to 24)
program_icon_state = "[initial(program_icon_state)]medium"
if(25 to INFINITY)
program_icon_state = "[initial(program_icon_state)]far"
if(last_icon_state != program_icon_state)
computer.update_appearance(UPDATE_ICON)
last_icon_state = program_icon_state
computer.setDir(get_dir(here_turf, target_turf))
//We can use process_tick to restart fast processing, since the computer will be running this constantly either way.
/datum/computer_file/program/radar/process_tick()
if(computer.active_program == src)
START_PROCESSING(SSfastprocess, src)
///////////////////
//Suit Sensor App//
///////////////////
///A program that tracks crew members via suit sensors
/datum/computer_file/program/radar/lifeline
filename = "Lifeline"
filedesc = "Lifeline"
extended_desc = "This program allows for tracking of crew members via their suit sensors."
requires_ntnet = FALSE //Tracking should not require NTNET, as sensors are not on the network at all, and the program is downloaded locally.
transfer_access = ACCESS_MEDICAL
available_on_ntnet = TRUE
category = PROGRAM_CATEGORY_EQUIPMENT
program_icon = "street-view"
/datum/computer_file/program/radar/lifeline/find_atom()
return locate(selected) in GLOB.carbon_list
/datum/computer_file/program/radar/lifeline/scan()
if(world.time < next_scan)
return
next_scan = world.time + (2 SECONDS)
objects = list()
var/list/names = list()
var/list/humanoids = list()
for(var/i in GLOB.mob_living_list)
var/mob/living/carbon/human/humanoid = i
if(!istype(humanoid))
continue
if(!trackable(humanoid))
continue
var/crewmember_name = "Unknown"
if(humanoid.wear_id)
var/obj/item/card/id/ID = humanoid.wear_id.GetID()
if(ID && ID.registered_name)
crewmember_name = ID.registered_name
while(crewmember_name in humanoids)
humanoids[crewmember_name]++
crewmember_name = text("[] ([])", crewmember_name, humanoids[crewmember_name])
names[crewmember_name] = humanoid
humanoids[crewmember_name] = 1
for(var/N in sortList(names))
var/list/crewinfo = list(
ref = REF(names[N]),
name = N
)
objects += list(crewinfo)
/datum/computer_file/program/radar/lifeline/trackable(mob/living/carbon/human/humanoid)
if(!humanoid || !istype(humanoid))
return FALSE
if(..())
if(HAS_TRAIT(humanoid, TRAIT_SUITLESS_SENSORS))
return TRUE
if(istype(humanoid.w_uniform, /obj/item/clothing/under))
var/obj/item/clothing/under/uniform = humanoid.w_uniform
if(uniform.has_sensor && uniform.sensor_mode >= SENSOR_COORDS) // Suit sensors must be on maximum
return TRUE
return FALSE
////////////////////////
//Nuke Disk Finder App//
////////////////////////
///A program that tracks important items like the nuke disk
/datum/computer_file/program/radar/fission360
filename = "Fission360"
filedesc = "Fission360"
category = PROGRAM_CATEGORY_EQUIPMENT
program_icon_state = "radarsyndicate"
extended_desc = "This program allows for tracking of nuclear authorization disks and warheads."
requires_ntnet = FALSE
transfer_access = null
available_on_ntnet = FALSE
available_on_syndinet = TRUE
tgui_id = "NtosRadarSyndicate"
program_icon = "radiation"
arrowstyle = "ntosradarpointerS.png"
pointercolor = "red"
/datum/computer_file/program/radar/fission360/find_atom()
return locate(selected) in GLOB.poi_list
/datum/computer_file/program/radar/fission360/scan()
if(world.time < next_scan)
return
next_scan = world.time + (2 SECONDS)
objects = list()
for(var/i in GLOB.nuke_list)
var/obj/machinery/nuclearbomb/nuke = i
if(!trackable(nuke))
continue
var/list/nukeinfo = list(
ref = REF(nuke),
name = nuke.name,
)
objects += list(nukeinfo)
var/obj/item/disk/nuclear/disk = locate() in GLOB.poi_list
if(trackable(disk))
var/list/nukeinfo = list(
ref = REF(disk),
name = disk.name,
)
objects += list(nukeinfo)
///////////////////////
//Implant Tracker App//
///////////////////////
///A program that tracks people via tracking implants
/datum/computer_file/program/radar/implant
filename = "implanttracker"
filedesc = "Implant Tracker"
category = PROGRAM_CATEGORY_SECURITY
extended_desc = "This program allows for tracking those implanted with tracking implants."
requires_ntnet = FALSE //Same as Lifeline.
transfer_access = ACCESS_BRIG
available_on_ntnet = TRUE
program_icon = "microchip"
/datum/computer_file/program/radar/implant/find_atom()
return locate(selected) in GLOB.mob_living_list
/datum/computer_file/program/radar/implant/scan()
if(world.time < next_scan)
return
next_scan = world.time + (2 SECONDS)
objects = list()
var/list/names = list()
var/list/humanoids = list()
for(var/obj/item/implant/imp in GLOB.tracked_implants)
var/mob/living/target = imp.imp_in
if(!istype(target))
continue
if(!trackable(target))
continue
var/crewmember_name = "Unknown"
if(istype(target, /mob/living/carbon/human))
var/mob/living/carbon/human/humanoid = target
if(humanoid.wear_id)
var/obj/item/card/id/ID = humanoid.wear_id.GetID()
if(ID && ID.registered_name)
crewmember_name = ID.registered_name
while(crewmember_name in humanoids)
humanoids[crewmember_name]++
crewmember_name = text("[] ([])", crewmember_name, humanoids[crewmember_name])
names[crewmember_name] = humanoid
humanoids[crewmember_name] = 1
for(var/N in sortList(names))
var/list/crewinfo = list(
ref = REF(names[N]),
name = N
)
objects += list(crewinfo)
/datum/computer_file/program/radar/implant/trackable(mob/living/target)
if(!target || !istype(target))
return FALSE
return TRUE