mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Optimalisations
This commit is contained in:
@@ -411,8 +411,14 @@
|
||||
drain_complete(H)
|
||||
return
|
||||
|
||||
// Attempts to drain up to 40kW
|
||||
var/target_drained = interfaced_with.drain_power(0,0,40000)
|
||||
if(holder.cell.fully_charged())
|
||||
H << "<span class = 'warning'>Your power sink flashes an amber light; your rig cell is full.</span>"
|
||||
drain_complete(H)
|
||||
return
|
||||
|
||||
// Attempts to drain up to 40kW, determines this value from remaining cell capacity to ensure we don't drain too much..
|
||||
var/to_drain = min(40000, ((holder.cell.maxcharge - holder.cell.charge) / CELLRATE))
|
||||
var/target_drained = interfaced_with.drain_power(0,0,to_drain)
|
||||
if(target_drained <= 0)
|
||||
H << "<span class = 'danger'>Your power sink flashes a red light; there is no power left in [interfaced_with].</span>"
|
||||
drain_complete(H)
|
||||
@@ -421,19 +427,16 @@
|
||||
holder.cell.give(target_drained * CELLRATE)
|
||||
total_power_drained += target_drained
|
||||
|
||||
if(holder.cell.fully_charged())
|
||||
H << "<span class = 'warning'>Your power sink flashes an amber light; your rig cell is full.</span>"
|
||||
drain_complete(H)
|
||||
return
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
/obj/item/rig_module/power_sink/proc/drain_complete(var/mob/living/M)
|
||||
|
||||
if(!interfaced_with)
|
||||
if(M) M << "<font color='blue'><b>Total power drained:</b> [total_power_drained]J.</font>"
|
||||
if(M) M << "<font color='blue'><b>Total power drained:</b> [round(total_power_drained/1000)]kJ.</font>"
|
||||
else
|
||||
if(M) M << "<font color='blue'><b>Total power drained from [interfaced_with]:</b> [total_power_drained]J.</font>"
|
||||
if(M) M << "<font color='blue'><b>Total power drained from [interfaced_with]:</b> [round(total_power_drained/1000)]kJ.</font>"
|
||||
interfaced_with.drain_power(0,1,0) // Damage the victim.
|
||||
|
||||
interfaced_with = null
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
if(drain_check)
|
||||
return 1
|
||||
|
||||
if(charge <= 0)
|
||||
return 0
|
||||
|
||||
var/cell_amt = min((amount * CELLRATE), charge)
|
||||
use(cell_amt)
|
||||
return cell_amt / CELLRATE
|
||||
|
||||
Reference in New Issue
Block a user