Mugen 101: Things you need to know (Read 5496 times)

Started by Odb718, October 13, 2015, 11:04:53 pm
Share this topic:
Mugen 101: Things you need to know
#1  October 13, 2015, 11:04:53 pm
  • *****
  • Shame on you!
    • USA
This thread is to help get the newest user up and editing as fast as possible. It's a collection of the major catch-all threads that break down the major parts of the character. (or it will be eventually)
THIS IS A FIRST STEP. Everything isnt included. There's a lot of stuff left out.
Check out the links if you have questions about each topic.

This thread explains what files Mugen, and the Characters use. Check it out if you dont know what any of the files do.

You'll need the character.def file listed in your Select.def for mugen to even show your character. It links to the cmd file that allows you to change the character's states inside the cns file, that calls on the air file to show the sprites (images) of the character. the cns also calls on the snd file to play sounds. the Def file decides who your character is. The CNS tells mugen how that character acts. The CMD finds out when the character can perform moves.

The start of your character's lists the Player's Variables at the top of the .cns file, lays down most of your character's traits. Just the basics. 
A specific action is usually broken into these groups
the StateDef; starts the specific move
it plays a sound; because the character feels hollow if it doesnt
displays an effect; because fighters kick up dust and use magic left and right
hits player 2; because it's a fighting game!
and changes states;ends the move

The statedefs can do a heck of a lot more. These options are called controllers
Like if you wanted to make a projectile, or a move that makes other moves (a helper). All the controllers go under the statedef, and above the changestate. You dont have to have a changestate to end it, but most states do.

Deciding how to get each of those controllers up and running exactly the way you want, when you want, and why you want is the job of the triggers and variables. (and a bunch of other stuff)
Defining the triggers usually relies on math symbols. But the most basic is just the equal sign. Another important step in editing your characters is learning how to tell mugen, if this doesnt work, do something else. << Ifelse() and Cond() are as important to learn as Variables. Variables remember stuff between statedefs. If you set them up they can even remember between rounds. (Check the Player's Variables link)

In the CNS file there are two special statedefs, Statedef -2, and Statedef -3.
Statedef -1 IS/is in the CMD file.
Mugen constantly monitors these Statedefs without the character having to be in them.
 States that are always executed (use statedef -2)
 States that are executed when in self's state file (use statedef -3)
Electbyte's example,
[Statedef -3]
;This controller plays a sound everytime KFM lands from a jump, or
;from his back-dash.
[State -3, Landing Sound]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 52 ;Jump land
trigger2 = stateno = 106 ;Run-back land
value = 40, 0
Would work best in Statedef -3 because if P2 throws you and uses stateno 106 the sound would play. Obviously this is something the other creator wouldnt want to happen.

DO NOT FORGET YOUR [Statedef -2] and [Statedef -3]
Be sure these are located before all -2 and -3 state coding.

The CMD controls the controls. The input from the keyboard/controller is matched up to commands in the Command Definitions, then the State Entry kicks in. Command Definitions section has [Remap], [Defaults], and [Command]. There can be a maximum of 128 Command names.
The State Entry, Statedef -1, part is usually where you see all of the ChangeStates and AI code. 
Commands can also be read as triggers which allows you to sneak in statedef -1 style changestates inside the CNS file. The name has to be inside the CMD file for it to work though.

If youre having trouble making the commands work, there's a common mess up.
As I mentioned, mugen is constantly searching statedef -1. It's also looking at button inputs to match against the command definitions. Because people arent super precise pressing buttons, Mugen gives us some leeway. While you may think you pressed F,D,DF, A, in reality you may have pressed, F,DF,D,DF,F, A. If you notice the first set of inputs is hidden inside the second set. Mugen lets that activate the command which will go down the line to the changestate. If both sets are actually a named command, both will be triggered in the order their listed.
Meaning if  F,D,DF, A  is above  F,DF,D,DF,F, A. Mugen checks it first to see if any ChangeStates with that name can be activated. If not, Mugen will check if any Changestates F,DF,D,DF,F, A. can activate.
The way to make sure you can do all of your moves properly is to make sure the most complex input commands are at the top Going a step further you'd need to make sure your most complex ChangeStates are at the top of the State Entry section. This isnt always the case but it's important and just good practice.
This thread is a mess right now. I plan on editing this a lot. For now, I think I'll lock the topic until it's a little better.
If you feel I should refine or talk about anything and it's still locked, shoot me a PM and I'll add it.

vVv Wheat Stage Released vVv
Last Edit: June 30, 2016, 07:16:13 pm by Odb718
Re: Mugen 101: Things you need to know
#2  October 13, 2015, 11:05:19 pm
  • *****
  • Shame on you!
    • USA
This post will hopefully list some useful info if you're having trouble with your character(s). Your best bet if you're running into trouble is to use the search button and search ALL of Mugen Development Help. If you're having a specific problem with something, refer to The MUGEN Docs Master Thread. If your question isnt answered post a question in help. We've all been there.

The first thing any good Mugen player/dev should learn is the Hot Keys. These little tricks come in super handy for development. Debug is by far the most useful hot key if you're coding a character. (That, and Spacebar)
Cycling debug will go from Player to Player to Player... to Off. Once debug is off and is restarted it jumps back to P1. Remember Helpers also count as Players! So if you press Ctrl+D and it's on a helper you'll get the info for that helper. Debug posts the Anim, AnimElemno, Time, Animtime, and StateNo, and a bunch of other info. You can also get it to post almost anything else you'd like to know using DisplayToClipboard & AppendToClipboard. Helpers can also use Display and Appendtoclipboard. You just have to cycle debug until you reach the helper. If debug is active for the helper and it's destroyed, You'll see a message like "Player 4 Disabled". Debug will automatically work if the helper is recreated. If the Helper isnt active cycling debug will skip over it's spot and proceed to post about the next character. (or turn off) If the helper is destroyed and you move to the next player, and the helper is then recreated, you can cycle all the way back through and debug will post the info for the helper.
Debug is useful to keep on if you're doing more dev'ing than battling. Look inside C:\Mugen\Data\Mugen.cfg (or where ever you have your mugen) for
 ;Set to 0 to disable starting in debug mode by default.
Debug =
and set it to 1.
This will help with 2 things. Having to turn it on every time you load up, and the fact that pressing ctrl+d skips the intro(s). Remember, if you need to debug the intro and you dont have debug on, F4 will reset the round and you'll see a random intro.

Debug will also help you see the Flood. Debug flood will post if youre missing required sprites, if your using a float value in the wrong spot, and a few more things.

VirtuallTek's Fighter Factory 3 will also list any syntax errors in the CNS file. It's very useful for finding problems and typos. You should really be using this tool if you're building characters.
You'll see the error(s) in the bottom right of FF3. They'll look like this

Double click on that icon and a box will pop up listing all the errors

 In my example you can see it lists, SFF, AIR, CMD, and ST. I'm not sure if SND file can have an error or if FF3 would detect it. If you double click each line, FF3 will jump to the problem.

More to come later as I think of it.
vVv Wheat Stage Released vVv
Last Edit: May 06, 2016, 12:34:11 am by Odb718
Re: Mugen 101: Things you need to know
#3  October 08, 2016, 01:09:55 am
  • ******
States are executed in this order:



normal states, ordered by cns files based on DEF (2 states with the same number, the one loaded first on the CNS is executed, the other will never be activated)

common.cns states
Re: Mugen 101: Things you need to know
#4  January 27, 2017, 09:08:30 pm
  • ******
Last Edit: August 25, 2017, 05:34:34 am by Just No Point
Re: Mugen 101: Things you need to know
#5  January 17, 2019, 07:40:34 pm
  • avatar
  • **
Hmm, IsnĀ“t here are now also that FF fusion or what it called?