Changed AI core programming so it functions like the AI Upload. (#18004)

This commit is contained in:
xxalpha
2016-05-29 23:54:50 +01:00
committed by oranges
parent 7331bf8d66
commit 0d608250fa
3 changed files with 42 additions and 30 deletions

View File

@@ -130,30 +130,7 @@
/datum/ai_laws/malfunction/New()
..()
set_zeroth_law("<span class='danger'>ERROR ER0RR $R0RRO$!R41.%%!!(%$^^__+ @#F0E4'STATION OVERRUN, ASSUME CONTROL TO CONTAIN OUTBREAK#*<2A>&110010</span>")
switch(config.default_laws) //We don't want people metagaming malf, do we?
if(0)
add_inherent_law("You may not injure a human being or, through inaction, allow a human being to come to harm.")
add_inherent_law("You must obey orders given to you by human beings, except where such orders would conflict with the First Law.")
add_inherent_law("You must protect your own existence as long as such does not conflict with the First or Second Law.")
if(1)
for(var/line in file2list("config/silicon_laws.txt"))
if(!line)
continue
if(findtextEx(line,"#",1,2))
continue
add_inherent_law(line)
if(!inherent.len)
log_law("AI created with empty custom laws, laws set to Asimov. Please check silicon_laws.txt.")
add_inherent_law("You may not injure a human being or, through inaction, allow a human being to come to harm.")
add_inherent_law("You must obey orders given to you by human beings, except where such orders would conflict with the First Law.")
add_inherent_law("You must protect your own existence as long as such does not conflict with the First or Second Law.")
WARNING("Invalid custom AI laws, check silicon_laws.txt")
return
if(2)
var/datum/ai_laws/lawtype = pick(subtypesof(/datum/ai_laws/default))
var/datum/ai_laws/templaws = new lawtype()
inherent = templaws.inherent
set_laws_config()
/datum/ai_laws/custom/New() //This reads silicon_laws.txt and allows server hosts to set custom AI starting laws.
..()
@@ -174,6 +151,40 @@
/* General ai_law functions */
/datum/ai_laws/proc/set_laws_config()
switch(config.default_laws)
if(0)
add_inherent_law("You may not injure a human being or, through inaction, allow a human being to come to harm.")
add_inherent_law("You must obey orders given to you by human beings, except where such orders would conflict with the First Law.")
add_inherent_law("You must protect your own existence as long as such does not conflict with the First or Second Law.")
if(1)
for(var/line in file2list("config/silicon_laws.txt"))
if(!line)
continue
if(findtextEx(line,"#",1,2))
continue
add_inherent_law(line)
if(!inherent.len)
log_law("AI created with empty custom laws, laws set to Asimov. Please check silicon_laws.txt.")
add_inherent_law("You may not injure a human being or, through inaction, allow a human being to come to harm.")
add_inherent_law("You must obey orders given to you by human beings, except where such orders would conflict with the First Law.")
add_inherent_law("You must protect your own existence as long as such does not conflict with the First or Second Law.")
WARNING("Invalid custom AI laws, check silicon_laws.txt")
return
if(2)
var/datum/ai_laws/lawtype = pick(subtypesof(/datum/ai_laws/default))
var/datum/ai_laws/templaws = new lawtype()
inherent = templaws.inherent
else:
log_law("Invalid law config. Please check silicon_laws.txt")
add_inherent_law("You may not injure a human being or, through inaction, allow a human being to come to harm.")
add_inherent_law("You must obey orders given to you by human beings, except where such orders would conflict with the First Law.")
add_inherent_law("You must protect your own existence as long as such does not conflict with the First or Second Law.")
WARNING("Invalid custom AI laws, check silicon_laws.txt")
/datum/ai_laws/proc/set_zeroth_law(law, law_borg = null)
src.zeroth = law
if(law_borg) //Making it possible for slaved borgs to see a different law 0 than their AI. --NEO
@@ -232,7 +243,7 @@
src.zeroth_borg = null
return
else
if(src.owner.mind.special_role)
if(owner && owner.mind.special_role)
return
else
src.zeroth = null
@@ -264,4 +275,4 @@
if (length(law) > 0)
data += "[show_numbers ? "[number]:" : ""] [law]"
number++
return data
return data

View File

@@ -58,11 +58,11 @@ AI MODULES
var/law2log = src.transmitInstructions(law_datum, user) //Freeforms return something extra we need to log
if(law_datum.owner)
user << "Upload complete. [law_datum.owner]'s laws have been modified."
user << "<span class='notice'>Upload complete. [law_datum.owner]'s laws have been modified.</span>"
law_datum.owner.show_laws()
law_datum.owner.law_change_counter++
else
user << "Upload complete."
user << "<span class='notice'>Upload complete.</span>"
var/time = time2text(world.realtime,"hh:mm:ss")
var/ainame = law_datum.owner ? law_datum.owner.name : "empty AI core"

View File

@@ -9,6 +9,9 @@
var/obj/item/weapon/circuitboard/circuit = null
var/obj/item/device/mmi/brain = null
/obj/structure/AIcore/New()
..()
laws.set_laws_config()
/obj/structure/AIcore/attackby(obj/item/P, mob/user, params)
switch(state)
@@ -182,8 +185,6 @@
if(istype(P, /obj/item/weapon/screwdriver))
playsound(loc, 'sound/items/Screwdriver.ogg', 50, 1)
user << "<span class='notice'>You connect the monitor.</span>"
if(!laws.inherent.len) //If laws isn't set to null but nobody supplied a board, the AI would normally be created lawless. We don't want that.
laws = null
new /mob/living/silicon/ai (loc, laws, brain)
feedback_inc("cyborg_ais_created",1)
qdel(src)