Skip to content

Commit

Permalink
better way of doing it
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSuckerberg committed Dec 17, 2024
1 parent b3cdcf0 commit cc2a39f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/robot/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
if(cell.charge <= 100)
uneq_all()
var/amt = clamp((lamp_enabled * lamp_intensity),1,cell.charge) //Lamp will use a max of 5 charge, depending on brightness of lamp. If lamp is off, borg systems consume 1 point of charge, or the rest of the cell if it's lower than that.
cell.use(amt) //Usage table: 1/tick if off/lowest setting, 4 = 4/tick, 6 = 8/tick, 8 = 12/tick, 10 = 16/tick
cell.use(amt, FALSE) //Usage table: 1/tick if off/lowest setting, 4 = 4/tick, 6 = 8/tick, 8 = 12/tick, 10 = 16/tick
else
uneq_all()
low_power_mode = TRUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

if(battery_module && battery_module.battery && battery_module.battery.charge)
var/obj/item/stock_parts/cell/cell = battery_module.battery
if(cell.use(amount * GLOB.CELLRATE))
if(cell.use(amount * GLOB.CELLRATE, FALSE))
return TRUE
else // Discharge the cell anyway.
cell.use(min(amount*GLOB.CELLRATE, cell.charge))
cell.use(min(amount*GLOB.CELLRATE, cell.charge), FALSE)
return FALSE
return FALSE

Expand Down
2 changes: 1 addition & 1 deletion code/modules/power/apc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
if(cell && !shorted)
// draw power from cell as before to power the area
var/cellused = min(cell.charge, GLOB.CELLRATE * lastused_total) // clamp deduction to a max, amount left in cell
cell.use(cellused)
cell.use(cellused, FALSE)

if(excess > lastused_total) // if power excess recharge the cell
// by the same amount just used
Expand Down
4 changes: 2 additions & 2 deletions code/modules/power/cell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@
return 100*charge/maxcharge

// use power from a cell
/obj/item/stock_parts/cell/use(amount)
/obj/item/stock_parts/cell/use(amount, log = TRUE)
if(rigged && amount > 0)
explode()
return 0
if(charge < amount)
return 0
charge = (charge - amount)
if(!istype(loc, /obj/machinery/power/apc))
if(log)
SSblackbox.record_feedback("tally", "cell_used", 1, type)
return 1

Expand Down
2 changes: 1 addition & 1 deletion code/modules/power/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/small/built, 28)
visible_message("<span class='warning'>[src] short-circuits from too powerful of a power cell!</span>")
burn_out()
return FALSE
cell.use(pwr)
cell.use(pwr, FALSE)
set_light(brightness * bulb_emergency_brightness_mul, max(bulb_emergency_pow_min, bulb_emergency_pow_mul * (cell.charge / cell.maxcharge)), bulb_emergency_colour)
return TRUE

Expand Down

0 comments on commit cc2a39f

Please sign in to comment.