From 705debd161ba49b77588e001fd31a90bf14a52fc Mon Sep 17 00:00:00 2001 From: "n3ophyt3@gmail.com" Date: Fri, 24 Sep 2010 00:23:50 +0000 Subject: [PATCH] The AI upload module now requires you to select an AI to upload to (for if/when multiple AIs happen) Robots now select an AI to sync laws with at creation (for if/when multiple AIs happen) git-svn-id: http://tgstation13.googlecode.com/svn/trunk@161 316c924e-a436-60f5-8080-3fe189b3f50e --- code/defines/obj/computer.dm | 1 + code/game/objects/items/weapons/AI_modules.dm | 58 +++++++++++++++---- code/modules/mob/living/silicon/ai/ai.dm | 1 + .../modules/mob/living/silicon/robot/robot.dm | 40 ++++++++++--- 4 files changed, 81 insertions(+), 19 deletions(-) diff --git a/code/defines/obj/computer.dm b/code/defines/obj/computer.dm index 875397ad426..b83103ba91c 100644 --- a/code/defines/obj/computer.dm +++ b/code/defines/obj/computer.dm @@ -42,6 +42,7 @@ /obj/machinery/computer/aiupload name = "AI Upload" icon_state = "aiupload" + var/mob/living/silicon/ai/current = null /obj/machinery/computer/atmosphere name = "atmos" diff --git a/code/game/objects/items/weapons/AI_modules.dm b/code/game/objects/items/weapons/AI_modules.dm index c1495e5cb6c..e5fcdb85c52 100644 --- a/code/game/objects/items/weapons/AI_modules.dm +++ b/code/game/objects/items/weapons/AI_modules.dm @@ -25,6 +25,38 @@ AI MODULES else return ..() +/obj/machinery/computer/aiupload/attack_hand(var/mob/user as mob) + if(src.stat & NOPOWER) + usr << "The upload computer has no power!" + return + if(src.stat & BROKEN) + usr << "The upload computer is broken!" + return + + var/select = null + var/list/names = list() + var/list/ais = list() + var/list/namecounts = list() + for (var/mob/living/silicon/ai/A in world) + var/name = A.real_name + if (A.real_name == "Inactive AI") + continue + if (A.stat == 2) + continue + if (A.control_disabled == 1) + continue + else + names.Add(name) + namecounts[name] = 1 + ais[name] = A + + if (ais.len) + select = input("Select an AI to upload laws to.", "AI selection", null, null) as null|anything in ais + src.current = ais[select] + else + usr << "No active AIs detected." + + /obj/item/weapon/aiModule/proc/install(var/obj/machinery/computer/aiupload/comp) if(comp.stat & NOPOWER) usr << "The upload computer has no power!" @@ -32,19 +64,23 @@ AI MODULES if(comp.stat & BROKEN) usr << "The upload computer is broken!" return + if (!comp.current) + usr << "You haven't selected an AI to transmit laws to!" + return var/found=0 - for(var/mob/living/silicon/ai/M in world) - if (M.stat == 2) - usr << "Upload failed. No signal is being detected from the AI." - else if (M.see_in_dark == 0) - usr << "Upload failed. Only a faint signal is being detected from the AI, and it is not responding to our requests. It may be low on power." - else - src.transmitInstructions(M, usr) - M << "These are your laws now:" - M.show_laws() - usr << "Upload complete. The AI's laws have been modified." - found=1 + + + if (comp.current.stat == 2 || comp.current.control_disabled == 1) + usr << "Upload failed. No signal is being detected from the AI." + else if (comp.current.see_in_dark == 0) + usr << "Upload failed. Only a faint signal is being detected from the AI, and it is not responding to our requests. It may be low on power." + else + src.transmitInstructions(comp.current, usr) + comp.current << "These are your laws now:" + comp.current.show_laws() + usr << "Upload complete. The AI's laws have been modified." + found=1 if (!found) usr << "Upload failed. No signal is being detected from the AI." diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index dedc063bb40..0c1d3536967 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -1,4 +1,5 @@ /mob/living/silicon/ai/New(loc, var/datum/ai_laws/L, var/obj/item/brain/B) + src.anchored = 1 src.loc = loc if(L) if (istype(L, /datum/ai_laws)) diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 4f7f45c4f09..056fff60efe 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -10,16 +10,36 @@ src.real_name += " [pick(rand(1, 999))]" src.name = src.real_name spawn (4) - for(var/mob/living/silicon/ai/A in world) - src.connected_ai = A - A.connected_robots += src - src.laws = A.laws_object //If there's an AI, the borg inherits its laws - src << "AI [A.name] detected, syncing laws" - break - if (!src.laws) // If it doesn't inherit an AI's laws, it gets a set of asimov + var/select = null + var/list/names = list() + var/list/ais = list() + var/list/namecounts = list() + for (var/mob/living/silicon/ai/A in world) + var/name = A.real_name + if (A.real_name == "Inactive AI") + continue + if (A.stat == 2) + continue + if (A.control_disabled == 1) + continue + else + names.Add(name) + namecounts[name] = 1 + ais[name] = A + + if (ais.len) + select = input("Select an AI to sync with.", "AI selection", null, null) as null|anything in ais + src.connected_ai = ais[select] + src.connected_ai.connected_robots += src + src.laws = src.connected_ai.laws_object //The borg inherits its AI's laws + src << "Laws synced with [src.connected_ai.name]." + src.lawupdate = 1 + else + usr << "No active AIs detected." src.laws = new /datum/ai_laws/asimov src.lawupdate = 0 src << "Unable to locate an AI, reverting to standard Asimov laws." + src.radio = new /obj/item/device/radio(src) src.camera = new /obj/machinery/camera(src) src.camera.c_tag = src.real_name @@ -265,10 +285,14 @@ laws = connected_ai.laws_object who << "Laws synced with AI." else - who << "AI signal lost, unable to sync laws." + who << "No AI selected to sync laws with." who << "Obey these laws:" laws.show_laws(who) + if (connected_ai) + who << "Remember, [connected_ai.name] is your master, other AIs can be ignored." + else + who << "Remember, you are not bound to any AI, you are not required to listen to them." /* if(syndicate) if(everyone)