Skip to content

Commit

Permalink
bugfix: fixes malfs that cannot be AIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rerik007 committed Apr 10, 2024
1 parent 58d9f90 commit 53c284a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion code/game/gamemodes/antag_paradise/antag_paradise.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions code/game/gamemodes/game_mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,15 @@
* 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()

// Assemble a list of active players without jobbans and role enabled
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

Expand Down Expand Up @@ -317,15 +317,15 @@
/**
* 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()

// Assemble a list of active players without jobbans and role enabled
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

Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/traitor/traitor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
15 changes: 11 additions & 4 deletions code/modules/client/preference/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 53c284a

Please sign in to comment.