Triggered sounds: how to make them play for instigator only?

Discussions about Coding and Scripting

Triggered sounds: how to make them play for instigator only?

Postby Dizzy » Tue Feb 26, 2019 1:48 am

Hey all

When using a SpecialEvent to trigger a sound, is it possible to make the sound play only for the person who triggers it?

I messed around with various properties in SpecialEvent but the sound was still being played for every player in the map, even if they were far away from the trigger.

Thanks
Image
Join our UT Discord chat server: https://www.bunnytrack.net/discord
User avatar
Dizzy
Experienced
 
Posts: 99
Joined: Tue May 21, 2013 3:57 pm
Personal rank: Oaf

Re: Triggered sounds: how to make them play for instigator o

Postby JackGriffin » Tue Feb 26, 2019 2:09 am

Subclass it and script your own. Would take about 10 seconds of work. AFAIK there's not a way to restrict a triggered sound to the instigator with the default settings. I'm sure there's a way to cheat it (like the bunny trick for triggers) but it's just going to be simpler to subclass and restrict.
"You damn kids, back in my time we made the items, maps and games ourselves with an unwieldy engine using counter-intuitive crash-prone tools and we liked it so much we built communities around this which nowadays look like cults because they're quasi-parallel societies based on the same old games." -Hellkeeper
User avatar
JackGriffin
Godlike
 
Posts: 3758
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: Hack coder

Re: Triggered sounds: how to make them play for instigator o

Postby Barbie » Tue Feb 26, 2019 6:02 pm

Dizzy wrote:When using a SpecialEvent to trigger a sound, is it possible to make the sound play only for the person who triggers it?
No. But as Jack suggested, you can easily expand (subclass) this Actor and use ClientPlaySound() to play the sound only for the instigator. Create a new state PlayerPlaySoundEffect for example:

Code: Select all
//=============================================================================
// SpecialEventEx.
//=============================================================================
class SpecialEventEx expands SpecialEvent;

state() PlayerPlaySoundEffect {
   function Trigger( actor Other, pawn EventInstigator ) {
   local pawn P;

      Global.Trigger( Self, EventInstigator);
      if (PlayerPawn(EventInstigator) != None)
         PlayerPawn(EventInstigator).ClientPlaySound(Sound);
   }
}
(See also attached map "TestSpecialEventEx.unr".)

I have used such in my SBBeepTrigger: here the sound can be played for the instigator only optionally.
Attachments
TestSpecialEventEx.unr.7z
(2.21 KiB) Downloaded 13 times
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
Barbie
Godlike
 
Posts: 1654
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Triggered sounds: how to make them play for instigator o

Postby Dizzy » Sat Mar 02, 2019 6:36 pm

Image
Join our UT Discord chat server: https://www.bunnytrack.net/discord
User avatar
Dizzy
Experienced
 
Posts: 99
Joined: Tue May 21, 2013 3:57 pm
Personal rank: Oaf

Re: Triggered sounds: how to make them play for instigator o

Postby Barbie » Sun Mar 03, 2019 2:27 am

Code: Select all
if (
         PlayerPawn(EventInstigator) != none   &&
         PlayerPawn(EventInstigator).bIsPlayer &&
         PlayerPawn(EventInstigator).IsA('PlayerPawn')
)
:lol:
Make it really safe! Are you sure? - Yes. - Really? - Yes! - I mean, really really? - Yeehes.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
Barbie
Godlike
 
Posts: 1654
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Triggered sounds: how to make them play for instigator o

Postby JackGriffin » Sun Mar 03, 2019 5:56 am

Barbie wrote:Make it really safe! Are you sure? - Yes. - Really? - Yes! - I mean, really really? - Yeehes.

You obviously aren't married. This is SO a normal conversation.
"You damn kids, back in my time we made the items, maps and games ourselves with an unwieldy engine using counter-intuitive crash-prone tools and we liked it so much we built communities around this which nowadays look like cults because they're quasi-parallel societies based on the same old games." -Hellkeeper
User avatar
JackGriffin
Godlike
 
Posts: 3758
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: Hack coder

Re: Triggered sounds: how to make them play for instigator o

Postby sektor2111 » Sun Mar 03, 2019 8:35 am

Isn't more simple to look for "TournamentPlayer" instead ?
I suppose "GoTo" used even in that "decompiled" MapVote is CPU intensive, not these USELESS checks iterating through objects, right ?
ISA is slow somehow doing the same effect as "PlayerPawn(EventInstigator) != None" one of these is pointless...

PS: :ironic: You forgot other check(s) if you want more USELESS safety...
UselessCodingSession
Code: Select all
if (PlayerPawn(EventInstigator).bIsPawn &&
!PlayerPawn(EventInstigator).bDeleteMe &&
PlayerPawn(EventInstigator).Health > 0 &&
!PlayerPawn(EventInstigator).bHidden &&
PlayerPawn(EventInstigator).Mesh != None &&
PlayerPawn(EventInstigator).DrawType == DT_Mesh &&
!PlayerPawn(EventInstigator).ISA('ScriptedPawn')&&
!PlayerPawn(EventInstigator).ISA('FlockPawn')&&
!PlayerPawn(EventInstigator).ISA('TeamCannon')&&
!PlayerPawn(EventInstigator).ISA('Carcass')&&
!PlayerPawn(EventInstigator).ISA('Mover')&&
!PlayerPawn(EventInstigator).ISA('NavigationPoint')&&
!PlayerPawn(EventInstigator).ISA('KeyPoint')&&
!PlayerPawn(EventInstigator).ISA('Triggers')
/*&&
etc. all bullshit useless checking
*/)
Now that it's definitely a PlayerPawn and nothing else -> inspired from codes shared through these almost 20 years of UT...
User avatar
sektor2111
Godlike
 
Posts: 3962
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.


Return to Coding, Scripting

Who is online

Users browsing this forum: No registered users and 2 guests