mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-26 18:17:12 +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)
215 lines
7.8 KiB
C#
215 lines
7.8 KiB
C#
using Content.Shared.Administration.Logs;
|
|
using Content.Shared.Contests;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Psionics;
|
|
using Content.Shared.Psionics.Glimmer;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Serialization;
|
|
using Content.Shared.Mobs.Systems;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.Rejuvenate;
|
|
|
|
namespace Content.Shared.Abilities.Psionics
|
|
{
|
|
public sealed class SharedPsionicAbilitiesSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popups = default!;
|
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
|
[Dependency] private readonly GlimmerSystem _glimmerSystem = default!;
|
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
|
[Dependency] private readonly ContestsSystem _contests = default!;
|
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<PsionicComponent, PsionicPowerUsedEvent>(OnPowerUsed);
|
|
SubscribeLocalEvent<PsionicComponent, RejuvenateEvent>(OnRejuvenate);
|
|
}
|
|
|
|
public bool OnAttemptPowerUse(EntityUid uid, string power, float? manacost = null, bool checkInsulation = true)
|
|
{
|
|
if (!TryComp<PsionicComponent>(uid, out var component)
|
|
|| HasComp<MindbrokenComponent>(uid)
|
|
|| checkInsulation
|
|
&& HasComp<PsionicInsulationComponent>(uid))
|
|
return false;
|
|
|
|
var tev = new OnAttemptPowerUseEvent(uid, power);
|
|
RaiseLocalEvent(uid, tev);
|
|
|
|
if (tev.Cancelled)
|
|
return false;
|
|
|
|
if (component.DoAfter is not null)
|
|
{
|
|
_popups.PopupEntity(Loc.GetString(component.AlreadyCasting), uid, uid, PopupType.LargeCaution);
|
|
return false;
|
|
}
|
|
|
|
if (manacost is null)
|
|
return true;
|
|
|
|
if (component.Mana >= manacost
|
|
|| component.BypassManaCheck)
|
|
{
|
|
var newmana = component.Mana - manacost;
|
|
component.Mana = newmana ?? component.Mana;
|
|
|
|
var ev = new OnManaUpdateEvent();
|
|
RaiseLocalEvent(uid, ref ev);
|
|
}
|
|
else
|
|
{
|
|
_popups.PopupEntity(Loc.GetString(component.NoMana), uid, uid, PopupType.LargeCaution);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private void OnPowerUsed(EntityUid uid, PsionicComponent component, PsionicPowerUsedEvent args)
|
|
{
|
|
foreach (var entity in _lookup.GetEntitiesInRange(uid, 10f))
|
|
{
|
|
if (HasComp<MetapsionicPowerComponent>(entity) && entity != uid && !(TryComp<PsionicInsulationComponent>(entity, out var insul) && !insul.Passthrough))
|
|
{
|
|
_popups.PopupEntity(Loc.GetString("metapsionic-pulse-power", ("power", args.Power)), entity, entity, PopupType.LargeCaution);
|
|
args.Handled = true;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void LogPowerUsed(EntityUid uid, string power, float minGlimmer = 8, float maxGlimmer = 12)
|
|
{
|
|
_adminLogger.Add(Database.LogType.Psionics, Database.LogImpact.Medium, $"{ToPrettyString(uid):player} used {power}");
|
|
var ev = new PsionicPowerUsedEvent(uid, power);
|
|
RaiseLocalEvent(uid, ev, false);
|
|
|
|
_glimmerSystem.DeltaGlimmerInput(_robustRandom.NextFloat(minGlimmer, maxGlimmer));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the CurrentAmplification of a given Entity, multiplied by the result of that Entity's MoodContest.
|
|
/// Higher mood means more Amplification, Lower mood means less Amplification.
|
|
/// </summary>
|
|
public float ModifiedAmplification(EntityUid uid)
|
|
{
|
|
if (!TryComp<PsionicComponent>(uid, out var psionicComponent))
|
|
return 1;
|
|
|
|
return ModifiedAmplification(uid, psionicComponent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the CurrentAmplification of a given Entity, multiplied by the result of that Entity's MoodContest.
|
|
/// Higher mood means more Amplification, Lower mood means less Amplification.
|
|
/// </summary>
|
|
public float ModifiedAmplification(EntityUid uid, PsionicComponent component)
|
|
{
|
|
return component.CurrentAmplification * _contests.MoodContest(uid, true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the CurrentDampening of a given Entity, multiplied by the result of that Entity's MoodContest.
|
|
/// Lower mood means more Dampening, higher mood means less Dampening.
|
|
/// </summary>
|
|
public float ModifiedDampening(EntityUid uid)
|
|
{
|
|
if (!TryComp<PsionicComponent>(uid, out var psionicComponent))
|
|
return 1;
|
|
|
|
return ModifiedDampening(uid, psionicComponent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the CurrentDampening of a given Entity, multiplied by the result of that Entity's MoodContest.
|
|
/// Lower mood means more Dampening, higher mood means less Dampening.
|
|
/// </summary>
|
|
public float ModifiedDampening(EntityUid uid, PsionicComponent component)
|
|
{
|
|
return component.CurrentDampening / _contests.MoodContest(uid, true);
|
|
}
|
|
|
|
public void OnRejuvenate(EntityUid uid, PsionicComponent component, RejuvenateEvent args)
|
|
{
|
|
component.Mana = component.MaxMana;
|
|
var ev = new OnManaUpdateEvent();
|
|
RaiseLocalEvent(uid, ref ev);
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
var query = EntityQueryEnumerator<PsionicComponent>();
|
|
while (query.MoveNext(out var uid, out var component))
|
|
{
|
|
if (_mobState.IsDead(uid)
|
|
|| HasComp<PsionicInsulationComponent>(uid))
|
|
continue;
|
|
|
|
component.ManaAccumulator += frameTime;
|
|
|
|
if (component.ManaAccumulator <= 1)
|
|
continue;
|
|
|
|
component.ManaAccumulator -= 1;
|
|
|
|
if (component.Mana > component.MaxMana)
|
|
component.Mana = component.MaxMana;
|
|
|
|
if (component.Mana < 0)
|
|
component.Mana = 0;
|
|
|
|
if (component.Mana < component.MaxMana)
|
|
{
|
|
var gainedmana = component.ManaGain * component.ManaGainMultiplier;
|
|
component.Mana += gainedmana;
|
|
FixedPoint2.Min(component.Mana, component.MaxMana);
|
|
|
|
var ev = new OnManaUpdateEvent();
|
|
RaiseLocalEvent(uid, ref ev);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public sealed class PsionicPowerUsedEvent : HandledEntityEventArgs
|
|
{
|
|
public EntityUid User { get; }
|
|
public string Power = string.Empty;
|
|
|
|
public PsionicPowerUsedEvent(EntityUid user, string power)
|
|
{
|
|
User = user;
|
|
Power = power;
|
|
}
|
|
}
|
|
|
|
public sealed class OnAttemptPowerUseEvent : CancellableEntityEventArgs
|
|
{
|
|
public EntityUid User { get; }
|
|
public string Power = string.Empty;
|
|
|
|
public OnAttemptPowerUseEvent(EntityUid user, string power)
|
|
{
|
|
User = user;
|
|
Power = power;
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
[NetSerializable]
|
|
public sealed class PsionicsChangedEvent : EntityEventArgs
|
|
{
|
|
public readonly NetEntity Euid;
|
|
public PsionicsChangedEvent(NetEntity euid)
|
|
{
|
|
Euid = euid;
|
|
}
|
|
}
|
|
}
|