From 77e7348029aee525edae26daef8783dd20668e4e Mon Sep 17 00:00:00 2001 From: Aquilar Date: Sun, 17 Dec 2023 00:10:49 +0800 Subject: [PATCH] Cleans up and update of mind and objective. (#23350) * clean up and update of mind and objectives * making it work. * identity theft * requested changes * updating some target && target to target?. * requested changes * adds update_explaination_text to objective/steal --- code/datums/mind.dm | 24 +++---- code/game/gamemodes/objective.dm | 111 ++++++++++++++++--------------- 2 files changed, 66 insertions(+), 69 deletions(-) diff --git a/code/datums/mind.dm b/code/datums/mind.dm index ae2dc41e616..9a09c684389 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -631,8 +631,8 @@ def_value = "custom" var/new_obj_type = input("Select objective type:", "Objective type", def_value) as null|anything in list( - "assassinate", "assassinateonce", "blood", "debrain", "protect", "prevent", "hijack", "escape", "survive", "steal", "download", - "nuclear", "capture", "absorb", "destroy", "maroon", "identity theft", "custom") + "assassinate", "assassinateonce", "blood", "debrain", "protect", "prevent", "hijack", "escape", "survive", "steal", + "nuclear", "absorb", "destroy", "maroon", "identity theft", "custom") if(!new_obj_type) return @@ -640,11 +640,6 @@ switch(new_obj_type) if("assassinate", "assassinateonce", "protect","debrain", "maroon") - //To determine what to name the objective in explanation text. - var/objective_type_capital = uppertext(copytext(new_obj_type, 1,2))//Capitalize first letter. - var/objective_type_text = copytext(new_obj_type, 2)//Leave the rest of the text. - 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) @@ -680,13 +675,11 @@ if(new_target == "Free objective") new_objective = new objective_path new_objective:target = null - new_objective.explanation_text = "Free objective" + new_objective.update_explanation_text() else new_objective = new objective_path new_objective:target = new_target:mind - //Will display as special role if assigned mode is equal to special role.. Ninjas/commandos/nuke ops. - new_objective.explanation_text = "[objective_type] [new_target:real_name], the [new_target:mind:assigned_role == new_target:mind:special_role ? (new_target:mind:special_role) : (new_target:mind:assigned_role)]." - new_objective.establish_signals() + new_objective.update_explanation_text() if("destroy") var/list/possible_targets = active_ais(1) @@ -694,7 +687,7 @@ var/mob/new_target = input("Select target:", "Objective target") as null|anything in possible_targets new_objective = new /datum/objective/destroy new_objective.target = new_target.mind - new_objective.explanation_text = "Destroy [new_target.name], the experimental AI." + new_objective.update_explanation_text() else to_chat(usr, "No active AIs with minds") @@ -722,7 +715,7 @@ if(!steal.select_target()) return - if("download","capture","absorb", "blood") + if("absorb", "blood") var/def_num if(objective&&objective.type==text2path("/datum/objective/[new_obj_type]")) def_num = objective.target_amount @@ -734,11 +727,10 @@ switch(new_obj_type) if("absorb") new_objective = new /datum/objective/absorb - new_objective.explanation_text = "Absorb [target_number] compatible genomes." if("blood") new_objective = new /datum/objective/blood - new_objective.explanation_text = "Accumulate at least [target_number] total units of blood." new_objective.target_amount = target_number + new_objective.update_explanation_text() if("identity theft") var/list/possible_targets = list() @@ -755,7 +747,7 @@ CRASH("Invalid target for identity theft objective, cancelling") new_objective = new /datum/objective/escape/escape_with_identity new_objective.target = new_target - new_objective.explanation_text = "Escape on the shuttle or an escape pod with the identity of [targ.current.real_name], the [targ.assigned_role] while wearing [targ.current.p_their()] identification card." + new_objective.update_explanation_text() var/datum/objective/escape/escape_with_identity/O = new_objective O.target_real_name = new_objective.target.current.real_name if("custom") diff --git a/code/game/gamemodes/objective.dm b/code/game/gamemodes/objective.dm index fad00385276..e2ecd53358e 100644 --- a/code/game/gamemodes/objective.dm +++ b/code/game/gamemodes/objective.dm @@ -58,11 +58,17 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) return target /** - * This is for objectives that need to register signals, so place them in here. Makes it easier for add_objective to call it. + * This is for objectives that need to register signals, so place them in here. */ /datum/objective/proc/establish_signals() return +/** + * This is for objectives that have reason to update their text, such as target changes. + */ +/datum/objective/proc/update_explanation_text() + return + /** * Get all owners of the objective, including ones from the objective's team, if it has one. * @@ -118,6 +124,8 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) target = pick(possible_targets) SEND_SIGNAL(src, COMSIG_OBJECTIVE_TARGET_FOUND, target) + update_explanation_text() + return target /** * Called when the objective's target goes to cryo. @@ -150,18 +158,16 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) /datum/objective/assassinate name = "Assassinate" - martyr_compatible = 1 + martyr_compatible = TRUE -/datum/objective/assassinate/find_target(list/target_blacklist) - ..() - if(target && target.current) +/datum/objective/assassinate/update_explanation_text() + if(target?.current) explanation_text = "Assassinate [target.current.real_name], the [target.assigned_role]." else explanation_text = "Free Objective" - return target /datum/objective/assassinate/check_completion() - if(target && target.current) + if(target?.current) if(target.current.stat == DEAD) return TRUE if(is_special_dead(target.current)) //Borgs/brains/AIs count as dead for traitor objectives. --NeoFite @@ -176,14 +182,12 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) martyr_compatible = TRUE var/won = FALSE -/datum/objective/assassinateonce/find_target(list/target_blacklist) - ..() +/datum/objective/assassinateonce/update_explanation_text() if(target?.current) explanation_text = "Teach [target.current.real_name], the [target.assigned_role], a lesson they will not forget. The target only needs to die once for success." establish_signals() else explanation_text = "Free Objective" - return target /datum/objective/assassinateonce/establish_signals() RegisterSignal(target.current, list(COMSIG_MOB_DEATH, COMSIG_PARENT_QDELETING), PROC_REF(check_midround_completion)) @@ -205,13 +209,11 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) name = "Mutiny" martyr_compatible = TRUE -/datum/objective/mutiny/find_target(list/target_blacklist) - ..() - if(target && target.current) +/datum/objective/mutiny/update_explanation_text() + if(target?.current) explanation_text = "Assassinate or exile [target.current.real_name], the [target.assigned_role]." else explanation_text = "Free Objective" - return target /datum/objective/mutiny/is_invalid_target(datum/mind/possible_target) . = ..() @@ -221,7 +223,7 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) return TARGET_INVALID_NOTHEAD /datum/objective/mutiny/check_completion() - if(target && target.current) + if(target?.current) if(target.current.stat == DEAD || !ishuman(target.current) || !target.current.ckey || !target.current.client) return TRUE var/turf/T = get_turf(target.current) @@ -240,18 +242,16 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) /datum/objective/maroon name = "Maroon" - martyr_compatible = 1 + martyr_compatible = FALSE -/datum/objective/maroon/find_target(list/target_blacklist) - ..() - if(target && target.current) +/datum/objective/maroon/update_explanation_text() + if(target?.current) explanation_text = "Prevent [target.current.real_name], the [target.assigned_role] from escaping alive." else explanation_text = "Free Objective" - return target /datum/objective/maroon/check_completion() - if(target && target.current) + if(target?.current) if(target.current.stat == DEAD) return TRUE if(!target.current.ckey) @@ -267,7 +267,7 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) /datum/objective/debrain //I want braaaainssss name = "Debrain" - martyr_compatible = 0 + martyr_compatible = FALSE /datum/objective/debrain/is_invalid_target(datum/mind/possible_target) . = ..() @@ -277,14 +277,11 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) if(ischangeling(possible_target.current)) return TARGET_INVALID_CHANGELING -/datum/objective/debrain/find_target(list/target_blacklist) - ..() - if(target && target.current) - explanation_text = "Steal the brain of [target.current.real_name] the [target.assigned_role]." +/datum/objective/debrain/update_explanation_text() + if(target?.current) + explanation_text = "Steal the brain of [target.current.real_name], the [target.assigned_role]." else explanation_text = "Free Objective" - return target - /datum/objective/debrain/check_completion() if(!target) // If it's a free objective. @@ -301,15 +298,13 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) /datum/objective/protect //The opposite of killing a dude. name = "Protect" - martyr_compatible = 1 + martyr_compatible = TRUE -/datum/objective/protect/find_target(list/target_blacklist) - ..() - if(target && target.current) +/datum/objective/protect/update_explanation_text() + if(target?.current) explanation_text = "Protect [target.current.real_name], the [target.assigned_role]." else explanation_text = "Free Objective" - return target /datum/objective/protect/check_completion() if(!target) //If it's a free objective. @@ -337,7 +332,7 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) /datum/objective/hijack name = "Hijack" - martyr_compatible = 0 //Technically you won't get both anyway. + martyr_compatible = FALSE //Technically you won't get both anyway. explanation_text = "Hijack the shuttle by escaping on it with no loyalist Nanotrasen crew on board and free. \ Syndicate agents, other enemies of Nanotrasen, cyborgs, pets, and cuffed/restrained hostages may be allowed on the shuttle alive. \ Alternatively, hack the shuttle console multiple times (by alt clicking on it) until the shuttle directions are corrupted." @@ -354,7 +349,7 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) /datum/objective/hijackclone name = "Hijack (with clones)" explanation_text = "Hijack the shuttle by ensuring only you (or your copies) escape." - martyr_compatible = 0 + martyr_compatible = FALSE needs_target = FALSE // This objective should only be given to a single owner, because the "copies" can only copy one person. @@ -389,7 +384,7 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) explanation_text = "Hijack the shuttle with no loyalist Nanotrasen crew on board and free. \ Syndicate agents, other enemies of Nanotrasen, cyborgs, pets, and cuffed/restrained hostages may be allowed on the shuttle alive. \ Using the doomsday device successfully is also an option." - martyr_compatible = 1 + martyr_compatible = FALSE needs_target = FALSE /datum/objective/block/check_completion() @@ -457,9 +452,8 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) // If the target is geneless, then it's an invalid target. return HAS_TRAIT(possible_target.current, TRAIT_GENELESS) -/datum/objective/escape/escape_with_identity/find_target(list/target_blacklist) - ..() - if(target && target.current) +/datum/objective/escape/escape_with_identity/update_explanation_text() + if(target?.current) target_real_name = target.current.real_name explanation_text = "Escape on the shuttle or an escape pod with the identity of [target_real_name], the [target.assigned_role] while wearing [target.p_their()] identification card." else @@ -521,13 +515,13 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) /datum/objective/nuclear name = "Nuke station" explanation_text = "Destroy the station with a nuclear device." - martyr_compatible = 1 + martyr_compatible = TRUE needs_target = FALSE /datum/objective/steal name = "Steal Item" var/datum/theft_objective/steal_target - martyr_compatible = 0 + martyr_compatible = FALSE var/theft_area /datum/objective/steal/found_target() @@ -556,9 +550,7 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) continue steal_target = O - explanation_text = "Steal [steal_target]. One was last seen in [get_location()]. " - if(length(O.protected_jobs) && O.job_possession) - explanation_text += "It may also be in the possession of the [english_list(O.protected_jobs, and_text = " or ")]." + update_explanation_text() if(steal_target.special_equipment) give_kit(steal_target.special_equipment) return @@ -581,11 +573,16 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) explanation_text = "Steal [O.name]." else steal_target = new new_target - explanation_text = "Steal [steal_target.name]." + update_explanation_text() if(steal_target.special_equipment) give_kit(steal_target.special_equipment) return steal_target +/datum/objective/steal/update_explanation_text() + explanation_text = "Steal [steal_target.name]. One was last seen in [get_location()]. " + if(length(steal_target.protected_jobs) && steal_target.job_possession) + explanation_text += "It may also be in the possession of the [english_list(steal_target.protected_jobs, and_text = " or ")]." + /datum/objective/steal/check_completion() if(!steal_target) return TRUE // Free Objective @@ -643,10 +640,12 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) if(P.client && !(P.mind in SSticker.mode.changelings) && !(P.mind in get_owners())) n_p++ target_amount = min(target_amount, n_p) - - explanation_text = "Acquire [target_amount] compatible genomes. The 'Extract DNA Sting' can be used to stealthily get genomes without killing somebody." + update_explanation_text() return target_amount +/datum/objective/absorb/update_explanation_text() + explanation_text = "Acquire [target_amount] compatible genomes. The 'Extract DNA Sting' can be used to stealthily get genomes without killing somebody." + /datum/objective/absorb/check_completion() for(var/datum/mind/M in get_owners()) var/datum/antagonist/changeling/cling = M?.has_antag_datum(/datum/antagonist/changeling) @@ -656,22 +655,25 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) /datum/objective/destroy name = "Destroy AI" - martyr_compatible = 1 - var/target_real_name + martyr_compatible = TRUE /datum/objective/destroy/find_target(list/target_blacklist) var/list/possible_targets = active_ais(1) var/mob/living/silicon/ai/target_ai = pick(possible_targets) target = target_ai.mind - if(target && target.current) + update_explanation_text() + return target + +/datum/objective/destory/update_explanation_text() + var/target_real_name + if(target?.current) target_real_name = target.current.real_name explanation_text = "Destroy [target_real_name], the AI." else explanation_text = "Free Objective" - return target /datum/objective/destroy/check_completion() - if(target && target.current) + if(target?.current) if(target.current.stat == DEAD || is_away_level(target.current.z) || !target.current.ckey) return TRUE return FALSE @@ -749,9 +751,12 @@ GLOBAL_LIST_INIT(potential_theft_objectives, (subtypesof(/datum/theft_objective) /datum/objective/blood/proc/gen_amount_goal(low = 150, high = 400) target_amount = rand(low,high) target_amount = round(round(target_amount/5)*5) - explanation_text = "Accumulate at least [target_amount] total units of blood." + update_explanation_text() return target_amount +/datum/objective/blood/update_explanation_text() + explanation_text = "Accumulate at least [target_amount] total units of blood." + /datum/objective/blood/check_completion() for(var/datum/mind/M in get_owners()) var/datum/antagonist/vampire/V = M.has_antag_datum(/datum/antagonist/vampire)