From 6cc07c5bc3e26d098f1912c5b6e56d403f3a2851 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Fri, 29 Nov 2019 02:59:54 +0100 Subject: [PATCH] Ports the energy gun empty state overlay fix. --- code/modules/projectiles/guns/energy.dm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm index 2cccc57d9e..8a65a29826 100644 --- a/code/modules/projectiles/guns/energy.dm +++ b/code/modules/projectiles/guns/energy.dm @@ -144,22 +144,24 @@ ..() if(!automatic_charge_overlays) return - var/ratio = CEILING(CLAMP(cell.charge / cell.maxcharge, 0, 1) * charge_sections, 1) + var/ratio = can_shoot() ? CEILING(CLAMP(cell.charge / cell.maxcharge, 0, 1) * charge_sections, 1) : 0 + // Sets the ratio to 0 if the gun doesn't have enough charge to fire, or if it's power cell is removed. + // TG issues #5361 & #47908 if(ratio == old_ratio && !force_update) return old_ratio = ratio cut_overlays() - var/obj/item/ammo_casing/energy/shot = ammo_type[select] var/iconState = "[icon_state]_charge" var/itemState = null if(!initial(item_state)) itemState = icon_state if (modifystate) + var/obj/item/ammo_casing/energy/shot = ammo_type[select] add_overlay("[icon_state]_[shot.select_name]") iconState += "_[shot.select_name]" if(itemState) itemState += "[shot.select_name]" - if(cell.charge < shot.e_cost) + if(ratio == 0) add_overlay("[icon_state]_empty") else if(!shaded_charge)