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
@@ -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)