YesNoOk
avatar

How to code fly? [Credit to sgn15 to teaching me how] (Read 1650 times)

Started by gopal, September 23, 2012, 07:18:55 pm
Share this topic:
How to code fly? [Credit to sgn15 to teaching me how]
#1  September 23, 2012, 07:18:55 pm
  • *
    • India
    • gopalprasadgd@gmail.com
    • http://gamingx.elementfx.com/
Okay here is the code i use.
I will explain codes line by line.
;----------------------------------------------------------------------------------
; go to fly mode
[Statedef 999] ;< Statedef, this is the process to go in fly from standing.
type = A ;< Make sure you use A = Air as type
movetype = I
physics = N
juggle = 0
velset = 0,0
ctrl = 0
anim = 999 ;< Enter the anim you want

;go up (whether you are in ground or air before you went to this state, you go up)
[State 0, VelSet] ;< This is for make the character go up till the Anim ends
type = VelSet
trigger1 = 1
x = 0
y = -3

[State 0, ChangeState] ;< This Change state is to go to Fly Stand state after you are flying
type = ChangeState
trigger1 = animtime = 0
value = 1000
ctrl = 1

;---------------------------------------------------------------------------
;fly stance
[Statedef 1000] ;< This is fly stance
type = A ;< Make sure you use A = Air as type
movetype= I
physics = N
juggle = 0
poweradd= 0
ctrl = 0
anim = 1000 ;< here enter the number of anim which you want as Fly idle
velset = 0,0

;limit for flying up
[State 0, PosSet] ;< This is to limit the character not to go too high, if you remove it then it won't be fair gameplay.
type = PosSet
trigger1 = pos y <= -180 ;< Limit -180 is ideal for it
y = -180

;fly stance float up
[State 0, VelSet]
type = VelSet
trigger1 = gametime%30 = [0,14] ;< This is to make the character float in AIR to make it look more real
x = 0
y = -1

;fly stance float down
[State 0, VelSet]
type = VelSet
trigger1 = gametime%30 = [15,29] ;< This is to make the character float in AIR to make it look more real
x = 0
y = 1

;turn
[State 0, Turn] ;< Simple Turn, When P2's distance is X <-10
type = Turn
trigger1 = P2dist X < -10

; fly dash forward
[State 0, ChangeState] ;< This is the command for fly dash forward.
type = ChangeState
trigger1 = command = "FF"
value = 1100
ctrl = 1

; fly dash backward
[State 0, ChangeState] ;< This is the command for fly dash backward.
type = ChangeState
trigger1 = command = "BB"
value = 1105
ctrl = 1

;fly forward ;< This is the command for fly forward.
[State 0, ChangeState]
type = ChangeState
trigger1 = command = "holdfwd"
value = 1020
ctrl = 1

;fly backward ;< This is the command for fly backward.
[State 0, ChangeState]
type = ChangeState
trigger1 = command = "holdback"
value = 1021
ctrl = 1

;fly up ;< This is the command for fly up
[State 0, ChangeState]
type = ChangeState
trigger1 = command = "holdup"
value = 1040
ctrl = 1

;fly down ;< This is the command for fly down
[State 0, ChangeState]
type = ChangeState
trigger1 = command = "holddown"
value = 1041
ctrl = 1

;go back to jump/fall state ;< This is the command for jump to ground if you Won in air, you know no one will like to have the win pose in AIR
[State 0, ChangeState]
type = ChangeState
trigger1 = Win = 1
value = 50
ctrl = 1

;go back to damage fall state ;< If you get hit then this will happen.
[State 0, ChangeState]
type = ChangeState
trigger1 = Life = 0
trigger2 = roundstate = 3
value = 5050
ctrl = 1

;go back to fly land state
[State 0, ChangeState] ;< This is to come down from Fly mode
type = ChangeState
trigger1 = pos y >= 0
value = 1047
ctrl = 1

;---------------------------------------------------------------------------
;fly fwd
[Statedef 1020] ;< Fly walk fwd
type = A
movetype= I
physics = N
juggle = 0
poweradd= 0
ctrl = 0
;anim = 1020 ;< I have commented out the anim because i didn't had an Fly walk fwd so i use the Fly idle Anim for it
velset = 0,0

[State 0, Turn]; < Turn
type = Turn
trigger1 = P2dist X < -10

[State 0, VelSet] ;< VelSet or The speed to fly walk fwd
type = VelSet
trigger1 = 1
x = 4
y = 0

[State 0, ChangeState] ;< This change state is to go back to the fly idle state if you are not holding fwd
type = ChangeState
trigger1 = command != "holdfwd"
value = 1000
ctrl = 1

;---------------------------------------------------------------------------
;fly bkd
[Statedef 1021] ;< fly Walk Back
type = A
movetype= I
physics = N
juggle = 0
poweradd= 0
ctrl = 0
;anim = 1021 ;< I have commented out the anim because i didn't had an Fly walk back so i use the Fly idle Anim for it
velset = 0,0

[State 0, Turn] ;< Turn
type = Turn
trigger1 = P2dist X < -10

[State 0, VelSet] ;< VelSet or The speed to fly walk back
type = VelSet
trigger1 = 1
x = -4
y = 0

[State 0, ChangeState] ;< This change state is to go back to the fly idle state if you are not holding back
type = ChangeState
trigger1 = command != "holdback"
value = 1000
ctrl = 1

;---------------------------------------------------------------------------
;fly up
[Statedef 1040] ;< Fly Up
type = A
movetype= I
physics = N
juggle = 0
poweradd= 0
ctrl = 0
;anim = 1040
velset = 0,0

[State 0, Turn] ;< Turn
type = Turn
trigger1 = P2dist X < -10

[State 0, VelSet] ;< VelSet for the speed of Fly Up.
type = VelSet
trigger1 = pos y > -180 ;< I am using the pos trigger to stop to play the fly up anim when reaching the Limit. (Change the 180 if you have changed the limit.
x = 0
y = -4

;limit for flying up
[State 0, PosSet]
type = PosSet
trigger1 = pos y <= -180
y = -180

[State 0, ChangeState]
type = ChangeState
trigger1 = command != "holdup"
value = 1000
ctrl = 1

;---------------------------------------------------------------------------
;fly down
[Statedef 1041] ; Fly down
type = A
movetype= I
physics = N
juggle = 0
poweradd= 0
ctrl = 0
;anim = 1041
velset = 0,0

[State 0, Turn]
type = Turn
trigger1 = P2dist X < -10

[State 0, VelSet] ; The speed of fly down
type = VelSet
trigger1 = pos y < 0
x = 0
y = 4

;go back to jump/fall state
[State 0, ChangeState] ; If you are landing with by pressing "down" then this will take it to the landing state
type = ChangeState
trigger1 = pos y >= 0
value = 1047
ctrl = 1

[State 0, ChangeState]
type = ChangeState
trigger1 = command != "holddown"
value = 1000
ctrl = 1

;---------------------------------------------------------------------------
;fly landing
[Statedef 1047] ;< Airplane is landing
type = S
movetype= I
physics = N
juggle = 0
poweradd= 0
ctrl = 0
;anim = 1047 ;< I have commented this out because i didn't had an fly land
velset = 0,0

[State 0, PosSet] ;< You know PosSet
type = PosSet
trigger1 = pos y >= 0
y = 0

[State 0, ChangeState] ;< This is to take the character to the Jump Land state.
type = ChangeState
trigger1 = Animtime = 0
value = 52
ctrl = 1

;---------------------------------------------------------------------------
;fly dash forward
[Statedef 1100] ; Fly Dash Fwd
type = A
movetype= I
physics = N
juggle = 0
poweradd= 0
ctrl = 0
anim = 1100 ;< Anim to the Fly dash Fwd
velset = 0,0

[State 0, VelSet] ;< Speed of Fly Dash Fwd
type = VelSet
trigger1 = time = 0
x = 5

[State 0, VelAdd]
type = VelAdd
trigger1 = 1
x = 0.1

[State 0, ChangeState] ;< To stop him
type = ChangeState
trigger1 = frontedgebodydist < 2
trigger2 = command != "holdfwd"
trigger3 = command = "BB"
value = 1000
ctrl = 1

;---------------------------------------------------------------------------
;fly dash backward
[Statedef 1105] ; The fly dash back is same as the fly dash forward
type = A
movetype= I
physics = N
juggle = 0
poweradd= 0
ctrl = 0
anim = 1105
velset = 0,0

[State 0, VelSet]
type = VelSet
trigger1 = time = 0
x = -5 ;-0.2

[State 0, VelAdd]
type = VelAdd
trigger1 = 1
x = -0.1 ;-2

[State 0, ChangeState]
type = ChangeState
trigger1 = backedgebodydist < 2
trigger2 = command != "holdback"
trigger3 = command = "FF"
value = 1000
ctrl = 1

;If you want to make the character fly even after getting hurt then make the 5000s state's type "A"
------------------------------------------------------------------------------------------------------------------------------------------------

Everything which has ; at the start means that is commented out

TO make Fly Attacks copy the codes and make the type = A.
And do something like this in you CMD

;---------------------------------------------------------------------------
;Fly
[State -1, Fly] ;< This is the Fly code command
type = ChangeState
value = 999
trigger1 = command = "c"
trigger1 = statetype != C
trigger1 = ctrl

;flying Light Punch
[State 0, ChangeState] ;< There are fly attacks
type = ChangeState
trigger1 = command = "x"
value = 2000
ctrl = 1

;flying Strong Punch
[State 0, ChangeState]
type = ChangeState
trigger1 = command = "y"
value = 2100
ctrl = 1

;flying Light Kick
[State 0, ChangeState]
type = ChangeState
trigger1 = command = "a"
value = 2300
ctrl = 1

;flying Strong Punch
[State 0, ChangeState]
type = ChangeState
trigger1 = command = "b"
value = 2400
ctrl = 1

;Now an example of the CNS code of the fly attacks:

; Fly Light Punch ;< This is an example
[Statedef 2000]
type = A
movetype= A
physics = S
juggle = 1

velset = 0,0
ctrl = 0
anim = 200

[State 2000, 1]
type = HitDef
trigger1 = AnimElem = 2
attr = A, NA
damage = 23, 0
animtype = Light
guardflag = MA
hitflag = MAF
priority = 3, Hit
pausetime = 8, 8
sparkno = 0
sparkxy = -10, -56
hitsound = 5, 0
guardsound = 6, 0
ground.type = High
ground.slidetime = 5
ground.hittime = 11
ground.velocity = -4
airguard.velocity = -1.9,-.8
air.type = High
air.velocity = -1.4,-3
air.hittime = 15

[State 2000, 2] ;< Now this is very important if you don't do this then you will be standing in air
type = ChangeState
trigger1 = AnimTime = 0
value = 1000 ;< In the value add the statedef number of the fly idle to make him fly after the attack finishes
ctrl = 1

I hope this helps, credit to sgn15 because he told me how to code fly.

EDIT:
sgn15 just sended this PM please see this:
i don't recommend meddling with the 5000's states. they are default. you already have default air hit states, aside from stand and crouch hit states.
you just need type = A in all your flying states (idle, movements, attacks) and you should go back to default air hit states when hit.

if you want to stay as flying after hit during flying, just make a new hit state and use a hitoverride in state -2 that will activate when you are in flying states (trigger1 = stateno = [1000,2500])
that is just for example that you used 1000 to 2500 as stateno for all flying (idle, custom hitstate, attacks, movement states)

type = A
movetype = H ;<-- this should already make you absorb the damage from enemy's hitdef
physics = N

then go back to fly idle like after time = # or animtime = 0 or any other trigger you want.
Re: How to code fly? [Credit to sgn15 to teaching me how]
#2  September 24, 2012, 03:40:59 pm
  • ******
  • Limited time to use Infinite power !
    • France
    • network.mugenguild.com/cybaster/
This would be better in the "tricks and tutorials" section of the forum. ;)
Re: How to code fly? [Credit to sgn15 to teaching me how]
#3  September 25, 2012, 09:45:51 pm
  • *
    • India
    • gopalprasadgd@gmail.com
    • http://gamingx.elementfx.com/
okay, are you the moderator?
then please move this
Re: How to code fly? [Credit to sgn15 to teaching me how]
#4  September 25, 2012, 10:14:56 pm
  • ******
  • Limited time to use Infinite power !
    • France
    • network.mugenguild.com/cybaster/
I'm not a moderator, I can't.
You can do it yourself at the bottom of the topc, there should be a "move topic" button or something.