Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cryo Overhaul #1507

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Content.Server/Body/Components/MetabolizerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@ public sealed partial class MetabolizerComponent : Component
/// </summary>
[DataField]
public bool RemoveEmpty = false;

/// <summary>
/// How many reagents can this metabolizer process at once?
/// How many poisons can this metabolizer process at once?
/// Used to nerf 'stacked poisons' where having 5+ different poisons in a syringe, even at low
/// quantity, would be muuuuch better than just one poison acting.
/// </summary>
[DataField("maxReagents")]
public int MaxReagentsProcessable = 3;
[DataField("maxPoisons")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[DataField("maxPoisons")]
[DataField("maxReagents")]

This is why renaming DataFields is not a good idea.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why renaming DataFields is not a good idea.

image

I think looking at that gave me a stroke

public int MaxPoisonsProcessable = 3;

/// <summary>
/// A list of metabolism groups that this metabolizer will act on, in order of precedence.
Expand Down
13 changes: 7 additions & 6 deletions Content.Server/Body/Systems/MetabolizerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private void TryMetabolize(Entity<MetabolizerComponent, OrganComponent?, Solutio
var list = solution.Contents.ToArray();
_random.Shuffle(list);

int reagents = 0;
int poisons = 0;
foreach (var (reagent, quantity) in list)
{
if (!_prototypeManager.TryIndex<ReagentPrototype>(reagent.Prototype, out var proto))
Expand All @@ -163,9 +163,9 @@ private void TryMetabolize(Entity<MetabolizerComponent, OrganComponent?, Solutio
continue;
}

// we're done here entirely if this is true
if (reagents >= ent.Comp1.MaxReagentsProcessable)
return;
// Already processed all poisons, skip to the next reagent.
if (poisons >= ent.Comp1.MaxPoisonsProcessable && proto.Metabolisms.ContainsKey("Poison"))
continue;


// loop over all our groups and see which ones apply
Expand Down Expand Up @@ -226,8 +226,9 @@ private void TryMetabolize(Entity<MetabolizerComponent, OrganComponent?, Solutio
{
solution.RemoveReagent(reagent, mostToRemove);

// We have processed a reagant, so count it towards the cap
reagents += 1;
// We have processed a poison, so count it towards the cap
if (proto.Metabolisms.ContainsKey("Poison"))
poisons++;
}
}

Expand Down
6 changes: 5 additions & 1 deletion Content.Server/Medical/CryoPodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ public override void Update(float frameTime)
continue;
}

var solutionToInject = _solutionContainerSystem.SplitSolution(containerSolution.Value, cryoPod.BeakerTransferAmount);
// Filter out a fixed amount of each reagent from the cryo pod's beaker
var solutionToInject = _solutionContainerSystem.SplitSolutionReagentsEvenly(containerSolution.Value, cryoPod.BeakerTransferAmount);
// for every .25 units used, .5 units per second are added to the body, making cryo-pod more efficient than injections
solutionToInject.ScaleSolution(cryoPod.PotencyMultiplier);

_bloodstreamSystem.TryAddToChemicals(patient.Value, solutionToInject, bloodstream);
_reactiveSystem.DoEntityReaction(patient.Value, solutionToInject, ReactionMethod.Injection);
}
Expand Down
57 changes: 55 additions & 2 deletions Content.Shared/Chemistry/Components/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,11 @@ public Solution SplitSolutionWithout(FixedPoint2 toTake, params string[] exclude

return sol;
}

/// <summary>
/// Splits a solution without the specified reagent prototypes.
/// splits the solution taking the specified amount of reagents proportionally to their quantity.
/// </summary>
/// <param name="toTake">The total amount of solution to remove and return.</param>
/// <returns>a new solution of equal proportions to the original solution</returns>
public Solution SplitSolutionWithOnly(FixedPoint2 toTake, params string[] includedPrototypes)
{
// First remove the non-included prototypes
Expand Down Expand Up @@ -671,6 +672,58 @@ public Solution SplitSolution(FixedPoint2 toTake)
return newSolution;
}

/// <summary>
/// splits the solution taking up to the specified amount of each reagent from the solution.
/// If the solution has less of a reagent than the specified amount, it will take all of that reagent.
/// </summary>
/// <param name="toTakePer">How much of each reagent to take</param>
/// <returns>a new solution containing the reagents taken from the original solution</returns>
public Solution SplitSolutionReagentsEvenly(FixedPoint2 toTakePer)
{
var splitSolution = new Solution();

if (toTakePer <= FixedPoint2.Zero)
return splitSolution;
var reagentsCount = Contents.Count;
var reagentsToRemove = new List<ReagentQuantity>();
for (var i = 0; i < reagentsCount; i++)
{
var currentReagent = Contents[i];

if (currentReagent.Quantity <= FixedPoint2.Zero)
{
reagentsToRemove.Add(currentReagent);
continue;
}

if (currentReagent.Quantity <= toTakePer)
{
splitSolution.AddReagent(currentReagent);
reagentsToRemove.Add(currentReagent);
}
else
{
splitSolution.AddReagent(currentReagent.Reagent, toTakePer);
RemoveReagent(currentReagent.Reagent, toTakePer);
}
}

foreach (var reagent in reagentsToRemove)
{
RemoveReagent(reagent);
}
if (Volume == FixedPoint2.Zero)
RemoveAllSolution();

_heatCapacityDirty = true;
splitSolution._heatCapacityDirty = true;

ValidateSolution();
splitSolution.ValidateSolution();

return splitSolution;
}

/// <summary>
/// Variant of <see cref="SplitSolution(FixedPoint2)"/> that doesn't return a new solution containing the removed reagents.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,7 @@ public void UpdateAppearance(Entity<SolutionComponent, AppearanceComponent?> sol

/// <summary>
/// Removes part of the solution in the container.
/// </summary>
/// <param name="targetUid"></param>
/// <param name="solutionHolder"></param>
/// </summary> /// <param name="soln">The container to remove solution from.</param>
/// <param name="quantity">the volume of solution to remove.</param>
/// <returns>The solution that was removed.</returns>
public Solution SplitSolution(Entity<SolutionComponent> soln, FixedPoint2 quantity)
Expand All @@ -341,6 +339,22 @@ public Solution SplitSolution(Entity<SolutionComponent> soln, FixedPoint2 quanti
return splitSol;
}

/// <summary>
/// Splits a solution removing a specified amount of each reagent, if available.
/// </summary>
/// <param name="soln">The container to split the solution from.</param>
/// <param name="quantity">The amount of each reagent to split.</param>
/// <returns></returns>
public Solution SplitSolutionReagentsEvenly(Entity<SolutionComponent> soln, FixedPoint2 quantity)
{
var (uid, comp) = soln;
var solution = comp.Solution;

var splitSol = solution.SplitSolutionReagentsEvenly(quantity);
UpdateChemicals(soln);
return splitSol;
}

public Solution SplitStackSolution(Entity<SolutionComponent> soln, FixedPoint2 quantity, int stackCount)
{
var (uid, comp) = soln;
Expand Down
14 changes: 11 additions & 3 deletions Content.Shared/Medical/Cryogenics/CryoPodComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Robust.Shared.Containers;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
Expand Down Expand Up @@ -34,11 +34,19 @@ public sealed partial class CryoPodComponent : Component
public TimeSpan? NextInjectionTime;

/// <summary>
/// How many units to transfer per tick from the beaker to the mob?
/// How many units of each reagent to transfer per tick from the beaker to the mob?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("beakerTransferAmount")]
public float BeakerTransferAmount = 1f;
public float BeakerTransferAmount = .25f;

/// <summary>
/// How potent (multiplier) the reagents are when transferred from the beaker to the mob.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("PotencyAmount")]
public float PotencyMultiplier = 2f;


/// <summary>
/// Delay applied when inserting a mob in the pod.
Expand Down
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/reagents/meta/chemicals.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ reagent-desc-sodium-polyacrylate = A super-absorbent polymer with assorted indus
reagent-name-cellulose = cellulose fibers
reagent-desc-cellulose = A crystaline polydextrose polymer, plants swear by this stuff.

reagent-name-salicylicacid = salicylic acid
reagent-desc-salicylicacid = A powdery substance used for dermatological treatments.

reagent-name-formaldehyde = formaldehyde
reagent-desc-formaldehyde = A yellowish substance used for peservation of tissue.
10 changes: 8 additions & 2 deletions Resources/Locale/en-US/reagents/meta/medicine.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ reagent-name-bicaridine = bicaridine
reagent-desc-bicaridine = An analgesic which is highly effective at treating brute damage. It's useful for stabilizing people who have been severely beaten, as well as treating less life-threatening injuries.

reagent-name-cryoxadone = cryoxadone
reagent-desc-cryoxadone = Required for the proper function of cryogenics. Heals all standard types of damage, but only works in temperatures under 213K. It can treat and rejuvenate plants when applied in small doses.
reagent-desc-cryoxadone = Required for the proper function of cryogenics. Useful in treating asphyxiation and bloodloss, but only works in temperatures under 213K. It can treat and rejuvenate plants when applied in small doses. Works regardless of the patient being alive or dead.

reagent-name-doxarubixadone = doxarubixadone
reagent-desc-doxarubixadone = A cryogenics chemical. Heals certain types of cellular damage done by Slimes and improper use of other chemicals.
reagent-desc-doxarubixadone = A cryogenics chemical. Heals certain types of cellular damage done by Slimes and improper use of other chemicals. Works regardless of the patient being alive or dead.

reagent-name-traumoxadone = traumoxadone
reagent-desc-traumoxadone = A cryogenics chemical. Used to treat severe trauma via regeneration of the damaged tissue. Works regardless of the patient being alive or dead. Product of Mystic Medical

reagent-name-stelloxadone = stelloxadone
reagent-desc-stelloxadone = A cryogenics chemical. Used to aggressively dissolve toxins from the body. Works regardless of the patient being alive or dead. Product of Mystic Medical

reagent-name-dermaline = dermaline
reagent-desc-dermaline = An advanced chemical that is more effective at treating burn damage than kelotane.
Expand Down
14 changes: 14 additions & 0 deletions Resources/Prototypes/Reagents/chemicals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,17 @@
color: "#E6E6DA"
physicalDesc: reagent-physical-desc-crystalline
slippery: false

- type: reagent
id: SalicylicAcid
name: reagent-name-salicylicacid
desc: reagent-desc-salicylicacid
physicalDesc: reagent-physical-desc-powdery
color: "#EEEEEE"

- type: reagent
id: Formaldehyde
name: reagent-name-formaldehyde
desc: reagent-desc-formaldehyde
physicalDesc: reagent-physical-desc-sickly
color: "#F26724"
47 changes: 46 additions & 1 deletion Resources/Prototypes/Reagents/medicine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
- !type:ReagentThreshold
min: 15
- !type:Drunk

- type: reagent
id: Cryoxadone
name: reagent-name-cryoxadone
Expand Down Expand Up @@ -1396,3 +1396,48 @@
- !type:PlantAdjustHealth
amount: 0.1

- type: reagent
id : Traumoxadone
name: reagent-name-traumoxadone
group: Medicine
desc: reagent-desc-traumoxadone
physicalDesc: reagent-physical-desc-soothing
flavor: medicine
color: "#880077"
worksOnTheDead: true
metabolisms:
Medicine:
effects:
- !type:HealthChange
conditions:
- !type:Temperature
max: 213.0
damage:
types:
Blunt: -2
Piercing: -2
Slash: -2

- type: reagent
id : Stelloxadone
name: reagent-name-stelloxadone
group: Medicine
desc: reagent-desc-stelloxadone
physicalDesc: reagent-physical-desc-soothing
flavor: medicine
color: "#FFA861"
worksOnTheDead: true
metabolisms:
Medicine:
effects:
- !type:HealthChange
conditions:
- !type:Temperature
max: 213.0
damage:
types:
Poison: -6
Radiation: -3
Cellular: 1
groups:
Brute: 3
26 changes: 26 additions & 0 deletions Resources/Prototypes/Recipes/Reactions/chemicals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,29 @@
amount: 1
products:
Tazinide: 1

- type: reaction
id : SalicylicAcid
reactants:
Phenol:
amount: 1
Sodium:
amount: 1
Carbon:
amount: 1
Oxygen:
amount: 1
SulfuricAcid:
amount: 1
products:
SalicylicAcid: 3

- type: reaction
id : Formaldehyde
reactants:
Vinegar:
amount: 2
Silver:
amount: 1
products:
Formaldehyde: 3
28 changes: 27 additions & 1 deletion Resources/Prototypes/Recipes/Reactions/medicine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
reactants:
Cryoxadone:
amount: 1
UnstableMutagen:
Phalanximine:
amount: 1
products:
Doxarubixadone: 2
Expand Down Expand Up @@ -666,3 +666,29 @@
amount: 1
products:
Haloperidol: 5

- type: reaction
id: Traumoxadone
reactants:
Cryoxadone:
amount: 1
SalicylicAcid:
amount: 1
Lipozine:
amount: 1
products:
Traumoxadone: 2

- type: reaction
id: Stelloxadone
reactants:
Cryoxadone:
amount: 3
Stellibinin:
amount: 5
Arithrazine:
amount: 2
products:
Stelloxadone: 5
Water: 3
Fiber: 2
12 changes: 9 additions & 3 deletions Resources/ServerInfo/Guidebook/Medical/Cryogenics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ Not every network will look like this, but hopefully, it's enough to give you th
An important thing to note, winter clothing (and hardsuits) will make cryogenic treatment less, or completely ineffective. Be sure to remove cold preventative clothing before placing people in the pod.

## Using the Pod
Once things have been set up, you're going to require a specific medication, Cryoxadone. Cryoxadone heals all damage types when a patient is chilled, and can either be pre-adminsitered (with a pill), or loaded into the cell directly with a beaker. Do note, patients won't begin to heal until they've chilled to the appropriate temperature, it may be worthwhile to wait a bit before placing a beaker inside.
Once things have been set up, you're going to require cryogenic medications (all listed below). They each provide healing when a patient is chilled, and should be loaded into the pod directly with a beaker. Do note, patients won't begin to heal until they've chilled to the appropriate temperature, it may be worthwhile to wait a bit before placing a beaker inside.

## Additional Information:

The standard pressure for a gas pump is 100.325 kpa. Cryoxadone works at under 170K, but it is standard practice to set the freezer to 100K for faster freezing.
The standard pressure for a gas pump is 100.325 kpa. Cryogenics medicines work at under 213K (150K for Opporozidone), but it is standard practice to set the freezer to 100K for faster freezing.

Cryo pods separate out each reagent from the beaker in the pod, injecting a small, steady amount of each into the patient. This allows for medicine to be administered twice as efficiently than with injection or oral administration.

<GuideReagentEmbed Reagent="Cryoxadone"/>
<GuideReagentEmbed Reagent="Traumoxadone"/>
<GuideReagentEmbed Reagent="Aloxadone"/>
<GuideReagentEmbed Reagent="Stelloxadone"/>
<GuideReagentEmbed Reagent="Doxarubixadone"/>
<GuideReagentEmbed Reagent="Dexalin"/>
<GuideReagentEmbed Reagent="Necrosol"/>
<GuideReagentEmbed Reagent="Opporozidone"/>

</Document>
Loading