From 133633ac90c174e28611acc9ccc8b6a00a46a652 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 1 Sep 2021 17:43:53 +0200 Subject: [PATCH] [MIRROR] Objective-specific equipment will always be given. (#7862) * Objective-specific equipment will always be given. * Update datum_traitor.dm Co-authored-by: Y0SH1M4S73R Co-authored-by: Gandalf --- code/datums/components/uplink.dm | 22 ++++++++++-- code/datums/mind.dm | 25 ++++++++++--- code/game/gamemodes/objective.dm | 36 ++++++++++++++++--- .../game/objects/items/storage/uplink_kits.dm | 6 ++-- .../antagonists/traitor/datum_traitor.dm | 15 ++++---- code/modules/uplink/uplink_items.dm | 13 +++++++ 6 files changed, 96 insertions(+), 21 deletions(-) diff --git a/code/datums/components/uplink.dm b/code/datums/components/uplink.dm index 5b76278a1db..9f9610dfd0f 100644 --- a/code/datums/components/uplink.dm +++ b/code/datums/components/uplink.dm @@ -79,10 +79,11 @@ purchase_log = null return ..() -/datum/component/uplink/proc/update_items() +/datum/component/uplink/proc/update_items(user) var/updated_items updated_items = get_uplink_items(uplink_flag, TRUE, allow_restricted) update_sales(updated_items) + update_special_equipment(user, updated_items) uplink_items = updated_items /datum/component/uplink/proc/update_sales(updated_items) @@ -93,6 +94,23 @@ if (uplink_items[category] != null && updated_items[category] != null) updated_items[category] = uplink_items[category] +/datum/component/uplink/proc/update_special_equipment(mob/user, updated_items) + if(!user?.mind?.failed_special_equipment) + return + for(var/obj/item/equipment_path as anything in user.mind.failed_special_equipment) + var/datum/uplink_item/special_equipment/equipment_uplink_item = new + if(!updated_items[equipment_uplink_item.category]) + updated_items[equipment_uplink_item.category] = list() + var/list/name_words = splittext(initial(equipment_path.name), " ") + var/capitalized_name + for(var/i in 1 to name_words.len) + name_words[i] = capitalize(name_words[i]) + capitalized_name = name_words.Join(" ") + equipment_uplink_item.item = equipment_path + equipment_uplink_item.name = capitalized_name + equipment_uplink_item.desc = initial(equipment_path.desc) + updated_items[equipment_uplink_item.category][equipment_uplink_item.name] = equipment_uplink_item + /datum/component/uplink/proc/LoadTC(mob/user, obj/item/stack/telecrystal/TC, silent = FALSE) if(!silent) to_chat(user, span_notice("You slot [TC] into [parent] and charge its internal uplink.")) @@ -128,7 +146,7 @@ if(locked) return active = TRUE - update_items() + update_items(user) if(user) INVOKE_ASYNC(src, .proc/ui_interact, user) // an unlocked uplink blocks also opening the PDA or headset menu diff --git a/code/datums/mind.dm b/code/datums/mind.dm index af25ef851ca..01465cc8559 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -88,6 +88,8 @@ var/list/addiction_points ///Assoc list of key active addictions and value amount of cycles that it has been active. var/list/active_addictions + ///List of objective-specific equipment that couldn't properly be given to the mind + var/list/failed_special_equipment /datum/mind/New(_key) key = _key @@ -724,13 +726,28 @@ to_chat(current, "[objective.objective_name] #[obj_count]: [objective.explanation_text]") obj_count++ -/datum/mind/proc/find_syndicate_uplink() +/datum/mind/proc/find_syndicate_uplink(check_unlocked) var/list/L = current.GetAllContents() for (var/i in L) var/atom/movable/I = i - . = I.GetComponent(/datum/component/uplink) - if(.) - break + var/datum/component/uplink/found_uplink = I.GetComponent(/datum/component/uplink) + if(!found_uplink || (check_unlocked && found_uplink.locked)) + continue + return found_uplink + +/** +* Checks to see if the mind has an accessible uplink (their own, if they are a traitor; any unlocked uplink otherwise), +* and gives them a fallback spell if no uplink was found +*/ +/datum/mind/proc/try_give_equipment_fallback() + var/datum/component/uplink/uplink + var/datum/antagonist/traitor/traitor_datum = has_antag_datum(/datum/antagonist/traitor) + if(traitor_datum) + uplink = traitor_datum.uplink + if(!uplink) + uplink = find_syndicate_uplink(check_unlocked = TRUE) + if(!uplink && !(locate(/obj/effect/proc_holder/spell/self/special_equipment_fallback) in spell_list)) + AddSpell(new /obj/effect/proc_holder/spell/self/special_equipment_fallback(null, src)) /datum/mind/proc/take_uplink() qdel(find_syndicate_uplink()) diff --git a/code/game/gamemodes/objective.dm b/code/game/gamemodes/objective.dm index a622e6cc247..0bd329c7d86 100644 --- a/code/game/gamemodes/objective.dm +++ b/code/game/gamemodes/objective.dm @@ -159,11 +159,39 @@ GLOBAL_LIST_EMPTY(objectives) var/datum/mind/receiver = pick(get_owners()) if(receiver?.current) if(ishuman(receiver.current)) - var/mob/living/carbon/human/H = receiver.current + var/mob/living/carbon/human/receiver_current = receiver.current var/list/slots = list("backpack" = ITEM_SLOT_BACKPACK) - for(var/eq_path in special_equipment) - var/obj/O = new eq_path - H.equip_in_one_of_slots(O, slots) + for(var/obj/equipment_path as anything in special_equipment) + var/obj/equipment_object = new equipment_path + if(!receiver_current.equip_in_one_of_slots(equipment_object, slots)) + LAZYINITLIST(receiver.failed_special_equipment) + receiver.failed_special_equipment += equipment_path + receiver.try_give_equipment_fallback() + +/obj/effect/proc_holder/spell/self/special_equipment_fallback + name = "Request Objective-specific Equipment" + desc = "Call down a supply pod containing the equipment required for specific objectives." + action_icon = 'icons/obj/device.dmi' + action_icon_state = "beacon" + charge_max = 0 + clothes_req = FALSE + nonabstract_req = TRUE + phase_allowed = TRUE + antimagic_allowed = TRUE + invocation_type = "none" + +/obj/effect/proc_holder/spell/self/special_equipment_fallback/cast(list/targets, mob/user) + var/datum/mind/mind = user.mind + if(!mind) + CRASH("[src] has no owner!") + if(mind.failed_special_equipment?.len) + podspawn(list( + "target" = get_turf(user), + "style" = STYLE_SYNDICATE, + "spawn" = mind.failed_special_equipment + )) + mind.failed_special_equipment = null + mind.RemoveSpell(src) /datum/objective/assassinate name = "assasinate" diff --git a/code/game/objects/items/storage/uplink_kits.dm b/code/game/objects/items/storage/uplink_kits.dm index ea3a603be44..6bbd0e03d5d 100644 --- a/code/game/objects/items/storage/uplink_kits.dm +++ b/code/game/objects/items/storage/uplink_kits.dm @@ -481,7 +481,8 @@ new /obj/item/reagent_containers/syringe(src) /obj/item/storage/box/syndie_kit/nuke - name = "box" + name = "nuke core extraction kit" + desc = "A box containing the equipment and instructions for extracting the plutonium cores of most Nanotrasen nuclear explosives." /obj/item/storage/box/syndie_kit/nuke/PopulateContents() new /obj/item/screwdriver/nuke(src) @@ -489,7 +490,8 @@ new /obj/item/paper/guides/antag/nuke_instructions(src) /obj/item/storage/box/syndie_kit/supermatter - name = "box" + name = "supermatter sliver extraction kit" + desc = "A box containing the equipment and instructions for extracting a sliver of supermatter." /obj/item/storage/box/syndie_kit/supermatter/PopulateContents() new /obj/item/scalpel/supermatter(src) diff --git a/code/modules/antagonists/traitor/datum_traitor.dm b/code/modules/antagonists/traitor/datum_traitor.dm index 2cb4f04749c..50eb50811df 100644 --- a/code/modules/antagonists/traitor/datum_traitor.dm +++ b/code/modules/antagonists/traitor/datum_traitor.dm @@ -50,6 +50,12 @@ /datum/antagonist/traitor/on_gain() owner.special_role = job_rank + + if(give_uplink) + owner.give_uplink(silent = TRUE, antag_datum = src) + + uplink = owner.find_syndicate_uplink() + if(give_objectives) forge_traitor_objectives() forge_ending_objective() @@ -60,15 +66,6 @@ traitor_flavor = strings(TRAITOR_FLAVOR_FILE, employer) - /* - SKYRAT EDIT START - AMBITIONS - if(give_uplink) - owner.give_uplink(silent = TRUE, antag_datum = src) - - uplink = owner.find_syndicate_uplink() - SKYRAT EDIT END - AMBITIONS - */ - owner.current.playsound_local(get_turf(owner.current), 'sound/ambience/antag/tatoralert.ogg', 100, FALSE, pressure_affected = FALSE, use_reverb = FALSE) return ..() diff --git a/code/modules/uplink/uplink_items.dm b/code/modules/uplink/uplink_items.dm index 09a233993a6..a57c857e290 100644 --- a/code/modules/uplink/uplink_items.dm +++ b/code/modules/uplink/uplink_items.dm @@ -2065,3 +2065,16 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item)) cost = 1 purchasable_from = UPLINK_CLOWN_OPS illegal_tech = FALSE + +// Special equipment (Dynamically fills in uplink component) +/datum/uplink_item/special_equipment + category = "Objective-Specific Equipment" + name = "Objective-Specific Equipment" + desc = "Equipment necessary for accomplishing specific objectives. If you are seeing this, something has gone wrong." + limited_stock = 1 + illegal_tech = FALSE + +/datum/uplink_item/special_equipment/purchase(mob/user, datum/component/uplink/U) + ..() + if(user?.mind?.failed_special_equipment) + user.mind.failed_special_equipment -= item