Skip to content

Commit

Permalink
Merge pull request #171 from neuPanda/Cryo-overhaul
Browse files Browse the repository at this point in the history
Cryo Overhaul
  • Loading branch information
Fansana committed Sep 4, 2024
2 parents eab876f + b5451ee commit c48c5cb
Show file tree
Hide file tree
Showing 16 changed files with 256 additions and 32 deletions.
9 changes: 5 additions & 4 deletions Content.Server/Body/Components/MetabolizerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ public sealed partial class MetabolizerComponent : Component
/// </summary>
[DataField]
public bool RemoveEmpty = false;

/// <summary>
/// How many reagents can this metabolizer process at once?
/// floof
///
/// 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")]
public int MaxPoisonsProcessable = 3;

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

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

// we're done here entirely if this is true
if (reagents >= ent.Comp1.MaxReagentsProcessable)
return;
// floof modified
// 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 @@ -223,8 +224,10 @@ private void TryMetabolize(Entity<MetabolizerComponent, OrganComponent?, Solutio
{
solution.RemoveReagent(reagent, mostToRemove);

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

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

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);

// End floof
_bloodstreamSystem.TryAddToChemicals(patient.Value, solutionToInject, bloodstream);
_reactiveSystem.DoEntityReaction(patient.Value, solutionToInject, ReactionMethod.Injection);
}
Expand Down
58 changes: 56 additions & 2 deletions Content.Shared/Chemistry/Components/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,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 @@ -677,6 +678,59 @@ public Solution SplitSolution(FixedPoint2 toTake)
return newSolution;
}

/// <summary>
/// floof
/// 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 @@ -296,9 +296,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 @@ -311,6 +309,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
15 changes: 12 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,20 @@ 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;// floof: 1<0.25

/// <summary>
/// Frontier
/// 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/Floof/reagents/meta/chemicals.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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.
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/Floof/reagents/meta/medicine.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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
6 changes: 4 additions & 2 deletions Resources/Locale/en-US/reagents/meta/medicine.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ reagent-desc-arithrazine = A mildly unstable medication used for the most extrem
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.
# Floof: consistent cryogenics descriptors
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.
# End Floof

reagent-name-dermaline = dermaline
reagent-desc-dermaline = An advanced chemical that is more effective at treating burn damage than kelotane.
Expand Down
13 changes: 13 additions & 0 deletions Resources/Prototypes/Floof/Reagents/chemicals.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- 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: 47 additions & 0 deletions Resources/Prototypes/Floof/Reagents/medicine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
- 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/Floof/Recipes/Reactions/chemicals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,29 @@
amount: 5
products:
Libidozenithizine: 5

- 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
26 changes: 26 additions & 0 deletions Resources/Prototypes/Floof/Recipes/Reactions/medicine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,29 @@
amount: 1
products:
Philterex: 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
Loading

0 comments on commit c48c5cb

Please sign in to comment.