Skip to content

Commit

Permalink
tweak: Antag Paradise Changeling Weight Adjustment (#5114)
Browse files Browse the repository at this point in the history
* Antag Paradise Changeling Weight Adjustment

* Typo

* Shift
  • Loading branch information
Gottfrei authored Jun 3, 2024
1 parent 7a52dd0 commit 1fa133d
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 26 deletions.
34 changes: 33 additions & 1 deletion code/controllers/configuration/entries/config.dm
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,47 @@
min_val = 0


/datum/config_entry/keyed_list/antag_paradise_main_antags
/datum/config_entry/str_list/antag_paradise_random_antags_whitelist
lowercase = TRUE
default = list(
ROLE_TRAITOR,
ROLE_VAMPIRE,
)


/datum/config_entry/keyed_list/antag_paradise_single_antags_weights
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM
default = list(
ROLE_TRAITOR = 60,
ROLE_THIEF = 0,
ROLE_VAMPIRE = 20,
ROLE_CHANGELING = 0,
)


/datum/config_entry/keyed_list/antag_paradise_double_antags_weights
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM
default = list(
ROLE_TRAITOR = 60,
ROLE_THIEF = 0,
ROLE_VAMPIRE = 20,
ROLE_CHANGELING = 20,
)


/datum/config_entry/keyed_list/antag_paradise_tripple_antags_weights
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM
default = list(
ROLE_TRAITOR = 60,
ROLE_THIEF = 0,
ROLE_VAMPIRE = 20,
ROLE_CHANGELING = 20,
)


/datum/config_entry/keyed_list/antag_paradise_special_antags_weights
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM
Expand Down
53 changes: 37 additions & 16 deletions code/game/gamemodes/antag_paradise/antag_paradise.dm
Original file line number Diff line number Diff line change
Expand Up @@ -233,30 +233,51 @@

antags_weights = list()

var/list/antag_weight_config = CONFIG_GET(keyed_list/antag_paradise_main_antags)
antag_weight_config = antag_weight_config.Copy()

for(var/antag in antag_weight_config)
if(players < antag_required_players[antag])
antag_weight_config -= antag

if(!length(antag_weight_config))
return

var/mode_type = pick_weight_classic(CONFIG_GET(keyed_list/antag_paradise_mode_subtypes))
if(mode_type == ANTAG_RANDOM)
for(var/antag in antag_weight_config)
var/list/random_mode_whitelist = CONFIG_GET(str_list/antag_paradise_random_antags_whitelist)
for(var/antag in list(ROLE_TRAITOR, ROLE_VAMPIRE, ROLE_CHANGELING, ROLE_THIEF))
if(!(antag in random_mode_whitelist))
continue
antags_weights[antag] = rand(1, 100)
return

var/list/single_weights_config = CONFIG_GET(keyed_list/antag_paradise_single_antags_weights)
single_weights_config = single_weights_config.Copy()
for(var/antag in single_weights_config)
if(players < antag_required_players[antag] || single_weights_config[antag] <= 0)
single_weights_config -= antag
if(!length(single_weights_config))
return
var/list/subtype_weights = CONFIG_GET(keyed_list/antag_paradise_subtype_weights)
antags_weights[pick_weight_n_take(antag_weight_config)] = subtype_weights[ANTAG_SINGLE]
if(!length(antag_weight_config) || mode_type == ANTAG_SINGLE)
var/list/choosen_antags = list()
var/single_antag = pick_weight_classic(single_weights_config)
choosen_antags += single_antag
antags_weights[single_antag] = subtype_weights[ANTAG_SINGLE]
if(mode_type == ANTAG_SINGLE)
return
antags_weights[pick_weight_n_take(antag_weight_config)] = subtype_weights[ANTAG_DOUBLE]
if(!length(antag_weight_config) || mode_type == ANTAG_DOUBLE)

var/list/double_weights_config = CONFIG_GET(keyed_list/antag_paradise_double_antags_weights)
double_weights_config = double_weights_config.Copy() - choosen_antags
for(var/antag in double_weights_config)
if(players < antag_required_players[antag] || double_weights_config[antag] <= 0)
double_weights_config -= antag
if(!length(double_weights_config))
return
var/double_antag = pick_weight_classic(double_weights_config)
choosen_antags += double_antag
antags_weights[double_antag] = subtype_weights[ANTAG_DOUBLE]
if(mode_type == ANTAG_DOUBLE)
return

var/list/tripple_weights_config = CONFIG_GET(keyed_list/antag_paradise_tripple_antags_weights)
tripple_weights_config = tripple_weights_config.Copy() - choosen_antags
for(var/antag in tripple_weights_config)
if(players < antag_required_players[antag] || tripple_weights_config[antag] <= 0)
tripple_weights_config -= antag
if(!length(tripple_weights_config))
return
antags_weights[pick_weight_n_take(antag_weight_config)] = subtype_weights[ANTAG_TRIPPLE]
antags_weights[pick_weight_classic(tripple_weights_config)] = subtype_weights[ANTAG_TRIPPLE]


/datum/game_mode/antag_paradise/post_setup()
Expand Down
6 changes: 2 additions & 4 deletions code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1248,10 +1248,8 @@
if(GLOB.antag_paradise_weights)
antags_list = GLOB.antag_paradise_weights
else
antags_list = CONFIG_GET(keyed_list/antag_paradise_main_antags)
antags_list = CONFIG_GET(keyed_list/antag_paradise_single_antags_weights)
antags_list = antags_list.Copy()
for(var/key in list(ROLE_TRAITOR, ROLE_VAMPIRE, ROLE_CHANGELING, ROLE_THIEF))
antags_list[key] = !!(key in antags_list)

for(var/antag in antags_list)
dat += {"<tr><td>[capitalize(antag)]</td><td><A href='?src=[UID()];change_weights2=weights_normal_[antag]'>\[[antags_list[antag]]\]</A></td></tr>"}
Expand Down Expand Up @@ -1294,7 +1292,7 @@

else if(findtext(command, "weights_normal_"))
if(!GLOB.antag_paradise_weights)
var/list/antags_list = CONFIG_GET(keyed_list/antag_paradise_main_antags)
var/list/antags_list = CONFIG_GET(keyed_list/antag_paradise_single_antags_weights)
antags_list = antags_list.Copy()
for(var/key in list(ROLE_TRAITOR, ROLE_VAMPIRE, ROLE_CHANGELING, ROLE_THIEF))
antags_list[key] = !!(key in antags_list)
Expand Down
26 changes: 21 additions & 5 deletions config/example/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,27 @@ MINPLAYERS ABDUCTION 15
MINPLAYERS DEVIL 2
MINPLAYERS DEVILAGENTS 25

## List of minor antags in ANTAG-PARADISE gamemode. Only listed here antags will be spawned as main antags
#ANTAG_PARADISE_MAIN_ANTAGS TRAITOR
#ANTAG_PARADISE_MAIN_ANTAGS THIEF
#ANTAG_PARADISE_MAIN_ANTAGS VAMPIRE
#ANTAG_PARADISE_MAIN_ANTAGS CHANGELING
## List of minor antags in ANTAG-PARADISE gamemode. Antags from this config will be picked for primary role (ANTAG_SINGLE), using correspoding weights.
#ANTAG_PARADISE_SINGLE_ANTAGS TRAITOR 60
#ANTAG_PARADISE_SINGLE_ANTAGS THIEF 0
#ANTAG_PARADISE_SINGLE_ANTAGS VAMPIRE 20
#ANTAG_PARADISE_SINGLE_ANTAGS CHANGELING 0

## List of minor antags in ANTAG-PARADISE gamemode. Antags from this config will be picked for secondary role (ANTAG_DOUBLE), using correspoding weights.
#ANTAG_PARADISE_DOUBLE_ANTAGS TRAITOR 60
#ANTAG_PARADISE_DOUBLE_ANTAGS THIEF 0
#ANTAG_PARADISE_DOUBLE_ANTAGS VAMPIRE 20
#ANTAG_PARADISE_DOUBLE_ANTAGS CHANGELING 20

## List of minor antags in ANTAG-PARADISE gamemode. Antags from this config will be picked for final role (ANTAG_TRIPPLE), using correspoding weights.
#ANTAG_PARADISE_TRIPPLE_ANTAGS TRAITOR 60
#ANTAG_PARADISE_TRIPPLE_ANTAGS THIEF 0
#ANTAG_PARADISE_TRIPPLE_ANTAGS VAMPIRE 20
#ANTAG_PARADISE_TRIPPLE_ANTAGS CHANGELING 20

## Whitelist for minor antags in ANTAG-PARADISE gamemode. Only antags from below will be choosen for random mode subtype (ANTAG_RANDOM).
#ANTAG_PARADISE_RANDOM_MODE_WHITELIST TRAITOR
#ANTAG_PARADISE_RANDOM_MODE_WHITELIST VAMPIRE

## Chances for ANTAG-PARADISE gamemode subtypes.
#ANTAG_PARADISE_MODE_SUBTYPES ANTAG_SINGLE 10
Expand Down

0 comments on commit 1fa133d

Please sign in to comment.