From b14535344b3dfbfed454b99a7925e26ce4aea783 Mon Sep 17 00:00:00 2001 From: scoopscoop Date: Tue, 12 Aug 2014 13:56:02 +0300 Subject: [PATCH] Rewrote request console code to use a proc when generating a message on a target console Redemption machine now sends a message to chemistry, too. --- code/game/machinery/requests_console.dm | 128 +++++++++--------------- code/modules/mining/equipment_locker.dm | 4 +- 2 files changed, 50 insertions(+), 82 deletions(-) diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm index 1819ea14e26..807fbe30d1f 100644 --- a/code/game/machinery/requests_console.dm +++ b/code/game/machinery/requests_console.dm @@ -312,49 +312,11 @@ var/list/obj/machinery/requests_console/allConsoles = list() if (ckey(Console.department) == ckey(href_list["department"])) switch(priority) if(2) //High priority - if(Console.newmessagepriority < 2) - Console.newmessagepriority = 2 - Console.update_icon() - if(!Console.silent) - playsound(Console.loc, 'sound/machines/twobeep.ogg', 50, 1) - for (var/mob/O in hearers(5, Console.loc)) - O.show_message("\icon[Console] *The Requests Console beeps: 'PRIORITY Alert in [department]'") - Console.messages += "High Priority
From: [department]
[sending]" - var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(Console.loc) - // Same message, but without the hyperlink. - slip.info = "High Priority
From: [department]
[sending]" - slip.name = "Priority Request - [department]" - + Console.createmessage(src, "PRIORITY Alert in [department]", sending, 2, 1) if(3) // Extreme Priority - if(Console.newmessagepriority < 3) - Console.newmessagepriority = 3 - Console.update_icon() - if(1) // This is EXTREMELY important, so beep. - playsound(Console.loc, 'sound/machines/twobeep.ogg', 50, 1) - for (var/mob/O in hearers(7, Console.loc)) - O.show_message("\icon[Console] *The Requests Console yells: 'EXTREME PRIORITY alert in [department]'") - Console.messages += "!!!Extreme Priority!!!
From: [department]
[sending]" - var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(Console.loc) - // Same message, but without the hyperlink. - slip.info = "!!!Extreme Priority!!!
From: [department]
[sending]" - slip.name = "EXTREME Request - [department]" - var/mob/living/target = locate() in view(7,Console) - if(target) - Console.visible_message("[Console] launches [slip] at [target]!") - slip.throw_at(target, 16, 3) - + Console.createmessage(src, "EXTREME PRIORITY Alert in [department]", sending, 3, 1) else // Normal priority - if(Console.newmessagepriority < 1) - Console.newmessagepriority = 1 - Console.update_icon() - if(!Console.silent) - playsound(Console.loc, 'sound/machines/twobeep.ogg', 50, 1) - for (var/mob/O in hearers(4, Console.loc)) - O.show_message("\icon[Console] *The Requests Console beeps: 'Message from [department]'") - Console.messages += "From: [department]
[sending]" - var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(Console.loc) - slip.info = "From: [department]
[sending]" - slip.name = "Request Slip - [department]" + Console.createmessage(src, "Message from [department]", sending, 1, 1) screen = 6 Console.luminosity = 2 @@ -410,59 +372,65 @@ var/list/obj/machinery/requests_console/allConsoles = list() updateUsrDialog() return -/obj/machinery/requests_console/proc/createmessage(source, title, message, priority, paper) //generate one-way message, from 'source' - var/obj/machinery/requests_console/Console = src - var/sending = message - capitalize(source) +/obj/machinery/requests_console/proc/createmessage(source, title, message, priority, paper) + var/linkedsender + var/unlinkedsender + if(istype(source, /obj/machinery/requests_console)) + var/obj/machinery/requests_console/sender = source + linkedsender = "[sender.department]" + unlinkedsender = sender.department + else + capitalize(source) + linkedsender = source + unlinkedsender = source capitalize(title) - sending += "
" switch(priority) if(2) //High priority - if(Console.newmessagepriority < 2) - Console.newmessagepriority = 2 - Console.update_icon() - if(!Console.silent) - playsound(Console.loc, 'sound/machines/twobeep.ogg', 50, 1) - for (var/mob/O in hearers(5, Console.loc)) - O.show_message("\icon[Console] *The Requests Console beeps: '[title]'") - Console.messages += "High Priority
From: [source]>
[sending]" + if(src.newmessagepriority < 2) + src.newmessagepriority = 2 + src.update_icon() + if(!src.silent) + playsound(src.loc, 'sound/machines/twobeep.ogg', 50, 1) + for (var/mob/O in hearers(5, src.loc)) + O.show_message("\icon[src] *The Requests Console beeps: '[title]'") + src.messages += "High Priority
From: [linkedsender]
[message]" if(paper) - var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(Console.loc) - slip.info = "High Priority
From: [source]
[sending]" + var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(src.loc) + slip.info = "High Priority
From: [unlinkedsender]
[message]" slip.name = "Important Message - [source]" if(3) // Extreme Priority - if(Console.newmessagepriority < 3) - Console.newmessagepriority = 3 - Console.update_icon() + if(src.newmessagepriority < 3) + src.newmessagepriority = 3 + src.update_icon() if(1) - playsound(Console.loc, 'sound/machines/twobeep.ogg', 50, 1) - for (var/mob/O in hearers(7, Console.loc)) - O.show_message("\icon[Console] *The Requests Console yells: '[title]'") - Console.messages += "!!!Extreme Priority!!!
From: [source]
[sending]" - var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(Console.loc) + playsound(src.loc, 'sound/machines/twobeep.ogg', 50, 1) + for (var/mob/O in hearers(7, src.loc)) + O.show_message("\icon[src] *The Requests Console yells: '[title]'") + src.messages += "!!!Extreme Priority!!!
From: [linkedsender]
[message]" + var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(src.loc) if(paper) - slip.info = "!!!Extreme Priority!!!
From: [source]
[sending]" - slip.name = "URGENT message - [source]" - var/mob/living/target = locate() in view(7,Console) + slip.info = "!!!Extreme Priority!!!
From: [unlinkedsender]
[message]" + slip.name = "URGENT message - [unlinkedsender]" + var/mob/living/target = locate() in view(7,src) if(target) - Console.visible_message("[Console] launches [slip] at [target]!") + src.visible_message("[src] launches [slip] at [target]!") slip.throw_at(target, 16, 3) else // Normal priority - if(Console.newmessagepriority < 1) - Console.newmessagepriority = 1 - Console.update_icon() - if(!Console.silent) - playsound(Console.loc, 'sound/machines/twobeep.ogg', 50, 1) - for (var/mob/O in hearers(4, Console.loc)) - O.show_message("\icon[Console] *The Requests Console beeps: '[title]'") - Console.messages += "From: [source]
[sending]" + if(src.newmessagepriority < 1) + src.newmessagepriority = 1 + src.update_icon() + if(!src.silent) + playsound(src.loc, 'sound/machines/twobeep.ogg', 50, 1) + for (var/mob/O in hearers(4, src.loc)) + O.show_message("\icon[src] *The Requests Console beeps: '[title]'") + src.messages += "From: [linkedsender]
[message]" if(paper) - var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(Console.loc) - slip.info = "From: [source]
[sending]" - slip.name = "Message - [source]" - Console.luminosity = 2 + var/obj/item/weapon/paper/slip = new /obj/item/weapon/paper(src.loc) + slip.info = "From: [unlinkedsender]
[message]" + slip.name = "Message - [unlinkedsender]" + src.luminosity = 2 /obj/machinery/requests_console/attackby(var/obj/item/weapon/O as obj, var/mob/user as mob) if (istype(O, /obj/item/weapon/crowbar)) diff --git a/code/modules/mining/equipment_locker.dm b/code/modules/mining/equipment_locker.dm index f2a7fedcae4..aa118b234d1 100644 --- a/code/modules/mining/equipment_locker.dm +++ b/code/modules/mining/equipment_locker.dm @@ -36,8 +36,8 @@ stack_list[processed_sheet] = s if(s.name != "glass" && s.name != "metal") //we can get these from cargo anyway var/msg = "[capitalize(s.name)] sheets are now available in the Cargo Bay." - for(var/obj/machinery/requests_console/D in world) //this will only happen a few times per round - if(D.department == "Science" || D.department == "Robotics" || D.department == "Research Director's Desk") + for(var/obj/machinery/requests_console/D in allConsoles) + if(D.department == "Science" || D.department == "Robotics" || D.department == "Research Director's Desk" || (D.department == "Chemistry" && (s.name == "uranium" || s.name == "solid plasma"))) D.createmessage("Ore Redemption Machine", "New minerals available!", msg, 1, 0) var/obj/item/stack/sheet/storage = stack_list[processed_sheet] storage.amount += 1 //Stack the sheets