SndInfo: $Random List Weighting

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

User avatar
NeuralStunner
 
 
Posts: 12326
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

SndInfo: $Random List Weighting

Post by NeuralStunner »

Suppose you have some sounds in your selection that you'd like ZDoom to play more rarely than others. Say you've added a couple new alert sounds for the Zombieman, and want him to (rarely) exclaim "aw crap!" or "I'm hungry!"

Currently, you're forced to do this:

Code: Select all

$random grunt/sight
{
	grunt/sight1
	grunt/sight1
	grunt/sight1
	grunt/sight1
	grunt/sight2
	grunt/sight2
	grunt/sight2
	grunt/sight2
	grunt/sight3
	grunt/sight3
	grunt/sight3
	grunt/sight3
	grunt/sight4
	grunt/sight5
}
Note how long and messy this is.

Suppose you could do this, instead:

Code: Select all

$random grunt/sight
{
	grunt/sight1 4
	grunt/sight2 4
	grunt/sight3 4
	grunt/sight4 1
	grunt/sight5 1
}
(Of course, not specifying a wight defaults to 1. Also, I guess a weight of 0 would keep it from even being added, for whatever reason.)
User avatar
Xeotroid
Posts: 436
Joined: Sat Jun 23, 2012 7:44 am
Graphics Processor: nVidia with Vulkan support
Location: Czech Rep.

Re: SndInfo: $Random List Weighting

Post by Xeotroid »

That would be useful, why not?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: SndInfo: $Random List Weighting

Post by Graf Zahl »

Xeotroid wrote:why not?
The only reason that comes to mind is how badly the SNDINFO syntax is suited to such a change because it lacks any kind of sufficient structure to decide whether the number is an actual number or a sound name consisting entirely of digits.
User avatar
Xeotroid
Posts: 436
Joined: Sat Jun 23, 2012 7:44 am
Graphics Processor: nVidia with Vulkan support
Location: Czech Rep.

Re: SndInfo: $Random List Weighting

Post by Xeotroid »

Doesn't a space solve that? I have never seen a sound name with a space in it.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: SndInfo: $Random List Weighting

Post by Graf Zahl »

No, a space doesn't solve that.

Imagine

$random { sounds/bang 1234567 sounds/poof 3 }

Can you tell me if '1234567' is a supposed to be a weighting factor or an actual sound name? I can't and neither can the parser.
Oh, and I HAVE seen mods using sound names like '111'.
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: SndInfo: $Random List Weighting

Post by Gez »

What if there is some special token? For example:

Code: Select all

$random grunt/sight
{
   grunt/sight1 = 4
   grunt/sight2 = 4
   grunt/sight3 = 4
   grunt/sight4 = 1
   grunt/sight5 = 1
}
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: SndInfo: $Random List Weighting

Post by Graf Zahl »

What if someone has a sound named '='? :mrgreen:
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: SndInfo: $Random List Weighting

Post by Edward-san »

mmm, does ',' suffer the same issue?
User avatar
Xeotroid
Posts: 436
Joined: Sat Jun 23, 2012 7:44 am
Graphics Processor: nVidia with Vulkan support
Location: Czech Rep.

Re: SndInfo: $Random List Weighting

Post by Xeotroid »

I guess so, everything in SNDINFO is divided by space. God damn it Raven, you're not helping! :D Maybe if the number property had to be included and it would be separated by lines? So it couldn't be "sound1 4 sound2 5" but every sound + weight would have to be its own individual line, like in NeuralStunner's example.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: SndInfo: $Random List Weighting

Post by Graf Zahl »

Edward-san wrote:mmm, does ',' suffer the same issue?
The non-CMode parser won't end a token on a parser so it'd have to be separated with a space from the preceding name.
Xeotroid wrote:I guess so, everything in SNDINFO is divided by space. God damn it Raven, you're not helping! :D Maybe if the number property had to be included and it would be separated by lines? So it couldn't be "sound1 4 sound2 5" but every sound + weight would have to be its own individual line, like in NeuralStunner's example.

Cannot be done without breaking the existing format.
HeXaGoN
Posts: 161
Joined: Sat Dec 04, 2010 3:07 pm
Location: Texas, United States

Re: SndInfo: $Random List Weighting

Post by HeXaGoN »

I don't know if this would be the best idea, but maybe a second statement?

Something along the lines of this:

Code: Select all

$random sound { sound1 sound2 sound3 }
$randomweight sound { 4 2 1 }
The numbers in the $randomweight statement would be respective to the list of sounds in the $random statement.
So "sound1" would have a weight of 4, "sound2" would have a weight of 2, and so on.

Lets say list lengths don't match:

Code: Select all

$random sound { sound1 sound2 sound3 sound4 sound5 }
$randomweight sound { 4 2 1 }
Well, what we could do there is perhaps, default the weight of every sound in the $random statement after the third sound to 1.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: SndInfo: $Random List Weighting

Post by Graf Zahl »

You are getting on the right track but that's just way too messy.
Actually the real solution would be

$randomweight
{
sound1 4
sound2 2
sound3 1
}
HeXaGoN
Posts: 161
Joined: Sat Dec 04, 2010 3:07 pm
Location: Texas, United States

Re: SndInfo: $Random List Weighting

Post by HeXaGoN »

Graf Zahl wrote: $randomweight
{
sound1 4
sound2 2
sound3 1
}
That's much better. At first glance I thought we were stepping back into our original problem, but then remembered we were using a different command. :P
I really like that solution though! It lets us set the weight of each sound individually as we like rather than setting the weight for all of them.
User avatar
NeuralStunner
 
 
Posts: 12326
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: SndInfo: $Random List Weighting

Post by NeuralStunner »

That would work for me! Might be better to call it "randomweighted".
Post Reply

Return to “Feature Suggestions [GZDoom]”