From 7cc20bbfd5b4e060c0c3a39aa2ef0bd75d027f8b Mon Sep 17 00:00:00 2001 From: Doubleumc Date: Fri, 9 Aug 2024 20:19:43 -0400 Subject: [PATCH] initial --- code/__DEFINES/stats.dm | 4 ++++ code/game/jobs/role_authority.dm | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/code/__DEFINES/stats.dm b/code/__DEFINES/stats.dm index 1810d01e1d..bc7cbfc4a4 100644 --- a/code/__DEFINES/stats.dm +++ b/code/__DEFINES/stats.dm @@ -8,7 +8,11 @@ #define FACEHUG_TIER_3 100 #define FACEHUG_TIER_4 1000 +/// Consecutive rounds this player has readied up and failed to get a slot. +#define PLAYER_STAT_UNASSIGNED_ROUND_STREAK "unassigned_round_streak" + // Stat Categories #define STAT_CATEGORY_MARINE "marine" #define STAT_CATEGORY_XENO "xeno" #define STAT_CATEGORY_YAUTJA "yautja" +#define STAT_CATEGORY_MISC "misc" diff --git a/code/game/jobs/role_authority.dm b/code/game/jobs/role_authority.dm index 42ffc22570..0f5ca441cc 100644 --- a/code/game/jobs/role_authority.dm +++ b/code/game/jobs/role_authority.dm @@ -246,12 +246,26 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou if(!length(roles_to_assign) || !length(unassigned_players)) return + log_debug("ASSIGNMENT: Building weighted_players list.") + var/list/weighted_players = list() + for(var/mob/new_player/cycled_unassigned in unassigned_players) + //1 base weight + 1 for new players + 1/per missed round + var/weight = 1 + (cycled_unassigned.client.get_total_human_playtime() < 5 HOURS) + get_client_stat(cycled_unassigned.client, PLAYER_STAT_UNASSIGNED_ROUND_STREAK) + weighted_players[cycled_unassigned] = weight + + log_debug("ASSIGNMENT: Weighted shuffling unassigned_players list.") + unassigned_players.Cut() + while(length(weighted_players)) + var/mob/new_player/weighted_pick = pick_weight(weighted_players) + unassigned_players += weighted_pick + weighted_players -= weighted_pick + log_debug("ASSIGNMENT: Starting prime priority assignments.") - for(var/mob/new_player/cycled_unassigned in shuffle(unassigned_players)) + for(var/mob/new_player/cycled_unassigned in unassigned_players) assign_role_to_player_by_priority(cycled_unassigned, roles_to_assign, unassigned_players, PRIME_PRIORITY) log_debug("ASSIGNMENT: Starting regular priority assignments.") - for(var/mob/new_player/cycled_unassigned in shuffle(unassigned_players)) + for(var/mob/new_player/cycled_unassigned in unassigned_players) var/player_assigned_job = FALSE for(var/priority in HIGH_PRIORITY to LOW_PRIORITY) @@ -278,6 +292,7 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou if(assign_role(cycled_unassigned, random_job)) log_debug("ASSIGNMENT: We have randomly assigned [random_job_name] to [cycled_unassigned]") + cycled_unassigned.client.player_data?.adjust_stat(PLAYER_STAT_UNASSIGNED_ROUND_STREAK, STAT_CATEGORY_MISC, 0, TRUE) unassigned_players -= cycled_unassigned if(random_job.spawn_positions != -1 && random_job.current_positions >= random_job.spawn_positions) @@ -292,6 +307,7 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou var/datum/job/marine_job = GET_MAPPED_ROLE(JOB_SQUAD_MARINE) if(assign_role(cycled_unassigned, marine_job)) log_debug("ASSIGNMENT: We have assigned [marine_job.title] to [cycled_unassigned] via alternate option.") + cycled_unassigned.client.player_data?.adjust_stat(PLAYER_STAT_UNASSIGNED_ROUND_STREAK, STAT_CATEGORY_MISC, 0, TRUE) unassigned_players -= cycled_unassigned if(marine_job.spawn_positions != -1 && marine_job.current_positions >= marine_job.spawn_positions) @@ -305,6 +321,8 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou cycled_unassigned.ready = 0 log_debug("ASSIGNMENT: Assignment complete. Players unassigned: [length(unassigned_players)] Jobs unassigned: [length(roles_to_assign)]") + for(var/mob/new_player/cycled_unassigned in unassigned_players) + cycled_unassigned.client.player_data?.adjust_stat(PLAYER_STAT_UNASSIGNED_ROUND_STREAK, STAT_CATEGORY_MISC, 1) return roles_to_assign @@ -321,6 +339,7 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou if(assign_role(cycled_unassigned, actual_job)) log_debug("ASSIGNMENT: We have assigned [job_name] to [cycled_unassigned].") + cycled_unassigned.client.player_data?.adjust_stat(PLAYER_STAT_UNASSIGNED_ROUND_STREAK, STAT_CATEGORY_MISC, 0, TRUE) unassigned_players -= cycled_unassigned if(actual_job.spawn_positions != -1 && actual_job.current_positions >= actual_job.spawn_positions)