Skip to content

Commit

Permalink
Fix: Grenades don't make trigger sound (space-wizards#25321)
Browse files Browse the repository at this point in the history
* Fix: Grenades don't make trigger sound

* transform instead of trycomp transform

---------

Co-authored-by: Plykiya <plykiya@protonmail.com>
  • Loading branch information
2 people authored and joshepvodka committed Feb 18, 2024
1 parent 4ea051d commit 4dc144a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions Content.Server/Explosion/EntitySystems/TriggerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
using Robust.Shared.Physics.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Player;
using Content.Shared.Coordinates;

namespace Content.Server.Explosion.EntitySystems
{
Expand Down Expand Up @@ -103,9 +105,15 @@ public override void Initialize()

private void OnSoundTrigger(EntityUid uid, SoundOnTriggerComponent component, TriggerEvent args)
{
_audio.PlayPvs(component.Sound, uid);
if (component.RemoveOnTrigger)
RemCompDeferred<SoundOnTriggerComponent>(uid);
if (component.RemoveOnTrigger) // if the component gets removed when it's triggered
{
var xform = Transform(uid);
_audio.PlayPvs(component.Sound, xform.Coordinates); // play the sound at its last known coordinates
}
else // if the component doesn't get removed when triggered
{
_audio.PlayPvs(component.Sound, uid); // have the sound follow the entity itself
}
}

private void OnAnchorTrigger(EntityUid uid, AnchorOnTriggerComponent component, TriggerEvent args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
sprite: Objects/Weapons/Grenades/flashbang.rsi
- type: FlashOnTrigger
range: 7
- type: EmitSoundOnTrigger
- type: SoundOnTrigger
sound:
path: "/Audio/Effects/flash_bang.ogg"
- type: DeleteOnTrigger
Expand Down

0 comments on commit 4dc144a

Please sign in to comment.