ninja hotfixes (#20032)

* check that slot is power cell slot

* add BatteryChangedEvent

* use BatteryChangedEvent when enabling gloves and replacing battery

* sort gloves dependencies

* increase stun duration and cooldown

* play sound when stunning people

* remove dirty for non networked field

* NinjaBatteryChangedEvent

* real

* fake

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-09-12 21:54:18 +01:00
committed by GitHub
parent ef869b1cff
commit b53e5d6661
6 changed files with 58 additions and 11 deletions

View File

@@ -1,10 +1,12 @@
using Content.Server.Ninja.Events;
using Content.Server.Power.EntitySystems;
using Content.Shared.Electrocution;
using Content.Shared.Interaction;
using Content.Shared.Ninja.Components;
using Content.Shared.Ninja.Systems;
using Content.Shared.Popups;
using Content.Shared.Whitelist;
using Content.Server.Power.EntitySystems;
using Robust.Shared.Audio;
using Robust.Shared.Timing;
namespace Content.Server.Ninja.Systems;
@@ -16,6 +18,7 @@ public sealed class StunProviderSystem : SharedStunProviderSystem
{
[Dependency] private readonly BatterySystem _battery = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedElectrocutionSystem _electrocution = default!;
[Dependency] private readonly SharedNinjaGlovesSystem _gloves = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
@@ -25,6 +28,7 @@ public sealed class StunProviderSystem : SharedStunProviderSystem
base.Initialize();
SubscribeLocalEvent<StunProviderComponent, BeforeInteractHandEvent>(OnBeforeInteractHand);
SubscribeLocalEvent<StunProviderComponent, NinjaBatteryChangedEvent>(OnBatteryChanged);
}
/// <summary>
@@ -49,12 +53,18 @@ public sealed class StunProviderSystem : SharedStunProviderSystem
return;
}
_audio.PlayPvs(comp.Sound, target);
// not holding hands with target so insuls don't matter
_electrocution.TryDoElectrocution(target, uid, comp.StunDamage, comp.StunTime, false, ignoreInsulation: true);
// short cooldown to prevent instant stunlocking
comp.NextStun = _timing.CurTime + comp.Cooldown;
Dirty(uid, comp);
args.Handled = true;
}
private void OnBatteryChanged(EntityUid uid, StunProviderComponent comp, ref NinjaBatteryChangedEvent args)
{
SetBattery(uid, args.Battery, comp);
}
}