Skip to content

Commit

Permalink
Update Probers and Power Cooldown Scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Jul 9, 2024
1 parent a96e9e1 commit 5090aab
Show file tree
Hide file tree
Showing 13 changed files with 210 additions and 135 deletions.
32 changes: 16 additions & 16 deletions Content.Server/Psionics/Abilities/DispelPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<DispelPowerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<DispelPowerComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<DispelPowerActionEvent>(OnPowerUsed);
SubscribeLocalEvent<DispelPowerComponent, DispelPowerActionEvent>(OnPowerUsed);

SubscribeLocalEvent<DispellableComponent, DispelledEvent>(OnDispelled);
SubscribeLocalEvent<DamageOnDispelComponent, DispelledEvent>(OnDmgDispelled);
Expand All @@ -44,18 +44,17 @@ public override void Initialize()

private void OnInit(EntityUid uid, DispelPowerComponent component, ComponentInit args)
{
_actions.AddAction(uid, ref component.DispelActionEntity, component.DispelActionId );
_actions.TryGetActionData( component.DispelActionEntity, out var actionData );
EnsureComp<PsionicComponent>(uid, out var psionic);
_actions.AddAction(uid, ref component.DispelActionEntity, component.DispelActionId);
_actions.TryGetActionData(component.DispelActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.StartUseDelay(component.DispelActionEntity);
if (TryComp<PsionicComponent>(uid, out var psionic))
{
psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.DispelFeedback);
//It's fully intended that Dispel doesn't increase Amplification, and instead heavily spikes Dampening
//Antimage archetype.
psionic.Dampening += 1f;
}
_actions.SetCooldown(component.DispelActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));

psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.DispelFeedback);
//It's fully intended that Dispel doesn't increase Amplification, and instead heavily spikes Dampening
//Antimage archetype.
psionic.Dampening += 1f;
}

private void OnShutdown(EntityUid uid, DispelPowerComponent component, ComponentShutdown args)
Expand All @@ -70,18 +69,19 @@ private void OnShutdown(EntityUid uid, DispelPowerComponent component, Component
}
}

private void OnPowerUsed(DispelPowerActionEvent args)
private void OnPowerUsed(EntityUid uid, DispelPowerComponent component, DispelPowerActionEvent args)
{
if (HasComp<PsionicInsulationComponent>(args.Target) || HasComp<PsionicInsulationComponent>(args.Performer))
return;
if (!TryComp<PsionicComponent>(args.Performer, out var psionic) || !HasComp<PsionicComponent>(args.Target))
if (!_psionics.CheckCanTargetCast(uid, args.Target, out var psionic))
return;

var ev = new DispelledEvent();
RaiseLocalEvent(args.Target, ev, false);

if (ev.Handled)
{
_actions.TryGetActionData(component.DispelActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.SetCooldown(component.DispelActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));
args.Handled = true;
_psionics.LogPowerUsed(args.Performer, "dispel", psionic, 1, 1, true);

Expand Down
36 changes: 17 additions & 19 deletions Content.Server/Psionics/Abilities/MetapsionicPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,30 @@ public override void Initialize()

private void OnInit(EntityUid uid, MetapsionicPowerComponent component, ComponentInit args)
{
EnsureComp<PsionicComponent>(uid, out var psionic);
if (!TryComp(uid, out ActionsComponent? comp))
return;
_actions.AddAction(uid, ref component.ActionWideMetapsionicEntity, component.ActionWideMetapsionic, component: comp);
_actions.AddAction(uid, ref component.ActionFocusedMetapsionicEntity, component.ActionFocusedMetapsionic, component: comp);
_actions.TryGetActionData(component.ActionWideMetapsionicEntity, out var actionData);
if (actionData is { UseDelay: not null })
{
_actions.StartUseDelay(component.ActionWideMetapsionicEntity);
_actions.StartUseDelay(component.ActionFocusedMetapsionicEntity);
}
if (TryComp<PsionicComponent>(uid, out var psionic))
{
psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.MetapsionicFeedback);
psionic.Amplification += 0.1f;
psionic.Dampening += 0.5f;
}
UpdateActions(uid, component, psionic);

psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.MetapsionicFeedback);
psionic.Amplification += 0.1f;
psionic.Dampening += 0.5f;
}

private void UpdateActions(EntityUid uid, MetapsionicPowerComponent? component = null)
private void UpdateActions(EntityUid uid, MetapsionicPowerComponent? component = null, PsionicComponent? psionic = null)
{
if (!Resolve(uid, ref component))
if (!Resolve(uid, ref component) || !Resolve(uid, ref psionic)
|| !_actions.TryGetActionData(component.ActionWideMetapsionicEntity, out var actionData))
return;
_actions.StartUseDelay(component.ActionWideMetapsionicEntity);
_actions.StartUseDelay(component.ActionFocusedMetapsionicEntity);

if (actionData is { UseDelay: not null })
{
_actions.SetCooldown(component.ActionWideMetapsionicEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));
_actions.SetCooldown(component.ActionFocusedMetapsionicEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));
}
}

private void OnShutdown(EntityUid uid, MetapsionicPowerComponent component, ComponentShutdown args)
Expand Down Expand Up @@ -95,7 +93,7 @@ private void OnWidePowerUsed(EntityUid uid, MetapsionicPowerComponent component,
}
_popups.PopupEntity(Loc.GetString("metapsionic-pulse-failure"), uid, uid, PopupType.Large);
_psionics.LogPowerUsed(uid, "metapsionic pulse", psionic, 2, 4);
UpdateActions(uid, component);
UpdateActions(uid, component, psionic);
args.Handled = true;
}

Expand Down Expand Up @@ -128,7 +126,7 @@ private void OnFocusedPowerUsed(FocusedMetapsionicPowerActionEvent args)
_psionics.LogPowerUsed(args.Performer, "focused metapsionic pulse", psionic, 3, 6);
args.Handled = true;

UpdateActions(args.Performer, component);
UpdateActions(args.Performer, component, psionic);
}

private void OnDoAfter(EntityUid uid, MetapsionicPowerComponent component, FocusedMetapsionicDoAfterEvent args)
Expand Down
32 changes: 16 additions & 16 deletions Content.Server/Psionics/Abilities/MindSwapPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<MindSwapPowerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<MindSwapPowerComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<MindSwapPowerActionEvent>(OnPowerUsed);
SubscribeLocalEvent<MindSwapPowerComponent, MindSwapPowerActionEvent>(OnPowerUsed);
SubscribeLocalEvent<MindSwappedComponent, MindSwapPowerReturnActionEvent>(OnPowerReturned);
SubscribeLocalEvent<MindSwappedComponent, DispelledEvent>(OnDispelled);
SubscribeLocalEvent<MindSwappedComponent, MobStateChangedEvent>(OnMobStateChanged);
Expand All @@ -41,16 +41,15 @@ public override void Initialize()

private void OnInit(EntityUid uid, MindSwapPowerComponent component, ComponentInit args)
{
EnsureComp<PsionicComponent>(uid, out var psionic);
_actions.AddAction(uid, ref component.MindSwapActionEntity, component.MindSwapActionId);
_actions.TryGetActionData( component.MindSwapActionEntity, out var actionData);
_actions.TryGetActionData(component.MindSwapActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.StartUseDelay(component.MindSwapActionEntity);
if (TryComp<PsionicComponent>(uid, out var psionic))
{
psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.MindSwapFeedback);
psionic.Amplification += 1f;
}
_actions.SetCooldown(component.MindSwapActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));

psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.MindSwapFeedback);
psionic.Amplification += 1f;
}

private void OnShutdown(EntityUid uid, MindSwapPowerComponent component, ComponentShutdown args)
Expand All @@ -64,17 +63,16 @@ private void OnShutdown(EntityUid uid, MindSwapPowerComponent component, Compone
}
}

private void OnPowerUsed(MindSwapPowerActionEvent args)
private void OnPowerUsed(EntityUid uid, MindSwapPowerComponent component, MindSwapPowerActionEvent args)
{

if (!(TryComp<DamageableComponent>(args.Target, out var damageable) && damageable.DamageContainerID == "Biological"))
if (!(TryComp<DamageableComponent>(args.Target, out var damageable) && damageable.DamageContainerID == "Biological")
|| !_psionics.CheckCanTargetCast(uid, args.Target, out var psionic))
return;

if (HasComp<PsionicInsulationComponent>(args.Target))
return;

if (!TryComp<PsionicComponent>(args.Performer, out var psionic))
return;
_actions.TryGetActionData(component.MindSwapActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.SetCooldown(component.MindSwapActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));

Swap(args.Performer, args.Target);

Expand Down Expand Up @@ -159,6 +157,8 @@ private void OnSwapInit(EntityUid uid, MindSwappedComponent component, Component
{
psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.MindSwappedFeedback);
if (actionData is { UseDelay: not null })
_actions.SetCooldown(component.MindSwapReturnActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));
}
}

Expand Down
28 changes: 14 additions & 14 deletions Content.Server/Psionics/Abilities/NoosphericZapPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@ public override void Initialize()
base.Initialize();
SubscribeLocalEvent<NoosphericZapPowerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<NoosphericZapPowerComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<NoosphericZapPowerActionEvent>(OnPowerUsed);
SubscribeLocalEvent<NoosphericZapPowerComponent, NoosphericZapPowerActionEvent>(OnPowerUsed);
}

private void OnInit(EntityUid uid, NoosphericZapPowerComponent component, ComponentInit args)
{
EnsureComp<PsionicComponent>(uid, out var psionic);
_actions.AddAction(uid, ref component.NoosphericZapActionEntity, component.NoosphericZapActionId );
_actions.TryGetActionData( component.NoosphericZapActionEntity, out var actionData );
_actions.TryGetActionData(component.NoosphericZapActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.StartUseDelay(component.NoosphericZapActionEntity);
if (TryComp<PsionicComponent>(uid, out var psionic))
{
psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.NoosphericZapFeedback);
psionic.Amplification += 1f;
}
_actions.SetCooldown(component.NoosphericZapActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));

psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.NoosphericZapFeedback);
psionic.Amplification += 1f;
}

private void OnShutdown(EntityUid uid, NoosphericZapPowerComponent component, ComponentShutdown args)
Expand All @@ -51,13 +50,14 @@ private void OnShutdown(EntityUid uid, NoosphericZapPowerComponent component, Co
}
}

private void OnPowerUsed(NoosphericZapPowerActionEvent args)
private void OnPowerUsed(EntityUid uid, NoosphericZapPowerComponent component, NoosphericZapPowerActionEvent args)
{
if (!TryComp<PsionicComponent>(args.Performer, out var psionic))
return;

if (!HasComp<PsionicInsulationComponent>(args.Performer))
if (_psionics.CheckCanTargetCast(uid, args.Target, out var psionic))
{

_actions.TryGetActionData(component.NoosphericZapActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.SetCooldown(component.NoosphericZapActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));
_beam.TryCreateBeam(args.Performer, args.Target, "LightningNoospheric");
_stunSystem.TryParalyze(args.Target, TimeSpan.FromSeconds(1 * psionic.Amplification), false);

Expand Down
24 changes: 13 additions & 11 deletions Content.Server/Psionics/Abilities/PsionicRegenerationPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ public override void Initialize()

private void OnInit(EntityUid uid, PsionicRegenerationPowerComponent component, ComponentInit args)
{
_actions.AddAction(uid, ref component.PsionicRegenerationActionEntity, component.PsionicRegenerationActionId );
_actions.TryGetActionData( component.PsionicRegenerationActionEntity, out var actionData );
EnsureComp<PsionicComponent>(uid, out var psionic);
_actions.AddAction(uid, ref component.PsionicRegenerationActionEntity, component.PsionicRegenerationActionId);
_actions.TryGetActionData(component.PsionicRegenerationActionEntity, out var actionData);
if (actionData is { UseDelay: not null })
_actions.StartUseDelay(component.PsionicRegenerationActionEntity);
if (TryComp<PsionicComponent>(uid, out var psionic))
{
psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.RegenerationFeedback);
psionic.Amplification += 0.5f;
psionic.Dampening += 0.5f;
}
_actions.SetCooldown(component.PsionicRegenerationActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));

psionic.ActivePowers.Add(component);
psionic.PsychicFeedback.Add(component.RegenerationFeedback);
psionic.Amplification += 0.5f;
psionic.Dampening += 0.5f;
}

private void OnPowerUsed(EntityUid uid, PsionicRegenerationPowerComponent component, PsionicRegenerationPowerActionEvent args)
Expand All @@ -66,6 +65,9 @@ private void OnPowerUsed(EntityUid uid, PsionicRegenerationPowerComponent compon
if (actionData != null && actionData.Cooldown.HasValue && actionData.Cooldown.Value.End > curTime)
return;

if (actionData is { UseDelay: not null })
_actions.SetCooldown(component.PsionicRegenerationActionEntity, actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification));

_doAfterSystem.TryStartDoAfter(doAfterArgs, out var doAfterId);

component.DoAfter = doAfterId;
Expand Down Expand Up @@ -116,7 +118,7 @@ private void OnMobStateChangedEvent(EntityUid uid, PsionicRegenerationPowerCompo

_psionics.LogPowerUsed(uid, "psionic regeneration", psionic, 10, 20);

_actions.StartUseDelay(component.PsionicRegenerationActionEntity);
_actions.SetCooldown(component.PsionicRegenerationActionEntity, 2 * (actionData.UseDelay.Value - TimeSpan.FromSeconds(psionic.Dampening + psionic.Amplification)));
}
}
}
Expand Down
Loading

0 comments on commit 5090aab

Please sign in to comment.