Merge pull request #9258 from mwerezak/charge

Updates instances of power cell usage
This commit is contained in:
Chinsky
2015-05-21 03:24:20 +03:00
9 changed files with 36 additions and 21 deletions
+1 -1
View File
@@ -706,7 +706,7 @@
take_hit((100/severity_class), "electrical pulse", 1)
/obj/item/weapon/rig/proc/shock(mob/user)
if (electrocute_mob(user, cell, src))
if (electrocute_mob(user, cell, src)) //electrocute_mob() handles removing charge from the cell, no need to do that here.
spark_system.start()
if(user.stunned)
return 1
@@ -3,9 +3,7 @@
if(!istype(user,/mob/living)) return 0
if(electrified != 0)
if(cell && cell.charge >= 100)
cell.use(100)
if(shock(user, 100))
if(shock(user)) //Handles removing charge from the cell, as well. No need to do that here.
return
// Pass repair items on to the chestpiece.
@@ -193,8 +191,6 @@
/obj/item/weapon/rig/attack_hand(var/mob/user)
if(electrified != 0)
if(cell && cell.charge >= 100)
cell.use(100)
if(shock(user, 100))
if(shock(user)) //Handles removing charge from the cell, as well. No need to do that here.
return
..()
@@ -1233,8 +1233,9 @@ var/list/robot_verbs_default = list(
if(cell.charge == 0)
return 0
if(cell.use(amount * CELLRATE * CYBORG_POWER_USAGE_MULTIPLIER))
used_power_this_tick += amount * CYBORG_POWER_USAGE_MULTIPLIER
var/power_use = amount * CYBORG_POWER_USAGE_MULTIPLIER
if(cell.checked_use(CELLRATE * power_use))
used_power_this_tick += power_use
return 1
return 0
+20 -7
View File
@@ -9,7 +9,7 @@
spawn(5)
updateicon()
/obj/item/weapon/cell/drain_power(var/drain_check, var/surge, var/amount = 0)
/obj/item/weapon/cell/drain_power(var/drain_check, var/surge, var/power = 0)
if(drain_check)
return 1
@@ -17,9 +17,9 @@
if(charge <= 0)
return 0
var/cell_amt = min((amount * CELLRATE), charge)
use(cell_amt)
return cell_amt / CELLRATE
var/cell_amt = power * CELLRATE
return use(cell_amt) / CELLRATE
/obj/item/weapon/cell/proc/updateicon()
overlays.Cut()
@@ -37,13 +37,26 @@
/obj/item/weapon/cell/proc/fully_charged()
return (charge == maxcharge)
// use power from a cell
// checks if the power cell is able to provide the specified amount of charge
/obj/item/weapon/cell/proc/check_charge(var/amount)
return (charge >= amount)
// use power from a cell, returns the amount actually used
/obj/item/weapon/cell/proc/use(var/amount)
if(rigged && amount > 0)
explode()
return 0
charge = max(0, charge - amount)
return charge
var/used = min(charge, amount)
charge -= used
return used
// Checks if the specified amount can be provided. If it can, it removes the amount
// from the cell and returns 1. Otherwise does nothing and returns 0.
/obj/item/weapon/cell/proc/checked_use(var/amount)
if(!check_charge(amount))
return 0
use(amount)
return 1
// recharge the cell
/obj/item/weapon/cell/proc/give(var/amount)
+1 -1
View File
@@ -374,7 +374,7 @@
if (source_area)
source_area.use_power(drained_energy/CELLRATE)
else if (istype(power_source,/datum/powernet))
var/drained_power = drained_energy/CELLRATE //convert from "joules" to "watts"
var/drained_power = drained_energy/CELLRATE
drained_power = PN.draw_power(drained_power)
else if (istype(power_source, /obj/item/weapon/cell))
cell.use(drained_energy)
+1 -1
View File
@@ -57,7 +57,7 @@
/obj/item/weapon/gun/energy/consume_next_projectile()
if(!power_supply) return null
if(!ispath(projectile_type)) return null
if(!power_supply.use(charge_cost)) return null
if(!power_supply.checked_use(charge_cost)) return null
return new projectile_type(src)
/obj/item/weapon/gun/energy/proc/get_external_power_supply()