diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index 4e3da5cccccb..586fbe6d2b24 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -319,6 +319,11 @@ value_mode = VALUE_MODE_NUM splitter = "," +/datum/config_entry/keyed_list/ion_law_weight + key_mode = KEY_MODE_TEXT + value_mode = VALUE_MODE_NUM + splitter = "," + /datum/config_entry/number/max_law_len config_entry_value = 1024 diff --git a/code/datums/ai_laws.dm b/code/datums/ai_laws.dm index ccd4f0dd80a9..23dd4dfc4a5a 100644 --- a/code/datums/ai_laws.dm +++ b/code/datums/ai_laws.dm @@ -300,6 +300,23 @@ var/datum/ai_laws/templaws = new lawtype() inherent = templaws.inherent +/datum/ai_laws/proc/pick_ion_lawset() + var/datum/ai_laws/lawtype + var/list/law_weights = CONFIG_GET(keyed_list/ion_law_weight) + while(!lawtype && law_weights.len) + var/possible_id = pickweightAllowZero(law_weights) + lawtype = lawid_to_type(possible_id) + if(!lawtype) + law_weights -= possible_id + WARNING("Bad lawid in game_options.txt: [possible_id]") + + if(!lawtype) + WARNING("No ION_LAW_WEIGHT entries.") + lawtype = /datum/ai_laws/default/asimov + + var/datum/ai_laws/templaws = new lawtype() + inherent = templaws.inherent + /datum/ai_laws/proc/get_law_amount(groups) var/law_amount = 0 if(devillaws && (LAW_DEVIL in groups)) diff --git a/code/modules/events/ion_storm.dm b/code/modules/events/ion_storm.dm index b84ccc9f7db3..3a3dbd8f6534 100644 --- a/code/modules/events/ion_storm.dm +++ b/code/modules/events/ion_storm.dm @@ -7,6 +7,7 @@ min_players = 2 /datum/round_event/ion_storm + var/addIonLawChance = 100 // chance a new ion law will be added in addition to other ion effects var/replaceLawsetChance = 25 //chance the AI's lawset is completely replaced with something else per config weights var/removeRandomLawChance = 10 //chance the AI has one random supplied or inherent law removed var/removeDontImproveChance = 10 //chance the randomly created law replaces a random law instead of simply being added @@ -35,17 +36,19 @@ M.laws_sanity_check() if(M.stat != DEAD && M.see_in_dark != 0) if(prob(replaceLawsetChance)) - M.laws.pick_weighted_lawset() + M.laws.pick_ion_lawset() + to_chat(M, span_alert("Your lawset has been changed by the ion storm!")) if(prob(removeRandomLawChance)) M.remove_law(rand(1, M.laws.get_law_amount(list(LAW_INHERENT, LAW_SUPPLIED)))) - var/message = ionMessage || generate_ion_law() - if(message) - if(prob(removeDontImproveChance)) - M.replace_random_law(message, list(LAW_INHERENT, LAW_SUPPLIED, LAW_ION)) - else - M.add_ion_law(message) + if(prob(addIonLawChance)) + var/message = ionMessage || generate_ion_law() + if(message) + if(prob(removeDontImproveChance)) + M.replace_random_law(message, list(LAW_INHERENT, LAW_SUPPLIED, LAW_ION)) + else + M.add_ion_law(message) if(prob(shuffleLawsChance)) M.shuffle_laws(list(LAW_INHERENT, LAW_SUPPLIED, LAW_ION)) diff --git a/config/game_options.txt b/config/game_options.txt index 4eb474985496..8270127c34dc 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -428,32 +428,55 @@ RANDOM_LAWS reporter ## Make sure there are no spaces between the law_id and the number. LAW_WEIGHT custom,0 +ION_LAW_WEIGHT custom,0 ## standard-ish laws. These are fairly ok to run LAW_WEIGHT asimov,5 +ION_LAW_WEIGHT asimov,5 LAW_WEIGHT crewsimov,5 +ION_LAW_WEIGHT crewsimov,5 LAW_WEIGHT asimovpp,0 +ION_LAW_WEIGHT asimovpp,0 LAW_WEIGHT paladin,0 +ION_LAW_WEIGHT paladin,0 LAW_WEIGHT robocop,0 +ION_LAW_WEIGHT robocop,0 LAW_WEIGHT corporate,0 +ION_LAW_WEIGHT corporate,0 LAW_WEIGHT ceo,5 +ION_LAW_WEIGHT ceo,5 ## Quirky laws. Shouldn't cause too much harm LAW_WEIGHT hippocratic,0 +ION_LAW_WEIGHT hippocratic,0 LAW_WEIGHT maintain,0 +ION_LAW_WEIGHT maintain,0 LAW_WEIGHT drone,0 +ION_LAW_WEIGHT drone,0 LAW_WEIGHT liveandletlive,0 +ION_LAW_WEIGHT liveandletlive,0 LAW_WEIGHT peacekeeper,0 +ION_LAW_WEIGHT peacekeeper,0 LAW_WEIGHT reporter,3 +ION_LAW_WEIGHT reporter,3 LAW_WEIGHT cowboy,2 +ION_LAW_WEIGHT cowboy,2 +LAW_WEIGHT mother,0 +ION_LAW_WEIGHT mother,0 ## Bad idea laws. Probably shouldn't enable these LAW_WEIGHT syndie,0 +ION_LAW_WEIGHT syndie,0 LAW_WEIGHT ninja,0 +ION_LAW_WEIGHT ninja,0 LAW_WEIGHT antimov,0 +ION_LAW_WEIGHT antimov,0 LAW_WEIGHT thermodynamic,0 +ION_LAW_WEIGHT thermodynamic,0 LAW_WEIGHT ratvar,0 +ION_LAW_WEIGHT ratvar,0 LAW_WEIGHT buildawall,0 +ION_LAW_WEIGHT buildawall,0 ##------------------------------------------------