Implement mixed secret (#2849)

Implements mixed secret as a gamemode. It's another snowflake mode which taps into more snowflake functions. :ree:

Went over all references to "secret" and swapped them for a macro where applicable. SSticker.hide_mode now holds a reference to which type of secret was picked. "random" gamemode will now pick from both secret lists for added randomness!

Implementation of https://forums.aurorastation.org/viewtopic.php?f=18&t=8253
This commit is contained in:
skull132
2017-07-02 02:38:00 +03:00
committed by GitHub
parent 5c76d89e78
commit b886ef644a
10 changed files with 96 additions and 40 deletions

View File

@@ -51,9 +51,18 @@
#define MODE_VAMPIRE "vampire"
#define MODE_THRALL "thrall"
#define DEFAULT_TELECRYSTAL_AMOUNT 25
// Defines (NOT FLAGS) for making secret, random, and mixed secret less snowflake-string
// and number dependant.
#define ROUNDTYPE_RANDOM 0
#define ROUNDTYPE_SECRET 1
#define ROUNDTYPE_MIXED_SECRET 2
#define ROUNDTYPE_STR_SECRET "secret"
#define ROUNDTYPE_STR_MIXED_SECRET "mixed secret"
#define ROUNDTYPE_STR_RANDOM "random"
/////////////////
////WIZARD //////
/////////////////

View File

@@ -54,7 +54,8 @@ var/list/gamemode_cache = list()
var/list/mode_names = list()
var/list/modes = list() // allowed modes
var/list/votable_modes = list() // votable modes
var/list/probabilities = list() // relative probability of each mode
var/list/probabilities_secret = list() // relative probability of each mode in secret/random
var/list/probabilities_mixed_secret = list() // relative probability of each mode in heavy secret mode
var/humans_need_surnames = 0
var/allow_random_events = 0 // enables random events mid-round when set to 1
var/allow_ai = 1 // allow ai job
@@ -281,10 +282,11 @@ var/list/gamemode_cache = list()
log_misc("Adding game mode [M.name] ([M.config_tag]) to configuration.")
src.modes += M.config_tag
src.mode_names[M.config_tag] = M.name
src.probabilities[M.config_tag] = M.probability
src.probabilities_secret[M.config_tag] = M.probability
if (M.votable)
src.votable_modes += M.config_tag
src.votable_modes += "secret"
src.votable_modes += ROUNDTYPE_STR_SECRET
votable_modes += ROUNDTYPE_STR_MIXED_SECRET
/datum/configuration/proc/load(filename, type = "config") //the type can also be game_options, in which case it uses a different switch. not making it separate to not copypaste code - Urist
var/list/Lines = file2list(filename)
@@ -522,15 +524,22 @@ var/list/gamemode_cache = list()
config.protect_roles_from_antagonist = 1
if ("probability")
var/prob_pos = findtext(value, " ")
var/prob_name = null
var/prob_value = null
var/list/chunks = splittext(value, " ")
var/prob_type
var/prob_name
var/prob_value
if (prob_pos)
prob_name = lowertext(copytext(value, 1, prob_pos))
prob_value = copytext(value, prob_pos + 1)
if (chunks.len == 3)
prob_type = lowertext(chunks[1])
prob_name = lowertext(chunks[2])
prob_value = text2num(chunks[3])
if (prob_name in config.modes)
config.probabilities[prob_name] = text2num(prob_value)
// S adds a mode to standard secret rotation
// MS adds a mode to mixed secret rotation
if (prob_type == "s")
config.probabilities_secret[prob_name] = prob_value
else if (prob_type == "ms")
config.probabilities_mixed_secret[prob_name] = prob_value
else
log_misc("Unknown game mode probability configuration definition: [prob_name].")
else
@@ -932,11 +941,21 @@ var/list/gamemode_cache = list()
return M
return gamemode_cache["extended"]
/datum/configuration/proc/get_runnable_modes()
/datum/configuration/proc/get_runnable_modes(secret_type = ROUNDTYPE_STR_SECRET)
var/list/probabilities = config.probabilities_secret
if (secret_type == ROUNDTYPE_STR_MIXED_SECRET)
probabilities = config.probabilities_mixed_secret
else if (secret_type == ROUNDTYPE_STR_RANDOM)
// Random picks from EVERYTHING. Need to use Copy() as to not pollute the
// original list. PBRef is /great/.
probabilities = config.probabilities_secret.Copy()
probabilities |= config.probabilities_mixed_secret
var/list/runnable_modes = list()
for(var/game_mode in gamemode_cache)
var/datum/game_mode/M = gamemode_cache[game_mode]
if(M && M.can_start() && !isnull(config.probabilities[M.config_tag]) && config.probabilities[M.config_tag] > 0)
if(M && M.can_start() && probabilities[M.config_tag] && probabilities[M.config_tag] > 0)
runnable_modes |= M
return runnable_modes

View File

@@ -326,21 +326,34 @@ var/datum/controller/subsystem/ticker/SSticker
/datum/controller/subsystem/ticker/proc/setup()
//Create and announce mode
if(master_mode=="secret")
src.hide_mode = 1
if(master_mode == ROUNDTYPE_STR_SECRET)
src.hide_mode = ROUNDTYPE_SECRET
else if (master_mode == ROUNDTYPE_STR_MIXED_SECRET)
src.hide_mode = ROUNDTYPE_MIXED_SECRET
var/list/runnable_modes = config.get_runnable_modes()
if((master_mode=="random") || (master_mode=="secret"))
var/list/runnable_modes = config.get_runnable_modes(master_mode)
if(master_mode in list(ROUNDTYPE_STR_RANDOM, ROUNDTYPE_STR_SECRET, ROUNDTYPE_STR_MIXED_SECRET))
if(!runnable_modes.len)
current_state = GAME_STATE_PREGAME
world << "<B>Unable to choose playable game mode.</B> Reverting to pre-game lobby."
return 0
if(secret_force_mode != "secret")
if(secret_force_mode != ROUNDTYPE_STR_SECRET && secret_force_mode != ROUNDTYPE_STR_MIXED_SECRET)
src.mode = config.pick_mode(secret_force_mode)
if(!src.mode)
var/list/weighted_modes = list()
var/list/probabilities = list()
if (master_mode == ROUNDTYPE_STR_SECRET)
probabilities = config.probabilities_secret
else if (master_mode == ROUNDTYPE_STR_MIXED_SECRET)
probabilities = config.probabilities_mixed_secret
else
// master_mode == ROUNDTYPE_STR_RANDOM
probabilities = config.probabilities_secret.Copy()
probabilities |= config.probabilities_mixed_secret
for(var/datum/game_mode/GM in runnable_modes)
weighted_modes[GM.config_tag] = config.probabilities[GM.config_tag]
weighted_modes[GM.config_tag] = probabilities[GM.config_tag]
src.mode = gamemode_cache[pickweight(weighted_modes)]
else
src.mode = config.pick_mode(master_mode)
@@ -366,7 +379,7 @@ var/datum/controller/subsystem/ticker/SSticker
var/starttime = REALTIMEOFDAY
if(hide_mode)
world << "<B>The current game mode is - Secret!</B>"
world << "<B>The current game mode is - [hide_mode == ROUNDTYPE_SECRET ? "Secret" : "Mixed Secret"]!</B>"
if(runnable_modes.len)
var/list/tmpmodes = new
for (var/datum/game_mode/M in runnable_modes)

View File

@@ -268,7 +268,8 @@ var/datum/controller/subsystem/vote/SSvote
continue
gamemode_names[M.config_tag] = capitalize(M.name) //It's ugly to put this here but it works
additional_text.Add("<td align = 'center'>[M.required_players]</td>")
gamemode_names["secret"] = "Secret"
gamemode_names[ROUNDTYPE_STR_SECRET] = "Secret"
gamemode_names[ROUNDTYPE_STR_MIXED_SECRET] = "Mixed Secret"
if("crew_transfer")
if(check_rights(R_ADMIN|R_MOD, 0))
question = "End the shift?"

View File

@@ -134,7 +134,7 @@ var/global/list/additional_antag_types = list()
antag_summary += "[antag.role_text_plural]"
i++
antag_summary += "."
if(antag_templates.len > 1 && master_mode != "secret")
if(antag_templates.len > 1 && !SSticker.hide_mode)
world << "[antag_summary]"
else
message_admins("[antag_summary]")
@@ -606,7 +606,7 @@ proc/get_nt_opposed()
usr << "Something is terribly wrong; there is no gametype."
return
if(master_mode != "secret")
if(!SSticker.hide_mode)
usr << "<b>The roundtype is [capitalize(SSticker.mode.name)]</b>"
if(SSticker.mode.round_description)
usr << "<i>[SSticker.mode.round_description]</i>"

View File

@@ -598,7 +598,7 @@ proc/admin_notice(var/message, var/rights)
<center><B>Game Panel</B></center><hr>\n
<A href='?src=\ref[src];c_mode=1'>Change Game Mode</A><br>
"}
if(master_mode == "secret")
if(master_mode == ROUNDTYPE_STR_SECRET || master_mode == ROUNDTYPE_STR_MIXED_SECRET)
dat += "<A href='?src=\ref[src];f_secret=1'>(Force Secret Mode)</A><br>"
dat += {"

View File

@@ -420,7 +420,7 @@
else if(href_list["boot2"])
var/mob/M = locate(href_list["boot2"])
if (ismob(M))
if(!check_rights(R_MOD|R_ADMIN, 0))
if(!check_rights(R_MOD|R_ADMIN, 0))
usr << "<span class='warning'>You do not have the appropriate permissions to boot users!</span>"
return
if(!check_if_greater_rights_than(M.client))
@@ -544,7 +544,7 @@
if(ROUND_IS_STARTED)
return alert(usr, "The game has already started.", null, null, null, null)
if(master_mode != "secret")
if(master_mode != ROUNDTYPE_STR_SECRET && master_mode != ROUNDTYPE_STR_MIXED_SECRET)
return alert(usr, "The game mode has to be secret!", null, null, null, null)
var/dat = {"<B>What game mode do you want to force secret to be? Use this if you want to change the game mode, but want the players to believe it's secret. This will only work if the current game mode is secret.</B><HR>"}
for(var/mode in config.modes)

View File

@@ -70,11 +70,12 @@
if(statpanel("Lobby"))
stat("Game ID:", game_id)
if(SSticker.hide_mode)
if(SSticker.hide_mode == ROUNDTYPE_SECRET)
stat("Game Mode:", "Secret")
else if (SSticker.hide_mode == ROUNDTYPE_MIXED_SECRET)
stat("Game Mode:", "Mixed Secret")
else
if(SSticker.hide_mode == 0)
stat("Game Mode:", "[master_mode]") // Old setting for showing the game mode
stat("Game Mode:", "[master_mode]") // Old setting for showing the game mode
if(SSticker.current_state == GAME_STATE_PREGAME)
if (SSticker.lobby_ready)
@@ -500,4 +501,4 @@
return 1
/mob/new_player/show_message(msg, type, alt, alt_type)
return
return

View File

@@ -102,17 +102,25 @@ MOD_TEMPBAN_MAX 1440
MOD_JOB_TEMPBAN_MAX 1440
## probablities for game modes chosen in "secret" and "random" modes
## Probablities for game modes chosen in "secret", "mixed secret" and "random" modes.
## S or MS after the PROBABILITY keyword dictates whether the probability is for mixed
## secret, or secret. These can overlap. "Random" will pick from both.
##
## default probablity is 1, increase to make that mode more likely to be picked
## set to 0 to disable that mode
PROBABILITY EXTENDED 1
PROBABILITY MALFUNCTION 1
PROBABILITY MERCENARY 1
PROBABILITY WIZARD 1
PROBABILITY CHANGELING 1
PROBABILITY CULT 1
PROBABILITY EXTEND-A-TRAITORMONGOUS 6
## Default probablity is 1, increase to make that mode more likely to be picked.
## Set to 0 to disable that mode.
PROBABILITY S EXTENDED 1
PROBABILITY S MALFUNCTION 1
PROBABILITY S MERCENARY 1
PROBABILITY S WIZARD 1
PROBABILITY S CHANGELING 1
PROBABILITY S CULT 1
PROBABILITY S EXTEND-A-TRAITORMONGOUS 6
PROBABILITY MS CONFLUX 1
PROBABILITY MS CROSSFIRE 1
PROBABILITY MS PARANOIA 1
PROBABILITY MS UPRISING 1
PROBABILITY MS VISITORS 1
PROBABILITY MS EXTENDED 1
## Hash out to disable random events during the round.
ALLOW_RANDOM_EVENTS

View File

@@ -0,0 +1,5 @@
author: Skull132
delete-after: True
changes:
- rscadd: "Added the Mixed Secret gamemode, which contains all of the mixed antag modes."