Round weighting now reduces the chances of repeating a recently played mode (#30522)

* Automatic changelog generation for PR #30056 [ci skip]

* Less Repeated Modes

* Delete AutoChangeLog-pr-30056.yml

* Update configuration.dm

* No need for .sav contingency

* Making it configurable

* Config fixes

* Tested and Working Edition
This commit is contained in:
Robustin
2017-09-11 21:38:11 -04:00
committed by Jordan Brown
parent 7da8d6619e
commit 8503bf3f6a
3 changed files with 44 additions and 4 deletions
+14 -3
View File
@@ -133,6 +133,7 @@ GLOBAL_PROTECT(config_dir)
var/list/probabilities = list() // relative probability of each mode
var/list/min_pop = list() // overrides for acceptible player counts in a mode
var/list/max_pop = list()
var/list/adjust = list() // weight adjustments for recent modes
var/humans_need_surnames = 0
var/allow_ai = 0 // allow ai job
@@ -709,7 +710,11 @@ GLOBAL_PROTECT(config_dir)
WRITE_FILE(GLOB.config_error_log, "Unknown game mode probability configuration definition: [prob_name].")
else
WRITE_FILE(GLOB.config_error_log, "Incorrect probability configuration definition: [prob_name] [prob_value].")
if("adjust")
if(value)
adjust += text2num(value)
else
WRITE_FILE(GLOB.config_error_log, "Incorrect round weight adjustment configuration definition for [value].")
if("protect_roles_from_antagonist")
protect_roles_from_antagonist = 1
if("protect_assistant_from_antagonist")
@@ -960,8 +965,14 @@ GLOBAL_PROTECT(config_dir)
if(max_pop[M.config_tag])
M.maximum_players = max_pop[M.config_tag]
if(M.can_start())
runnable_modes[M] = probabilities[M.config_tag]
//to_chat(world, "DEBUG: runnable_mode\[[runnable_modes.len]\] = [M.config_tag]")
var/final_weight = probabilities[M.config_tag]
var/recent_round = SSpersistence.saved_modes.Find(M.config_tag)
var/adjustment
while(recent_round)
adjustment += adjust[recent_round]
recent_round = SSpersistence.saved_modes.Find(M.config_tag,recent_round+1,0)
final_weight *= ((100-adjustment)/100)
runnable_modes[M] = final_weight
return runnable_modes
/datum/configuration/proc/get_runnable_midround_modes(crew)
+24 -1
View File
@@ -8,7 +8,7 @@ SUBSYSTEM_DEF(persistence)
var/list/obj/structure/chisel_message/chisel_messages = list()
var/list/saved_messages = list()
var/list/saved_modes = list(1,2,3)
var/list/saved_trophies = list()
/datum/controller/subsystem/persistence/Initialize()
@@ -16,6 +16,7 @@ SUBSYSTEM_DEF(persistence)
LoadPoly()
LoadChiselMessages()
LoadTrophies()
LoadRecentModes()
..()
/datum/controller/subsystem/persistence/proc/LoadSatchels()
@@ -136,6 +137,17 @@ SUBSYSTEM_DEF(persistence)
saved_trophies = json["data"]
SetUpTrophies(saved_trophies.Copy())
/datum/controller/subsystem/persistence/proc/LoadRecentModes()
var/json_file = file("data/RecentModes.json")
if(!fexists(json_file))
return
var/list/json = list()
json = json_decode(file2text(json_file))
if(!json)
return
saved_modes = json["data"]
/datum/controller/subsystem/persistence/proc/SetUpTrophies(list/trophy_items)
for(var/A in GLOB.trophy_cases)
var/obj/structure/displaycase/trophy/T = A
@@ -165,6 +177,7 @@ SUBSYSTEM_DEF(persistence)
CollectChiselMessages()
CollectSecretSatchels()
CollectTrophies()
CollectRoundtype()
/datum/controller/subsystem/persistence/proc/CollectSecretSatchels()
var/list/satchels = list()
@@ -224,3 +237,13 @@ SUBSYSTEM_DEF(persistence)
data["message"] = T.trophy_message
data["placer_key"] = T.placer_key
saved_trophies += list(data)
/datum/controller/subsystem/persistence/proc/CollectRoundtype()
saved_modes[3] = saved_modes[2]
saved_modes[2] = saved_modes[1]
saved_modes[1] = SSticker.mode.config_tag
var/json_file = file("data/RecentModes.json")
var/list/file_data = list()
file_data["data"] = saved_modes
fdel(json_file)
WRITE_FILE(json_file, json_encode(file_data))
+6
View File
@@ -101,6 +101,12 @@ PROBABILITY DEVIL_AGENTS 0
## You probably want to keep sandbox off by default for secret and random.
PROBABILITY SANDBOX 0
## Percent weight reductions for three of the most recent modes where the top figure is the most recent.
ADJUST 45
ADJUST 30
ADJUST 10
## Toggles for continuous modes.
## Modes that aren't continuous will end the instant all antagonists are dead.