mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-27 18:47:52 +03:00
# Description This PR brings back a feature that was present in the Psionic Refactor Version 1, which ultimately never made it into the game. I have substantially reworked the underlying math behind Glimmer, such that it operates on a Logistic Curve described by this equation:  Instead of 0 being the "Normal" amount of glimmer, the "Normal" amount is the "seemingly arbitrary" number 502.941. This number is measured first by taking the derivative of the Glimmer Equation, and then solving for the derivative equal to 1. Above this constant, glimmer grows exponentially more difficult to increase. Below this constant, glimmer grows exponentially easier to increase. It will thus constantly attempt to trend towards the "Glimmer Equilibrium". Probers, Drainers, Anomalies, and Glimmer Mites all cause glimmer to "Fluctuate", either up or down the graph. This gives a glimmer that swings constantly to both high and low values, with more violent swings being caused by having more probers/anomalies etc. A great deal of math functions have been implemented that allow for various uses for glimmer measurements, and psionic powers can even have their effects modified by said measurements. The most significant part of this rework is what's facing Epistemics. It's essentially no longer possible for Probers to cause a round-ending chain of events known as "Glimmerloose". You can ALWAYS recover from high glimmer, no matter how high it gets. As a counterpart to this, Probers have had the math behind their research point generation reworked. Research output follows an inverse log base 4 curve. Which can be found here: https://www.desmos.com/calculator/q183tseun8 I wouldn't drop this massive update on people without a way for them to understand what's going on. So this PR also features the return(and expansion of), the much-demanded Psionics Guidebook. <details><summary><h1>Media</h1></summary> <p> Psionics Guidebook   </p> </details> # Changelog 🆑 VMSolidus, Gollee - add: Glimmer has been substantially reworked. Please read the new Psionics Guidebook for more information. In short: "500 is the new normal glimmer. Stop panicking if Sophia says the glimmer is 500. Call code white if it gets to 750 and stays above that level." - add: The much-requested Psionics Guidebook has returned, now with all new up-to-date information. - remove: Removed "GLIMMERLOOSE". It's no longer possible for glimmer to start a chain of events that ends the round if epistemics isn't destroyed. You can ALWAYS recover from high glimmer now. - tweak: All glimmer events have had their thresholds tweaked to reflect the fact that 500 is the new "Normal" amount of glimmer. --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit 638071c48fe3ac7c727a1294de3b6d5d8136e79f)
136 lines
6.0 KiB
C#
136 lines
6.0 KiB
C#
using Content.Server.Anomaly.Components;
|
|
using Content.Server.Power.EntitySystems;
|
|
using Content.Server.Research.Components;
|
|
using Content.Shared.Anomaly.Components;
|
|
using Content.Shared.Mobs;
|
|
using Content.Shared.Psionics.Glimmer;
|
|
using Content.Shared.Power;
|
|
|
|
namespace Content.Server.Psionics.Glimmer;
|
|
|
|
/// <summary>
|
|
/// Handles structures which add/subtract glimmer.
|
|
/// </summary>
|
|
public sealed class GlimmerStructuresSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
|
|
[Dependency] private readonly GlimmerSystem _glimmerSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<AnomalyVesselComponent, PowerChangedEvent>(OnAnomalyVesselPowerChanged);
|
|
|
|
SubscribeLocalEvent<GlimmerSourceComponent, AnomalyPulseEvent>(OnAnomalyPulse);
|
|
SubscribeLocalEvent<GlimmerSourceComponent, AnomalySupercriticalEvent>(OnAnomalySupercritical);
|
|
SubscribeLocalEvent<GlimmerSourceComponent, MobStateChangedEvent>(OnMobStateChanged);
|
|
SubscribeLocalEvent<GlimmerSourceComponent, ComponentStartup>(OnInit);
|
|
}
|
|
|
|
private void OnInit(EntityUid uid, GlimmerSourceComponent component, ComponentStartup args)
|
|
{
|
|
if (component.ResearchPointGeneration != null)
|
|
{
|
|
EnsureComp<ResearchPointSourceComponent>(uid, out var points);
|
|
points.PointsPerSecond = component.ResearchPointGeneration.Value;
|
|
points.Active = true;
|
|
}
|
|
}
|
|
|
|
private void OnAnomalyVesselPowerChanged(EntityUid uid, AnomalyVesselComponent component, ref PowerChangedEvent args)
|
|
{
|
|
if (TryComp<GlimmerSourceComponent>(component.Anomaly, out var glimmerSource))
|
|
glimmerSource.Active = args.Powered;
|
|
}
|
|
|
|
private void OnAnomalyPulse(EntityUid uid, GlimmerSourceComponent component, ref AnomalyPulseEvent args)
|
|
{
|
|
// Anomalies are meant to have GlimmerSource on them with the
|
|
// active flag set to false, as they will be set to actively
|
|
// generate glimmer when scanned to an anomaly vessel for
|
|
// harvesting research points.
|
|
//
|
|
// It is not a bug that glimmer increases on pulse or
|
|
// supercritical with an inactive glimmer source.
|
|
//
|
|
// However, this will need to be reworked if a distinction
|
|
// needs to be made in the future. I suggest a GlimmerAnomaly
|
|
// component.
|
|
|
|
if (TryComp<AnomalyComponent>(uid, out var anomaly))
|
|
_glimmerSystem.DeltaGlimmerOutput(5f * anomaly.Severity);
|
|
}
|
|
|
|
private void OnAnomalySupercritical(EntityUid uid, GlimmerSourceComponent component, ref AnomalySupercriticalEvent args)
|
|
{
|
|
_glimmerSystem.DeltaGlimmerOutput(100);
|
|
}
|
|
|
|
private void OnMobStateChanged(EntityUid uid, GlimmerSourceComponent component, ref MobStateChangedEvent args)
|
|
{
|
|
if (args.NewMobState != MobState.Alive)
|
|
component.Active = false;
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
var glimmerSources = Count<GlimmerSourceComponent>();
|
|
foreach (var source in EntityQuery<GlimmerSourceComponent>())
|
|
{
|
|
if (!_powerReceiverSystem.IsPowered(source.Owner)
|
|
&& source.RequiresPower)
|
|
{
|
|
glimmerSources--;
|
|
continue;
|
|
}
|
|
|
|
if (!source.Active)
|
|
{
|
|
glimmerSources--;
|
|
continue;
|
|
}
|
|
|
|
source.Accumulator += frameTime;
|
|
|
|
if (source.Accumulator > source.SecondsPerGlimmer)
|
|
{
|
|
source.Accumulator -= source.SecondsPerGlimmer;
|
|
|
|
// https://www.desmos.com/calculator/zjzefpue03
|
|
// In Short: 1 prober makes 20 research points. 4 probers makes twice as many points as 1 prober. 9 probers makes 69 points in total between all 9.
|
|
// This is then modified by afterwards by GlimmerEquilibrium, to help smooth out the curves. But also, now if you have more drainers than probers, the probers won't generate research!
|
|
// Also, this counts things like Anomalies & Glimmer Mites! Which means scientists should be more encouraged to actively hunt mites.
|
|
// As a fun novelty, this means that a highly psionic Epistemics department can essentially "Study" their powers for actual research points!
|
|
if (source.ResearchPointGeneration != null
|
|
&& TryComp<ResearchPointSourceComponent>(source.Owner, out var research))
|
|
research.PointsPerSecond = (int) MathF.Round(
|
|
source.ResearchPointGeneration.Value
|
|
/ (MathF.Log(glimmerSources, 4) + 1)
|
|
* _glimmerSystem.GetGlimmerEquilibriumRatio());
|
|
|
|
// Shorthand explanation:
|
|
// This makes glimmer far more "Swingy", by making both positive and negative glimmer sources scale quite dramatically with glimmer
|
|
if (!_glimmerSystem.GetGlimmerEnabled())
|
|
return;
|
|
|
|
var glimmerEquilibrium = GlimmerSystem.GlimmerEquilibrium;
|
|
|
|
if (source.AddToGlimmer)
|
|
{
|
|
_glimmerSystem.DeltaGlimmerInput((_glimmerSystem.GlimmerOutput > glimmerEquilibrium
|
|
? MathF.Pow(_glimmerSystem.GetGlimmerOutputInteger() - source.GlimmerExponentOffset + glimmerSources, 2) : 1f)
|
|
* (_glimmerSystem.GlimmerOutput < glimmerEquilibrium ? _glimmerSystem.GetGlimmerEquilibriumRatio() : 1f));
|
|
}
|
|
else
|
|
{
|
|
_glimmerSystem.DeltaGlimmerInput(-(_glimmerSystem.GlimmerOutput > glimmerEquilibrium
|
|
? MathF.Pow(_glimmerSystem.GetGlimmerOutputInteger() - source.GlimmerExponentOffset + glimmerSources, 2) : 1f)
|
|
* (_glimmerSystem.GlimmerOutput > glimmerEquilibrium ? _glimmerSystem.GetGlimmerEquilibriumRatio() : 1f));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|