Files
Aurora.3/code/modules/paperwork/faxmachine.dm
T
skull132 e9b688e1f6 Merge branch 'development-2' into development
Christ on a stick. SO MANY ERRORS. REEE.

# Conflicts:
#	baystation12.dme
#	code/_helpers/lists.dm
#	code/_helpers/logging.dm
#	code/_helpers/text.dm
#	code/_onclick/click.dm
#	code/controllers/configuration.dm
#	code/controllers/master_controller.dm
#	code/datums/supplypacks.dm
#	code/game/antagonist/antagonist.dm
#	code/game/antagonist/antagonist_print.dm
#	code/game/antagonist/outsider/commando.dm
#	code/game/antagonist/outsider/ninja.dm
#	code/game/area/areas.dm
#	code/game/gamemodes/cult/cult_items.dm
#	code/game/gamemodes/game_mode.dm
#	code/game/jobs/access.dm
#	code/game/machinery/atmoalter/canister.dm
#	code/game/machinery/autolathe.dm
#	code/game/machinery/doors/airlock.dm
#	code/game/machinery/recharger.dm
#	code/game/machinery/suit_storage_unit.dm
#	code/game/mecha/mech_fabricator.dm
#	code/game/mecha/mecha.dm
#	code/game/objects/effects/spiders.dm
#	code/game/objects/items.dm
#	code/game/objects/items/devices/PDA/PDA.dm
#	code/game/objects/items/devices/flash.dm
#	code/game/objects/items/devices/lightreplacer.dm
#	code/game/objects/items/devices/paicard.dm
#	code/game/objects/items/devices/scanners.dm
#	code/game/objects/items/devices/suit_cooling.dm
#	code/game/objects/items/devices/uplink.dm
#	code/game/objects/items/robot/robot_upgrades.dm
#	code/game/objects/items/toys.dm
#	code/game/objects/items/weapons/cards_ids.dm
#	code/game/objects/items/weapons/handcuffs.dm
#	code/game/objects/items/weapons/manuals.dm
#	code/game/objects/items/weapons/material/kitchen.dm
#	code/game/objects/items/weapons/material/misc.dm
#	code/game/objects/items/weapons/material/swords.dm
#	code/game/objects/items/weapons/melee/energy.dm
#	code/game/objects/items/weapons/melee/misc.dm
#	code/game/objects/items/weapons/scrolls.dm
#	code/game/objects/items/weapons/storage/belt.dm
#	code/game/objects/items/weapons/stunbaton.dm
#	code/game/objects/items/weapons/tools.dm
#	code/game/objects/objs.dm
#	code/game/objects/structures/crates_lockers/closets.dm
#	code/game/objects/structures/crates_lockers/closets/secure/security.dm
#	code/game/objects/structures/janicart.dm
#	code/game/sound.dm
#	code/game/turfs/simulated.dm
#	code/game/verbs/ooc.dm
#	code/global.dm
#	code/modules/admin/verbs/debug.dm
#	code/modules/admin/verbs/modifyvariables.dm
#	code/modules/client/client procs.dm
#	code/modules/client/preferences.dm
#	code/modules/clothing/clothing.dm
#	code/modules/clothing/head/hardhat.dm
#	code/modules/clothing/head/helmet.dm
#	code/modules/clothing/head/jobs.dm
#	code/modules/clothing/head/misc_special.dm
#	code/modules/clothing/shoes/jobs.dm
#	code/modules/clothing/spacesuits/alien.dm
#	code/modules/clothing/spacesuits/captain.dm
#	code/modules/clothing/spacesuits/miscellaneous.dm
#	code/modules/clothing/spacesuits/rig/rig_pieces.dm
#	code/modules/clothing/spacesuits/rig/suits/alien.dm
#	code/modules/clothing/spacesuits/spacesuits.dm
#	code/modules/clothing/spacesuits/void/merc.dm
#	code/modules/clothing/spacesuits/void/void.dm
#	code/modules/clothing/suits/armor.dm
#	code/modules/clothing/suits/jobs.dm
#	code/modules/clothing/suits/storage.dm
#	code/modules/clothing/suits/utility.dm
#	code/modules/clothing/suits/wiz_robe.dm
#	code/modules/clothing/under/jobs/security.dm
#	code/modules/economy/Events.dm
#	code/modules/economy/Events_Mundane.dm
#	code/modules/economy/economy_misc.dm
#	code/modules/events/blob.dm
#	code/modules/events/event.dm
#	code/modules/events/event_container.dm
#	code/modules/events/event_manager.dm
#	code/modules/events/money_lotto.dm
#	code/modules/events/prison_break.dm
#	code/modules/events/spacevine.dm
#	code/modules/hydroponics/trays/tray.dm
#	code/modules/mob/dead/observer/observer.dm
#	code/modules/mob/emote.dm
#	code/modules/mob/holder.dm
#	code/modules/mob/language/station.dm
#	code/modules/mob/living/bot/cleanbot.dm
#	code/modules/mob/living/carbon/alien/diona/diona.dm
#	code/modules/mob/living/carbon/alien/diona/diona_attacks.dm
#	code/modules/mob/living/carbon/give.dm
#	code/modules/mob/living/carbon/human/emote.dm
#	code/modules/mob/living/carbon/human/human.dm
#	code/modules/mob/living/carbon/human/human_defense.dm
#	code/modules/mob/living/carbon/human/inventory.dm
#	code/modules/mob/living/carbon/human/life.dm
#	code/modules/mob/living/carbon/human/species/outsider/vox.dm
#	code/modules/mob/living/carbon/human/species/station/golem.dm
#	code/modules/mob/living/carbon/human/species/station/station.dm
#	code/modules/mob/living/carbon/human/update_icons.dm
#	code/modules/mob/living/carbon/metroid/metroid.dm
#	code/modules/mob/living/living.dm
#	code/modules/mob/living/living_defense.dm
#	code/modules/mob/living/living_defines.dm
#	code/modules/mob/living/silicon/ai/ai.dm
#	code/modules/mob/living/silicon/pai/admin.dm
#	code/modules/mob/living/silicon/pai/pai.dm
#	code/modules/mob/living/silicon/robot/drone/drone.dm
#	code/modules/mob/living/silicon/robot/drone/drone_manufacturer.dm
#	code/modules/mob/living/silicon/robot/emote.dm
#	code/modules/mob/living/silicon/robot/robot_items.dm
#	code/modules/mob/living/silicon/robot/robot_modules.dm
#	code/modules/mob/living/silicon/silicon.dm
#	code/modules/mob/living/simple_animal/bees.dm
#	code/modules/mob/living/simple_animal/friendly/cat.dm
#	code/modules/mob/living/simple_animal/friendly/corgi.dm
#	code/modules/mob/living/simple_animal/friendly/farm_animals.dm
#	code/modules/mob/living/simple_animal/friendly/mouse.dm
#	code/modules/mob/living/simple_animal/friendly/spiderbot.dm
#	code/modules/mob/living/simple_animal/hostile/hostile.dm
#	code/modules/mob/living/simple_animal/simple_animal.dm
#	code/modules/mob/logout.dm
#	code/modules/mob/mob.dm
#	code/modules/mob/mob_grab_specials.dm
#	code/modules/mob/mob_helpers.dm
#	code/modules/mob/new_player/sprite_accessories.dm
#	code/modules/organs/organ.dm
#	code/modules/organs/organ_alien.dm
#	code/modules/organs/organ_external.dm
#	code/modules/paperwork/faxmachine.dm
#	code/modules/projectiles/ammunition/boxes.dm
#	code/modules/projectiles/ammunition/bullets.dm
#	code/modules/projectiles/guns/energy/nuclear.dm
#	code/modules/projectiles/guns/energy/rifle.dm
#	code/modules/projectiles/guns/energy/special.dm
#	code/modules/projectiles/guns/projectile.dm
#	code/modules/projectiles/guns/projectile/automatic.dm
#	code/modules/projectiles/guns/projectile/pistol.dm
#	code/modules/projectiles/guns/projectile/revolver.dm
#	code/modules/projectiles/guns/projectile/shotgun.dm
#	code/modules/projectiles/projectile/bullets.dm
#	code/modules/projectiles/projectile/special.dm
#	code/modules/reagents/reagent_containers.dm
#	code/modules/reagents/reagent_containers/food/drinks.dm
#	code/modules/research/designs.dm
#	code/modules/research/destructive_analyzer.dm
#	code/modules/research/rdconsole.dm
#	code/modules/spells/artifacts.dm
#	code/modules/spells/spellbook.dm
#	code/modules/tables/tables.dm
#	code/world.dm
#	config/example/config.txt
#	icons/mob/items_lefthand.dmi
#	icons/mob/items_righthand.dmi
#	icons/obj/lighting.dmi
2016-10-31 00:01:52 +02:00

264 lines
8.8 KiB
Plaintext

var/list/obj/machinery/photocopier/faxmachine/allfaxes = list()
var/list/admin_departments = list("[boss_name]", "Sol Government", "Supply")
var/list/alldepartments = list()
var/list/arrived_faxes = list() //cache for faxes that have been sent to the admins
var/list/sent_faxes = list() //cache for faxes that have been sent by the 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.
density = 0//It's a small machine that sits on a table, this allows small things to walk under that table
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 = null // the department we're sending to
var/list/obj/item/device/pda/alert_pdas = list() //A list of PDAs to alert upon arrival of the fax.
/obj/machinery/photocopier/faxmachine/New()
..()
allfaxes += src
if(!destination) destination = "[boss_name]"
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<BR>"
var/scan_name
if(scan)
scan_name = scan.name
else
scan_name = "--------"
dat += "Confirm Identity: <a href='byond://?src=\ref[src];scan=1'>[scan_name]</a><br>"
if(authenticated)
dat += "<a href='byond://?src=\ref[src];logout=1'>{Log Out}</a>"
else
dat += "<a href='byond://?src=\ref[src];auth=1'>{Log In}</a>"
dat += "<hr>"
if(authenticated)
dat += "<b>Logged in to:</b> [boss_name] Quantum Entanglement Network<br><br>"
if(copyitem)
dat += "<a href='byond://?src=\ref[src];remove=1'>Remove Item</a><br><br>"
if(sendcooldown)
dat += "<b>Transmitter arrays realigning. Please stand by.</b><br>"
else
dat += "<a href='byond://?src=\ref[src];send=1'>Send</a><br>"
dat += "<b>Currently sending:</b> [copyitem.name]<br>"
dat += "<b>Sending to:</b> <a href='byond://?src=\ref[src];dept=1'>[destination]</a><br>"
else
if(sendcooldown)
dat += "Please insert paper to send via secure connection.<br><br>"
dat += "<b>Transmitter arrays realigning. Please stand by.</b><br>"
else
dat += "Please insert paper to send via secure connection.<br><br>"
else
dat += "Proper authentication is required to use this device.<br><br>"
if(copyitem)
dat += "<a href ='byond://?src=\ref[src];remove=1'>Remove Item</a><br>"
dat += "<br>PDAs to notify:<br>"
if (alert_pdas && alert_pdas.len)
for (var/obj/item/device/pda/pda in alert_pdas)
dat += "[alert_pdas[pda]] - <a href='byond://?src=\ref[src];unlink=\ref[pda]'>Unlink</a><br>"
dat += "<br><a href='byond://?src=\ref[src];linkpda=1'>Add PDA to Notify</a>"
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 = loc
if (get_dist(usr, src) < 2)
usr.put_in_hands(copyitem)
usr << "<span class='notice'>You take \the [copyitem] out of \the [src].</span>"
else
usr << "<span class='notice'>You eject \the [copyitem] from \the [src].</span>"
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.unEquip(I))
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
if(href_list["linkpda"])
var/obj/item/device/pda/pda = usr.get_active_hand()
if (!pda || !istype(pda))
usr << "<span class='warning'>You need to be holding a PDA to link it.</span>"
else if (pda in alert_pdas)
usr << "<span class='notice'>\The [pda] appears to be already linked.</span>"
//Update the name real quick.
alert_pdas[pda] = pda.name
else
alert_pdas += pda
alert_pdas[pda] = pda.name
usr << "<span class='notice'>You link \the [pda] to \the [src]. It will now ping upon the arrival of a fax to this machine.</span>"
if(href_list["unlink"])
var/obj/item/device/pda/pda = locate(href_list["unlink"])
if (pda && istype(pda))
if (pda in alert_pdas)
usr << "<span class='notice'>You unlink [alert_pdas[pda]] from \the [src]. It will no longer be notified of new faxes.</span>"
alert_pdas -= pda
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"
if (!istype(incoming, /obj/item/weapon/paper) && !istype(incoming, /obj/item/weapon/photo) && !istype(incoming, /obj/item/weapon/paper_bundle))
return 0
flick("faxreceive", src)
playsound(loc, "sound/items/polaroid1.ogg", 50, 1)
// give the sprite some time to flick
spawn(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)
do_pda_alerts()
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, 0)
else
visible_message("[src] beeps, \"Error transmitting message.\"")
return
rcvdcopy.loc = null //hopefully this shouldn't cause trouble
arrived_faxes += rcvdcopy
//message badmins that a fax has arrived
switch(destination)
if (boss_name)
message_admins(sender, "[uppertext(boss_short)] 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 <b><font color='[font_colour]'>[faxname]: </font>[key_name(sender, 1)] (<A HREF='?_src_=holder;adminplayeropts=\ref[sender]'>PP</A>) (<A HREF='?_src_=vars;Vars=\ref[sender]'>VV</A>) (<A HREF='?_src_=holder;subtlemessage=\ref[sender]'>SM</A>) (<A HREF='?_src_=holder;adminplayerobservejump=\ref[sender]'>JMP</A>) (<A HREF='?_src_=holder;secretsadmin=check_antagonist'>CA</A>) (<a href='?_src_=holder;[reply_type]=\ref[src];faxMachine=\ref[src]'>REPLY</a>)</b>: Receiving '[sent.name]' via secure connection ... <a href='?_src_=holder;AdminFaxView=\ref[sent]'>view message</a>"
for(var/client/C in admins)
if((R_ADMIN|R_CCIAA) & C.holder.rights)
C << msg
discord_bot.send_to_cciaa("New fax arrived! [faxname]: \"[sent.name]\" by [sender].")
/obj/machinery/photocopier/faxmachine/proc/do_pda_alerts()
if (!alert_pdas || !alert_pdas.len)
return
for (var/obj/item/device/pda/pda in alert_pdas)
if (pda.toff || pda.message_silent)
continue
var/message = "New fax has arrived at [src.department] fax machine."
pda.new_info(pda.message_silent, pda.ttone, "\icon[pda] <b>[message]</b>")