Files
space-station-14/Content.Server/EntityEffects/Effects/Botany/PlantMutateChemicalsEntityEffectSystem.cs
Princess Cheeseballs 4cd5d115bf Balance swing at Vestine (#42302)
* AAAAAAAAAAAAAAAAAAAAAAA

* whhops

* full range whoop

* less diff any%

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2026-01-13 07:29:34 +00:00

46 lines
1.9 KiB
C#

using Content.Server.Botany;
using Content.Server.Botany.Components;
using Content.Shared.EntityEffects;
using Content.Shared.EntityEffects.Effects.Botany;
using Content.Shared.FixedPoint;
using Content.Shared.Random.Helpers;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.EntityEffects.Effects.Botany;
public sealed partial class PlantMutateChemicalsEntityEffectSystem : EntityEffectSystem<PlantHolderComponent, PlantMutateChemicals>
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IRobustRandom _random = default!;
protected override void Effect(Entity<PlantHolderComponent> entity, ref EntityEffectEvent<PlantMutateChemicals> args)
{
if (entity.Comp.Seed == null)
return;
var chemicals = entity.Comp.Seed.Chemicals;
var randomChems = _proto.Index(args.Effect.RandomPickBotanyReagent);
// Add a random amount of a random chemical to this set of chemicals
var (chemicalId, quantity) = randomChems.Pick(_random);
var amount = FixedPoint2.Max(_random.NextFloat(0f, 1f) * quantity, FixedPoint2.Epsilon);
var seedChemQuantity = new SeedChemQuantity();
if (chemicals.ContainsKey(chemicalId))
{
seedChemQuantity.Min = chemicals[chemicalId].Min;
seedChemQuantity.Max = chemicals[chemicalId].Max + amount;
}
else
{
//Set the minimum to a fifth of the quantity to give some level of bad luck protection
seedChemQuantity.Min = FixedPoint2.Clamp(quantity / 5f, FixedPoint2.Epsilon, 1f);
seedChemQuantity.Max = seedChemQuantity.Min + amount;
seedChemQuantity.Inherent = false;
}
var potencyDivisor = 100f / seedChemQuantity.Max;
seedChemQuantity.PotencyDivisor = (float) potencyDivisor;
chemicals[chemicalId] = seedChemQuantity;
}
}