SndInfo: $Random List Weighting

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

Moderator: GZDoom Developers

SndInfo: $Random List Weighting

Postby NeuralStunner » Thu Jun 11, 2015 8:32 am

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 allExpand view
$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 allExpand view
$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
NeuralStunner
Not "Neutral"
 
 
 
Joined: 21 Jul 2009
Location: capital N, capital S, no space
Discord: NeuralStunner#4201
Operating System: Windows Vista/7/2008 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: SndInfo: $Random List Weighting

Postby Xeotroid » Thu Jun 11, 2015 8:51 am

That would be useful, why not?
User avatar
Xeotroid
 
Joined: 23 Jun 2012
Location: Czech Rep.

Re: SndInfo: $Random List Weighting

Postby Graf Zahl » Thu Jun 11, 2015 9:13 am

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: SndInfo: $Random List Weighting

Postby Xeotroid » Thu Jun 11, 2015 9:31 am

Doesn't a space solve that? I have never seen a sound name with a space in it.
User avatar
Xeotroid
 
Joined: 23 Jun 2012
Location: Czech Rep.

Re: SndInfo: $Random List Weighting

Postby Graf Zahl » Thu Jun 11, 2015 10:52 am

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'.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: SndInfo: $Random List Weighting

Postby Gez » Thu Jun 11, 2015 11:17 am

What if there is some special token? For example:
Code: Select allExpand view
$random grunt/sight
{
   grunt/sight1 = 4
   grunt/sight2 = 4
   grunt/sight3 = 4
   grunt/sight4 = 1
   grunt/sight5 = 1
}
Gez
 
 
 
Joined: 06 Jul 2007

Re: SndInfo: $Random List Weighting

Postby Graf Zahl » Thu Jun 11, 2015 11:44 am

What if someone has a sound named '='? :mrgreen:
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: SndInfo: $Random List Weighting

Postby Edward-san » Thu Jun 11, 2015 12:04 pm

mmm, does ',' suffer the same issue?
Edward-san
Mathematics is the language with which God has written the universe. (Galilei)
 
Joined: 17 Oct 2009

Re: SndInfo: $Random List Weighting

Postby Xeotroid » Thu Jun 11, 2015 1:00 pm

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
Xeotroid
 
Joined: 23 Jun 2012
Location: Czech Rep.

Re: SndInfo: $Random List Weighting

Postby Graf Zahl » Thu Jun 11, 2015 1:01 pm

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: SndInfo: $Random List Weighting

Postby HeXaGoN » Thu Jun 11, 2015 1:17 pm

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

Something along the lines of this:
Code: Select allExpand view
$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 allExpand view
$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.
HeXaGoN
 
Joined: 04 Dec 2010
Location: Texas, United States

Re: SndInfo: $Random List Weighting

Postby Graf Zahl » Thu Jun 11, 2015 1:33 pm

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
}
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: SndInfo: $Random List Weighting

Postby HeXaGoN » Thu Jun 11, 2015 1:37 pm

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.
HeXaGoN
 
Joined: 04 Dec 2010
Location: Texas, United States

Re: SndInfo: $Random List Weighting

Postby NeuralStunner » Fri Jun 12, 2015 4:06 pm

That would work for me! Might be better to call it "randomweighted".
User avatar
NeuralStunner
Not "Neutral"
 
 
 
Joined: 21 Jul 2009
Location: capital N, capital S, no space
Discord: NeuralStunner#4201
Operating System: Windows Vista/7/2008 64-bit
Graphics Processor: nVidia (Modern GZDoom)


Return to Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests