From 096cdafce5fbfecf4b897166f0be06fd9f83e4e3 Mon Sep 17 00:00:00 2001 From: Contrabang <91113370+Contrabang@users.noreply.github.com> Date: Sun, 25 Sep 2022 12:37:53 -0400 Subject: [PATCH] Fixes #19095 (#19096) * fixxy fixxy * uses is_invalid_target instead * aa review, consistency * wowee! * Revert "wowee!" This reverts commit cf1905092cace1ba187fd8ab3a6f391a8903cc41. --- code/datums/mind.dm | 12 +++++++++--- code/game/gamemodes/objective.dm | 13 ++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/code/datums/mind.dm b/code/datums/mind.dm index 3e5f9f4d1bb..53576887361 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -606,9 +606,12 @@ var/objective_type = "[objective_type_capital][objective_type_text]"//Add them together into a text string. var/list/possible_targets = list() + var/list/possible_targets_random = list() for(var/datum/mind/possible_target in SSticker.minds) if((possible_target != src) && istype(possible_target.current, /mob/living/carbon/human)) - possible_targets += possible_target.current + possible_targets += possible_target.current // Allows for admins to pick off station roles + if(!is_invalid_target(possible_target)) + possible_targets_random += possible_target.current // For random picking, only valid targets var/mob/def_target = null var/objective_list[] = list(/datum/objective/assassinate, /datum/objective/protect, /datum/objective/debrain) @@ -617,12 +620,15 @@ possible_targets = sortAtom(possible_targets) var/new_target - if(length(possible_targets) > 0) + if(length(possible_targets)) if(alert(usr, "Do you want to pick the objective yourself? No will randomise it", "Pick objective", "Yes", "No") == "Yes") possible_targets += "Free objective" new_target = input("Select target:", "Objective target", def_target) as null|anything in possible_targets else - new_target = pick(possible_targets) + if(!length(possible_targets_random)) + to_chat(usr, "No random target found. Pick one manually.") + return + new_target = pick(possible_targets_random) if(!new_target) return diff --git a/code/game/gamemodes/objective.dm b/code/game/gamemodes/objective.dm index 4ffbbe69d5f..c939fef0ba6 100644 --- a/code/game/gamemodes/objective.dm +++ b/code/game/gamemodes/objective.dm @@ -30,11 +30,7 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) /datum/objective/proc/check_completion() return completed -/datum/objective/proc/is_invalid_target(datum/mind/possible_target) - if(possible_target == owner) - return TARGET_INVALID_IS_OWNER - if(possible_target in owner.targets) - return TARGET_INVALID_IS_TARGET +/datum/proc/is_invalid_target(datum/mind/possible_target) // Originally an Objective proc. Changed to a datum proc to allow for the proc to be run on minds, before the objective is created if(!ishuman(possible_target.current)) return TARGET_INVALID_NOT_HUMAN if(possible_target.current.stat == DEAD) @@ -50,6 +46,13 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) if(possible_target.offstation_role) return TARGET_INVALID_EVENT +/datum/objective/is_invalid_target(datum/mind/possible_target) + if(possible_target == owner) + return TARGET_INVALID_IS_OWNER + if(possible_target in owner.targets) + return TARGET_INVALID_IS_TARGET + return ..() + /datum/objective/proc/find_target() if(!needs_target)