Files
wwdpublic/Content.Server/StationEvents/Events/NoosphericFryRule.cs
VMSolidus 4d2e140858 Glimmer Rework 1: "Swingy Glimmer" (#1480)
# 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

🆑 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)
2025-01-20 20:50:02 +03:00

137 lines
6.0 KiB
C#

using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.GameTicking.Components;
using Content.Shared.Construction.EntitySystems;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Psionics.Glimmer;
using Content.Server.StationEvents.Components;
using Content.Shared.Abilities.Psionics;
using Content.Shared.Damage;
using Content.Shared.Inventory;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Psionics.Glimmer;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map.Components;
namespace Content.Server.StationEvents.Events;
/// <summary>
/// Fries tinfoil hats and cages
/// </summary>
internal sealed class NoosphericFryRule : StationEventSystem<NoosphericFryRuleComponent>
{
[Dependency] private readonly SharedMapSystem _sharedMapSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly GlimmerSystem _glimmerSystem = default!;
[Dependency] private readonly FlammableSystem _flammableSystem = default!;
[Dependency] private readonly GlimmerReactiveSystem _glimmerReactiveSystem = default!;
[Dependency] private readonly AnchorableSystem _anchorableSystem = default!;
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
protected override void Started(EntityUid uid, NoosphericFryRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
List<(EntityUid wearer, TinfoilHatComponent worn)> psionicList = new();
var query = EntityQueryEnumerator<PsionicInsulationComponent, MobStateComponent>();
while (query.MoveNext(out var psion, out _, out _))
{
if (!_mobStateSystem.IsAlive(psion))
continue;
if (!_inventorySystem.TryGetSlotEntity(psion, "head", out var headItem))
continue;
if (!TryComp<TinfoilHatComponent>(headItem, out var tinfoil))
continue;
psionicList.Add((psion, tinfoil));
}
foreach (var pair in psionicList)
{
if (pair.worn.DestroyOnFry)
{
QueueDel(pair.worn.Owner);
Spawn("Ash", Transform(pair.wearer).Coordinates);
_popupSystem.PopupEntity(Loc.GetString("psionic-burns-up", ("item", pair.worn.Owner)), pair.wearer, Filter.Pvs(pair.worn.Owner), true, Shared.Popups.PopupType.MediumCaution);
_audioSystem.PlayEntity("/Audio/Effects/lightburn.ogg", Filter.Pvs(pair.worn.Owner), pair.worn.Owner, true);
} else
{
_popupSystem.PopupEntity(Loc.GetString("psionic-burn-resist", ("item", pair.worn.Owner)), pair.wearer, Filter.Pvs(pair.worn.Owner), true, Shared.Popups.PopupType.SmallCaution);
_audioSystem.PlayEntity("/Audio/Effects/lightburn.ogg", Filter.Pvs(pair.worn.Owner), pair.worn.Owner, true);
}
DamageSpecifier damage = new();
damage.DamageDict.Add("Heat", 2.5);
damage.DamageDict.Add("Shock", 2.5);
if (_glimmerSystem.GlimmerOutput > component.FryHeadgearMinorThreshold && _glimmerSystem.GlimmerOutput < component.FryHeadgearMajorThreshold)
{
damage *= 2;
if (TryComp<FlammableComponent>(pair.wearer, out var flammableComponent))
{
flammableComponent.FireStacks += 1;
_flammableSystem.Ignite(pair.wearer, pair.wearer, flammableComponent);
}
} else if (_glimmerSystem.GlimmerOutput > component.FryHeadgearMajorThreshold)
{
damage *= 3;
if (TryComp<FlammableComponent>(pair.wearer, out var flammableComponent))
{
flammableComponent.FireStacks += 2;
_flammableSystem.Ignite(pair.wearer, pair.wearer, flammableComponent);
}
}
_damageableSystem.TryChangeDamage(pair.wearer, damage, true, true);
}
// for probers:
var queryReactive = EntityQueryEnumerator<SharedGlimmerReactiveComponent, TransformComponent, PhysicsComponent>();
while (queryReactive.MoveNext(out var reactive, out _, out var xform, out var physics))
{
// shoot out three bolts of lighting...
_glimmerReactiveSystem.BeamRandomNearProber(reactive, 3, 12);
// try to anchor if we can
if (!xform.Anchored)
{
var coordinates = xform.Coordinates;
var gridUid = xform.GridUid;
if (gridUid == null)
continue;
if (!TryComp<MapGridComponent>(gridUid, out var grid))
continue;
var tileIndices = _sharedMapSystem.TileIndicesFor((EntityUid) gridUid, grid, coordinates);
if (_anchorableSystem.TileFree(grid, tileIndices, physics.CollisionLayer, physics.CollisionMask))
_transformSystem.AnchorEntity(reactive, xform);
}
if (!TryComp<ApcPowerReceiverComponent>(reactive, out var power))
continue;
// If it's been turned off, turn it back on.
if (power.PowerDisabled)
_powerReceiverSystem.TogglePower(reactive, false);
}
}
}