Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions code/controllers/configuration/entries/game_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions code/datums/ai_laws.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
17 changes: 10 additions & 7 deletions code/modules/events/ion_storm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
23 changes: 23 additions & 0 deletions config/game_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

##------------------------------------------------

Expand Down