-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathfaxmachine.dm
265 lines (236 loc) · 9.68 KB
/
faxmachine.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
GLOBAL_LIST_EMPTY(allfaxes)
GLOBAL_LIST_EMPTY(admin_departments)
GLOBAL_LIST_EMPTY(alldepartments)
GLOBAL_LIST_EMPTY(adminfaxes)
/obj/machinery/photocopier/faxmachine
name = "fax machine"
icon = 'icons/obj/library.dmi'
icon_state = "fax"
insert_anim = "faxsend"
req_one_access = list(ACCESS_LAWYER, ACCESS_COMMAND, ACCESS_ARMORY, ACCESS_DETECTIVE, ACCESS_QM)
use_power = 1
idle_power_usage = 30
active_power_usage = 200
var/authenticated = FALSE
var/auth_name
var/sendcooldown = 0 // to avoid spamming fax messages
var/department = "Unknown" // our department
var/destination = "Central Command" // the department we're sending to
var/hidefromfaxlist = FALSE // If enabled does not show up in the destination fax list
/obj/machinery/photocopier/faxmachine/Initialize(mapload)
. = ..()
if(hidefromfaxlist)
return
GLOB.allfaxes += src
if( !((department in GLOB.alldepartments) || (department in GLOB.admin_departments)) )
GLOB.alldepartments |= department
/obj/machinery/photocopier/faxmachine/Initialize(mapload)
. = ..()
GLOB.admin_departments |= list("Central Command")
//please dont add to this
/obj/machinery/photocopier/faxmachine/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "FaxMachine", name)
ui.open()
/obj/machinery/photocopier/faxmachine/ui_state(mob/user)
return GLOB.default_state
/obj/machinery/photocopier/faxmachine/ui_data(mob/user)
. = list()
.["authenticated"] = authenticated
.["auth_name"] = auth_name
.["has_copy"] = !copier_empty()
.["copy_name"] = copy?.name || photocopy?.name || doccopy?.name
.["cooldown"] = sendcooldown - world.time
.["depts"] = obj_flags & EMAGGED ? (GLOB.alldepartments + GLOB.admin_departments + list("Syndicate")) : (GLOB.alldepartments + GLOB.admin_departments)
.["destination"] = destination
/obj/machinery/photocopier/faxmachine/ui_act(action, list/params)
. = ..()
if(.)
return
. = TRUE
switch(action)
if("send")
if(!copier_empty())
if(sendcooldown - world.time > 0)
to_chat(usr, "<span class='warning'>Transmitter recharging</span>")
return
sendcooldown = world.time + 1 MINUTES
if (destination in GLOB.admin_departments)
INVOKE_ASYNC(src, PROC_REF(send_admin_fax), usr, destination)
if (destination == "Syndicate")
INVOKE_ASYNC(src, PROC_REF(send_admin_fax), usr, destination)
else
INVOKE_ASYNC(src, PROC_REF(sendfax), destination)
return
if("remove")
if(copy)
copy.loc = usr.loc
usr.put_in_hands(copy)
to_chat(usr, "<span class='notice'>You take \the [copy] out of \the [src].</span>")
copy = null
return
if(photocopy)
photocopy.loc = usr.loc
usr.put_in_hands(photocopy)
to_chat(usr, "<span class='notice'>You take \the [photocopy] out of \the [src].</span>")
photocopy = null
return
if("dept")
var/lastdestination = destination
destination = input(usr, "Which department?", "Choose a department", "") as null|anything in (GLOB.alldepartments + GLOB.admin_departments)
if(!destination) destination = lastdestination
return
if("set_dept")
destination = params["dept"]
return
if("auth")
if (IsAdminGhost(usr))
authenticated = TRUE
auth_name = usr.client.holder.admin_signature
return
if(obj_flags & EMAGGED)
authenticated = TRUE
auth_name = "$#%*! - ERROR"
return
var/obj/item/card/id/id_card = usr.get_idcard(hand_first = TRUE)
if (check_access(id_card))
authenticated = TRUE
auth_name = "[id_card.registered_name] - [id_card.assignment]"
return
if("logout")
authenticated = FALSE
auth_name = null
return
return FALSE
/obj/machinery/photocopier/faxmachine/proc/sendfax(destination)
if(stat & (BROKEN|NOPOWER))
return
use_power(200)
var/success = FALSE
for(var/obj/machinery/photocopier/faxmachine/F in GLOB.allfaxes)
if( F.department == destination )
success ||= F.recievefax(copy || photocopy)
if (success)
visible_message("[src] beeps, \"Message transmitted successfully.\"")
else
visible_message("[src] beeps, \"Error transmitting message.\"")
/obj/machinery/photocopier/faxmachine/proc/recievefax(obj/item/incoming)
if(stat & (BROKEN|NOPOWER))
return FALSE
if(department == "Unknown")
return FALSE //You can't send faxes to "Unknown"
flick("faxreceive", src)
playsound(loc, "sound/items/polaroid1.ogg", 50, 1)
// give the sprite some time to flick
sleep(2.3 SECONDS)
if (istype(incoming, /obj/item/paper))
copy(incoming)
else if (istype(incoming, /obj/item/photo))
photocopy(incoming)
else if (istype(incoming, /obj/item/paper_bundle))
bundlecopy(incoming)
else
return FALSE
use_power(active_power_usage)
return TRUE
/obj/machinery/photocopier/faxmachine/proc/send_admin_fax(mob/sender, destination)
if(stat & (BROKEN|NOPOWER))
return
use_power(200)
var/obj/item/rcvdcopy
if (istype(copy, /obj/item/paper_bundle))
var/obj/item/paper_bundle/rcvdbundle = bundlecopy(copy)
rcvdbundle.admin_faxed = TRUE
rcvdcopy = rcvdbundle
else if (copy)
rcvdcopy = copy(copy)
else if (photocopy)
rcvdcopy = photocopy(photocopy)
else
visible_message("[src] beeps, \"Error transmitting message.\"")
return
rcvdcopy.moveToNullspace() //hopefully this shouldn't cause trouble
GLOB.adminfaxes += rcvdcopy
for(var/obj/machinery/photocopier/faxmachine/F in GLOB.allfaxes)
if(is_centcom_level(F.z))
F.recievefax(rcvdcopy)
//message badmins that a fax has arrived
for(var/client/C in GLOB.permissions.admins) //linked to prayers cause we are running out of legacy toggles
if(C.prefs.chat_toggles & CHAT_PRAYER_N_FAX) //if to be moved elsewhere then we must declutter legacy toggles
if(C.prefs.toggles & SOUND_PRAYER_N_FAX)//if done then delete these comments
SEND_SOUND(sender, sound('sound/effects/admin_fax.ogg'))
send_adminmessage(sender, destination == "Syndicate" ? "SYNDICATE FAX" : "CENTCOM FAX", rcvdcopy, "AdminFaxReply", destination == "Syndicate" ? "crimson" : "#006100")
sendcooldown = world.time + 1 MINUTES
sleep(5 SECONDS)
visible_message("[src] beeps, \"Message transmitted successfully.\"")
/obj/machinery/photocopier/faxmachine/proc/send_adminmessage(mob/sender, faxname, obj/item/sent, reply_type, font_colour="#006100")
var/msg = "<b><font color='[font_colour]'>[faxname]: </font>[key_name(sender, 1)] (<A HREF='?_src_=holder;[HrefToken(TRUE)];adminplayeropts=\ref[sender]'>PP</A>) (<A HREF='?_src_=vars;[HrefToken(TRUE)];Vars=\ref[sender]'>VV</A>) (<A HREF='?_src_=holder;[HrefToken(TRUE)];subtlemessage=\ref[sender]'>SM</A>) (<A HREF='?_src_=holder;[HrefToken(TRUE)];adminplayerobservefollow=\ref[sender]'>JMP</A>) (<a href='?_src_=holder;[HrefToken(TRUE)];[reply_type]=\ref[sender];originfax=\ref[src]'>REPLY</a>)</b>: Receiving '[sent.name]' via secure connection ... <a href='?_src_=holder;[HrefToken(TRUE)];AdminFaxView=\ref[sent]'>view message</a>"
msg = span_admin("<span class=\"message\">[msg]</span>")
to_chat(GLOB.permissions.admins,
type = MESSAGE_TYPE_ADMINLOG,
html = msg,
confidential = TRUE)
/obj/machinery/photocopier/faxmachine/check_ass()
return FALSE // No ass here
/obj/machinery/photocopier/faxmachine/proc/recieve_admin_fax(customname, list/T)
if(stat & (BROKEN|NOPOWER))
return
// animate! it's alive!
flick("faxreceive", src)
// give the sprite some time to flick
spawn(20)
var/obj/item/paper/P = new /obj/item/paper( loc )
var/syndicate = obj_flags & EMAGGED
P.name = syndicate ? "The Syndicate - [customname]" : "[command_name()] - [customname]"
var/list/templist = list() // All the stuff we're adding to $written
for(var/text in T)
if(text == PAPER_FIELD)
templist += text
else
var/datum/langtext/L = new(text,/datum/language/common)
templist += L
P.written += templist
P.update_appearance(UPDATE_ICON)
playsound(loc, "sound/items/polaroid1.ogg", 50, 1)
// Stamps
var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/simple/paper)
if (isnull(P.stamps))
P.stamps = sheet.css_tag()
P.stamps += syndicate ? sheet.icon_tag("stamp-syndiround") : sheet.icon_tag("stamp-cent")
P.stamps += "<br><i>This paper has [syndicate ? "not" : ""] been verified by the Central Command Quantum Relay.</i><br>"
var/mutable_appearance/stampoverlay = mutable_appearance('icons/obj/bureaucracy.dmi', syndicate ? "paper_stamp-syndiround" : "paper_stamp-cent")
stampoverlay.pixel_x = rand(-2, 2)
stampoverlay.pixel_y = rand(-3, 2)
LAZYADD(P.stamped, syndicate ? "stamp-syndiround" : "stamp-cent")
P.add_overlay(stampoverlay)
/obj/machinery/photocopier/faxmachine/AltClick(mob/user)
if(IsAdminGhost(user))
send_admin_fax(src)
/obj/machinery/photocopier/faxmachine/examine(mob/user)
. = ..()
if(IsAdminGhost(user))
.+= span_notice("You can send admin faxes via Alt-Click to this specific fax machine.")
/obj/machinery/photocopier/faxmachine/emag_act(mob/user, /obj/item/card/emag/emag_card)
if(obj_flags & EMAGGED)
to_chat(user, span_warning("[src]'s transceiver is damaged!"))
return FALSE
obj_flags |= EMAGGED
playsound(src, "sparks", 100, 1)
to_chat(user, span_warning("You short out the security protocols on [src]'s transceiver!"))
return TRUE
///Common syndicate fax machines, comes pre-emagged
/obj/machinery/photocopier/faxmachine/syndicate
department = "Unidentified"
desc = "Used to send black pages to Nanotrasen stations."
name = "Syndicate Fax Machine"
obj_flags = CAN_BE_HIT | EMAGGED
req_access = list(ACCESS_SYNDICATE)
///The fax machine in the Syndicate mothership
/obj/machinery/photocopier/faxmachine/syndicate_command
department = "Syndicate"
desc = "Used for communication between the different echelons of the Syndicate. It has a note on the side reading <i>'DO NOT MOVE'</i>."
destination = "Bridge"
hidefromfaxlist = TRUE
name = "Syndicate Fax Machine"
req_access = list(ACCESS_SYNDICATE)