From 9539452dc5d3b2b1c60796d8a0656622d473dc22 Mon Sep 17 00:00:00 2001 From: dwasint <82520990+dwasint@users.noreply.github.com> Date: Thu, 15 Feb 2024 12:25:54 -0500 Subject: [PATCH 1/8] skeleton of a system. --- code/__DEFINES/logging.dm | 1 + code/__HELPERS/_lists.dm | 8 +++ code/__HELPERS/logging/_logging.dm | 3 + .../logging/categories/log_category_monke.dm | 7 +++ .../code/controllers/subsystem/job.dm | 18 ++++-- .../modules/client/preference_savefile.dm | 2 + .../code/modules/client/preferences.dm | 3 + .../storytellers/antag_rep/helper_procs.dm | 62 +++++++++++++++++++ .../converted_events/_base_event.dm | 39 ++++++++++-- .../solo/ghosts/paradox_clone.dm | 18 +++++- tgstation.dme | 1 + 11 files changed, 152 insertions(+), 10 deletions(-) create mode 100644 monkestation/code/modules/storytellers/antag_rep/helper_procs.dm diff --git a/code/__DEFINES/logging.dm b/code/__DEFINES/logging.dm index bdb79226e738..0c20aed77bd8 100644 --- a/code/__DEFINES/logging.dm +++ b/code/__DEFINES/logging.dm @@ -117,6 +117,7 @@ #define LOG_CATEGORY_META "currency" #define LOG_CATEGORY_ARTIFACT "artifact" #define LOG_CATEGORY_BLACKMARKET "blackmarket" +#define LOG_CATEGORY_ANTAG_REP "antag rep" // Admin categories #define LOG_CATEGORY_ADMIN "admin" diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index be61fe7f9a33..d7e4a66ec302 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -534,6 +534,14 @@ . = list_to_pick[picked] list_to_pick.Cut(picked,picked+1) //Cut is far more efficient that Remove() +/// Pick a random element from the list and remove it from the list. +/proc/pick_n_take_weighted(list/list_to_pick) + if(list_to_pick.len) + var/picked = pick_weight(list_to_pick) + list_to_pick[picked] = null + list_to_pick.Remove(picked) + return picked + ///Returns the top(last) element from the list and removes it from the list (typical stack function) /proc/pop(list/L) if(L.len) diff --git a/code/__HELPERS/logging/_logging.dm b/code/__HELPERS/logging/_logging.dm index 05f099b7284f..8297168e6e21 100644 --- a/code/__HELPERS/logging/_logging.dm +++ b/code/__HELPERS/logging/_logging.dm @@ -268,3 +268,6 @@ GLOBAL_LIST_INIT(testing_global_profiler, list("_PROFILE_NAME" = "Global")) /proc/log_blackmarket(text, list/data) logger.Log(LOG_CATEGORY_BLACKMARKET, text, data) + +/proc/log_antag_rep(text, list/data) + logger.Log(LOG_CATEGORY_ANTAG_REP, text, data) diff --git a/code/modules/logging/categories/log_category_monke.dm b/code/modules/logging/categories/log_category_monke.dm index 659f3efbe70a..96eb231ae020 100644 --- a/code/modules/logging/categories/log_category_monke.dm +++ b/code/modules/logging/categories/log_category_monke.dm @@ -36,3 +36,10 @@ config_flag = /datum/config_entry/flag/blackmarket /datum/config_entry/flag/blackmarket + + +/datum/log_category/antag_rep + category = LOG_CATEGORY_ANTAG_REP + config_flag = /datum/config_entry/flag/antag_rep + +/datum/config_entry/flag/antag_rep diff --git a/monkestation/code/controllers/subsystem/job.dm b/monkestation/code/controllers/subsystem/job.dm index 3836a5d4a584..2130791ede4c 100644 --- a/monkestation/code/controllers/subsystem/job.dm +++ b/monkestation/code/controllers/subsystem/job.dm @@ -57,6 +57,15 @@ return FALSE var/list/candidates = SSgamemode.current_roundstart_event.get_candidates() + + var/list/cliented_list = list() + for(var/mob/living/mob as anything in candidates) + cliented_list += mob.client + if(length(cliented_list)) + mass_adjust_antag_rep(cliented_list, 1) + + var/list/weighted_candidates = return_antag_rep_weight(candidates) + var/antag_selection_loops = SSgamemode.current_roundstart_event.get_antag_amount() for(var/i in 1 to antag_selection_loops) if(antag_selection_loops >= 100) @@ -67,7 +76,8 @@ JobDebug("h_r_a failed, below required candidates for selected roundstart event") return FALSE break - var/mob/dead/new_player/candidate = pick_n_take(candidates) + var/client/dead_client = pick_n_take_weighted(weighted_candidates) + var/mob/dead/new_player/candidate = dead_client.mob if(!candidate.mind || !istype(candidate)) antag_selection_loops++ continue @@ -86,16 +96,16 @@ var/mob/dead/new_player/player = player_mind.current //we should always have a current mob as we get set from it if(!player.temp_assignment && !GiveRandomJob(player, TRUE, enemy_job_instances + restricted_job_instances) && !handle_temp_assignments(player, GetJobType(overflow_role))) SSgamemode.roundstart_antag_minds -= player_mind - if(!length(candidates)) + if(!length(weighted_candidates)) if(length(SSgamemode.roundstart_antag_minds) < SSgamemode.current_roundstart_event.base_antags) JobDebug("h_r_a failed, removing unassigned antag player put us below current event minimum candidates") return FALSE continue var/mob/dead/new_player/candidate var/sanity = 0 - while(!candidate && length(candidates) && !sanity >= 100) + while(!candidate && length(weighted_candidates) && !sanity >= 100) sanity++ - candidate = pick_n_take(candidates) + candidate = pick_n_take_weighted(weighted_candidates) if(!candidate.mind || !istype(candidate)) candidate = null if(!candidate) diff --git a/monkestation/code/modules/client/preference_savefile.dm b/monkestation/code/modules/client/preference_savefile.dm index fcb1b1694154..dabfff0e8912 100644 --- a/monkestation/code/modules/client/preference_savefile.dm +++ b/monkestation/code/modules/client/preference_savefile.dm @@ -58,6 +58,7 @@ if(token_month) savefile.set_entry("token_month", token_month) savefile.set_entry("lootboxes_owned", lootboxes_owned) + savefile.set_entry("antag_rep", antag_rep) /datum/preferences/proc/load_preferences_monkestation() load_jobxp_preferences() @@ -72,4 +73,5 @@ token_month = savefile.get_entry("token_month", token_month) lootboxes_owned = savefile.get_entry("lootboxes_owned", lootboxes_owned) + antag_rep = savefile.get_entry("antag_rep", antag_rep) diff --git a/monkestation/code/modules/client/preferences.dm b/monkestation/code/modules/client/preferences.dm index 94399ccb2f13..c8c7b67c98c9 100644 --- a/monkestation/code/modules/client/preferences.dm +++ b/monkestation/code/modules/client/preferences.dm @@ -45,3 +45,6 @@ ) ///amount of lootboxes owned var/lootboxes_owned = 0 + + ///our current antag rep (base is 10) + var/antag_rep = 10 diff --git a/monkestation/code/modules/storytellers/antag_rep/helper_procs.dm b/monkestation/code/modules/storytellers/antag_rep/helper_procs.dm new file mode 100644 index 000000000000..a83889c8f52d --- /dev/null +++ b/monkestation/code/modules/storytellers/antag_rep/helper_procs.dm @@ -0,0 +1,62 @@ +GLOBAL_LIST_INIT(blessed_ckeys, list( + "taocat" = list(3, 25), +)) //this is a lmao moment should be a json but its being left here because lol it goes ckey = list(multiplier, base) + +///adjusts antag rep by {VALUE} keeping the value above 0 +/datum/preferences/proc/adjust_antag_rep(value, multiplier = TRUE) + if(multiplier) + value *= return_rep_multiplier() + log_antag_rep("[parent]'s antag rep was adjusted by [value]") + antag_rep += value + if(antag_rep < 1) + log_antag_rep("[parent]'s antag rep was adjusted below 1 resetting to 1") + antag_rep = 1 + save_preferences() + +/datum/preferences/proc/reset_antag_rep() + var/default = return_default_antag_rep() + log_antag_rep("[parent]'s antag rep was reset to default ([default])") + antag_rep = default + save_preferences() + +/datum/preferences/proc/return_default_antag_rep() + if(!parent) + return 10 + if(!(parent.ckey in GLOB.blessed_ckeys)) + return 10 + return GLOB.blessed_ckeys[parent.ckey][2] + +/datum/preferences/proc/return_rep_multiplier() + if(!parent) + return 1 + if(!(parent.ckey in GLOB.blessed_ckeys)) + return 1 + return GLOB.blessed_ckeys[parent.ckey][1] + + +///give it a list of clients and the value aswell if it should be affected by multipliers and let er rip +/proc/mass_adjust_antag_rep(list/clients, value, mulitplier = TRUE) + for(var/client/listed_client as anything in clients) + if(!listed_client.prefs || !IS_CLIENT_OR_MOCK(listed_client)) + continue + listed_client.prefs.adjust_antag_rep(value, mulitplier) + +/proc/return_antag_rep_weight(list/candidates) + var/list/returning_list = list() + for(var/anything in candidates) + var/client/client_source + if(ismob(anything)) + var/mob/mob = anything + client_source = mob.client + if(IS_CLIENT_OR_MOCK(anything)) + client_source = anything + if(!client_source) + continue + + returning_list += client_source + var/return_value = 10 + if(client_source.prefs?.antag_rep) + return_value = client_source.prefs?.antag_rep + returning_list[client_source] = return_value + + return returning_list diff --git a/monkestation/code/modules/storytellers/converted_events/_base_event.dm b/monkestation/code/modules/storytellers/converted_events/_base_event.dm index 9a375f0b7886..5e18b0ec4d44 100644 --- a/monkestation/code/modules/storytellers/converted_events/_base_event.dm +++ b/monkestation/code/modules/storytellers/converted_events/_base_event.dm @@ -207,18 +207,31 @@ candidates += antag_mind.current SSgamemode.roundstart_antag_minds -= antag_mind //commented out for debugging in case something breaks + //guh + var/list/cliented_list = list() + for(var/mob/living/mob as anything in possible_candidates) + cliented_list += mob.client + if(length(cliented_list)) + mass_adjust_antag_rep(cliented_list, 1) + while(length(possible_candidates) && length(candidates) < antag_count) //both of these pick_n_take from possible_candidates so this should be fine if(prompted_picking) - candidates |= poll_candidates("Would you like to be a [cast_control.name]", antag_flag, antag_flag, 20 SECONDS, FALSE, FALSE, list(pick_n_take(possible_candidates))) + candidates |= poll_candidates("Would you like to be a [cast_control.name]", antag_flag, antag_flag, 20 SECONDS, FALSE, FALSE, list(pick_n_take_weighted(possible_candidates))) else - candidates |= pick_n_take(possible_candidates) + candidates |= pick_n_take_weighted(candidates) + + var/list/weighted_candidates = return_antag_rep_weight(candidates) for(var/i in 1 to antag_count) - if(!length(candidates)) + if(!length(weighted_candidates)) message_admins("A roleset event got fewer antags then its antag_count and may not function correctly.") break - var/mob/candidate = pick_n_take(candidates) + var/client/mob_client = pick_n_take(weighted_candidates) + var/mob/candidate = mob_client.mob + + if(candidate.client) //I hate this + candidate.client.prefs.reset_antag_rep() if(!candidate.mind) candidate.mind = new /datum/mind(candidate.key) @@ -238,13 +251,29 @@ restricted_roles = cast_control.restricted_roles prompted_picking = cast_control.prompted_picking var/list/candidates = cast_control.get_candidates() + + //guh + var/list/cliented_list = list() + for(var/mob/living/mob as anything in candidates) + cliented_list += mob.client + if(length(cliented_list)) + mass_adjust_antag_rep(cliented_list, 1) + if(prompted_picking) candidates = poll_candidates("Would you like to be a [cast_control.name]", antag_flag, antag_flag, 20 SECONDS, FALSE, FALSE, candidates) + var/list/weighted_candidates = return_antag_rep_weight(candidates) + for(var/i in 1 to antag_count) if(!length(candidates)) break - var/mob/candidate = pick_n_take(candidates) + + var/client/mob_client = pick_n_take_weighted(weighted_candidates) + var/mob/candidate = mob_client.mob + + if(candidate.client) //I hate this + candidate.client.prefs.reset_antag_rep() + if(!candidate.mind) candidate.mind = new /datum/mind(candidate.key) diff --git a/monkestation/code/modules/storytellers/converted_events/solo/ghosts/paradox_clone.dm b/monkestation/code/modules/storytellers/converted_events/solo/ghosts/paradox_clone.dm index 32be80f46d66..be987640501a 100644 --- a/monkestation/code/modules/storytellers/converted_events/solo/ghosts/paradox_clone.dm +++ b/monkestation/code/modules/storytellers/converted_events/solo/ghosts/paradox_clone.dm @@ -32,13 +32,29 @@ restricted_roles = cast_control.restricted_roles prompted_picking = cast_control.prompted_picking var/list/candidates = cast_control.get_candidates() + + var/list/cliented_list = list() + for(var/mob/living/mob as anything in candidates) + cliented_list += mob.client + if(length(cliented_list)) + mass_adjust_antag_rep(cliented_list, 1) + + if(prompted_picking) candidates = poll_candidates("Would you like to be a [cast_control.name]", antag_flag, antag_flag, 20 SECONDS, FALSE, FALSE, candidates) + var/list/weighted_candidates = return_antag_rep_weight(candidates) + for(var/i in 1 to antag_count) if(!candidates.len) break - var/mob/candidate = pick_n_take(candidates) + + var/client/mob_client = pick_n_take(weighted_candidates) + var/mob/candidate = mob_client.mob + + if(candidate.client) //I hate this + candidate.client.prefs.reset_antag_rep() + if(!candidate.mind) candidate.mind = new /datum/mind(candidate.key) diff --git a/tgstation.dme b/tgstation.dme index 2387286375dd..e05e0a1cd5c9 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6661,6 +6661,7 @@ #include "monkestation\code\modules\storytellers\config.dm" #include "monkestation\code\modules\storytellers\gamemode_subsystem.dm" #include "monkestation\code\modules\storytellers\scheduled_events.dm" +#include "monkestation\code\modules\storytellers\antag_rep\helper_procs.dm" #include "monkestation\code\modules\storytellers\converted_events\_base_event.dm" #include "monkestation\code\modules\storytellers\converted_events\event_overrides.dm" #include "monkestation\code\modules\storytellers\converted_events\solo\bloodcult.dm" From 8bb3d9ef015806475c6680b424756a6838d5b168 Mon Sep 17 00:00:00 2001 From: dwasint <82520990+dwasint@users.noreply.github.com> Date: Thu, 15 Feb 2024 18:09:25 -0500 Subject: [PATCH 2/8] changes --- code/__HELPERS/_lists.dm | 2 +- .../code/modules/storytellers/antag_rep/helper_procs.dm | 2 +- .../modules/storytellers/converted_events/_base_event.dm | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index d7e4a66ec302..c0b3e24146e9 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -536,7 +536,7 @@ /// Pick a random element from the list and remove it from the list. /proc/pick_n_take_weighted(list/list_to_pick) - if(list_to_pick.len) + if(length(list_to_pick)) var/picked = pick_weight(list_to_pick) list_to_pick[picked] = null list_to_pick.Remove(picked) diff --git a/monkestation/code/modules/storytellers/antag_rep/helper_procs.dm b/monkestation/code/modules/storytellers/antag_rep/helper_procs.dm index a83889c8f52d..1fb67611e1e9 100644 --- a/monkestation/code/modules/storytellers/antag_rep/helper_procs.dm +++ b/monkestation/code/modules/storytellers/antag_rep/helper_procs.dm @@ -56,7 +56,7 @@ GLOBAL_LIST_INIT(blessed_ckeys, list( returning_list += client_source var/return_value = 10 if(client_source.prefs?.antag_rep) - return_value = client_source.prefs?.antag_rep + return_value = client_source.prefs.antag_rep returning_list[client_source] = return_value return returning_list diff --git a/monkestation/code/modules/storytellers/converted_events/_base_event.dm b/monkestation/code/modules/storytellers/converted_events/_base_event.dm index 5e18b0ec4d44..9ee7c84ebe48 100644 --- a/monkestation/code/modules/storytellers/converted_events/_base_event.dm +++ b/monkestation/code/modules/storytellers/converted_events/_base_event.dm @@ -216,7 +216,7 @@ while(length(possible_candidates) && length(candidates) < antag_count) //both of these pick_n_take from possible_candidates so this should be fine if(prompted_picking) - candidates |= poll_candidates("Would you like to be a [cast_control.name]", antag_flag, antag_flag, 20 SECONDS, FALSE, FALSE, list(pick_n_take_weighted(possible_candidates))) + candidates |= poll_candidates("Would you like to be a [cast_control.name]", antag_flag, antag_flag, 20 SECONDS, FALSE, FALSE, list(pick_n_take(possible_candidates))) else candidates |= pick_n_take_weighted(candidates) @@ -227,11 +227,10 @@ message_admins("A roleset event got fewer antags then its antag_count and may not function correctly.") break - var/client/mob_client = pick_n_take(weighted_candidates) + var/client/mob_client = pick_n_take_weighted(weighted_candidates) var/mob/candidate = mob_client.mob - if(candidate.client) //I hate this - candidate.client.prefs.reset_antag_rep() + candidate.client?.prefs.reset_antag_rep() if(!candidate.mind) candidate.mind = new /datum/mind(candidate.key) From bab47d6b9a9937c48340bd8c79a123c96c4f8d1e Mon Sep 17 00:00:00 2001 From: dwasint <82520990+dwasint@users.noreply.github.com> Date: Thu, 15 Feb 2024 19:31:11 -0500 Subject: [PATCH 3/8] Update _base_event.dm --- .../code/modules/storytellers/converted_events/_base_event.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkestation/code/modules/storytellers/converted_events/_base_event.dm b/monkestation/code/modules/storytellers/converted_events/_base_event.dm index 9ee7c84ebe48..24f095bd5a8b 100644 --- a/monkestation/code/modules/storytellers/converted_events/_base_event.dm +++ b/monkestation/code/modules/storytellers/converted_events/_base_event.dm @@ -218,7 +218,7 @@ if(prompted_picking) candidates |= poll_candidates("Would you like to be a [cast_control.name]", antag_flag, antag_flag, 20 SECONDS, FALSE, FALSE, list(pick_n_take(possible_candidates))) else - candidates |= pick_n_take_weighted(candidates) + candidates |= pick_n_take(candidates) var/list/weighted_candidates = return_antag_rep_weight(candidates) From 96f4f56e75b69244044c26b8e55812683759a235 Mon Sep 17 00:00:00 2001 From: dwasint <82520990+dwasint@users.noreply.github.com> Date: Thu, 15 Feb 2024 19:43:09 -0500 Subject: [PATCH 4/8] Update _base_event.dm --- .../code/modules/storytellers/converted_events/_base_event.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkestation/code/modules/storytellers/converted_events/_base_event.dm b/monkestation/code/modules/storytellers/converted_events/_base_event.dm index 24f095bd5a8b..5054da37ee16 100644 --- a/monkestation/code/modules/storytellers/converted_events/_base_event.dm +++ b/monkestation/code/modules/storytellers/converted_events/_base_event.dm @@ -218,7 +218,7 @@ if(prompted_picking) candidates |= poll_candidates("Would you like to be a [cast_control.name]", antag_flag, antag_flag, 20 SECONDS, FALSE, FALSE, list(pick_n_take(possible_candidates))) else - candidates |= pick_n_take(candidates) + candidates |= pick_n_take(possible_candidates) var/list/weighted_candidates = return_antag_rep_weight(candidates) From e1955d6d57c95635ee24d79367bba77fb7190582 Mon Sep 17 00:00:00 2001 From: dwasint <82520990+dwasint@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:45:16 -0500 Subject: [PATCH 5/8] changes log stuff --- code/__DEFINES/logging.dm | 2 +- code/__HELPERS/_lists.dm | 3 +- .../logging/categories/log_category_monke.dm | 28 +++++++++---------- .../storytellers/antag_rep/helper_procs.dm | 1 + 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/code/__DEFINES/logging.dm b/code/__DEFINES/logging.dm index 0c20aed77bd8..27a48520a404 100644 --- a/code/__DEFINES/logging.dm +++ b/code/__DEFINES/logging.dm @@ -117,7 +117,7 @@ #define LOG_CATEGORY_META "currency" #define LOG_CATEGORY_ARTIFACT "artifact" #define LOG_CATEGORY_BLACKMARKET "blackmarket" -#define LOG_CATEGORY_ANTAG_REP "antag rep" +#define LOG_CATEGORY_ANTAG_REP "antag-rep" // Admin categories #define LOG_CATEGORY_ADMIN "admin" diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index c0b3e24146e9..c4376731f610 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -538,8 +538,7 @@ /proc/pick_n_take_weighted(list/list_to_pick) if(length(list_to_pick)) var/picked = pick_weight(list_to_pick) - list_to_pick[picked] = null - list_to_pick.Remove(picked) + list_to_pick -= picked return picked ///Returns the top(last) element from the list and removes it from the list (typical stack function) diff --git a/code/modules/logging/categories/log_category_monke.dm b/code/modules/logging/categories/log_category_monke.dm index 96eb231ae020..cad1619ce6d8 100644 --- a/code/modules/logging/categories/log_category_monke.dm +++ b/code/modules/logging/categories/log_category_monke.dm @@ -1,45 +1,45 @@ /datum/log_category/cloning category = LOG_CATEGORY_CLONING master_category = /datum/log_category/game - config_flag = /datum/config_entry/flag/cloning + config_flag = /datum/config_entry/flag/log_cloning -/datum/config_entry/flag/cloning +/datum/config_entry/flag/log_cloning /datum/log_category/mechcomp category = LOG_CATEGORY_MECHCOMP master_category = /datum/log_category/game - config_flag = /datum/config_entry/flag/mechcomp + config_flag = /datum/config_entry/flag/log_mechcomp -/datum/config_entry/flag/mechcomp +/datum/config_entry/flag/log_mechcomp /datum/log_category/music category = LOG_CATEGORY_MUSIC - config_flag = /datum/config_entry/flag/music + config_flag = /datum/config_entry/flag/log_music -/datum/config_entry/flag/music +/datum/config_entry/flag/log_music /datum/log_category/meta category = LOG_CATEGORY_META - config_flag = /datum/config_entry/flag/meta + config_flag = /datum/config_entry/flag/log_meta -/datum/config_entry/flag/meta +/datum/config_entry/flag/log_meta /datum/log_category/artifact category = LOG_CATEGORY_ARTIFACT - config_flag = /datum/config_entry/flag/artifact + config_flag = /datum/config_entry/flag/log_artifact -/datum/config_entry/flag/artifact +/datum/config_entry/flag/log_artifact /datum/log_category/blackmarket category = LOG_CATEGORY_BLACKMARKET master_category = /datum/log_category/economy - config_flag = /datum/config_entry/flag/blackmarket + config_flag = /datum/config_entry/flag/log_blackmarket -/datum/config_entry/flag/blackmarket +/datum/config_entry/flag/log_blackmarket /datum/log_category/antag_rep category = LOG_CATEGORY_ANTAG_REP - config_flag = /datum/config_entry/flag/antag_rep + config_flag = /datum/config_entry/flag/log_antag_rep -/datum/config_entry/flag/antag_rep +/datum/config_entry/flag/log_antag_rep diff --git a/monkestation/code/modules/storytellers/antag_rep/helper_procs.dm b/monkestation/code/modules/storytellers/antag_rep/helper_procs.dm index 1fb67611e1e9..5970239e1287 100644 --- a/monkestation/code/modules/storytellers/antag_rep/helper_procs.dm +++ b/monkestation/code/modules/storytellers/antag_rep/helper_procs.dm @@ -59,4 +59,5 @@ GLOBAL_LIST_INIT(blessed_ckeys, list( return_value = client_source.prefs.antag_rep returning_list[client_source] = return_value + log_antag_rep("Returned Weighted List of [length(returning_list)]", list("before_weight" = candidates, "after_weight" = returning_list)) return returning_list From d445051b44db4b430e64d6fdf67d0fa9e3c60c75 Mon Sep 17 00:00:00 2001 From: dwasint <82520990+dwasint@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:51:46 -0500 Subject: [PATCH 6/8] Update _base_event.dm --- .../modules/storytellers/converted_events/_base_event.dm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/monkestation/code/modules/storytellers/converted_events/_base_event.dm b/monkestation/code/modules/storytellers/converted_events/_base_event.dm index 5054da37ee16..4c735f949465 100644 --- a/monkestation/code/modules/storytellers/converted_events/_base_event.dm +++ b/monkestation/code/modules/storytellers/converted_events/_base_event.dm @@ -214,14 +214,17 @@ if(length(cliented_list)) mass_adjust_antag_rep(cliented_list, 1) + var/list/weighted_candidates = return_antag_rep_weight(possible_candidates) + while(length(possible_candidates) && length(candidates) < antag_count) //both of these pick_n_take from possible_candidates so this should be fine if(prompted_picking) - candidates |= poll_candidates("Would you like to be a [cast_control.name]", antag_flag, antag_flag, 20 SECONDS, FALSE, FALSE, list(pick_n_take(possible_candidates))) + var/client/picked_client = pick_n_take_weighted(weighted_candidates) + var/mob/picked_mob = picked_client.mob + if(picked_mob) + candidates |= poll_candidates("Would you like to be a [cast_control.name]", antag_flag, antag_flag, 20 SECONDS, FALSE, FALSE, list(picked_mob)) else candidates |= pick_n_take(possible_candidates) - var/list/weighted_candidates = return_antag_rep_weight(candidates) - for(var/i in 1 to antag_count) if(!length(weighted_candidates)) message_admins("A roleset event got fewer antags then its antag_count and may not function correctly.") From 18d653ae5cd9f8e7a1f6364cfed13d28ee2e1ce0 Mon Sep 17 00:00:00 2001 From: dwasint <82520990+dwasint@users.noreply.github.com> Date: Fri, 16 Feb 2024 23:28:01 -0500 Subject: [PATCH 7/8] fixes rep to work again --- .../code/modules/storytellers/converted_events/_base_event.dm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/monkestation/code/modules/storytellers/converted_events/_base_event.dm b/monkestation/code/modules/storytellers/converted_events/_base_event.dm index 4c735f949465..0bf191093b46 100644 --- a/monkestation/code/modules/storytellers/converted_events/_base_event.dm +++ b/monkestation/code/modules/storytellers/converted_events/_base_event.dm @@ -214,8 +214,6 @@ if(length(cliented_list)) mass_adjust_antag_rep(cliented_list, 1) - var/list/weighted_candidates = return_antag_rep_weight(possible_candidates) - while(length(possible_candidates) && length(candidates) < antag_count) //both of these pick_n_take from possible_candidates so this should be fine if(prompted_picking) var/client/picked_client = pick_n_take_weighted(weighted_candidates) @@ -225,6 +223,7 @@ else candidates |= pick_n_take(possible_candidates) + var/list/weighted_candidates = return_antag_rep_weight(candidates) for(var/i in 1 to antag_count) if(!length(weighted_candidates)) message_admins("A roleset event got fewer antags then its antag_count and may not function correctly.") From b1e67d436df8df29c480f3bfbce44b807278887f Mon Sep 17 00:00:00 2001 From: dwasint <82520990+dwasint@users.noreply.github.com> Date: Fri, 16 Feb 2024 23:32:09 -0500 Subject: [PATCH 8/8] Update _base_event.dm --- .../storytellers/converted_events/_base_event.dm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/monkestation/code/modules/storytellers/converted_events/_base_event.dm b/monkestation/code/modules/storytellers/converted_events/_base_event.dm index 0bf191093b46..6a85bfb630ef 100644 --- a/monkestation/code/modules/storytellers/converted_events/_base_event.dm +++ b/monkestation/code/modules/storytellers/converted_events/_base_event.dm @@ -214,6 +214,8 @@ if(length(cliented_list)) mass_adjust_antag_rep(cliented_list, 1) + var/list/weighted_candidates = return_antag_rep_weight(possible_candidates) + while(length(possible_candidates) && length(candidates) < antag_count) //both of these pick_n_take from possible_candidates so this should be fine if(prompted_picking) var/client/picked_client = pick_n_take_weighted(weighted_candidates) @@ -221,16 +223,16 @@ if(picked_mob) candidates |= poll_candidates("Would you like to be a [cast_control.name]", antag_flag, antag_flag, 20 SECONDS, FALSE, FALSE, list(picked_mob)) else - candidates |= pick_n_take(possible_candidates) + var/client/picked_client = pick_n_take_weighted(weighted_candidates) + var/mob/picked_mob = picked_client.mob + candidates |= picked_mob - var/list/weighted_candidates = return_antag_rep_weight(candidates) for(var/i in 1 to antag_count) if(!length(weighted_candidates)) message_admins("A roleset event got fewer antags then its antag_count and may not function correctly.") break - var/client/mob_client = pick_n_take_weighted(weighted_candidates) - var/mob/candidate = mob_client.mob + var/mob/candidate = pick_n_take(candidates) candidate.client?.prefs.reset_antag_rep()