Files
Aurora.3/code/game/objects/items/recharger_backpack.dm
T
BatrachophrenoandGitHub 387cee9243 Object Examine Text Overhaul (#20923)
Extends and reworks how various extended information text (desc_info,
desc_build, desc_upgrades) are handled to make object interactions and
mechanics A.) much more clearly documented in-game and B.) much easier
to support from the back-end.

Almost certainly a candidate for test merge.

Assembly/Disassembly instructions are noticeably sporadic, largely due
to our current lack of a unified framework. That's a future thing I'd
like to attack so that it can be handled programmatically, but for now I
only targeted the biggest culprits as I came across them.

---------

Signed-off-by: Batrachophreno <Batrochophreno@gmail.com>
2025-07-21 15:35:14 +00:00

133 lines
4.1 KiB
Plaintext

/obj/item/recharger_backpack
name = "weapon recharger backpack"
desc = "Developed by Hephaestus Industries, the HI-92 Recharge Platform is designed for long-term field recharge of energy weapons. Due to legal concerns, the design is rarely seen outside of military hands."
icon = 'icons/obj/recharger_backpack.dmi'
icon_state = "recharger_backpack"
item_state = "recharger_backpack"
contained_sprite = TRUE
w_class = WEIGHT_CLASS_BULKY
slot_flags = SLOT_BACK
///Power cell used to recharge the gun. Empty by default.
var/obj/item/cell/powersupply
///The gun we're currently recharging. Connection handled in connect() and /obj/item/gun/energy/connect()
var/obj/item/gun/energy/connected
/obj/item/recharger_backpack/feedback_hints(mob/user, distance, is_adjacent)
. += ..()
if(powersupply)
. += SPAN_NOTICE("The backpack display shows that the installed power cell is at <b>[round(powersupply.percent())]%</b>.")
/obj/item/recharger_backpack/Initialize()
. = ..()
//To update the icon based on the power cell charge we spawn with
update_icon()
/obj/item/recharger_backpack/Destroy()
if(connected)
connected.disconnect()
QDEL_NULL(powersupply)
. = ..()
/obj/item/recharger_backpack/attackby(obj/item/attacking_item, mob/user)
if(istype(attacking_item, /obj/item/cell) && !powersupply)
to_chat(usr, SPAN_NOTICE("You slot \the [attacking_item] into \the [src]'s power socket."))
playsound(get_turf(src), 'sound/machines/click.ogg', 30, 0)
user.drop_from_inventory(attacking_item, src)
powersupply = attacking_item
update_icon()
else if(istype(attacking_item, /obj/item/screwdriver) && powersupply)
to_chat(user, SPAN_NOTICE("You remove \the [powersupply] from \the [src]'s power socket"))
powersupply.forceMove(get_turf(src))
user.put_in_hands(powersupply)
powersupply = null
update_icon()
else if(istype(attacking_item, /obj/item/gun/energy))
var/obj/item/gun/energy/gun_attempting_to_connect = attacking_item
gun_attempting_to_connect.connect(src)
else
. = ..()
/obj/item/recharger_backpack/AltClick(mob/user)
if(!connected)
to_chat(usr, SPAN_WARNING("\The [src] has no energy weapon connected!"))
return
connected.disconnect()
/obj/item/recharger_backpack/update_icon()
. = ..()
if(!powersupply)
icon_state = "recharger_backpack"
item_state = "recharger_backpack"
set_light(0)
else
var/current_charge = powersupply.percent()
switch(current_charge)
if(70 to INFINITY)
icon_state = "recharger_backpack_full"
item_state = "recharger_backpack_full"
set_light(2, 0.75, LIGHT_COLOR_GREEN)
if(35 to 70)
icon_state = "recharger_backpack_med"
item_state = "recharger_backpack_med"
set_light(2, 0.75, LIGHT_COLOR_FIRE)
if(1 to 35)
icon_state = "recharger_backpack_low"
item_state = "recharger_backpack_low"
set_light(2, 0.75, LIGHT_COLOR_RED)
if(-INFINITY to 1)
icon_state = "recharger_backpack"
item_state = "recharger_backpack"
set_light(0)
/obj/item/recharger_backpack/get_cell()
if(powersupply)
return powersupply
return ..()
/**
* Connects a gun to the backpack
*
* * newgun - An `/obj/item/gun/energy` to connect to the backpack
*
* Returns `TRUE` if the connection was successful, `FALSE` otherwise
*/
/obj/item/recharger_backpack/proc/connect(obj/item/gun/energy/newgun)
if(connected)
to_chat(usr, SPAN_WARNING("\The [src] already has an energy weapon connected!"))
return FALSE
connected = newgun
RegisterSignal(connected, COMSIG_QDELETING, PROC_REF(handle_weapon_qdel))
return TRUE
/**
* Disconnects a gun from the backpack
*
* * disconnecting_gun - An `/obj/item/gun/energy` to disconnect from the backpack
*/
/obj/item/recharger_backpack/proc/disconnect(obj/item/gun/energy/disconnecting_gun)
UnregisterSignal(connected, COMSIG_QDELETING)
connected = null
///Handles the weapon connected to the backpack being deleted
/obj/item/recharger_backpack/proc/handle_weapon_qdel()
SIGNAL_HANDLER
connected = null
/*###############
SUBTYPES
###############*/
/obj/item/recharger_backpack/high/Initialize()
. = ..()
powersupply = new /obj/item/cell/high(src)
update_icon()