diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index eb441a96b94..d31c7dd746b 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -442,6 +442,22 @@ return candidates +/proc/pollCandidatesForMob(Question, jobbanType, datum/game_mode/gametypeCheck, be_special_flag = 0, poll_time = 300, mob/M) + var/list/L = pollCandidates(Question, jobbanType, gametypeCheck, be_special_flag, poll_time) + if(!M || qdeleted(M)) + return list() + return L + +/proc/pollCandidatesForMobs(Question, jobbanType, datum/game_mode/gametypeCheck, be_special_flag = 0, poll_time = 300, list/mobs) + var/list/L = pollCandidates(Question, jobbanType, gametypeCheck, be_special_flag, poll_time) + var/i=1 + for(var/v in mobs) + if(!v || qdeleted(v)) + mobs.Cut(i,i+1) + else + ++i + return L + /proc/makeBody(mob/dead/observer/G_found) // Uses stripped down and bastardized code from respawn character if(!G_found || !G_found.key) return diff --git a/code/game/gamemodes/blob/powers.dm b/code/game/gamemodes/blob/powers.dm index f8781f3b6d3..0d7e5ffe098 100644 --- a/code/game/gamemodes/blob/powers.dm +++ b/code/game/gamemodes/blob/powers.dm @@ -166,7 +166,7 @@ blobber.notransform = 1 //stop the naut from moving around blobber.adjustHealth(blobber.maxHealth * 0.5) blob_mobs += blobber - var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as a [blob_reagent_datum.name] blobbernaut?", ROLE_BLOB, null, ROLE_BLOB, 50) //players must answer rapidly + var/list/mob/dead/observer/candidates = pollCandidatesForMob("Do you want to play as a [blob_reagent_datum.name] blobbernaut?", ROLE_BLOB, null, ROLE_BLOB, 50, blobber) //players must answer rapidly if(candidates.len) //if we got at least one candidate, they're a blobbernaut now. var/client/C = pick(candidates) blobber.notransform = 0 diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm index 9d2f9d3c628..cc7b43a6adb 100644 --- a/code/game/gamemodes/game_mode.dm +++ b/code/game/gamemodes/game_mode.dm @@ -517,7 +517,7 @@ return max(0, enemy_minimum_age - C.player_age) /datum/game_mode/proc/replace_jobbaned_player(mob/living/M, role_type, pref) - var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as a [role_type]?", "[role_type]", null, pref, 100) + var/list/mob/dead/observer/candidates = pollCandidatesForMob("Do you want to play as a [role_type]?", "[role_type]", null, pref, 100, M) var/mob/dead/observer/theghost = null if(candidates.len) theghost = pick(candidates) diff --git a/code/modules/admin/fun_balloon.dm b/code/modules/admin/fun_balloon.dm index 64d0a762731..40eff1ce83b 100644 --- a/code/modules/admin/fun_balloon.dm +++ b/code/modules/admin/fun_balloon.dm @@ -51,7 +51,7 @@ bodies += M var/question = "Would you like to be [group_name]?" - var/list/candidates = pollCandidates(question, "pAI", null, FALSE, 100) + var/list/candidates = pollCandidatesForMobs(question, "pAI", null, FALSE, 100, bodies) while(candidates.len && bodies.len) var/mob/dead/observer/ghost = pick_n_take(candidates) var/mob/living/body = pick_n_take(bodies) diff --git a/code/modules/awaymissions/mission_code/Academy.dm b/code/modules/awaymissions/mission_code/Academy.dm index b4b537285f7..585453a1849 100644 --- a/code/modules/awaymissions/mission_code/Academy.dm +++ b/code/modules/awaymissions/mission_code/Academy.dm @@ -91,7 +91,7 @@ if(!current_wizard) return spawn(0) - var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as Wizard Academy Defender?", "wizard", null, ROLE_WIZARD) + var/list/mob/dead/observer/candidates = pollCandidatesForMob("Do you want to play as Wizard Academy Defender?", "wizard", null, ROLE_WIZARD, current_wizard) var/mob/dead/observer/chosen = null if(candidates.len) @@ -266,7 +266,7 @@ servant_mind.objectives += O servant_mind.transfer_to(H) - var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as [user.real_name] Servant?", "wizard") + var/list/mob/dead/observer/candidates = pollCandidatesForMob("Do you want to play as [user.real_name] Servant?", "wizard", mob = H) var/mob/dead/observer/chosen = null if(candidates.len) diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 2add2975aa3..3e734dee12f 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -453,7 +453,7 @@ It's fairly easy to fix if dealing with single letters but not so much with comp poll_message = "[poll_message] Job:[M.mind.assigned_role]." if(M.mind && M.mind.special_role) poll_message = "[poll_message] Status:[M.mind.special_role]." - var/list/mob/dead/observer/candidates = pollCandidates(poll_message, "pAI", null, FALSE, 100) + var/list/mob/dead/observer/candidates = pollCandidatesForMob(poll_message, "pAI", null, FALSE, 100, M) var/mob/dead/observer/theghost = null if(candidates.len) diff --git a/code/modules/research/xenobiology/xenobiology.dm b/code/modules/research/xenobiology/xenobiology.dm index 66b18bd7ce5..810d8aedba4 100644 --- a/code/modules/research/xenobiology/xenobiology.dm +++ b/code/modules/research/xenobiology/xenobiology.dm @@ -184,7 +184,7 @@ user << "You offer the sentience potion to [SM]..." being_used = 1 - var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as [SM.name]?", ROLE_ALIEN, null, ROLE_ALIEN, 50, POLL_IGNORE_SENTIENCE_POTION) // see poll_ignore.dm + var/list/mob/dead/observer/candidates = pollCandidatesForMob("Do you want to play as [SM.name]?", ROLE_ALIEN, null, ROLE_ALIEN, 50, POLL_IGNORE_SENTIENCE_POTION, SM) // see poll_ignore.dm var/mob/dead/observer/theghost = null if(candidates.len) theghost = pick(candidates)