From 3c693545a1af3257bda10ebb655f261f485dae77 Mon Sep 17 00:00:00 2001 From: NanakoAC Date: Sun, 4 Sep 2016 18:43:40 +0100 Subject: [PATCH] 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." --- code/game/machinery/autolathe.dm | 1 + code/game/machinery/cell_charger.dm | 5 ++-- code/game/machinery/recharger.dm | 15 ++++++---- code/game/machinery/rechargestation.dm | 17 +++++------ code/game/mecha/mech_fabricator.dm | 1 + code/game/objects/objs.dm | 10 +++++++ code/modules/power/cell.dm | 6 ++++ code/modules/research/rdconsole.dm | 1 + html/changelogs/Nanako-Powercells.yml | 39 ++++++++++++++++++++++++++ 9 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 html/changelogs/Nanako-Powercells.yml diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index c613124cede..55478fa6ef0 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -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 diff --git a/code/game/machinery/cell_charger.dm b/code/game/machinery/cell_charger.dm index c3f617057c8..c29e6657231 100644 --- a/code/game/machinery/cell_charger.dm +++ b/code/game/machinery/cell_charger.dm @@ -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() diff --git a/code/game/machinery/recharger.dm b/code/game/machinery/recharger.dm index c91e9e1bd4c..7112da87376 100644 --- a/code/game/machinery/recharger.dm +++ b/code/game/machinery/recharger.dm @@ -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 diff --git a/code/game/machinery/rechargestation.dm b/code/game/machinery/rechargestation.dm index 1ed307ee112..098808fc401 100644 --- a/code/game/machinery/rechargestation.dm +++ b/code/game/machinery/rechargestation.dm @@ -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) diff --git a/code/game/mecha/mech_fabricator.dm b/code/game/mecha/mech_fabricator.dm index cec76e16dc3..6b42ef30733 100644 --- a/code/game/mecha/mech_fabricator.dm +++ b/code/game/mecha/mech_fabricator.dm @@ -384,6 +384,7 @@ if(being_built) src.being_built.Move(get_step(src,output_dir)) src.visible_message("\icon[src] [src] beeps, \"The following has been completed: [src.being_built] is built\".") + being_built.Created() src.being_built = null src.updateUsrDialog() return 1 diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm index fa3786fd1f4..76729420e0e 100644 --- a/code/game/objects/objs.dm +++ b/code/game/objects/objs.dm @@ -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 \ No newline at end of file diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index 13634ce1701..5eb5709f75d 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -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) diff --git a/code/modules/research/rdconsole.dm b/code/modules/research/rdconsole.dm index 37814e58556..1243e8516a1 100644 --- a/code/modules/research/rdconsole.dm +++ b/code/modules/research/rdconsole.dm @@ -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. diff --git a/html/changelogs/Nanako-Powercells.yml b/html/changelogs/Nanako-Powercells.yml new file mode 100644 index 00000000000..54b6591adc9 --- /dev/null +++ b/html/changelogs/Nanako-Powercells.yml @@ -0,0 +1,39 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +################################# + +# Your name. +author: Nanako + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +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." \ No newline at end of file