Skip to content

Commit

Permalink
add: Antag Paradise Gamemode (#3578)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottfrei authored Nov 17, 2023
1 parent 897b4a9 commit 1511e1a
Show file tree
Hide file tree
Showing 13 changed files with 676 additions and 42 deletions.
6 changes: 6 additions & 0 deletions code/__DEFINES/gamemode.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//antag paradise gamemode type defines
#define ANTAG_SINGLE "antag_single"
#define ANTAG_DOUBLE "antag_double"
#define ANTAG_TRIPPLE "antag_tripple"
#define ANTAG_RANDOM "antag_random"

//objective defines
#define TARGET_INVALID_IS_OWNER 1
#define TARGET_INVALID_NOT_HUMAN 2
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/role_preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#define ROLE_SPACE_DRAGON "space dragon"
#define ROLE_MALF_AI "Malfunctioning AI"

#define ROLE_NONE "nothing" // special define used as a marker

//Missing assignment means it's not a gamemode specific role, IT'S NOT A BUG OR ERROR.
//The gamemode specific ones are just so the gamemodes can query whether a player is old enough
//(in game days played) to play that role
Expand Down
61 changes: 52 additions & 9 deletions code/__HELPERS/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,61 @@
result = first ^ second
return result

//Pretends to pick an element based on its weight but really just seems to pick a random element.
/proc/pickweight(list/L)
/**
* Picks a random element from a list based on a weighting system.
* All keys with zero or non integer weight will be considered as one
* For example, given the following list:
* A = 5, B = 3, C = 1, D = 0
* A would have a 50% chance of being picked,
* B would have a 30% chance of being picked,
* C would have a 10% chance of being picked,
* and D would have a 10% chance of being picked.
* This proc not modify input list
*/
/proc/pickweight(list/list_to_pick)
var/total = 0
for(var/item in list_to_pick)
var/weight = list_to_pick[item]
if(!weight)
weight = 1
total += weight

total = rand(1, total)
for(var/item in list_to_pick)
var/weight = list_to_pick[item]
if(!weight)
weight = 1
total -= weight
if(total <= 0)
return item

return null

/**
* Picks a random element from a list based on a weighting system.
* All keys with zero or non integer weight will be considered as zero
* For example, given the following list:
* A = 6, B = 3, C = 1, D = 0
* A would have a 60% chance of being picked,
* B would have a 30% chance of being picked,
* C would have a 10% chance of being picked,
* and D would have a 0% chance of being picked.
* This proc not modify input list
*/
/proc/pick_weight_classic(list/list_to_pick)
var/total = 0
var/item
for(item in L)
if(!L[item])
L[item] = 1
total += L[item]
for(var/item in list_to_pick)
var/weight = list_to_pick[item]
if(!weight)
continue
total += weight

total = rand(1, total)
for(item in L)
total -=L [item]
for(var/item in list_to_pick)
var/weight = list_to_pick[item]
if(!weight)
continue
total -= weight
if(total <= 0)
return item

Expand Down
20 changes: 20 additions & 0 deletions code/_globalvars/game_modes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,23 @@ GLOBAL_VAR(custom_event_admin_msg)
GLOBAL_VAR_INIT(morphs_announced, FALSE)

GLOBAL_VAR_INIT(disable_robotics_consoles, FALSE)

/// Chance to roll double antag for traitors in ANTAG-PARADISE gamemode.
GLOBAL_VAR(antag_paradise_double_antag_chance)

/// Weights for all minor antags in ANTAG-PARADISE gamemode. Highter the weight higher the chance for antag to roll.
GLOBAL_LIST_INIT(antag_paradise_weights, list(
ROLE_TRAITOR = 0,
ROLE_THIEF = 0,
ROLE_VAMPIRE = 0,
ROLE_CHANGELING = 0,
))

/// Weights for all special antags in ANTAG-PARADISE gamemode.
GLOBAL_LIST_INIT(antag_paradise_special_weights, list(
ROLE_TRAITOR = 0, // hijacker actually
ROLE_MALF_AI = 0,
ROLE_NINJA = 0,
ROLE_NONE = 0, // to skip all roles entirely
))

64 changes: 64 additions & 0 deletions code/controllers/configuration/entries/config.dm
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,70 @@
/datum/config_entry/number/expected_round_length
default = 2 HOURS


/datum/config_entry/number/antag_paradise_double_antag_chance


/datum/config_entry/number/antag_paradise_double_antag_chance/ValidateAndSet(str_val)
. = ..()
if(.)
GLOB.antag_paradise_double_antag_chance = config_entry_value


/datum/config_entry/keyed_list/antag_paradise_weights
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM


/datum/config_entry/keyed_list/antag_paradise_weights/ValidateAndSet(str_val)
. = ..()
if(.)
for(var/role in config_entry_value)
GLOB.antag_paradise_weights[role] = config_entry_value[role]


/datum/config_entry/keyed_list/antag_paradise_special_weights
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM
default = list(
"hijacker" = 10,
"malfai" = 10,
"ninja" = 10,
"nothing" = 30,
)


/datum/config_entry/keyed_list/antag_paradise_special_weights/ValidateAndSet(str_val)
. = ..()
if(.)
GLOB.antag_paradise_special_weights[ROLE_TRAITOR] = config_entry_value["hijacker"]
GLOB.antag_paradise_special_weights[ROLE_MALF_AI] = config_entry_value["malfai"]
GLOB.antag_paradise_special_weights[ROLE_NINJA] = config_entry_value["ninja"]
GLOB.antag_paradise_special_weights[ROLE_NONE] = config_entry_value["nothing"]


/datum/config_entry/keyed_list/antag_paradise_mode_subtypes
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM
default = list(
ANTAG_SINGLE = 10,
ANTAG_DOUBLE = 10,
ANTAG_TRIPPLE = 10,
ANTAG_RANDOM = 10,
)


/datum/config_entry/keyed_list/antag_paradise_subtype_weights
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM
default = list(
ANTAG_SINGLE = 6,
ANTAG_DOUBLE = 4,
ANTAG_TRIPPLE = 2,
ANTAG_RANDOM = 10,
)


//Made that way because compatibility reasons.
/datum/config_entry/keyed_list/event_delay_lower
default = list("ev_level_mundane" = 10, "ev_level_moderate" = 30, "ev_level_major" = 50) //minutes
Expand Down
Loading

0 comments on commit 1511e1a

Please sign in to comment.