SndInfo: $Random List Weighting

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is ON
[img] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: SndInfo: $Random List Weighting

Re: SndInfo: $Random List Weighting

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

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

Re: SndInfo: $Random List Weighting

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

Re: SndInfo: $Random List Weighting

by 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
}

Re: SndInfo: $Random List Weighting

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

Re: SndInfo: $Random List Weighting

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

Re: SndInfo: $Random List Weighting

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

Re: SndInfo: $Random List Weighting

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

mmm, does ',' suffer the same issue?

Re: SndInfo: $Random List Weighting

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

What if someone has a sound named '='? :mrgreen:

Re: SndInfo: $Random List Weighting

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

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
}

Re: SndInfo: $Random List Weighting

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

Re: SndInfo: $Random List Weighting

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

Re: SndInfo: $Random List Weighting

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

Re: SndInfo: $Random List Weighting

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

That would be useful, why not?

SndInfo: $Random List Weighting

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

Top