Jump to content
  • 0

Randomized BGM on Stage Issues?


LunarDash

Question

Hi everyone, I posted a thread about this elsewhere but figured I would try here as well to see if anyone had any input.

 

I am trying to utilize some code meant to go in common1.cns that I found from a thread on Mugen Archive while browsing for a solution to using randomized BGM on stages. I implemented it and it sort of worked as described, however I noticed that the songs don't continue after the round ends. I figure this has to do with PlaySnd or something along those lines, but here's the original code I am working from:

Spoiler

[statedef-2]
 
 
[State -2, PlaySnd]
type = PlaySnd
triggerall = time = 0 && roundstate != 2 && !win && !lose
trigger1 = StageVar(info.name) = "stagename" ; Name of stage in between the quotation marks
value = F5001,random%2 ; the numbers after F is your song of choice and random%X will be the number of songs you want to be randomized. Please add your music to Common.snd or anything similar. Not all of your character's snd files.
volumescale = 2000 ;If your music is too loud.
persistent = 0
channel = -1
;lowpriority = -1
freqmul = 1.0
loop = 0
pan = 0

 

 

I've tried a few things such as moving it into State 5900 (I did this because I saw somewhere that negative states should be avoided when editing common1.cns as they can easily be overridden) and also having the song be chosen by a VarSet prior to PlaySnd being triggered (more on this later in the post.) However, my issues still persist. Is there a way to have a PlaySnd state fully act as BGM? If not, is there a way for me to set a specific start time based on a variable that tracks the amount of ticks that go by in a battle? 

 

As for my other issue, I've noticed that when a battle starts, sometimes both sounds will play at once. I've tried resolving this by having a VarSet generate a random number before the PlaySnd and then use that variable to choose the sound from common.snd. However, it still occurs about 33% of the time. I tried rounding the random number thinking there may be some funky decimals going on there or something, but given how modulus works, this makes no sense. I going to leave the code that I'm working on myself below. Thanks to anyone who takes a look!

Spoiler

[State 5900, BGM Randomizer]
type = VarSet
trigger1 = roundno = 1 && time = 0
sysvar(2) = random%2

[State 5900, BGM]
type = PlaySnd
trigger1 = time = 0
trigger1 = StageVar(info.name) = "Training Room 720"
value = F5000,sysvar(2)
persistent = 1
ignorehitpause = 1

 

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

All sounds are muted between rounds and it is not possible to play audio from a specific point unless you split the audio up, but that would be ridiculous.

 

For the second issue, be aware that if you've modified the global 5900 state and no character overwrites it, both characters will play a sound effect; alternatively, if this is a character's state 5900 you've modified, a mirror match will produce the same result.

Link to comment
Share on other sites

  • 0
37 minutes ago, PlasmoidThunder said:

All sounds are muted between rounds and it is not possible to play audio from a specific point unless you split the audio up, but that would be ridiculous.

 

For the second issue, be aware that if you've modified the global 5900 state and no character overwrites it, both characters will play a sound effect; alternatively, if this is a character's state 5900 you've modified, a mirror match will produce the same result.

That makes sense. I added a trigger for the global 5900 states that I was using so that they can only be triggered by player 1. It didn't even occur to me that since it's reading from common1 both characters are going to execute that code.

 

I've been reading up on IKEMEN lately and it appears that there is a feature to have BGM be randomized from a specific set of songs, so I think I may try and build my full game upon that instead. I have a few ideas for stages that would be cool to have a variety of songs play on. I'm not exactly sure how that feature works, but I wonder if I can do something to make it so when a certain song plays, a certain animation also plays. That'd be something I have to mess around with to figure out about, though, as I imagine it's dependent on if it takes place in the .def somewhere or in some other file.

 

Thanks for the info!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...