From f8ff7a551072d0a2f89df4cd3cc08f554e619fc5 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Wed, 16 Jul 2014 16:02:10 +0200 Subject: [PATCH 1/3] Allows the AI to select which channel to state laws on. --- code/modules/mob/living/silicon/ai/ai.dm | 9 ++++++ code/modules/mob/living/silicon/ai/laws.dm | 32 ++++++++++++---------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 44da5d74af6..62a00326189 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -27,6 +27,7 @@ var/list/ai_list = list() var/viewalerts = 0 var/lawcheck[1] var/ioncheck[1] + var/lawchannel = "Common" // Default channel on which to state laws var/icon/holo_icon//Default is assigned when AI is created. var/obj/item/device/pda/ai/aiPDA = null var/obj/item/device/multitool/aiMulti = null @@ -390,6 +391,14 @@ var/list/ai_list = list() // src << text ("Switching Law [L]'s report status to []", lawcheck[L+1]) checklaws() + if (href_list["lawr"]) // Selects on which channel to state laws + var/setchannel = input(usr, "Specify channel.", "Channel selection") in list("State","Common","Science","Command","Medical","Engineering","Security","Supply","Cancel") + if(setchannel == "Cancel") + return + lawchannel = setchannel + + checklaws() + //Uncomment this line of code if you are enabling the AI Vocal (VOX) announcements. /* if(href_list["say_word"]) diff --git a/code/modules/mob/living/silicon/ai/laws.dm b/code/modules/mob/living/silicon/ai/laws.dm index 904451aa1dc..b4c9db3fcd5 100755 --- a/code/modules/mob/living/silicon/ai/laws.dm +++ b/code/modules/mob/living/silicon/ai/laws.dm @@ -51,24 +51,28 @@ src.laws_sanity_check() src.laws.clear_supplied_laws() - - - - /mob/living/silicon/ai/proc/statelaws() // -- TLE // set category = "AI Commands" // set name = "State Laws" - src.say("Current Active Laws:") + /var/prefix = "" + switch(lawchannel) + if("Common") prefix = ";" + if("Science") prefix = ":n " + if("Command") prefix = ":c " + if("Medical") prefix = ":m " + if("Engineering") prefix = ":e " + if("Security") prefix = ":s " + if("Supply") prefix = ":u " + + src.say("[prefix]Current Active Laws:") //src.laws_sanity_check() //src.laws.show_laws(world) var/number = 1 sleep(10) - - if (src.laws.zeroth) if (src.lawcheck[1] == "Yes") //This line and the similar lines below make sure you don't state a law unless you want to. --NeoFite - src.say("0. [src.laws.zeroth]") + src.say("[prefix]0. [src.laws.zeroth]") sleep(10) for (var/index = 1, index <= src.laws.ion.len, index++) @@ -76,7 +80,7 @@ var/num = ionnum() if (length(law) > 0) if (src.ioncheck[index] == "Yes") - src.say("[num]. [law]") + src.say("[prefix][num]. [law]") sleep(10) for (var/index = 1, index <= src.laws.inherent.len, index++) @@ -84,22 +88,20 @@ if (length(law) > 0) if (src.lawcheck[index+1] == "Yes") - src.say("[number]. [law]") + src.say("[prefix][number]. [law]") sleep(10) number++ - for (var/index = 1, index <= src.laws.supplied.len, index++) var/law = src.laws.supplied[index] if (length(law) > 0) if(src.lawcheck.len >= number+1) if (src.lawcheck[number+1] == "Yes") - src.say("[number]. [law]") + src.say("[prefix][number]. [law]") sleep(10) number++ - /mob/living/silicon/ai/verb/checklaws() //Gives you a link-driven interface for deciding what laws the statelaws() proc will share with the crew. --NeoFite set category = "AI Commands" set name = "State Laws" @@ -144,6 +146,8 @@ src.lawcheck[number+1] = "Yes" list += {"[src.lawcheck[number+1]] [number]: [law]
"} number++ - list += {"

State Laws"} + + list += {"
Channel: [src.lawchannel]
"} + list += {"State Laws"} usr << browse(list, "window=laws") \ No newline at end of file From 7f16a352657876271128d0a391faf288f6d47e36 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Wed, 16 Jul 2014 16:45:48 +0200 Subject: [PATCH 2/3] Adds the binary channel as a potential statement target. --- code/modules/mob/living/silicon/ai/ai.dm | 2 +- code/modules/mob/living/silicon/ai/laws.dm | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 62a00326189..3f070046d57 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -392,7 +392,7 @@ var/list/ai_list = list() checklaws() if (href_list["lawr"]) // Selects on which channel to state laws - var/setchannel = input(usr, "Specify channel.", "Channel selection") in list("State","Common","Science","Command","Medical","Engineering","Security","Supply","Cancel") + var/setchannel = input(usr, "Specify channel.", "Channel selection") in list("State","Common","Science","Command","Medical","Engineering","Security","Supply","Binary","Cancel") if(setchannel == "Cancel") return lawchannel = setchannel diff --git a/code/modules/mob/living/silicon/ai/laws.dm b/code/modules/mob/living/silicon/ai/laws.dm index b4c9db3fcd5..cc74d6f4da1 100755 --- a/code/modules/mob/living/silicon/ai/laws.dm +++ b/code/modules/mob/living/silicon/ai/laws.dm @@ -63,6 +63,7 @@ if("Engineering") prefix = ":e " if("Security") prefix = ":s " if("Supply") prefix = ":u " + if("Binary") prefix = ":b " src.say("[prefix]Current Active Laws:") //src.laws_sanity_check() From dfcf25ce496b7d457b67c7c654e4c0f46746f207 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Thu, 17 Jul 2014 12:43:41 +0200 Subject: [PATCH 3/3] Allows the AI to state laws over the holopad. Modifies say-code to return true on success. Say-code updated to return true on success. This allows for quitting early when stating laws without having to duplicating the checks made in the say-code. --- code/modules/mob/living/say.dm | 11 +++++---- code/modules/mob/living/silicon/ai/ai.dm | 3 +-- code/modules/mob/living/silicon/ai/laws.dm | 6 ++++- code/modules/mob/living/silicon/ai/say.dm | 5 ++-- code/modules/mob/living/silicon/say.dm | 27 ++++++++++++---------- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index 2e819928262..97920c22049 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -93,7 +93,7 @@ var/list/department_radio_keys = list( if (speaking.flags & SIGNLANG) say_signlang(message, pick(speaking.signlang_verb), speaking) - return + return 1 //speaking into radios if(used_radios.len) @@ -116,13 +116,13 @@ var/list/department_radio_keys = list( if(pressure < SAY_MINIMUM_PRESSURE) italics = 1 message_range = 1 - + if (speech_sound) sound_vol *= 0.5 //muffle the sound a bit, so it's like we're actually talking through contact var/list/listening = list() var/list/listening_obj = list() - + if(T) var/list/hear = hear(message_range, T) var/list/hearturfs = list() @@ -144,7 +144,7 @@ var/list/department_radio_keys = list( var/obj/O = I hearturfs += O.locs[1] listening_obj |= O - + for(var/mob/M in player_list) if(M.stat == DEAD && M.client && (M.client.prefs.toggles & CHAT_GHOSTEARS)) @@ -165,8 +165,9 @@ var/list/department_radio_keys = list( spawn(0) if(O) //It's possible that it could be deleted in the meantime. O.hear_talk(src, message, verb, speaking) - + log_say("[name]/[key] : [message]") + return 1 /mob/living/proc/say_signlang(var/message, var/verb="gestures", var/datum/language/language) for (var/mob/O in viewers(src, null)) diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 3f070046d57..cac6dd1907a 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -392,11 +392,10 @@ var/list/ai_list = list() checklaws() if (href_list["lawr"]) // Selects on which channel to state laws - var/setchannel = input(usr, "Specify channel.", "Channel selection") in list("State","Common","Science","Command","Medical","Engineering","Security","Supply","Binary","Cancel") + var/setchannel = input(usr, "Specify channel.", "Channel selection") in list("State","Common","Science","Command","Medical","Engineering","Security","Supply","Binary","Holopad", "Cancel") if(setchannel == "Cancel") return lawchannel = setchannel - checklaws() //Uncomment this line of code if you are enabling the AI Vocal (VOX) announcements. diff --git a/code/modules/mob/living/silicon/ai/laws.dm b/code/modules/mob/living/silicon/ai/laws.dm index cc74d6f4da1..9e104ac100a 100755 --- a/code/modules/mob/living/silicon/ai/laws.dm +++ b/code/modules/mob/living/silicon/ai/laws.dm @@ -64,8 +64,12 @@ if("Security") prefix = ":s " if("Supply") prefix = ":u " if("Binary") prefix = ":b " + if("Holopad") prefix = ":h " + else prefix = "" + + if(src.say("[prefix]Current Active Laws:") != 1) + return - src.say("[prefix]Current Active Laws:") //src.laws_sanity_check() //src.laws.show_laws(world) var/number = 1 diff --git a/code/modules/mob/living/silicon/ai/say.dm b/code/modules/mob/living/silicon/ai/say.dm index 65118d811c3..f3f1b4e1c80 100644 --- a/code/modules/mob/living/silicon/ai/say.dm +++ b/code/modules/mob/living/silicon/ai/say.dm @@ -1,9 +1,8 @@ /mob/living/silicon/ai/say(var/message) if(parent && istype(parent) && parent.stat != 2) - parent.say(message) - return + return parent.say(message) //If there is a defined "parent" AI, it is actually an AI, and it is alive, anything the AI tries to say is said by the parent instead. - ..(message) + return ..(message) // These Verbs are commented out since we've disabled the AI vocal (VOX) announcements. // If you re-enable them there is 3 lines in ai.dm Topic() that you need to uncomment as well. diff --git a/code/modules/mob/living/silicon/say.dm b/code/modules/mob/living/silicon/say.dm index 67ca178e893..c95f4ff2a6e 100644 --- a/code/modules/mob/living/silicon/say.dm +++ b/code/modules/mob/living/silicon/say.dm @@ -60,7 +60,7 @@ return var/verb = say_quote(message) - + //parse radio key and consume it var/message_mode = parse_message_mode(message, "general") if (message_mode) @@ -68,31 +68,31 @@ message = trim(copytext(message,2)) else message = trim(copytext(message,3)) - + if(message_mode && bot_type == IS_ROBOT && message_mode != "binary" && !R.is_component_functioning("radio")) src << "\red Your radio isn't functional at this time." return - - + + //parse language key and consume it var/datum/language/speaking = parse_language(message) if (speaking) verb = speaking.speech_verb message = copytext(message,3) - - + + switch(message_mode) if("department") switch(bot_type) if(IS_AI) - AI.holopad_talk(message) + return AI.holopad_talk(message) if(IS_ROBOT) log_say("[key_name(src)] : [message]") R.radio.talk_into(src,message,message_mode,verb,speaking) if(IS_PAI) log_say("[key_name(src)] : [message]") P.radio.talk_into(src,message,message_mode,verb,speaking) - return + return 1 if("binary") switch(bot_type) @@ -105,12 +105,13 @@ return robot_talk(message) - return + return 1 if("general") switch(bot_type) if(IS_AI) if (AI.aiRadio.disabledAi) src << "\red System Error - Transceiver Disabled" + return else log_say("[key_name(src)] : [message]") AI.aiRadio.talk_into(src,message,null,verb,speaking) @@ -120,7 +121,7 @@ if(IS_PAI) log_say("[key_name(src)] : [message]") P.radio.talk_into(src,message,null,verb,speaking) - return + return 1 else if(message_mode && message_mode in radiochannels) @@ -128,6 +129,7 @@ if(IS_AI) if (AI.aiRadio.disabledAi) src << "\red System Error - Transceiver Disabled" + return else log_say("[key_name(src)] : [message]") AI.aiRadio.talk_into(src,message,message_mode,verb,speaking) @@ -137,7 +139,7 @@ if(IS_PAI) log_say("[key_name(src)] : [message]") P.radio.talk_into(src,message,message_mode,verb,speaking) - return + return 1 return ..(message,speaking,verb) @@ -172,7 +174,8 @@ This is another way of saying that we won't bother dealing with them.*/ else src << "No holopad connected." - return + return + return 1 /mob/living/proc/robot_talk(var/message)