YesNoOk
avatar

Commonly-used controllers (CNS) (Read 2375 times)

Started by Just No Point, October 07, 2015, 03:33:31 am
Share this topic:
Commonly-used controllers (CNS)
#1  October 07, 2015, 03:33:31 am
  • ******
    • www.justnopoint.com/
The null controller will be useful for debugging. A null controller basically does nothing. You can use it to temporarily turn off certain controllers, instead of commenting out the entire section. For example, you might want to disable this:

Code:
[State 300, 1] ;Controller that accelerates P1 forwards
type = VelAdd
trigger1 = Time >= 0
x = .8
Simply comment out the type and put in null:

Code:
[State 300, 1] ;Controller that accelerates P1 forwards
type = null ;VelAdd
trigger1 = Time >= 0
x = .8
Later, when you want to reenable the controller, just change the type back to what it used to be.

Now let us look back at the example:

Code:
[Statedef 200]
type = S
physics = S
movetype = I
ctrl = 0
anim = 200
velset = 0

[State 200, 1]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
[State 200, 1] is a ChangeState controller. As the name implies, it changes P1's state number (i.e., the [StateDef] block from which P1 executes). The value parameter should have the number of the state to change to. The optional ctrl parameter can be set P1's control flag as he changes states.

Now let's make this an attack state. First of all, the animation action needs attack collision boxes. A quick review from the AIR documentation: Clsn1 is for attack and Clsn2 is where the player can be hit. So P1 will hit P2 if any one of P1's Clsn1 boxes intersects with any of P2's Clsn2 boxes.

As an example, let's assume the animation action in P1's AIR file looks like this:

Code:
[Begin Action 200]
200,0, 0,0, 3
200,1, 0,0, 4
200,2, 0,0, 4
200,3, 0,0, 3
After defining the bounding boxes, it looks like:

Code:
[Begin Action 200]
Clsn2: 1
  Clsn2[0] = -10,0, 10,-80
200,0, 0,0, 3
Clsn1: 1
  Clsn1[0] =  10,-70, 40,-60
Clsn2: 2
  Clsn2[0] = -10,  0, 10,-80
  Clsn2[1] =  10,-70, 40,-60
200,1, 0,0, 4
Clsn2Default: 1 ;Use this box for the last two frames
  Clsn2[0] = -10,0, 10,-80
200,2, 0,0, 4
200,3, 0,0, 3
As you can see, each element has a Clsn2 box defined for it (the last two elements are using the same boxes). The second element is the only one with a Clsn1 box.

Note: It is all right to define Clsn1 boxes for any elements in an Animation Action, but if you put a Clsn1 box in the very first element, the attack will be instantaneous, and become unblockable. Therefore, it is recommended that you define Clsn1 boxes only for elements after the first one.

Now we are ready to set up the state in the CNS. We will explain the changes below.

Code:
[Statedef 200]
type = S
physics = S
movetype = A  ;<-- changed from "I" to "A"
ctrl = 0
anim = 200
velset = 0

[State 200, 1] ;<-- Added this state controller
type = HitDef
trigger1 = AnimElem = 2
attr = S, NA
animtype  = Light
damage    = 10
guardflag = MA
pausetime = 12,12
sparkxy = 0,-55
hitsound   = 5,0
guardsound = 6,0
ground.type = High
ground.slidetime = 12
ground.hittime  = 15
ground.velocity = -5
air.velocity = -2.5,-3.5

[State 200, 2]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
The movetype parameter in the StateDef is set to A for "attack". Remember to do this for all attack states. As before, P1 changes back to his standing state after his animation is over.

That HitDef controller looks like a monster! Do not worry, we will go through it slowly.

Code:
type = HitDef
trigger1 = AnimElem = 2
This specifies the controller type as HitDef, which stands for "Hit Definition". It is triggered on the second element of animation. Any Clsn2 box from the time the trigger was activated will take on this hit definition.

If, for example, you had a Clsn1 in both the second and third element of animation, triggering a single HitDef at the second element makes it apply to both elements of animation. So P1 will hit at most once: if the second element hits, the third will miss. If the second element misses, the third can still hit. To make the attack hit twice, you must trigger a HitDef for each of the two elements.

Code:
attr = S, NA
This is the attribute of the attack. It is used to determine if the attack can hit P2. In this case, it is a Standing Normal Attack.

attr has the format attr = arg1, arg2, where:
  • arg1 is either S, C or A. Similar to statetype for the StateDef, this says whether the attack is a standing, crouching, or aerial attack.
  • arg2 is a 2-character string. The first character is either N for "normal", S for "special", or H for "hyper" (or "super", as it is commonly known). The second character must be either A for "attack" (a normal hit attack), T for "throw", or P for projectile.

Code:
animtype = Light
This refers to the type of animation that P2 will go into when hit by the attack. Choose from light, medium, hard or back. The first three should be self-explanatory. Back is the animation where P2 is knocked off her feet.

Code:
damage = 10
This is the damage that P2 takes when hit, and it does no damage if guarded. If we changed that line to damage = 10, 1, then it would do 1 point of damage if guarded.

Code:
guardflag = MA
guardflag determines how P2 may guard the attack. Here, it may be guarded high(standing), low (crouching) and in the air. The argument must be a string of characters that includes any of the following: H for "high", L for "low" or A for air. M (mid) is equivalent to saying HL.

Code:
pausetime = 12,12
This is the time that each player will pause on the hit. The first argument is the time to freeze P1, measured in game-ticks. The second is the time to make P2 shake before recoiling from the hit.

Code:
sparkxy = 0,-55
This is where to make the hit/guard spark. The arguments must be in the form x, y. x is relative to the front of P2. A negative x makes a spark deeper inside P2. y is relative to P1. A negative y makes a spark higher up.

Code:
hitsound = 5,0
This is the sound to play on hit (from fight.snd). The included fight.snd lets you choose from 5,0 (light hit sound) through to 5,4 (painful whack). To play a sound from the player's own SND file, precede the first number with an S. For example, hitsound = S1,0.

Code:
guardsound = 6,0
This is the sound to play on guard (from fight.snd). Right now all we have is 6,0. To play a sound from the player's own SND file, precede the first number with an S.

Code:
ground.type = High
This is the kind of attack for ground attacks (it also defaults to air attacks if you do not specify an air.type parameter). In this case, it is a high attack. Choose from High for attacks that make P2's head snap backwards, Low for attacks that look like they hit in the stomach, Trip for low sweep attacks, or None to not do anything to P2. High and Low attacks are the same on P2 if the AnimType is Back.

Code:
ground.slidetime = 12
This is the time in game-ticks that P2 will slide back for after being hit (this time does not include the pausetime for P2). Applicable only to hits that keep P2 on the ground.

Code:
ground.hittime = 15
Time that P2 stays in the hit state after being hit. Applicable only to hits that keep P2 on the ground.

Code:
ground.velocity = -5
Initial x-velocity to give P2 after being hit, if P2 is in a standing or crouching state on the ground. You can specify a y-velocity as the second argument if you want P2 to be knocked into the air, eg. ground.velocity = -3, -2.

Code:
air.velocity = -2.5,-3.5
Initial velocity to give P2 if P2 is hit in the air.

There are more things that you can control in a HitDef. See the sctrls documentation for details.
Re: Commonly-used controllers (CNS)
#2  October 10, 2015, 07:46:52 pm
  • ***
  • Mega Man Classic
  • pachirisu is sexy af
    • Canada
    • anoobtroll@gmail.com
I understand that S is for standing friction, A is for air friction, and C is for crouch frictioning but I don't understand what "U" does in type =


Can I have an explanation for this?
Pokecommunity account (Will start learning about romhacking): http://www.pokecommunity.com/member.php?u=553303

Why are there some people here trying to go into their ways into trying to ruin my Mugen hobby here and make me look like bad?



https://www.youtube.com/watch?v=3_TMrr6eqQc
Re: Commonly-used controllers (CNS)
#3  October 10, 2015, 07:53:49 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
I understand that S is for standing friction, A is for air friction, and C is for crouch frictioning but I don't understand what "U" does in type =


Can I have an explanation for this?

I think U stands for Unchanged - as in, whatever the previous state type was will persist.

Re: Commonly-used controllers (CNS)
#4  October 11, 2015, 03:23:03 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
That is correct.

For any state controller there aren't actually many rules

[State]

I think that's all that is required. Normally people do [State Number, debug identifier]

Those have no bearing on the code at all. All you need is the [state ] bit, the rest is free commenting fluff. I often just do [State Hitdef] these days. It's rubbish for debugging, but if you know you're not changing much it's much cleaner to copy paste things between states as you don't need to sit there changing numbers about.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.