PDA update (Messenger works while dead, Microwave works, etc). (#80069) [REMIRROR] (#25829)

* PDA update (Messenger works while dead, Microwave works, etc). (#80069)

This is an update that touches many more things all at once (compared to
my other PRs) meant to make PDAs in general feel more consistent and not
take away from one of the experiences we want to encourage: interaction
between players.

1. Replaced all checks of a 'pda' with a 'modular pc'. This means
technically (though not done in-game currently) other modpcs can hold an
uplink, and microwaves can charge laptops.
2. Speaking of microwave, they now don't break and require
deconstruction if the cell is removed mid-charge.
3. When a Mod PC is out of power, it will now allow the Messenger to
work (which now also doesn't consume any additional power), if the app
exists on the PC. Here's a video demonstration

https://github.com/tgstation/tgstation/assets/53777086/7ae12f81-a271-49b8-95fa-2ba54d2e2d1f

4. Flashlights can't be turned on while the cell is dead
5. I replaced a bunch of program vars with ``program_flags`` and renamed
``usage_flags`` to ``can_run_on_flags``.
6. Added a debug modPC that has every app installed by default. Mafia
had some issues in the past that were unknown because Mafia wasn't
preinstalled with any tablet so was never in create & destroy nor in any
other unit test. This was just an easy solution I had, but PDAs should
get more in-depth unit tests in the future for running apps n stuff- I
just wanted to make sure no other apps were broken/harddeling.

Currently when a PDA dies, its only use is to reply to PDA messages sent
to you, since you can still reply to them. Instead of just fixing it and
telling players to cope, I thought it would be nice to allow PDA
Messenger to still work, as it is a vital app.
You can call it some emergency power mode or whatever, I don't really
mind the reason behind why it is this way.

When I made cells used more on PDAs, my main goal was to encourage
upgrading your PDA and/or limiting how many apps you use at once, I did
not want this to hit on players who use it as a form of interaction.
This is the best of both worlds, I think.

The rest of the changes is just for modularity, if some downstream wants
to add tablets, phone computers, or whatever the hell else, they can
still get just as far as PDAs should be able to get to, hopefully.

🆑
add: PDAs with a dead power cell are now limited to using their
Messenger app.
fix: Microwaves now stop charging PDAs if the cell was removed
mid-charge.
fix: Microwaves can now charge laptops.
fix: PDA Flashlights can't be turned on while the PDA is dead.
fix: You can now hold a laptop up to a camera (if it has a notekeeper
app installed) like PDAs already could.
/🆑

---------

Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com>

* ok

---------

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com>
This commit is contained in:
Gandalf
2023-12-24 23:20:11 +00:00
committed by GitHub
parent 761f910d2c
commit 9361376345
56 changed files with 179 additions and 180 deletions
@@ -4,6 +4,12 @@
/// File name. FILE NAME MUST BE UNIQUE IF YOU WANT THE PROGRAM TO BE DOWNLOADABLE FROM NTNET!
filename = "UnknownProgram"
/// Program-specific bitflags that tell the app what it runs on.
/// (PROGRAM_ALL | PROGRAM_CONSOLE | PROGRAM_LAPTOP | PROGRAM_PDA)
var/can_run_on_flags = PROGRAM_ALL
/// Program-specific bitflags that tells the ModPC what the app is able to do special.
/// (PROGRAM_REQUIRES_NTNET|PROGRAM_ON_NTNET_STORE|PROGRAM_ON_SYNDINET_STORE|PROGRAM_UNIQUE_COPY|PROGRAM_HEADER|PROGRAM_RUNS_WITHOUT_POWER)
var/program_flags = PROGRAM_ON_NTNET_STORE
///How much power running this program costs.
var/power_cell_use = PROGRAM_BASIC_CELL_USE
///List of required accesses to *run* the program. Any match will do.
@@ -16,23 +22,14 @@
/// Short description of this program's function.
var/extended_desc = "N/A"
///What category this program can be found in within NTNetDownloader.
///This is required if PROGRAM_ON_NTNET_STORE or PROGRAM_ON_SYNDINET_STORE is on.
var/downloader_category = PROGRAM_CATEGORY_DEVICE
///The overlay to add ontop of the ModPC running the app while it's open.
///This is taken from the same file as the ModPC, so you can use usage_flags to prevent
///This is taken from the same file as the ModPC, so you can use can_run_on_flags to prevent
///the program from being used on devices that don't have sprites for it.
var/program_open_overlay = null
///Boolean on whether the program will appear at the top on PDA menus, or in the app list with everything else.
var/header_program = FALSE
/// Set to 1 for program to require nonstop NTNet connection to run. If NTNet connection is lost program crashes.
var/requires_ntnet = FALSE
/// NTNet status, updated every tick by computer running this program. Don't use this for checks if NTNet works, computers do that. Use this for calculations, etc.
var/ntnet_status = 1
/// Bitflags (PROGRAM_CONSOLE, PROGRAM_LAPTOP, PROGRAM_PDA combination) or PROGRAM_ALL
var/usage_flags = PROGRAM_ALL
/// Whether the program can be downloaded from NTNet. Set to FALSE to disable.
var/available_on_ntnet = TRUE
/// Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to TRUE to enable.
var/available_on_syndinet = FALSE
/// Name of the tgui interface. If this is not defined, this will not be available in NTNet.
var/tgui_id
/// Example: "something.gif" - a header image that will be rendered in computer's UI when this program is running at background. Images must also be inserted into /datum/asset/simple/headers.
@@ -47,17 +44,15 @@
var/alert_pending = FALSE
/// How well this program will help combat detomatix viruses.
var/detomatix_resistance = NONE
///Boolean on whether or not only one copy of the app can exist. This means it deletes itself when cloned elsewhere.
var/unique_copy = FALSE
/datum/computer_file/program/clone()
var/datum/computer_file/program/temp = ..()
temp.run_access = run_access
temp.filedesc = filedesc
temp.program_open_overlay = program_open_overlay
temp.requires_ntnet = requires_ntnet
temp.usage_flags = usage_flags
if(unique_copy)
temp.program_flags = program_flags
temp.can_run_on_flags = can_run_on_flags
if(program_flags & PROGRAM_UNIQUE_COPY)
if(computer)
computer.remove_file(src)
if(disk_host)
@@ -104,7 +99,7 @@
///Makes sure a program can run on this hardware (for apps limited to tablets/computers/laptops)
/datum/computer_file/program/proc/is_supported_by_hardware(hardware_flag = NONE, loud = FALSE, mob/user)
if(!(hardware_flag & usage_flags))
if(!(hardware_flag & can_run_on_flags))
if(loud && computer && user)
to_chat(user, span_danger("\The [computer] flashes a \"Hardware Error - Incompatible software\" warning."))
return FALSE
@@ -126,13 +121,13 @@
* access can contain a list of access numbers to check against. If access is not empty, it will be used istead of checking any inserted ID.
*/
/datum/computer_file/program/proc/can_run(mob/user, loud = FALSE, access_to_check, downloading = FALSE, list/access)
if(issilicon(user) && !ispAI(user))
return TRUE
if(user)
if(issilicon(user) && !ispAI(user))
return TRUE
if(isAdminGhostAI(user))
return TRUE
if(isAdminGhostAI(user))
return TRUE
if(computer && (computer.obj_flags & EMAGGED) && (available_on_syndinet || !downloading)) //emagged can run anything on syndinet, and can bypass execution locks, but not download.
if(computer && (computer.obj_flags & EMAGGED) && (program_flags & PROGRAM_ON_SYNDINET_STORE || !downloading)) //emagged can run anything on syndinet, and can bypass execution locks, but not download.
return TRUE
if(!access_to_check)
@@ -149,7 +144,7 @@
accesscard = computer.computer_id_slot?.GetID()
if(!accesscard)
if(loud)
if(loud && user)
to_chat(user, span_danger("\The [computer] flashes an \"RFID Error - Unable to scan ID\" warning."))
return FALSE
access = accesscard.GetAccess()
@@ -158,7 +153,7 @@
if(singular_access in access) //For loop checks every individual access entry in the access list. If the user's ID has access to any entry, then we're good.
return TRUE
if(loud)
if(loud && user)
to_chat(user, span_danger("\The [computer] flashes an \"Access Denied\" warning."))
return FALSE
@@ -173,7 +168,7 @@
/datum/computer_file/program/proc/on_start(mob/living/user)
SHOULD_CALL_PARENT(TRUE)
if(can_run(user, loud = TRUE))
if(requires_ntnet)
if(program_flags & PROGRAM_REQUIRES_NTNET)
var/obj/item/card/id/ID = computer.computer_id_slot?.GetID()
generate_network_log("Connection opened -- Program ID:[filename] User:[ID?"[ID.registered_name]":"None"]")
return TRUE
@@ -193,11 +188,11 @@
if(src == computer.active_program)
computer.active_program = null
if(computer.enabled)
computer.update_tablet_open_uis(usr)
computer.update_tablet_open_uis(user)
if(src in computer.idle_threads)
computer.idle_threads.Remove(src)
if(requires_ntnet)
if(program_flags & PROGRAM_REQUIRES_NTNET)
var/obj/item/card/id/ID = computer.computer_id_slot?.GetID()
generate_network_log("Connection closed -- Program ID: [filename] User:[ID ? "[ID.registered_name]" : "None"]")
@@ -207,7 +202,7 @@
///Sends the running program to the background/idle threads. Header programs can't be minimized and will kill instead.
/datum/computer_file/program/proc/background_program()
SHOULD_CALL_PARENT(TRUE)
if(header_program)
if(program_flags & PROGRAM_HEADER)
return kill_program()
computer.idle_threads.Add(src)