YesNoOk
avatar

[Tutorial] Constants (Read 20201 times)

Started by PotS, September 22, 2006, 08:31:22 am
Share this topic:
[Tutorial] Constants
#1  September 22, 2006, 08:31:22 am
  • ******
    • network.mugenguild.com/pots/
I've seen a lot of people using weird values in the constants, so decided to write a simple tutorial about them to shed some light on the subject, or at least make people pay more attention to it.
I was also bored and feeling like writing something. ;P

Default values used here refer to Kung Fu Man's constants.
I ommitted them when they only fitted Kung Fu Man.

Format is usually like this:

constant
Brief explanation
Default value

Some more details about it

Saying how to get that value and/or which one to use



[Data]


life
Ammount of life the character starts with.
Default = 1000

You usually don't need to change this, but for characters from some games you'll have to do some math.

Let's take CvS2 Sakura as example, she has 13600 life points when the average value is 14400. To recreate that in Mugen you'll have to do this calculation:

(Char's Game Life) * (Mugen's Average Life) / (Game's Average Life)

In Sakura's case, equals to:
13600 * 1000 / 14400 = 944.444...
So you'd use 944 or 945 as the life value, since Mugen doesn't accept floats there.


power
Maximum ammount of power the character can hold.
Default = 3000

This one isn't shown in KFM's constants, but everyone knows it exists by now.

Pretty easy, you just need to multiply the number of levels you want the character to have by 1000. So if a character has 5 powerbar levels in its original game, in Mugen it'd have power = 5000, and so on.


attack
Attack power given in percentage.
Default = 100

Affects the ammount of damage each attack does to an opponent, higher values mean higher damage.
I said it's given in percentage because 100 means regular damage (100%), so 200 means double damage, 50 means half damage and so on, but you can use whatever integer value you want.

Don't change it, just leave it at 100, it's best to modify the damage values of each attack instead. Change it only if you notice you screwed up on those damages and want to fix them quickly by increasing/decreasing all of them at once.


defence
Defensive power given in percentage.
Default = 100

Affects the ammount of damage the character receives, higher values mean lower damage.
Like with attack, I said it's given in percentage because 100 means regular damage (100%), so 200 means half damage, 50 means double damage and so on, but you can use whatever integer value you want.

And like with life, for characters from some games you'll have to do some math.
To get a good idea of the character's defense, it's best to hit him with a single, very damaging move, preferably one that does a single hit. Then do the same to a char of average defense (usually the Ryu/Kyo of the game) and compare those values.

I'll use MSHvSF Zangief being hit by Mech Gouki's Shining Gou Shock (counts as one hit) as an example here. Maximum life for this game is 144, and the move damages Zangief by 67 while it damages Ryu (the average character) by 75.
To recreate that in Mugen you'll have to do this calculation:

(Damage Average Char Received) / (Damage Char Received) * 100

In this case, equals to:
75 / 67 * 100 = 111.940...
So you'd use 112 as the defence value, since Mugen doesn't accept floats there.

Note that it's best not to rely on a single measurement, you should make some more and then check the average value.


fall.defence_up
Percentage to increase defense everytime player is knocked down.
Default = 50

Affects the defense value when the character is falling after being hit by a sweep type of move.

You won't need to change this, leave it at 50 unless you have other plans.


liedown.time
Time which the characters lies down for, before getting up again.
Default = 60

Determines how long the character stays on the floor every time he's knocked down. Value is measured in gameticks, so 60 means 1 second and so on.

To let the char interact better with chars of different gameplays, it's better to leave it at 60, but there isn't much harm in changing it to the same value as in the original game.


airjuggle
Maximum juggle points.
Default = 15

Along side with the juggle in Statedefs, this determines how many times you can juggle an opponent.

Juggling is simple once you're used to it, otherwise it takes a while to understand. I'll try to give a brief explanation about it.
In order for this value to have any effect, you need to add juggle values to the Statedefs of attacks, and  air.juggle to Hitdefs of projectiles.
Everytime a move knocks down an opponent, or hits one that's already falling, juggle points are decreased by what you specified in the Statedef, and when they're not enough or already equal or below 0, you can't hit the opponent out of the air until he recovers.

Let's use Gouki as an example and leave this constant at 15. Now let's add juggle = 10 to his Gou Shoryuken and juggle = 5 to his Tatsumaki Zankuu Kyaku Statedefs.
If you hit an opponent with Shoryuken, your juggle points are decreased by 10, leaving them at 5. While that opponent is falling, if you try to hit him again with another Shoryuken it will miss entirely, because your juggle points aren't enough to allow the move to hit (you have 5, while the move requires/spends 10). However, if you try to him with the Tatsumaki instead, that move will hit without a problem because your juggle points are enough (you have 5, which is what the move requires/spends).
As another example, you could juggle the opponent with 3 Tatsumakis, since each takes 5 juggle points and you have 15 to spend.

Juggle points are reset whenever the opponent isn't in a movetype=H.
Note that helpers have their own juggling, separate from the character.

Hope this explanation shed some (more) light on the matter. For more info on it, you can read some FAQs or check Elecbyte's doc about CNS.


sparkno
Default hit spark anim for Hitdefs and Projectiles.
Default = 2 (Mugen's strong hit spark)

Hit spark that is used by default by every Hitdef and Projectile. To override it just use sparkno in Hitdefs/Projectiles.
To use an anim from your own AIR, add "s" before the anim number, like "sparkno=s8000" where 8000 is the anim you want it to use.

If you're using custom sparks, change this value to use one of them.


guard.sparkno
Default guard spark anim for Hitdefs and Projectiles.
Default = 40 (Mugen's light guard spark)

Same as sparkno, but for the guard sparks.


KO.echo
Enables/disables echo on the character's KO sound.
Default = 0

If your character's KO sound already has an echo, set it to 0, otherwise whatever you choose is fine.


volume
Volume offset, positive for louder, negative for softer.
Default = 0

Affects the volume of every sound your character plays. Maximum is 255, minimum is -255.

Put your character against others for a while, then tweak this until his sounds are about as loud as the others'.


IntPersistIndex
Variables (var) with this index and above will not have their values reset to 0 between rounds or matches.
Default = 60

So, setting it to 30 will make var(30) and above be reset to 0 between rounds, and so on.

Personnaly, I like setting this to 0 (all variables persist between rounds) and resetting them myself manually.


FloatPersistIndex
Float variables (fvar) with this index and above will not have their values reset to 0 between rounds or matches.
Default = 40

Same as IntPersistIndex, but for float variables.



[Size]


xscale
Horizontal scaling factor.
Default = 1

Determines the horizontal scale of the character's sprites . 1 is normal size, 2 is twice as big and so on.

Usually best to leave it at 1 (or .5 for hi-res chars), to avoid distorting the sprites.

You can also use this to resize characters to other resolutions (like CPS to 4:3 and such). To do so, just do this calculation:

320 / (Game's Horizontal Resolution) = xscale
240 / (Game's Vertical Resolution) = yscale

For example, to convert an arcade SFA char to 4:3 resolution (as seen in CvS), knowing that SFA's resolution is 384x224 that equals to:
320 / 384 = 0.833...
240 / 224 = 1.071...
So you'd use xscale=0.833 and yscale=1.071.

Keep in mind that, if you change the x and yscale, you should adapt the other [Size] parameters accordingly.

yscale
Vertical scaling factor.
Default = 1

Same as xscale, but for the vertical scale.


ground.back
Width of the character's back when on the ground.

Determines the width of the character when he's on the ground. Higher values make the character wider and vice-versa.

Usually the same value as ground.front. Read below for more info.


ground.front
Width of the character's front when on the ground.

Determines the width of the character when he's on the ground. Higher values make the character wider and vice-versa.

If you're making a KoF char, you can check this value by using the debug DIP switches and measuring the "size" collision box (the one that's always the same despite the char's anim).
Otherwise, if you know your way around Artmoney or a similar program, look for P1 and P2's X position, then select the same character for both players. Now make both characters push eachother, pause the game, and check their positions in Artmoney. Finally, just subtract the two positions and divide the result by 2 to get your width.

For example, I made two Chun-Lis push each other in SFA3 and their X positions were 660 and 620, which means the distance between them is 40 pixels and thus their front width is 20 pixels.

(Note added by Renzo) Also, be aware that if one of the CLSN2s defined for the character has less width than the ground.front value, when the player is pushed or pushes a player it will look like he's trembling. Most noticeable when you push a character that is in State 0.


air.back
Width of the character's back when in the air.

Same as ground.back, but for when the character in in the air.

Usually the same value as air.front. Read below for more info.


air.front
Width of the character's back when in the air.

Same as ground.front, but for when the character in in the air.

Calculated the same way as ground.front, but while the character is jumping.

With the second method, I made two Guys push each other in SFA3 in the air while jumping forward, and their X positions were 829 and 865, which means the distance between them is 36 pixels and thus their front width is 18 pixels.


height
Height of player (for opponent to jump over).
Default = 60

Determines the height of the character. Higher values make it harder for opponent to jump over him and vice-versa.

If you're making a KoF char, you can also check this with the same method as with ground.front.

Otherwise, you can use Artmoney or a similar program to check the difference in altitude at the moment one character jumps over the other.
To do this, put both characters as close to each other as you can, then jump forward with one of them and pause the game. Now advance the game frame by frame while checking the characters' X and Y position in Artmoney, you'll notice that the X position of the jumping character won't change until he reaches a certain altitude. Take note of that altitude and subtract it by the other character's Y position, that gives you his approximate height.

As an alternative, you can calculate this relatively to Kung Fu Man's height.
Let's use SFA3 Karin as example, knowing that she's 81-pixels-tall in her stance and that Kung Fu Man is 97-pixels-tall in his stance while having 60 as height value, you'd make this calculation:

(Character's Height in Pixels) * 60 / (KFM's Height in Pixels)

In this case, means:
81 * 60 / 97 = 50.103...
So you'd use 50 as height because Mugen doesn't accept floats there.

Anyway, if you're not sure of this and your character is average-sized, just set it to 60.


attack.dist
Default attack distance.
Default = 160

Determines the default distance at which an opponent has to be from you to start guarding your attack.

For example, setting it to 100 makes characters within 100 pixels of your character be able to guard if he attacks, while characters farther away are not.

Leave it at 160.


proj.attack.dist
Default attack distance for projectiles.
Default = 90

Same as attack.dist, but for projectiles.
Note that attacks from helpers use the attack.dist value and not this one.

Leave it at 90.


proj.doscale
Set to 1 to scale projectiles too.
Default = 0

If you set it to 1, the character's projectiles' scale will be multiplied by his xscale and yscale. So if your char has xscale=2 and yscale=2, setting this to 1 makes his projectiles also twice as big.

Depends on each character, though I'd say using 1 is better.


head.pos
Approximate position of the character's head.

Important to have the character reacting properly to the opponent.

Some people set this according to sprite 5000,0, others (including myself) according to the stance, and most don't set it at all (the shame).
Either way, you get this position like you would for say an explod. You open the SFF and AIR with an adequate program (like MCM or Fighter Factory) and make an anim with the sprite you want to use to get the position. Then click and drag the anim axis (crosshair) until it's on the character's head and check the X and Y position, that's your head.pos.


mid.pos
Approximate position of the character's waist.

Same as head.pos, but for the center of his waist.


shadowoffset
Number of pixels to vertically offset the shadow.
Default = 0

Determines where the shadow is drawn relatively to the character. Setting it to 5 makes the shadow appear 5 pixels lower than usual, and so on.

Leave it at 0, unless you notice the shadow needs to be adjusted.


draw.offset
Player drawing offset.
Default = 0, 0

Determines where the character's sprites are drawn relatively to his axis. Setting it to 5, -10 makes him be drawn 5 pixels to the front and 10 pixels higher than usual, and so on.

Many people use this to fix the axis when they mess it up, don't do that. Just set it to 0,0 and fix the axis manually if needed.



[Velocity]


Explaining how to get these values would require making a velocity tutorial, so I'll just advise you to check one and instead just tell you what each of these values is for.

walk.fwd
Velocity while walking forward.


walk.back
Velocity while walking backward.


run.fwd
Velocity while running/dashing forward.


run.back
Velocity while running/dashing backward.


jump.neu
Velocity that a neutral jump starts with.


jump.back
Velocity that a backward jump starts with.
Y velocity is the same as jump.neu.


jump.fwd
Velocity that a forward jump starts with.
Y velocity is the same as jump.neu.


runjump.back
Velocity that a jump starts with if it was executed from running/dashing backward.


runjump.fwd
Velocity that a jump starts with if it was executed from running/dashing forward.


airjump.neu
Velocity that a neutral aerial/double jump starts with.


airjump.back
Velocity that a backward aerial/double jump starts with.
Y velocity is the same as airjump.neu.


airjump.fwd
Velocity that a forward aerial/double jump starts with.
Y velocity is the same as airjump.neu.



[Movement]


airjump.num
Number of air jumps allowed.

Air jump means, obviously, a jump performed while in the air. Think Guilty Gear or Marvel VS Capcom.
Setting it to 2 lets your character perform 2 additional jumps in the air, and so on.

airjump.height
Minimum distance from ground before you can air jump.

Your character must be at least at this altitude to perform an air jump, otherwise he won't be able to.
Note that this uses a positive value for above ground level and a negative one for below.


yaccel
Vertical acceleration.

Y velocity added each tick when the char is using physics=A or a Gravity Sctrl.

Like with the Velocity part, you should check a velocity tutorial for this.
If you're not sure about it use .5, that's the value used in most games.


stand.friction
Friction coefficient when standing.

X velocity is multiplied by this every tick while using physics=S.

Messing with this may prevent your char from reacting properly to hits, so leave it at .85 unless you know what you're doing.


crouch.friction
Friction coefficient when crouching.

X velocity is multiplied by this every tick while using physics=C.

Messing with this may prevent your char from reacting properly to hits, so leave it at .82 unless you know what you're doing.



That's it, hope this helps somehow. I haven't read it before posting, so let me know of any typos, confusing sentences and whatnot.
Also feel free to slap me if this is utterly useless :sugoi:, though I think it isn't.
Use anything you want from my works.  If you need to contact me use email, not private messages.
Last Edit: September 24, 2006, 04:40:53 pm by P.o.t.S.
Re: [Tutorial] Constants
#2  September 22, 2006, 04:20:55 pm
  • *****
    • Peru
Really nice.
Only pointing one thing you maybe noticed:
If one of the CLSNs defined for the character exceeds in width the ground.front value, when the player is pushed or pushes a player it will look like he's trembling. Noticeable when you push a character that is in State 0.
Re: [Tutorial] Constants
#3  September 23, 2006, 09:01:06 pm
  • ******
    • network.mugenguild.com/pots/
Really nice.
Only pointing one thing you maybe noticed:
If one of the CLSNs defined for the character exceeds in width the ground.front value, when the player is pushed or pushes a player it will look like he's trembling. Noticeable when you push a character that is in State 0.
thanks. i'll add that

Quote
Two things:
The damage values seem off, Zangief's defense in that game is actually about 115
Also, some games use random damage, which can either bounce around greatly, or just a tiny bit. (i.e +1 damage every once in a while). It's best to do multiple experiments with this to ensure no random factors are involved, and if there are that you can at least derive if there's a significant difference in defense (the smaller the shifts, the better)
using sgs probably threw it off. i wanted to use otoko michi (nice single-hit damage) but the damage isn't so great. should replace that example (*takes note*), hm... maybe screw piledriver can provide what i need
and yeah i noticed the -1 randomness in the mvc games, but not in other games, so adding that info may just complicate things more than they should be

edit @ renzo: after checking, it's the other way around, when width > clsn2
Use anything you want from my works.  If you need to contact me use email, not private messages.
Last Edit: September 23, 2006, 09:09:26 pm by P.o.t.S.
Re: [Tutorial] Constants
#4  September 24, 2006, 10:22:23 am
  • *****
    • Peru
Oh, I see. Well, the problem was anyways related to front, clsn2 and a > somewhere :P
Re: [Tutorial] Constants
#5  October 10, 2015, 03:32:18 am
  • avatar
  • **
  • Mugen League Host
  • Mugen League Host
    • Malaysia
    • fljyin08020511@gmail.com
    • Skype - fljyin08020511
    • http://www.mugenleague.com/
IntPersistIndex
Variables (var) with this index and above will not have their values reset to 0 between rounds or matches.
Default = 60

So, setting it to 30 will make var(30) and above be reset to 0 between rounds, and so on.

means that if i write it 60,  then the var(0) to var(59) will not be reset to 0? is it?
Host of the team, Mugen League, which drive to promote member's quality work.