From e471f4cc2ea9c76ed6f62566c090fa0593bfaad7 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sun, 17 Apr 2022 23:07:57 +0200 Subject: [PATCH] [MIRROR] [NO GBP] modsuits now retract if summoned through summon items or some other hijinx [MDB IGNORE] (#12852) * [NO GBP] modsuits now retract if summoned through summon items or some other hijinx * Update mod_activation.dm * Update mod_activation.dm Co-authored-by: Fikou <23585223+Fikou@users.noreply.github.com> Co-authored-by: Zonespace <41448081+Zonespace27@users.noreply.github.com> --- code/modules/mod/mod_activation.dm | 21 ++++++++++----------- code/modules/mod/mod_control.dm | 30 +++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/code/modules/mod/mod_activation.dm b/code/modules/mod/mod_activation.dm index d5b4fc85f5d..1e5e508a2ec 100644 --- a/code/modules/mod/mod_activation.dm +++ b/code/modules/mod/mod_activation.dm @@ -149,24 +149,24 @@ if(mod_pai) to_chat(mod_pai, span_notice("MODsuit [active ? "shutting down" : "starting up"].")) // SKYRAT EDIT END - - if(do_after(wearer, activation_step_time, wearer, MOD_ACTIVATION_STEP_FLAGS)) + + if(do_after(wearer, activation_step_time, wearer, MOD_ACTIVATION_STEP_FLAGS, extra_checks = CALLBACK(src, .proc/has_wearer))) to_chat(wearer, span_notice("[boots] [active ? "relax their grip on your legs" : "seal around your feet"].")) playsound(src, 'sound/mecha/mechmove03.ogg', 25, TRUE, SHORT_RANGE_SOUND_EXTRARANGE) seal_part(boots, seal = !active) - if(do_after(wearer, activation_step_time, wearer, MOD_ACTIVATION_STEP_FLAGS)) + if(do_after(wearer, activation_step_time, wearer, MOD_ACTIVATION_STEP_FLAGS, extra_checks = CALLBACK(src, .proc/has_wearer))) to_chat(wearer, span_notice("[gauntlets] [active ? "become loose around your fingers" : "tighten around your fingers and wrists"].")) playsound(src, 'sound/mecha/mechmove03.ogg', 25, TRUE, SHORT_RANGE_SOUND_EXTRARANGE) seal_part(gauntlets, seal = !active) - if(do_after(wearer, activation_step_time, wearer, MOD_ACTIVATION_STEP_FLAGS)) + if(do_after(wearer, activation_step_time, wearer, MOD_ACTIVATION_STEP_FLAGS, extra_checks = CALLBACK(src, .proc/has_wearer))) to_chat(wearer, span_notice("[chestplate] [active ? "releases your chest" : "cinches tightly against your chest"].")) playsound(src, 'sound/mecha/mechmove03.ogg', 25, TRUE, SHORT_RANGE_SOUND_EXTRARANGE) - seal_part(chestplate,seal = !active) - if(do_after(wearer, activation_step_time, wearer, MOD_ACTIVATION_STEP_FLAGS)) + seal_part(chestplate, seal = !active) + if(do_after(wearer, activation_step_time, wearer, MOD_ACTIVATION_STEP_FLAGS, extra_checks = CALLBACK(src, .proc/has_wearer))) to_chat(wearer, span_notice("[helmet] hisses [active ? "open" : "closed"].")) playsound(src, 'sound/mecha/mechmove03.ogg', 25, TRUE, SHORT_RANGE_SOUND_EXTRARANGE) seal_part(helmet, seal = !active) - if(do_after(wearer, activation_step_time, wearer, MOD_ACTIVATION_STEP_FLAGS)) + if(do_after(wearer, activation_step_time, wearer, MOD_ACTIVATION_STEP_FLAGS, extra_checks = CALLBACK(src, .proc/has_wearer))) to_chat(wearer, span_notice("Systems [active ? "shut down. Parts unsealed. Goodbye" : "started up. Parts sealed. Welcome"], [wearer].")) // SKYRAT EDIT START - pAIs in MODsuits if(mod_pai) @@ -232,10 +232,6 @@ update_icon_state() wearer.update_inv_back() -/obj/item/mod/control/update_icon_state() - icon_state = "[skin]-control[active ? "-sealed" : ""]" - return ..() - /// Quickly deploys all the suit parts and if successful, seals them and turns on the suit. Intended mostly for outfits. /obj/item/mod/control/proc/quick_activation() var/seal = TRUE @@ -248,4 +244,7 @@ seal_part(part, seal = TRUE) finish_activation(on = TRUE) +/obj/item/mod/control/proc/has_wearer() + return wearer + #undef MOD_ACTIVATION_STEP_FLAGS diff --git a/code/modules/mod/mod_control.dm b/code/modules/mod/mod_control.dm index f66fa4bb1f9..287d4af0bd9 100644 --- a/code/modules/mod/mod_control.dm +++ b/code/modules/mod/mod_control.dm @@ -244,6 +244,23 @@ if(slot == ITEM_SLOT_BACK) return TRUE +/obj/item/mod/control/Moved(atom/old_loc, movement_dir, forced = FALSE, list/old_locs) + . = ..() + if(!wearer || old_loc != wearer || loc == wearer) + return + if(active || activating) + for(var/obj/item/mod/module/module as anything in modules) + if(!module.active) + continue + module.on_deactivation(display_message = FALSE) + for(var/obj/item/part as anything in mod_parts) + seal_part(part, seal = FALSE) + for(var/obj/item/part as anything in mod_parts) + conceal(null, part) + if(active) + finish_activation(on = FALSE) + unset_wearer() + /obj/item/mod/control/allow_attack_hand_drop(mob/user) if(user != wearer) return ..() @@ -432,11 +449,14 @@ continue . += module_icons +/obj/item/mod/control/update_icon_state() + icon_state = "[skin]-control[active ? "-sealed" : ""]" + return ..() + /obj/item/mod/control/proc/set_wearer(mob/user) wearer = user SEND_SIGNAL(src, COMSIG_MOD_WEARER_SET, wearer) RegisterSignal(wearer, COMSIG_ATOM_EXITED, .proc/on_exit) - RegisterSignal(src, COMSIG_ITEM_PRE_UNEQUIP, .proc/on_unequip) update_charge_alert() for(var/obj/item/mod/module/module as anything in modules) module.on_equip() @@ -445,18 +465,10 @@ for(var/obj/item/mod/module/module as anything in modules) module.on_unequip() UnregisterSignal(wearer, list(COMSIG_ATOM_EXITED, COMSIG_PROCESS_BORGCHARGER_OCCUPANT)) - UnregisterSignal(src, COMSIG_ITEM_PRE_UNEQUIP) wearer.clear_alert(ALERT_MODSUIT_CHARGE) SEND_SIGNAL(src, COMSIG_MOD_WEARER_UNSET, wearer) wearer = null -/obj/item/mod/control/proc/on_unequip() - SIGNAL_HANDLER - - for(var/obj/item/part as anything in mod_parts) - if(part.loc != src) - return COMPONENT_ITEM_BLOCK_UNEQUIP - /obj/item/mod/control/proc/update_flags() var/list/used_skin = theme.skins[skin] for(var/obj/item/clothing/part as anything in mod_parts)