YesNoOk
avatar

Music before battle - More than one choice (Read 2161 times)

Started by Charles_2011, December 30, 2021, 04:43:31 am
Share this topic:
Music before battle - More than one choice
#1  December 30, 2021, 04:43:31 am
  • ***
    • Peru

  • Online
Hello.

I have this code to add music before battle and it works correctly. But I have a question: Is there a way to add more than one music, randomly?

More choices like this:

Values:
200,0 ---> Music 1
200,1 ---> Music 2
200,2 ---> Music 3
...


This is my current code:

[Statedef 190]

[State 200, snd]
type=playsnd
triggerall = RoundNo = 1
trigger1 = !time
value = 200,0 ---> Music
channel = 22

[Statedef -3]

[STATE 2002 UM, REJY2505]
type = AssertSpecial
triggerall = TeamMode != Turns
triggerall = roundno = 1
trigger1 = roundstate = 1
trigger2 = stateno = 5900
trigger3 = stateno = [190,199]
flag = nomusic
ignorehitpause = 1
persistent = 1

[State 200, snd]
type=stopsnd
triggerall = TeamMode != Turns
trigger1 = roundstate != 1
trigger1 = stateno != 5900
trigger1 = stateno != [190,199]
channel = 22

[State 200, snd]
type = Stopsnd
triggerall = TeamMode = Turns
triggerall = RoundNo = 1
trigger1 = RoundState > 1
channel = 22

I hope you can help me with this.
Re: Music before battle - More than one choice
#2  December 30, 2021, 10:53:54 am
  • *****
  • A.K.A. NED
  • I like to draw fighting game characters...
With my old way to code, it would be using a var random:
exemple from one of my old character project (it was used for voices randomizer)

Code:
[State 182, 4];random voice system
type = VarRandom
trigger1 = Time = 0
v = 18;----------------------OR ANY OTHER free VAR
range = 0,100


then adding this kind of code in any playsnd you choose

Code:
triggerall = Var(18) = [0,49];percentage 100

In this exemple, for 2 musics

the first
Code:
triggerall = Var(18) = [0,49];percentage 100

the second
Code:
triggerall = Var(18) = [50,100];percentage 100


It should work.
If there is some doubt, you can wait for skilled coders to give you a better option. ^^
Re: Music before battle - More than one choice
#3  December 30, 2021, 11:18:46 am
  • ***
    • Peru

  • Online
Hello.

Thank you Momotaro for provide this code. I´ll test it.
Re: Music before battle - More than one choice
#4  December 30, 2021, 06:44:46 pm
  • ******
No need for variables for something this simple.

Assuming you're putting each music in group 200, like this:
200,0
200,1
200,2
etc.

you can just put

value = 200,0+random%n

where n is the number of sound clips you have.

Let's say you have three sounds: 200,0, 200,1 and 200,2
your PlaySND would look like this:


Code:
[State 200, Music Round Start]
type = PlaySND
triggerall = RoundNo = 1
trigger1 = !Ttime
value = 200,0+random%3
channel = 22
Re: Music before battle - More than one choice
#5  December 30, 2021, 07:16:35 pm
  • ***
    • Peru

  • Online
Thank you so much AlexSin and Momotaro for your help.

This last code works perfectly.