diff --git a/Content.Server/Abilities/Psionics/Abilities/HealOtherPowerSystem.cs b/Content.Server/Abilities/Psionics/Abilities/HealOtherPowerSystem.cs index fa6eb7536b..138a341ce8 100644 --- a/Content.Server/Abilities/Psionics/Abilities/HealOtherPowerSystem.cs +++ b/Content.Server/Abilities/Psionics/Abilities/HealOtherPowerSystem.cs @@ -32,7 +32,6 @@ public sealed class RevivifyPowerSystem : EntitySystem [Dependency] private readonly MobStateSystem _mobState = default!; [Dependency] private readonly GlimmerSystem _glimmer = default!; - public override void Initialize() { base.Initialize(); @@ -48,26 +47,29 @@ private void OnPowerUsed(EntityUid uid, PsionicComponent component, PsionicHealO if (component.DoAfter is not null) return; + args.ModifiedAmplification = _psionics.ModifiedAmplification(uid, component); + args.ModifiedDampening = _psionics.ModifiedDampening(uid, component); + if (!args.Immediate) AttemptDoAfter(uid, component, args); else ActivatePower(uid, component, args); if (args.PopupText is not null - && _glimmer.Glimmer > args.GlimmerPopupThreshold * component.CurrentDampening) + && _glimmer.Glimmer > 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 * component.CurrentDampening) + && _glimmer.Glimmer > 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) - + component.CurrentAmplification - component.CurrentDampening); + * args.ModifiedAmplification - args.ModifiedDampening); var maxGlimmer = (int) Math.Round(MathF.MaxMagnitude(args.MinGlimmer, args.MaxGlimmer) - + component.CurrentAmplification - component.CurrentDampening); + * args.ModifiedAmplification - args.ModifiedDampening); _psionics.LogPowerUsed(uid, args.PowerName, minGlimmer, maxGlimmer); args.Handled = true; @@ -80,12 +82,15 @@ private void AttemptDoAfter(EntityUid uid, PsionicComponent component, PsionicHe ev.HealingAmount = args.HealingAmount; if (args.RotReduction is not null) ev.RotReduction = args.RotReduction.Value; + + ev.ModifiedAmplification = args.ModifiedAmplification; + ev.ModifiedDampening = args.ModifiedDampening; ev.DoRevive = args.DoRevive; var doAfterArgs = new DoAfterArgs(EntityManager, uid, args.UseDelay, ev, uid, target: args.Target) { BreakOnUserMove = args.BreakOnUserMove, BreakOnTargetMove = args.BreakOnTargetMove, - Hidden = _glimmer.Glimmer > args.GlimmerDoAfterVisibilityThreshold * component.CurrentDampening, + Hidden = _glimmer.Glimmer > args.GlimmerDoAfterVisibilityThreshold * args.ModifiedDampening, }; if (!_doAfterSystem.TryStartDoAfter(doAfterArgs, out var doAfterId)) @@ -118,13 +123,13 @@ private void OnDoAfter(EntityUid uid, PsionicComponent component, PsionicHealOth return; if (args.RotReduction is not null) - _rotting.ReduceAccumulator(args.Target.Value, TimeSpan.FromSeconds(args.RotReduction.Value * component.CurrentAmplification)); + _rotting.ReduceAccumulator(args.Target.Value, TimeSpan.FromSeconds(args.RotReduction.Value * args.ModifiedAmplification)); if (!TryComp(args.Target.Value, out var damageableComponent)) return; if (args.HealingAmount is not null) - _damageable.TryChangeDamage(args.Target.Value, args.HealingAmount * component.CurrentAmplification, true, false, damageableComponent, uid); + _damageable.TryChangeDamage(args.Target.Value, args.HealingAmount * args.ModifiedAmplification, true, false, damageableComponent, uid); if (!args.DoRevive || _rotting.IsRotten(args.Target.Value) @@ -144,13 +149,13 @@ private void ActivatePower(EntityUid uid, PsionicComponent component, PsionicHea return; if (args.RotReduction is not null) - _rotting.ReduceAccumulator(args.Target, TimeSpan.FromSeconds(args.RotReduction.Value * component.CurrentAmplification)); + _rotting.ReduceAccumulator(args.Target, TimeSpan.FromSeconds(args.RotReduction.Value * args.ModifiedAmplification)); if (!TryComp(args.Target, out var damageableComponent)) return; if (args.HealingAmount is not null) - _damageable.TryChangeDamage(args.Target, args.HealingAmount * component.CurrentAmplification, true, false, damageableComponent, uid); + _damageable.TryChangeDamage(args.Target, args.HealingAmount * args.ModifiedAmplification, true, false, damageableComponent, uid); if (!args.DoRevive || _rotting.IsRotten(args.Target) diff --git a/Content.Shared/Actions/Events/PsionicHealOtherPowerActionEvent.cs b/Content.Shared/Actions/Events/PsionicHealOtherPowerActionEvent.cs index 0001c7842d..cdcba6740c 100644 --- a/Content.Shared/Actions/Events/PsionicHealOtherPowerActionEvent.cs +++ b/Content.Shared/Actions/Events/PsionicHealOtherPowerActionEvent.cs @@ -5,11 +5,21 @@ namespace Content.Shared.Actions.Events; public sealed partial class PsionicHealOtherPowerActionEvent : EntityTargetActionEvent { + /// + /// Caster's Amplification that has been modified by the results of a MoodContest. + /// + public float ModifiedAmplification = default!; + + /// + /// Caster's Dampening that has been modified by the results of a MoodContest. + /// + public float ModifiedDampening = default!; + [DataField] public DamageSpecifier? HealingAmount = default!; [DataField] - public string PowerName; + public string PowerName = default!; /// Controls whether or not a power fires immediately and with no DoAfter [DataField] diff --git a/Content.Shared/Psionics/Events.cs b/Content.Shared/Psionics/Events.cs index 744dd3b6ea..68ec3097e7 100644 --- a/Content.Shared/Psionics/Events.cs +++ b/Content.Shared/Psionics/Events.cs @@ -50,6 +50,16 @@ public sealed partial class PsionicHealOtherDoAfterEvent : DoAfterEvent [DataField] public bool DoRevive; + /// + /// Caster's Amplification that has been modified by the results of a MoodContest. + /// + public float ModifiedAmplification = default!; + + /// + /// Caster's Dampening that has been modified by the results of a MoodContest. + /// + public float ModifiedDampening = default!; + public PsionicHealOtherDoAfterEvent(TimeSpan startedAt) { StartedAt = startedAt; diff --git a/Content.Shared/Psionics/SharedPsionicAbilitiesSystem.cs b/Content.Shared/Psionics/SharedPsionicAbilitiesSystem.cs index f1f03bcb9e..2792864568 100644 --- a/Content.Shared/Psionics/SharedPsionicAbilitiesSystem.cs +++ b/Content.Shared/Psionics/SharedPsionicAbilitiesSystem.cs @@ -1,4 +1,5 @@ using Content.Shared.Administration.Logs; +using Content.Shared.Contests; using Content.Shared.Popups; using Content.Shared.Psionics.Glimmer; using Robust.Shared.Random; @@ -13,6 +14,7 @@ public sealed class SharedPsionicAbilitiesSystem : EntitySystem [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly GlimmerSystem _glimmerSystem = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly ContestsSystem _contests = default!; public override void Initialize() { @@ -41,6 +43,48 @@ public void LogPowerUsed(EntityUid uid, string power, int minGlimmer = 8, int ma _glimmerSystem.Glimmer += _robustRandom.Next(minGlimmer, maxGlimmer); } + + /// + /// 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. + /// + public float ModifiedAmplification(EntityUid uid) + { + if (!TryComp(uid, out var psionicComponent)) + return 1; + + return ModifiedAmplification(uid, psionicComponent); + } + + /// + /// 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. + /// + public float ModifiedAmplification(EntityUid uid, PsionicComponent component) + { + return component.CurrentAmplification * _contests.MoodContest(uid, true); + } + + /// + /// 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. + /// + public float ModifiedDampening(EntityUid uid) + { + if (!TryComp(uid, out var psionicComponent)) + return 1; + + return ModifiedDampening(uid, psionicComponent); + } + + /// + /// 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. + /// + public float ModifiedDampening(EntityUid uid, PsionicComponent component) + { + return component.CurrentDampening / _contests.MoodContest(uid, true); + } } public sealed class PsionicPowerUsedEvent : HandledEntityEventArgs