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
🆑
fix: Borg emag module jank when no longer emagged
fix: Borg piercing hypospray fail message
/🆑

---------

Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
This commit is contained in:
thegrb93
2024-06-07 00:09:47 -07:00
committed by GitHub
co-authored by LemonInTheDark
parent e364cf5740
commit 8925d03775
3 changed files with 11 additions and 10 deletions
+3 -3
View File
@@ -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
@@ -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)
@@ -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)