Skip to content

Commit

Permalink
Glimmer Rework 1: "Swingy Glimmer" (DeltaV-Station#1480)
Browse files Browse the repository at this point in the history
# 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:


![GlimmerEquation](https://github.com/user-attachments/assets/b079c0f6-5944-408f-adf6-170b8472d6c2)

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

![image](https://github.com/user-attachments/assets/6449f518-bdce-4ba5-a9f5-9f87b5c424c9)


![image](https://github.com/user-attachments/assets/5cf5d5a1-8567-40ae-a020-af074cf9abe3)

</p>
</details>

# Changelog

:cl: 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 <[email protected]>
  • Loading branch information
VMSolidus authored Jan 17, 2025
1 parent 3a1c2dd commit 638071c
Show file tree
Hide file tree
Showing 81 changed files with 1,060 additions and 590 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PanelContainer StyleClasses="BackgroundDark"></PanelContainer>
<BoxContainer Name="SettingsBox" Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="False">
<Label Text="{Loc 'glimmer-monitor-interval'}"/>
<Button Name="IntervalButton6s" Access="Public" Text="6s" StyleClasses="OpenRight"/>
<Button Name="IntervalButton1" Access="Public" Text="1m" StyleClasses="OpenRight"/>
<Button Name="IntervalButton5" Access="Public" Text="5m" StyleClasses="OpenBoth"/>
<Button Name="IntervalButton10" Access="Public" Text="10m" StyleClasses="OpenLeft"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ public GlimmerMonitorUiFragment()
VerticalExpand = true;

var intervalGroup = new ButtonGroup();
IntervalButton6s.Group = intervalGroup;
IntervalButton1.Group = intervalGroup;
IntervalButton5.Group = intervalGroup;
IntervalButton10.Group = intervalGroup;

IntervalButton1.Pressed = true;
IntervalButton6s.Pressed = true;

IntervalButton6s.OnPressed += _ => UpdateState(_cachedValues);
IntervalButton1.OnPressed += _ => UpdateState(_cachedValues);
IntervalButton5.OnPressed += _ => UpdateState(_cachedValues);
IntervalButton10.OnPressed += _ => UpdateState(_cachedValues);
Expand Down Expand Up @@ -62,14 +64,12 @@ private List<int> FormatGlimmerValues(List<int> glimmerValues)
{
var returnList = glimmerValues;

if (IntervalButton5.Pressed)
{
returnList = GetAveragedList(glimmerValues, 5);
}
else if (IntervalButton10.Pressed)
{
if (IntervalButton1.Pressed)
returnList = GetAveragedList(glimmerValues, 10);
}
else if (IntervalButton5.Pressed)
returnList = GetAveragedList(glimmerValues, 50);
else if (IntervalButton10.Pressed)
returnList = GetAveragedList(glimmerValues, 100);

return ClipToFifteen(returnList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void SpawnEntities(EntityUid uid, PsionicComponent component, EntitySpaw
component.CurrentDampening,
component.CurrentAmplification,
entry.Settings,
_glimmerSystem.Glimmer / 1000,
_glimmerSystem.GlimmerOutput / 1000,
component.CurrentAmplification,
component.CurrentAmplification);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ private void OnPowerUsed(EntityUid uid, PsionicComponent component, PsionicHealO
else ActivatePower(uid, component, args);

if (args.PopupText is not null
&& _glimmer.Glimmer > args.GlimmerPopupThreshold * args.ModifiedDampening)
&& _glimmer.GlimmerOutput > args.GlimmerPopupThreshold * args.ModifiedDampening)
_popupSystem.PopupEntity(Loc.GetString(args.PopupText, ("entity", uid)), uid,
Filter.Pvs(uid).RemoveWhereAttachedEntity(entity => !_examine.InRangeUnOccluded(uid, entity, ExamineRange, null)),
true,
args.PopupType);

if (args.PlaySound
&& _glimmer.Glimmer > args.GlimmerSoundThreshold * args.ModifiedDampening)
&& _glimmer.GlimmerOutput > args.GlimmerSoundThreshold * args.ModifiedDampening)
_audioSystem.PlayPvs(args.SoundUse, uid, args.AudioParams);

// Sanitize the Glimmer inputs because otherwise the game will crash if someone makes MaxGlimmer lower than MinGlimmer.
var minGlimmer = (int) Math.Round(MathF.MinMagnitude(args.MinGlimmer, args.MaxGlimmer)
* args.ModifiedAmplification - args.ModifiedDampening);
var maxGlimmer = (int) Math.Round(MathF.MaxMagnitude(args.MinGlimmer, args.MaxGlimmer)
* args.ModifiedAmplification - args.ModifiedDampening);
var minGlimmer = MathF.MinMagnitude(args.MinGlimmer, args.MaxGlimmer)
* args.ModifiedAmplification - args.ModifiedDampening;
var maxGlimmer = MathF.MaxMagnitude(args.MinGlimmer, args.MaxGlimmer)
* args.ModifiedAmplification - args.ModifiedDampening;

_psionics.LogPowerUsed(uid, args.PowerName, minGlimmer, maxGlimmer);
args.Handled = true;
Expand All @@ -89,7 +89,7 @@ private void AttemptDoAfter(EntityUid uid, PsionicComponent component, PsionicHe
var doAfterArgs = new DoAfterArgs(EntityManager, uid, args.UseDelay, ev, uid, target: args.Target)
{
BreakOnMove = args.BreakOnMove,
Hidden = _glimmer.Glimmer > args.GlimmerDoAfterVisibilityThreshold * args.ModifiedDampening,
Hidden = _glimmer.GlimmerOutput > args.GlimmerDoAfterVisibilityThreshold * args.ModifiedDampening,
};

if (!_doAfterSystem.TryStartDoAfter(doAfterArgs, out var doAfterId))
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Abilities/Psionics/AnomalyPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void OnPowerUsed(EntityUid uid, PsionicComponent component, AnomalyPower
if (!_psionics.OnAttemptPowerUse(args.Performer, args.Settings.PowerName, args.Settings.ManaCost, args.Settings.CheckInsulation))
return;

var overcharged = args.Settings.DoSupercritical ? _glimmerSystem.Glimmer * component.CurrentAmplification
var overcharged = args.Settings.DoSupercritical ? _glimmerSystem.GlimmerOutput * component.CurrentAmplification
> Math.Min(args.Settings.SupercriticalThreshold * component.CurrentDampening, args.Settings.MaxSupercriticalThreshold)
: false;

Expand Down Expand Up @@ -84,7 +84,7 @@ public void DoAnomalySounds(EntityUid uid, PsionicComponent component, AnomalyPo
}

if (args.Settings.PulseSound is null
|| _glimmerSystem.Glimmer < args.Settings.GlimmerSoundThreshold * component.CurrentDampening)
|| _glimmerSystem.GlimmerOutput < args.Settings.GlimmerSoundThreshold * component.CurrentDampening)
return;

_audio.PlayEntity(args.Settings.PulseSound, uid, uid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public override void OnAddPsionic(
public sealed partial class PsionicModifyGlimmer : PsionicPowerFunction
{
[DataField]
public int GlimmerModifier;
public float GlimmerModifier;

public override void OnAddPsionic(
EntityUid uid,
Expand All @@ -477,7 +477,7 @@ public override void OnAddPsionic(
PsionicPowerPrototype proto)
{
var glimmerSystem = entityManager.System<GlimmerSystem>();
glimmerSystem.Glimmer += GlimmerModifier;
glimmerSystem.DeltaGlimmerInput(GlimmerModifier);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Chapel/SacrificialAltarSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void OnDoAfter(Entity<SacrificialAltarComponent> ent, ref SacrificeDoAft
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(args.Args.User):player} sacrificed {ToPrettyString(target):target} on {ToPrettyString(ent):altar}");

// lower glimmer by a random amount
_glimmer.Glimmer -= (int) (ent.Comp.GlimmerReduction * psionic.CurrentAmplification);
_glimmer.DeltaGlimmerInput(ent.Comp.GlimmerReduction * psionic.CurrentAmplification);

if (ent.Comp.RewardPool is not null && _random.Prob(ent.Comp.BaseItemChance * psionic.CurrentDampening))
{
Expand Down
8 changes: 4 additions & 4 deletions Content.Server/Chat/TelepathicChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ public void SendTelepathicChat(EntityUid source, string message, bool hideChat)
}

if (_random.Prob(0.1f))
_glimmerSystem.Glimmer++;
_glimmerSystem.DeltaGlimmerInput(1);

if (_random.Prob(Math.Min(0.33f + (float) _glimmerSystem.Glimmer / 1500, 1)))
if (_random.Prob(Math.Min(0.33f + (float) _glimmerSystem.GlimmerOutput / 1500, 1)))
{
float obfuscation = 0.25f + (float) _glimmerSystem.Glimmer / 2000;
float obfuscation = 0.25f + (float) _glimmerSystem.GlimmerOutput / 2000;
var obfuscated = ObfuscateMessageReadability(message, obfuscation);
_chatManager.ChatMessageToMany(ChatChannel.Telepathic, obfuscated, messageWrap, source, hideChat, false, GetDreamers(clients.normal.Concat(clients.psychog)), Color.PaleVioletRed);
}
Expand Down Expand Up @@ -149,4 +149,4 @@ private string ObfuscateMessageReadability(string message, float chance)

return modifiedMessage.ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public sealed partial class ChangeGlimmerReactionEffect : EntityEffect
/// <summary>
/// Added to glimmer when reaction occurs.
/// </summary>
[DataField("count")]
public int Count = 1;
[DataField]
public float Count = 1;

public override void Effect(EntityEffectBaseArgs args)
{
Expand All @@ -25,6 +25,6 @@ public override void Effect(EntityEffectBaseArgs args)

var glimmerSystem = args.EntityManager.EntitySysManager.GetEntitySystem<GlimmerSystem>();

glimmerSystem.Glimmer += Count;
glimmerSystem.DeltaGlimmerInput(Count);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace Content.Server.Objectives.Components;

/// <summary>
/// Requires that the player dies to be complete.
/// Requires that the player ensures glimmer remain above a specific amount.
/// </summary>
[RegisterComponent, Access(typeof(RaiseGlimmerConditionSystem))]
public sealed partial class RaiseGlimmerConditionComponent : Component
{
[DataField("target"), ViewVariables(VVAccess.ReadWrite)]
public int Target;
}
[DataField]
public float Target;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public sealed class RaiseGlimmerConditionSystem : EntitySystem
{
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly GlimmerSystem _glimmer = default!;
public override void Initialize()
{
base.Initialize();
Expand All @@ -30,10 +31,9 @@ private void OnGetProgress(EntityUid uid, RaiseGlimmerConditionComponent comp, r
args.Progress = GetProgress(comp.Target);
}

private float GetProgress(int target)
private float GetProgress(float target)
{
var glimmer = _sysMan.GetEntitySystem<GlimmerSystem>().Glimmer;
var progress = Math.Min((float) glimmer / (float) target, 1f);
var progress = Math.Min(_glimmer.GlimmerOutput / target, 1f);
return progress;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override void Update(float frameTime)
{
base.Update(frameTime);

if (_glimmerSystem.Glimmer == 0)
if (_glimmerSystem.GlimmerOutput == 0)
return; // yes, return. Glimmer value is global.

var curTime = _timing.CurTime;
Expand All @@ -38,7 +38,7 @@ public override void Update(float frameTime)
if (!TryComp<IntrinsicRadioTransmitterComponent>(scribe, out var radio))
continue;

var message = Loc.GetString("glimmer-report", ("level", _glimmerSystem.Glimmer));
var message = Loc.GetString("glimmer-report", ("level", _glimmerSystem.GlimmerOutput));
var channel = _prototypeManager.Index<RadioChannelPrototype>("Science");
_radioSystem.SendRadioMessage(scribe, message, channel, scribe);

Expand All @@ -62,7 +62,7 @@ private void OnInteractHand(EntityUid uid, SophicScribeComponent component, Inte

component.StateTime = _timing.CurTime + component.StateCD;

_chat.TrySendInGameICMessage(uid, Loc.GetString("glimmer-report", ("level", _glimmerSystem.Glimmer)), InGameICChatType.Speak, true);
_chat.TrySendInGameICMessage(uid, Loc.GetString("glimmer-report", ("level", _glimmerSystem.GlimmerOutput)), InGameICChatType.Speak, true);
}

private void OnGlimmerEventEnded(GlimmerEventEndedEvent args)
Expand All @@ -79,7 +79,7 @@ private void OnGlimmerEventEnded(GlimmerEventEndedEvent args)
speaker = swapped.OriginalEntity;
}

var message = Loc.GetString(args.Message, ("decrease", args.GlimmerBurned), ("level", _glimmerSystem.Glimmer));
var message = Loc.GetString(args.Message, ("decrease", args.GlimmerBurned), ("level", _glimmerSystem.GlimmerOutput));
var channel = _prototypeManager.Index<RadioChannelPrototype>("Common");
_radioSystem.SendRadioMessage(speaker, message, channel, speaker);
}
Expand Down
11 changes: 8 additions & 3 deletions Content.Server/Psionics/Glimmer/GlimmerCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,29 @@ public sealed class GlimmerShowCommand : IConsoleCommand
public async void Execute(IConsoleShell shell, string argStr, string[] args)
{
var entMan = IoCManager.Resolve<IEntityManager>();
shell.WriteLine(entMan.EntitySysManager.GetEntitySystem<GlimmerSystem>().Glimmer.ToString());
shell.WriteLine(entMan.EntitySysManager.GetEntitySystem<GlimmerSystem>().GlimmerOutput.ToString("#.##"));
}
}

[AdminCommand(AdminFlags.Debug)]
public sealed class GlimmerSetCommand : IConsoleCommand
{
// SetGlimmerOutput cannot accept inputs greater than or equal to this number. The equation spits out imaginary number solutions past this point.
private const int MaxGlimmer = 1000;

public string Command => "glimmerset";
public string Description => Loc.GetString("command-glimmerset-description");
public string Help => Loc.GetString("command-glimmerset-help");

public async void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1
|| !int.TryParse(args[0], out var glimmerValue))
|| !float.TryParse(args[0], out var glimmerValue)
|| glimmerValue >= MaxGlimmer || glimmerValue < 0)
return;

var entMan = IoCManager.Resolve<IEntityManager>();
entMan.EntitySysManager.GetEntitySystem<GlimmerSystem>().Glimmer = glimmerValue;
var glimmerSystem = entMan.System<GlimmerSystem>();
glimmerSystem.SetGlimmerOutput(glimmerValue);
}
}
Loading

0 comments on commit 638071c

Please sign in to comment.