Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HealingWord & Revivify Bugs #949

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ private void OnPowerUsed(EntityUid uid, PsionicComponent component, PsionicHealO
else ActivatePower(uid, component, args);

if (args.PopupText is not null
&& _glimmer.Glimmer > args.GlimmerObviousPopupThreshold * component.CurrentDampening)
&& _glimmer.Glimmer > args.GlimmerPopupThreshold * component.CurrentDampening)
_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.GlimmerObviousSoundThreshold * component.CurrentDampening)
&& _glimmer.Glimmer > args.GlimmerSoundThreshold * component.CurrentDampening)
_audioSystem.PlayPvs(args.SoundUse, uid, args.AudioParams);

// Sanitize the Glimmer inputs because otherwise the game will crash if someone makes MaxGlimmer lower than MinGlimmer.
Expand All @@ -76,13 +76,16 @@ private void OnPowerUsed(EntityUid uid, PsionicComponent component, PsionicHealO
private void AttemptDoAfter(EntityUid uid, PsionicComponent component, PsionicHealOtherPowerActionEvent args)
{
var ev = new PsionicHealOtherDoAfterEvent(_gameTiming.CurTime);
ev.HealingAmount = args.HealingAmount;
ev.RotReduction = args.RotReduction;
if (args.HealingAmount is not null)
ev.HealingAmount = args.HealingAmount;
if (args.RotReduction is not null)
ev.RotReduction = args.RotReduction.Value;
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,
};

if (!_doAfterSystem.TryStartDoAfter(doAfterArgs, out var doAfterId))
Expand All @@ -104,23 +107,28 @@ private void OnDispelled(EntityUid uid, PsionicComponent component, DispelledEve
private void OnDoAfter(EntityUid uid, PsionicComponent component, PsionicHealOtherDoAfterEvent args)
{
// It's entirely possible for the caster to stop being Psionic(due to mindbreaking) mid cast
if (component is null)
if (component is null
|| args.Cancelled)
return;
component.DoAfter = null;

// The target can also cease existing mid-cast
if (args.Target is null)
return;

_rotting.ReduceAccumulator(args.Target.Value, TimeSpan.FromSeconds(args.RotReduction * component.CurrentAmplification));
if (args.RotReduction is not null)
_rotting.ReduceAccumulator(args.Target.Value, TimeSpan.FromSeconds(args.RotReduction.Value * component.CurrentAmplification));

if (!TryComp<DamageableComponent>(args.Target.Value, out var damageableComponent))
return;

_damageable.TryChangeDamage(args.Target.Value, args.HealingAmount * component.CurrentAmplification, true, false, damageableComponent, uid);
if (args.HealingAmount is not null)
_damageable.TryChangeDamage(args.Target.Value, args.HealingAmount * component.CurrentAmplification, true, false, damageableComponent, uid);

if (!args.DoRevive
|| !TryComp<MobStateComponent>(args.Target, out var mob)
|| _rotting.IsRotten(args.Target.Value)
|| !TryComp<MobStateComponent>(args.Target.Value, out var mob)
|| !_mobState.IsDead(args.Target.Value, mob)
|| !_mobThreshold.TryGetThresholdForState(args.Target.Value, MobState.Dead, out var threshold)
|| damageableComponent.TotalDamage > threshold)
return;
Expand All @@ -134,15 +142,19 @@ private void ActivatePower(EntityUid uid, PsionicComponent component, PsionicHea
if (component is null)
return;

_rotting.ReduceAccumulator(args.Target, TimeSpan.FromSeconds(args.RotReduction * component.CurrentAmplification));
if (args.RotReduction is not null)
_rotting.ReduceAccumulator(args.Target, TimeSpan.FromSeconds(args.RotReduction.Value * component.CurrentAmplification));

if (!TryComp<DamageableComponent>(args.Target, out var damageableComponent))
return;

_damageable.TryChangeDamage(args.Target, args.HealingAmount * component.CurrentAmplification, true, false, damageableComponent, uid);
if (args.HealingAmount is not null)
_damageable.TryChangeDamage(args.Target, args.HealingAmount * component.CurrentAmplification, true, false, damageableComponent, uid);

if (!args.DoRevive
|| _rotting.IsRotten(args.Target)
|| !TryComp<MobStateComponent>(args.Target, out var mob)
|| !_mobState.IsDead(args.Target, mob)
|| !_mobThreshold.TryGetThresholdForState(args.Target, MobState.Dead, out var threshold)
|| damageableComponent.TotalDamage > threshold)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Content.Shared.Actions.Events;
public sealed partial class PsionicHealOtherPowerActionEvent : EntityTargetActionEvent
{
[DataField]
public DamageSpecifier HealingAmount = default!;
public DamageSpecifier? HealingAmount = default!;

[DataField]
public string PowerName;
Expand All @@ -19,7 +19,7 @@ public sealed partial class PsionicHealOtherPowerActionEvent : EntityTargetActio
public string? PopupText;

[DataField]
public float RotReduction;
public float? RotReduction;

[DataField]
public bool DoRevive;
Expand All @@ -40,10 +40,13 @@ public sealed partial class PsionicHealOtherPowerActionEvent : EntityTargetActio
public int MaxGlimmer = 12;

[DataField]
public int GlimmerObviousSoundThreshold;
public int GlimmerSoundThreshold;

[DataField]
public int GlimmerObviousPopupThreshold;
public int GlimmerPopupThreshold;

[DataField]
public int GlimmerDoAfterVisibilityThreshold;

[DataField]
public PopupType PopupType = PopupType.Medium;
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Psionics/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public sealed partial class PsionicHealOtherDoAfterEvent : DoAfterEvent
public TimeSpan StartedAt;

[DataField]
public DamageSpecifier HealingAmount = default!;
public DamageSpecifier? HealingAmount = default!;

[DataField]
public float RotReduction;
public float? RotReduction;

[DataField]
public bool DoRevive;
Expand Down
10 changes: 6 additions & 4 deletions Resources/Prototypes/Actions/psionics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@
playSound: true
minGlimmer: 2
maxGlimmer: 4
glimmerObviousSoundThreshold: 100
glimmerObviousPopupThreshold: 200
glimmerSoundThreshold: 100
glimmerPopupThreshold: 200
glimmerDoAfterVisibilityThreshold: 70

- type: entity
id: ActionRevivify
Expand Down Expand Up @@ -217,5 +218,6 @@
playSound: true
minGlimmer: 10 # These also get multiplied by caster stats. So,
maxGlimmer: 15 # keeping in mind the ~3.5x multiplier, this spikes glimmer by as much as 60 points.
glimmerObviousSoundThreshold: 50
glimmerObviousPopupThreshold: 100
glimmerSoundThreshold: 50
glimmerPopupThreshold: 100
glimmerDoAfterVisibilityThreshold: 35
Loading