diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index 4585837f802..3b6b584ee23 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -134,7 +134,40 @@ var/global/datum/controller/occupations/job_master if(!job) continue var/list/candidates = FindOccupationCandidates(job, level) if(!candidates.len) continue - var/mob/new_player/candidate = pick(candidates) + + // Build a weighted list, weight by age. + var/list/weightedCandidates = list() + + // Different head positions have different good ages. + var/good_age_minimal = 25 + var/good_age_maximal = 60 + if(command_position == "Captain") + good_age_minimal = 30 + good_age_maximal = 70 // Old geezer captains ftw + + for(var/mob/V in candidates) + // Log-out during round-start? What a bad boy, no head position for you! + if(!V.client) continue + var/age = V.client.prefs.age + switch(age) + if(good_age_minimal - 10 to good_age_minimal) + weightedCandidates[V] = 3 // Still a bit young. + if(good_age_minimal to good_age_minimal + 10) + weightedCandidates[V] = 6 // Better. + if(good_age_minimal + 10 to good_age_maximal - 10) + weightedCandidates[V] = 10 // Great. + if(good_age_maximal - 10 to good_age_maximal) + weightedCandidates[V] = 6 // Still good. + if(good_age_maximal to good_age_maximal + 10) + weightedCandidates[V] = 6 // Bit old, don't you think? + if(good_age_maximal to good_age_maximal + 50) + weightedCandidates[V] = 3 // Geezer. + else + // If there's ABSOLUTELY NOBODY ELSE + if(candidates.len == 1) weightedCandidates[V] = 1 + + + var/mob/new_player/candidate = pickweight(weightedCandidates) if(AssignRole(candidate, command_position)) return 1 return 0