From f949f125e49e50140af011ed576e1a7a3ca7a866 Mon Sep 17 00:00:00 2001 From: "baloh.matevz@gmail.com" Date: Wed, 7 Dec 2011 00:55:20 +0000 Subject: [PATCH] Command intercept will now only increase the security level if it's lower than blue... Added a keycard authentication device. When you interact with it it asks you which event you'd like to trigger, currently only "Red alert". When you select the event, it asks you to swipe your ID card. If you have the new keycard auth access (60) on it (all heads of staff do), it will trigger all other devices of the same type to flash for 2 seconds. If someone with the same access level on their card swipes their card on another device during this period, the event will happen. The idea behind this is the two key idea from submarine movies - just with ID cards. Admins are informed who requests the event and who triggers it btw, so abusing this is a bad idea. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@2635 316c924e-a436-60f5-8080-3fe189b3f50e --- .../security levels/keycard authentication.dm | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 code/modules/security levels/keycard authentication.dm diff --git a/code/modules/security levels/keycard authentication.dm b/code/modules/security levels/keycard authentication.dm new file mode 100644 index 00000000000..55a1172b3b6 --- /dev/null +++ b/code/modules/security levels/keycard authentication.dm @@ -0,0 +1,143 @@ +/obj/machinery/keycard_auth + name = "Keycard Authentication Device" + desc = "This device is used to trigger station functions, which require more than one ID card to authenticate." + icon = 'monitors.dmi' + icon_state = "auth_off" + var/active = 0 //This gets set to 1 on all devices except the one where the initial request was made. + var/event = "" + var/screen = 1 + var/confirmed = 0 //This variable is set by the device that confirms the request. + var/confirm_delay = 20 //(2 seconds) + var/busy = 0 //Busy when waiting for authentication or an event request has been sent from this device. + var/obj/machinery/keycard_auth/event_source + var/mob/event_triggered_by + var/mob/event_confirmed_by + //1 = select event + //2 = authenticate + anchored = 1.0 + use_power = 1 + idle_power_usage = 2 + active_power_usage = 6 + power_channel = ENVIRON + +/obj/machinery/keycard_auth/attack_ai(mob/user as mob) + user << "The station AI is not to interact with these devices" + return + +/obj/machinery/keycard_auth/attack_paw(mob/user as mob) + user << "You are too primitive to use this device" + return + +/obj/machinery/keycard_auth/attackby(obj/item/weapon/W as obj, mob/user as mob) + if(stat & (NOPOWER|BROKEN)) + user << "This device is not powered." + return + if(istype(W,/obj/item/weapon/card/id)) + var/obj/item/weapon/card/id/ID = W + if(access_keycard_auth in ID.access) + if(active == 1) + //This is not the device that made the initial request. It is the device confirming the request. + if(event_source) + event_source.confirmed = 1 + event_source.event_confirmed_by = usr + else if(screen == 2) + event_triggered_by = usr + broadcast_request() //This is the device making the initial event request. It needs to broadcast to other devices + +/obj/machinery/keycard_auth/power_change() + if(powered(ENVIRON)) + stat &= ~NOPOWER + icon_state = "auth_off" + else + stat |= NOPOWER + +/obj/machinery/keycard_auth/attack_hand(mob/user as mob) + if(user.stat || stat & (NOPOWER|BROKEN)) + user << "This device is not powered." + return + if (busy) + user << "This device is busy" + return + + user.machine = src + + var/dat = "

Keycard Authentication Device

" + + dat += "This device is used to trigger some high security events. It requires the simultaneous swipe of two high-level ID cards" + dat += "


" + + if ( screen == 1 ) + dat += "Select an event to trigger:" + user << browse(dat, "window=keycard_auth;size=500x250") + if ( screen == 2 ) + dat += "Please swipe your card to authorize the following event: [event]" + dat += "

Back" + user << browse(dat, "window=keycard_auth;size=500x250") + return + + +/obj/machinery/keycard_auth/Topic(href, href_list) + ..() + if (busy) + usr << "This device is busy" + return + if (usr.stat || stat & (BROKEN|NOPOWER)) + usr << "This device is without power" + return + if (href_list["triggerevent"]) + event = href_list["triggerevent"] + screen = 2 + if (href_list["reset"]) + reset() + + src.updateUsrDialog() + src.add_fingerprint(usr) + return + +/obj/machinery/keycard_auth/proc/reset() + active = 0 + event = "" + screen = 1 + confirmed = 0 + event_source = null + icon_state = "auth_off" + event_triggered_by = null + event_confirmed_by = null + +/obj/machinery/keycard_auth/proc/broadcast_request() + icon_state = "auth_on" + for(var/obj/machinery/keycard_auth/KA in world) + if(KA == src) continue + KA.reset() + spawn() + KA.receive_request(src) + + sleep(confirm_delay) + if(confirmed) + confirmed = 0 + trigger_event(event) + log_game("[key_name(event_triggered_by)] triggered and [key_name(event_confirmed_by)] confirmed event [event]") + message_admins("[key_name(event_triggered_by)] triggered and [key_name(event_confirmed_by)] confirmed event [event]", 1) + reset() + +/obj/machinery/keycard_auth/proc/receive_request(var/obj/machinery/keycard_auth/source) + if(stat & (BROKEN|NOPOWER)) + return + event_source = source + busy = 1 + active = 1 + icon_state = "auth_on" + + sleep(confirm_delay) + + event_source = null + icon_state = "auth_off" + active = 0 + busy = 0 + +/obj/machinery/keycard_auth/proc/trigger_event() + switch(event) + if("Red alert") + set_security_level(SEC_LEVEL_RED) \ No newline at end of file