Scale other needed metabolism reagents (#12005)
Closes https://github.com/space-wizards/space-station-14/issues/7434
This commit is contained in:
@@ -152,10 +152,13 @@ namespace Content.Server.Body.Systems
|
||||
if (entry.MetabolismRate > mostToRemove)
|
||||
mostToRemove = entry.MetabolismRate;
|
||||
|
||||
|
||||
mostToRemove *= group.MetabolismRateModifier;
|
||||
|
||||
mostToRemove = FixedPoint2.Clamp(mostToRemove, 0, reagent.Quantity);
|
||||
|
||||
float scale = (float) mostToRemove / (float) entry.MetabolismRate;
|
||||
|
||||
// if it's possible for them to be dead, and they are,
|
||||
// then we shouldn't process any effects, but should probably
|
||||
// still remove reagents
|
||||
@@ -167,7 +170,7 @@ namespace Content.Server.Body.Systems
|
||||
|
||||
var actualEntity = organ?.Body ?? solutionEntityUid.Value;
|
||||
var args = new ReagentEffectArgs(actualEntity, (meta).Owner, solution, proto, mostToRemove,
|
||||
EntityManager, null, entry);
|
||||
EntityManager, null, scale);
|
||||
|
||||
// do all effects, if conditions apply
|
||||
foreach (var effect in entry.Effects)
|
||||
|
||||
@@ -32,12 +32,16 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
if (args.Source != null)
|
||||
{
|
||||
var solutionSys = args.EntityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
|
||||
var amount = Amount;
|
||||
|
||||
amount *= args.Scale;
|
||||
|
||||
if (Reagent != null)
|
||||
{
|
||||
if (Amount < 0 && args.Source.ContainsReagent(Reagent))
|
||||
solutionSys.TryRemoveReagent(args.SolutionEntity, args.Source, Reagent, -Amount);
|
||||
if (Amount > 0)
|
||||
solutionSys.TryAddReagent(args.SolutionEntity, args.Source, Reagent, Amount, out _);
|
||||
if (amount < 0 && args.Source.ContainsReagent(Reagent))
|
||||
solutionSys.TryRemoveReagent(args.SolutionEntity, args.Source, Reagent, -amount);
|
||||
if (amount > 0)
|
||||
solutionSys.TryAddReagent(args.SolutionEntity, args.Source, Reagent, amount, out _);
|
||||
}
|
||||
else if (Group != null)
|
||||
{
|
||||
@@ -47,10 +51,10 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
var proto = prototypeMan.Index<ReagentPrototype>(quant.ReagentId);
|
||||
if (proto.Metabolisms != null && proto.Metabolisms.ContainsKey(Group))
|
||||
{
|
||||
if (Amount < 0)
|
||||
solutionSys.TryRemoveReagent(args.SolutionEntity, args.Source, quant.ReagentId, Amount);
|
||||
if (Amount > 0)
|
||||
solutionSys.TryAddReagent(args.SolutionEntity, args.Source, quant.ReagentId, Amount, out _);
|
||||
if (amount < 0)
|
||||
solutionSys.TryRemoveReagent(args.SolutionEntity, args.Source, quant.ReagentId, amount);
|
||||
if (amount > 0)
|
||||
solutionSys.TryAddReagent(args.SolutionEntity, args.Source, quant.ReagentId, amount, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,11 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
if (args.EntityManager.TryGetComponent(args.SolutionEntity, out TemperatureComponent? temp))
|
||||
{
|
||||
var sys = args.EntityManager.EntitySysManager.GetEntitySystem<TemperatureSystem>();
|
||||
sys.ChangeHeat(args.SolutionEntity, Amount, true, temp);
|
||||
var amount = Amount;
|
||||
|
||||
amount *= args.Scale;
|
||||
|
||||
sys.ChangeHeat(args.SolutionEntity, amount, true, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
if (args.Scale != 1f)
|
||||
return;
|
||||
|
||||
EntitySystem.Get<DiseaseSystem>().TryAddDisease(args.SolutionEntity, Disease);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
if (args.EntityManager.TryGetComponent<DiseasedComponent>(args.SolutionEntity, out var diseased))
|
||||
return;
|
||||
|
||||
if (args.Scale != 1f)
|
||||
return;
|
||||
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
|
||||
EntitySystem.Get<DiseaseSystem>().TryAddDisease(args.SolutionEntity, random.Pick(Diseases));
|
||||
|
||||
@@ -17,8 +17,12 @@ namespace Content.Server.Chemistry.ReactionEffects
|
||||
if (args.Source == null)
|
||||
return;
|
||||
|
||||
var cleanseRate = CleanseRate;
|
||||
|
||||
cleanseRate *= args.Scale;
|
||||
|
||||
var bloodstreamSys = EntitySystem.Get<BloodstreamSystem>();
|
||||
bloodstreamSys.FlushChemicals(args.SolutionEntity, args.Reagent.ID, CleanseRate);
|
||||
bloodstreamSys.FlushChemicals(args.SolutionEntity, args.Reagent.ID, cleanseRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,11 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
var ev = new CureDiseaseAttemptEvent(CureChance);
|
||||
var cureChance = CureChance;
|
||||
|
||||
cureChance *= args.Scale;
|
||||
|
||||
var ev = new CureDiseaseAttemptEvent(cureChance);
|
||||
args.EntityManager.EventBus.RaiseLocalEvent(args.SolutionEntity, ev, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
if (args.Scale != 1f)
|
||||
return;
|
||||
|
||||
args.EntityManager.EntitySysManager.GetEntitySystem<SharedBlindingSystem>().AdjustEyeDamage(args.SolutionEntity, Amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
{
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
if (args.Scale != 1f)
|
||||
return;
|
||||
|
||||
string disease = EntitySystem.Get<MiasmaSystem>().RequestPoolDisease();
|
||||
|
||||
EntitySystem.Get<DiseaseSystem>().TryAddDisease(args.SolutionEntity, disease);
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
if (args.Scale != 1f)
|
||||
return;
|
||||
|
||||
var vomitSys = args.EntityManager.EntitySysManager.GetEntitySystem<VomitSystem>();
|
||||
|
||||
vomitSys.Vomit(args.SolutionEntity, ThirstAmount, HungerAmount);
|
||||
|
||||
@@ -19,7 +19,11 @@ public sealed class Drunk : ReagentEffect
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
var boozePower = BoozePower;
|
||||
|
||||
boozePower *= args.Scale;
|
||||
|
||||
var drunkSys = args.EntityManager.EntitySysManager.GetEntitySystem<SharedDrunkSystem>();
|
||||
drunkSys.TryApplyDrunkenness(args.SolutionEntity, BoozePower, SlurSpeech);
|
||||
drunkSys.TryApplyDrunkenness(args.SolutionEntity, boozePower, SlurSpeech);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
var scale = ScaleByQuantity ? args.Quantity : FixedPoint2.New(1);
|
||||
if (args.MetabolismEffects != null)
|
||||
scale *= (args.Quantity / args.MetabolismEffects.MetabolismRate);
|
||||
scale *= args.Scale;
|
||||
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(args.SolutionEntity, Damage * scale, IgnoreResistances);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ public sealed class ModifyBleedAmount : ReagentEffect
|
||||
{
|
||||
var sys = EntitySystem.Get<BloodstreamSystem>();
|
||||
var amt = Scaled ? Amount * args.Quantity.Float() : Amount;
|
||||
amt *= args.Scale;
|
||||
|
||||
sys.TryModifyBleedAmount(args.SolutionEntity, amt, blood);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ public sealed class ModifyBloodLevel : ReagentEffect
|
||||
{
|
||||
var sys = EntitySystem.Get<BloodstreamSystem>();
|
||||
var amt = Scaled ? Amount * args.Quantity : Amount;
|
||||
amt *= args.Scale;
|
||||
|
||||
sys.TryModifyBloodLevel(args.SolutionEntity, amt, blood);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,11 @@ namespace Content.Server.Chemistry.ReagentEffects
|
||||
status.WalkSpeedModifier = WalkSpeedModifier;
|
||||
status.SprintSpeedModifier = SprintSpeedModifier;
|
||||
|
||||
IncreaseTimer(status, StatusLifetime);
|
||||
// only going to scale application time
|
||||
var statusLifetime = StatusLifetime;
|
||||
statusLifetime *= args.Scale;
|
||||
|
||||
IncreaseTimer(status, statusLifetime);
|
||||
|
||||
if (modified)
|
||||
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(args.SolutionEntity);
|
||||
|
||||
@@ -14,7 +14,10 @@ public sealed class Paralyze : ReagentEffect
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
EntitySystem.Get<StunSystem>().TryParalyze(args.SolutionEntity, TimeSpan.FromSeconds(ParalyzeTime), Refresh);
|
||||
var paralyzeTime = ParalyzeTime;
|
||||
paralyzeTime *= args.Scale;
|
||||
|
||||
EntitySystem.Get<StunSystem>().TryParalyze(args.SolutionEntity, TimeSpan.FromSeconds(paralyzeTime), Refresh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,17 +40,21 @@ namespace Content.Server.Chemistry.ReagentEffects.StatusEffects
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
var statusSys = args.EntityManager.EntitySysManager.GetEntitySystem<StatusEffectsSystem>();
|
||||
|
||||
var time = Time;
|
||||
time *= args.Scale;
|
||||
|
||||
if (Type == StatusEffectMetabolismType.Add && Component != String.Empty)
|
||||
{
|
||||
statusSys.TryAddStatusEffect(args.SolutionEntity, Key, TimeSpan.FromSeconds(Time), Refresh, Component);
|
||||
statusSys.TryAddStatusEffect(args.SolutionEntity, Key, TimeSpan.FromSeconds(time), Refresh, Component);
|
||||
}
|
||||
else if (Type == StatusEffectMetabolismType.Remove)
|
||||
{
|
||||
statusSys.TryRemoveTime(args.SolutionEntity, Key, TimeSpan.FromSeconds(Time));
|
||||
statusSys.TryRemoveTime(args.SolutionEntity, Key, TimeSpan.FromSeconds(time));
|
||||
}
|
||||
else if (Type == StatusEffectMetabolismType.Set)
|
||||
{
|
||||
statusSys.TrySetTime(args.SolutionEntity, Key, TimeSpan.FromSeconds(Time));
|
||||
statusSys.TrySetTime(args.SolutionEntity, Key, TimeSpan.FromSeconds(time));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,11 @@ namespace Content.Server.Chemistry.ReagentEffects.StatusEffects
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
var time = Time;
|
||||
time *= args.Scale;
|
||||
|
||||
args.EntityManager.EntitySysManager.GetEntitySystem<SharedJitteringSystem>()
|
||||
.DoJitter(args.SolutionEntity, TimeSpan.FromSeconds(Time), Refresh, Amplitude, Frequency);
|
||||
.DoJitter(args.SolutionEntity, TimeSpan.FromSeconds(time), Refresh, Amplitude, Frequency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace Content.Shared.Chemistry.Reaction
|
||||
{
|
||||
var args = new ReagentEffectArgs(owner, null, solution,
|
||||
randomReagent,
|
||||
unitReactions, EntityManager, null, null);
|
||||
unitReactions, EntityManager, null, 1f);
|
||||
|
||||
foreach (var effect in reaction.Effects)
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Content.Shared.Chemistry
|
||||
|
||||
// If we have a source solution, use the reagent quantity we have left. Otherwise, use the reaction volume specified.
|
||||
var args = new ReagentEffectArgs(uid, null, source, reagent,
|
||||
source?.GetReagentQuantity(reagent.ID) ?? reactVolume, EntityManager, method, null);
|
||||
source?.GetReagentQuantity(reagent.ID) ?? reactVolume, EntityManager, method, 1f);
|
||||
|
||||
// First, check if the reagent wants to apply any effects.
|
||||
if (reagent.ReactiveEffects != null && reactive.ReactiveGroups != null)
|
||||
|
||||
@@ -83,6 +83,6 @@ namespace Content.Shared.Chemistry.Reagent
|
||||
FixedPoint2 Quantity,
|
||||
IEntityManager EntityManager,
|
||||
ReactionMethod? Method,
|
||||
ReagentEffectsEntry? MetabolismEffects
|
||||
float Scale
|
||||
);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace Content.Shared.Chemistry.Reagent
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var args = new ReagentEffectArgs(plantHolder.Value, null, solution, this, amount.Quantity, entMan, null, null);
|
||||
var args = new ReagentEffectArgs(plantHolder.Value, null, solution, this, amount.Quantity, entMan, null, 1f);
|
||||
foreach (var plantMetabolizable in PlantMetabolisms)
|
||||
{
|
||||
if (!plantMetabolizable.ShouldApply(args, random))
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
Alcohol:
|
||||
effects:
|
||||
- !type:Drunk
|
||||
boozePower: 3
|
||||
boozePower: 20
|
||||
|
||||
- type: reagent
|
||||
id: Gin
|
||||
|
||||
Reference in New Issue
Block a user