diff --git a/code/WorkInProgress/Chinsky/guestpass.dm b/code/WorkInProgress/Chinsky/guestpass.dm new file mode 100644 index 00000000000..1e2f3b8a957 --- /dev/null +++ b/code/WorkInProgress/Chinsky/guestpass.dm @@ -0,0 +1,182 @@ +///////////////////////////////////////////// +//Guest pass //////////////////////////////// +///////////////////////////////////////////// +/obj/item/weapon/card/id/guest + name = "guest pass" + desc = "Allows temporary access to station areas." + icon_state = "guest" + + var/temp_access = list() //to prevent agent cards stealing access as permanent + var/expiration_time = 0 + var/reason = "NOT SPECIFIED" + +/obj/item/weapon/card/id/guest/GetAccess() + if (world.time > expiration_time) + return access + else + return temp_access + +/obj/item/weapon/card/id/guest/examine() + ..() + if (world.time < expiration_time) + usr << "\blue This pass expires at [worldtime2text(expiration_time)]." + else + usr << "\red It expired at [worldtime2text(expiration_time)]." + +/obj/item/weapon/card/id/guest/read() + if (world.time > expiration_time) + usr << "This pass expired at [worldtime2text(expiration_time)]." + else + usr << "This pass expires at [worldtime2text(expiration_time)]." + + usr << "It grants access to following areas:" + for (var/A in temp_access) + usr << "[get_access_desc(A)]." + usr << "Issuing reason: [reason]." + return + +///////////////////////////////////////////// +//Guest pass terminal//////////////////////// +///////////////////////////////////////////// + +/obj/machinery/computer/guestpass + name = "guest pass terminal" + icon_state = "guest" + density = 0 + + + var/obj/item/weapon/card/id/giver + var/list/accesses = list() + var/giv_name = "NOT SPECIFIED" + var/reason = "NOT SPECIFIED" + var/duration = 0 + + var/list/internal_log = list() + var/mode = 0 // 0 - making pass, 1 - viewing logs + +/obj/machinery/computer/guestpass/attackby(obj/O, mob/user) + if(istype(O, /obj/item/weapon/card/id)) + user.drop_item() + O.loc = src + giver = O + updateUsrDialog() + +/obj/machinery/computer/guestpass/attack_ai(var/mob/user as mob) + return attack_hand(user) + +/obj/machinery/computer/guestpass/attack_paw(var/mob/user as mob) + return attack_hand(user) + +/obj/machinery/computer/guestpass/attack_hand(var/mob/user as mob) + if(..()) + return + + user.set_machine(src) + var/dat + + if (mode == 1) //Logs + dat += "

Activity log


" + for (var/entry in internal_log) + dat += "[entry]

" + dat += "Print
" + dat += "Back
" + else + dat += "

Guest pass terminal #[uid]


" + dat += "View activity log

" + dat += "Issuing ID: [giver]
" + dat += "Issued to: [giv_name]
" + dat += "Reason: [reason]
" + dat += "Duration (minutes): [duration] m
" + dat += "Access to areas:
" + if (giver && giver.access) + for (var/A in giver.access) + var/area = get_access_desc(A) + if (A in accesses) + area = "[area]" + dat += "[area]
" + dat += "
Issue pass
" + + user << browse(dat, "window=guestpass;size=400x520") + onclose(user, "guestpass") + + +/obj/machinery/computer/guestpass/Topic(href, href_list) + if(..()) + return + usr.set_machine(src) + if (href_list["mode"]) + mode = text2num(href_list["mode"]) + + if (href_list["choice"]) + switch(href_list["choice"]) + if ("giv_name") + var/nam = input("Person pass is issued to", "Name", name) + if (nam) + giv_name = nam + if ("reason") + var/reas = input("Reason why pass is issued", "Reason", reason) + reason = reas + if ("duration") + var/dur = input("Duration (in minutes) during which pass is valid.", "Duration") as num + if (dur > 0 && dur < 30) + duration = dur + else + usr << "\red Invalid duration." + if ("access") + var/A = text2num(href_list["access"]) + if (A in accesses) + accesses.Remove(A) + else + accesses.Add(A) + if (href_list["action"]) + switch(href_list["action"]) + if ("id") + if (giver) + if(ishuman(usr)) + giver.loc = usr.loc + if(!usr.get_active_hand()) + usr.put_in_hands(giver) + giver = null + else + giver.loc = src.loc + giver = null + else + var/obj/item/I = usr.get_active_hand() + if (istype(I, /obj/item/weapon/card/id)) + usr.drop_item() + I.loc = src + giver = I + updateUsrDialog() + + if ("print") + var/dat = "

Activity log of guest pass terminal #[uid]


" + for (var/entry in internal_log) + dat += "[entry]

" + //usr << "Printing the log, standby..." + //sleep(50) + var/obj/item/weapon/paper/P = new/obj/item/weapon/paper( loc ) + P.name = "activity log" + P.info = dat + + if ("issue") + if (giver) + var/number = add_zero("[rand(0,9999)]", 4) + var/entry = "\[[worldtime2text()]\] Pass #[number] issued by [giver.registered_name] ([giver.assignment]) to [giv_name]. Reason: [reason]. Grants access to following areas: " + for (var/i=1 to accesses.len) + var/A = accesses[i] + if (A) + var/area = get_access_desc(A) + entry += "[i > 1 ? ", [area]" : "[area]"]" + entry += ". Expires at [worldtime2text(world.time + duration*10*60)]." + internal_log.Add(entry) + + var/obj/item/weapon/card/id/guest/pass = new(src.loc) + pass.temp_access = accesses.Copy() + pass.registered_name = giv_name + pass.expiration_time = world.time + duration*10*60 + pass.reason = reason + pass.name = "guest pass #[number]" + else + usr << "\red Cannot issue pass without issuing ID." + updateUsrDialog() + return \ No newline at end of file diff --git a/icons/obj/card.dmi b/icons/obj/card.dmi index dce5f9ce954..d304ba2e277 100644 Binary files a/icons/obj/card.dmi and b/icons/obj/card.dmi differ diff --git a/icons/obj/computer.dmi b/icons/obj/computer.dmi index 932d4b60f33..7aecafe3533 100644 Binary files a/icons/obj/computer.dmi and b/icons/obj/computer.dmi differ