[MIRROR] Recharger fixes & QoL (#11899)

Co-authored-by: Cameron Lennox <killer65311@gmail.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-11-05 16:58:53 -07:00
committed by GitHub
parent e79c1647e6
commit 82b6654bd6

View File

@@ -1,3 +1,39 @@
GLOBAL_LIST_INIT(allowed_recharger_devices, list(
/obj/item/gun/energy,
/obj/item/gun/magnetic,
/obj/item/melee/baton,
/obj/item/modular_computer,
/obj/item/computer_hardware/battery_module,
/obj/item/cell,
/obj/item/suit_cooling_unit/emergency,
/obj/item/flashlight,
/obj/item/electronic_assembly,
/obj/item/weldingtool/electric,
/obj/item/ammo_magazine/smart,
/obj/item/flash,
/obj/item/defib_kit,
/obj/item/ammo_casing/microbattery,
/obj/item/paicard,
/obj/item/personal_shield_generator,
/obj/item/gun/projectile/cell_loaded,
/obj/item/ammo_magazine/cell_mag
))
GLOBAL_LIST_INIT(allowed_wallcharger_devices, list(
/obj/item/gun/energy,
/obj/item/gun/magnetic,
/obj/item/melee/baton,
/obj/item/flashlight,
/obj/item/cell/device
))
GLOBAL_LIST_INIT(recharger_battery_exempt, list(
/obj/item/ammo_casing/microbattery,
/obj/item/paicard,
/obj/item/gun/projectile/cell_loaded,
/obj/item/ammo_magazine/cell_mag
))
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31
/obj/machinery/recharger
name = "recharger"
@@ -10,11 +46,13 @@
active_power_usage = 40000 //40 kW
var/efficiency = 40000 //will provide the modified power rate when upgraded
var/obj/item/charging = null
var/list/allowed_devices = list(/obj/item/gun/energy, /obj/item/melee/baton, /obj/item/modular_computer, /obj/item/computer_hardware/battery_module, /obj/item/cell, /obj/item/suit_cooling_unit/emergency, /obj/item/flashlight, /obj/item/electronic_assembly, /obj/item/weldingtool/electric, /obj/item/ammo_magazine/smart, /obj/item/flash, /obj/item/defib_kit, /obj/item/ammo_casing/microbattery, /obj/item/paicard, /obj/item/ammo_magazine/cell_mag, /obj/item/gun/projectile/cell_loaded, /obj/item/personal_shield_generator) // CHOMPedit: medigun stuff
var/icon_state_charged = "recharger2"
var/icon_state_charging = "recharger1"
var/icon_state_idle = "recharger0" //also when unpowered
var/portable = 1
///If we can be wrenched and moved around or not.
var/portable = TRUE
///If we can charge everything or use a smaller list.
var/small = FALSE
circuit = /obj/item/circuitboard/recharger
/obj/machinery/recharger/Initialize(mapload)
@@ -31,7 +69,7 @@
if(C) // Sometimes we get things without cells in it.
. += "Current charge: [C.charge] / [C.maxcharge]"
//CHOMPEdit Start - Let borgs clickdrag things into chargers
///Checks valid items to see if there's any reasons we wouldn't allow them to be put in.
/obj/machinery/recharger/proc/do_allowed_checks(obj/item/G, mob/user)
. = FALSE
if(charging)
@@ -49,7 +87,7 @@
if(istype(G, /obj/item/modular_computer))
var/obj/item/modular_computer/C = G
if(!C.battery_module)
to_chat(user, span_notice("\The [C] does not have a battery installed."))
to_chat(user, span_notice("\The [C] does not have a battery installed. "))
return
if(istype(G, /obj/item/flash))
var/obj/item/flash/F = G
@@ -61,20 +99,9 @@
if(EW.use_external_power)
to_chat(user, span_notice("\The [EW] has no recharge port."))
return
else if(istype(G, /obj/item/ammo_magazine/cell_mag)) // CHOMPedit start
var/obj/item/ammo_magazine/cell_mag/maggy = G
if(maggy.stored_ammo.len < 1)
to_chat(user, span_notice("\The [G] does not have any cells installed."))
return
else if(istype(G, /obj/item/gun/projectile/cell_loaded))
var/obj/item/gun/projectile/cell_loaded/gunny = G
if(gunny.ammo_magazine)
var/obj/item/ammo_magazine/cell_mag/maggy = gunny.ammo_magazine
if(maggy.stored_ammo.len < 1)
to_chat(user, span_notice("\The [G] does not have any cell in its magazine installed."))
return
else
to_chat(user, span_notice("\The [G] does not have a magazine installed..")) // CHOMPedit end
if(!G.get_cell() && !is_type_in_list(G, GLOB.recharger_battery_exempt))
to_chat(user, "\The [G] does not have a battery installed.")
return
if(istype(G, /obj/item/paicard))
var/obj/item/paicard/ourcard = G
if(ourcard.panel_open)
@@ -90,77 +117,26 @@
return TRUE
/obj/machinery/recharger/MouseDrop_T(obj/item/G as obj, mob/user as mob)
var/allowed = 0
for (var/allowed_type in allowed_devices)
if(istype(G, allowed_type)) allowed = 1
if(allowed)
if((!small && is_type_in_list(G, GLOB.allowed_recharger_devices)) || (small && is_type_in_list(G, GLOB.allowed_wallcharger_devices)))
if(!do_allowed_checks(G, user))
return
G.loc = src
G.forceMove(src)
charging = G
update_icon()
user.visible_message("[user] inserts [charging] into [src].", "You insert [charging] into [src].")
//CHOMPEdit End
/obj/machinery/recharger/attackby(obj/item/G as obj, mob/user as mob)
var/allowed = 0
for (var/allowed_type in allowed_devices)
if(istype(G, allowed_type)) allowed = 1
if(allowed)
//CHOMPEdit Start - move checks into their own proc
if((!small && is_type_in_list(G, GLOB.allowed_recharger_devices)) || (small && is_type_in_list(G, GLOB.allowed_wallcharger_devices)))
if(!do_allowed_checks(G, user))
return
//CHOMPEdit End
// Checks to make sure he's not in space doing it, and that the area got proper power.
if(!powered())
to_chat(user, span_warning("\The [src] blinks red as you try to insert [G]!"))
return
if(istype(G, /obj/item/gun/energy))
var/obj/item/gun/energy/E = G
if(E.self_recharge)
to_chat(user, span_notice("\The [E] has no recharge port."))
return
if(istype(G, /obj/item/modular_computer))
var/obj/item/modular_computer/C = G
if(!C.battery_module)
to_chat(user, span_notice("\The [C] does not have a battery installed. "))
return
if(istype(G, /obj/item/flash))
var/obj/item/flash/F = G
if(F.use_external_power)
to_chat(user, span_notice("\The [F] has no recharge port."))
return
if(istype(G, /obj/item/weldingtool/electric))
var/obj/item/weldingtool/electric/EW = G
if(EW.use_external_power)
to_chat(user, span_notice("\The [EW] has no recharge port."))
return
if(!G.get_cell() && !istype(G, /obj/item/ammo_casing/microbattery) && !istype(G, /obj/item/paicard)) //VOREStation Edit: NSFW charging
to_chat(user, "\The [G] does not have a battery installed.")
return
if(istype(G, /obj/item/paicard))
var/obj/item/paicard/ourcard = G
if(ourcard.panel_open)
to_chat(user, span_warning("\The [ourcard] won't fit in the recharger with its panel open."))
return
if(ourcard.pai)
if(ourcard.pai.stat == CONSCIOUS)
to_chat(user, span_warning("\The [ourcard] boops... it doesn't need to be recharged!"))
return
else
to_chat(user, span_warning("\The [ourcard] doesn't have a personality!"))
return
if(HAS_TRAIT(user, TRAIT_UNLUCKY) && prob(10))
user.visible_message("[user] inserts [charging] into [src] backwards!", "You insert [charging] into [src] backwards!")
user.drop_item()
G.loc = get_turf(src)
G.forceMove(get_turf(src))
return
user.drop_item()
G.loc = src
G.forceMove(src)
charging = G
update_icon()
user.visible_message("[user] inserts [charging] into [src].", "You insert [charging] into [src].")
@@ -196,7 +172,7 @@
if(charging)
user.visible_message("[user] removes [charging] from [src].", "You remove [charging] from [src].")
charging.update_icon()
charging.loc = src.loc
charging.forceMove(src.loc)
charging = null
update_icon()
@@ -209,26 +185,22 @@
if(!charging)
update_use_power(USE_POWER_IDLE)
icon_state = icon_state_idle
//VOREStation Edit Start - pAI revival!
return
//PAI Cards
else if(istype(charging, /obj/item/paicard))
var/obj/item/paicard/pcard = charging
if(pcard.is_damage_critical())
pcard.forceMove(get_turf(src))
charging = null
//pcard.damage_random_component()//CHOMPEDIT: Punishing PAI for charging too soon seems kinda annoying
update_icon()
else if(pcard.pai.bruteloss)
pcard.pai.adjustBruteLoss(-5)
else if(pcard.pai.fireloss)
pcard.pai.adjustFireLoss(-5)
else
charging = null
update_icon()
src.visible_message(span_notice("\The [src] ejects the [pcard]!"))
pcard.forceMove(get_turf(src))
pcard.pai.full_restore()
//VOREStation Edit End
charge_pai(charging)
return
//Charging cell-loaded guns.
else if(istype(charging, /obj/item/gun/projectile/cell_loaded))
charge_cell_gun(charging)
return
//Charging cell magazines
else if(istype(charging, /obj/item/ammo_magazine/cell_mag))
charge_cell_magazine(charging)
return
else
//Everything Else
var/obj/item/cell/C = charging.get_cell()
if(istype(C))
if(!C.fully_charged())
@@ -239,39 +211,77 @@
icon_state = icon_state_charged
update_use_power(USE_POWER_IDLE)
//VOREStation Add - NSFW Batteries
//NSFW Batteries
else if(istype(charging, /obj/item/ammo_casing/microbattery))
var/obj/item/ammo_casing/microbattery/batt = charging
if(batt.shots_left >= initial(batt.shots_left))
batt.shots_left = initial(batt.shots_left)
icon_state = icon_state_charged
update_use_power(USE_POWER_IDLE)
else
icon_state = icon_state_charging
batt.shots_left++
update_use_power(USE_POWER_ACTIVE)
charge_microbattery(charging)
return
//VOREStation Add End
else if(istype(charging, /obj/item/ammo_magazine/cell_mag))
charge_mag(charging)
///Charges PAIs.
/obj/machinery/recharger/proc/charge_pai(obj/item/paicard/pcard)
if(pcard.is_damage_critical())
pcard.forceMove(get_turf(src))
charging = null
update_icon()
return
if(pcard.pai.bruteloss || pcard.pai.fireloss)
pcard.pai.adjustBruteLoss(-5)
pcard.pai.adjustFireLoss(-5)
else
charging = null
update_icon()
visible_message(span_notice("\The [src] ejects the [pcard]!"))
pcard.forceMove(get_turf(src))
pcard.pai.full_restore()
else if(istype(charging, /obj/item/gun/projectile/cell_loaded))
var/obj/item/gun/projectile/cell_loaded/gunny = charging
charge_mag(gunny.ammo_magazine)
///Charges microbatteries. One projectile at a time.
/obj/machinery/recharger/proc/charge_microbattery(obj/item/ammo_casing/microbattery/batt)
if(batt.shots_left >= initial(batt.shots_left))
batt.shots_left = initial(batt.shots_left)
icon_state = icon_state_charged
update_use_power(USE_POWER_IDLE)
else
icon_state = icon_state_charging
batt.shots_left++
update_use_power(USE_POWER_ACTIVE)
/obj/machinery/recharger/proc/charge_mag(var/obj/item/ammo_magazine/cell_mag/maggy)
var/tally = maggy.stored_ammo.len
for(var/obj/item/ammo_casing/microbattery/batt in maggy)
if(batt.shots_left < initial(batt.shots_left))
///Charges cell magazines, one projectile at a time.
/obj/machinery/recharger/proc/charge_cell_magazine(obj/item/ammo_magazine/cell_mag/magazine)
if(LAZYLEN(magazine.stored_ammo))
for(var/obj/item/ammo_casing/microbattery/shot_to_charge in magazine)
if(shot_to_charge.shots_left >= initial(shot_to_charge.shots_left))
continue
shot_to_charge.shots_left++
icon_state = icon_state_charging
batt.shots_left++
update_use_power(USE_POWER_ACTIVE)
else
tally -= 1
if(tally == 0)
icon_state = icon_state_charged
update_use_power(USE_POWER_IDLE)
return
icon_state = icon_state_charged
update_use_power(USE_POWER_IDLE)
///Charges cell guns. First charges the currently chambered battery, then the batteries in the magazine.
/obj/machinery/recharger/proc/charge_cell_gun(obj/item/gun/projectile/cell_loaded/cellgun)
var/obj/item/ammo_magazine/magazine = cellgun.ammo_magazine //CAN BE NULL.
var/obj/item/ammo_casing/microbattery/batt = cellgun.chambered //CAN BE NULL.
//First, we charge the currently chambered battery if there is one.
if(batt && !(batt.shots_left >= initial(batt.shots_left)))
icon_state = icon_state_charging
batt.shots_left++
update_use_power(USE_POWER_ACTIVE)
return
//Second, we charge the batteries in the magazine.
else if(magazine && LAZYLEN(magazine.stored_ammo))
for(var/obj/item/ammo_casing/microbattery/shot_to_charge in magazine)
if(shot_to_charge.shots_left >= initial(shot_to_charge.shots_left))
continue
shot_to_charge.shots_left++
icon_state = icon_state_charging
update_use_power(USE_POWER_ACTIVE)
return //only heal one at a time.
//If the chambered battery AND the magazine are all full, we are done.
icon_state = icon_state_charged
update_use_power(USE_POWER_IDLE)
return
/obj/machinery/recharger/emp_act(severity)
if(stat & (NOPOWER|BROKEN) || !anchored)
@@ -306,9 +316,9 @@
layer = ABOVE_TURF_LAYER
active_power_usage = 60000 //60 kW , It's more specialized than the standalone recharger (guns, batons, and flashlights only) so make it more powerful
efficiency = 60000
allowed_devices = list(/obj/item/gun/energy, /obj/item/gun/magnetic, /obj/item/melee/baton, /obj/item/flashlight, /obj/item/cell/device, /obj/item/ammo_casing/microbattery, /obj/item/ammo_magazine/cell_mag, /obj/item/gun/projectile/cell_loaded)
small = TRUE
icon_state_charged = "wrecharger2"
icon_state_charging = "wrecharger1"
icon_state_idle = "wrecharger0"
portable = 0
portable = FALSE
circuit = /obj/item/circuitboard/recharger/wrecharger