diff --git a/code/modules/clothing/spacesuits/rig/modules/computer.dm b/code/modules/clothing/spacesuits/rig/modules/computer.dm
index 9ec7d7e5d1..1b2befa59a 100644
--- a/code/modules/clothing/spacesuits/rig/modules/computer.dm
+++ b/code/modules/clothing/spacesuits/rig/modules/computer.dm
@@ -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 << "Your power sink flashes an amber light; your rig cell is full."
+ 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 << "Your power sink flashes a red light; there is no power left in [interfaced_with]."
drain_complete(H)
@@ -421,19 +427,16 @@
holder.cell.give(target_drained * CELLRATE)
total_power_drained += target_drained
- if(holder.cell.fully_charged())
- H << "Your power sink flashes an amber light; your rig cell is full."
- 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 << "Total power drained: [total_power_drained]J."
+ if(M) M << "Total power drained: [round(total_power_drained/1000)]kJ."
else
- if(M) M << "Total power drained from [interfaced_with]: [total_power_drained]J."
+ if(M) M << "Total power drained from [interfaced_with]: [round(total_power_drained/1000)]kJ."
interfaced_with.drain_power(0,1,0) // Damage the victim.
interfaced_with = null
diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm
index e6c7b0eec9..36ab1047a3 100644
--- a/code/modules/power/cell.dm
+++ b/code/modules/power/cell.dm
@@ -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