Fix stun baton throwing and visual effect (#18777)

This commit is contained in:
Slava0135
2023-08-08 23:19:31 +03:00
committed by GitHub
parent 2714101ad7
commit 375f487d94
12 changed files with 117 additions and 75 deletions

View File

@@ -1,29 +0,0 @@
using Content.Server.Stunnable.Systems;
using Content.Shared.Timing;
using Robust.Shared.Audio;
namespace Content.Server.Stunnable.Components
{
[RegisterComponent, Access(typeof(StunbatonSystem))]
public sealed class StunbatonComponent : Component
{
public bool Activated = false;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("energyPerUse")]
public float EnergyPerUse { get; set; } = 350;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("onThrowStunChance")]
public float OnThrowStunChance { get; set; } = 0.20f;
[DataField("stunSound")]
public SoundSpecifier StunSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/egloves.ogg");
[DataField("sparksSound")]
public SoundSpecifier SparksSound { get; set; } = new SoundCollectionSpecifier("sparks");
[DataField("turnOnFailSound")]
public SoundSpecifier TurnOnFailSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/button.ogg");
}
}

View File

@@ -4,20 +4,19 @@ using Content.Server.Power.EntitySystems;
using Content.Server.Power.Events;
using Content.Server.Stunnable.Components;
using Content.Shared.Audio;
using Content.Shared.Damage;
using Content.Shared.Damage.Events;
using Content.Shared.Examine;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Popups;
using Content.Shared.Stunnable;
using Content.Shared.Toggleable;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Audio;
using Robust.Shared.Player;
namespace Content.Server.Stunnable.Systems
{
public sealed class StunbatonSystem : EntitySystem
public sealed class StunbatonSystem : SharedStunbatonSystem
{
[Dependency] private readonly SharedItemSystem _item = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
@@ -31,16 +30,6 @@ namespace Content.Server.Stunnable.Systems
SubscribeLocalEvent<StunbatonComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<StunbatonComponent, SolutionChangedEvent>(OnSolutionChange);
SubscribeLocalEvent<StunbatonComponent, StaminaDamageOnHitAttemptEvent>(OnStaminaHitAttempt);
SubscribeLocalEvent<StunbatonComponent, GetMeleeDamageEvent>(OnGetMeleeDamage);
}
private void OnGetMeleeDamage(EntityUid uid, StunbatonComponent component, ref GetMeleeDamageEvent args)
{
if (!component.Activated)
return;
// Don't apply damage if it's activated; just do stamina damage.
args.Damage = new DamageSpecifier();
}
private void OnStaminaHitAttempt(EntityUid uid, StunbatonComponent component, ref StaminaDamageOnHitAttemptEvent args)
@@ -52,8 +41,6 @@ namespace Content.Server.Stunnable.Systems
return;
}
args.HitSoundOverride = component.StunSound;
if (battery.CurrentCharge < component.EnergyPerUse)
{
SoundSystem.Play(component.SparksSound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), uid, AudioHelpers.WithVariation(0.25f));
@@ -99,6 +86,7 @@ namespace Content.Server.Stunnable.Systems
SoundSystem.Play(comp.SparksSound.GetSound(), Filter.Pvs(comp.Owner), comp.Owner, AudioHelpers.WithVariation(0.25f));
comp.Activated = false;
Dirty(comp);
}
private void TurnOn(EntityUid uid, StunbatonComponent comp, EntityUid user)
@@ -131,6 +119,7 @@ namespace Content.Server.Stunnable.Systems
SoundSystem.Play(comp.SparksSound.GetSound(), playerFilter, comp.Owner, AudioHelpers.WithVariation(0.25f));
comp.Activated = true;
Dirty(comp);
}
// https://github.com/space-wizards/space-station-14/pull/17288#discussion_r1241213341