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

Discussions about Coding and Scripting
User avatar
Dizzy
Experienced
Posts: 109
Joined: Tue May 21, 2013 3:57 pm
Personal rank: Oaf

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

Post by Dizzy »

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
Join the BunnyTrack.net Discord chat server: https://www.bunnytrack.net/discord
JackGriffin
Godlike
Posts: 3767
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

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

Post by JackGriffin »

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.
So long, and thanks for all the fish
User avatar
Barbie
Godlike
Posts: 2536
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

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

Post by Barbie »

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.
You do not have the required permissions to view the files attached to this post.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
Dizzy
Experienced
Posts: 109
Joined: Tue May 21, 2013 3:57 pm
Personal rank: Oaf

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

Post by Dizzy »

Join the BunnyTrack.net Discord chat server: https://www.bunnytrack.net/discord
User avatar
Barbie
Godlike
Posts: 2536
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

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

Post by Barbie »

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
JackGriffin
Godlike
Posts: 3767
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

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

Post by JackGriffin »

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.
So long, and thanks for all the fish
User avatar
sektor2111
Godlike
Posts: 6133
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

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

Post by sektor2111 »

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...