Powercell and Charging tweaks (#796)

changes:

bugfix: "Newly protolathed/fabricated power cells now spawn with no charge."
rscdel: "Added entropy to all cell-charging operations."
tweak: "Most chargers are now faster. Cyborg charging stations are significantly slower."
bugfix: "Fixed newly spawned cells showing the incorrect charge state."
This commit is contained in:
NanakoAC
2016-09-04 19:43:40 +02:00
committed by skull132
parent 2c59299902
commit 3c693545a1
9 changed files with 79 additions and 16 deletions
+1
View File
@@ -263,6 +263,7 @@
//Create the desired item.
var/obj/item/I = new making.path(get_step(loc, get_dir(src,usr)))
I.Created()
if(multiplier > 1 && istype(I, /obj/item/stack))
var/obj/item/stack/S = I
S.amount = multiplier
+3 -2
View File
@@ -6,8 +6,9 @@
anchored = 1
use_power = 1
idle_power_usage = 5
active_power_usage = 40000 //40 kW. (this the power drawn when charging)
active_power_usage = 90000 //90 kW. (this the power drawn when charging)
power_channel = EQUIP
var/charging_efficiency = 0.92
var/obj/item/weapon/cell/charging = null
var/chargelevel = -1
@@ -105,7 +106,7 @@
return
if (charging && !charging.fully_charged())
charging.give(active_power_usage*CELLRATE)
charging.give(active_power_usage*CELLRATE*charging_efficiency)
update_use_power(2)
update_icon()
+9 -6
View File
@@ -7,7 +7,9 @@ obj/machinery/recharger
anchored = 1
use_power = 1
idle_power_usage = 4
active_power_usage = 15000 //15 kW
active_power_usage = 30000 //15 kW
var/charging_efficiency = 0.85
//Entropy. The charge put into the cell is multiplied by this
var/obj/item/charging = null
var/list/allowed_devices = list(/obj/item/weapon/gun/energy, /obj/item/weapon/melee/baton, /obj/item/device/laptop, /obj/item/weapon/cell)
var/icon_state_charged = "recharger2"
@@ -101,7 +103,7 @@ obj/machinery/recharger/process()
var/obj/item/weapon/gun/energy/E = charging
if(!E.power_supply.fully_charged())
icon_state = icon_state_charging
E.power_supply.give(active_power_usage*CELLRATE)
E.power_supply.give(active_power_usage*CELLRATE*charging_efficiency)
update_use_power(2)
else
icon_state = icon_state_charged
@@ -113,7 +115,7 @@ obj/machinery/recharger/process()
if(B.bcell)
if(!B.bcell.fully_charged())
icon_state = icon_state_charging
B.bcell.give(active_power_usage*CELLRATE)
B.bcell.give(active_power_usage*CELLRATE*charging_efficiency)
update_use_power(2)
else
icon_state = icon_state_charged
@@ -127,7 +129,7 @@ obj/machinery/recharger/process()
var/obj/item/device/laptop/L = charging
if(!L.stored_computer.battery.fully_charged())
icon_state = icon_state_charging
L.stored_computer.battery.give(active_power_usage*CELLRATE)
L.stored_computer.battery.give(active_power_usage*CELLRATE*charging_efficiency)
update_use_power(2)
else
icon_state = icon_state_charged
@@ -138,7 +140,7 @@ obj/machinery/recharger/process()
var/obj/item/weapon/cell/C = charging
if(!C.fully_charged())
icon_state = icon_state_charging
C.give(active_power_usage*CELLRATE)
C.give(active_power_usage*CELLRATE*charging_efficiency)
update_use_power(2)
else
icon_state = icon_state_charged
@@ -172,9 +174,10 @@ obj/machinery/recharger/wallcharger
name = "wall recharger"
icon = 'icons/obj/stationobjs.dmi'
icon_state = "wrecharger0"
active_power_usage = 25000 //25 kW , It's more specialized than the standalone recharger (guns and batons only) so make it more powerful
active_power_usage = 45000 //40 kW , It's more specialized than the standalone recharger (guns and batons only) so make it more powerful
allowed_devices = list(/obj/item/weapon/gun/energy, /obj/item/weapon/melee/baton)
icon_state_charged = "wrecharger2"
icon_state_charging = "wrecharger1"
icon_state_idle = "wrecharger0"
portable = 0
charging_efficiency = 0.8
+9 -8
View File
@@ -11,10 +11,10 @@
var/obj/item/weapon/cell/cell = null
var/icon_update_tick = 0 // Used to rebuild the overlay only once every 10 ticks
var/charging = 0
var/charging_power // W. Power rating used for charging the cyborg. 120 kW if un-upgraded
var/restore_power_active // W. Power drawn from APC when an occupant is charging. 40 kW if un-upgraded
var/restore_power_passive // W. Power drawn from APC when idle. 7 kW if un-upgraded
var/charging_efficiency = 0.85//Multiplier applied to all operations of giving power to cells, represents entropy. Efficiency increases with upgrades
var/charging_power // W. Power rating drawn from internal cell to recharge occupant's cell 60 kW unupgraded
var/restore_power_active // W. Power drawn from APC to recharge internal cell when an occupant is charging. 40 kW if un-upgraded
var/restore_power_passive // W. Power drawn from APC to recharge internal cell when idle. 7 kW if un-upgraded
var/weld_rate = 0 // How much brute damage is repaired per tick
var/wire_rate = 0 // How much burn damage is repaired per tick
@@ -62,7 +62,7 @@
// Calculating amount of power to draw
recharge_amount = (occupant ? restore_power_active : restore_power_passive) * CELLRATE
recharge_amount = cell.give(recharge_amount)
recharge_amount = cell.give(recharge_amount*charging_efficiency)
use_power(recharge_amount / CELLRATE)
if(icon_update_tick >= 10)
@@ -96,7 +96,7 @@
if(R.cell && !R.cell.fully_charged())
var/diff = min(R.cell.maxcharge - R.cell.charge, charging_power * CELLRATE) // Capped by charging_power / tick
var/charge_used = cell.use(diff)
R.cell.give(charge_used)
R.cell.give(charge_used*charging_efficiency)
//Lastly, attempt to repair the cyborg if enabled
if(weld_rate && R.getBruteLoss() && cell.checked_use(weld_power_use * weld_rate * CELLRATE))
@@ -150,8 +150,9 @@
man_rating += P.rating
cell = locate(/obj/item/weapon/cell) in component_parts
charging_power = 40000 + 40000 * cap_rating
restore_power_active = 10000 + 15000 * cap_rating
charging_efficiency = 0.85 + 0.015 * cap_rating
charging_power = 30000 + 12000 * cap_rating
restore_power_active = 10000 + 10000 * cap_rating
restore_power_passive = 5000 + 1000 * cap_rating
weld_rate = max(0, man_rating - 3)
wire_rate = max(0, man_rating - 5)
+1
View File
@@ -384,6 +384,7 @@
if(being_built)
src.being_built.Move(get_step(src,output_dir))
src.visible_message("\icon[src] <b>[src]</b> beeps, \"The following has been completed: [src.being_built] is built\".")
being_built.Created()
src.being_built = null
src.updateUsrDialog()
return 1
+10
View File
@@ -184,3 +184,13 @@
icon_species_tag = wearer.species.short_name
return 1
return 0
//This function should be called on an item when it is:
//Built, autolathed, protolathed, crafted or constructed. At runtime, by players or machines
//It should NOT be called on things that:
//spawn at roundstart, are adminspawned, arrive on shuttles, spawned from vendors, removed from fridges and containers, etc
//This is useful for setting special behaviour for built items that shouldn't apply to those spawned at roundstart
/obj/proc/Created()
return
+6
View File
@@ -5,11 +5,17 @@
/obj/item/weapon/cell/New()
..()
charge = maxcharge
update_icon()
/obj/item/weapon/cell/initialize()
..()
update_icon()
/obj/item/weapon/cell/Created()
//Newly built cells spawn with no charge to prevent power exploits
charge = 0
update_icon()
/obj/item/weapon/cell/drain_power(var/drain_check, var/surge, var/power = 0)
if(drain_check)
+1
View File
@@ -383,6 +383,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
linked_lathe.busy = 0
screen = 3.1
errored = 0
new_item.Created()
updateUsrDialog()
else if(href_list["imprint"]) //Causes the Circuit Imprinter to build something.