From 821b324e6ae7429b7a2cc49c2dc24f342a363c4d Mon Sep 17 00:00:00 2001 From: alex-gh Date: Tue, 14 Jun 2022 14:31:18 +0200 Subject: [PATCH] [Ready] AI building fixes: Runtimes when adding AI law modules, Syndicate modules work during building again, Helpful messages for freeform modules. (#17935) * Fixes rumtimes when adding AI law modules while building AI * Syndicate AI modules now can be used during AI construction Freeform modules now provide helpful messages if you try to use empty module on the AI during construction Co-authored-by: Kugamo --- code/game/machinery/computer/ai_core.dm | 16 +++++++++++++++- code/game/objects/items/weapons/AI_modules.dm | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/code/game/machinery/computer/ai_core.dm b/code/game/machinery/computer/ai_core.dm index b9c567321c3..069533e18a6 100644 --- a/code/game/machinery/computer/ai_core.dm +++ b/code/game/machinery/computer/ai_core.dm @@ -6,7 +6,7 @@ icon_state = "0" max_integrity = 500 var/state = 0 - var/datum/ai_laws/laws = null + var/datum/ai_laws/laws = new /datum/ai_laws/crewsimov() var/obj/item/circuitboard/aicore/circuit = null var/obj/item/mmi/brain = null @@ -63,16 +63,30 @@ if(istype(P, /obj/item/aiModule/freeform)) var/obj/item/aiModule/freeform/M = P + if(!M.newFreeFormLaw) + to_chat(usr, "No law detected on module, please create one.") + return laws.add_inherent_law(M.newFreeFormLaw) to_chat(usr, "Added a freeform law.") return + if(istype(P, /obj/item/aiModule/syndicate)) + var/obj/item/aiModule/syndicate/M = P + if(!M.newFreeFormLaw) + to_chat(usr, "No law detected on module, please create one.") + return + laws.add_ion_law(M.newFreeFormLaw) + to_chat(usr, "Added a hacked law.") + return + if(istype(P, /obj/item/aiModule)) var/obj/item/aiModule/M = P if(!M.laws) to_chat(usr, "This AI module can not be applied directly to AI cores.") return laws = M.laws + to_chat(usr, "Added [M.laws.name] laws.") + return if(istype(P, /obj/item/mmi) && !brain) var/obj/item/mmi/M = P diff --git a/code/game/objects/items/weapons/AI_modules.dm b/code/game/objects/items/weapons/AI_modules.dm index cd31f945770..2d9255ae798 100755 --- a/code/game/objects/items/weapons/AI_modules.dm +++ b/code/game/objects/items/weapons/AI_modules.dm @@ -188,7 +188,7 @@ AI MODULES /****************** New Freeform ******************/ /obj/item/aiModule/freeform // Slightly more dynamic freeform module -- TLE name = "\improper Freeform AI module" - var/newFreeFormLaw = "freeform" + var/newFreeFormLaw = "" var/lawpos = 15 desc = "A 'freeform' AI module: ''" origin_tech = "programming=4;materials=4"