diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index 068f857c8cb..8297085dbcf 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -464,3 +464,12 @@ /datum/config_entry/number/max_positive_quirks default = 6 min_val = -1 + +/** + * A config that skews with the random spawners weights + * If the value is lower than 1, it'll tend to even out the odds + * If higher than 1, it'll lean toward common spawns even more. + */ +/datum/config_entry/number/random_loot_weight_modifier + default = 1 + min_val = 0.05 diff --git a/code/game/objects/effects/spawners/random/random.dm b/code/game/objects/effects/spawners/random/random.dm index 2c98ba72a4e..ed77f671191 100644 --- a/code/game/objects/effects/spawners/random/random.dm +++ b/code/game/objects/effects/spawners/random/random.dm @@ -52,6 +52,9 @@ if(loot_subtype_path) loot += subtypesof(loot_subtype_path) + if(CONFIG_GET(number/random_loot_weight_modifier) != 1) + skew_loot_weights(CONFIG_GET(number/random_loot_weight_modifier)) + if(loot?.len) var/loot_spawned = 0 var/pixel_divider = FLOOR(16 / spawn_loot_split_pixel_offsets, 1) // 16 pixels offsets is max that should be allowed in any direction @@ -85,6 +88,22 @@ spawned_loot.pixel_y = spawn_loot_split_pixel_offsets * (loot_spawned % pixel_divider) loot_spawned++ +///Levels out the weights of loot if lower than 1, or makes rarer spawns even more rare. +/obj/effect/spawner/random/proc/skew_loot_weights(list/loot_list, exponent) + ///This helps keeping the modified weights more or less correct, since pick_weight doesn't appreciate decimals. + var/precision = 1 + if(exponent < 1) + precision = round((1 - exponent) * 10) + 1 + for(var/loot_type in loot_list) + if(islist(loot_type)) + skew_loot_weights(loot_type, exponent) + var/loot_weight = loot_list[loot_type] + if(loot_weight <= 1) + if(exponent < 1) + loot_list[loot_type] *= precision + continue + loot_list[loot_type] = round(loot_weight ** exponent * precision, 1) + /** * Makes the actual item related to our spawner. * diff --git a/config/game_options.txt b/config/game_options.txt index d4655d4423d..ca32f1b8128 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -572,3 +572,8 @@ NEGATIVE_STATION_TRAITS 3 1 # If set to 0, then players won't be able to select any positive quirks. # If commented-out or undefined, the maximum default is 6. MAX_POSITIVE_QUIRKS 6 + +# A config that skews with the random spawners weights +# If the value is lower than 1, it'll tend to even out the odds +# If higher than 1, it'll lean toward common spawns even more. +RANDOM_LOOT_WEIGHT_MODIFIER 1 \ No newline at end of file