;-------------- Generated by Fighter Factory -------------
              ;Sean Matsuda by Victorys

;--------------------- Variable List ----------------------
; Var(0) - Palette Number
; Var(3) - Jump Type (0 = Normal; 1 = Low Jump; 2 = Long Low Jump; 3 = Long Jump)
; Var(5) - Special Cancel Check
; Var(6) - Super Cancel Check
; Var(7) - MAX Cancel Check
; Var(9) - Counter Flag
; Var(10) - Button Detect (0 = Light; 1 = Medium; 2 = Heavy)
; Var(12) - Mashing Buttons during Tsukami Nage
; Var(13) - Hit Count
; Var(14) - Mashing Buttons during Shoryuu Cannon
; Var(15) - Juggle Points
; Var(16) - Juggle Flag
; Var(17) - Ticks UnGuardable
; Var(18) - ProjContact (0 = No; 1 = Yes)
; Var(19) - Throw Escape
; Var(20) - MAX Mode Timer
; Var(21) - Super Cancel Flag
; Var(22) - MAX Cancel Flag
; Var(23) - Super Finish Type (3000 = Hadou Burst, 3100 = Shoryuu Cannon, 3200 = Hyper Tornado, 4000 = Shippu Jinrairasen, 4100 = Shinryuken)
; Var(24) - MAX Mode Power Gauge Set
; Var(25) - Ticks to Apply EX FX
; Var(26) - Ticks Unable to Walk
; Var(30) - Hit Detection
; Var(33) - Hit Spark (8010 = Light; 8011 = Medium; 8012 = Hard; 8013 = Special; 8014 = Super)
; Var(34) - Guard Spark (8000 = Normal; 8001 = Special)
; Var(35) - Spark xPos
; Var(36) - Spark yPos
; Var(38) - Throw (0 = Allowed; 1 = Not Allowed)
; Var(42) - Mashing Buttons during Tsukami Nage
; Var(44) - Tsukami Nage Timer
; Var(51) - Mode (0 = Normal, 1 = Ex)
; Var(58) - Game Time

;--------------------- Float Variable List ----------------------
;fvar(5) - Amount of Corner Push
;fvar(8) - Life Holder
;fvar(10) - Damage Dampener
;fvar(11) - Damage Dampener with Counter Multiplier Added
;----------------------------------------------------------------


[Data]
life = 1000			;Amount of life to start with
attack = 100		;attack power (more is stronger)
defence = 100		;defensive power (more is stronger)
fall.defence_up = 50	;Percentage to increase defense everytime player is knocked down
liedown.time = 50		;Time which player lies down for, before getting up
airjuggle = 15		;Number of points for juggling
sparkno = s8010			;Default hit spark number for HitDefs
guard.sparkno = s8000	;Default guard spark number
KO.echo = 0			;1 to enable echo on KO
volume = 200			;Volume offset (negative for softer)
IntPersistIndex = 58	;Variables with this index and above will not have their values
FloatPersistIndex = 40  ;reset to 0 between rounds or matches. There are 60 int variables,
  				;indexed from 0 to 59, and 40 float variables, indexed from 0 to 39.
  				;If omitted, then it defaults to 60 and 40 for integer and float
  				;variables repectively, meaning that none are persistent, i.e. all
  				;are reset. If you want your variables to persist between matches,
  				;you need to override state 5900 from common1.cns.

[Size]
xscale = 1           ;Horizontal scaling factor.
yscale = 1           ;Vertical scaling factor.
ground.back = 15     ;Player width (back, ground)
ground.front = 15   ;Player width (front, ground)
air.back = 15        ;Player width (back, air)
air.front = 15       ;Player width (front, air)
height = 60          ;Height of player (for opponent to jump over)
attack.dist = 160    ;Default attack distance
proj.attack.dist = 90 ;Default attack distance for projectiles
proj.doscale = 0     ;Set to 1 to scale projectiles too
head.pos = 6, -92   ;Approximate position of head
mid.pos = -6, -60    ;Approximate position of midsection
shadowoffset = 0     ;Number of pixels to vertically offset the shadow
draw.offset = 0,0    ;Player drawing offset in pixels (x, y)

[Velocity]
walk.fwd  = 3.55     ;Walk forward
walk.back = -2.36     ;Walk backward
run.fwd  = 5.74, 0    ;Run forward (x, y)
run.back = -10,0      ;Hop backward (x, y)
jump.neu = 0, -10.51   ;Neutral jumping velocity (x, y)
jump.back = -3.87     ;Jump back Speed (x, y)
jump.fwd = 3.36       ;Jump forward Speed (x, y)
runJump.back = -5.81,-10.75 ;Running jump speeds (opt)
runJump.fwd = 5.04,-10.75      ;.
airjump.neu = 0,-6.5      ;.
airjump.back = -2.8     ;Air jump speeds (opt)
airjump.fwd = 2.8        ;.

[Movement]
airJump.num = 0
airJump.height = 0
yAccel = .58
stand.friction = .85
crouch.friction = .82

[Quotes]
victory1 = "Oh yeah! I'll start using that move more often now!"
victory2 = "My master was right... I have to improve myself from every battle!"
victory3 = "Call the fire department, cause I'm on fire, baby!!"
victory4 = "I'm so eager to try out new and different things! This is great!"
victory5 = "Now I understand why they fight! This feeling is incredible."
victory6 = "Tell me who just rocked your world with skill!"
victory7 = "With every match, my timing becomes more precise!"
victory8 = "Wow! That actually worked?! Next time I'll do it with skill!"
victory9 = "I like close fights. It makes me stronger!"
victory10 = "Shoryu-reppa! I'll perfect it next time!"
victory11 = "I can't lose! I must defeat everyone!"
victory12 = "When it comes to the fighting spirit, I can not lose!"
victory13 = "I must learn more. Where is Ken?"
victory14 = "Hado-power! I think I've come to understand it!"
victory15 = "I've reached my potential!"
victory16 = "You lack strength of purpose. Don't despise me!"
victory17 = "I'm as fast as the wind, as fierce as fire, and as solid as a rock!"
victory18 = "Don't call me Dan!"
victory19 = "I did it, master! I beat my first opponent!"

; Vs Ryu
victory20 = "Please show me that move again! This time I'll watch your hands!"

; Vs Ken
victory21 = "Master! One more match please!"

; Vs Violent Ken
victory22 = "Master?! What happened to you!?!?"

; Vs Dan
victory23 = "Someone like you will never beat me!"

; Vs Ibuki/Guy
victory24 = "Great! Are you a real Ninja?"

; Vs Necro
victory25 = "I'm too desperate to win to be deluded by your strange moves!"

; Vs Himself
victory26 = "You are a man right? Don't be so slow!"

; Vs Oro
victory27 = "You're great old man. You've shown me how to defeat a worthless opponent."

; Vs Elena
victory28 = "When it comes to the sense of rhythm, you can't beat me!"

; Vs Dudley
victory29 = "My fist is my soul! You can't defeat me with that spiritless punch!"

; Vs Alex
victory30 =  "I could tell when you were going to make your next move. It was too obvious!"

; Vs Yun
victory31 = "Unlike you, I always try to defeat the opponent with one punch!"

;Vs Yang
victory32 = "Kung Fu is supposed to be the best, right?"

;====================<INITIALIZE (PART 2)>====================
[StateDef 5901]
type = S

[State 5901, RemapPal]
type = RemapPal
trigger1 = 1
source = 1,1
dest = 1,var(0)

[State 5900, Intro vs Ryu]
type = ChangeState
trigger1 = NumEnemy
trigger1 = RoundNo = 1 || (!(Enemy, RoundsExisted) && !(TeamMode = Simul) && !(Enemy, TeamMode = Simul))
trigger1 = Enemy, AuthorName = "Phantom.of.the.Server" && Enemy, Name = "Ryu" && (Enemy, Var(1) != 2)
trigger2 = Enemy, AuthorName = "Victorys" && Enemy, Name = "Ryu" 
value = 5902

[State 5900, Intro vs Ken]
type = ChangeState
triggerAll = NumEnemy
triggerAll = RoundNo = 1 || (!(Enemy, RoundsExisted) && !(TeamMode = Simul) && !(Enemy, TeamMode = Simul))
trigger1 = Enemy, Name = "Ken Masters" && enemy,authorname = "Jmorphman" && (Enemy, Var(40) != 1)
value = 5903

[State 5900, Intro vs Boss Guys]
type = ChangeState
triggerAll = NumEnemy
triggerAll = RoundNo = 1 || (!(Enemy, RoundsExisted) && !(TeamMode = Simul) && !(Enemy, TeamMode = Simul))
trigger1 = Enemy, Name = "Orochi Iori" || Enemy, Name = "O.Iori" || Enemy, Name = "Wild Iori" || Enemy, Name = "Orochi Leona" || Enemy, Name = "O.Leona" || Enemy, Name = "Wild Leona" || Enemy, Name = "Violent Ken" || Enemy, Name = "V.Ken"
trigger2 = Enemy, Name = "Evil Ryu" || Enemy, Name = "E.Ryu" || Enemy, Name = "Evil Ken" || Enemy, Name = "E.Ken"
trigger3 = Enemy, Name = "Akuma" || Enemy, Name = "cvsgouki" || Enemy, Name = "Gouki" || Enemy, Name = "Shin Akuma" || Enemy, Name = "Shin Gouki" || Enemy, Name = "ShinAkuma" || Enemy, Name = "ShinGouki" || Enemy, Name = "Pocket Shin Gouki"
trigger4 = Enemy, Name = "Gouken" || Enemy, Name = "Rasetsumaru" || Enemy, Name = "Gill"
trigger5 = Enemy, Name = "Kusanagi" || Enemy, Name = "Kyo-1" || Enemy, Name = "Kyo-2" || Enemy, Name = "Geese" || Enemy, Name = "Nightmare Geese"
trigger6 = Enemy, Name = "Rugal" || Enemy, Name = "Omega Rugal" || Enemy, Name = "God Rugal" || Enemy, Name = "Ultimate Rugal"
trigger7 = Enemy, Name = "Mr. Karate" || Enemy, Name = "Mr.Karate"
value = 5904

[State 5900, Intro Decider]
type = ChangeState
trigger1 = RoundNo = 1
value = 191 + (Random % 4)

[State 5900, Turns Intro]
type = ChangeState
trigger1 = TeamMode = Turns
trigger1 = !RoundsExisted && RoundNo >= 2
value = 6900

[State 5901, End]
type = ChangeState
trigger1 = 1
value = 0

;---------------------------------------------------------------------------
; Lose by Time Over
; CNS difficulty: basic
[Statedef 170]
type = S
ctrl = 0
anim = 170
velset = 0,0

[State 170, 1]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

;---------------------------------------------------------------------------
; Win state decider
; CNS difficulty: basic
[Statedef 180]
type = S

[State 180, Generic Victory Quote]
type = VictoryQuote
trigger1 = 1
value = (Random % 20)

[State 180, Victory Quote Vs. Ryu]
type = VictoryQuote
trigger1 =  Enemy, Name = "Ryu" 
value = 20

[State 180, Victory Quote Vs. Ken]
type = VictoryQuote
trigger1 =  Enemy, Name = "Ken" || Enemy, Name = "Ken Masters"
value = 21

[State 180, Victory Quote Vs. Violent Ken]
type = VictoryQuote
trigger1 =  Enemy, Name = "Violent Ken" || Enemy, Name = "Evil Ken"
value = 22

[State 180, Victory Quote Vs. Dan]
type = VictoryQuote
trigger1 =  Enemy, Name = "Dan" || Enemy, Name = "Dan Hibiki"
value = 23

[State 180, Victory Quote Vs. Ibuki/Guy]
type = VictoryQuote
trigger1 =  Enemy, Name = "Ibuki" || Enemy, Name = "Guy"
value = 24

[State 180, Victory Quote Vs. Necro]
type = VictoryQuote
trigger1 =  Enemy, Name = "Necro" 
value = 25

[State 180, Victory Quote Vs. Himself]
type = VictoryQuote
trigger1 =  Enemy, Name = "Sean" || Enemy, Name = "Sean Matsuda"
value = 26

[State 180, Victory Quote Vs. Oro]
type = VictoryQuote
trigger1 =  Enemy, Name = "Oro"
value = 27

[State 180, Victory Quote Vs. Elena]
type = VictoryQuote
trigger1 =  Enemy, Name = "Elena"
value = 28

[State 180, Victory Quote Vs. Dudley]
type = VictoryQuote
trigger1 =  Enemy, Name = "Dudley"
value = 29

[State 180, Victory Quote Vs. Alex]
type = VictoryQuote
trigger1 =  Enemy, Name = "Alex"
value = 30

[State 180, Victory Quote Vs. Yun]
type = VictoryQuote
trigger1 =  Enemy, Name = "Yun"
value = 31

[State 180, Victory Quote Vs. Yang]
type = VictoryQuote
trigger1 =  Enemy, Name = "Yang"
value = 32

[State 180, 1]
type = ChangeState
trigger1 = !Time 
value = 181 + (random%3)

;---------------------------------------------------------------------------
; Win pose 1 
[Statedef 181]
type = S
ctrl = 0
anim = 181
velset = 0,0

[State 181, Voice]
type = PlaySnd
trigger1 = AnimElem = 2
value = 0, 8
channel = 0

[State 181, AssertSpecial]
type = AssertSpecial
trigger1 = time = [0, 200]
flag = roundnotover

; Win pose 2 
[Statedef 182]
type = S
ctrl = 0
anim = 182
velset = 0,0

[State 182, Voice]
type = PlaySnd
trigger1 = AnimElem = 8
value = 0, 7
channel = 0

[State 182, AssertSpecial]
type = AssertSpecial
trigger1 = time = [0, 200]
flag = roundnotover

; Win pose 3-1
[Statedef 183]
type = S
ctrl = 0
anim = 183
velset = 2,-7

[State 40, Dust Helper]
type = Helper
trigger1 = Time = 0
helperType = Normal
stateNo = 8100
ID = 8100
name = "Jump Dust"
posType = P1
ownPal = 1

[State 184, 0]
type = PlaySnd
trigger1 = animelem = 1
value = s40, 0
channel = 0

[State 183, 2]
type = PlaySnd
trigger1 = animelem = 4
value = s0,7
channel = 1

[State 183, 2]
type = PlaySnd
trigger1 = animelem = 4
value = s1,2
channel = 2

[State 183, 1] ;Gravity
type = VelAdd
trigger1 = 1
y = .35

[State 183, 2] ;Change state when KFM is close to ground
type = ChangeState
trigger1 = Vel Y > 0 && Pos Y >= -5
value = 184

[State 182, AssertSpecial]
type = AssertSpecial
trigger1 = time = [0, 100]
flag = roundnotover

; Win pose 3-2
[Statedef 184]
type = S
ctrl = 0
anim = 184
velset = 0,0

[State 184, 0]
type = PlaySnd
trigger1 = animelem = 1
value = s52, 0

[State 184, 1]
type = PlaySnd
trigger1 = animelem = 2
value = s0,8

[State 106, Landing Dust Explod]
type = Explod
trigger1 = !Time
anim = 8102
sprpriority = -3
postype = P1
scale = 0.5,0.5
pauseMoveTime = -1
superMoveTime = -1
ownPal = 1

[State 182, AssertSpecial]
type = AssertSpecial
trigger1 = time = [0, 150]
flag = roundnotover

;---------------------------------------------------------------------------
; Win pose 4
[Statedef 185]
type = S
ctrl = 0
anim = 185
velset = 0,0

[State 181, AssertSpecial]
type = AssertSpecial
trigger1 = time = [0, 250]
flag = roundnotover

;---------------------------------------------------------------------------
; Introduction
; CNS difficulty: basic
[Statedef 191]
type = S
ctrl = 0
anim = 190
velset = 0,0

[State 188, PosAdd]
type = PosAdd
trigger1 = !Time
trigger1 = PrevStateNo = 5902
x = -ceil(var(10) - 110)

[State 192, PosSet]
type = PosSet
trigger1 = !Time
trigger1 = PrevStateNo = 5903
x = var(10)
y = 0

[State 191, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 190

[State 191, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 191, 3] ;Change to stand state when done
type = ChangeState
trigger1 = !AnimTime
value = 0

[State 191, PlaySnd]
type = PlaySnd
trigger1 = Animelem = 10
value = S0,5
channel = 0

[State 191, PlaySnd]
type = PlaySnd
trigger1 = animelem = 3
value = S0,11
channel = 1

[State 191, PlaySnd]
type = PlaySnd
trigger1 = animelem = 11
value = S0,11
channel = 1

[State 191, PlaySnd]
type = PlaySnd
trigger1 = animelem = 19
value = S0,11
channel = 1

[State 200, 2]
type = Explod
trigger1 = Anim = 190
trigger1 = animelem = 8
anim = 192
pos = 0, 0
postype = p1
facing = 1
sprpriority = 3
ownpal = 0
bindtime = -1
persistent = 0
ignorehitpause = 1
scale = const(size.xscale),const(size.yscale)

[State 0, Explod]
type = Explod
trigger1 = animelem = 26
anim = 191
ID = 191
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
sprpriority = 0
ownpal = 0


;---------------------------
;Intro 2
[Statedef 192]
type = S
ctrl = 0
anim = 190
velset = 0,0

[State 188, PosAdd]
type = PosAdd
trigger1 = !Time
trigger1 = PrevStateNo = 5902
x = -ceil(var(10) - 110)

[State 192, PosSet]
type = PosSet
trigger1 = !Time
trigger1 = PrevStateNo = 5903
x = var(10)
y = 0

[State 191, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 190

[State 191, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 191, 3] ;Change to stand state when done
type = ChangeState
trigger1 = !AnimTime
value = 0

[State 191, PlaySnd]
type = PlaySnd
trigger1 = Animelem = 10
value = S0,6
channel = 0

[State 191, PlaySnd]
type = PlaySnd
trigger1 = animelem = 3
value = S0,11
channel = 1

[State 191, PlaySnd]
type = PlaySnd
trigger1 = animelem = 11
value = S0,11
channel = 1

[State 191, PlaySnd]
type = PlaySnd
trigger1 = animelem = 19
value = S0,11
channel = 1

[State 200, 2]
type = Explod
trigger1 = Anim = 190
trigger1 = animelem = 8
anim = 193
pos = 0, 0
postype = p1
facing = 1
sprpriority = 3
ownpal = 0
bindtime = -1
persistent = 0
ignorehitpause = 1
scale = const(size.xscale),const(size.yscale)

[State 0, Explod]
type = Explod
trigger1 = animelem = 26
anim = 191
ID = 191
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
sprpriority = 0
ownpal = 0

; Intro 3
[Statedef 193]
type = S
ctrl = 0
anim = 199
velset = 0, 0

[State 188, PosAdd]
type = PosAdd
trigger1 = !Time
trigger1 = PrevStateNo = 5902
x = -ceil(var(10) - 110)

[State 192, PosSet]
type = PosSet
trigger1 = !Time
trigger1 = PrevStateNo = 5903
x = var(10)
y = 0

[State 192, Whoosh Sound]
type = PlaySnd
trigger1 = AnimElem = 4
trigger2 = AnimElem = 7
value = 1,0

[State 192, Whoosh Sound]
type = PlaySnd
trigger1 = AnimElem = 12
value = 1,1

[State 194, Intro Assert]
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 194, End]
type = ChangeState
trigger1 = !AnimTime
value = 0

; Intro 4
; CNS difficulty: basic
[Statedef 194]
type = S
ctrl = 0
anim = 203
velset = 0,0

[State 188, PosAdd]
type = PosAdd
trigger1 = !Time
trigger1 = PrevStateNo = 5902 
x = -ceil(var(10) - 110)

[State 192, PosSet]
type = PosSet
trigger1 = !Time
trigger1 = PrevStateNo = 5903
x = var(10)
y = 0

[State 191, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 203

[State 191, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 200, Swing Snd]
type = Null
trigger1 = AnimElem = 4
value = 1,0
channel = 1

[State 191, 3] ;Change to stand state when done
type = ChangeState
trigger1 = !AnimTime
value = 0

[State 191, PlaySnd]
type = PlaySnd
trigger1 = Animelem = 5
value = S0,5
channel = 0

; Intro Vs Ryu
[StateDef 5902]
type = S
moveType = I
physics = N
anim = 194
ctrl = 0

[State 5900, Intro Decider]
type = ChangeState
trigger1 = (Enemy, Var(1) = 2)
trigger1 = NumEnemy
trigger1 = RoundNo = 1 && (!(TeamMode = Simul) && !(Enemy, TeamMode = Simul))
trigger1 = Enemy, AuthorName = "Phantom.of.the.Server" && Enemy, Name = "Ryu"
value = 191 + (Random % 4)

[State 193, VarSet]
type = VarSet
trigger1 = !Time
var(10) = ceil(P2dist X)

[State 193, Assert: Intro]
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 193, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 0
moveCamera = 0,0
ignoreHitPause = 1

[State 193, Camera Helper]
type = Helper
trigger1 = !NumHelper(8999)
helpertype = Normal
stateNo = 8999
ID = 8999
name = "Camera"
posType = P1

[State 193, VarSet]
type = VarSet
trigger1 = !Time
var(10) = ceil(P2dist X)

[State 193, PosAdd]
type = PosAdd
trigger1 = !Time
x = ceil(P2Dist X - 110)

[State 193, Voice]
type = PlaySnd
trigger1 = AnimElem = 9
value = 0,7
channel = 0

[State 193, Back Dash Sound]
type = PlaySnd
trigger1 = AnimElem = 10
value = 105,0

[State 193, Dust Helper]
type = Helper
trigger1 = AnimElem = 10
helperType = Normal
stateNo = 8103
ID = 8100
name = "Dash Dust"
posType = P1
facing = -1
pauseMoveTime = 255
superMoveTime = 255
ownPal = 1

[State 193, VelSet]
type = VelSet
trigger1 = AnimElem = 10
x = -(ceil(var(10) - 110) * 0.0625)

[State 193, VelSet]
type = VelSet
trigger1 = AnimElem = 12
x = 0

[State 193, Landing Sound]
type = PlaySnd
trigger1 = AnimElem = 12
value = 100,1

[State 193, Landing Dust Explod]
type = Explod
trigger1 = AnimElem = 12
anim = 8102
sprpriority = -3
postype = P1
scale = 0.5,0.5
pauseMoveTime = -1
superMoveTime = -1
ownPal = 1

[State 193, End]
type = ChangeState
trigger1 = !AnimTime
value = 0


[State 193, End]
type = ChangeState
trigger1 = !AnimTime
value = 0

; Intro vs Ken 
[Statedef 5903]
type = S
ctrl = 0
anim = 202
velset = 0, 0

[State 5900, Intro Decider]
type = ChangeState
trigger1 = (Enemy, Var(40) = 1)
trigger1 = NumEnemy
trigger1 = RoundNo = 1 && (!(TeamMode = Simul) && !(Enemy, TeamMode = Simul))
trigger1 = Enemy, Name = "Ken Masters" && enemy,authorname = "Jmorphman"
value = 191 + (Random % 4)

[State 194, VarSet]
type = VarSet
trigger1 = !Time
var(10) = ceil(pos x)

[State 194, Intro Assert]
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 192, Whoosh Sound]
type = PlaySnd
trigger1 = (Enemy, Var(40) != 1)
trigger1 = Time = 10
value = 0,6

[State 194, End]
type = ChangeState
trigger1 = !AnimTime
value = 0

; Intro vs Boss Guys
[Statedef 5904]
type = S
ctrl = 0
anim = 204
velset = 0, 0

[State 194, Intro Assert]
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 194, End]
type = ChangeState
trigger1 = !AnimTime
value = 0

;====================<TURNS INTRO>====================
[Statedef 6900]
type = A
anim = 6900
velset = 0, 0
ctrl = 0

[State 6900, Intro]
type = assertspecial
trigger1 = 1
flag = intro

[State 6900, Camera]
type = screenbound
trigger1 = 1
value = 0
movecamera = 0, 0

[State 6900, Camera]
type = helper
trigger1 = !numhelper(8999)
helpertype = normal
stateno = 8999
ID = 8999
name = "Camera"
postype = p1

[State 6900, Pos]
type = posset
trigger1 = !time
x = (-320 + abs(pos x)) * facing

[State 6900, Vel]
type = velset
trigger1 = !time
x = (helper(8999), rootdist x) / -40.0
y = -10.25

[State 6900, Vel]
type = veladd
trigger1 = 1
y = 0.5

[State 6900, End]
type = changestate
trigger1 = time
trigger1 = pos y > -vel y
value = 6901

;---Land---
[Statedef 6901]
type = S
physics = S
anim = 6901
velset = 0, 0

[State 6901, Intro]
type = assertspecial
trigger1 = 1
flag = intro

[State 6901, Pos]
type = posset
trigger1 = !time && numhelper(8999)
x = ceil(helper(8999), pos x)

[State 6901, Landing Snd]
type = Playsnd
trigger1 = !Time
value = 52,0

[State 191, PlaySnd]
type = PlaySnd
trigger1 = Animelem = 12
value = S0,5
channel = 0

[State 191, PlaySnd]
type = PlaySnd
trigger1 = animelem = 5
value = S0,11
channel = 1

[State 191, PlaySnd]
type = PlaySnd
trigger1 = animelem = 13
value = S0,11
channel = 1

[State 191, PlaySnd]
type = PlaySnd
trigger1 = animelem = 21
value = S0,11
channel = 1

[State 200, 2]
type = Explod
trigger1 = animelem = 10
anim = 192
pos = 0, 0
postype = p1
facing = 1
sprpriority = 3
ownpal = 0
bindtime = -1
persistent = 0
ignorehitpause = 1
scale = const(size.xscale),const(size.yscale)

[State 0, Explod]
type = Explod
trigger1 = animelem = 28
anim = 191
ID = 191
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
sprpriority = 0
ownpal = 0

[State 6901, Landing Dust]
type = Explod
trigger1 = !Time
anim = 8102
sprpriority = -3
postype = p1
scale = .5,.5
pausemovetime = -1
supermovetime = -1
ownpal = 1

[State 6901, End]
type = ChangeState
trigger1 = !Animtime
value = 0

;-----------------------
; Taunt
; CNS difficulty: easy
[Statedef 195]
type = S
ctrl = 0
anim = 195
velset = 0,0
movetype = I
physics = S
sprpriority = 2

[State 40, Dust Helper]
type = Helper
trigger1 = AnimElem = 4
helperType = Normal
stateNo = 8100
ID = 8100
name = "Jump Dust"
posType = P1
ownPal = 1

[State 195, Ball Helper]
type = helper
triggerall = NumHelper(10096) < 1
trigger1 = Time = 0
helpertype = Normal
name = "Ball"
ID = 10095
pos = -340, -120
postype = p1
stateno = 10095
ownpal = 1
;keyctrl = 1

[State 195, Air]
type = StateTypeSet
trigger1 = AnimElem = 4
statetype = A
movetype = I
physics = N

[State 195, Vel]
type = VelSet
trigger1 = AnimElem = 4
y = -3.8

[State 195, Success]
type = ChangeState
triggerall = NumHelper(10095) > 0
trigger1 = AnimTime = 0
value = 196

[State 195, Miss]
type = ChangeState
triggerall = NumHelper(10095) < 1
trigger1 = AnimTime = 0
value = 197

; Taunt - Success
[Statedef 196]
type = A
ctrl = 0
anim = 196
velset = 0,0
movetype = I
physics = N
sprpriority = 2

[State 196, Ctrl]
type = CtrlSet
trigger1 = Time = 40
value = 1

[State 196, Ball]
type = Helper
trigger1 = AnimElem = 4
helpertype = normal
name = "Ball in hands"
ID = 10096
pos = 25, -132
postype = p1
stateno = 10096
ownpal = 1
keyctrl = 1

[State 196, Vel]
type = VelSet
trigger1 = AnimElem = 1
y = -.7

[State 196, Vel]
type = VelSet
trigger1 = AnimElem = 4
y = 0

[State 196, Vel]
type = StateTypeSet
trigger1 = AnimElem = 5
statetype = A
movetype = I
physics = A

[state 196, Vel]
type = VelSet
trigger1 = AnimElem = 5
x = -.5

[State 196, Voice]
type = PlaySnd
trigger1 = AnimElem = 3
value = 0, 10
channel = 0

[State 196, End]
type = ChangeState
trigger1 = Pos Y >= 0
trigger1 = Vel Y > 0
value = 52 
ctrl = 1

; Taunt - Miss
[Statedef 197]
type = A
ctrl = 0
anim = 197
velset = 0,0
movetype = I
physics = N
sprpriority = 2

[State 197, Ctrl]
type = CtrlSet
trigger1 = Time = 40
value = 1

[State 197, Vel]
type = VelSet
trigger1 = AnimElem = 1
y = -.7

[State 197, Vel]
type = VelSet
trigger1 = AnimElem = 4
y = 0

[State 197, Air]
type = StateTypeSet
trigger1 = AnimElem = 6
statetype = A
movetype = I
physics = A

[State 197, Voice]
type = PlaySnd
trigger1 = AnimElem = 4
value = 0, 9
channel = 0

[State 197, End]
type = ChangeState
trigger1 = Pos Y >= 0
trigger1 = Vel Y > 0
value = 52 
ctrl = 1

; Taunt 2
; CNS difficulty: easy
[Statedef 198]
type = S
ctrl = 0
anim = 198
velset = 0,0
movetype = I
physics = S
sprpriority = 2

[State 700, SFX]
type = Null
trigger1 = Animelem = 2
value = 0,7
channel = 0

[State 195, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

; Taunt 3
; CNS difficulty: easy
[Statedef 199]
type = S
ctrl = 0
anim = 201
velset = 0,0
movetype = I
physics = S
sprpriority = 2

[State 700, SFX]
type = PlaySnd
trigger1 = Animelem = 1
value = 0,21
channel = 0

[State 195, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;=========<DODGE>=============
[Statedef 700]
type    = S
movetype= I
physics = S
juggle  = 0
velset = 0,0
ctrl = 0
anim = 700
sprpriority = -1

[State 700, SFX]
type = Playsnd
trigger1 = time = 3
value = 1,3
volume = 255

[State 700, Voice]
type = Playsnd
trigger1 = time = 3
value = 0,0
volume = 255
channel = 1

[State 700, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 0

[State 700, HitBy]
type = HitBy
trigger1 = 1
value = SCA,AT
time = 1

[State 700, Attack]
type = ChangeState
trigger1 = Time = [15,25]
trigger1 = command = "x" || command = "y" || command = "z" || command = "a" || command = "b" || command = "c"
value = ifElse((command = "x" || command = "y" || command = "z"), 225, 252)

[State 700, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;=========<ROLLING>===========
[StateDef 710]
type = S
physics = N
moveType = I
anim = 710
ctrl = 0
velSet = 0,0
sprPriority = 1

[State 710, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 0

[State 710, HitBy]
type = HitBy
trigger1 = 1
value = SCA,AT
time = 1

[State 710, Voice]
type = PlaySnd
trigger1 = AnimElem = 1
value = 0, 9
channel = 0

[State 710, Roll Sound]
type = PlaySnd
trigger1 = Time = 1
value = 110,0
channel = 1

[State 710, Start Roll]
type = VelSet
trigger1 = AnimElem = 1
x = 5

[State 710, End Roll]
type = VelSet
trigger1 = AnimElem = 8
x = 0

[State 710, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;Roll Back
[StateDef 715]
type = S
physics = N
moveType = I
anim = 715
ctrl = 0
velSet = 0,0
sprPriority = 1

[State 715, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 0

[State 715, HitBy]
type = HitBy
trigger1 = 1
value = SCA,AT
time = 1

[State 715, Voice]
type = PlaySnd
trigger1 = AnimElem = 1
value = 0, 9
channel = 0

[State 715, Roll Sound]
type = PlaySnd
trigger1 = Time = 1
value = 110,0
channel = 1

[State 715, Start Roll]
type = VelSet
trigger1 = AnimElem = 1
x = -5

[State 715, Stop Roll]
type = VelSet
trigger1 = AnimElem = 8
x = 0

[State 715, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;===========<POWER CHARGE>==================
[StateDef 730]
type = S
physics = S
moveType = I
anim = 730
velSet = 0,0
ctrl = 0

[State 730, PowerAdd]
type = PowerAdd
triggerAll = Power < const(data.power) && Power < PowerMax
trigger1 = (command = "hold_b" && command = "hold_y")
value = 5 + ifElse(time < 60, 0, (time - 60) / 12)

[State 730, Voice]
type = PlaySnd
trigger1 = !Time
value = 0,21
channel = 0

[State 730, Character Flash]
type = PalFX
trigger1 = 1
time = 1
add = 75 + ceil(sin(Time / 6.0 * pi) * 75),25 + ceil(sin(Time / 6.0 * pi) * 25),0

[State 730, Power Charge Helper]
type = Helper
trigger1 = !NumHelper(8330)
helperType = Normal
stateNo = 8330
ID = 8330
name = "Power Charge"
posType = P1
pos = 0,0
pauseMoveTime = 65535
superMoveTime = 65535
ownPal = 1

[State 730, Particles]
type = Helper
trigger1 = !NumHelper(8331)
helperType = Normal
stateNo = 8331
ID = 8331
name = "Particles"
postype = P1
pauseMoveTime = 65535
superMoveTime = 65535
ownPal = 1

[State 730, End]
type = ChangeState
trigger1 = Power >= const(data.power) || Power >= PowerMax || RoundState != 2
trigger2 = (command != "hold_b" || command != "hold_y")
value = 731
ctrl = 1


;Power Charge End
[StateDef 731]
type = S
physics = S
moveType = I
anim = 731
velSet = 0,0
ctrl = 1

[State 731, StopSnd]
type = StopSnd
trigger1 = !Time
channel = 0

[State 730, Full Power Voice]
type = PlaySnd
trigger1 = !Time && Power >= const(data.power)
value = 0,8
channel = 0
persistent = 0

[State 730, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;====================<ZERO COUNTER>====================
[StateDef 750]
type = S
physics = S
moveType = I
anim = 750
velSet = 0,0
ctrl = 0
sprPriority = 2
powerAdd = -1000
faceP2 = 1

[State 750, High or Low]
type = VarSet
trigger1 = !Time
var(10) = (command = "412k")
ignoreHitPause = 1

[State 750, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 750, PosFreeze]
type = PosFreeze
trigger1 = 1
value = 1

[State 750, Voice]
type = PlaySnd
trigger1 = !Time
value = 0,1
channel = 0

[State 750, Zero Counter FX Helper]
type = Helper
trigger1 = !Time
helperType = Normal
stateNo = 8350
ID = 8350
name = "Zero Counter"
posType = P1
pos = 20, -66
superMoveTime = 255
ownPal = 1

[State 750, SuperPause]
type = SuperPause
trigger1 = !Time
time = 15
moveTime = 15
p2DefMul = 1
anim = -1
sound = s750,0
darken = 0

[State 750, End]
type = ChangeState
trigger1 = Time >= 15
value = ifElse(var(10) = 1, 451, 1002)

;====================<PARRY>====================
;Standing Parry
[StateDef 760]
type = S
physics = S
moveType = I
anim = 760
velSet = 0,0
ctrl = 0
sprPriority = 2
powerAdd = 78 * !var(20)
faceP2 = 1

[State 760, HitBy]
type = HitBy
trigger1 = 1
value = SCA,AT
time = 1

[State 760, Pause]
type = Pause
trigger1 = !Time
time = 15
moveTime = 15
endCmdBufTime = 15
pauseBg = 0

[State 760, Stop]
type = PosFreeze
trigger1 = 1
value = 1

[State 760, No Walking]
type = VarSet
trigger1 = 1
var(26) = 7

[State 760, Voice]
type = PlaySnd
trigger1= !Time
value = 0,0
channel = 0

[State 760, Parry Sound]
type = PlaySnd
trigger1 = !Time
value = 760,0

[State 760, Player Flash]
type = PalFX
trigger1 = !Time
add = 0,64,255
sinadd = 0,-64,-255,60
time = 15

[State 760, FX]
type = Explod
trigger1 = !Time
anim = 8360
sprPriority = 5
posType = P1
pos = ceil(40 * const(size.xScale)), ceil(-75 * const(size.yScale))
pauseMoveTime = -1
superMoveTime = -1
scale = 0.5,0.5
ownPal = 1

[State 760, EnvShake]
type = EnvShake
trigger1 = !Time
time = 0
ampl = 0

[State 760, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1


;Crouching Parry
[StateDef 761]
type = C
physics = C
moveType = I
anim = 761
velSet = 0,0
ctrl = 0
sprPriority = 2
powerAdd = 78 * !var(20)
faceP2 = 1

[State 761, HitBy]
type = HitBy
trigger1 = 1
value = SCA,AT
time = 1

[State 761, Pause]
type = Pause
trigger1 = !Time
time = 15
moveTime = 15
endCmdBufTime = 15
pauseBg = 0

[State 761, PosFreeze]
type = PosFreeze
trigger1 = 1
value = 1

[State 761, No Walk]
type = VarSet
trigger1 = 1
var(26) = 7

[State 761, Voice]
type = PlaySnd
trigger1 = !Time
value = 0,0
channel = 0

[State 761, Parry Sound]
type = PlaySnd
trigger1 = !Time
value = 760,0

[State 761, Player Flash]
type = PalFX
trigger1 = !Time
add = 0,64,255
sinAdd = 0,-64,-255,60
time = 15

[State 761, Parry FX]
type = Explod
trigger1 = !Time
anim = 8360
sprpriority = 5
postype = P1
pos = ceil(30 * const(size.xScale)), ceil(-47 * const(size.yScale))
pauseMovetime = -1
superMovetime = -1
scale = 0.5,0.5
ownpal = 1

[State 761, EnvShake]
type = EnvShake
trigger1 = !time
time = 0
ampl = 0

[State 761, End]
type = ChangeState
trigger1 = !AnimTime
value = 11
ctrl = 1


;Jumping Parry
[StateDef 762]
type = A
physics = N
moveType = I
anim = 762
ctrl = 0
sprPriority = 2
powerAdd = 78 * !var(20)
faceP2 = 1

[State 762, HitBy]
type = HitBy
trigger1 = 1
value = SCA,AT
time = 1

[State 762, Pause]
type = Pause
trigger1 = !Time
time = 15
moveTime = 15
endCmdBufTime = 15
pauseBg = 0

[State 762, PosFreeze]
type = PosFreeze
trigger1 = 1
value = 1

[State 762, Voice]
type = PlaySnd
trigger1 = !Time
value = 0,0
channel = 0

[State 762, Parry Sound]
type = PlaySnd
trigger1 = !Time
value = 760,0

[State 762, Player Flash]
type = PalFX
trigger1 = !Time
add = 0,64,255
sinadd = 0,-64,-255,60
time = 15

[State 762, Parry FX]
type = Explod
trigger1 = !Time
anim = 8360
sprPriority = 5
posType = P1
pos = ceil(28 * const(size.xScale)), ceil(-80 * const(size.yScale))
pauseMoveTime = -1
superMoveTime = -1
scale = 0.5,0.5
ownpal = 1

[State 762, EnvShake]
type = EnvShake
trigger1 = !Time
time = 0
ampl = 0

[State 762, End]
type = ChangeState
trigger1 = !AnimTime
value = 763
ctrl = 1


;Falling
[StateDef 763]
type = A
physics = N
movetype = I
anim = 763
ctrl = 1

[State 763, VelSet]
type = VelSet
trigger1 = !Time
x = ifElse(vel x > 2, 2, ifElse(vel x < -2, -2, vel x))
y = ifElse(vel y < -2, vel y, -2)

[State 763, Gravity]
type = Gravity
trigger1 = 1

[State 763, Landing]
type = ChangeState
trigger1 = pos y > -vel y
value=52

;===============<MAX Mode>===============
[Statedef 770]
type = S
movetype = I
physics = S
anim = 770
ctrl = 0

[State 770, No Sliding]
type = VelSet
trigger1 = !Time 
x = 0

[State 770, Voice]
type = PlaySnd
trigger1 = AnimElem = 1
value = 0, 8
channel = 0

[State 770, MAX Snd]
type = PlaySnd
trigger1 = !Time
value = 770, 0

[State 770, Power Up! Text]
type = Helper
trigger1 = !Time
helperType = Normal
stateNo = 8291
ID = 8291
name = "Power Up FX"
posType = P1
pos = ceil(4 * const(size.xScale)), ceil(-62 * const(size.yScale))
facing = -1
ownPal = 1
pauseMoveTime = 255
superMoveTime = 255
ignoreHitPause = 1

[State 770, PowerAdd]
type = PowerAdd
trigger1 = AnimElem = 1
value = -1000

[State 770, PowerSet Var]
type = Varset
trigger1 = Animelem = 1
var(24) = Power

[State 770, MAX Mode Timer]
type = VarSet
trigger1 = AnimElem = 1
var(20) = 1000

[State 770, Max Meter V2]
type = Helper
helpertype = Normal
trigger1 = Animelem = 1 && !NumHelper(780)
id = 780
pos = 0,0
postype = left
name = "Max Meter"
stateno = 780
ignorehitpause = 1
pauseMoveTime = 255
superMoveTime = 255
ownpal = 1

[State 770, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Override common states (use same number to override) :
;---------------------------------------------------------------------------
;STANDING
[StateDef 0]
type = S
physics = S
moveType = I
velSet = 0,0
sprPriority = 0

[State 0, Remove Explods]
type = RemoveExplod
trigger1 = IsHelper

[State 0, Destroy Helpers]
type = DestroySelf
trigger1 = IsHelper

[State 0, 1]
type = ChangeAnim
triggerall = var(51)!=0
trigger1 = Anim != 2 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0 ;Turn anim over
value = 2

[State 0, 1]
type = ChangeAnim
triggerall = var(51)=0
trigger1 = Anim != 0 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0 ;Turn anim over
value = 0

[State 0, Dead]
type = ChangeState
trigger1 = !Alive
value = 5050

;====================<CROUCHING>====================
;Stand to Crouch
[StateDef 10]
type = C
physics = C
moveType = I
velSet = 0,0
sprPriority = 0

[State 10, ChangeAnim]
type = ChangeAnim
trigger1 = !Time && Anim = 12
value = 10
elem = 3 - AnimElemNo(0)

[State 10, ChangeAnim]
type = ChangeAnim
trigger1 = Anim != 10
value = 10

[State 10, End]
type = ChangeState
trigger1 = !AnimTime
value = 11


;Crouching
[StateDef 11]
type = C
physics = C
moveType = I
anim = 11
velSet = 0,0
sprPriority = 0

[State 11, ChangeAnim]
type = ChangeAnim
trigger1 = Anim = 6 && !AnimTime
value = 11


;Crouch to Stand
[StateDef 12]
type = S
physics = S
moveType = I
velSet = 0,0
sprPriority = 0

[State 12, ChangeAnim]
type = ChangeAnim
trigger1 = !Time && Anim = 10
value = 12
elem = 3 - AnimElemNo(0)

[State 12, ChangeAnim]
type = ChangeAnim
trigger1 = Anim != 12
value = 12

[State 12, End]
type = ChangeState
trigger1 = command = "holddown" && command != "holdup"
value = 10

[State 12, End]
type = ChangeState
trigger1 = !AnimTime
value = 0

;-------------
;WALKING
[StateDef 20]
type = S
physics = S
moveType = I
sprPriority = 0

[State 20, VelSet]
type = VelSet
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)

[State 20, VelSet]
type = VelSet
trigger1 = command = "holdback"
x = const(velocity.walk.back.x)

[State 20, ChangeAnim]
type = ChangeAnim
triggerAll = vel x > 0
trigger1 = Anim != 20 && Anim != 5
trigger2 = Anim = 5 && AnimElemTime(1) >= 1
value = 20

[State 20, ChangeAnim]
type = ChangeAnim
triggerAll = vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimElemTime(1) >= 1
value = 21

;====================<Jumping>====================
[StateDef 40]
type = S
physics = S
moveType = I
anim = 40
ctrl = 0
velSet = 0,0
sprPriority = 1
faceP2 = 1

[State 40, Direction]
type = VarSet
trigger1 = 1
sysvar(1) = ifElse(!Time, 0, ifElse(command = "holdfwd", 1, ifElse(command = "holdback", -1, sysvar(1))))

[State 40, High Jump]
type = VarSet
trigger1 = !Time
var(3) = ifElse(command = "highjump", 3, 0)

[State 40, High Jump]
type = VarSet
trigger1 = !Time && PrevStateNo = 100
var(3) = 3

[State 40, Low Jump]
type = VarSet
trigger1 = command != "holdup" && (var(3) != [1,2])
var(3) = ifElse((var(3) = 3 && sysvar(1)), 2, 1)

[State 40, Jump Sound]
type = PlaySnd
trigger1 = !AnimTime
value = ifElse((var(3) = [2,3]), 41, 40), 0

[State 40, Dust Helper]
type = Helper
trigger1 = !AnimTime
helperType = Normal
stateNo = 8100
ID = 8100
name = "Jump Dust"
posType = P1
ownPal = 1

[State 40, Velocity: Normal Jump]
type = VelSet
trigger1 = !AnimTime
x = ifElse(!sysvar(1), const(velocity.jump.neu.x), ifElse(sysvar(1) = 1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, Velocity: Low Jump]
type = VelSet
trigger1 = !AnimTime && var(3) = 1
x = ifElse(!sysvar(1), const(velocity.jump.neu.x), ifElse(sysvar(1) = 1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = 0.75 * const(velocity.jump.y)

[State 40, Velocity: Long Low Jump]
type = VelSet
trigger1 = !AnimTime && var(3) = 2
x = ifElse(!sysvar(1), const(velocity.jump.neu.x), ifElse(sysvar(1) = 1, const(velocity.runjump.fwd.x), const(velocity.runjump.back.x)))
y = 0.75 * const(velocity.jump.y)

[State 40, Velocity: Long Jump]
type = VelSet
trigger1 = !AnimTime && var(3) = 3
x = ifElse(!sysvar(1), const(velocity.jump.neu.x), ifElse(sysvar(1) = 1, const(velocity.runjump.fwd.x), const(velocity.runjump.back.x)))
y = 1.0772 * const(velocity.jump.y)

[State 40, End]
type = ChangeState
trigger1 = !AnimTime
value = 50
ctrl = 1


;In Air
[StateDef 50]
type = A
physics = N
moveType = I
sprPriority = 1

[State 50, ChangeAnim]
type = ChangeAnim
trigger1 = !Time
value = ifElse(!vel x , 41, ifElse(vel x > 0, 42, 43)) + 10 * (var(3) = [1,2])
persistent = 0

[State 50, Assert: No Guard]
type = AssertSpecial
trigger1 = var(3) = [1,2]
flag = NoAirGuard

[State 50, Grounded Frame]
type = PosFreeze
trigger1 = Time < 1 && PrevStateNo = 40
value = 1

[State 50, Gravity]
type = Gravity
trigger1 = Time >= 1 || PrevStateNo != 40

[State 50, Landing]
type = ChangeState
trigger1 = pos y > -vel y
value = 52


[StateDef 51]
type = A
physics = N
moveType = I
sprPriority = 1

[State 51, Gravity]
type = Gravity
trigger1 = 1

[State 51, Landing]
type = ChangeState
trigger1 = pos y > -vel y
value = 52


;Landing
[StateDef 52]
type = S
physics = S
moveType = I
anim = 47
ctrl = 0
velSet = 0,0
sprPriority = 1

[State 52, ChangeAnim]
type = ChangeAnim
trigger1 = !Time && (var(3) = 1 || var(3) = 2)
trigger1 = (PrevStateNo = [600,699])
value = 57

[State 52, PosSet]
type = PosSet
trigger1 = 1
y = 0

[State 52, CtrlSet]
type = CtrlSet
trigger1 = !Time && (PrevStateNo != [600,699])
trigger2 = Time = 1 && Anim != 57
value = 1

[State 52, ChangeState to Guarding]
type = ChangeState
trigger1 = ctrl && command = "holdback"
trigger1 = InGuardDist && (PrevStateNo != [600,699])
value = 120

[State 52, Assert: NoWalk]
type = AssertSpecial
trigger1 = anim != 5
flag = NoWalk

[State 52, Landing Sound]
type = PlaySnd
trigger1 = !Time
value = 52,0

[State 52, Landing Dust Explod]
type = Explod
trigger1 = !Time
anim = 8102
sprPriority = -3
posType = P1
scale = 0.5,0.5
pauseMoveTime = -1
superMoveTime = -1
ownPal = 1

[State 52, ChangeAnim to Turning]
type = ChangeAnim
trigger1 = ctrl && P2Dist x < 0
trigger1 = Anim != 5
value = 5

[State 52, Turn]
type = Turn
trigger1 = Anim = 5 && AnimElem = 1

[State 52, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;=============<Running>====================
[Statedef 100]
type    = S
movetype = I
physics = S
ctrl = 0
VelSet = 0,0

[State 100, ChangeAnim]
type = ChangeAnim
trigger1 = !Time
value = 100

[State 100, Velocity]
type = VelSet
trigger1 = AnimElem = 2 >= 0
x = Const(velocity.run.fwd.x)

[State 100, Change to Run Stop]
type = ChangeState
trigger1 = Command != "holdfwd" && Time >= 10
value = 101
ctrl = 1

[State 100, Able to Jump]
type = ChangeState
trigger1 = Command = "holdupfwd"
value = 40

[State 100, Dust Helper]
type = Helper
trigger1 = AnimElem = 2
helperType = Normal
stateNo = 8103
ID = 8100
name = "Dash Dust"
posType = P1
pauseMoveTime = 255
superMoveTime = 255
ownPal = 1

[State 105, Starting Step snd]
type = PlaySnd
trigger1 = !Time
value = 102, 0
channel = 5

[State 105, Step1 snd]
type = PlaySnd
trigger1 = AnimElem = 3
trigger2 = AnimElem = 9
value = 100, 0
channel = 5

[State 105, Step2 snd]
type = PlaySnd
trigger1 = AnimElem = 6
trigger2 = AnimElem = 12
value = 100, 1
channel = 5

[State 100, No Walk During Run]
type = AssertSpecial
trigger1 = 1
flag = NoWalk

;Run Stop
[Statedef 101]
type = S
movetype = I
physics = S

[State 101, Skid Snd]
type = PlaySnd
trigger1 = !Time
value = 101,0

[State 101, Skid Dust]
type = Explod
trigger1 = !Time
anim = 8104
sprPriority=3
posType = P1
pos = -10,0
vel = 0,0
scale = 0.5,0.5
pauseMovetime = -1
superMoveTime = -1
ownpal = 1

[State 101, ChangeAnim]
type = ChangeAnim
trigger1 = !Time
value = 101

[State 101, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;------------------------ 
;Hop Back
[Statedef 105]
type = S
movetype = I
physics = S
anim = 105
ctrl = 0
velset = 0, 0

[State 105, StateTypeSet];Air, no physics
type = Null
trigger1 = AnimElem = 3
statetype = A
physics = N

[State 105, Dust Helper]
type = Helper
trigger1 = AnimElem = 1
helperType = Normal
stateNo = 8103
ID = 8100
name = "Dash Dust"
posType = P1
facing = -1
pauseMoveTime = 255
superMoveTime = 255
ownPal = 1

[State 105, VelSet]
type = VelSet
trigger1 = AnimElem = 1
x = Const(velocity.run.back.x)
;y = Const(velocity.run.back.y)

[State 106, Landing Dust Explod]
type = Explod
trigger1 = AnimElem = 5
anim = 8102
sprpriority = -3
postype = P1
scale = 0.5,0.5
pauseMoveTime = -1
superMoveTime = -1
ownPal = 1

[State 106, Landing Sound]
type = PlaySnd
trigger1 = !Time
value = 52,0

[State 105, Gravity]
type = Null
trigger1 = AnimElem = 3 > 0
y = .58

[State 105, Dash Back Snd]
type = PlaySnd
trigger1 = AnimElem = 3
value = 105, 0

[State 105, VelAdd]
type = VelSet
trigger1 = !AnimTime
x = 0

[State 105, On Ground]
type = Null
trigger1 = AnimElem = 3 > 0
trigger1 = Vel Y > 0 && Pos Y >= 0
y = 0

[State 105, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;Hop Back Landing
[Statedef 106]
type = S
movetype = I
physics = S
anim = 106
velset = 0, 0

[State 106, Landing Sound]
type = PlaySnd
trigger1 = !Time
value = 52,0

[State 106, Landing Dust Explod]
type = Explod
trigger1 = !Time
anim = 8102
sprpriority = -3
postype = P1
scale = 0.5,0.5
pauseMoveTime = -1
superMoveTime = -1
ownPal = 1

[State 106, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;---------------------------------------------------------------------------
;=================<DASH FORWARD>=================
[StateDef 110]
type = S
physics = N
moveType = I
anim = 110
ctrl = 0
sprPriority = 1

[State 110, VelSet]
type = VelSet
trigger1 = AnimElem = 2
x = const(velocity.run.fwd.x) + 2

[State 110, VelMul]
type = VelMul
trigger1 = AnimElemTime(2) > 0
x = 0.98

[State 105, Dash Back Snd]
type = PlaySnd
trigger1 = Time = 0
value = 105, 0

[State 110, Dust Helper]
type = Helper
trigger1 = AnimElem = 2
helperType = Normal
stateNo = 8103
ID = 8100
name = "Dash Dust"
posType = P1
pauseMoveTime = 255
superMoveTime = 255
ownPal = 1

[State 110, VarSet -> Running]
type = VarSet
trigger1 = !Time
sysvar(1) = 1

[State 110, VarSet -> Not Running]
type = VarSet
triggerAll = Time <= 10
trigger1 = command != "holdfwd"
sysvar(1) = 0

[State 110, ChangeState to Running]
type = ChangeState
trigger1 = Time = 10 && sysvar(1)
value = 100

[State 110, End]
type = ChangeState
trigger1 = !AnimTime
value = 111


;Stop Dashing Forward
[StateDef 111]
type = S
physics = S
ctrl = 1
anim = 111
velSet = 0,0

[State 106, Landing Sound]
type = PlaySnd
trigger1 = !Time
value = 52,0

[State 111, Landing Dust Explod]
type = Explod
trigger1 = !Time
anim = 8102
sprPriority = -3
posType = P1
scale = 0.5,0.5
pauseMoveTime = -1
superMoveTime = -1
ownPal = 1

[State 111, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;=====================<HIT GROUND(BOUNCE)>===================
[Statedef 5100]
type    = L
movetype= H
physics = N

[State 5100, 1]
type = VelSet
trigger1 = Time = 0
trigger1 = GetHitVar(fall.yvel) = 0
trigger1 = vel x > 1
x = 1

[State 5100, EnvShake]
type = FallEnvShake
trigger1 = Time = 0

[State 5100, Var] ;Save fall velocity
type = VarSet
trigger1 = Time = 0
sysvar(1) = floor(vel y)

[State 5100, 2] ;Hit ground anim (normal)
type = ChangeAnim
triggerall = time = 0
trigger1 = (anim != [5051,5059]) && (anim != [5061,5069])
trigger2 = !SelfAnimExist(5100 + (anim % 10))
value = 5100

[State 5100, 3] ;Hit ground anim (for hit up)
type = ChangeAnim
trigger1 = time = 0
trigger1 = (anim = [5051,5059]) || (anim = [5061,5069])
trigger1 = SelfAnimExist(5100 + (anim % 10))
value = 5100 + (anim % 10)

[State 5100, 4]
type = PosSet
trigger1 = Time = 0
y = 0

[State 5100, 5]
type = VelSet
trigger1 = Time = 0
y = 0

[State 5100, 6] ;Reduce speed
type = VelMul
trigger1 = Time = 0
x = 0.75

[State 5100, 7]
type = ChangeState
trigger1 = Time = 0
trigger1 = GetHitVar(fall.yvel) = 0
value = 5110 ;HIT_LIEDOWN

[State 5100, 8]
type = GameMakeAnim
trigger1 = Time = 1
value = 60 + (sysvar(1) > 5) + (sysvar(1) > 14)
pos = 0, 0
under = sysvar(1) <= 14

[State 5100, 9]
type = HitFallDamage
trigger1 = Time = 3

[State 5100, 10] ;Thud sound for when char hits ground
type = PlaySnd
trigger1 = Time = 1
value = 5000,11

[State 5100, 11]
type = PosFreeze
trigger1 = 1

[State 5100, 12]
type = ChangeState
trigger1 = AnimTime = 0
value = 5101

[State 5100, 13]
type = ForceFeedback
trigger1 = Time = 0
waveform = sinesquare
ampl = 128,-3,-.2,.005
time = 20

;================<HIT LIEDOWN>====================
[Statedef 5110]
type    = L
movetype= H
physics = N

[State 5110, EnvShake]
type = FallEnvShake
trigger1 = Time = 0

[State 5110, 1] ;For hit up/up-diag type (from state 5081)
type = ChangeAnim
persistent = 0
trigger1 = SelfAnimExist(5110 + (anim % 10))
trigger1 = anim = [5081,5089]
value = 5110 + (anim % 10)

[State 5110, 2] ;Hit ground anim (normal)
type = ChangeAnim
triggerall = time = 0
triggerall = anim != [5110,5119] ;Not already changed anim
trigger1 = anim != [5161,5169]
trigger2 = !SelfAnimExist(5170 + (anim % 10))
value = 5170

[State 5110, 3] ;Hit ground anim (for hit up)
type = ChangeAnim
triggerall = time = 0
triggerall = anim != [5110,5119] ;Not already changed anim
trigger1 = anim = [5161,5169]
trigger1 = SelfAnimExist(5170 + (anim % 10))
value = 5170 + (anim % 10)

[State 5110, 4]
type = HitFallDamage
trigger1 = Time = 0

[State 5110, 5]
type = PosSet
trigger1 = Time = 0
y = 0

[State 5110, Var] ;Get fall velocity
type = VarSet
trigger1 = Time = 0
trigger1 = GetHitVar(fall.yvel) != 0
sysvar(1) = floor(vel y)

[State 5110, 6] ;Thud sound for when char hits ground
type = PlaySnd
trigger1 = Time = 0
trigger1 = !SysVar(0)
value = 5000,11

[State 5110, 7]
type = GameMakeAnim
trigger1 = Time = 0
trigger1 = !SysVar(0)
value = 60 + (sysvar(1) > 5) + (sysvar(1) > 14)
pos = 0, 0
under = sysvar(1) <= 14

[State 5110, 8]
type = VelSet
trigger1 = Time = 0
y = 0

[State 5110, 9] ;For hit up type
type = ChangeAnim
persistent = 0
triggerall = anim = [5171,5179]
triggerall = SelfAnimExist(5110 + (anim % 10))
trigger1 = AnimTime = 0
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground anim
value = 5110 + (anim % 10)

[State 5110, 10] ;For normal
type = ChangeAnim
persistent = 0
triggerall = Anim != [5111,5119]
trigger1 = AnimTime = 0
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground frame
value = 5110

[State 5110, 11] ;If just died
type = ChangeState
triggerall = !alive
trigger1 = AnimTime = 0
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground frame
trigger3 = Anim = [5110,5119]
value = 5150

[State 5110, 12]
type = VarSet
trigger1 = SysVar(0)
trigger1 = Time = 0
sysvar(0) = 0

[State 5110, 13] ;Friction
type = VelMul
trigger1 = 1
x = 0.85

[State 5110, 14]
type = ForceFeedback
trigger1 = alive
trigger1 = Time = 0
time = 8
ampl = 240
waveform = sine

[State 5110, 15]
type = ForceFeedback
trigger1 = !alive
trigger1 = Time = 0
ampl = 200, 7, -.467
time = 30
waveform = sine

;================<GUARDING>==================
[StateDef 120]
type = U
physics = U
anim = 120 + (StateType = C) + (StateType = A) * 2

[State 120, StateTypeSet: Standing]
type = StateTypeSet
trigger1 = !Time && StateType = S
physics = S

[State 120, StateTypeSet: Crouching]
type = StateTypeSet
trigger1 = !Time && StateType = C
physics = C

[State 120, StateTypeSet: Jumping]
type = StateTypeSet
trigger1 = !Time && StateType = A
physics = A

[State 120, VelSet]
type = VelSet
trigger1 = !Time && StateType != A
x = 0
y = 0

[State 120, Stand to Crouching]
type = StateTypeSet
trigger1 = StateType = S && command = "holddown"
physics = C

[State 120, Crouching to Stand]
type = StateTypeSet
trigger1 = StateType = C && command != "holddown"
stateType = S
physics = S

[State 120, Change to Guard State]
type = ChangeState
trigger1 = !AnimTime
value = 130 + (StateType = C) + (StateType = A) * 2

[State 120, Stop Guarding]
type = ChangeState
trigger1 = command != "holdback"
trigger2 = !InGuardDist
trigger3 = EnemyNear, HitDefAttr = SCA,AT
value = 140


;Standing Guard
[StateDef 130]
type = S
physics = S

[State 130, ChangeAnim]
type = ChangeAnim
trigger1 = Anim != 130
value = 130

[State 130, Standing to Crouch]
type = ChangeState
trigger1 = command = "holddown"
value = 131

[State 130, Stop Guarding]
type = ChangeState
trigger1 = command != "holdback"
trigger2 = !InGuardDist
value = 140

[State 130, Landing Sound]
type = PlaySnd
trigger1 = !Time
trigger1 = PrevStateNo = 132 || (PrevStateNo = [154,155])
value = 52,0

[State 130, Landing Dust Expod]
type = Explod
trigger1 = !Time
trigger1 = PrevStateNo = 132 || (PrevStateNo = [154,155])
anim = 8102
sprpriority = -3
posType = P1
scale = 0.5,0.5
pauseMoveTime = -1
superMoveTime = -1
ownPal = 1


;Crouch Guarding
[StateDef 131]
type = C
physics = C

[State 131, ChangeAnim]
type = ChangeAnim
trigger1 = anim != 131
value = 131

[State 131, Crouching to Standing]
type = ChangeState
trigger1 = command != "holddown"
value = 130

[State 131, Stop Guarding]
type = ChangeState
trigger1 = command != "holdback"
trigger2 = !InGuardDist
value = 140


;Air Guard
[StateDef 132]
type = A
physics = N

[State 132, ChangeAnim]
type = ChangeAnim
trigger1 = anim != 132
value = 132

[State 132, VelAdd]
type = VelAdd
trigger1 = 1
y = const(movement.yAccel)

[State 132, VarSet]
type = VarSet
trigger1 = 1
sysvar(0) = (pos y >= 0 && vel y > 0)

[State 132, VelSet]
type = VelSet
trigger1 = sysvar(0)
y = 0

[State 132, PosSet]
type = PosSet
trigger1 = sysvar(0)
y = 0

[State 132, Jumping to Standing]
type = ChangeState
trigger1 = sysvar(0) && InGuardDist
trigger1 = command = "holdback"
value = 130

[State 132, Change to Falling]
type = ChangeState
trigger1 = sysvar(0)
value = 52

[State 132, Stop Guarding]
type = ChangeState
trigger1 = command != "holdback"
trigger2 = !InGuardDist
value = 140


;Guard End
[StateDef 140]
type = U
physics = U
ctrl = 1

[State 140, ChangeAnim]
type = ChangeAnim
trigger1 = !Time
value = 140 + (StateType = C) + (StateType = A) * 2

[State 140, StateTypeSet: Standing]
type = StateTypeSet
trigger1 = !Time && StateType = S
physics = S

[State 140, StateTypeSet: Crouching]
type = StateTypeSet
trigger1 = !Time && StateType = C
physics = C

[State 140, StateTypeSet: Jumping]
type = StateTypeSet
trigger1 = !Time && StateType = A
physics = A

[State 140, Standing to Crouching]
type = StateTypeSet
trigger1 = StateType = S && command = "holddown"
stateType = C
physics = C

[State 140, Crouching to Standing]
type = StateTypeSet
trigger1 = StateType = C && command != "holddown"
stateType = S
physics = S

[State 140, End]
type = ChangeState
trigger1 = !AnimTime
value = (StateType = C) * 11 + (StateType = A) * 51


;Hit while Guarding (Standing)
[StateDef 150]
type = S
movetype = H
physics = N
velSet = 0,0

[State 150, ChangeAnim]
type = ChangeAnim
trigger1 = 1
value = 150

[State 150, End]
type = ChangeState
trigger1 = HitShakeOver
value = 151 + 2 * command = "holddown"

[State 150, Standing to Crouching]
type = StateTypeSet
trigger1 = StateType = S && command = "holddown"
stateType = C
physics = C

[State 150, Crouching to Standing]
type = StateTypeSet
trigger1 = StateType = C && command != "holddown"
stateType = S
physics = S


;Knocked Back while Guarding (Standing)
[StateDef 151]
type = S
moveType = H
physics = S
anim = 150

[State 151, HitVelSet]
type = HitVelSet
trigger1 = !Time
x = 1

[State 151, VelSet]
type = VelSet
trigger1 = Time = GetHitVar(SlideTime)
trigger2 = HitOver
x = 0

[State 151, CtrlSet]
type = CtrlSet
trigger1 = time = GetHitVar(CtrlTime)
value = 1

[State 151, Standing to Crouching]
type = StateTypeSet
trigger1 = StateType = S && command = "holddown"
stateType = C
physics = C

[State 151, Crouching to Standing]
type = StateTypeSet
trigger1 = Statetype = C && command != "holddown"
stateType = S
physics = S

[State 151, End]
type = ChangeState
trigger1 = HitOver
value = 130
ctrl = 1


;Hit while Guarding (Crouching)
[StateDef 152]
type = C
moveType = H
physics = N
velSet = 0,0

[State 152, ChangeAnim]
type = ChangeAnim
trigger1 = 1
value = 151

[State 152, End]
type = ChangeState
trigger1 = HitShakeOver
value = 151 + 2 * command = "holddown"

[State 152, Standing to Crouching]
type = StateTypeSet
trigger1 = StateType = S && command = "holddown"
stateType = C
physics = C

[State 152, Crouching to Standing]
type = StateTypeSet
trigger1 = StateType = C && command != "holddown"
stateType = S
physics = S


;Knocked Back while Guarding (Crouching)
[StateDef 153]
type = C
moveType = H
physics = C
anim = 151

[State 153, HitVelSet]
type = HitVelSet
trigger1 = !Time
x = 1

[State 153, VelSet]
type = VelSet
trigger1 = Time = GetHitVar(SlideTime)
trigger2 = HitOver
x = 0

[State 153, CtrlSet]
type = CtrlSet
trigger1 = Time = GetHitVar(CtrlTime)
value = 1

[State 153, Standing to Crouching]
type = StateTypeSet
trigger1 = StateType = S && command = "holddown"
stateType = C
physics = C

[State 153, Crouching to Standing]
type = StateTypeSet
trigger1 = StateType = C && command != "holddown"
stateType = S
physics = S

[State 153, End]
type = ChangeState
trigger1 = HitOver
value = 131
ctrl = 1


;Hit while Guarding (Jumping)
[StateDef 154]
type = A
moveType = H
physics = N
velSet = 0,0

[State 154, ChangeAnim]
type = ChangeAnim
trigger1 = 1
value = 152

[State 154, End]
type = ChangeState
trigger1 = HitShakeOver
value = 155


;Knocked Back while Guarding (Jumping)
[StateDef 155]
type = A
moveType = H
physics = N
anim = 152

[State 155, HitVelSet]
type = HitVelSet
trigger1 = !Time
x = 1
y = 1

[State 155, VelAdd]
type = VelAdd
trigger1 = 1
y = const(movement.yAccel)

[State 155, CtrlSet]
type = CtrlSet
trigger1 = Time = GetHitVar(CtrlTime)
value = 1

[State 155, VarSet]
type = VarSet
trigger1 = 1
sysvar(0) = (pos y >= 0 && vel y > 0)

[State 155, VelSet]
type = VelSet
trigger1 = sysvar(0)
y = 0

[State 155, PosSet]
type = PosSet
trigger1 = sysvar(0)
y = 0

[State 155, End]
type = ChangeState
trigger1 = sysvar(0) && InGuardDist
trigger1 = command = "holdback"
value = 130

[State 155, End]
type = ChangeState
trigger1 = sysvar(0)
value = 52

;==========<FORCED P2 RECOVERY>==========
[StateDef 5025]
type = A
moveType = H
physics = N
velSet = 0,0
faceP2 = 1

[State 5025, HitFallSet]
type = HitFallSet
trigger1 = 1
value = 0

[State 5025, End]
type = SelfState
trigger1 = 1
value = ifElse(pos y, 5020, 5000)

;==========<TARGET SAFE FALL>==========
[StateDef 5205]
type = A
physics = N
moveType = H

[State 5205, End]
type = SelfState
trigger1 = 1
value = ifElse(pos y < -20, 5210, 5200)

;==========<FALL RECOVERY>==========
[StateDef 5200]
type = A
moveType = H
physics = N

[State 5200, ChangeAnim]
type = ChangeAnim
trigger1 = anim = 5035 && !AnimTime
value = 5050

[State 5200, VelAdd]
type = VelAdd
trigger1 = 1
y = GetHitVar(yAccel)

[State 5200, End]
type = SelfState
trigger1 = vel y > 0 && pos y >= 10
value = 5201

[StateDef 5201]
type = S
moveType = I
physics = N
anim = 5200
ctrl = 0
faceP2 = 1

[State 5201, PosSet]
type = PosSet
trigger1 = 1
y = 0

[State 5201, VelSet]
type = VelSet
trigger1 = !Time
x = -8
y = 0

[State 5201, VelMul]
type = VelMul
trigger1 = 1
x = 0.9

[State 5201, Voice]
type = PlaySnd
trigger1 = !Time
value = 0,13
channel = 0

[State 5201, Recover Sound]
type = PlaySnd
trigger1 = !Time
value = 5200,0
channel = 1

[State 5201, Flash]
type = PalFX
trigger1 = !Time
add = 255,255,255
sinAdd = -255,-255,-255,40
time=10

[State 5201, Recover FX]
type = Helper
trigger1 = !Time
helperType = Normal
stateNo = 8200
ID = 8200
name = "Recover FX"
posType = P1
pos = 0, ceil(-18 * const(size.yScale))
size.xScale = 1
size.yScale = 1
ownpal = 1

[State 5201, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 5201, End]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1


;Air Recover
[StateDef 5210]
type = A
moveType = I
physics = N
anim = 5210
ctrl = 0
faceP2 = 1

[State 5210, VelAdd]
type = VelAdd
trigger1 = 1
y = 0.6

[State 5210, VelSet]
type = VelSet
trigger1 = !Time
x = ifElse((command = "holdfwd" && command != "holdback"), 0, ifElse((command != "holdfwd" && command = "holdback"), -4, -2))
y = -7.55

[State 5210, Voice]
type = PlaySnd
trigger1 = !Time
value = 0,13
channel = 0

[State 5210, Recover Sound]
type = PlaySnd
trigger1 = !Time
value  = 5200,0
channel = 1

[State 5210, Flash]
type = PalFX
trigger1 = !Time
add = 255,255,255
sinAdd = -255,-255,-255,40
time = 10

[State 5210, Recover FX]
type = Helper
trigger1 = !Time
helperType = Normal
stateNo = 8200
ID = 8200
name = "Recover FX"
posType = P1
pos = 0, ceil(-66 * const(size.yScale))
size.xScale = 1
size.yScale = 1
ownPal = 1

[State 5210, NotHitBy]
type = NotHitBy
trigger1 = AnimElemTime(8) < 0
value = SCA
time = 1

[State 5210, CtrlSet]
type = CtrlSet
trigger1 = AnimElemTime(8) >= 0
value = 1

[State 5210, Land]
type = ChangeState
trigger1 = pos y > -vel y
value = 52

;============<CONTINUE?>==============
[Statedef 5500]
type = S
anim = 5300
velset = 0,0
ctrl = 0

[State 5500, Anim]
type = ChangeAnim
trigger1 = !Time
value = 5500

;=============<CHEAP K.O.>=============
[StateDef 5950]
type = S
moveType = H
physics = S
anim = 5950
velSet = 0,0

[State 5950, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA

[State 5950, PosSet]
type = PosSet
trigger1 = 1
y = 0

[State 5950, Assert: NoKOsnd]
type = AssertSpecial
trigger1 = 1
flag = NoKOsnd

[State 5950, StopSnd]
type = StopSnd
trigger1 = !Time && !Alive
channel = 0

[State 5950, KO Sound]
type = PlaySnd
trigger1 = AnimElem = 2 && !Alive
value = 5950,0

[State 5950, Hitting the Floor Sound]
type = PlaySnd
trigger1 = AnimElem = 5
value = 5000,11
volume = 200

[State 5950, Hitting the Floor Explod]
type = Explod
trigger1 = AnimElem = 5
anim = 8102
sprpriority = -3
postype = P1
scale = 0.5,0.5
pauseMoveTime = -1
superMoveTime = -1
ownPal = 1

[State 5950, End]
type = ChangeState
trigger1= !AnimTime
value = ifElse(Alive, 5110, 5150)

;================<AIR HIT TRANSITION>=================
[Statedef 5035]
type = A
movetype = H
physics = N

[State 5035, ChangeAnim]
type = ChangeAnim
trigger1 = !Time
trigger1 = SelfAnimExist(5035)
trigger1 = Anim = [5000,5029]
value = 5035

[State 5035, VelAdd]
type = VelAdd
trigger1 = 1
y = GetHitVar(yAccel)

[State 5035, Recover]
type = ChangeState
triggerAll = !HitFall
trigger1 = HitOver
trigger2 = !AnimTime
trigger3 = vel y > 0 && pos y >= 10
trigger4 = !Time
trigger4 = Anim != 5035
value = 5040

[State 5035, Fall]
type = ChangeState
triggerAll = HitFall
trigger1 = HitOver
trigger2 = !AnimTime
trigger3 = vel y > 0 && pos y >= 10
trigger4 = !Time
trigger4 = Anim != 5035
value = 5050

[Statedef 6200] ;;Special thanks to Don Drago
type    = S
movetype= H
physics = N
velset = 0,0

[State 6000, 1]
type = hitfallset
trigger1 = 1
value = 0
ignorehitpause = 1

[State 6000, 1]
type = Playerpush
trigger1 = 1
value = 0

[State 6000, 1]
type = hitby
trigger1 = 1
value = SCA,HA, HP, HT
ignorehitpause = 1

[State 6000, 1]
type = PosSet
trigger1 = Time = 0
y = 0

[State 6000, 1]
type = VelSet
trigger1 = Time = 0
y = 0

[State 6000, 1]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) != [3,5]
value = ifelse((GetHitVar(groundtype) = 1),5000,5010) + GetHitVar(animtype)

[State 6000, 1]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5030

[State 6000, 1]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5047 + GetHitVar(animtype) ;5051 - 4 + type

[State 6000, 1]
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 6000, 1]
type = ChangeState
trigger1 = HitShakeOver
value = 6201

[State 6000, 1]
type = ForceFeedback
trigger1 = anim = 5000
trigger2 = anim = 5010
persistent = 0
time = 6
waveform = square

[State 6000, 1]
type = ForceFeedback
trigger1 = anim = 5001
trigger2 = anim = 5011
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 6000, 1]
type = ForceFeedback
trigger1 = anim = 5012
trigger2 = anim = 5002
trigger3 = anim = 5030
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

;---------------------------------------------------------------------------
; HITG_SLIDE
[Statedef 6201]
type    = S
movetype= H
physics = S

[State 6000, 1]
type = hitfallset
trigger1 = 1
value = 0
ignorehitpause = 1

[State 6000, 1]
type = hitby
trigger1 = 1
value = SCA,HA, HP, HT
ignorehitpause = 1

[State 6000, 1]
type = Playerpush
trigger1 = 1
value = 0

[State 6000, 1]
type = HitVelSet
trigger1 = Time = 0
x = 1
ignorehitpause = 1

[State 6000, 1]
type = Null
trigger1 = AnimTime = 0
value = 5005;5005 + GetHitVar(animtype) + (GetHitVar(groundtype)=2)*10

[State 6000, 1]
type = VelMul
trigger1 = Time >= GetHitVar(slidetime)
x = .6

[State 6000, 1]
type = VelSet
trigger1 = HitOver
x = 0

[State 6000, 1]
type = ChangeState
trigger1 = HitOver
value = 6202


;---------------------------------------------------------------------------
; DIZZYED
[Statedef 6202]
type = S
ctrl = 0
movetype = H
velset = 0,0

[State 6000, 1]
type = hitby
trigger1 = 1
value = SCA,HA, HP, HT
ignorehitpause = 1

[State 6000, 1]
type=changeanim
trigger1 = time = 0
trigger1 = selfanimexist(5300)
value = 5300

[State 6000, 1]
type = changeanim2
trigger1 = time = 0 && !selfanimexist(5300)
value = 5301

[State 6000, 1]
type = defencemulset
trigger1 = time = 100
value = 1

[State 6000, 1]
type = Selfstate
trigger1 = time = 100
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; States that are always executed (use statedef -2)
;---------------------------------------------------------------------------
[Statedef -2]

[State -2, Updated Hit Count];special thanks to 20S
type = VarAdd
trigger1 = !IsHelper
trigger1 = MoveHit = 1
trigger1 = !HitPauseTime 
trigger1 = !(HitDefAttr = SCA, AT)
var(13) = 1

[State -2, Hit Count Reset]
type = VarSet
trigger1 = NumEnemy && var(13)
trigger1 = (EnemyNear, MoveType != H) && (EnemyNear, StateNo != 5300)
var(13) = 0
ignoreHitPause = 1

[State -2, Updated Juggle Count];special thanks to 20S
type = VarAdd
trigger1 = !IsHelper
trigger1 = MoveHit = 1
trigger1 = !HitPauseTime 
trigger1 = !(HitDefAttr = SCA, AT)
var(15) = 1

[State -2, Juggle Reset Single];updated special thanks to 20S
type = VarSet
triggerAll = NumEnemy = 1 && var(15)
trigger1 = (Enemy, StateType != A) && (Enemy, StateNo != [5100,5109]) && (Enemy, Time >= 0)
trigger2 = (Enemy, MoveType != H) || (Enemy, StateNo = [120,155]) || (Enemy, Ctrl)
var(15) = 0
ignoreHitPause = 1

[State -2, Juggle Reset Simul];updated special thanks to 20S
type = VarSet
triggerAll = NumEnemy >= 2 && var(15)
trigger1 = (EnemyNear(0), StateType != A) && (EnemyNear(0), Time >= 0)
trigger2 = (EnemyNear(0), MoveType != H) || (EnemyNear(0), StateNo = [120,155]) || (EnemyNear(0), Ctrl)
trigger3 = (EnemyNear(1), StateType != A) && (EnemyNear(0), Time >= 0)
trigger4 = (EnemyNear(1), MoveType != H) || (EnemyNear(0), StateNo = [120,155]) || (EnemyNear(0), Ctrl)
var(15) = 0
ignoreHitPause = 1

[State -2, Free Juggling]
type = VarSet
trigger1 = RoundState != 2
var(15) = 0
ignoreHitPause = 1

[State -2, Juggle Flag]
type = VarSet
trigger1 = NumEnemy && !var(16)
trigger1 = (EnemyNear, StateNo = 5040) && !(EnemyNear, Ctrl)
var(16) = 1
ignorehitpause = 1

[State -2, Juggle Flag Reset Single]
type = VarSet
triggerAll = NumEnemy = 1 && var(16)
trigger1 = (Enemy, MoveType != H) && (Enemy, StateNo != 5040)
trigger2 = !(Enemy, HitShakeOver) || (Enemy, StateType = L) || (Enemy, Ctrl)
var(16) = 0
ignoreHitPause = 1

[State -2, Juggle Flag Reset Simul]
type = VarSet
triggerAll = NumEnemy >= 2 && var(16)
trigger1 = (EnemyNear(0), MoveType != H) && (EnemyNear(0), StateNo != 5040)
trigger2 = !(EnemyNear(0), HitShakeOver) || (EnemyNear(0), StateType = L) || (EnemyNear(0), Ctrl)
trigger3 = (EnemyNear(1), MoveType != H) && (EnemyNear(1), StateNo != 5040)
trigger4 = !(EnemyNear(1), HitShakeOver) || (EnemyNear(1), StateType = L) || (EnemyNear(1), Ctrl)
var(16) = 0
ignoreHitPause = 1

[State -2, Assert: UnGuardable]
type = AssertSpecial
trigger1 = var(17) > 0
trigger1 = var(17) := (var(17) - 1)
flag = UnGuardable
ignoreHitPause = 1

[State -2, P2 Recovery]
type = TargetState
trigger1 = NumTarget(200)
trigger1 = (Target(200), StateNo = 5020) && (Target(200), Alive) && (Target(200), HitFall)
ID = 200
value = 5025
ignoreHitPause = 1

[State -2, P2 Facing]
type = TargetFacing
trigger1 = MoveContact = 1 && NumTarget
trigger1 = !(Target, HitShakeOver) && !(Target, HitFall) && (Target, Time <= 1)
value = ifElse(P2Dist x >= 0, -1, 1)
ignoreHitPause = 1

[State -2, P2 Safe Fall]
type = TargetState
trigger1 = NumTarget = 1
trigger1 = Target, command = "recovery"
trigger1 = Target, pos y >= -20 && Target, vel y > 0
trigger1 = Target, Alive && Target, HitFall && Target, GetHitVar(fall.recover)
trigger1 = Target, StateNo = 5030 || Target, StateNo = 5035 || Target, StateNo = 5050 || Target, StateNo = 5071
value = 5205
ignoreHitPause = 1

[State -2, Hit Detection]
type = VarSet
trigger1 = MoveContact = 1 && var(30) < 0
var(30) = HitPauseTime
ignoreHitPause = 1

[State -2, Hit Sparks]
type = Helper
triggerall =  (StateNo != 1700 && StateNo != 4001) || (StateNo = 1700 && P2Dist x >= 0) || (StateNo = 4001 && P2Dist x >= 0) 
triggerAll = MoveContact = 1 && var(30) = HitPauseTime
trigger1 = MoveHit = 1 && NumEnemy
trigger1 = var(33) = 8010 || var(33) = 8011 || var(33) = 8012 || var(33) = 8013 || var(33) = 8014 || var(33) = 8001
trigger2 = MoveGuarded = 1 && NumEnemy
trigger2 = var(34) = 8000 || var(34) = 8001
HelperType = Normal
stateNo = ifElse(MoveGuarded, var(34), var(33))
ID = 8000
name = "Spark"
Postype = P1
Pos = ifElse(P2Dist x < 0, 0, ifElse(P2Dist x < var(35), ceil(P2Dist x), var(35))), var(36)
facing = -1
ownPal = 1
pauseMoveTime = 65535
superMoveTime = 65535
ignoreHitPause = 1

[State -2, Hit Sparks (Airborne Tatsumaki Senpukyaku, Opponent Behind)]
type = Helper
triggerAll = ((StateNo = 1700 && P2Dist x < 0) || (StateNo = 4001 && P2Dist x < 0))
triggerAll = MoveContact = 1 && var(30) = HitPauseTime
trigger1 = MoveHit = 1 && NumEnemy
trigger1 = var(33) = 8010 || var(33) = 8011 || var(33) = 8012 || var(33) = 8013 || var(33) = 8014 || var(33) = 8001
trigger2 = MoveGuarded = 1 && NumEnemy
trigger2 = var(34) = 8000 || var(34) = 8001
HelperType = Normal
stateNo = ifElse(MoveGuarded, var(34), var(33))
ID = 8000
name = "Spark"
Postype = P1
Pos = ifElse(P2Dist x >= 0, 0, ifElse(P2Dist x >= var(35), ceil(P2Dist x), var(35))), var(36)
facing = 1
ownPal = 1
pauseMoveTime = 65535
superMoveTime = 65535
ignoreHitPause = 1

[State -2, Counter FX]
type = Helper
trigger1 = MoveHit = 1 && var(30) = HitPauseTime
trigger1 = NumEnemy && var(9)
trigger1 = !(HitDefAttr = SCA, AT) && (EnemyNear, MoveReversed != 1)
helperType = Normal
stateNo = 8290
ID = 8290
name = "Counter FX"
posType = P1
pos = ifElse(P2Dist x < 0, 0, ifElse(P2Dist x < var(35), ceil(P2Dist x), var(35))), var(36)
facing = -1
ownPal = 1
pauseMoveTime = 255
superMoveTime = 255
ignoreHitPause = 1

[State -2, Counter Flag]
type = VarSet
trigger1 = NumEnemy
var(9) = (EnemyNear, MoveType = A)
ignoreHitPause = 1

[State -2, Hit Detection]
type = VarSet
trigger1 = 1
var(30) = -1

[State -2, Hit Detection]
type = VarRangeSet
trigger1 = MoveType = I
trigger2 = MoveType = H && Time
first = 30
last = 36
value = -1
ignoreHitPause = 1

[State -2, Throws Allowed]
type = VarSet
trigger1 = 1
var(38) = 0

[State -2, Throws Disallowed]
type = VarSet
triggerall = NumEnemy
trigger1 = (EnemyNear, StateNo = [150,155])
trigger2 = (EnemyNear, MoveType = H && EnemyNear, StateType != A) && !var(21) && !var(22)
trigger3 = (EnemyNear, StateNo = [5020,5040]) && !(EnemyNear, HitFall)
trigger4 = ((EnemyNear, StateNo = 0) || (EnemyNear, StateNo = 52)) && (EnemyNear, PrevStateNo = [5000,5040]) && ((EnemyNear, Time <= 0) || !(EnemyNear, Ctrl))
trigger5 = (EnemyNear, StateNo = 0) && (EnemyNear, PrevStateNo = 52) && ((EnemyNear, Time <= 0) || !(EnemyNear, Ctrl))
trigger6 = (EnemyNear, StateNo = 40) && (EnemyNear, Time >= 1 || EnemyNear, PrevStateNo = 0 || EnemyNear, PrevStateNo = 52)
var(38) = 1

[State -2, Dampener]
type = VarSet
trigger1 = 1
fvar(10) = ifElse(var(13) < 6, 24, ifElse(var(13) >= 23, 1, 29 - var(13))) / 24.0
ignoreHitPause = 1

[State -2, Dampener - Supers]
type = VarSet
trigger1 = (StateNo = [3000,4999])
fvar(10) = ifElse(var(22), 0.6, ifElse(var(21), 0.8, 1.0))
ignoreHitPause = 1

[State -2, Dampener Limit]
type = VarSet
trigger1 = fvar(10) < 0
fvar(10) = 0
ignoreHitPause = 1

[State -2, Root Dampener];Dampener for projectiles
type = VarSet
trigger1 = 1
fvar(11) = fvar(10) * ifElse(var(9), 1.2, 1)
ignoreHitPause = 1

;MAX Mode (Adapted fom Sander 71113's Terry Bogard)
[State -2, MAX Mode End]
type = VarSet
trigger1 = var(20) < 0
trigger2 = RoundState != 2
trigger3 = !Alive
trigger4 = (StateNo = [3000,4999])
var(20) = 0
ignoreHitPause=1

[State -2, MAX Mode Time]
type = VarAdd
trigger1 = var(20) > 0
ignorehitpause = 1
var(20) = -1

[State -2, MAX Mode PowerSet]
type = PowerSet
trigger1 = var(20) > 0
ignorehitpause = 1
value = var(24)

[State -2, MAX Mode PalFX]
type = PalFX
triggerall = var(20) > 0
trigger1 = !(GameTime % 2)
time = 1
add = 60,60,60
ignorehitpause = 1

[State -2, MAX Mode Atk Up]
type = AttackMulSet
trigger1 = var(20) > 0
value = 1.10

[State -2, MAX Mode Atk Reset]
type = AttackMulSet
trigger1 = var(20) <= 0
value = 1

[State -2, MAX Mode Def Up(New)];special thanks to Jesuszilla
type = LifeAdd
triggerall = Alive && MoveType = H
triggerall = var(20) ; MAX Mode 
trigger1 = (FVar(8)-life)>0
value = ifElse((FVar(8)-life)<life,floor((FVar(8)-life)*0.125),0)

[State -2, Life Holder];special thanks to Jesuszilla
type = VarSet
trigger1 = 1
fvar(8) = Life
ignorehitpause = 1

[State -2, Debug Info];Attack strength, # of hits, juggle count
type = DisplayToClipboard
trigger1 = 1
text = "Attack = %f Hits = %d Juggle = %d"
params= fvar(11), var(13), var(15)
ignoreHitPause = 1

[State -2, Debug Info]
type = AppendToClipboard
trigger1 = 1
text = "\nBy Victorys"
ignoreHitPause = 1

[State -2, Voice Position]
type = SndPan
trigger1 = 1
channel = 0
pan = 0
ignoreHitPause = 1

[State -2, Wall Impact Dust];For EX Kung Fu Palm
type = Helper
trigger1 = NumTarget(1500)
trigger1 = (Target(1500), StateNo = 1033) && !NumHelper(8111)
helperType = Normal
stateNo = 8111
ID = 8111
name = "Wall Impact Dust"
posType = P2
facing = -1
pos = Target(1500), Const(size.mid.pos.x) - 10, Target(1500), Const(size.mid.pos.y)
ownPal = 1

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = AnimElem = 15 && Anim = 3101
trigger2 = Anim != 3101
id = 3110

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = AnimElem = 15 && Anim = 3151
trigger2 = Anim != 3151
id = 3151

;[State -2, Ground Impact Dust];Not used, but still added just incase...
;type = Null;Helper
;trigger1 = NumTarget(635)
;trigger1 = (Target(635), StateNo = 636) && !NumHelper(8110)
;helperType = Normal
;stateNo = 8110
;ID = 8110
;name = "Ground Impact Dust"
;posType = P2
;facing = -1
;pos = 0,0
;ownPal = 1

;-------------------------------------
;Has a bug that prevents the player from being KO'd...
;However I keep it around just in case of reworking it or something for-
;some other purpose. An archive of it basically.

;[State -2, MAX Mode Def Up(Old)] 
;type = Null;LifeAdd
;trigger1 = var(20)
;trigger1 = GetHitVar(HitCount) = 1 && GetHitVar(Damage)
;trigger1 = StateNo != [760,762]
;value = ceil(0.1 * GetHitVar(Damage))
;kill = 0
;ignoreHitPause = 1
;--------------------------------------

;---------------------------------------------------------------------------
; States that are executed when in self's state file (use statedef -3)
;---------------------------------------------------------------------------

[Statedef -3]

[State -3, GameTime]
type = VarSet
trigger1 = 1
var(58) = GameTime
ignoreHitPause = 1

[State -3, ProjContact Reset];only needed for projectile using chars 
type = VarSet
triggerAll = var(18)
trigger1 = (StateNo != [3000,3050])
var(18) = 0

[State -3, Projectile Flag Off]
type = Null
trigger1 = !NumHelper(3011)
trigger1 = !NumHelper(3060)
var(39) = 0
ignoreHitPause = 1

[State -3, Parry Detection]
type = Helper
triggerAll = RoundState = 2 && !NumHelper(765) ;&& !var(20)
triggerAll = (MoveType = I && ctrl) || (StateNo = [760,762]) || StateNo = 5120
triggerAll = (command != "rlsfwd" && command != "rlsback" && command != "rlsup" && command != "rlsdown")
trigger1 = (StateType = S || StateType = C || StateNo = 5120) && (command = "fwd" || command = "down")
trigger2 = StateType = A && (var(3) != 1 && var(3) != 2) && command = "fwd"
helperType = Normal
stateNo = 765
ID = 765
name = "Parry Detection"
posType = P1
pauseMoveTime = 65535
superMoveTime = 65535

[State -3, Parry Attacks]
type = ChangeState
trigger1 = (StateNo != [760,762]) && NumHelper(765)
trigger1 = Helper(765), StateNo = 766
value = ifElse((Helper(765), Anim = 767), 762, ifElse((Helper(765), Anim = 766), 761, 760))
ignoreHitPause = 1

[State -3, Parry Projectiles]
type = HitOverride
trigger1 = (StateNo != [760,762]) && NumHelper(765)
trigger1 = !(Helper(765), var(0)) && (Helper(765), Anim = 765)
attr = SA, AP
stateNo = 760
slot = 0
time = 1
ignoreHitPause = 1

[State -3, Parry Projectiles]
type = HitOverride
trigger1 = (StateNo != [760,762]) && NumHelper(765)
trigger1 = !(Helper(765), var(0)) && (Helper(765), Anim = 766)
attr = C, AP
stateNo = 761
slot = 0
time = 1
ignoreHitPause = 1

[State -3, Parry Projectiles]
type = HitOverride
trigger1 = (StateNo != [760,762]) && NumHelper(765)
trigger1 = !(Helper(765), var(0)) && (Helper(765), Anim = 767)
attr = SCA, AP
stateNo = 762
slot = 0
time = 1
ignoreHitPause = 1

[State -3, Assert: NoWalk after Parry]
type = AssertSpecial
trigger1 = var(26) > 0
trigger1 = var(26) := (var(26)-1)
flag = NoWalk

[State -3, Corner Push]
type = VarSet
triggerAll = fvar(5)
trigger1 = abs(fvar(5)) <= (1 / 0.85)
trigger2 = NumTarget
trigger2 = Target, GetHitVar(HitTime) <= 0 || (Target, GetHitVar(HitShakeTime) > 0 && Target, Time <= 0)
fvar(5) = 0

[State -3, Corner Push]
type = VarSet
trigger1 = NumTarget
trigger1 = Target, GetHitVar(HitShakeTime) <= 0
fvar(5) = fvar(5) * 0.85

[State -3, Corner Push]
type = VarSet
triggerall = movetype != H
trigger1 = MoveContact = 1 && NumTarget
fvar(5) = Target, GetHitVar(xVel)
ignoreHitPause = 1

[State -3, Corner Push]
type = PosAdd
triggerAll = fvar(5)
triggerAll = (StateType = S || StateType = C) && NumTarget
triggerAll = !HitPauseTime && Target, GetHitVar(HitShakeTime) <= 1
triggerAll = (Target, StateType = S || Target, StateType = C) && !(Target, GetHitVar(yVel)) && !(Target, HitFall)
trigger1 = Target, FrontEdgeBodyDist <= 0 && (Target, GetHitVar(xVel) * Target, Facing) > 0
trigger2 = Target, BackEdgeBodyDist <= 0 && (Target, GetHitVar(xVel) * Target, Facing) < 0
x = ifElse(Target, FrontEdgeBodyDist <= 0, -1, 1) * (Target, Facing) * fvar(5)

[State -3, Cheap KO]
type = ChangeState
trigger1 = !Alive && (StateNo = [5000,5010])
trigger1 = (PrevStateNo = [130,131]) || (PrevStateNo = [140,141]) || (PrevStateNo = [150,153])
value = 5950
ignoreHitPause = 1

[State -3, Assert: NoKOsnd (Cheap KO)]
type = AssertSpecial
trigger1 = (StateNo = [5000,5010])
trigger1 = (PrevStateNo = [130,131]) || (PrevStateNo = [140,141]) || (PrevStateNo=[150,153])
flag = NoKOsnd
ignoreHitPause = 1

[State -3, Get Hit Sound]
type = PlaySnd
triggerAll = Alive && Time = 1
triggerAll = StateNo = 5000 || StateNo = 5010
trigger1 = GetHitVar(AnimType) >= 2 && Random < 500
trigger2 = GetHitVar(AnimType) = 1 && Random < 375
trigger3 = GetHitVar(AnimType) = 0 && Random < 250
value = 5000,(Random % 3)
channel = 0
ignoreHitPause = 1

[State -3, Get Hit Sound]
type = PlaySnd
triggerAll = Alive && Time = 1
trigger1 = (StateNo = 5000 || StateNo = 5010) && NumEnemy
trigger1 = GetHitVar(fall) || (EnemyNear, HitDefAttr = SCA,SA,HA)
trigger2 = (StateNo = 5020 || StateNo = 5070 || StateNo = 5080)
trigger3 = (StateNo = 5050 || StateNo = 5100) && (PrevStateNo != [5000,5199])
value = 5000,(Random % 3)
channel = 0
ignoreHitPause = 1

[State -3, Special Cancel Reset]
type = VarSet
trigger1 = 1
var(5) = 0
ignoreHitPause = 1

[State -3, Special Cancel Check]
type = VarSet
trigger1= (stateno = [200,699]) && Time <= 2
trigger2= (stateno=[200,205]) && movecontact
trigger3= (stateno=[215,216]) && movecontact
trigger4= Stateno = 225 && movecontact
trigger5= Stateno = 230 && movecontact
trigger6= (stateno=[253,255]) && movecontact
trigger7= (stateno=[400,440]) && movecontact
var(5) = 1
ignoreHitPause = 1

[State -3, Super Cancel Reset]
type = VarSet
trigger1 = 1
var(6) = 0
ignoreHitPause = 1

[State -3, Super Cancel Check]
type = VarSet
trigger1= (stateno = [200,699]) && Time <= 2
trigger2= (stateno=[200,205]) && movecontact
trigger3= (stateno=[215,216]) && movecontact
trigger4= Stateno = 225 && movecontact
trigger5= Stateno = 230 && movecontact
trigger6= (stateno=[253,255]) && movecontact
trigger7= (stateno=[400,440]) && movecontact
trigger8= (stateno=[1000, 1050]) && movecontact ;&& (animelemtime(3)<=0)
trigger9 = StateNo = 1500 && MoveContact && AnimElemTime(6) < 0
trigger10 = (stateno=[1600, 1650]) && MoveContact && AnimElemTime(3) > 0
var(6) = 1
ignoreHitPause = 1

[State -3, MAX Cancel Reset]
type = VarSet
trigger1 = 1
var(7) = 0
ignoreHitPause = 1

[State -3, MAX Cancel Check]
type = VarSet
trigger1= stateno= 3000 && animelemtime(7)>=2 && animelemtime(10)<0 && var(18)
trigger2= stateno= 3101 && animelemtime(3)>=0 && animelemtime(5)<0 && MoveContact
trigger3= stateno= 3201 && animelemtime(4)>=0 && animelemtime(30)<0 && MoveContact
var(7) = 1
ignoreHitPause = 1

[State -3, Underground Juggle Prevention]
type = TargetBind
trigger1 = MoveContact = 1
trigger1 = NumTarget = 1 && NumEnemy
trigger1 = (Target, Time = 0) && (Target, ID = EnemyNear, ID)
trigger1 = !(Target, HitShakeOver) && (Target, Pos y > 0)
pos = ceil(P2dist x), ceil(-pos y)
ignorehitpause = 1

[State -3, Prevent Crossup]
type = Width
trigger1 = 1
edge = 8,0
ignoreHitPause = 1

[State -3, Variable Height]
type = PlayerPush
triggerAll = StateType = A && MoveType != H && NumEnemy
triggerAll = P2BodyDist x = [-(EnemyNear, const(size.ground.back) + EnemyNear, const(size.ground.front)), 0]
trigger1 = P2StateType = S
trigger1 = P2Dist y >= (EnemyNear, const(size.height) - 12)
trigger2 = P2StateType = C
trigger2 = P2Dist y >= (EnemyNear, const(size.height) - 28)
trigger3 = P2StateType = L
trigger3 = P2Dist y >= 12
value = 0
ignoreHitPause = 1

[State -3, Movement AfterImage]
type = AfterImage
triggerAll = Time = 1 
trigger1 = StateNo = 50 && (var(3) = 2 || var(3) = 3)
trigger2 = (StateNo = [700,715])
time = 2
timeGap = 1
frameGap = 4
length = 9
palBright = 0,0,0
palContrast = 128,128,128
palPostBright = 0,0,0
palAdd = 0,0,0
palMul = 0.9,0.9,0.9
trans = Add1

[State -3, EX FX Decrement]
type = VarAdd
trigger1 = var(25) > 0
var(25) = -1

[State -3, EX FX Reset]
type = VarSet
trigger1 = (StateNo != [1000,2999]) || MoveType = H
var(25) = 0

[State -3, EX Flash]
type = PalFX
trigger1 = !(GameTime % 2) && var(25)
time = 1
color = 0
mul = 256, 224, 0
add = 128, 128, 128
ignoreHitPause = 1

[State -3, Level 1 Super AfterImage]
type = AfterImage
trigger1 = StateNo = 3000 && Time = 43
trigger2 = StateNo = 3100 && Time = 43
trigger3 = StateNo = 3200 && Time = 43
time = 2
timeGap = 1
frameGap = 10
length = 21
palBright = 0,0,0
palContrast = 128,128,128
palPostBright = 0,0,0
palAdd = 0,0,0
palMul = 0.75,0.75,0.75
trans = Add1

[State -3, Level 2 Super AfterImage]
type = AfterImage
trigger1 = StateNo = 3050 && Time = 43
trigger2 = Stateno = 3150 && Time = 43
trigger3 = Stateno = 3250 && Time = 43
time = 2
timeGap = 1
framegap = 10
length = 21
palBright = 0,0,0
palContrast = 32,32,160
palPostBright = 0,0,0
palAdd = 0,0,0
palMul = 0.75,0.75,0.75
trans = Add1

[State -3, Level 3 Super AfterImage]
type = AfterImage
trigger1 = StateNo = 4000 && Time = 43
trigger2 = StateNo = 4001 && Time = 3
trigger3 = StateNo = 4100 && Time = 43
trigger4 = StateNo = 4101 && Time = 0
time = 2
timeGap = 1
frameGap = 10
length = 21
palBright = 0,0,0
palContrast = 160,32,32
palPostBright = 0,0,0
palAdd = 0,0,0
palMul= 0.75,0.75,0.75
trans = Add1

[State -3, AfterImage Persist]
type = AfterImageTime
trigger1 = StateNo = 50 || (StateNo = [600,699])
trigger1 = (var(3) = 2 || var(3) = 3) && vel y < -1
trigger2 = StateNo = [700,715]
trigger3 = StateNo = [3000,4999]
time = 2

[State -3, AfterImage Off]
type = AfterImageTime
triggerAll = Time <= 1
trigger1 = StateNo = 3000 || StateNo = 3050 ;|| StateNo = 300
trigger2 = Stateno = 3100 || StateNo = 3101 || StateNo = 3150 || StateNo = 3151 || StateNo = 3152
trigger3 = Stateno = 3200 || Stateno = 3201 || StateNo = 3250 || Stateno = 3251
trigger4 = StateNo = 4000 || Stateno = 4001 || StateNo = 4100 || StateNo = 4101
time = 0

[State -2, AfterImageTime]
type = AfterImageTime
trigger1 = Stateno = 3102
time = 0

[State -3, Super Finish]
type = Helper
triggerAll = WinKO && RoundState = 3 && !NumHelper(8600)
trigger1 = MoveHit = 1 && (StateNo = [3000,4999])
trigger1 = var(23) := StateNo
trigger2 = (StateNo = [3000,3050])
trigger2 = var(23) := 3000
trigger3 = (StateNo = [3100,3152])
trigger3 = var(23) := 3100
trigger4 = (StateNo = [3200,3251])
trigger4 = var(23) := 3200
trigger5 = (StateNo = [4000,4001])
trigger5 = var(23) := 4000
trigger6 = (StateNo = [4100,4101])
trigger6 = var(23) := 4100
helperType = Normal
stateNo = 8600
ID = 8600
name = "Super Finish"
posType = left
pos = 160,-120
ownPal = 1
pauseMoveTime = 255
superMoveTime = 255
ignoreHitPause = 1
