[SOLVED]Play *surface sound using ZScript

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Laskow
Posts: 66
Joined: Tue Feb 16, 2021 7:35 am
Preferred Pronouns: He/Him

[SOLVED]Play *surface sound using ZScript

Post by Laskow »

Hi.

I've seen there is a tricky issue to set $playersound in this forum and absolutely I'm the one who has a problem about it. Some sounds are played but others aren't.
For example:

Code: Select all

$playersound CustomPlayer male *gasp "sounds/CustomPlayer/CustomPlayer_gasp.ogg"
$playersounddup CustomPlayer male *surface *gasp 
In this case, the gasp sound is played correctly but the surface sound isn't played.

And,

Code: Select all

CustomPlayer/Gasp "sounds/CustomPlayer/CustomPlayer_gasp.ogg"
$playersound CustomPlayer male *gasp CustomPlayer/Gasp
$playersounddup CustomPlayer male *surface *gasp 
This isn't work for both somewhat.
Like the surface sound, somehow pain sounds and death sounds aren't played. I needed to make a hacky Event Handler for them. And *pain-drowning sounds aren't played like them, perhaps I'll need to create another hacky Event Handler for this...


I hope this can be solved to use the Event Handler or add something to the custom player class because the surface sound is hard-coded AFAIK.
Is it possible to handle the surface sound from ZScript or other definitions?


Note that I'm still using GZDoom 4.8.2 and the problem of playing *grunt and *surface sounds are fixed in 4.9.0, so probably this would be solved if I just update the engine though, I have a problem with $playersound in the first place.
Last edited by Laskow on Mon Dec 05, 2022 2:13 am, edited 2 times in total.
User avatar
Laskow
Posts: 66
Joined: Tue Feb 16, 2021 7:35 am
Preferred Pronouns: He/Him

Re: Play *surface sound using ZScript

Post by Laskow »

Well, I didn't need even using ZScript. Check the water level in the spawn state and jump to the state which just plays a sound.

Code: Select all

Gasp:
TNT1 A 0 A_StartSound("CustomPlayer/Gasp", CHAN_VOICE)
Goto Spawn
Personally I don't like to create a hack state like this though, I hope this will help people who are stuck the with the player sound problem.
User avatar
Player701
 
 
Posts: 1530
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: [SOLVED?]Play *surface sound using ZScript

Post by Player701 »

Laskow wrote: Sun Dec 04, 2022 9:42 am

Code: Select all

CustomPlayer/Gasp "sounds/CustomPlayer/CustomPlayer_gasp.ogg"
$playersound CustomPlayer male *gasp CustomPlayer/Gasp
$playersounddup CustomPlayer male *surface *gasp 
This isn't work for both somewhat.
This is not surprising because you need to use $playeralias here instead of $playersound.
Laskow wrote: Sun Dec 04, 2022 9:42 am

Code: Select all

$playersound CustomPlayer male *gasp "sounds/CustomPlayer/CustomPlayer_gasp.ogg"
$playersounddup CustomPlayer male *surface *gasp
In this case, the gasp sound is played correctly but the surface sound isn't played.
This works for me, at least if I check the sounds via the playsound console command. Could you please post a small example mod containing this code to reproduce the issue?
User avatar
Laskow
Posts: 66
Joined: Tue Feb 16, 2021 7:35 am
Preferred Pronouns: He/Him

Re: [SOLVED?]Play *surface sound using ZScript

Post by Laskow »

This is not surprising because you need to use $playeralias here instead of $playersound.
Yes, replace $playersound to $playeralias is the best solution I've ever seen in this forum. However...

Code: Select all

CustomPlayer/Gasp "sounds/CustomPlayer/CustomPlayer_gasp.ogg"
$playeralias CustomPlayer male *gasp CustomPlayer/Gasp
$playersounddup CustomPlayer male *surface *gasp
Or,

Code: Select all

CustomPlayer/Gasp "sounds/CustomPlayer/CustomPlayer_gasp.ogg"
$playeralias CustomPlayer male *gasp CustomPlayer/Gasp
$playeralias CustomPlayer male *surface CustomPlayer/Gasp
Despite *gaps work for both case, *surface doesn't.

This works for me, at least if I check the sounds via the playsound console command.
Yes, it works for me either. Somehow there are few types of the player sound cannot play through the $playersound or $playeralias. For example, *falling, *gasp and *grunt sounds play correctly using $playersound for me.
Although I haven't tested other types such as *usefail or *jump, only *surface, *pain and *death don't work just for now.

And it's hard to upload a mod because this is a part of my TC. Sorry. Not sure how to separate only things related to this problem from the 20MB+ file.
User avatar
Player701
 
 
Posts: 1530
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: [SOLVED?]Play *surface sound using ZScript

Post by Player701 »

I've just tested the first method from your first post ($playersound + $playersounddup) myself, and I can hear the sound play when exiting water both when I still have some air left as well as when I've run out. Either you're doing something wrong (this is why I asked you earlier to send a self-contained example, if possible), or perhaps you're using an older version of GZDoom which might be bugged. I'm using the latest official release (4.10 as of now).
User avatar
Laskow
Posts: 66
Joined: Tue Feb 16, 2021 7:35 am
Preferred Pronouns: He/Him

Re: [SOLVED?]Play *surface sound using ZScript

Post by Laskow »

Wow, I didn't know that the 4.10 has released and finally I can hear the *surface sound! Probably I was stuck with the 4.8.2's sound problem exactly.
I should have used the latest version (and I hesitate to update it because I've customized the engine...) before trying to a hacky way and post here. Thanks for helping me!!

Return to “Scripting”