Merge pull request #617 from Sharkmare/patch-72

Restructure of power trans code for drones.
This commit is contained in:
Vollybally
2019-04-09 13:25:44 -04:00
committed by GitHub
@@ -436,13 +436,18 @@ var/list/mob_hat_cache = list()
set name = "Transmit Power"
if(!power)
power=250
if(power<=0 || power>=cell.maxcharge || power>=cell.charge) return //Safeties to not kill ourselves, also safeties to not use this to drain.
actpower(power)
return
if(power<=0 || power>=cell.maxcharge || power>=cell.charge) return //Safeties to not kill ourselves, also safeties to not use this to drain.
actpower(power)
return
/mob/living/silicon/robot/drone/proc/actpower(var/power)
for(var/obj/item/weapon/cell/remotecell in range(1, src)) //assuming 1 = 1 tile next to us, if this works will lower to 0
src << "<b>Trying to transfer power to a cell.</b>."
if(power>=cell.charge) return //rechecking our initial safety so if we mass charge we dont die.
var/newcharge = remotecell.charge + power //What the battery is at after charge
if(newcharge<=remotecell.maxcharge) //Making sure we arent wasting power
remotecell.give(power) //give is a proc native to cells that increases charge and updates the iconstate if needed
cell.give(-power)//TO BE TESTED, no idea if negative give works, once i've tested this i'll add this as a verb-shark
else return