mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 13:10:02 +01:00
Modular computers (PDAs) now shutdown when out of power (#96932)
## About The Pull Request This PR refactors modular computers (PDAs) so that they actually respect their power cells and shut down when they hit 0% charge. Previously, PDA power mechanics were essentially non-functional. While the flashlight would drain more power, it would never actually turn off when the battery died. Additionally, there was broken code intended to make the messenger program immune to power requirements. That immunity code was so buggy that it made all the power mechanics get ignored. To fix this, I gutted the broken immunity code. The marginal power draw of the messenger program is so tiny that it doesn't need exceptions. Now, when a modular computer runs out of power, everything, including the flashlight, shuts off completely. ## Why It's Good For The Game Right now, the power mechanics for modular computers are effectively LARP that does nothing. Players now have a tangible reason to conserve power and seek out upgraded power cells if they plan on heavily utilizing their PDA's features. It's balanced so that you'd have to be quite careless with the flashlight to completely drain a standard battery. It adds consequence without being overly punishing to the average crewmember. ## Changelog 🆑 balance: Modular computers (PDAs) now shutdown when out of power fix: PDA flashlights now turn off when out of power sound: Added a terminal off switch sound to PDAs when power runs out /🆑
This commit is contained in:
@@ -796,6 +796,7 @@
|
||||
if(looping_sound)
|
||||
soundloop.stop()
|
||||
if(physical && loud)
|
||||
playsound(src, 'sound/machines/terminal/terminal_off.ogg', 25, FALSE)
|
||||
physical.visible_message(span_notice("\The [src] shuts down."))
|
||||
enabled = FALSE
|
||||
update_appearance()
|
||||
|
||||
@@ -6,20 +6,14 @@
|
||||
/obj/item/modular_computer/proc/use_energy(amount = 0, check_programs = TRUE)
|
||||
if(check_power_override(amount))
|
||||
return TRUE
|
||||
|
||||
if(!internal_cell)
|
||||
return FALSE
|
||||
if(!amount || internal_cell.use(amount))
|
||||
return TRUE
|
||||
if(!check_programs)
|
||||
return FALSE
|
||||
internal_cell.use(min(amount, internal_cell.charge)) //drain it anyways.
|
||||
if(active_program?.program_flags & PROGRAM_RUNS_WITHOUT_POWER)
|
||||
return TRUE
|
||||
|
||||
INVOKE_ASYNC(src, PROC_REF(close_all_programs))
|
||||
for(var/datum/computer_file/program/programs as anything in stored_files)
|
||||
if((programs.program_flags & PROGRAM_RUNS_WITHOUT_POWER) && open_program(program = programs))
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/obj/item/modular_computer/proc/give_power(amount)
|
||||
@@ -37,7 +31,7 @@
|
||||
set_light_on(FALSE)
|
||||
for(var/datum/computer_file/program/programs as anything in idle_threads)
|
||||
programs.event_powerfailure()
|
||||
shutdown_computer(loud = FALSE)
|
||||
shutdown_computer()
|
||||
|
||||
///Takes the charge necessary from the Computer, shutting it off if it's unable to provide it.
|
||||
///Charge depends on whether the PC is on, and what programs are running/idle on it.
|
||||
@@ -59,9 +53,8 @@
|
||||
return FALSE
|
||||
|
||||
///Returns TRUE if the PC should not be using any power, FALSE otherwise.
|
||||
///Checks to see if the current app allows to be ran without power, if so we'll run with it.
|
||||
/obj/item/modular_computer/proc/check_power_override(amount)
|
||||
return !amount && !internal_cell?.charge && (active_program?.program_flags & PROGRAM_RUNS_WITHOUT_POWER)
|
||||
return !amount && !internal_cell?.charge
|
||||
|
||||
//Integrated (Silicon) tablets don't drain power, because the tablet is required to state laws, so it being disabled WILL cause problems.
|
||||
/obj/item/modular_computer/pda/silicon/check_power_override()
|
||||
|
||||
Reference in New Issue
Block a user