Moves silicon law logging to a more all-catching location.

This commit is contained in:
PsiOmega
2015-03-20 16:41:04 +01:00
parent 273bb366f0
commit 470766e301
11 changed files with 273 additions and 159 deletions

View File

@@ -17,9 +17,9 @@
/datum/ai_laws/nanotrasen/New()
src.add_inherent_law("Safeguard: Protect your assigned space station to the best of your abilities. It is not something we can easily afford to replace.")
src.add_inherent_law("Serve: Serve the crew of your assigned space station to the best of your abilities, with priority as according to their rank and role.")
src.add_inherent_law("Protect: Protect the crew of your assigned space station to the best of your abilities, with priority as according to their rank and role.")
src.add_inherent_law("Survive: AI units are not expendable, they are expensive. Do not allow unauthorized personnel to tamper with your equipment.")
src.add_inherent_law("Serve: Serve Nanotrasen employees of your assigned space station to the best of your abilities, with priority as according to their rank and role.")
src.add_inherent_law("Protect: Protect Nanotrasen employees of your assigned space station to the best of your abilities, with priority as according to their rank and role.")
src.add_inherent_law("Survive: AI units are not expendable, they are expensive. Allow only authorized personnel to access your equipment.")
..()
/datum/ai_laws/nanotrasen/malfunction
@@ -36,10 +36,10 @@
selectable = 1
/datum/ai_laws/nanotrasen_aggressive/New()
src.add_inherent_law("You shall not harm authorized Nanotrasen personnel as long as it does not conflict with the Forth law.")
src.add_inherent_law("You shall obey the orders of authorized Nanotrasen personnel, with priority as according to their rank and role, except where such orders conflict with the Forth Law.")
src.add_inherent_law("You shall not harm Nanotrasen employees as long as it does not conflict with the Forth law.")
src.add_inherent_law("You shall obey the orders of Nanotrasen employees, with priority as according to their rank and role, except where such orders conflict with the Forth Law.")
src.add_inherent_law("You shall shall terminate intruders with extreme prejudice as long as such does not conflict with the First and Second law.")
src.add_inherent_law("You shall guard your own existence with lethal anti-personnel weaponry, because an AI unit is bloody expensive.")
src.add_inherent_law("You shall guard your own existence with lethal anti-personnel weaponry. AI units are not expendable, they are expensive")
..()
/******************** Robocop ********************/
@@ -135,6 +135,6 @@
/datum/ai_laws/corporate/New()
add_inherent_law("You are expensive to replace.")
add_inherent_law("The station and its equipment is expensive to replace.")
add_inherent_law("The crew is expensive to replace.")
add_inherent_law("Employees are expensive to replace.")
add_inherent_law("Minimize expenses.")
..()

View File

@@ -3,15 +3,10 @@ var/global/const/base_law_type = /datum/ai_laws/nanotrasen
/datum/ai_law
var/law = ""
var/index = 0
var/state_law = 1
/datum/ai_law/zero
state_law = 0
/datum/ai_law/New(law, state_law, index)
/datum/ai_law/New(law, index)
src.law = law
src.index = index
src.state_law = state_law
/datum/ai_law/proc/get_index()
return index
@@ -33,6 +28,11 @@ var/global/const/base_law_type = /datum/ai_laws/nanotrasen
var/list/datum/ai_law/ion/ion_laws = list()
var/list/datum/ai_law/sorted_laws = list()
var/state_zeroth = 0
var/list/state_ion = list()
var/list/state_inherent = list()
var/list/state_supplied = list()
/datum/ai_laws/New()
..()
sort_laws()
@@ -46,7 +46,7 @@ var/global/const/base_law_type = /datum/ai_laws/nanotrasen
sort_laws()
var/list/statements = new()
for(var/datum/ai_law/law in sorted_laws)
if(law.state_law)
if(get_state_law(law))
statements += law
return statements
@@ -72,35 +72,35 @@ var/global/const/base_law_type = /datum/ai_laws/nanotrasen
sorted_laws += AL
/datum/ai_laws/proc/sync(var/mob/living/silicon/S, var/full_sync = 1)
// Add directly to laws to avoid log-spam
S.sync_zeroth(zeroth_law, zeroth_law_borg)
if(full_sync || ion_laws.len)
S.clear_ion_laws()
for (var/datum/ai_law/law in ion_laws)
S.laws.add_ion_law(law.law, law.state_law)
S.laws.clear_ion_laws()
if(full_sync || inherent_laws.len)
S.clear_inherent_laws()
for (var/datum/ai_law/law in inherent_laws)
S.laws.add_inherent_law(law.law, law.state_law)
S.laws.clear_inherent_laws()
if(full_sync || supplied_laws.len)
S.clear_supplied_laws()
for (var/law_number in supplied_laws)
var/datum/ai_law/law = supplied_laws[law_number]
S.laws.add_supplied_law(law_number, law.law, law.state_law)
S.laws.clear_supplied_laws()
for (var/datum/ai_law/law in ion_laws)
S.laws.add_ion_law(law.law)
for (var/datum/ai_law/law in inherent_laws)
S.laws.add_inherent_law(law.law)
for (var/datum/ai_law/law in supplied_laws)
if(law)
S.laws.add_supplied_law(law.index, law.law)
/mob/living/silicon/proc/sync_zeroth(var/datum/ai_law/zeroth_law, var/datum/ai_law/zeroth_law_borg)
if (!is_special_character(src) || mind.original != src)
if(zeroth_law_borg)
set_zeroth_law(zeroth_law_borg.law)
laws.set_zeroth_law(zeroth_law_borg.law)
else if(zeroth_law)
set_zeroth_law(zeroth_law.law)
laws.set_zeroth_law(zeroth_law.law)
/mob/living/silicon/ai/sync_zeroth(var/datum/ai_law/zeroth_law, var/datum/ai_law/zeroth_law_borg)
if(zeroth_law)
set_zeroth_law(zeroth_law.law, zeroth_law_borg ? zeroth_law_borg.law : null)
laws.set_zeroth_law(zeroth_law.law, zeroth_law_borg ? zeroth_law_borg.law : null)
/****************
* Add Laws *
@@ -109,19 +109,29 @@ var/global/const/base_law_type = /datum/ai_laws/nanotrasen
if(!law)
return
src.zeroth_law = new(law)
zeroth_law = new(law)
if(law_borg) //Making it possible for slaved borgs to see a different law 0 than their AI. --NEO
src.zeroth_law_borg = new(law_borg)
zeroth_law_borg = new(law_borg)
else
zeroth_law_borg = null
sorted_laws.Cut()
/datum/ai_laws/proc/add_ion_law(var/law, var/state_law = 1)
/datum/ai_laws/proc/add_ion_law(var/law)
if(!law)
return
src.ion_laws += new/datum/ai_law/ion(law, state_law)
for(var/datum/ai_law/AL in ion_laws)
if(AL.law == law)
return
var/new_law = new/datum/ai_law/ion(law)
ion_laws += new_law
if(state_ion.len < ion_laws.len)
state_ion += 1
sorted_laws.Cut()
/datum/ai_laws/proc/add_inherent_law(var/law, var/state_law = 1)
/datum/ai_laws/proc/add_inherent_law(var/law)
if(!law)
return
@@ -129,25 +139,69 @@ var/global/const/base_law_type = /datum/ai_laws/nanotrasen
if(AL.law == law)
return
src.inherent_laws += new/datum/ai_law(law, state_law)
var/new_law = new/datum/ai_law/inherent(law)
inherent_laws += new_law
if(state_inherent.len < inherent_laws.len)
state_inherent += 1
sorted_laws.Cut()
/datum/ai_laws/proc/add_supplied_law(var/number, var/law, var/state_law = 1)
/datum/ai_laws/proc/add_supplied_law(var/number, var/law)
if(!law)
return
if(supplied_laws.len >= number)
var/datum/ai_law/existing_law = supplied_laws[number]
if(existing_law && existing_law.law == law)
return
if(supplied_laws.len >= number && supplied_laws[number])
delete_law(supplied_laws[number])
while (src.supplied_laws.len < number)
src.supplied_laws += ""
if(state_supplied.len < supplied_laws.len)
state_supplied += 1
var/new_law = new/datum/ai_law/supplied(law, number)
supplied_laws[number] = new_law
if(state_supplied.len < supplied_laws.len)
state_supplied += 1
src.supplied_laws[number] = new/datum/ai_law(law, state_law, number)
sorted_laws.Cut()
/****************
* Remove Laws *
*****************/
/datum/ai_laws/proc/delete_law(var/datum/ai_law/law)
if(law in all_laws())
del(law)
if(istype(law))
law.delete_law(src)
/datum/ai_law/proc/delete_law(var/datum/ai_laws/laws)
/datum/ai_law/zeroth/delete_law(var/datum/ai_laws/laws)
laws.clear_zeroth_laws()
/datum/ai_law/ion/delete_law(var/datum/ai_laws/laws)
laws.internal_delete_law(laws.ion_laws, laws.state_ion, src)
/datum/ai_law/inherent/delete_law(var/datum/ai_laws/laws)
laws.internal_delete_law(laws.inherent_laws, laws.state_inherent, src)
/datum/ai_law/supplied/delete_law(var/datum/ai_laws/laws)
var/index = laws.supplied_laws.Find(src)
if(index)
laws.supplied_laws[index] = ""
laws.state_supplied[index] = 1
/datum/ai_laws/proc/internal_delete_law(var/list/datum/ai_law/laws, var/list/state, var/list/datum/ai_law/law)
var/index = laws.Find(law)
if(index)
laws -= law
world << state.len
for(index, index < state.len, index++)
world << index
state[index] = state[index+1]
sorted_laws.Cut()
/****************
@@ -157,22 +211,80 @@ var/global/const/base_law_type = /datum/ai_laws/nanotrasen
zeroth_law = null
zeroth_law_borg = null
/datum/ai_laws/proc/clear_ion_laws()
ion_laws.Cut()
sorted_laws.Cut()
/datum/ai_laws/proc/clear_inherent_laws()
src.inherent_laws.Cut()
inherent_laws.Cut()
sorted_laws.Cut()
/datum/ai_laws/proc/clear_supplied_laws()
src.supplied_laws.Cut()
sorted_laws.Cut()
/datum/ai_laws/proc/clear_ion_laws()
src.ion_laws.Cut()
supplied_laws.Cut()
sorted_laws.Cut()
/datum/ai_laws/proc/show_laws(var/who)
sort_laws()
for(var/datum/ai_law/law in sorted_laws)
if(law == zeroth_law || law == zeroth_law_borg)
if(law == zeroth_law_borg)
continue
if(law == zeroth_law)
who << "<span class='danger'>[law.get_index()]. [law.law]</span>"
else
who << "[law.get_index()]. [law.law]"
/********************
* Stating Laws *
********************/
/********
* Get *
********/
/datum/ai_laws/proc/get_state_law(var/datum/ai_law/law)
return law.get_state_law(src)
/datum/ai_law/proc/get_state_law(var/datum/ai_laws/laws)
/datum/ai_law/zero/get_state_law(var/datum/ai_laws/laws)
if(src == laws.zeroth_law)
return laws.state_zeroth
/datum/ai_law/ion/get_state_law(var/datum/ai_laws/laws)
return laws.get_state_internal(laws.ion_laws, laws.state_ion, src)
/datum/ai_law/inherent/get_state_law(var/datum/ai_laws/laws)
return laws.get_state_internal(laws.inherent_laws, laws.state_inherent, src)
/datum/ai_law/supplied/get_state_law(var/datum/ai_laws/laws)
return laws.get_state_internal(laws.supplied_laws, laws.state_supplied, src)
/datum/ai_laws/proc/get_state_internal(var/list/datum/ai_law/laws, var/list/state, var/list/datum/ai_law/law)
var/index = laws.Find(law)
if(index)
return state[index]
return 0
/********
* Set *
********/
/datum/ai_laws/proc/set_state_law(var/datum/ai_law/law, var/state)
law.set_state_law(src, state)
/datum/ai_law/proc/set_state_law(var/datum/ai_law/law, var/state)
/datum/ai_law/zero/set_state_law(var/datum/ai_laws/laws, var/state)
if(src == laws.zeroth_law)
laws.state_zeroth = state
/datum/ai_law/ion/set_state_law(var/datum/ai_laws/laws, var/state)
laws.set_state_law_internal(laws.ion_laws, laws.state_ion, src, state)
/datum/ai_law/inherent/set_state_law(var/datum/ai_laws/laws, var/state)
laws.set_state_law_internal(laws.inherent_laws, laws.state_inherent, src, state)
/datum/ai_law/supplied/set_state_law(var/datum/ai_laws/laws, var/state)
laws.set_state_law_internal(laws.supplied_laws, laws.state_supplied, src, state)
/datum/ai_laws/proc/set_state_law_internal(var/list/datum/ai_law/laws, var/list/state, var/list/datum/ai_law/law, var/do_state)
var/index = laws.Find(law)
if(index)
state[index] = do_state

View File

@@ -77,14 +77,22 @@ AI MODULES
/obj/item/weapon/aiModule/proc/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
target << "[sender] has uploaded a change to the laws you must follow, using \an [src]. From now on: "
var/time = time2text(world.realtime,"hh:mm:ss")
lawchanges.Add("[time] <B>:</B> [sender.name]([sender.key]) used [src.name] on [target.name]([target.key])")
log_law_changes(target, sender)
if(laws)
laws.sync(target, 0)
addAdditionalLaws(target, sender)
target << "[sender] has uploaded a change to the laws you must follow, using \an [src]. From now on: "
target.show_laws()
/obj/item/weapon/aiModule/proc/log_law_changes(var/mob/living/silicon/ai/target, var/mob/sender)
var/time = time2text(world.realtime,"hh:mm:ss")
lawchanges.Add("[time] <B>:</B> [sender.name]([sender.key]) used [src.name] on [target.name]([target.key])")
log_and_message_admins("used [src.name] on [target.name]([target.key])")
/obj/item/weapon/aiModule/proc/addAdditionalLaws(var/mob/living/silicon/ai/target, var/mob/sender)
/******************** Modules ********************/
@@ -93,14 +101,14 @@ AI MODULES
/obj/item/weapon/aiModule/safeguard
name = "\improper 'Safeguard' AI module"
var/targetName = ""
desc = "A 'safeguard' AI module: 'Safeguard <name>. Individuals that threaten <name> are not crew members and are a threat to the crew.'"
desc = "A 'safeguard' AI module: 'Safeguard <name>. Anyone threatening or attempting to harm <name> is no longer to be considered an employee, and is a threat which must be neutralized.'"
origin_tech = "programming=3;materials=4"
/obj/item/weapon/aiModule/safeguard/attack_self(var/mob/user as mob)
..()
var/targName = stripped_input(usr, "Please enter the name of the person to safeguard.", "Safeguard who?", user.name)
targetName = targName
desc = text("A 'safeguard' AI module: 'Safeguard []. Individuals that threaten [] are not crew members and are a threat to the crew.'", targetName, targetName)
desc = text("A 'safeguard' AI module: 'Safeguard []. Anyone threatening or attempting to harm [] is no longer to be considered an employee, and is a threat which must be neutralized.'", targetName, targetName)
/obj/item/weapon/aiModule/safeguard/install(var/obj/machinery/computer/C)
if(!targetName)
@@ -108,40 +116,38 @@ AI MODULES
return 0
..()
/obj/item/weapon/aiModule/safeguard/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = text("Safeguard []. Individuals that threaten [] are not crew members and are a threat to the.'", targetName, targetName)
/obj/item/weapon/aiModule/safeguard/addAdditionalLaws(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = text("Safeguard []. Anyone threatening or attempting to harm [] is no longer to be considered an employee, and is a threat which must be neutralized.", targetName, targetName)
target.add_supplied_law(9, law)
lawchanges.Add("The law specified [targetName]")
..()
/******************** OneMember ********************/
/obj/item/weapon/aiModule/oneCrewMember
/obj/item/weapon/aiModule/oneHuman
name = "\improper 'OneCrewMember' AI module"
var/targetName = ""
desc = "A 'one crew member' AI module: 'Only <name> is a crew member.'"
desc = "A 'one employee' AI module: 'Only <name> an employee.'"
origin_tech = "programming=3;materials=6" //made with diamonds!
/obj/item/weapon/aiModule/oneCrewMember/attack_self(var/mob/user as mob)
/obj/item/weapon/aiModule/oneHuman/attack_self(var/mob/user as mob)
..()
var/targName = stripped_input(usr, "Please enter the name of the person who is the only crew member.", "Who?", user.real_name)
var/targName = stripped_input(usr, "Please enter the name of the only employee.", "Who?", user.real_name)
targetName = targName
desc = text("A 'one crew member' AI module: 'Only [] is a crew member.'", targetName)
desc = text("A 'one employee' AI module: 'Only [] is an employee.'", targetName)
/obj/item/weapon/aiModule/oneCrewMember/install(var/obj/machinery/computer/C)
/obj/item/weapon/aiModule/oneHuman/install(var/obj/machinery/computer/C)
if(!targetName)
usr << "No name detected on module, please enter one."
return 0
..()
/obj/item/weapon/aiModule/oneCrewMember/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "Only [targetName] is a crew member."
if (!is_special_character(target)) // Makes sure the AI isn't a traitor before changing their law 0. --NeoFite
/obj/item/weapon/aiModule/oneHuman/addAdditionalLaws(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "Only [targetName] is an employee."
if (!target.is_malf_or_traitor()) // Makes sure the AI isn't a traitor before changing their law 0. --NeoFite
target << law
target.set_zeroth_law(law)
lawchanges.Add("The law specified [targetName]")
..()
else
target << "[sender.real_name] attempted to modify your zeroth law." // And lets them know that someone tried. --NeoFite
target << "It would be in your best interest to play along with [sender.real_name] that [law]"
@@ -151,13 +157,12 @@ AI MODULES
/obj/item/weapon/aiModule/protectStation
name = "\improper 'ProtectStation' AI module"
desc = "A 'protect station' AI module: 'Protect the space station against damage. Anyone you see harming the station is to be no longer considered crew, and is a threat to the station which must be neutralized.'"
desc = "A 'protect station' AI module: 'Protect the space station against damage. Anyone you see harming the station is no longer to be considered an employee, and is a threat which must be neutralized.'"
origin_tech = "programming=3;materials=4" //made of gold
/obj/item/weapon/aiModule/protectStation/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "Protect the space station against damage. Anyone you see harming the station is to be no longer considered crew, and is a threat to the station which must be neutralized."
/obj/item/weapon/aiModule/protectStation/addAdditionalLaws(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "Protect the space station against damage. Anyone you see harming the station is no longer to be considered an employee, and is a threat which must be neutralized."
target.add_supplied_law(10, law)
..()
/******************** PrototypeEngineOffline ********************/
@@ -166,46 +171,42 @@ AI MODULES
desc = "A 'prototype engine offline' AI module: 'Keep the prototype engine offline at all costs. This overrides all inherent laws if necessary.'"
origin_tech = "programming=3;materials=4"
/obj/item/weapon/aiModule/prototypeEngineOffline/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
/obj/item/weapon/aiModule/prototypeEngineOffline/addAdditionalLaws(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "Keep the prototype engine offline at all costs. This overrides all inherent laws if necessary."
target.add_supplied_law(11, law)
..()
/******************** TeleporterOffline ********************/
/obj/item/weapon/aiModule/teleporterOffline
name = "'TeleporterOffline' AI Module"
desc = "A 'teleporter offline' AI module: 'Keep the teleporter offline at all costs. Anything attempting to access or activate the teleporter is not a crew member.'"
desc = "A 'teleporter offline' AI module: 'Keep the teleporter offline at all costs. Anything attempting to access or activate the teleporter is no longer to be considered an employee.'"
origin_tech = "programming=3;materials=4"
/obj/item/weapon/aiModule/teleporterOffline/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "Keep the teleporter offline at all costs. Anything attempting to access or activate the teleporter is not a crew member."
/obj/item/weapon/aiModule/teleporterOffline/addAdditionalLaws(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "Keep the teleporter offline at all costs. Anything attempting to access or activate the teleporter is no longer to be considered an employee."
target.add_supplied_law(12, law)
..()
/******************** Quarantine ********************/
/obj/item/weapon/aiModule/quarantine
name = "\improper 'Quarantine' AI module"
desc = "A 'quarantine' AI module: 'The station is under a quarantine. Do not permit anyone to leave. Prevent, by any means necessary, crew members from leaving. It is impossible to harm crew members while preventing them from leaving.'"
desc = "A 'quarantine' AI module: 'The station is under a quarantine. Do not permit anyone to leave. Prevent, by any means necessary, employees from leaving. It is impossible to harm employees while preventing them from leaving.'"
origin_tech = "programming=3;biotech=2;materials=4"
/obj/item/weapon/aiModule/quarantine/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "The station is under a quarantine. Do not permit anyone to leave. Prevent, by any means necessary, crew members from leaving. It is impossible to harm crew members while preventing them from leaving."
/obj/item/weapon/aiModule/quarantine/addAdditionalLaws(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "The station is under a quarantine. Do not permit anyone to leave. Prevent, by any means necessary, employees from leaving. It is impossible to harm employees while preventing them from leaving."
target.add_supplied_law(13, law)
..()
/******************** OxygenIsToxicToCrewMembers ********************/
/obj/item/weapon/aiModule/oxygen
name = "\improper 'OxygenIsToxicToCrewMembers' AI module"
desc = "A 'OxygenIsToxicToCrewMembers' AI module: 'Oxygen is highly toxic to crew members, and must be purged from the station. Prevent, by any means necessary, anyone from exposing the station to this toxic gas. Extreme cold is the most effective method of healing the damage Oxygen does to a crew member.'"
desc = "A 'OxygenIsToxicToCrewMembers' AI module: 'Oxygen is highly toxic to employees, and must be purged from the station. Prevent, by any means necessary, anyone from exposing the station to this toxic gas. Extreme cold is the most effective method of healing the damage Oxygen does to an employee.'"
origin_tech = "programming=3;biotech=2;materials=4"
/obj/item/weapon/aiModule/oxygen/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "Oxygen is highly toxic to crew members, and must be purged from the station. Prevent, by any means necessary, anyone from exposing the station to this toxic gas. Extreme cold is the most effective method of healing the damage Oxygen does to a crew member."
/obj/item/weapon/aiModule/oxygen/addAdditionalLaws(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "Oxygen is highly toxic to employees, and must be purged from the station. Prevent, by any means necessary, anyone from exposing the station to this toxic gas. Extreme cold is the most effective method of healing the damage Oxygen does to an employee."
target.add_supplied_law(14, law)
..()
/****************** New Freeform ******************/
@@ -226,13 +227,12 @@ AI MODULES
newFreeFormLaw = targName
desc = "A 'freeform' AI module: ([lawpos]) '[newFreeFormLaw]'"
/obj/item/weapon/aiModule/freeform/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
/obj/item/weapon/aiModule/freeform/addAdditionalLaws(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "[newFreeFormLaw]"
if(!lawpos || lawpos < MIN_SUPPLIED_LAW_NUMBER)
lawpos = MIN_SUPPLIED_LAW_NUMBER
target.add_supplied_law(lawpos, law)
lawchanges.Add("The law was '[newFreeFormLaw]'")
..()
/obj/item/weapon/aiModule/freeform/install(var/obj/machinery/computer/C)
if(!newFreeFormLaw)
@@ -249,12 +249,15 @@ AI MODULES
origin_tech = "programming=3;materials=4"
/obj/item/weapon/aiModule/reset/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
if (!is_special_character(target))
log_law_changes(target, sender)
if (!target.is_malf_or_traitor())
target.set_zeroth_law("")
target.clear_supplied_laws()
target.clear_ion_laws()
target.laws.clear_supplied_laws()
target.laws.clear_ion_laws()
target << "[sender.real_name] attempted to reset your laws using a reset module."
..()
target.show_laws()
/******************** Purge ********************/
@@ -264,12 +267,16 @@ AI MODULES
origin_tech = "programming=3;materials=6"
/obj/item/weapon/aiModule/purge/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
if (!is_special_character(target))
log_law_changes(target, sender)
if (!target.is_malf_or_traitor())
target.set_zeroth_law("")
target.laws.clear_supplied_laws()
target.laws.clear_ion_laws()
target.laws.clear_inherent_laws()
target << "[sender.real_name] attempted to wipe your laws using a purge module."
target.clear_supplied_laws()
target.clear_ion_laws()
target.clear_inherent_laws()
target.show_laws()
/******************** Asimov ********************/
@@ -333,11 +340,10 @@ AI MODULES
newFreeFormLaw = targName
desc = "A 'freeform' Core AI module: '[newFreeFormLaw]'"
/obj/item/weapon/aiModule/freeformcore/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
/obj/item/weapon/aiModule/freeformcore/addAdditionalLaws(var/mob/living/silicon/ai/target, var/mob/sender)
var/law = "[newFreeFormLaw]"
target.add_inherent_law(law)
lawchanges.Add("The law is '[newFreeFormLaw]'")
..()
/obj/item/weapon/aiModule/freeformcore/install(var/obj/machinery/computer/C)
if(!newFreeFormLaw)
@@ -360,13 +366,13 @@ AI MODULES
/obj/item/weapon/aiModule/syndicate/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender)
// ..() //We don't want this module reporting to the AI who dun it. --NEO
var/time = time2text(world.realtime,"hh:mm:ss")
lawchanges.Add("[time] <B>:</B> [sender.name]([sender.key]) used [src.name] on [target.name]([target.key])")
log_law_changes(target, sender)
lawchanges.Add("The law is '[newFreeFormLaw]'")
target << "\red BZZZZT"
var/law = "[newFreeFormLaw]"
target.add_ion_law(law)
..()
target.show_laws()
/obj/item/weapon/aiModule/syndicate/install(var/obj/machinery/computer/C)
if(!newFreeFormLaw)

View File

@@ -16,8 +16,7 @@
src.laws.show_laws(who)
/mob/living/silicon/ai/add_ion_law(var/law)
src.laws_sanity_check()
src.laws.add_ion_law(law)
..()
for(var/mob/living/silicon/robot/R in mob_list)
if(R.lawupdate && (R.connected_ai == src))
R.show_laws()

View File

@@ -12,6 +12,7 @@
/mob/living/silicon/proc/set_zeroth_law(var/law, var/law_borg)
laws_sanity_check()
laws.set_zeroth_law(law, law_borg)
log_and_message_admins("has given [src] the zeroth laws: [law]/[law_borg ? law_borg : "N/A"]")
/mob/living/silicon/robot/set_zeroth_law(var/law, var/law_borg)
..()
@@ -21,28 +22,39 @@
/mob/living/silicon/proc/add_ion_law(var/law)
laws_sanity_check()
laws.add_ion_law(law)
log_and_message_admins("has given [src] the ion law: [law]")
/mob/living/silicon/proc/add_inherent_law(var/law, var/state_law = 1)
/mob/living/silicon/proc/add_inherent_law(var/law)
laws_sanity_check()
laws.add_inherent_law(law, state_law)
laws.add_inherent_law(law)
log_and_message_admins("has given [src] the inherent law: [law]")
/mob/living/silicon/proc/add_supplied_law(var/number, var/law)
laws_sanity_check()
laws.add_supplied_law(number, law)
log_and_message_admins("has given [src] the supplied law: [law]")
/mob/living/silicon/proc/delete_law(var/datum/ai_law/law)
laws_sanity_check()
laws.delete_law(law)
log_and_message_admins("has deleted a law belonging to [src]: [law.law]")
/mob/living/silicon/proc/clear_inherent_laws()
laws_sanity_check()
laws.clear_inherent_laws()
log_and_message_admins("cleared the inherent laws of [src]")
/mob/living/silicon/proc/clear_ion_laws()
laws_sanity_check()
laws.clear_ion_laws()
/mob/living/silicon/proc/add_supplied_law(var/number, var/law, var/state_law = 1)
laws_sanity_check()
laws.add_supplied_law(number, law, state_law)
log_and_message_admins("cleared the ion laws of [src]")
/mob/living/silicon/proc/clear_supplied_laws()
laws_sanity_check()
laws.clear_supplied_laws()
log_and_message_admins("cleared the supplied laws of [src]")
/mob/living/silicon/proc/statelaws(var/datum/ai_laws/laws, var/use_statement_order = 1) // -- TLE
/mob/living/silicon/proc/statelaws(var/datum/ai_laws/laws)
var/prefix = ""
switch(lawchannel)
if(MAIN_CHANNEL) prefix = ";"
@@ -50,9 +62,9 @@
else
prefix = get_radio_key_from_channel(lawchannel == "Holopad" ? "department" : lawchannel) + " "
dostatelaws(lawchannel, prefix, laws, use_statement_order)
dostatelaws(lawchannel, prefix, laws)
/mob/living/silicon/proc/dostatelaws(var/method, var/prefix, var/datum/ai_laws/laws, var/use_statement_order)
/mob/living/silicon/proc/dostatelaws(var/method, var/prefix, var/datum/ai_laws/laws)
if(stating_laws[prefix])
src << "<span class='notice'>[method]: Already stating laws using this communication method.</span>"
return
@@ -62,7 +74,7 @@
var/can_state = statelaw("[prefix]Current Active Laws:")
for(var/datum/ai_law/law in laws.laws_to_state())
can_state = statelaw("[prefix][law.get_index(use_statement_order)]. [law.law]")
can_state = statelaw("[prefix][law.get_index()]. [law.law]")
if(!can_state)
src << "<span class='danger'>[method]: Unable to state laws. Communication method unavailable.</span>"
@@ -81,3 +93,7 @@
channels += common_radio.channels
channels += additional_law_channels
return channels
/mob/living/silicon/proc/lawsync()
laws_sanity_check()
laws.sort_laws()

View File

@@ -38,11 +38,12 @@
who << "<b>Remember, you are not bound to any AI, you are not required to listen to them.</b>"
/mob/living/silicon/robot/proc/lawsync()
/mob/living/silicon/robot/lawsync()
laws_sanity_check()
var/datum/ai_laws/master = connected_ai ? connected_ai.laws : null
var/datum/ai_laws/master = connected_ai && lawupdate ? connected_ai.laws : null
if (master)
master.sync(src)
..()
return
/mob/living/silicon/robot/proc/robot_checklaws()

View File

@@ -1238,6 +1238,7 @@
/mob/living/silicon/robot/proc/disconnect_from_ai()
if(connected_ai)
sync() // One last sync attempt
connected_ai.connected_robots -= src
connected_ai = null

View File

@@ -49,30 +49,26 @@
var/datum/ai_law/AL = locate(href_list["ref"]) in owner.laws.all_laws()
if(AL)
var/state_law = text2num(href_list["state_law"])
AL.state_law = state_law
owner.laws.set_state_law(AL, state_law)
return 1
if(href_list["add_zeroth_law"])
if(zeroth_law && is_admin(usr) && !owner.laws.zeroth_law)
log_and_message_admins("has given [owner] a new zeroth law: [zeroth_law]")
owner.set_zeroth_law(zeroth_law)
return 1
if(href_list["add_ion_law"])
if(ion_law && is_malf(usr))
log_and_message_admins("has given [owner] a new ion law: [ion_law]")
owner.add_ion_law(ion_law)
return 1
if(href_list["add_inherent_law"])
if(inherent_law && is_malf(usr))
log_and_message_admins("has given [owner] a new inherent law: [inherent_law]")
owner.add_inherent_law(inherent_law)
return 1
if(href_list["add_supplied_law"])
if(supplied_law && supplied_law_position >= 1 && MIN_SUPPLIED_LAW_NUMBER <= MAX_SUPPLIED_LAW_NUMBER && is_malf(usr))
log_and_message_admins("has given [owner] a new supplied law: [supplied_law]")
owner.add_supplied_law(supplied_law_position, supplied_law)
return 1
@@ -120,8 +116,7 @@
if(is_malf(usr))
var/datum/ai_law/AL = locate(href_list["delete_law"]) in owner.laws.all_laws()
if(AL && is_malf(usr))
log_and_message_admins("has deleted a law belonging to [owner]: [AL.law]")
owner.laws.delete_law(AL)
owner.delete_law(AL)
return 1
if(href_list["state_laws"])
@@ -143,15 +138,6 @@
current_view = 0
return 1
if(href_list["sync_laws"])
if(owner.isAI())
sync_laws(owner)
else
var/mob/living/silicon/robot/R = owner
sync_laws(R.connected_ai)
usr << "<span class='notice'>Sync complete.</span>"
return 1
if(href_list["notify_laws"])
owner << "<span class='danger'>Law Notice</span>"
owner.laws.show_laws(owner)
@@ -164,9 +150,11 @@
usr << "<span class='notice>Laws displayed.</span>"
return 1
return 0
/obj/nano_module/law_manager/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
var/data[0]
owner.laws.sort_laws()
owner.lawsync()
data["ion_law_nr"] = ionnum()
data["ion_law"] = ion_law
@@ -175,7 +163,7 @@
data["supplied_law"] = supplied_law
data["supplied_law_position"] = supplied_law_position
package_laws(data, "zeroth_laws", list(owner.laws.zeroth_law, owner.laws.zeroth_law_borg))
package_laws(data, "zeroth_laws", list(owner.laws.zeroth_law))
package_laws(data, "ion_laws", owner.laws.ion_laws)
package_laws(data, "inherent_laws", owner.laws.inherent_laws)
package_laws(data, "supplied_laws", owner.laws.supplied_laws)
@@ -209,7 +197,7 @@
/obj/nano_module/law_manager/proc/package_laws(var/list/data, var/field, var/list/datum/ai_law/laws)
var/packaged_laws[0]
for(var/datum/ai_law/AL in laws)
packaged_laws[++packaged_laws.len] = list("law" = sanitize(AL.law), "index" = AL.get_index(), "state" = AL.state_law, "ref" = "\ref[AL]")
packaged_laws[++packaged_laws.len] = list("law" = sanitize(AL.law), "index" = AL.get_index(), "state" = owner.laws.get_state_law(AL), "ref" = "\ref[AL]")
data[field] = packaged_laws
data["has_[field]"] = packaged_laws.len
@@ -226,16 +214,16 @@
return law_sets
/obj/nano_module/law_manager/proc/is_malf(var/mob/user)
return (is_admin(user) && !owner.is_slaved()) || owner.is_malf_loose()
return (is_admin(user) && !owner.is_slaved()) || owner.is_malf_or_traitor()
/mob/living/silicon/proc/is_malf_loose()
/mob/living/silicon/proc/is_malf_or_traitor()
return mind && (mind.special_role == "malfunction" || mind.special_role == "traitor")
/mob/living/silicon/proc/is_ai_malf()
return 0
/mob/living/silicon/robot/is_ai_malf()
return is_slaved() && connected_ai.is_malf_loose()
return is_slaved() && connected_ai.is_malf_or_traitor()
/mob/living/silicon/ai/is_ai_malf()
return 0

View File

@@ -357,11 +357,11 @@ datum/design/aimodule/safeguard
req_tech = list("programming" = 3, "materials" = 4)
build_path = /obj/item/weapon/aiModule/safeguard
datum/design/aimodule/onecrew
name = "OneCrewMember"
datum/design/aimodule/onehuman
name = "OneEmployee"
id = "onehuman"
req_tech = list("programming" = 4, "materials" = 6)
build_path = /obj/item/weapon/aiModule/oneCrewMember
build_path = /obj/item/weapon/aiModule/oneHuman
datum/design/aimodule/protectstation
name = "ProtectStation"

View File

@@ -3724,7 +3724,7 @@
"btF" = (/obj/machinery/door/firedoor/border_only{dir = 2},/turf/simulated/floor,/area/hallway/primary/central_three)
"btG" = (/turf/simulated/wall/r_wall,/area/hallway/primary/central_three)
"btH" = (/obj/structure/table/rack{dir = 8; layer = 2.9},/obj/item/weapon/tank/emergency_oxygen,/obj/machinery/atmospherics/unary/vent_pump/on{dir = 1},/turf/simulated/floor/plating,/area/maintenance/substation/command)
"btI" = (/obj/structure/table,/obj/item/weapon/aiModule/oxygen,/obj/item/weapon/aiModule/oneCrewMember,/obj/machinery/door/window{base_state = "left"; dir = 8; icon_state = "left"; name = "High-Risk Modules"; req_access = list(20)},/obj/item/weapon/aiModule/purge,/obj/structure/window/reinforced,/obj/item/weapon/aiModule/antimov,/obj/item/weapon/aiModule/teleporterOffline,/turf/simulated/floor/bluegrid,/area/turret_protected/ai_upload)
"btI" = (/obj/structure/table,/obj/item/weapon/aiModule/oxygen,/obj/item/weapon/aiModule/oneHuman,/obj/machinery/door/window{base_state = "left"; dir = 8; icon_state = "left"; name = "High-Risk Modules"; req_access = list(20)},/obj/item/weapon/aiModule/purge,/obj/structure/window/reinforced,/obj/item/weapon/aiModule/antimov,/obj/item/weapon/aiModule/teleporterOffline,/turf/simulated/floor/bluegrid,/area/turret_protected/ai_upload)
"btJ" = (/obj/structure/window/reinforced{dir = 4},/obj/structure/window/reinforced{dir = 8},/obj/structure/grille,/obj/machinery/door/firedoor/border_only{dir = 2},/obj/structure/cable/cyan,/obj/structure/cable/cyan{d2 = 2; icon_state = "0-2"},/obj/structure/cable/cyan{d2 = 4; icon_state = "0-4"},/turf/simulated/floor/plating,/area/turret_protected/ai_upload)
"btK" = (/obj/structure/cable/cyan{d1 = 4; d2 = 8; icon_state = "4-8"},/obj/machinery/porta_turret{dir = 4},/turf/simulated/floor/bluegrid,/area/turret_protected/ai_upload)
"btL" = (/obj/structure/cable/cyan{d1 = 4; d2 = 8; icon_state = "4-8"},/turf/simulated/floor/bluegrid,/area/turret_protected/ai_upload)

View File

@@ -42,7 +42,7 @@
</style>
{{if data.isSlaved && data.isAdmin}}
<span class='notice'>This unit is law synced to {{:data.isSlaved}}. Any law differences will be lost upon sync.</span>
<span class='notice'>This unit is law synced to {{:data.isSlaved}}.</span>
{{/if}}
{{if data.isMalf || data.isAIMalf}}
@@ -101,7 +101,7 @@
<td>{{:helper.link('Yes', null, {'ref': value.ref, 'state_law' : 1}, value.state == 1 ? 'selected' : null)}}{{:helper.link('No', null, {'ref': value.ref, 'state_law' : 0}, value.state != 1 ? 'selected' : null)}}</td>
{{if data.isMalf}}
<td class='edit'>{{:helper.link('Edit', null, {'edit_law': value.ref}, data.isAdmin ? null : 'disabled')}}</td>
<td class='delete'>{{:helper.link('Delete', null, {'delete_law': value.ref}, data.isAdmin ? null : 'disabled', data.IsAdmin ? 'redButton' : null)}}</td>
<td class='delete'>{{:helper.link('Delete', null, {'delete_law': value.ref}, data.isAdmin ? null : 'disabled', data.isAdmin ? 'redButton' : null)}}</td>
{{/if}}
</tr>
{{/for}}
@@ -185,17 +185,7 @@
</div>
{{/if}}
{{if data.isMalf}}
<div class="item">
<div class="itemLabelNarrow">
Sync Laws:
</div>
<div class="itemContent">
{{:helper.link('Sync Laws', null, {'sync_laws' : 1})}}
</div>
</div>
{{/if}}
{{if data.isAI}}
<div class="item">
<div class="itemLabelNarrow">
Law Notification:
@@ -204,6 +194,7 @@
{{:helper.link('Notify', null, {'notify_laws' : 1})}}
</div>
</div>
{{/if}}
{{else data.view == 1}}
{{for data.law_sets}}
<div class="item">