Merge pull request #12761 from GhostActual/energen_batteries

EnerGen Brand Batteries
This commit is contained in:
Casey
2022-04-17 17:16:22 -04:00
committed by GitHub
7 changed files with 54 additions and 98 deletions

View File

@@ -1,85 +1,41 @@
#define CHARGER_EMPTY 0
#define CHARGER_WORKING 1
#define CHARGER_DONE 2
/obj/machinery/cell_charger
name = "heavy-duty cell charger"
desc = "A much more powerful version of the standard recharger that is specially designed for charging power cells."
icon = 'icons/obj/power.dmi'
icon_state = "recharger"
anchored = TRUE
icon_state = "ccharger0"
anchored = 1
use_power = USE_POWER_IDLE
power_channel = EQUIP
idle_power_usage = 5
active_power_usage = 60000 //60 kW. (this the power drawn when charging)
circuit = /obj/item/weapon/circuitboard/cell_charger
var/efficiency = 60000 //will provide the modified power rate when upgraded
power_channel = EQUIP
var/obj/item/weapon/cell/charging = null
var/charging_vis_flags = NONE
var/charge_state = CHARGER_EMPTY
var/chargelevel = -1
circuit = /obj/item/weapon/circuitboard/cell_charger
/obj/machinery/cell_charger/Initialize()
. = ..()
default_apply_parts()
/obj/machinery/cell_charger/update_icon()
var/new_state
icon_state = "ccharger[charging ? 1 : 0]"
if(!anchored)
new_state = "[initial(icon_state)]4"
return
icon_state = "ccharger2"
if(stat & (BROKEN|NOPOWER))
new_state = "[initial(icon_state)]3"
return
if(charging && !(stat & (BROKEN|NOPOWER)))
switch(charge_state)
if(CHARGER_EMPTY)
new_state = "[initial(icon_state)]0"
if(CHARGER_WORKING)
new_state = "[initial(icon_state)]1"
if(CHARGER_DONE)
new_state = "[initial(icon_state)]2"
if(icon_state != new_state)
icon_state = new_state
var/newlevel = round(charging.percent() * 4.0 / 99)
//to_world("nl: [newlevel]")
/obj/machinery/cell_charger/proc/insert_item(obj/item/W, mob/user)
if(!W || !user)
return
if(chargelevel != newlevel)
user.drop_item()
charging = W
charging.loc = src
charging_vis_flags = charging.vis_flags
charging.vis_flags = VIS_INHERIT_ID
vis_contents += charging
charge_state = CHARGER_WORKING
update_icon()
cut_overlays()
add_overlay("ccharger-o[newlevel]")
if((stat & (BROKEN|NOPOWER)) || !anchored)
update_use_power(USE_POWER_OFF)
chargelevel = newlevel
else
update_use_power(USE_POWER_ACTIVE)
/obj/machinery/cell_charger/proc/remove_item(mob/user)
if(!charging || !user)
return
vis_contents -= charging
charging.vis_flags = charging_vis_flags
user.put_in_hands(charging)
charging = null
charge_state = CHARGER_EMPTY
if((stat & (BROKEN|NOPOWER)) || !anchored)
update_use_power(USE_POWER_OFF)
else
update_use_power(USE_POWER_IDLE)
update_icon()
cut_overlays()
/obj/machinery/cell_charger/examine(mob/user)
. = ..()
@@ -107,8 +63,11 @@
to_chat(user, "<span class='warning'>\The [src] blinks red as you try to insert [W]!</span>")
return
insert_item(W, user)
user.drop_item()
W.loc = src
charging = W
user.visible_message("[user] inserts [charging] into [src].", "You insert [charging] into [src].")
chargelevel = -1
update_icon()
else if(W.is_wrench())
if(charging)
@@ -129,15 +88,22 @@
add_fingerprint(user)
if(charging)
remove_item(user)
user.put_in_hands(charging)
charging.update_icon()
user.visible_message("[user] removes [charging] from [src].", "You remove [charging] from [src].")
charging = null
chargelevel = -1
update_icon()
/obj/machinery/cell_charger/attack_ai(mob/user)
if(istype(user, /mob/living/silicon/robot) && Adjacent(user)) // Borgs can remove the cell if they are near enough
if(charging)
remove_item(user)
user.visible_message("[user] disconnects [charging] from [src].", "You disconnect [charging] from [src].")
user.visible_message("[user] removes [charging] from [src].", "You remove [charging] from [src].")
charging.loc = src.loc
charging.update_icon()
charging = null
update_icon()
/obj/machinery/cell_charger/emp_act(severity)
if(stat & (BROKEN|NOPOWER))
@@ -146,9 +112,6 @@
charging.emp_act(severity)
..(severity)
/obj/machinery/cell_charger/power_change()
. = ..()
update_icon()
/obj/machinery/cell_charger/process()
//to_world("ccpt [charging] [stat]")
@@ -156,22 +119,16 @@
update_use_power(USE_POWER_OFF)
return
if(charging)
if(!charging.fully_charged())
charge_state = CHARGER_WORKING
charging.give(efficiency*CELLRATE)
update_use_power(USE_POWER_ACTIVE)
else
charge_state = CHARGER_DONE
update_use_power(USE_POWER_IDLE)
if(charging && !charging.fully_charged())
charging.give(efficiency*CELLRATE)
update_use_power(USE_POWER_ACTIVE)
update_icon()
else
update_use_power(USE_POWER_IDLE)
/obj/machinery/cell_charger/RefreshParts()
var/E = 0
for(var/obj/item/weapon/stock_parts/capacitor/C in component_parts)
E += C.rating
efficiency = active_power_usage * (1+ (E - 1)*0.5)
#undef CHARGER_EMPTY
#undef CHARGER_WORKING
#undef CHARGER_DONE
efficiency = active_power_usage * (1+ (E - 1)*0.5)

View File

@@ -6,7 +6,7 @@
name = "power cell"
desc = "A rechargable electrochemical power cell."
icon = 'icons/obj/power_cells.dmi'
icon_state = "b_st"
icon_state = "standard"
item_state = "cell"
origin_tech = list(TECH_POWER = 1)
force = 5.0

View File

@@ -2,7 +2,7 @@
/obj/item/weapon/cell/device
name = "device power cell"
desc = "A small power cell designed to power handheld devices."
icon_state = "m_st"
icon_state = "device_cell"
item_state = "egg6"
w_class = ITEMSIZE_SMALL
force = 0
@@ -16,7 +16,7 @@
/obj/item/weapon/cell/device/weapon
name = "weapon power cell"
desc = "A small power cell designed to power handheld weaponry."
icon_state = "m_sup"
icon_state = "weapon_cell"
maxcharge = 2400
charge_amount = 20
@@ -31,7 +31,7 @@
/obj/item/weapon/cell/device/weapon/recharge
name = "self-charging weapon power cell"
desc = "A small power cell designed to power handheld weaponry. This one recharges itself."
icon_state = "meb_m_nu"
icon_state = "sc_weapon_cell"
self_recharge = TRUE
charge_amount = 120
charge_delay = 75

View File

@@ -3,7 +3,7 @@
name = "modified power cell"
desc = "A modified power cell sitting in a highly conductive chassis."
origin_tech = list(TECH_POWER = 2)
icon_state = "exs_m"
icon_state = "modded"
maxcharge = 10000
matter = list(MAT_STEEL = 1000, MAT_GLASS = 80, MAT_SILVER = 100)
self_recharge = TRUE

View File

@@ -2,7 +2,7 @@
name = "\improper rechargable AA battery"
desc = "You can't top the plasma top." //TOTALLY TRADEMARK INFRINGEMENT
origin_tech = list(TECH_POWER = 0)
icon_state = "s_st"
icon_state = "crap"
maxcharge = 500
matter = list(MAT_STEEL = 700, MAT_GLASS = 40)
@@ -13,7 +13,7 @@
/obj/item/weapon/cell/secborg
name = "security borg rechargable D battery"
origin_tech = list(TECH_POWER = 0)
icon_state = "meb_s_st"
icon_state = "secborg"
maxcharge = 600 //600 max charge / 100 charge per shot = six shots
matter = list(MAT_STEEL = 700, MAT_GLASS = 40)
@@ -25,14 +25,14 @@
/obj/item/weapon/cell/apc
name = "heavy-duty power cell"
origin_tech = list(TECH_POWER = 1)
icon_state = "meb_b_st"
icon_state = "apc"
maxcharge = 5000
matter = list(MAT_STEEL = 700, MAT_GLASS = 50)
/obj/item/weapon/cell/high
name = "high-capacity power cell"
origin_tech = list(TECH_POWER = 2)
icon_state = "b_hi"
icon_state = "high"
maxcharge = 10000
matter = list(MAT_STEEL = 700, MAT_GLASS = 60)
@@ -44,7 +44,7 @@
/obj/item/weapon/cell/super
name = "super-capacity power cell"
origin_tech = list(TECH_POWER = 5)
icon_state = "b_sup"
icon_state = "super"
maxcharge = 20000
matter = list(MAT_STEEL = 700, MAT_GLASS = 70)
@@ -56,7 +56,7 @@
/obj/item/weapon/cell/hyper
name = "hyper-capacity power cell"
origin_tech = list(TECH_POWER = 6)
icon_state = "b_hy"
icon_state = "hyper"
maxcharge = 30000
matter = list(MAT_STEEL = 700, MAT_GLASS = 80)
@@ -67,13 +67,13 @@
/obj/item/weapon/cell/mech
name = "mecha power cell"
icon_state = "exs_l"
icon_state = "mech"
charge = 15000
maxcharge = 15000
/obj/item/weapon/cell/infinite
name = "infinite-capacity power cell!"
icon_state = "infinite_b"
icon_state = "infinite"
origin_tech = null
maxcharge = 30000 //determines how badly mobs get shocked
matter = list(MAT_STEEL = 700, MAT_GLASS = 80)
@@ -88,8 +88,7 @@
name = "potato battery"
desc = "A rechargable starch based power cell."
origin_tech = list(TECH_POWER = 1)
icon = 'icons/obj/power.dmi' //'icons/obj/harvest.dmi'
icon_state = "potato_cell" //"potato_battery"
icon_state = "potato"
charge = 100
maxcharge = 300
minor_fault = 1
@@ -112,7 +111,7 @@
name = "backup battery"
desc = "A small one-time-use chemical battery for synthetic crew when they are low on power in emergency situations."
icon = 'icons/obj/power_cells.dmi'
icon_state = "exs_s"
icon_state = "backup"
w_class = ITEMSIZE_SMALL
var/amount = 100
var/used = FALSE
@@ -150,7 +149,7 @@
desc = "A tiny power cell with a very low power capacity. Used in light fixtures to power them in the event of an outage."
maxcharge = 120 //Emergency lights use 0.2 W per tick, meaning ~10 minutes of emergency power from a cell
matter = list(MAT_GLASS = 20)
icon_state = "meb_s_sup"
icon_state = "em_light"
w_class = ITEMSIZE_TINY
/obj/item/weapon/cell/emergency_light/Initialize()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB