YesNoOk
avatar

Question about random sounds (Read 860 times)

Started by MarioManX1983, March 04, 2019, 11:15:45 pm
Share this topic:
Question about random sounds
#1  March 04, 2019, 11:15:45 pm
  • **
  • Expert Noob
  • I am a lover and a fighter!
    • USA
Is it possible to have a specific sound play according to a previous random sound?

I'm making a Ryu Character with English voice clips from SF4 and 5 and have split his intro quotes into 6 different sounds. (3 different quotes split into 2 parts each.) And have two different "PlaySnd" States to play the quotes at random.

Code:
[State 191, PlaySnd1]
type = PlaySnd
trigger1 = Time = 0
value = 190,random%3

[State 191, PlaySnd2]
type = PlaySnd
trigger1 = Time = 115
value = 191,random%3

The first state, ([State 191, PlaySnd1]), plays the first half of a random intro (Ex. "The Answer Lie's" or "As Long as the path exists") and the second state, ([State 191, PlaySnd2]) plays the second half. (Ex. "In the heart of battle" or "Go beyond the Battle") I'm doing it this way to have more control over how long the pause in between the sounds are.

The problem is that each sound plays completely at random, so I'm getting an intro where Ryu mixes his quotes together. (Ex. "The answer lie's...go beyond the battle.")

Is there a way to code the second PlaySnd state so that the correct sound plays according to what the first PlaySnd state played?

(Ex. If the first state played "The answer lie's" then the second state will play "in the heart of battle." But, if the first state played "As long as the path exists" then the second state will play "go beyond the battle")

Note: I've tried using an ifelse((190,random%3 = 0),0,1) statement in place of the random%3 but Mugen gave an error.

Note: "The answer lie's" is sound group 190,0. "As Long as the path exists" is group 190,1. "In the heart of battle" is group 191,0. "Go beyond the battle" is group 191,1 Etc.
May you always win every round, both in MUGEN and Life. :)
Re: Question about random sounds
#2  March 04, 2019, 11:55:34 pm
  • ***
  • Non est hoc propter hoc sed propter est hoc
    • USA
    • doubletrend-zeta.neocities.org/
There's no trigger based on sound unfortunately, however, you can use a variable to cache the random number to play the sound
Code:
[state var]
type = varset
trigger1 = stateno = 191 && time = 0
v = ?
vale = random%3

And then use it to play your sound

Code:
[State 191, PlaySnd1]
type = PlaySnd
trigger1 = Time = 0
value = 190,var(?)

[State 191, PlaySnd2]
type = PlaySnd
trigger1 = Time = 115
value = 191,var(?)

Then have it rerun it depending on the current random number, which you can optimize with cond()

Code:
[state var]
type = varset
trigger1 = stateno = 191 && time = 114
v = ?
value = cond(var(?)=0,10,cond(var(?)=1,11,cond(var(?)=2,12,etc...)))



Re: Question about random sounds
#3  March 05, 2019, 12:56:00 am
  • **
  • Expert Noob
  • I am a lover and a fighter!
    • USA
Thank you very much. It worked. :)

I modified the code a bit but it seems to do what I want.

Spoiler, click to toggle visibilty

So, Variable 5 generates a random number between 0 to 2 and Variable 6 stores a copy of the value of Variable 5.

The first Play Sound State plays the sound from group 190 and the same number as Variable 5.

And the second Play Sound State plays the sound from group 191 and the same number as Variable 6.
May you always win every round, both in MUGEN and Life. :)
Last Edit: March 05, 2019, 12:59:32 am by MarioManX1983
Re: Question about random sounds
#4  March 05, 2019, 01:29:06 am
  • ***
  • Non est hoc propter hoc sed propter est hoc
    • USA
    • doubletrend-zeta.neocities.org/
No problem, glad to help!