var/list/obj/machinery/photocopier/faxmachine/allfaxes = list()
var/list/admin_departments = list("Central Command", "Sol Government")
var/list/alldepartments = list()
var/list/adminfaxes = list() //cache for faxes that have been sent to admins
/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_heads, access_armory) //Warden needs to be able to Fax solgov too.
use_power = 1
idle_power_usage = 30
active_power_usage = 200
var/obj/item/weapon/card/id/scan = null // identification
var/authenticated = 0
var/sendcooldown = 0 // to avoid spamming fax messages
var/department = "Unknown" // our department
var/destination = "Central Command" // the department we're sending to
/obj/machinery/photocopier/faxmachine/New()
..()
allfaxes += src
if( !(("[department]" in alldepartments) || ("[department]" in admin_departments)) )
alldepartments |= department
/obj/machinery/photocopier/faxmachine/attack_hand(mob/user as mob)
user.set_machine(src)
var/dat = "Fax Machine
"
var/scan_name
if(scan)
scan_name = scan.name
else
scan_name = "--------"
dat += "Confirm Identity: [scan_name]
"
if(authenticated)
dat += "{Log Out}"
else
dat += "{Log In}"
dat += "
"
if(authenticated)
dat += "Logged in to: Central Command Quantum Entanglement Network
"
if(copyitem)
dat += "Remove Item
"
if(sendcooldown)
dat += "Transmitter arrays realigning. Please stand by.
"
else
dat += "Send
"
dat += "Currently sending: [copyitem.name]
"
dat += "Sending to: [destination]
"
else
if(sendcooldown)
dat += "Please insert paper to send via secure connection.
"
dat += "Transmitter arrays realigning. Please stand by.
"
else
dat += "Please insert paper to send via secure connection.
"
else
dat += "Proper authentication is required to use this device.
"
if(copyitem)
dat += "Remove Item
"
user << browse(dat, "window=copier")
onclose(user, "copier")
return
/obj/machinery/photocopier/faxmachine/Topic(href, href_list)
if(href_list["send"])
if(copyitem)
if (destination in admin_departments)
send_admin_fax(usr, destination)
else
sendfax(destination)
if (sendcooldown)
spawn(sendcooldown) // cooldown time
sendcooldown = 0
else if(href_list["remove"])
if(copyitem)
copyitem.loc = usr.loc
usr.put_in_hands(copyitem)
usr << "You take \the [copyitem] out of \the [src]."
copyitem = null
updateUsrDialog()
if(href_list["scan"])
if (scan)
if(ishuman(usr))
scan.loc = usr.loc
if(!usr.get_active_hand())
usr.put_in_hands(scan)
scan = null
else
scan.loc = src.loc
scan = null
else
var/obj/item/I = usr.get_active_hand()
if (istype(I, /obj/item/weapon/card/id))
usr.drop_item()
I.loc = src
scan = I
authenticated = 0
if(href_list["dept"])
var/lastdestination = destination
destination = input(usr, "Which department?", "Choose a department", "") as null|anything in (alldepartments + admin_departments)
if(!destination) destination = lastdestination
if(href_list["auth"])
if ( (!( authenticated ) && (scan)) )
if (check_access(scan))
authenticated = 1
if(href_list["logout"])
authenticated = 0
updateUsrDialog()
/obj/machinery/photocopier/faxmachine/proc/sendfax(var/destination)
if(stat & (BROKEN|NOPOWER))
return
use_power(200)
var/success = 0
for(var/obj/machinery/photocopier/faxmachine/F in allfaxes)
if( F.department == destination )
success = F.recievefax(copyitem)
if (success)
visible_message("[src] beeps, \"Message transmitted successfully.\"")
//sendcooldown = 600
else
visible_message("[src] beeps, \"Error transmitting message.\"")
/obj/machinery/photocopier/faxmachine/proc/recievefax(var/obj/item/incoming)
if(stat & (BROKEN|NOPOWER))
return 0
if(department == "Unknown")
return 0 //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(20)
if (istype(incoming, /obj/item/weapon/paper))
copy(incoming)
else if (istype(incoming, /obj/item/weapon/photo))
photocopy(incoming)
else if (istype(incoming, /obj/item/weapon/paper_bundle))
bundlecopy(incoming)
else
return 0
use_power(active_power_usage)
return 1
/obj/machinery/photocopier/faxmachine/proc/send_admin_fax(var/mob/sender, var/destination)
if(stat & (BROKEN|NOPOWER))
return
use_power(200)
var/obj/item/rcvdcopy
if (istype(copyitem, /obj/item/weapon/paper))
rcvdcopy = copy(copyitem)
else if (istype(copyitem, /obj/item/weapon/photo))
rcvdcopy = photocopy(copyitem)
else if (istype(copyitem, /obj/item/weapon/paper_bundle))
rcvdcopy = bundlecopy(copyitem)
else
visible_message("[src] beeps, \"Error transmitting message.\"")
return
rcvdcopy.loc = null //hopefully this shouldn't cause trouble
adminfaxes += rcvdcopy
//message badmins that a fax has arrived
switch(destination)
if ("Central Command")
message_admins(sender, "CENTCOMM FAX", rcvdcopy, "CentcommFaxReply", "#006100")
if ("Sol Government")
message_admins(sender, "SOL GOVERNMENT FAX", rcvdcopy, "CentcommFaxReply", "#1F66A0")
//message_admins(sender, "SOL GOVERNMENT FAX", rcvdcopy, "SolGovFaxReply", "#1F66A0")
sendcooldown = 1800
sleep(50)
visible_message("[src] beeps, \"Message transmitted successfully.\"")
/obj/machinery/photocopier/faxmachine/proc/message_admins(var/mob/sender, var/faxname, var/obj/item/sent, var/reply_type, font_colour="#006100")
var/msg = "\blue [faxname]: [key_name(sender, 1)] (PP) (VV) (SM) (JMP) (CA) (REPLY): Receiving '[sent.name]' via secure connection ... view message"
for(var/client/C in admins)
if(R_ADMIN & C.holder.rights)
C << msg