diff --git a/code/game/objects/items/defib.dm b/code/game/objects/items/defib.dm index 4df3accb67..a154b8a638 100644 --- a/code/game/objects/items/defib.dm +++ b/code/game/objects/items/defib.dm @@ -19,6 +19,8 @@ var/on = FALSE //if the paddles are equipped (1) or on the defib (0) var/safety = TRUE //if you can zap people with the defibs on harm mode var/powered = FALSE //if there's a cell in the defib with enough power for a revive, blocks paddles from reviving otherwise + /// If the cell can be removed via screwdriver + var/cell_removable = TRUE var/obj/item/shockpaddles/paddles var/obj/item/stock_parts/cell/cell var/combat = FALSE //if true, revive through hardsuits, allow for combat shocking, and tint paddles syndicate colors @@ -29,6 +31,16 @@ var/timedeath = 10 var/disarm_shock_time = 10 var/always_emagged = FALSE + /// The icon state for the paddle overlay, not applied if null + var/paddle_state = "defibunit-paddles" + /// The icon state for the powered on overlay, not applied if null + var/powered_state = "defibunit-powered" + /// The icon state for the charge bar overlay, not applied if null + var/charge_state = "defibunit-charge" + /// The icon state for the missing cell overlay, not applied if null + var/nocell_state = "defibunit-nocell" + /// The icon state for the emagged overlay, not applied if null + var/emagged_state = "defibunit-emagged" /obj/item/defibrillator/get_cell() return cell @@ -56,18 +68,19 @@ /obj/item/defibrillator/update_overlays() . = ..() - if(!on) - . += "[initial(icon_state)]-paddles" - if(powered) - . += "[initial(icon_state)]-powered" - if(!QDELETED(cell)) + + if(!on && paddle_state) + . += paddle_state + if(powered && powered_state) + . += powered_state + if(!QDELETED(cell) && charge_state) var/ratio = cell.charge / cell.maxcharge ratio = CEILING(ratio*4, 1) * 25 - add_overlay("[initial(icon_state)]-charge[ratio]") - if(!cell) - . += "[initial(icon_state)]-nocell" - if(!safety) - . += "[initial(icon_state)]-emagged" + . += "[charge_state][ratio]" + if(!cell && nocell_state) + . += "[nocell_state]" + if(!safety && emagged_state) + . += emagged_state /obj/item/defibrillator/CheckParts(list/parts_list) ..() @@ -103,6 +116,18 @@ var/atom/movable/screen/inventory/hand/H = over_object M.putItemFromInventoryInHandIfPossible(src, H.held_index) +/obj/item/defibrillator/screwdriver_act(mob/living/user, obj/item/tool) + if(!cell || !cell_removable) + return FALSE + + cell.update_appearance() + cell.forceMove(get_turf(src)) + balloon_alert(user, "removed [cell]") + cell = null + tool.play_tool_sound(src, 50) + update_power() + return TRUE + /obj/item/defibrillator/attackby(obj/item/W, mob/user, params) if(W == paddles) toggle_paddles() @@ -120,13 +145,6 @@ to_chat(user, "You install a cell in [src].") update_power() - else if(W.tool_behaviour == TOOL_SCREWDRIVER) - if(cell) - cell.update_icon() - cell.forceMove(get_turf(src)) - cell = null - to_chat(user, "You remove the cell from [src].") - update_power() else return ..() @@ -236,6 +254,11 @@ item_state = "defibcompact" w_class = WEIGHT_CLASS_NORMAL slot_flags = ITEM_SLOT_BELT + paddle_state = "defibcompact-paddles" + powered_state = "defibcompact-powered" + charge_state = "defibcompact-charge" + nocell_state = "defibcompact-nocell" + emagged_state = "defibcompact-emagged" /obj/item/defibrillator/compact/item_action_slot_check(slot, mob/user, datum/action/A) if(slot == user.getBeltSlot()) @@ -254,6 +277,13 @@ always_emagged = TRUE disarm_shock_time = 0 cell = /obj/item/stock_parts/cell/infinite + paddles = /obj/item/shockpaddles/syndicate + paddle_state = "defibcombat-paddles" + powered_state = null + emagged_state = null + +/obj/item/defibrillator/compact/combat/loaded + cell_removable = FALSE // Don't let people just have an infinite power cell /obj/item/defibrillator/compact/combat/loaded/attackby(obj/item/W, mob/user, params) if(W == paddles)