From 07064298b0d51d45e961883f33be07d9eefa29ac Mon Sep 17 00:00:00 2001 From: Putnam Date: Sun, 20 Oct 2019 18:54:17 -0700 Subject: [PATCH] Dynamic voting (draft) --- .../configuration/entries/game_options.dm | 2 ++ code/controllers/subsystem/ticker.dm | 2 +- code/controllers/subsystem/vote.dm | 23 +++++++++++++++++-- config/game_options.txt | 3 +++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index cfd57b4850..29bb7671ae 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -364,3 +364,5 @@ /datum/config_entry/number/auto_transfer_delay config_entry_value = 72000 min_val = 0 + +/datum/config_entry/flag/dynamic_voting diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 14e1e86f7d..ccdf98a71f 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -479,7 +479,7 @@ SUBSYSTEM_DEF(ticker) if(SSticker.timeLeft < 900) SSticker.timeLeft = 900 SSticker.modevoted = TRUE - SSvote.initiate_vote("roundtype","server",TRUE) + SSvote.initiate_vote(CONFIG_GET(flag/dynamic_voting) ? "dynamic" : "roundtype","server",TRUE) /datum/controller/subsystem/ticker/Recover() current_state = SSticker.current_state diff --git a/code/controllers/subsystem/vote.dm b/code/controllers/subsystem/vote.dm index 2f56c69384..d32ece5aa8 100644 --- a/code/controllers/subsystem/vote.dm +++ b/code/controllers/subsystem/vote.dm @@ -87,7 +87,7 @@ SUBSYSTEM_DEF(vote) /datum/controller/subsystem/vote/proc/announce_result() var/list/winners = get_result() var/text - var/was_roundtype_vote = mode == "roundtype" + var/was_roundtype_vote = mode == "roundtype" || mode == "dynamic" if(winners.len > 0) if(question) text += "[question]" @@ -124,6 +124,12 @@ SUBSYSTEM_DEF(vote) message_admins(admintext) return . +#define PEACE2 "Very Calm" +#define PEACE1 "Somewhat Calm" +#define INDIFFERENT "Balanced" +#define CHAOS1"Somewhat chaotic" +#define CHAOS2 "Very chaotic" + /datum/controller/subsystem/vote/proc/result() . = announce_result() var/restart = 0 @@ -146,6 +152,17 @@ SUBSYSTEM_DEF(vote) restart = 1 else GLOB.master_mode = . + if("dynamic") + if(SSticker.current_state > GAME_STATE_PREGAME)//Don't change the mode if the round already started. + return message_admins("A vote has tried to change the gamemode, but the game has already started. Aborting.") + GLOB.dynamic_forced_extended = .=="extended" + if(GLOB.dynamic_forced_extended) + return message_admins("Dynamic extended has been voted for.") + var/mean = (choices["extended"]*-2+choices[PEACE2]*-2+choices[PEACE1]*-1+choices[CHAOS1]*1+choices[CHAOS2]*2)/voted.len + var/variance=(((-2-mean)**2)*choices["extended"]+((-2-mean)**2)*choices[PEACE2]+((-1-mean)**2)*choices[PEACE1]+((0-mean)**2)*choices[INDIFFERENT]+((1-mean)**2)*choices[CHAOS1]+((2-mean)**2)*choices[CHAOS2])/voted.len //Sorry. Im sorry. Im trying to remove it + GLOB.dynamic_curve_centre = mean*(5/2) + GLOB.dynamic_curve_width = max(variance,0.5) + message_admins("Dynamic curve centre set to [GLOB.dynamic_curve_centre] and width set to [GLOB.dynamic_curve_width]") if("map") var/datum/map_config/VM = config.maplist[.] message_admins("The map has been voted for and will change to: [VM.map_name]") @@ -213,6 +230,8 @@ SUBSYSTEM_DEF(vote) choices[i] = 0 if("roundtype") //CIT CHANGE - adds the roundstart secret/extended vote choices.Add("secret", "extended") + if("dynamic") + choices.Add("extended",PEACE2,PEACE1,INDIFFERENT,CHAOS1,CHAOS2) if("custom") question = stripped_input(usr,"What is the vote for?") if(!question) @@ -369,4 +388,4 @@ SUBSYSTEM_DEF(vote) else if(owner.ckey) var/datum/player_details/P = GLOB.player_details[owner.ckey] if(P) - P.player_actions -= src \ No newline at end of file + P.player_actions -= src diff --git a/config/game_options.txt b/config/game_options.txt index 2e346ce0ac..80887164ff 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -547,3 +547,6 @@ MONKEYCAP 64 ## Uncomment to use TG-style combat #DISABLE_STAMBUFFER + +#Replaces standard extended/secret dichotomy with extended and 5 levels of chaos using dynamic. +DYNAMIC_VOTING