Files
Bubberstation/code/modules/modular_computers/file_system/programs/airestorer.dm
Gandalf 9361376345 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>
2023-12-24 23:20:11 +00:00

135 lines
4.2 KiB
Plaintext

/datum/computer_file/program/ai_restorer
filename = "ai_restore"
filedesc = "AI Manager & Restorer"
downloader_category = PROGRAM_CATEGORY_SCIENCE
program_open_overlay = "generic"
extended_desc = "Firmware Restoration Kit, capable of reconstructing damaged AI systems. Requires direct AI connection via intellicard slot."
size = 12
can_run_on_flags = PROGRAM_CONSOLE | PROGRAM_LAPTOP
download_access = list(ACCESS_RD)
tgui_id = "NtosAiRestorer"
program_icon = "laptop-code"
/// The AI stored in the program
var/obj/item/aicard/stored_card
/// Variable dictating if we are in the process of restoring the AI in the inserted intellicard
var/restoring = FALSE
/datum/computer_file/program/ai_restorer/on_examine(obj/item/modular_computer/source, mob/user)
var/list/examine_text = list()
if(!stored_card)
examine_text += "It has a slot installed for an intelliCard."
return examine_text
if(computer.Adjacent(user))
examine_text += "It has a slot installed for an intelliCard which contains: [stored_card.name]"
else
examine_text += "It has a slot installed for an intelliCard, which appears to be occupied."
examine_text += span_info("Alt-click to eject the intelliCard.")
return examine_text
/datum/computer_file/program/ai_restorer/kill_program(mob/user)
try_eject(forced = TRUE)
return ..()
/datum/computer_file/program/ai_restorer/process_tick(seconds_per_tick)
. = ..()
if(!restoring) //Put the check here so we don't check for an ai all the time
return
var/mob/living/silicon/ai/A = stored_card.AI
if(stored_card.flush)
restoring = FALSE
return
A.adjustOxyLoss(-5, FALSE)
A.adjustFireLoss(-5, FALSE)
A.adjustBruteLoss(-5, FALSE)
// Please don't forget to update health, otherwise the below if statements will probably always fail.
A.updatehealth()
if(A.health >= 0 && A.stat == DEAD)
A.revive()
stored_card.update_appearance()
// Finished restoring
if(A.health >= 100)
restoring = FALSE
return TRUE
/datum/computer_file/program/ai_restorer/application_attackby(obj/item/attacking_item, mob/living/user)
if(!computer)
return FALSE
if(!istype(attacking_item, /obj/item/aicard))
return FALSE
if(stored_card)
to_chat(user, span_warning("You try to insert \the [attacking_item] into \the [computer.name], but the slot is occupied."))
return FALSE
if(user && !user.transferItemToLoc(attacking_item, computer))
return FALSE
stored_card = attacking_item
to_chat(user, span_notice("You insert \the [attacking_item] into \the [computer.name]."))
return TRUE
/datum/computer_file/program/ai_restorer/try_eject(mob/living/user, forced = FALSE)
if(!stored_card)
if(user)
to_chat(user, span_warning("There is no card in \the [computer.name]."))
return FALSE
if(restoring && !forced)
if(user)
to_chat(user, span_warning("Safeties prevent you from removing the card until reconstruction is complete..."))
return FALSE
if(user && computer.Adjacent(user))
to_chat(user, span_notice("You remove [stored_card] from [computer.name]."))
user.put_in_hands(stored_card)
else
stored_card.forceMove(computer.drop_location())
stored_card = null
restoring = FALSE
return TRUE
/datum/computer_file/program/ai_restorer/ui_act(action, params, datum/tgui/ui, datum/ui_state/state)
switch(action)
if("PRG_beginReconstruction")
if(!stored_card || !stored_card.AI)
return FALSE
var/mob/living/silicon/ai/A = stored_card.AI
if(A && A.health < 100)
restoring = TRUE
A.notify_revival("Your core files are being restored!", source = computer)
return TRUE
if("PRG_eject")
if(stored_card)
try_eject(usr)
return TRUE
/datum/computer_file/program/ai_restorer/ui_data(mob/user)
var/list/data = list()
data["ejectable"] = TRUE
data["AI_present"] = !!stored_card?.AI
data["error"] = null
if(!stored_card)
data["error"] = "Please insert an intelliCard."
else if(!stored_card.AI)
data["error"] = "No AI located..."
else if(stored_card.flush)
data["error"] = "Flush in progress!"
else
data["name"] = stored_card.AI.name
data["restoring"] = restoring
data["health"] = (stored_card.AI.health + 100) / 2
data["isDead"] = stored_card.AI.stat == DEAD
data["laws"] = stored_card.AI.laws.get_law_list(include_zeroth = TRUE, render_html = FALSE)
return data