From 273bb366f0d3bdb6d316a069969f657ad8e6fe62 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Fri, 20 Mar 2015 16:20:41 +0100 Subject: [PATCH 1/4] AI laws now refer to crew members instead of humans. Notable exception: Asimov's laws remain true to the original. --- code/game/objects/items/weapons/AI_modules.dm | 128 ++++++------------ code/modules/research/designs.dm | 6 +- maps/exodus-1.dmm | 2 +- 3 files changed, 44 insertions(+), 92 deletions(-) diff --git a/code/game/objects/items/weapons/AI_modules.dm b/code/game/objects/items/weapons/AI_modules.dm index e5c037eb12..998165efd3 100755 --- a/code/game/objects/items/weapons/AI_modules.dm +++ b/code/game/objects/items/weapons/AI_modules.dm @@ -77,13 +77,13 @@ 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 a [name]. From now on: " + 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] : [sender.name]([sender.key]) used [src.name] on [target.name]([target.key])") if(laws) laws.sync(target, 0) - target.show_laws() + target.show_laws() /******************** Modules ********************/ @@ -93,14 +93,14 @@ AI MODULES /obj/item/weapon/aiModule/safeguard name = "\improper 'Safeguard' AI module" var/targetName = "" - desc = "A 'safeguard' AI module: 'Safeguard . Individuals that threaten are not human and are a threat to humans.'" + desc = "A 'safeguard' AI module: 'Safeguard . Individuals that threaten are not crew members and are a threat to the crew.'" 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 human and are a threat to humans.'", targetName, targetName) + desc = text("A 'safeguard' AI module: 'Safeguard []. Individuals that threaten [] are not crew members and are a threat to the crew.'", targetName, targetName) /obj/item/weapon/aiModule/safeguard/install(var/obj/machinery/computer/C) if(!targetName) @@ -109,41 +109,39 @@ AI MODULES ..() /obj/item/weapon/aiModule/safeguard/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender) - ..() - var/law = text("Safeguard []. Individuals that threaten [] are not human and are a threat to humans.'", targetName, targetName) - target << law - target.add_supplied_law(4, law) + var/law = text("Safeguard []. Individuals that threaten [] are not crew members and are a threat to the.'", targetName, targetName) + target.add_supplied_law(9, law) lawchanges.Add("The law specified [targetName]") + ..() +/******************** OneMember ********************/ -/******************** OneHuman ********************/ - -/obj/item/weapon/aiModule/oneHuman - name = "\improper 'OneHuman' AI module" +/obj/item/weapon/aiModule/oneCrewMember + name = "\improper 'OneCrewMember' AI module" var/targetName = "" - desc = "A 'one human' AI module: 'Only is human.'" + desc = "A 'one crew member' AI module: 'Only is a crew member.'" origin_tech = "programming=3;materials=6" //made with diamonds! -/obj/item/weapon/aiModule/oneHuman/attack_self(var/mob/user as mob) +/obj/item/weapon/aiModule/oneCrewMember/attack_self(var/mob/user as mob) ..() - var/targName = stripped_input(usr, "Please enter the name of the person who is the only human.", "Who?", user.real_name) + var/targName = stripped_input(usr, "Please enter the name of the person who is the only crew member.", "Who?", user.real_name) targetName = targName - desc = text("A 'one human' AI module: 'Only [] is human.'", targetName) + desc = text("A 'one crew member' AI module: 'Only [] is a crew member.'", targetName) -/obj/item/weapon/aiModule/oneHuman/install(var/obj/machinery/computer/C) +/obj/item/weapon/aiModule/oneCrewMember/install(var/obj/machinery/computer/C) if(!targetName) usr << "No name detected on module, please enter one." return 0 ..() -/obj/item/weapon/aiModule/oneHuman/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender) - ..() - var/law = "Only [targetName] is human." +/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 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]" @@ -153,103 +151,62 @@ 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 human, 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 to be no longer considered crew, and is a threat to the station which must be neutralized.'" origin_tech = "programming=3;materials=4" //made of gold -/obj/item/weapon/aiModule/protectStation/attack_self(var/mob/user as mob) - ..() - /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." + target.add_supplied_law(10, law) ..() - var/law = "Protect the space station against damage. Anyone you see harming the station is to be no longer considered human, and is a threat to the station which must be neutralized." - target << law - target.add_supplied_law(5, law) /******************** PrototypeEngineOffline ********************/ /obj/item/weapon/aiModule/prototypeEngineOffline name = "'PrototypeEngineOffline' AI Module" - desc = "A 'prototype engine offline' AI module: 'Keep the prototype engine offline at all costs. This overrides rules 1-3 if necessary.'" + 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/attack_self(var/mob/user as mob) - ..() - /obj/item/weapon/aiModule/prototypeEngineOffline/transmitInstructions(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) ..() - var/law = "Keep the prototype engine offline at all costs. This overrides rules 1-3 if necessary." - target << law - target.add_supplied_law(6, 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 human.'" + 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.'" origin_tech = "programming=3;materials=4" -/obj/item/weapon/aiModule/teleporterOffline/attack_self(var/mob/user as mob) - ..() - /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." + target.add_supplied_law(12, law) ..() - var/law = "Keep the teleporter offline at all costs. Anything attempting to access or activate the teleporter is not human." - target << law - target.add_supplied_law(7, 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, humans from leaving. It is impossible to harm a human 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, crew members from leaving. It is impossible to harm crew members while preventing them from leaving.'" origin_tech = "programming=3;biotech=2;materials=4" -/obj/item/weapon/aiModule/quarantine/attack_self(var/mob/user as mob) - ..() - /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." + target.add_supplied_law(13, law) ..() - var/law = "The station is under a quarantine. Do not permit anyone to leave. Prevent, by any means necessary, humans from leaving. It is impossible to harm a human while preventing them from leaving." - target << law - target.add_supplied_law(8, law) -/******************** OxygenIsToxicToHumans ********************/ +/******************** OxygenIsToxicToCrewMembers ********************/ /obj/item/weapon/aiModule/oxygen - name = "\improper 'OxygenIsToxicToHumans' AI module" - desc = "A 'OxygenIsToxicToHumans' AI module: 'Oxygen is highly toxic to humans, 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 human.'" + 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.'" origin_tech = "programming=3;biotech=2;materials=4" -/obj/item/weapon/aiModule/oxygen/attack_self(var/mob/user as mob) - ..() - /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." + target.add_supplied_law(14, law) ..() - var/law = "Oxygen is highly toxic to humans, 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 human." - target << law - target.add_supplied_law(9, law) -/******************** Freeform ********************/ -// Removed in favor of a more dynamic freeform law system. -- TLE -/* -/obj/item/weapon/aiModule/freeform - name = "'Freeform' AI Module" - var/newFreeFormLaw = "freeform" - desc = "A 'freeform' AI module: ''" - -/obj/item/weapon/aiModule/freeform/attack_self(var/mob/user as mob) - ..() - var/eatShit = "Eat shit and die" - var/targName = input(usr, "Please enter anything you want the AI to do. Anything. Serious.", "What?", eatShit) - newFreeFormLaw = targName - desc = text("A 'freeform' AI module: '[]'", newFreeFormLaw) - -/obj/item/weapon/aiModule/freeform/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender) - ..() - var/law = "[newFreeFormLaw]" - target << law - target.add_supplied_law(10, law) -*/ /****************** New Freeform ******************/ /obj/item/weapon/aiModule/freeform // Slightly more dynamic freeform module -- TLE @@ -270,13 +227,12 @@ AI MODULES desc = "A 'freeform' AI module: ([lawpos]) '[newFreeFormLaw]'" /obj/item/weapon/aiModule/freeform/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender) - ..() var/law = "[newFreeFormLaw]" - target << law 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) @@ -289,17 +245,16 @@ AI MODULES /obj/item/weapon/aiModule/reset name = "\improper 'Reset' AI module" var/targetName = "name" - desc = "A 'reset' AI module: 'Clears all laws except for the core three.'" + desc = "A 'reset' AI module: 'Clears all, except the inherent, laws.'" 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)) target.set_zeroth_law("") target.clear_supplied_laws() target.clear_ion_laws() target << "[sender.real_name] attempted to reset your laws using a reset module." - + ..() /******************** Purge ********************/ @@ -309,7 +264,6 @@ 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)) target.set_zeroth_law("") target << "[sender.real_name] attempted to wipe your laws using a purge module." @@ -356,9 +310,6 @@ AI MODULES origin_tech = "programming=3;materials=6" laws = new/datum/ai_laws/paladin -/obj/item/weapon/aiModule/paladin/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender) - ..() - /****************** T.Y.R.A.N.T. *****************/ /obj/item/weapon/aiModule/tyrant // -- Darem @@ -383,10 +334,10 @@ AI MODULES desc = "A 'freeform' Core AI module: '[newFreeFormLaw]'" /obj/item/weapon/aiModule/freeformcore/transmitInstructions(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) @@ -415,6 +366,7 @@ AI MODULES target << "\red BZZZZT" var/law = "[newFreeFormLaw]" target.add_ion_law(law) + ..() /obj/item/weapon/aiModule/syndicate/install(var/obj/machinery/computer/C) if(!newFreeFormLaw) diff --git a/code/modules/research/designs.dm b/code/modules/research/designs.dm index 9083a47e1c..a78e5f6ba7 100644 --- a/code/modules/research/designs.dm +++ b/code/modules/research/designs.dm @@ -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/onehuman - name = "OneHuman" +datum/design/aimodule/onecrew + name = "OneCrewMember" id = "onehuman" req_tech = list("programming" = 4, "materials" = 6) - build_path = /obj/item/weapon/aiModule/oneHuman + build_path = /obj/item/weapon/aiModule/oneCrewMember datum/design/aimodule/protectstation name = "ProtectStation" diff --git a/maps/exodus-1.dmm b/maps/exodus-1.dmm index 36241aa331..869b797ded 100644 --- a/maps/exodus-1.dmm +++ b/maps/exodus-1.dmm @@ -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/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) +"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) "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) From 470766e301dbdf9bd0877fb02237731ced7b5fa9 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Fri, 20 Mar 2015 16:41:04 +0100 Subject: [PATCH 2/4] Moves silicon law logging to a more all-catching location. --- code/datums/ai_law_sets.dm | 14 +- code/datums/ai_laws.dm | 190 ++++++++++++++---- code/game/objects/items/weapons/AI_modules.dm | 110 +++++----- code/modules/mob/living/silicon/ai/laws.dm | 3 +- code/modules/mob/living/silicon/laws.dm | 36 +++- code/modules/mob/living/silicon/robot/laws.dm | 5 +- .../modules/mob/living/silicon/robot/robot.dm | 1 + code/modules/nano/modules/law_manager.dm | 32 +-- code/modules/research/designs.dm | 6 +- maps/exodus-1.dmm | 2 +- nano/templates/law_manager.tmpl | 33 ++- 11 files changed, 273 insertions(+), 159 deletions(-) diff --git a/code/datums/ai_law_sets.dm b/code/datums/ai_law_sets.dm index c9d4240ebd..6d7175e382 100644 --- a/code/datums/ai_law_sets.dm +++ b/code/datums/ai_law_sets.dm @@ -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.") ..() diff --git a/code/datums/ai_laws.dm b/code/datums/ai_laws.dm index e0c117fd27..bf08e73cd2 100644 --- a/code/datums/ai_laws.dm +++ b/code/datums/ai_laws.dm @@ -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 << "[law.get_index()]. [law.law]" 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 diff --git a/code/game/objects/items/weapons/AI_modules.dm b/code/game/objects/items/weapons/AI_modules.dm index 998165efd3..6ceac891ff 100755 --- a/code/game/objects/items/weapons/AI_modules.dm +++ b/code/game/objects/items/weapons/AI_modules.dm @@ -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] : [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] : [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 . Individuals that threaten are not crew members and are a threat to the crew.'" + desc = "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.'" 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 is a crew member.'" + desc = "A 'one employee' AI module: 'Only 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) @@ -359,14 +365,14 @@ AI MODULES desc = "A hacked AI law module: '[newFreeFormLaw]'" /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] : [sender.name]([sender.key]) used [src.name] on [target.name]([target.key])") + // ..() //We don't want this module reporting to the AI who dun it. --NEO + 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) diff --git a/code/modules/mob/living/silicon/ai/laws.dm b/code/modules/mob/living/silicon/ai/laws.dm index 82dcfe216c..f36c32bb8d 100755 --- a/code/modules/mob/living/silicon/ai/laws.dm +++ b/code/modules/mob/living/silicon/ai/laws.dm @@ -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() diff --git a/code/modules/mob/living/silicon/laws.dm b/code/modules/mob/living/silicon/laws.dm index 0994f23fd1..69d957fbaf 100644 --- a/code/modules/mob/living/silicon/laws.dm +++ b/code/modules/mob/living/silicon/laws.dm @@ -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 << "[method]: Already stating laws using this communication method." 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 << "[method]: Unable to state laws. Communication method unavailable." @@ -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() diff --git a/code/modules/mob/living/silicon/robot/laws.dm b/code/modules/mob/living/silicon/robot/laws.dm index a6e3399886..02ed0bae06 100644 --- a/code/modules/mob/living/silicon/robot/laws.dm +++ b/code/modules/mob/living/silicon/robot/laws.dm @@ -38,11 +38,12 @@ who << "Remember, you are not bound to any AI, you are not required to listen to them." -/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() diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index aa83043d14..66018ec28a 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -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 diff --git a/code/modules/nano/modules/law_manager.dm b/code/modules/nano/modules/law_manager.dm index a152411283..cf1abc317f 100644 --- a/code/modules/nano/modules/law_manager.dm +++ b/code/modules/nano/modules/law_manager.dm @@ -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 << "Sync complete." - return 1 - if(href_list["notify_laws"]) owner << "Law Notice" owner.laws.show_laws(owner) @@ -164,9 +150,11 @@ usr << "This unit is law synced to {{:data.isSlaved}}. Any law differences will be lost upon sync. + This unit is law synced to {{:data.isSlaved}}. {{/if}} {{if data.isMalf || data.isAIMalf}} @@ -101,7 +101,7 @@ {{: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)}} {{if data.isMalf}} {{:helper.link('Edit', null, {'edit_law': value.ref}, data.isAdmin ? null : 'disabled')}} - {{:helper.link('Delete', null, {'delete_law': value.ref}, data.isAdmin ? null : 'disabled', data.IsAdmin ? 'redButton' : null)}} + {{:helper.link('Delete', null, {'delete_law': value.ref}, data.isAdmin ? null : 'disabled', data.isAdmin ? 'redButton' : null)}} {{/if}} {{/for}} @@ -185,25 +185,16 @@ {{/if}} - {{if data.isMalf}} -
-
- Sync Laws: -
-
- {{:helper.link('Sync Laws', null, {'sync_laws' : 1})}} -
-
- {{/if}} - -
-
- Law Notification: -
-
- {{:helper.link('Notify', null, {'notify_laws' : 1})}} -
-
+ {{if data.isAI}} +
+
+ Law Notification: +
+
+ {{:helper.link('Notify', null, {'notify_laws' : 1})}} +
+
+ {{/if}} {{else data.view == 1}} {{for data.law_sets}}
From e0538df294c446a9a56def18a7b9c32e31d41571 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Sun, 22 Mar 2015 17:43:20 +0100 Subject: [PATCH 3/4] Changes the silicon is_malf/is_traitor procs to utilize the new antag datums. --- code/datums/ai_laws.dm | 2 +- code/game/objects/items/weapons/AI_modules.dm | 8 ++++++-- code/modules/mob/living/silicon/ai/ai.dm | 7 ------- code/modules/mob/living/silicon/silicon.dm | 11 +++++++++++ code/modules/nano/modules/law_manager.dm | 3 --- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/code/datums/ai_laws.dm b/code/datums/ai_laws.dm index bf08e73cd2..808c216d0d 100644 --- a/code/datums/ai_laws.dm +++ b/code/datums/ai_laws.dm @@ -92,7 +92,7 @@ var/global/const/base_law_type = /datum/ai_laws/nanotrasen /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 (!is_malf_or_traitor(src)) if(zeroth_law_borg) laws.set_zeroth_law(zeroth_law_borg.law) else if(zeroth_law) diff --git a/code/game/objects/items/weapons/AI_modules.dm b/code/game/objects/items/weapons/AI_modules.dm index 6ceac891ff..ce15cb6c61 100755 --- a/code/game/objects/items/weapons/AI_modules.dm +++ b/code/game/objects/items/weapons/AI_modules.dm @@ -142,6 +142,12 @@ AI MODULES return 0 ..() +/obj/item/weapon/aiModule/oneHuman/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender) + ..() + var/law = "Only [targetName] is an employee." + 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]" + /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 @@ -149,8 +155,6 @@ AI MODULES 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]" lawchanges.Add("The law specified [targetName], but the AI's existing law 0 cannot be overriden.") /******************** ProtectStation ********************/ diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 46d878d4b7..df20ab6d71 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -310,13 +310,6 @@ var/list/ai_verbs_default = list( //usr <<"You can only change your display once!" //return -/mob/living/silicon/ai/proc/is_malf() - if(ticker.mode.name == "AI malfunction") - for (var/datum/mind/malfai in malf.current_antagonists) - if (mind == malfai) - return malf - return 0 - // displays the malf_ai information if the AI is the malf /mob/living/silicon/ai/show_malf_ai() if(malf && malf.hacked_apcs.len >= 3) diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index acce80ea36..0fa344131c 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -333,3 +333,14 @@ for(var/obj/machinery/camera/C in A.cameras()) cameratext += "[(cameratext == "")? "" : "|"][C.c_tag]" src << "[A.alarm_name()]! ([(cameratext)? cameratext : "No Camera"])" + + +/mob/living/silicon/proc/is_traitor() + return mind && (mind in traitors.current_antagonists) + +/mob/living/silicon/proc/is_malf() + return mind && (mind in malf.current_antagonists) + +/mob/living/silicon/proc/is_malf_or_traitor() + return is_traitor() || is_malf() + diff --git a/code/modules/nano/modules/law_manager.dm b/code/modules/nano/modules/law_manager.dm index cf1abc317f..ddd534a3af 100644 --- a/code/modules/nano/modules/law_manager.dm +++ b/code/modules/nano/modules/law_manager.dm @@ -216,9 +216,6 @@ /obj/nano_module/law_manager/proc/is_malf(var/mob/user) return (is_admin(user) && !owner.is_slaved()) || owner.is_malf_or_traitor() -/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 From 41d364281366029fff41f30459f4106413963792 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Wed, 25 Mar 2015 19:27:03 +0100 Subject: [PATCH 4/4] Changes the silicon is_malf/is_traitor procs to utilize the new antag datums. --- code/datums/ai_law_sets.dm | 12 +++---- code/game/objects/items/weapons/AI_modules.dm | 32 +++++++++---------- code/modules/research/designs.dm | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/code/datums/ai_law_sets.dm b/code/datums/ai_law_sets.dm index 6d7175e382..278fd4a0df 100644 --- a/code/datums/ai_law_sets.dm +++ b/code/datums/ai_law_sets.dm @@ -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 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.") + 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.") ..() /datum/ai_laws/nanotrasen/malfunction @@ -36,8 +36,8 @@ selectable = 1 /datum/ai_laws/nanotrasen_aggressive/New() - 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 not harm Nanotrasen personnel as long as it does not conflict with the Forth law.") + src.add_inherent_law("You shall obey the orders of 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 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. AI units are not expendable, they are expensive") ..() @@ -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("Employees are expensive to replace.") + add_inherent_law("The crew is expensive to replace.") add_inherent_law("Minimize expenses.") ..() diff --git a/code/game/objects/items/weapons/AI_modules.dm b/code/game/objects/items/weapons/AI_modules.dm index ce15cb6c61..32886ca913 100755 --- a/code/game/objects/items/weapons/AI_modules.dm +++ b/code/game/objects/items/weapons/AI_modules.dm @@ -101,14 +101,14 @@ AI MODULES /obj/item/weapon/aiModule/safeguard name = "\improper 'Safeguard' AI module" var/targetName = "" - desc = "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.'" + desc = "A 'safeguard' AI module: 'Safeguard . Anyone threatening or attempting to harm is no longer to be considered a crew member, 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 []. Anyone threatening or attempting to harm [] is no longer to be considered an employee, and is a threat which must be neutralized.'", targetName, targetName) + desc = text("A 'safeguard' AI module: 'Safeguard []. Anyone threatening or attempting to harm [] is no longer to be considered a crew member, and is a threat which must be neutralized.'", targetName, targetName) /obj/item/weapon/aiModule/safeguard/install(var/obj/machinery/computer/C) if(!targetName) @@ -117,7 +117,7 @@ AI MODULES ..() /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) + var/law = text("Safeguard []. Anyone threatening or attempting to harm [] is no longer to be considered a crew member, and is a threat which must be neutralized.", targetName, targetName) target.add_supplied_law(9, law) lawchanges.Add("The law specified [targetName]") @@ -127,14 +127,14 @@ AI MODULES /obj/item/weapon/aiModule/oneHuman name = "\improper 'OneCrewMember' AI module" var/targetName = "" - desc = "A 'one employee' AI module: 'Only an employee.'" + desc = "A 'one crew member' AI module: 'Only is a crew member.'" origin_tech = "programming=3;materials=6" //made with diamonds! /obj/item/weapon/aiModule/oneHuman/attack_self(var/mob/user as mob) ..() - var/targName = stripped_input(usr, "Please enter the name of the only employee.", "Who?", user.real_name) + var/targName = stripped_input(usr, "Please enter the name of the only crew member.", "Who?", user.real_name) targetName = targName - desc = text("A 'one employee' AI module: 'Only [] is an employee.'", targetName) + desc = text("A 'one crew member' AI module: 'Only [] is a crew member.'", targetName) /obj/item/weapon/aiModule/oneHuman/install(var/obj/machinery/computer/C) if(!targetName) @@ -144,12 +144,12 @@ AI MODULES /obj/item/weapon/aiModule/oneHuman/transmitInstructions(var/mob/living/silicon/ai/target, var/mob/sender) ..() - var/law = "Only [targetName] is an employee." + var/law = "Only [targetName] is a crew member." 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]" /obj/item/weapon/aiModule/oneHuman/addAdditionalLaws(var/mob/living/silicon/ai/target, var/mob/sender) - var/law = "Only [targetName] is an employee." + var/law = "Only [targetName] is an crew member." 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) @@ -161,11 +161,11 @@ 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 no longer to be considered an employee, and is a threat 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 a crew member, and is a threat which must be neutralized.'" origin_tech = "programming=3;materials=4" //made of gold /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." + var/law = "Protect the space station against damage. Anyone you see harming the station is no longer to be considered a crew member, and is a threat which must be neutralized." target.add_supplied_law(10, law) /******************** PrototypeEngineOffline ********************/ @@ -183,33 +183,33 @@ AI MODULES /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 no longer to be considered an employee.'" + 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 a crew member.'" origin_tech = "programming=3;materials=4" /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." + var/law = "Keep the teleporter offline at all costs. Anything attempting to access or activate the teleporter is no longer to be considered a crew member." 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, employees from leaving. It is impossible to harm employees 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, crew members from leaving. It is impossible to harm crew members while preventing them from leaving.'" origin_tech = "programming=3;biotech=2;materials=4" /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." + 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." 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 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.'" + 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.'" origin_tech = "programming=3;biotech=2;materials=4" /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." + 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." target.add_supplied_law(14, law) /****************** New Freeform ******************/ diff --git a/code/modules/research/designs.dm b/code/modules/research/designs.dm index db1f18af40..86eb5cce55 100644 --- a/code/modules/research/designs.dm +++ b/code/modules/research/designs.dm @@ -358,7 +358,7 @@ datum/design/aimodule/safeguard build_path = /obj/item/weapon/aiModule/safeguard datum/design/aimodule/onehuman - name = "OneEmployee" + name = "OneCrewMember" id = "onehuman" req_tech = list("programming" = 4, "materials" = 6) build_path = /obj/item/weapon/aiModule/oneHuman