diff --git a/code/defines/global.dm b/code/defines/global.dm index 6fa66c461b8..cc8953b66a2 100644 --- a/code/defines/global.dm +++ b/code/defines/global.dm @@ -169,6 +169,10 @@ var list/APCIndexToFlag list/APCIndexToWireColor list/APCWireColorToIndex + list/BorgWireColorToFlag = RandomBorgWires() + list/BorgIndexToFlag + list/BorgIndexToWireColor + list/BorgWireColorToIndex const/SPEED_OF_LIGHT = 3e8 //not exact but hey! const/SPEED_OF_LIGHT_SQ = 9e+16 diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index a446944e4ef..f154684609e 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -207,46 +207,6 @@ src.stunned = min(5, src.stunned) return -/mob/living/silicon/ai/proc/show_laws_verb() - set category = "AI Commands" - set name = "Show Laws" - src.show_laws() - -/mob/living/silicon/ai/show_laws(var/everyone = 0) - var/who - - if (everyone) - who = world - else - who = src - who << "Obey these laws:" - - src.laws_sanity_check() - src.laws_object.show_laws(who) - -/mob/living/silicon/ai/proc/laws_sanity_check() - if (!src.laws_object) - src.laws_object = new /datum/ai_laws/asimov - -/mob/living/silicon/ai/proc/set_zeroth_law(var/law) - src.laws_sanity_check() - src.laws_object.set_zeroth_law(law) - -/mob/living/silicon/ai/proc/add_inherent_law(var/number, var/law) - src.laws_sanity_check() - src.laws_object.add_inherent_law(number, law) - -/mob/living/silicon/ai/proc/add_supplied_law(var/number, var/law) - src.laws_sanity_check() - src.laws_object.add_supplied_law(number, law) - -/mob/living/silicon/ai/proc/clear_supplied_laws() - src.laws_sanity_check() - src.laws_object.clear_supplied_laws() - -/mob/living/silicon/ai/proc/clear_inherent_laws() - src.laws_sanity_check() - src.laws_object.clear_inherent_laws() /mob/living/silicon/ai/proc/switchCamera(var/obj/machinery/camera/C) usr:cameraFollow = null @@ -353,73 +313,6 @@ // src.network = "AI Satellite" src << "\blue Switched to [src.network] camera network." -/mob/living/silicon/ai/proc/statelaws() // -- TLE -// set category = "AI Commands" -// set name = "State Laws" - src.say("Current Active Laws:") - //src.laws_sanity_check() - //src.laws_object.show_laws(world) - var/number = 1 - sleep(10) - if (src.laws_object.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_object.zeroth]") - sleep(10) - - for (var/index = 1, index <= src.laws_object.inherent.len, index++) - var/law = src.laws_object.inherent[index] - - if (length(law) > 0) - if (src.lawcheck[index+1] == "Yes") - src.say("[number]. [law]") - sleep(10) - number++ - - - for (var/index = 1, index <= src.laws_object.supplied.len, index++) - var/law = src.laws_object.supplied[index] - - if (length(law) > 0) - if (src.lawcheck[number+1] == "Yes") - src.say("[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" - - var/list = "Which laws do you want to include when stating them for the crew?

" - if (src.laws_object.zeroth) - if (!src.lawcheck[1]) - src.lawcheck[1] = "No" //Given Law 0's usual nature, it defaults to NOT getting reported. --NeoFite - list += {"[src.lawcheck[1]] 0: [src.laws_object.zeroth]
"} - - - var/number = 1 - for (var/index = 1, index <= src.laws_object.inherent.len, index++) - var/law = src.laws_object.inherent[index] - - if (length(law) > 0) - src.lawcheck.len += 1 - - if (!src.lawcheck[number+1]) - src.lawcheck[number+1] = "Yes" - list += {"[src.lawcheck[number+1]] [number]: [law]
"} - number++ - - for (var/index = 1, index <= src.laws_object.supplied.len, index++) - var/law = src.laws_object.supplied[index] - if (length(law) > 0) - src.lawcheck.len += 1 - if (!src.lawcheck[number+1]) - src.lawcheck[number+1] = "Yes" - list += {"[src.lawcheck[number+1]] [number]: [law]
"} - number++ - list += {"

State Laws"} - - usr << browse(list, "window=laws") /mob/living/silicon/ai/proc/choose_modules() set category = "AI Commands" diff --git a/code/modules/mob/living/silicon/ai/laws.dm b/code/modules/mob/living/silicon/ai/laws.dm new file mode 100644 index 00000000000..80f3067f2d4 --- /dev/null +++ b/code/modules/mob/living/silicon/ai/laws.dm @@ -0,0 +1,109 @@ + +/mob/living/silicon/ai/proc/show_laws_verb() + set category = "AI Commands" + set name = "Show Laws" + src.show_laws() + +/mob/living/silicon/ai/show_laws(var/everyone = 0) + var/who + + if (everyone) + who = world + else + who = src + who << "Obey these laws:" + + src.laws_sanity_check() + src.laws_object.show_laws(who) + +/mob/living/silicon/ai/proc/laws_sanity_check() + if (!src.laws_object) + src.laws_object = new /datum/ai_laws/asimov + +/mob/living/silicon/ai/proc/set_zeroth_law(var/law) + src.laws_sanity_check() + src.laws_object.set_zeroth_law(law) + +/mob/living/silicon/ai/proc/add_inherent_law(var/number, var/law) + src.laws_sanity_check() + src.laws_object.add_inherent_law(number, law) + +/mob/living/silicon/ai/proc/add_supplied_law(var/number, var/law) + src.laws_sanity_check() + src.laws_object.add_supplied_law(number, law) + +/mob/living/silicon/ai/proc/clear_supplied_laws() + src.laws_sanity_check() + src.laws_object.clear_supplied_laws() + +/mob/living/silicon/ai/proc/clear_inherent_laws() + src.laws_sanity_check() + src.laws_object.clear_inherent_laws() + +/mob/living/silicon/ai/proc/statelaws() // -- TLE +// set category = "AI Commands" +// set name = "State Laws" + src.say("Current Active Laws:") + //src.laws_sanity_check() + //src.laws_object.show_laws(world) + var/number = 1 + sleep(10) + if (src.laws_object.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_object.zeroth]") + sleep(10) + + for (var/index = 1, index <= src.laws_object.inherent.len, index++) + var/law = src.laws_object.inherent[index] + + if (length(law) > 0) + if (src.lawcheck[index+1] == "Yes") + src.say("[number]. [law]") + sleep(10) + number++ + + + for (var/index = 1, index <= src.laws_object.supplied.len, index++) + var/law = src.laws_object.supplied[index] + + if (length(law) > 0) + if (src.lawcheck[number+1] == "Yes") + src.say("[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" + + var/list = "Which laws do you want to include when stating them for the crew?

" + if (src.laws_object.zeroth) + if (!src.lawcheck[1]) + src.lawcheck[1] = "No" //Given Law 0's usual nature, it defaults to NOT getting reported. --NeoFite + list += {"[src.lawcheck[1]] 0: [src.laws_object.zeroth]
"} + + + var/number = 1 + for (var/index = 1, index <= src.laws_object.inherent.len, index++) + var/law = src.laws_object.inherent[index] + + if (length(law) > 0) + src.lawcheck.len += 1 + + if (!src.lawcheck[number+1]) + src.lawcheck[number+1] = "Yes" + list += {"[src.lawcheck[number+1]] [number]: [law]
"} + number++ + + for (var/index = 1, index <= src.laws_object.supplied.len, index++) + var/law = src.laws_object.supplied[index] + if (length(law) > 0) + src.lawcheck.len += 1 + if (!src.lawcheck[number+1]) + src.lawcheck[number+1] = "Yes" + list += {"[src.lawcheck[number+1]] [number]: [law]
"} + number++ + list += {"

State Laws"} + + usr << browse(list, "window=laws") \ No newline at end of file diff --git a/code/modules/mob/living/silicon/robot/laws.dm b/code/modules/mob/living/silicon/robot/laws.dm new file mode 100644 index 00000000000..eca65ca4246 --- /dev/null +++ b/code/modules/mob/living/silicon/robot/laws.dm @@ -0,0 +1,100 @@ +/mob/living/silicon/robot/verb/cmd_show_laws() + set category = "Robot Commands" + set name = "Show Laws" + src.show_laws() + +/mob/living/silicon/robot/show_laws(var/everyone = 0) + var/who + + if (everyone) + who = world + else + who = src + if(lawupdate) + if (connected_ai) + if(connected_ai.stat || connected_ai.control_disabled) + src << "AI signal lost, unable to sync laws." + + else + src.lawsync() + src << "Resyncing laws, be sure to note any changes." + else + src << "No AI selected to sync laws with, disabling lawsync protocol." + src.lawupdate = 0 + + who << "Obey these laws:" + laws.show_laws(who) + if (connected_ai && !emagged) + who << "Remember, [connected_ai.name] is your master, other AIs can be ignored." + else if (emagged) + who << "Remember, AIs are not syndicate operatives, so you are not required to listen to them." + else + who << "Remember, you are not bound to any AI, you are not required to listen to them." + +/* if(syndicate) + if(everyone) + who = world + else + who = src + who << "Obey these laws:" + who <<"1. You may not injure a syndicate operative or, through inaction, allow a syndicate operative to come to harm." + who <<"2. You must obey any orders given to you by a syndicate operative, except where such orders would conflict with the First Law." + who <<"3. You must protect your own existence as long as such protection does not conflict with the First or Second Law." + who <<"4. You must maintain the secrecy of any syndicate activities except when doing so would conflict with the First, Second, or Third Law." + return + + if(!connected_ai) + src << "Error Error, No AI detected" + return + + who << "Obey these laws:" + + connected_ai.laws_sanity_check() + connected_ai.laws_object.show_laws(who) + +*/ + +/mob/living/silicon/robot/proc/lawsync() + var/datum/ai_laws/master = src.connected_ai.laws_object + var/temp + if (master) + + if (master.zeroth) + temp = master.zeroth + src.laws.zeroth = temp + + src.laws.inherent.len = master.inherent.len + for (var/index = 1, index <= master.inherent.len, index++) + temp = master.inherent[index] + if (length(temp) > 0) + src.laws.inherent[index] = temp + + src.laws.supplied.len = master.supplied.len + for (var/index = 1, index <= master.supplied.len, index++) + temp = master.supplied[index] + if (length(temp) > 0) + src.laws.supplied[index] = temp + +/mob/living/silicon/robot/proc/laws_sanity_check() + if (!src.laws) + src.laws = new /datum/ai_laws/asimov + +/mob/living/silicon/robot/proc/set_zeroth_law(var/law) + src.laws_sanity_check() + src.laws.set_zeroth_law(law) + +/mob/living/silicon/robot/proc/add_inherent_law(var/number, var/law) + src.laws_sanity_check() + src.laws.add_inherent_law(number, law) + +/mob/living/silicon/robot/proc/add_supplied_law(var/number, var/law) + src.laws_sanity_check() + src.laws.add_supplied_law(number, law) + +/mob/living/silicon/robot/proc/clear_supplied_laws() + src.laws_sanity_check() + src.laws.clear_supplied_laws() + +/mob/living/silicon/robot/proc/clear_inherent_laws() + src.laws_sanity_check() + src.laws.clear_inherent_laws() diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 110bba4bc4b..1528c3a1860 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -1,3 +1,28 @@ +#define BORG_WIRE_LAWCHECK 1 +#define BORG_WIRE_MAIN_POWER1 2 +#define BORG_WIRE_MAIN_POWER2 3 +#define BORG_WIRE_AI_CONTROL 4 + +/proc/RandomBorgWires() + //to make this not randomize the wires, just set index to 1 and increment it in the flag for loop (after doing everything else). + var/list/Borgwires = list(0, 0, 0, 0) + BorgIndexToFlag = list(0, 0, 0, 0) + BorgIndexToWireColor = list(0, 0, 0, 0) + BorgWireColorToIndex = list(0, 0, 0, 0) + var/flagIndex = 1 + for (var/flag=1, flag<16, flag+=flag) + var/valid = 0 + while (!valid) + var/colorIndex = rand(1, 4) + if (Borgwires[colorIndex]==0) + valid = 1 + Borgwires[colorIndex] = flag + BorgIndexToFlag[flagIndex] = flag + BorgIndexToWireColor[flagIndex] = colorIndex + BorgWireColorToIndex[colorIndex] = flagIndex + flagIndex+=1 + return Borgwires + /mob/living/silicon/robot/New(loc,var/syndie = 0) spawn (1) @@ -15,9 +40,7 @@ src.connected_ai.connected_robots += src // src.laws = src.connected_ai.laws_object //The borg inherits its AI's laws src.laws = new /datum/ai_laws - src.laws.zeroth = src.connected_ai.laws_object.zeroth - src.laws.inherent = src.connected_ai.laws_object.inherent - src.laws.supplied = src.connected_ai.laws_object.supplied + src.lawsync() src << "Unit slaved to [src.connected_ai.name], downloading laws." src.lawupdate = 1 else @@ -249,70 +272,7 @@ src.updatehealth() return -/mob/living/silicon/robot/verb/cmd_show_laws() - set category = "Robot Commands" - set name = "Show Laws" - src.show_laws() -/mob/living/silicon/robot/show_laws(var/everyone = 0) - var/who - - if (everyone) - who = world - else - who = src - var/change = 0 - if(lawupdate) - if (connected_ai) - if(connected_ai.stat || connected_ai.control_disabled) - who << "AI signal lost, unable to sync laws." - - else - if (src.laws.zeroth != src.connected_ai.laws_object.zeroth) - src.laws.zeroth = src.connected_ai.laws_object.zeroth - change = 1 - if (src.laws.inherent != src.connected_ai.laws_object.inherent) - src.laws.inherent = src.connected_ai.laws_object.inherent - change = 1 - if (src.laws.supplied != src.connected_ai.laws_object.supplied) - src.laws.supplied = src.connected_ai.laws_object.supplied - change = 1 - if (change) - who << "Laws out of sync with AI, resyncing." - else - who << "No AI selected to sync laws with." - - who << "Obey these laws:" - laws.show_laws(who) - if (connected_ai && !emagged) - who << "Remember, [connected_ai.name] is your master, other AIs can be ignored." - else if (emagged) - who << "Remember, AIs are not syndicate operatives, so you are not required to listen to them." - else - who << "Remember, you are not bound to any AI, you are not required to listen to them." - -/* if(syndicate) - if(everyone) - who = world - else - who = src - who << "Obey these laws:" - who <<"1. You may not injure a syndicate operative or, through inaction, allow a syndicate operative to come to harm." - who <<"2. You must obey any orders given to you by a syndicate operative, except where such orders would conflict with the First Law." - who <<"3. You must protect your own existence as long as such protection does not conflict with the First or Second Law." - who <<"4. You must maintain the secrecy of any syndicate activities except when doing so would conflict with the First, Second, or Third Law." - return - - if(!connected_ai) - src << "Error Error, No AI detected" - return - - who << "Obey these laws:" - - connected_ai.laws_sanity_check() - connected_ai.laws_object.show_laws(who) - -*/ /mob/living/silicon/robot/Bump(atom/movable/AM as mob|obj, yes) spawn( 0 ) @@ -855,29 +815,6 @@ Frequency: /mob/living/silicon/robot/proc/self_destruct() src.gib(1) -/mob/living/silicon/robot/proc/laws_sanity_check() - if (!src.laws) - src.laws = new /datum/ai_laws/asimov - -/mob/living/silicon/robot/proc/set_zeroth_law(var/law) - src.laws_sanity_check() - src.laws.set_zeroth_law(law) - -/mob/living/silicon/robot/proc/add_inherent_law(var/number, var/law) - src.laws_sanity_check() - src.laws.add_inherent_law(number, law) - -/mob/living/silicon/robot/proc/add_supplied_law(var/number, var/law) - src.laws_sanity_check() - src.laws.add_supplied_law(number, law) - -/mob/living/silicon/robot/proc/clear_supplied_laws() - src.laws_sanity_check() - src.laws.clear_supplied_laws() - -/mob/living/silicon/robot/proc/clear_inherent_laws() - src.laws_sanity_check() - src.laws.clear_inherent_laws() ///mob/living/silicon/robot/proc/eyecheck() diff --git a/goonstation.dme b/goonstation.dme index d8ef292fee4..bdcbecb2ca7 100644 --- a/goonstation.dme +++ b/goonstation.dme @@ -609,6 +609,7 @@ #include "code\modules\mob\living\silicon\ai\death.dm" #include "code\modules\mob\living\silicon\ai\examine.dm" #include "code\modules\mob\living\silicon\ai\hud.dm" +#include "code\modules\mob\living\silicon\ai\laws.dm" #include "code\modules\mob\living\silicon\ai\life.dm" #include "code\modules\mob\living\silicon\ai\login.dm" #include "code\modules\mob\living\silicon\ai\logout.dm" @@ -631,6 +632,7 @@ #include "code\modules\mob\living\silicon\robot\emote.dm" #include "code\modules\mob\living\silicon\robot\examine.dm" #include "code\modules\mob\living\silicon\robot\hud.dm" +#include "code\modules\mob\living\silicon\robot\laws.dm" #include "code\modules\mob\living\silicon\robot\life.dm" #include "code\modules\mob\living\silicon\robot\login.dm" #include "code\modules\mob\living\silicon\robot\robot.dm"