]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix: Grenades don't make trigger sound (#25321)
authorPlykiya <58439124+Plykiya@users.noreply.github.com>
Sat, 17 Feb 2024 16:54:58 +0000 (08:54 -0800)
committerGitHub <noreply@github.com>
Sat, 17 Feb 2024 16:54:58 +0000 (09:54 -0700)
* Fix: Grenades don't make trigger sound

* transform instead of trycomp transform

---------

Co-authored-by: Plykiya <plykiya@protonmail.com>
Content.Server/Explosion/EntitySystems/TriggerSystem.cs
Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml

index 5830018c4887e408772944148f75cd6a49103539..9b9a042641f17f5ae516b2063d27bf2cf1473cdc 100644 (file)
@@ -29,6 +29,8 @@ using Robust.Shared.Physics.Events;
 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
 {
@@ -103,9 +105,15 @@ namespace Content.Server.Explosion.EntitySystems
 
         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)
index 90cb751e40a884abd4f96ca9e290684b258e202c..0b1a7ecb77a6668c9eb7fb85d6515ed7b2007500 100644 (file)
@@ -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