diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index f7e53bde3ab..3db6ae018f8 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -142,11 +142,11 @@ new_item.amount = R.res_amount*multiplier //new_item.add_to_stacks(usr) src.amount-=R.req_amount*multiplier - if (src.amount<=0) + if (src.amount < 1) // Just in case a stack's amount ends up fractional somehow var/oldsrc = src src = null //dont kill proc after del() usr.unEquip(oldsrc, 1) - del(oldsrc) + del(oldsrc) // Not qdel, because qdel'd stacks act strange for cyborgs if (istype(O,/obj/item)) usr.put_in_hands(O) O.add_fingerprint(usr) @@ -165,10 +165,11 @@ if (amount < used) return 0 amount -= used - if (amount <= 0) + if (amount < 1) // Just in case a stack's amount ends up fractional somehow if(usr) usr.unEquip(src, 1) - qdel(src) + spawn() + del(src) // Not qdel, because qdel'd stacks act strange for cyborgs update_icon() return 1 diff --git a/code/modules/mob/living/silicon/robot/inventory.dm b/code/modules/mob/living/silicon/robot/inventory.dm index eadef1b98c1..47f515401dc 100644 --- a/code/modules/mob/living/silicon/robot/inventory.dm +++ b/code/modules/mob/living/silicon/robot/inventory.dm @@ -220,3 +220,8 @@ while(slot_start != slot_num) //If we wrap around without finding any free slots, just give up. return + +/mob/living/silicon/robot/unEquip(obj/item/I) + if(I == module_active) + deselect_module(get_selected_module()) + return ..() diff --git a/code/modules/mob/living/silicon/robot/robot_modules.dm b/code/modules/mob/living/silicon/robot/robot_modules.dm index 774e90e55d9..4dd8b65610e 100644 --- a/code/modules/mob/living/silicon/robot/robot_modules.dm +++ b/code/modules/mob/living/silicon/robot/robot_modules.dm @@ -37,6 +37,7 @@ if(!stacktypes || !stacktypes.len) return + var/stack_respawned = 0 for(var/T in stacktypes) var/O = locate(T) in src.modules var/obj/item/stack/S = O @@ -46,9 +47,12 @@ S = new T(src) src.modules += S S.amount = 1 + stack_respawned = 1 if(S && S.amount < stacktypes[T]) S.amount++ + if(stack_respawned && istype(R) && R.hud_used) + R.hud_used.update_robot_modules_display() /obj/item/weapon/robot_module/proc/rebuild()//Rebuilds the list so it's possible to add/remove items from the module var/list/temp_list = modules