From 800369ef9f8577df26934ea5fac229276b8204bc Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 4 Aug 2022 16:49:11 +0200 Subject: [PATCH] [MIRROR] AI Lawset can now be specified instead of 'custom' [MDB IGNORE] (#15375) * AI Lawset can now be specified instead of 'custom' (#68587) * AI Lawset can now be specified instead of 'custom' Co-authored-by: Charlotte <98856144+orthography@users.noreply.github.com> --- .../configuration/entries/game_options.dm | 6 +++++- code/datums/ai_laws/ai_laws.dm | 18 ++++++++++++++++++ config/game_options.txt | 11 +++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index abed471d462..7390679746e 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -282,12 +282,16 @@ /datum/config_entry/number/default_laws //Controls what laws the AI spawns with. default = 0 min_val = 0 - max_val = 3 + max_val = 4 /datum/config_entry/number/silicon_max_law_amount default = 12 min_val = 0 +/datum/config_entry/keyed_list/specified_laws + key_mode = KEY_MODE_TEXT + value_mode = VALUE_MODE_FLAG + /datum/config_entry/keyed_list/random_laws key_mode = KEY_MODE_TEXT value_mode = VALUE_MODE_FLAG diff --git a/code/datums/ai_laws/ai_laws.dm b/code/datums/ai_laws/ai_laws.dm index a066f28d63e..8dd40dddaf6 100644 --- a/code/datums/ai_laws/ai_laws.dm +++ b/code/datums/ai_laws/ai_laws.dm @@ -24,11 +24,14 @@ #define CONFIG_RANDOM 2 /// Set to a configged weighted list of lawtypes in the config. This lets server owners pick from a pool of sane laws, it is also the same process for ian law rerolls. #define CONFIG_WEIGHTED 3 +/// Set to a specific lawset in the game options. +#define CONFIG_SPECIFIED 4 ///first called when something wants round default laws for the first time in a round, considers config ///returns a law datum that GLOB._round_default_lawset will be set to. /proc/setup_round_default_laws() var/list/law_ids = CONFIG_GET(keyed_list/random_laws) + var/list/specified_law_ids = CONFIG_GET(keyed_list/specified_laws) if(HAS_TRAIT(SSstation, STATION_TRAIT_UNIQUE_AI)) return pick_weighted_lawset() @@ -36,6 +39,21 @@ switch(CONFIG_GET(number/default_laws)) if(CONFIG_ASIMOV) return /datum/ai_laws/default/asimov + if(CONFIG_SPECIFIED) + var/list/specified_laws = list() + for (var/law_id in specified_law_ids) + var/datum/ai_laws/laws = lawid_to_type(law_id) + if (isnull(laws)) + log_config("ERROR: Specified law [law_id] does not exist!") + continue + specified_laws += laws + var/datum/ai_laws/lawtype + if(specified_laws.len) + lawtype = pick(specified_laws) + else + lawtype = pick(subtypesof(/datum/ai_laws/default)) + + return lawtype if(CONFIG_CUSTOM) return /datum/ai_laws/custom if(CONFIG_RANDOM) diff --git a/config/game_options.txt b/config/game_options.txt index c8b405f64fb..8e13e79b1f1 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -217,8 +217,19 @@ NEAR_DEATH_EXPERIENCE ## Set to 1 for "custom", silicons will start with the custom laws defined in silicon_laws.txt. (If silicon_laws.txt is empty, the AI will spawn with asimov and Custom boards will auto-delete.) ## Set to 2 for "random", silicons will start with a random lawset picked from random laws specified below. ## Set to 3 for "weighted random", using values in "silicon_weights.txt", a law will be selected, with weights specifed in that file. +## Set to 4 for "specified", silicons will start with an existing lawset. (If no specified lawset is identified, the AI will spawn with asimov.) + + DEFAULT_LAWS 0 +## SPECIFIED LAWS ## +## ------------------------------------------------------------------------------------------ +## These control what lawset the AI will use, edit the specified law to an *existing* lawset to make it the default. +## See datums\ai_laws.dm for the full law lists +## IE, SPECIFIED_LAWS asimovpp, SPECIFIED_LAWS robocop, SPECIFIED_LAWS antimov + +SPECIFIED_LAWS asimovpp + ## RANDOM LAWS ## ## ------------------------------------------------------------------------------------------ ## These control what laws are available for selection if random silicon laws are active.