Need Help With a Random Taunt Key

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
Zaeryn
Posts: 9
Joined: Fri Dec 09, 2022 9:55 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: AL, USA

Need Help With a Random Taunt Key

Post by Zaeryn »

In my current mod, when the player presses a key, it should play a randomly-selected sound. I think everything works as expected, except for the SNDINFO... unless I'm even more lost than I thought.

KEYCONF

Code: Select all

alias taunt "summon Taunter"
addkeysection "Universal Taunt" utmenu
addmenukey "Taunt" taunt
defaultbind T taunt
DECORATE

Code: Select all

ACTOR Taunter
{
	+ISMONSTER
	States
	{
	Spawn:
		MARN A 1
		NULL A 0 A_PlaySound("TAUNT0", 2)
		TNT1 A 0 A_AlertMonsters
		TNT1 A -1
		Goto StandStill
		Stop
	}
}
SNDINFO

Code: Select all

$random TAUNT0 { TAUNT01 TAUNT02 TAUNT03 TAUNT04 }

TAUNT01 TAUNT01
TAUNT02 TAUNT02
TAUNT03 TAUNT03
TAUNT04 TAUNT04
$limit TAUNT0 1
Anyway, whether I press the key or even manually `playsound`, I hear nothing and I have no clue where I went wrong. So, that's my final roadblock.
User avatar
Player701
 
 
Posts: 1575
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support

Re: Need Help With a Random Taunt Key

Post by Player701 »

If the console command playsound TAUNT01 (or TAUNT02 etc.) does nothing for you, it could mean any of the following:
  1. You forgot to put the sounds in your WAD/PK3 at all. Silly mistake, but it happens to us all sometimes.
  2. You're using the PK3/PK7 format, and your sounds are not in the subfolder named "sounds".
  3. Unlikely, but possible: your sounds are in a format that GZDoom doesn't understand. Note that GZDoom understands a lot of sound formats, and I think it should spit out a warning if it encounters corrupt data or an unknown sound format.
Now, this is unrelated to your problem, but I've also noticed these lines in your DECORATE code:

Code: Select all

TNT1 A -1
Goto StandStill
Stop
The first line means your actor will remain on the map forever after it is spawned. It's probably not what you want because every spawned copy will keep using memory, which can add up if a lot of them are spawned in the map. To make the actor disappear instead, change -1 to a positive value, and make it large enough to ensure the actor won't be destroyed before the sound stops playing (remember 1 tic = 1/35th of a second). The next line Goto StandStill attempts to send the actor to a non-existent state label StandStill, which doesn't take effect in the current version of your code because TNT1 A -1 is reached first. Remove this line as well to ensure the final Stop is reached, which will destroy the actor for good.
User avatar
Zaeryn
Posts: 9
Joined: Fri Dec 09, 2022 9:55 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: AL, USA

Re: Need Help With a Random Taunt Key

Post by Zaeryn »

Player701 wrote: Wed Dec 28, 2022 1:17 am If the console command playsound TAUNT01 (or TAUNT02 etc.) does nothing for you, it could mean any of the following:
  1. You're using the PK3/PK7 format, and your sounds are not in the subfolder named "sounds".
OOPS. Well, that was the problem and I also made the decorate adjustments. On one hand, everything got dumped into the root directory of vanilla IWads. On the other, mod PK3s can place the same components in different places so yeah, it was confusing.
User avatar
Zaeryn
Posts: 9
Joined: Fri Dec 09, 2022 9:55 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: AL, USA

Re: Need Help With a Random Taunt Key

Post by Zaeryn »

Okay, there's another problem. Right now, you can spam the taunt key and the $random sound set will just overlap itself, creating spam. I'd like to set a $limit, but I've read that it doesn't work the same way with those. "NearLimit" was mentioned in other threads, but there's no context about how to use it.

On another note, is there a way to detect the player's gender cvar?
User avatar
Player701
 
 
Posts: 1575
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support

Re: Need Help With a Random Taunt Key

Post by Player701 »

Zaeryn wrote: Sun Jan 08, 2023 3:02 pm Okay, there's another problem. Right now, you can spam the taunt key and the $random sound set will just overlap itself, creating spam. I'd like to set a $limit, but I've read that it doesn't work the same way with those. "NearLimit" was mentioned in other threads, but there's no context about how to use it.
From here:
Graf Zahl wrote:If the random sound had its own limit that is applied to the sound being played - separately for each sub-sound because sounds don't know if they were picked out of a random list.
Essentially, applying a $limit to a random sound is the same as applying it to each of the sub-sounds.
"NearLimit" refers to the internal implementation of the $limit feature in the GZDoom engine (C++ code).
Zaeryn wrote: Sun Jan 08, 2023 3:02 pm On another note, is there a way to detect the player's gender cvar?
There definitely is. In ACS/DECORATE you can use GetCVarString or GetUserCVarString (ACS only). Note that unless you're limited to DECORATE/ACS, it could be done much easier via ZScript (PlayerInfo has a specific method that returns the gender). Additionally, if your intention is to play a different sound based on the current gender, you can also use player sounds, but in this case you will either need some ACS hacks or, again, ZScript (to call A_StartSound from the PlayerPawn instead of the taunt actor).

Return to “Scripting”