From 8925d03775b9bf9c9ad8fa6e9dfd0439a45c519e Mon Sep 17 00:00:00 2001 From: thegrb93 Date: Fri, 7 Jun 2024 03:09:47 -0400 Subject: [PATCH] Fix borg emag modules stuck in inventory/screen after losing emag status (#83734) ## About The Pull Request Checks that held modules exist in new module list after rebuilding modules before putting them back in held modules. Fixes emag modules stuck in inventory/screen after losing emag status Also fixes jank fail to install piercing hypospray upgrade ## Why It's Good For The Game Fixes buges ## Changelog :cl: fix: Borg emag module jank when no longer emagged fix: Borg piercing hypospray fail message /:cl: --------- Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> --- code/_onclick/hud/robot.dm | 6 +++--- code/game/objects/items/robot/robot_upgrades.dm | 2 +- .../modules/mob/living/silicon/robot/robot_model.dm | 13 +++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/code/_onclick/hud/robot.dm b/code/_onclick/hud/robot.dm index 88d5dada281..e2e53444369 100644 --- a/code/_onclick/hud/robot.dm +++ b/code/_onclick/hud/robot.dm @@ -197,13 +197,13 @@ if(!R.client) return + //Module is not currently active + screenmob.client.screen -= R.model.get_inactive_modules() + if(!R.shown_robot_modules || !screenmob.hud_used.hud_shown) //Modules display is hidden screenmob.client.screen -= module_store_icon //"store" icon - for(var/atom/A in R.model.get_inactive_modules()) - //Module is not currently active - screenmob.client.screen -= A R.shown_robot_modules = 0 screenmob.client.screen -= R.robot_modules_background return diff --git a/code/game/objects/items/robot/robot_upgrades.dm b/code/game/objects/items/robot/robot_upgrades.dm index 959894b3163..3c42e65e29c 100644 --- a/code/game/objects/items/robot/robot_upgrades.dm +++ b/code/game/objects/items/robot/robot_upgrades.dm @@ -400,7 +400,7 @@ found_hypo = TRUE if(!found_hypo) - to_chat(user, span_warning("This unit is already equipped with a piercing hypospray upgrade!")) //check to see if we already have this module + to_chat(user, span_warning("There are no installed hypospray modules to upgrade with piercing!")) //check to see if any hyposprays were upgraded return FALSE /obj/item/borg/upgrade/piercing_hypospray/deactivate(mob/living/silicon/robot/borg, mob/living/user = usr) diff --git a/code/modules/mob/living/silicon/robot/robot_model.dm b/code/modules/mob/living/silicon/robot/robot_model.dm index 5ba061233d4..a46389e11b2 100644 --- a/code/modules/mob/living/silicon/robot/robot_model.dm +++ b/code/modules/mob/living/silicon/robot/robot_model.dm @@ -82,6 +82,8 @@ for(var/module in get_usable_modules()) if(!(module in cyborg.held_items)) . += module + if(!cyborg.emagged) + . += emag_modules /obj/item/robot_model/proc/add_module(obj/item/added_module, nonstandard, requires_rebuild) if(isstack(added_module)) @@ -121,16 +123,15 @@ var/active_module = cyborg.module_active cyborg.drop_all_held_items() modules = list() - for(var/obj/item/module in basic_modules) + for(var/obj/item/module as anything in basic_modules) add_module(module, FALSE, FALSE) if(cyborg.emagged) - for(var/obj/item/module in emag_modules) + for(var/obj/item/module as anything in emag_modules) add_module(module, FALSE, FALSE) - for(var/obj/item/module in added_modules) + for(var/obj/item/module as anything in added_modules) add_module(module, FALSE, FALSE) - for(var/module in held_modules) - if(module) - cyborg.equip_module_to_slot(module, held_modules.Find(module)) + for(var/obj/item/module as anything in held_modules & modules) + cyborg.equip_module_to_slot(module, held_modules.Find(module)) if(active_module) cyborg.select_module(held_modules.Find(active_module)) if(cyborg.hud_used)