"mugen code" parser

Started by Bastard Mami, March 06, 2010, 05:56:42 AM

Previous topic - Next topic

Bastard Mami

as a few guys here might know, I have been working on a mugen full game the past year(s), as less know I have been working on a small little app to make the game programming easier/faster. what it does is take a script very similar to mugen code, then takes self defined sctrls and blocks of code from user created files and substitutes them in a new script file. in the spoiler is the explanation as it is on the readme.

Spoiler (click to show)

/*WHAT IS THIS*/

A parser for mugen code so you can use a slightly higher level code, which is based on mugen's codebut support constants, macros and parent sctrls.

/* HOW TO USE */

1) edit config.txt.

    a) the first line points to the constants definition file.
      
      res/constants.res
   
   In the constant definitions file you code should be like this:
   
      define #constantname
         constantvalue
   
   the define statements tells the parser that a constant is about to be defined, #constantname is the name of the constant, you must use the constant complete with the # in your code so the program does the swapping,the value can be a single word or a series of sctrls.
   
      define #constantname
         constantvalue
         #anotherconstant
   
   you can define constants recursively.
   
   in you cns code now you can do stuff like:
   
      [State velstop]
      type       = VelAdd
      trigger1    = var(#morph)
      Y       = #secondary_gravity
   
    b) the second line points to the parent definition file.
   
      res/parents.res

      In the parent definition file your code goes like this.
      
      [State velstop]
      type       = VelSet
      identity   = VelStop
      trigger1    = Time = 0
      X       = 0
      Y       = 0
      
      as you can see, it's regular mugen code but with one difference; you must give the sctrls and identity, any other parameters are optional; the identity is used in your cns code to call the parent sctrl in the following way:
      
      [State 40, 4]
      parent = VelStop
      trigger1    = Time = 1
      
      which will be converted to:
            
      [State 40, 4]
      trigger1    = Time = 1
      type       = VelSet
      X       = 0
      Y       = 0

      if there are duplicated parameters (like the trigger1), the parent's parameers won'tbe used but the sctrl's will.
      
      something to note is that a parent can also have parents, like:
      
         [State velstop]
         type       = VelSet
         identity   = VelStop
         trigger1    = Time = 0
         X       = 0
         Y       = 0

         [State velstopX]
         parent      = VelStop
         type       = VelSet
         identity   = VelStopX
         trigger1    = Time = 0
         X       = 100

      so, if you have:
      
         [State 40, 4]
         parent = VelStopX
         trigger1    = Time = 1
      
      you will get:
      
         [State 40, 4]
         trigger1    = Time = 1
         type       = VelSet
         X       = 100
         Y       = 0

   
    c) any following lines are a pair of input file/output files(in the case of output files, if you use subfolders they must already exist).
      
      normals.src test/normals.st


Bastard Mami

Sorry, I konw my last post was horrible at explaining what the program does, itwas late at night for me and I was sleepy.

here is a statedef
Quote;___________________________________________________

[Statedef #close_a]
parent   = vgm_statedef_normal

#vgm_initVelSet
#vgm_initChangeAnim

[State Idle ]
parent   = vgm_backToIdle
Trigger1    = !AnimelemTime(5)

[State esp]
parent   = vgm_soundNormal

[State Counter Hit Damage]
parent      = vgm_counterHitDamage
Value          = -1*(Floor(fvar(0)*(9.8*(random%1))+(random*.001)))
[State hit ]
parent       = vgm_hitdef_normal_weak
Trigger1    = !AnimelemTime(4)
Damage             = Floor((29+((random%1)*9.8))*fvar(0)), 0
SparkXY          = 0, -75
GuardFlag          = L

#vgm_endState

those are excerpt from the parents file
Quote
[Statedef 210]
identity   = vgm_statedef_normal
Type          = S
MoveType      = A
Physics       = S
Ctrl          = 0
PowerAdd       = 0
Juggle        = 10
FaceP2          = 1
HitDefPersist       = 0
MoveHitPersist       = 0
HitCountPersist    = 0
SprPriority       = 2


[State Counter Hit Damage]
identity   = vgm_counterHitDamage
Type       = TargetLifeAdd
Trigger1    = NumTarget
Trigger1    = var(15)&1
Value          = -1*(Floor(fvar(0)*(9.8*(random%1))+(random*.001)))
Kill          = var(12)
Absolute      = 0
Persistent      = 0


in the case of parents, if both teh parent and the child have teh same parameters, the child's parameteris used, as seen in the counter hit damage sctrl.

the constants can be simple values or full pieces of code.

Quote
define #close_a
210
define #far_a
310
define #crouch_a
410
define #air_a
610


define #vgm_endState

[State Return]
Type       = ChangeState
Trigger1    = AnimTime = 0
Value          = 0
Ctrl          = 1

I ahd not planned for the constantsto be full pieces of code, but as I talked about this on irc insanius suggested that and I found it to be a enat idea (and one of the reasons I share this info is because I might get similar good ideas that I had not tought of).

rednavi -RETIRED

I'll be honest, I only understood like 1/2 of all this but is this supposed to be something that lets you change stuff on a helper depending of the user config loaded? because it sounds quite cool

MirageAtoli

[E], you need a static website to put all of your stuff; seriously.
Quote from: Titiln on December 31, 2007, 10:46:10 PM
i think we should call it an "engine" so we don't look like total idiots because otherwise we'd be arguing about a "game" and that would be somehow "dumber" than arguing about an "engine" on the "internet" for countless hours

Quote from: Beatrice on March 01, 2010, 06:55:03 PM
Quote from: Iced
I for one, do not enjoy round corners!  :bigcry:
But they hurt much less when we accidentally hit them!  :S

Cybaster

Quote from: Rednavi on March 10, 2010, 11:41:07 PM
I'll be honest, I only understood like 1/2 of all this but is this supposed to be something that lets you change stuff on a helper depending of the user config loaded? because it sounds quite cool
Basically, it allows you to code for Mugen using "real" coding syntax, or at least something easier to read and correct.

You can give names to your variables and constants, and they will refer to a number, as shown in :
Quotedefine #close_a
210
Then, when you write "[Statedef #close_a]", it actually means statedef 210, except that it's much easier to read for you.

However, the best is the parent system. You surely noticed that when you're writing a HitDef for example, you keep copy-pasting the same stuff over and over again between each hitdef, only changing a few values. The parent system allows you to just write something like
Quoteparent   = vgm_statedef_normal
And when the program will convert back your code to mugen code, it will change this line by what you defined as vgm_statedef_normal. In short, you just write this line of code, and during the conversion to Mugen code, it will write (taking [E]'s example :
Quote
[Statedef 210]
identity   = vgm_statedef_normal
Type          = S
MoveType      = A
Physics       = S
Ctrl          = 0
PowerAdd       = 0
Juggle        = 10
FaceP2          = 1
HitDefPersist       = 0
MoveHitPersist       = 0
HitCountPersist    = 0
SprPriority       = 2




Anyway, this all looks very cool. This pointer/parent system is really very nice and well thought.

Is it possible to initialize variables as you would do for constants ? Would this be a valid syntax ?
Quote
define #custom_combo_var
var(17)
If not, it could be something nice.


MirageAtoli

Instead of calling it a parent system, maybe inheritance would be better and less easy to confuse with the players in mugen (p1 thru p4)
Quote from: Titiln on December 31, 2007, 10:46:10 PM
i think we should call it an "engine" so we don't look like total idiots because otherwise we'd be arguing about a "game" and that would be somehow "dumber" than arguing about an "engine" on the "internet" for countless hours

Quote from: Beatrice on March 01, 2010, 06:55:03 PM
Quote from: Iced
I for one, do not enjoy round corners!  :bigcry:
But they hurt much less when we accidentally hit them!  :S

Bastard Mami

Quote from: Cybaster on March 11, 2010, 12:52:43 AM

Is it possible to initialize variables as you would do for constants ? Would this be a valid syntax ?
Quote
define #custom_combo_var
var(17)
If not, it could be something nice.

yes , it is possible:


Quote
define #cancel_buffer
var(20)
define #cancel_ground_ctrl
32

from the cmd file:

Quote[State -1]
Type       = ChangeState
Value          = #close_y
Triggerall    = command = "y" && (helper(200000),command != "holddown")
Triggerall    = #cancel_buffer&#cancel_close
Trigger1    = #cancel_buffer&#cancel_ground_ctrl
Trigger2    =  #cancel_buffer&#cancel_running

thanks for explaining it in better detail than I did. here is a beta of the program, it is likely to have undocumented bugs as I am still testing it while porting samus.
http://www.mediafire.com/download.php?2mdiynnynmy
the currently known bugs are that the program freezes if you use  a parent/constant that has not been defined.

rednavi -RETIRED

Thanks Cybaster I totally got it now :D