From 93e77f7a4962ab43b3579cf62d101f86dede4ab3 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 21 Sep 2023 01:20:21 +0200 Subject: [PATCH] [MIRROR] Holo para refund fix [MDB IGNORE] (#23823) * Holo para refund fix (#78431) ## About The Pull Request Holoparasite injector can be refunded if its been used, this is because the uplink_reimburse element is not removed from it when its used. Added some signal code to it so that this is fixed. ## Why It's Good For The Game Fixes a bug. ## Changelog Fixes a bug allowing holopara injectors to be refundable when used. :cl: fix: Fixes a bug allowing holopara injectors to be refundable when used. /:cl: * Holo para refund fix --------- Co-authored-by: Coconutwarrior97 <40315842+Coconutwarrior97@users.noreply.github.com> --- code/__DEFINES/dcs/signals/signals_object.dm | 2 ++ code/datums/elements/uplink_reimburse.dm | 13 ++++++++++--- .../simple_animal/guardian/guardian_creator.dm | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/code/__DEFINES/dcs/signals/signals_object.dm b/code/__DEFINES/dcs/signals/signals_object.dm index a5ab7349fda..19286859e9e 100644 --- a/code/__DEFINES/dcs/signals/signals_object.dm +++ b/code/__DEFINES/dcs/signals/signals_object.dm @@ -248,6 +248,8 @@ /// Called on component/uplink/OnAttackBy(..) #define COMSIG_ITEM_ATTEMPT_TC_REIMBURSE "item_attempt_tc_reimburse" +///Called when a holoparasite/guardiancreator is used. +#define COMSIG_TRAITOR_ITEM_USED(type) "traitor_item_used_[type]" // /obj/item/clothing signals diff --git a/code/datums/elements/uplink_reimburse.dm b/code/datums/elements/uplink_reimburse.dm index 5387f245d8c..3ff182ec231 100644 --- a/code/datums/elements/uplink_reimburse.dm +++ b/code/datums/elements/uplink_reimburse.dm @@ -1,5 +1,5 @@ /** - * Uplinik Reimburse element. + * Uplink Reimburse element. * When element is applied onto items, it allows them to be reimbursed if an user pokes an item with a uplink component with them. * * Element is only compatible with items. @@ -21,9 +21,11 @@ RegisterSignal(target, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine)) RegisterSignal(target, COMSIG_ITEM_ATTEMPT_TC_REIMBURSE, PROC_REF(reimburse)) - + RegisterSignal(target,COMSIG_TRAITOR_ITEM_USED(target.type), PROC_REF(used)) + /datum/element/uplink_reimburse/Detach(datum/target) - UnregisterSignal(target, list(COMSIG_ATOM_ATTACKBY, COMSIG_ATOM_EXAMINE)) + UnregisterSignal(target, list(COMSIG_ATOM_EXAMINE, COMSIG_TRAITOR_ITEM_USED(target.type), COMSIG_ITEM_ATTEMPT_TC_REIMBURSE)) + return ..() @@ -47,3 +49,8 @@ do_sparks(2, source = uplink_comp.uplink_handler) uplink_comp.add_telecrystals(refundable_tc) qdel(refund_item) +/// If the item is used, it needs to no longer be refundable +/datum/element/uplink_reimburse/proc/used(datum/target) + SIGNAL_HANDLER + + Detach(target) diff --git a/code/modules/mob/living/simple_animal/guardian/guardian_creator.dm b/code/modules/mob/living/simple_animal/guardian/guardian_creator.dm index b57ae45e1b7..ebd5658f07f 100644 --- a/code/modules/mob/living/simple_animal/guardian/guardian_creator.dm +++ b/code/modules/mob/living/simple_animal/guardian/guardian_creator.dm @@ -87,9 +87,10 @@ GLOBAL_LIST_INIT(guardian_radial_images, setup_guardian_radial()) if(LAZYLEN(candidates)) var/mob/dead/observer/candidate = pick(candidates) spawn_guardian(user, candidate, guardian_path) + used = TRUE + SEND_SIGNAL(src, COMSIG_TRAITOR_ITEM_USED(type)) else to_chat(user, failure_message) - used = FALSE /obj/item/guardiancreator/proc/spawn_guardian(mob/living/user, mob/dead/candidate, guardian_path) if(QDELETED(user) || user.stat == DEAD)