From 53c284a0bb8da20f0794b08a1fe439b683726f24 Mon Sep 17 00:00:00 2001 From: Rerik007 <120549107+Rerik007@users.noreply.github.com> Date: Wed, 10 Apr 2024 18:51:49 +0300 Subject: [PATCH] bugfix: fixes malfs that cannot be AIs --- .../gamemodes/antag_paradise/antag_paradise.dm | 2 +- code/game/gamemodes/game_mode.dm | 8 ++++---- code/game/gamemodes/traitor/traitor.dm | 2 +- code/modules/client/preference/preferences.dm | 15 +++++++++++---- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/code/game/gamemodes/antag_paradise/antag_paradise.dm b/code/game/gamemodes/antag_paradise/antag_paradise.dm index a84b7a267df..8f53e8e3ee3 100644 --- a/code/game/gamemodes/antag_paradise/antag_paradise.dm +++ b/code/game/gamemodes/antag_paradise/antag_paradise.dm @@ -97,7 +97,7 @@ if(ROLE_MALF_AI) if(special_antag_amount) - var/datum/mind/special_antag = roundstart ? safepick(get_players_for_role(ROLE_MALF_AI)) : safepick(get_alive_players_for_role(ROLE_MALF_AI)) + var/datum/mind/special_antag = roundstart ? safepick(get_players_for_role(ROLE_MALF_AI, req_job_rank = JOB_TITLE_AI)) : safepick(get_alive_players_for_role(ROLE_MALF_AI, req_job_rank = JOB_TITLE_AI)) if(special_antag) special_antag.restricted_roles = (restricted_jobs|protected_jobs|protected_jobs_AI) special_antag.restricted_roles -= JOB_TITLE_AI diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm index 09597bf85df..98abd884a4d 100644 --- a/code/game/gamemodes/game_mode.dm +++ b/code/game/gamemodes/game_mode.dm @@ -281,7 +281,7 @@ * Returns a list of player minds who had the antagonist role set to yes, regardless of recomended_enemies. * Jobbans and restricted jobs are checked. Species lock and prefered species are checked. List is already shuffled. */ -/datum/game_mode/proc/get_players_for_role(role, list/prefered_species) +/datum/game_mode/proc/get_players_for_role(role, list/prefered_species, req_job_rank) var/list/players = list() var/list/candidates = list() @@ -289,7 +289,7 @@ for(var/mob/new_player/player in GLOB.player_list) if(!player.client || !player.ready || !player.has_valid_preferences() \ || jobban_isbanned(player, "Syndicate") || jobban_isbanned(player, role) \ - || !player_old_enough_antag(player.client, role) || player.client.prefs?.skip_antag \ + || !player_old_enough_antag(player.client, role, req_job_rank) || player.client.prefs?.skip_antag \ || !(role in player.client.prefs.be_special)) continue @@ -317,7 +317,7 @@ /** * Works like get_players_for_role, but for alive mobs. */ -/datum/game_mode/proc/get_alive_players_for_role(role, list/preferred_species) +/datum/game_mode/proc/get_alive_players_for_role(role, list/preferred_species, req_job_rank) var/list/players = list() var/list/candidates = list() @@ -325,7 +325,7 @@ for(var/mob/living/carbon/human/player in GLOB.alive_mob_list) if(!player.client \ || jobban_isbanned(player, "Syndicate") || jobban_isbanned(player, role) \ - || !player_old_enough_antag(player.client, role) || player.client.prefs?.skip_antag \ + || !player_old_enough_antag(player.client, role, req_job_rank) || player.client.prefs?.skip_antag \ || !(role in player.client.prefs.be_special)) continue diff --git a/code/game/gamemodes/traitor/traitor.dm b/code/game/gamemodes/traitor/traitor.dm index dfe88ef3776..6a651c2aeef 100644 --- a/code/game/gamemodes/traitor/traitor.dm +++ b/code/game/gamemodes/traitor/traitor.dm @@ -47,7 +47,7 @@ restricted_jobs += protected_jobs var/list/possible_traitors = get_players_for_role(ROLE_TRAITOR) - var/list/possible_malfs = get_players_for_role(ROLE_MALF_AI) + var/list/possible_malfs = get_players_for_role(ROLE_MALF_AI, req_job_rank = JOB_TITLE_AI) var/malf_AI_candidate if(length(possible_malfs)) diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index eb62c08a8c2..269509a81fd 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -32,12 +32,19 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts ROLE_DEVIL = 14 )) -/proc/player_old_enough_antag(client/C, role) +/proc/player_old_enough_antag(client/C, role, req_job_rank) if(available_in_days_antag(C, role)) - return 0 //available_in_days>0 = still some days required = player not old enough + return FALSE //available_in_days>0 = still some days required = player not old enough if(role_available_in_playtime(C, role)) - return 0 //available_in_playtime>0 = still some more playtime required = they are not eligible - return 1 + return FALSE //available_in_playtime>0 = still some more playtime required = they are not eligible + if(!req_job_rank) + return TRUE + var/datum/job/job = SSjobs.GetJob(req_job_rank) + if(!job) + return FALSE + if(job.available_in_playtime(C)) + return TRUE + /proc/available_in_days_antag(client/C, role) if(!C)