space-station-14 icon indicating copy to clipboard operation
space-station-14 copied to clipboard

feat: Medbay cryo pods

Open Carbonhell opened this issue 2 years ago • 9 comments

Fixes #11245

About the PR

This PR adds a new machine called cryo pods (or cryo cells). This is a medical machine which allows cooling down a patient to extremely low temperatures, without damaging them. This is useful paired with medicines that react on low temperatures such as cryoxadone. The machine also accepts a solution container to draw chemicals from, periodically injecting them in the mob at a specific rate (1 unit per second right now). The machine requires a small atmos setup to work, a power amount slightly lower than clone pods and it can be tampered in several ways.

  1. The machine requires an atmos setup to prepare an air mix at an acceptable pressure for mobs (one atmosphere) and with a low temperature (which can be achieved with the use of a freezer). Forgetting the pressure requirement can make the medical machine become a torture machine instead, quickly killing the patient with overpressurization (or due to no pressure aswell). The machine overrides the cold protection of the patient to 10°K.

  2. Normally you can insert a mob (or yourself) by dragging it into the pod. Ejection works through the use of a verb. Ejection might not work if the pod is locked. This can be achieved by cutting a specific wire (mending solves it) or emagging it (which requires the machine to be rebuilt).

  3. The machine circuitboard can be obtained by high level research (same as clone pods). This PR does not affects map (and I think those pods should be built rather than mapped in).

  4. Once the patient is ejected, the cold protection is nullified. This means damage will start to stack. This is intended, medics can heal the tiny damage caused by this or prevent it somehow (heating the room, giving clothes, dunno).

The PR introduces two (somewhat?) important code tweaks. One is the ChangeDamageGetThresholdsEvent ref event which allows to override the temperature threshold similar to how it's done for the AtmosExposedGetAirEvent event. Another is a force argument flag to the Stand method of the StandingStateSystem to ignore overrides (this is needed to allow showing the mob contained within the cryo pod in certain cases).

Screenshots

Example of an atmos setup (the cryo pod itself can also be scanned with a gas analyzer to ensure everything's ok) image

No power, the human inside is visible, floating within the pod. image

Power available, the pod turns on automatically and begins to inject the human inside with chemicals image

Interacting with the pod with an empty hand shows a shamelessly recycled health analyzer UI to monitor the patient with. The cryo pod in the picture also has its maintenance pod open. image

The locking mechanism was tampered with and the ejection verb doesn't work. image

Changelog

:cl:

  • add: Medbay can now obtain cryo pods, specialized cryogenics machines used to lower the temperature of a patient to extreme values somewhat safely to use specific chemicals, such as cryoxadone.

Carbonhell avatar Sep 16 '22 12:09 Carbonhell

RSI Diff Bot; head commit c4699aa42e716e34509679535ab0746148fdd079 merging into 54b5a9238cdf02978e38a9c65b23e12c3770f6f6 This PR makes changes to 1 or more RSIs. Here is a summary of all changes:

Resources/Textures/Structures/Machines/cryogenics.rsi

State Old New Status
cover-off Added
cover-on Added
pod-off Added
pod-on Added
pod-open Added
pod-panel Added
Edit: diff updated after c4699aa42e716e34509679535ab0746148fdd079

github-actions[bot] avatar Sep 16 '22 12:09 github-actions[bot]

Just FYI, clonexadone has been removed from the game in #11253

lapatison avatar Sep 16 '22 13:09 lapatison

Ah I missed that PR, thanks for telling me!

On a sidenote, there's a slight graphical glitch that happens when the pod's open and someone walks on the tile below it. I left it in because otherwise people who get ejected would appear under the pod, which IMO is uglier. Not sure if there's a way to solve this. image

Also, I just rebased on the latest commit and removed the deprecated GasAnalyzable component.

Carbonhell avatar Sep 16 '22 13:09 Carbonhell

Just FYI, clonexadone has been removed from the game in #11253

it was removed, but would probably be added again if it has a use, and it was removed becuase it's exactly the same as cryoxadone if the chems just get different effects and such they can both exist again, no?

Otherwise cool feature

Kromabae avatar Sep 16 '22 13:09 Kromabae

Ah I missed that PR, thanks for telling me!

On a sidenote, there's a slight graphical glitch that happens when the pod's open and someone walks on the tile below it. I left it in because otherwise people who get ejected would appear under the pod, which IMO is uglier. Not sure if there's a way to solve this. image

Also, I just rebased on the latest commit and removed the deprecated GasAnalyzable component.

Probably would want to give the top the proper drawdepth and then just have the game deal with drawdepth on the pod portion when exiting. Doesnt climbing on the pod put it on top of it visually?

EmoGarbage404 avatar Sep 16 '22 13:09 EmoGarbage404

On a sidenote, there's a slight graphical glitch that happens when the pod's open and someone walks on the tile below it. I left it in because otherwise people who get ejected would appear under the pod, which IMO is uglier. Not sure if there's a way to solve this.

Unless it's been changed, the other medical machines have half-wall collision and are climbable. When the person is ejected they are automatically put into the climbing state.

This makes it collidable while not pushing players out.

ShadowCommander avatar Sep 16 '22 15:09 ShadowCommander

Your gas analyzer scan looks like it uses the old gas analyzer before I reworked it. Looks like the cryo pod has a node container, but if you want to actually specify what mixes the gas analyzer displays, like having it instead display the gas mixture in the Cryo pod Component, you need to add a handler for GasAnalyzerScanEvent in the system. You can look at portable scrubbers for an example on this. I think for this device it makes sense to only display the internal environment, which I am assuming the gas mix on the component is that. If people want to see the piped in atmos they can scan the input pipe.

theashtronaut avatar Sep 16 '22 23:09 theashtronaut

Thank you @theashtronaut , I've implemented the event handler as you stated, I decided to show both the cryo pod air and the port air since scrubbers do something similar and it makes sense for cryo pods aswell. Thank you very much @vulppine for the review, I've addressed all the comments and I made all the events targeted since it makes no sense for any to be a broadcast.

Carbonhell avatar Sep 24 '22 16:09 Carbonhell

code looks good. on testing ingame some notes:

  • 1 canister is too high pressure for the cryopod at 73.15 with a small pipenet. i was still able to heal just fine, but something to note i suppose. nothing necessarily has to be done about this
  • people are fully conscious while within the cryopod. IMO they shouldnt be able to eject themselves from it, and it might be reasonable to just put them in a sleeping state?

mirrorcult avatar Oct 15 '22 21:10 mirrorcult

code looks good. on testing ingame some notes:

  • 1 canister is too high pressure for the cryopod at 73.15 with a small pipenet. i was still able to heal just fine, but something to note i suppose. nothing necessarily has to be done about this
  • people are fully conscious while within the cryopod. IMO they shouldnt be able to eject themselves from it, and it might be reasonable to just put them in a sleeping state?

Regarding 1, in the example pipenet setup you do need a pressure valve to stabilize the pressure to an acceptable value between the canister and the cryo pod, otherwise the patient will take pressure damage. Although, as you said, even just by using cryoxadone the damage is pretty much negated... Unless the beaker empties and the patient isn't ejected. Regarding 2, I was fairly conflicted on this point. I have a lot of bad experiences from ss13 where I'd be forgotten alone in a pod due to it putting the patient to sleep. I would really prefer to avoid causing the same experience to other players. If someone wants to use the cryo pod maliciously, the locking mechanism enabled either by an emag or by pulsing the right wire works. If it ends up being too easy for people to patch themself with a cryopod, though, it can easily be patched in a future PR.

Carbonhell avatar Oct 17 '22 15:10 Carbonhell

Regarding 2, I was fairly conflicted on this point. I have a lot of bad experiences from ss13 where I'd be forgotten alone in a pod due to it putting the patient to sleep. I would really prefer to avoid causing the same experience to other players. If someone wants to use the cryo pod maliciously, the locking mechanism enabled either by an emag or by pulsing the right wire works. If it ends up being too easy for people to patch themself with a cryopod, though, it can easily be patched in a future PR.

The fix that was put in place for the "medical forgot about you" was that the cryopod will auto-eject patient that are finished and beep angerly when doing it to alert medical (not continuously, just when ejected). I think tying the auto-eject function to the hacked/wire side could be good, so a malicious player can disable the auto-eject feature should they want. It would let people perma-trap others though. Maybe there is also an auto-ejection after X minutes like 5 or 10 minutes, where it dumps the patient out eventually even if hacked just to stop perma-lock from happening? That way you would have plenty of time for nefarious deeds, but can't just shove people into a pod somewhere in maintenance and remove them from the game at the same time?

theashtronaut avatar Oct 17 '22 17:10 theashtronaut

The fix that was put in place for the "medical forgot about you" was that the cryopod will auto-eject patient that are finished and beep angerly when doing it to alert medical (not continuously, just when ejected). I think tying the auto-eject function to the hacked/wire side could be good, so a malicious player can disable the auto-eject feature should they want. It would let people perma-trap others though. Maybe there is also an auto-ejection after X minutes like 5 or 10 minutes, where it dumps the patient out eventually even if hacked just to stop perma-lock from happening? That way you would have plenty of time for nefarious deeds, but can't just shove people into a pod somewhere in maintenance and remove them from the game at the same time?

I don't really see much difference between auto-ejection when fully healed vs letting the medic or the patient eject when they want. Also perma-trapping is already possible for antagonistic reason by either cutting the lock wire or by the use of an emag, but since patients do not fall asleep you can at least have the chance to scream for help, which is a fair balance imo. If you build a cryo pod in maintenance to lock people up, with the long do-after there is in place you would definitely need the victim cuffed, at that point you could remove them from the game in any other way as well, so I do not see a balance issue in this way. I do not see any obvious balance pain point in the current implementation, my idea still is to get this PR in as is and see how the community uses the pods and balance them out if some unexpected OP use shows up.

Carbonhell avatar Oct 22 '22 08:10 Carbonhell

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Oct 25 '22 00:10 github-actions[bot]

I resolved the conflicts along with some small errors regarding refactors to ItemSlotsSystem (GetItem is now GetItemOrNull) and Body stuff (In the CanInsert method, I just had to swap SharedBodyComponent to BodyComponent). I've tested ingame and everything works.

I've noticed something bizarre though: the CO2 buildup generated by a patient breathing within a cryo pod is enormous: 0.08 mols of CO2 were being generated every gas analyzer UI refresh. This means that, with an atmos setup without a working gas filter, the patient will die of poison extremely quickly. I've tried an isolated test in a 1x1 room and I noticed my mob (a lizard) was breathing out 0.02 mols of CO2. I'm not sure why it's x4 in a cryo pod, but 0.02 seems to also be too much according to mirrorcult.

Carbonhell avatar Oct 27 '22 11:10 Carbonhell

There's only one issue left regarding cryo pods with a wall above them: you can enter the pod, you cannot eject yourself from the pod though since the wall somehow stops you. Also, if someone ejects you, you'll be pushed above the wall. image

I'm not really sure how to handle this case, I'll need to think about it a bit more.

Carbonhell avatar Oct 27 '22 11:10 Carbonhell

cryo_pod_working_2 I refactored the code regarding the sprite offsetting when inside the cryopod to be handled by editing the clientside SpriteComponent Offset field, instead of editing the transform serverside, therefore the issues related to my last comments are now fixed. The PR should be good to go if all the tests pass.

Carbonhell avatar Oct 28 '22 21:10 Carbonhell

Does this look okay with rotated eye?

It completely broke when rotating the eye haha, thank you for making me notice. I've used only a single directional sprite now which looks okay and works when rotating the eye as well.

Carbonhell avatar Dec 08 '22 15:12 Carbonhell

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Dec 09 '22 03:12 github-actions[bot]

The failing test seems to be related to the wrong license used in some rsi files completely unrelated to my PR, so I believe it's safe to say those can be ignored.

Carbonhell avatar Dec 22 '22 09:12 Carbonhell