diff --git a/code/game/gamemodes/objective.dm b/code/game/gamemodes/objective.dm index f6ba5867919..587a43b7302 100644 --- a/code/game/gamemodes/objective.dm +++ b/code/game/gamemodes/objective.dm @@ -35,7 +35,6 @@ datum/objective if(possible_targets.len > 0) target = pick(possible_targets) - proc/find_target_by_role(role, role_type=0)//Option sets either to check assigned role or special role. Default to assigned. var/list/possible_targets = list() for(var/datum/mind/possible_target in ticker.minds) @@ -44,6 +43,15 @@ datum/objective if(possible_targets.len > 0) target = pick(possible_targets) +//Selects someone with a specific special role if role is != null. Or just anyone with a special role + proc/find_target_with_special_role(role) + var/list/possible_targets = list() + for(var/datum/mind/possible_target in ticker.minds) + if((possible_target != owner) && ishuman(possible_target.current) && (role && possible_target.special_role == role || !role && possible_target.special_role) && (possible_target.current.stat != 2) ) + possible_targets += possible_target + if(possible_targets.len > 0) + target = pick(possible_targets) + datum/objective/assassinate find_target() @@ -276,6 +284,14 @@ datum/objective/protect//The opposite of killing a dude. explanation_text = "Free Objective" return target + find_target_with_special_role(role,role_type=0) + ..(role) + if(target && target.current) + explanation_text = "Protect [target.current.real_name], the [!role_type ? target.assigned_role : target.special_role]." + else + explanation_text = "Free Objective" + return target + check_completion() if(!target) //If it's a free objective. return 1 diff --git a/code/game/gamemodes/traitor/traitor.dm b/code/game/gamemodes/traitor/traitor.dm index 24198d4e776..f975ecbcc20 100644 --- a/code/game/gamemodes/traitor/traitor.dm +++ b/code/game/gamemodes/traitor/traitor.dm @@ -109,7 +109,7 @@ if(41 to 50) var/datum/objective/protect/protect_objective = new protect_objective.owner = traitor - protect_objective.find_target_by_role("Traitor",0) //Protect your fellow traitor + protect_objective.find_target_with_special_role(null,0) if (!protect_objective.target) protect_objective.find_target() //We could not find any traitors, protect somebody traitor.objectives += protect_objective