;---------------------------------------------------------------------------
;Note: Var(10) assigned for Recovery Roll.

; Stand
[Statedef 0]
type = S
physics = S
sprpriority = 0
velset = 0,0

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

[State 0, 4] ;Are you dead?
type = ChangeState
trigger1 = !alive
value = 5050

;---------------------------------------------------------------------------

; Jump Start
[Statedef 40]
type   = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1
VelSet = 0,0

[State 40, 5]
type = ChangeState
trigger1 = Time = 0
trigger1 = var(13)
trigger1 = p2bodydist X < 40
value = 0
ctrl = 1

[State 40, 1]
type = VarSet
trigger1 = Time = 0
sysvar(1) = 0

[State 40, 2]
type = VarSet
triggerall = Time = 0
trigger1 = command = "holdfwd"
trigger2 = var(13) 
sysvar(1) = 1

[State 40, 3]
type = VarSet
trigger1 = Time = 0 && command = "holdback"
sysvar(1) = -1

[State 40, High jump]
type = VarSet
trigger1 = AnimTime = 0 && Var(1)
trigger2 = prevstateno = 100 && sysvar(1) >= 0
var(1) = -1

[State 40, 4]
type = VelSet
trigger1 = PrevStateNo = 455
trigger1 = AnimTime = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = -7.3

[State 40, 4]
type = VelSet
trigger1 = PrevStateNo != 455
trigger1 = AnimTime = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = ifelse(command = "holdup",const(velocity.jump.y),-4.3)

[State 40, long jump]
type = VelSet
trigger1 = AnimTime = 0 && Var(1) && sysvar(1)
x = ifelse(sysvar(1)=1,5,-5)

[State 40, High jump]
type = VelSet
trigger1 = !AnimTime && Var(1); && sysvar(1) = 0
y = ifelse(command = "holdup",const(velocity.jump.y)*1.2,-4.3)
x = Vel X * 1.2

[State 40, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1
;---------------------------------------------------------------------------
; Jump Up
[Statedef 50]
type    = A
physics = A

[State 50, 1]
type = VarSet
trigger1 = Time = 0
sysvar(1) = 0

[State 50, 2]
type = ChangeAnim
trigger1 = Time = 0
value = ifelse((vel x)=0, 41, ifelse((vel x)>0, 42, 43))

[State 50, 3]
type = ChangeAnim
trigger1 = Vel y > -2
trigger1 = SelfAnimExist(anim + 3)
persistent = 0
value = Anim + 3
;---------------------------------------------------------------------------
; Jump Land
[Statedef 52]
type    = S
physics = S
ctrl = 0
anim = 47
velset = 0,0

[state 52, 1]
type = PlaySnd
trigger1 = !Time
value = 100,0

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

[State 52, 1]
type = VarSet
trigger1 = Time = 0
var(20) = 0

[State 52, 2]
type = CtrlSet
trigger1 = Time = 3
value = 1

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

;---------------------------------------------------------------------------
;Forward Dash
[Statedef 103]
type    = A
physics = N
anim = 102
ctrl = 0
sprpriority = 1

[State 103, 1]
type = VelAdd
trigger1 = 1
y = .5

[State 103, 2]
type = VelSet
trigger1 = !Time
x = 9
y = -4

[State 103, Makedust]
type = Explod
trigger1 = !Time
anim = 7103
ID = 7103
sprpriority = 3
postype = p1
pos = -17,0
vel = 0,0
ownpal = 1

[State 103, 3]
type = ChangeState
trigger1 = command = "holdup"
value = 40

[State 103, 4]
type = AssertSpecial
trigger1 = 1
flag = NoAutoTurn

[State 103, 5]
type = AssertSpecial
trigger1 = 1
flag = NoWalk

[State 103, StateTypeSet]
type = StateTypeSet
trigger1 = animelem = 2
physics = S         ;A,C,S,N
;ignorehitpause =
;persistent =


[State 103, 6]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 104

;----------------------------------------------------------------------
;Forward Dash stop
[Statedef 104]
type    = S
physics = S
ctrl = 0
velset = 0,0
anim = 103

[State 104, Playsnd]
type = PlaySnd
trigger1 = !Time
value = 100,0

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

[State 104, Posfix]
type = PosAdd
trigger1 = !Time
x = 5

[State 104, 4]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; BACK DASH (1)
[Statedef 105]
type     = A
movetype = I
physics  = A
VelSet   = 0,0
anim     = 105
ctrl     = 0
sprpriority = 1

[State 105, vel]
type = VelSet
trigger1 = !Time
x = const(velocity.run.back.x)
y = const(velocity.run.back.y)

[State 105, snd]
type = PlaySnd
trigger1 = !Time
value = 0,105

[State 105, dust]
type = explod
trigger1 = !Time
anim = 7103
ID = 7103
sprpriority = 3
postype = p1
pos = 17,0
vel = 0,0
ownpal = 1

[State 105, 3]
type = ChangeState
trigger1 = Time
trigger1 = Vel Y > 0
trigger1 = Pos Y >= -5
value = 106
;---------------------------------------------------------------------------
; BACK DASH (2 - land)
[Statedef 106]
type    = S
physics = S
ctrl = 1
velset = 0,0
anim = 106

[State 100, steps]
type = PlaySnd
trigger1 = !Time
value = 100,0

[State 106, 2]
type = PosSet
trigger1 = !Time
y = 0

[State 106, posfix]
type = PosAdd
trigger1 = !Time
x = -5

[State 106, 4]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1
;==========<GUARD>==========
;---START---
[Statedef 120]
type = U
physics = U
[State 120, anim]
type = ChangeAnim
trigger1=!time
value = 120+(statetype = C)+(statetype = A)*2
[State 120, sts]
type = statetypeset
trigger1=!time&&statetype = S
physics = S
[State 120, sts]
type = statetypeset
trigger1=!time&&statetype = C
physics = C
[State 120, sts]
type = statetypeset
trigger1=!time&&statetype = A
physics = A
[State 120, Hi to Lo]
type = statetypeset
trigger1=!var(59)&&statetype = S&&command="holddown"
trigger2 = var(59)&&statetype = S&&(enemynear,movetype = A)&&(enemynear,statetype = C)
statetype = C
physics = C
[State 120, Lo to Hi]
type = statetypeset
trigger1=!var(59)&&statetype = C&&command!="holddown"
trigger2 = var(59)&&statetype = C&&(enemynear,movetype = A)&&(enemynear,statetype!=C)
statetype = S
physics = S
[State 120, end]
type = ChangeState
trigger1=!AnimTime
value = 130+(statetype = C)+(statetype = A)*2

[State 120, stop]
type = ChangeState
trigger1=!var(59)&&command!="holdback"
trigger2 = var(59)
trigger2 = enemynear,movetype!=A&&p2bodydist x>=80&&(p2bodydist y!=[-75,75])&&!(enemy,numproj)
trigger3=!inguarddist
value = 140


;---STAND GUARD (guarding)---
[Statedef 130]
type = S
physics = S
[State 130, anim]
type = ChangeAnim
trigger1 = anim!=130
value = 130
[State 130, Hi to Lo]
type = ChangeState
trigger1=!var(59)&&command="holddown"
trigger2 = var(59)&&(enemynear,movetype = A)&&(enemynear,statetype = C)
value = 131

[State 130, Stop Guarding]
type = ChangeState
trigger1=!var(59)&&command!="holdback"
trigger2 = var(59)
trigger2 = enemynear,movetype!=A&&p2bodydist x>=80&&(p2bodydist y!=[-75,75])&&!(enemy,numproj)
trigger3=!inguarddist
value = 140


;---CROUCH GUARD (guarding)---
[Statedef 131]
type = C
physics = C
[State 131, anim]
type = ChangeAnim
trigger1 = anim!=131
value = 131
[State 131, Lo to Hi]
type = ChangeState
trigger1=!var(59)&&statetype = C&&command!="holddown"
trigger2 = var(59)&&statetype = C&&(enemynear,movetype = A)&&(enemynear,statetype!=C)
value = 130

[State 131, Stop Guarding]
type = ChangeState
trigger1=!var(59)&&command!="holdback"
trigger2 = var(59)
trigger2 = enemynear,movetype!=A&&p2bodydist x>=80&&(p2bodydist y!=[-75,75])&&!(enemy,numproj)
trigger3=!inguarddist
value = 140


;---AIR GUARD (guarding)---
[Statedef 132]
type = A
physics = N
[State 132, anim]
type = ChangeAnim
trigger1 = anim!=132
value = 132
[State 132, grav]
type = veladd
trigger1 = 1
y = const(movement.yaccel)
[State 132, var]
type = varset
trigger1 = 1
sysvar(0)=(pos y>=0)&&(vel y>0)
[State 132, vel]
type = VelSet
trigger1 = sysvar(0)
y = 0
[State 132, pos]
type = posset
trigger1 = sysvar(0)
y = 0

[State 132, end]
type = ChangeState
triggerall = sysvar(0)
triggerall = inguarddist
trigger1=!var(59)&&command!="holdback"
trigger2 = var(59)
trigger2 = enemynear,movetype!=A&&p2bodydist x>=80&&(p2bodydist y!=[-75,75])&&!(enemy,numproj)
value = 130

[State 132, end]
type = ChangeState
trigger1 = sysvar(0)
value = 52

[State 132, stop guarding]
type = ChangeState
trigger1=!var(59)&&command!="holdback"
trigger2 = var(59)
trigger2 = enemynear,movetype!=A&&p2bodydist x>=80&&(p2bodydist y!=[-75,75])&&!(enemy,numproj)
trigger3=!inguarddist
value = 140

;---GUARD (end)---
[Statedef 140]
type = U
physics = U
ctrl = 1
[State 140, anim]
type = ChangeAnim
trigger1=!time
value = 140+(statetype = C)+(statetype = A)*2
[State 140, sts]
type = statetypeset
trigger1=!time&&statetype = S
physics = S
[State 140, sts]
type = statetypeset
trigger1=!time&&statetype = C
physics = C
[State 140, sts]
type = statetypeset
trigger1=!time&&statetype = A
physics = A

[State 140, Hi to Lo]
type = statetypeset
trigger1=!var(59)&&statetype = S&&command="holddown"
trigger2 = var(59)&&statetype = S&&(enemynear,movetype = A)&&(enemynear,statetype = C)
statetype = C
physics = C
[State 140, Lo to Hi]
type = statetypeset
trigger1=!var(59)&&statetype = C&&command!="holddown"
trigger2 = var(59)&&statetype = C&&(enemynear,movetype = A)&&(enemynear,statetype!=C)
statetype = S
physics = S

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

;---SGUARDHIT (shaking)---
[Statedef 150]
type = S
movetype = H
physics = N
VelSet = 0,0
[State 150, anim]
type = ChangeAnim
trigger1 = 1
value = 150
[State 150, end]
type = ChangeState
trigger1 = hitshakeover
value = 151+2*(command="holddown")
[State 150, Hi to Lo]
type = statetypeset
trigger1=!var(59)&&statetype = S&&command="holddown"
trigger2 = var(59)&&statetype = S&&(enemynear,movetype = A)&&(enemynear,statetype = C)
statetype = C
physics = C
[State 150, Lo to Hi]
type = statetypeset
trigger1=!var(59)&&statetype = C&&command!="holddown"
trigger2 = var(59)&&statetype = C&&(enemynear,movetype = A)&&(enemynear,statetype!=C)
statetype = S
physics = S
[State 150, shake]
type = forcefeedback
trigger1=!time
waveform = square
time = 3

;---SGUARDHIT2 (knocked back)---
[Statedef 151]
type = S
movetype = H
physics = S
anim = 150
[State 151, vel]
type = hitVelSet
trigger1=!time
x = 1
[State 151, vel]
type = VelSet
trigger1 = time = gethitvar(slidetime)
trigger2 = hitover
x = 0
[State 151, ctrl]
type = ctrlset
trigger1 = time = gethitvar(ctrltime)
value = 1
[State 151, Hi to Lo]
type = statetypeset
trigger1=!var(59)&&statetype = S&&command="holddown"
trigger2 = var(59)&&statetype = S&&(enemynear,movetype = A)&&(enemynear,statetype = C)
statetype = C
physics = C
[State 151, Lo to Hi]
type = statetypeset
trigger1=!var(59)&&statetype = C&&command!="holddown"
trigger2 = var(59)&&statetype = C&&(enemynear,movetype = A)&&(enemynear,statetype!=C)
statetype = S
physics = S
[State 151, end]
type = ChangeState
trigger1 = hitover
value = 130
ctrl = 1

;---CGUARDHIT (shaking)---
[Statedef 152]
type = C
movetype = H
physics = N
VelSet = 0,0
[State 152, anim]
type = ChangeAnim
trigger1 = 1
value = 151
[State 152, end]
type = ChangeState
trigger1 = hitshakeover
value = 151+2*(command="holddown")
[State 152, Hi to Lo]
type = statetypeset
trigger1=!var(59)&&statetype = S&&command="holddown"
trigger2 = var(59)&&statetype = S&&(enemynear,movetype = A)&&(enemynear,statetype = C)
statetype = C
physics = C
[State 152, Lo to Hi]
type = statetypeset
trigger1=!var(59)&&statetype = C&&command!="holddown"
trigger2 = var(59)&&statetype = C&&(enemynear,movetype = A)&&(enemynear,statetype!=C)
statetype = S
physics = S
[State 152, shake]
type = forcefeedback
trigger1=!time
waveform = square
time = 4

;---CGUARDHIT2 (knocked back)---
[Statedef 153]
type = C
movetype = H
physics = C
anim = 151
[State 153, vel]
type = hitVelSet
trigger1=!time
x = 1
[State 153, vel]
type = VelSet
trigger1 = time = gethitvar(slidetime)
trigger2 = hitover
x = 0
[State 153, ctrl]
type = ctrlset
trigger1 = time = gethitvar(ctrltime)
value = 1
[State 153, Hi to Lo]
type = statetypeset
trigger1=!var(59)&&statetype = S&&command="holddown"
trigger2 = var(59)&&statetype = S&&(enemynear,movetype = A)&&(enemynear,statetype = C)
statetype = C
physics = C
[State 153, Lo to Hi]
type = statetypeset
trigger1 = statetype = C&&command!="holddown"
statetype = S
physics = S
[State 153, end]
type = ChangeState
trigger1 = hitover
value = 131
ctrl = 1

;---AGUARDHIT (shaking)---
[Statedef 154]
type = A
movetype = H
physics = N
VelSet = 0,0
[State 154, anim]
type = ChangeAnim
trigger1 = 1
value = 152
[State 154, end]
type = ChangeState
trigger1 = hitshakeover
value = 155
[State 154, shake]
type = forcefeedback
trigger1=!time
waveform = square
time = 4

;---AGUARDHIT2 (knocked away)---
[Statedef 155]
type = A
movetype = H
physics = N
anim = 152
[State 155, vel]
type = hitVelSet
trigger1=!time
x = 1
y = 1
[State 155, vel]
type = veladd
trigger1 = 1
y = const(movement.yaccel)
[State 155, ctrl]
type = ctrlset
trigger1 = time = gethitvar(ctrltime)
value = 1
[State 155, var]
type = varset
trigger1 = 1
sysvar(0)=(pos y>=0)&&(vel y>0)
[State 155, vel]
type = VelSet
trigger1 = sysvar(0)
y = 0
[State 155, pos]
type = posset
trigger1 = sysvar(0)
y = 0

[State 155, end]
type = ChangeState
triggerall = sysvar(0)
triggerall = inguarddist
trigger1=!var(59)&&command!="holdback"
trigger2 = var(59)
trigger2 = enemynear,movetype!=A&&p2bodydist x>=80&&(p2bodydist y!=[-75,75])&&!(enemy,numproj)
value = 130

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


;==========<CHIP K.O.>==========
[Statedef 5950]
type = S
physics = S
movetype = H
anim = 5950
VelSet = 0,0
ctrl = 0
sprpriority=-3
[State 5950, nhb]
type = nothitby
trigger1 = 1
value = SCA
[State 5950, pos]
type = posset
trigger1 = 1
y = 0
[State 5950, sts]
type = statetypeset
trigger1 = AnimElem = 2
statetype = C
physics = C
[State 5950, snd]
type = PlaySnd
trigger1 = AnimElem = 2
value = 0,52
[State 5950, dust]
type = explod
trigger1 = AnimElem = 2
anim = 7104
ID = 7104
sprpriority=-4
postype = p1
pos=-6,0
scale=.5,.5
ownpal = 1
[State 5950, end]
type = ChangeState
trigger1 = AnimElemtime(7)>=0
value = 5150
;==========<LOSE (Time over)>==========
[Statedef 170]
type = S
ctrl = 0
anim = 170
VelSet = 0,0
[State 170, nhb]
type = nothitby
trigger1 = 1
value = SCA
time = 1
[State 170, dust]
type = explod
trigger1 = AnimElem = 2
anim = 7104
ID = 7104
sprpriority=-2
postype = p1
pos=-6,0
ownpal = 1
scale=.5,.5
[State 170, snd]
type = PlaySnd
trigger1 = AnimElem = 2
value = 0,52


;==========<DRAWGAME (Time over)>==========
[Statedef 175]
type = S
ctrl = 0
anim = 175
VelSet = 0,0
[State 175, nhb]
type = nothitby
trigger1 = 1
value = SCA
time = 1
[State 175, dust]
type = explod
trigger1 = AnimElem = 5
anim = 7104
ID = 7104
sprpriority=-2
postype = p1
pos=-5,0
ownpal = 1
[State 175, snd]
type = PlaySnd
trigger1 = AnimElem = 5
value = 5,4

;---------------------------------------------------------------------------
; PREINTRO
[Statedef 190]
type = S
ctrl = 0
VelSet = 0,0

[State 190, 3]
type = ChangeState
trigger1 = 1
value = 191
;---------------------------------------------------------------------------
;
[Statedef 191]
type = S
ctrl = 0
anim = 191
VelSet = 0,0

[State 191, Intro]
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 1100, voice]
type = PlaySnd
trigger1 = AnimElem = 1, = 25
value = 191,0

[State 1100, Playsnd]
type = PlaySnd
trigger1 = AnimElem = 6
value = 200,1
channel = 1

[State 191, 2]
type = ChangeState
trigger1 = Anim = 191
trigger1 = AnimTime = 0
value = 0
;---------------------------------------------------------------------------
; Taunt
[Statedef 195]
type = S
movetype = I
physics = S
anim = 195
VelSet = 0
ctrl = 0

[State 195,ctrl]
type = ctrlset
triggerall = time > 25
trigger1 = command = "holdfwd"
trigger2 = command = "holdback"
trigger3 = command = "holdup"
trigger4 = command = "holddown"
value = 1

[State 1100, voice]
type = PlaySnd
trigger1 = AnimElem = 4
value = 195,0
channel = 1
[State 1100, sfx]
type = PlaySnd
trigger1 = AnimElem = 5
value = 1100,0
channel = 2

[State 195, 1]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
;---------------------------------------------------------------------------
; Winpose
[Statedef 180]
type = S

;Hold an attack button to select your winpose after KO-ing your opponent

[State 180, 1]
type = ChangeState
triggerall = command = "holda" || command = "holdb" || command = "holdc"
trigger1 = !Time
value = 181

[State 180, 1]
type = ChangeState
triggerall = command = "holdx" || command = "holdy" || command = "holdz"
trigger1 = !Time
value = 182

[State 180, 1]
type = ChangeState
trigger1 = !Time
value = ifelse(random < 500,181,182)

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

[State 181, Voice]
type = PlaySnd
trigger1 = AnimElem = 3
value = 181,0
channel = 1

[State 181, 1]
type = AssertSpecial
trigger1 = Time = [0,300]
flag = roundnotover
;---------------------------------------------------------------------------
[Statedef 182]
type = S
ctrl = 0
anim = 182
velset = 0,0

[State 181, Voice]
type = PlaySnd
trigger1 = AnimElem = 13
value = 182,0
channel = 1
[State 181, Voice]
type = PlaySnd
trigger1 = AnimElem = 2
value = 1100,0
channel = 2

[State 181, 1]
type = AssertSpecial
trigger1 = Time = [0,300]
flag = roundnotover

;------------------------------------------------------------------------------

; HITG_SHAKE
[Statedef 5005]
type    = S
movetype= H
physics = N
velset = 0,0

[State 5000, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) != [3,5]
value = ifelse((GetHitVar(groundtype) = 1),5000,5010) + GetHitVar(animtype)

[State 5000, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5030

[State 5000, 3] ;Anim for HIT_UP/HIT_DIAGUP (only if it exists)
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5047 + GetHitVar(animtype) ;5051 - 4 + type

[State 5000, 4] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5000, 5] ;State type gets set to aerial if getting hit up
type = StateTypeSet
trigger1 = Time = 0
trigger1 = GetHitVar(yvel) != 0 && GetHitVar(fall)
trigger2 = Pos Y != 0
type = a

[State 5000, 6]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0
value = 5001 ;HITG_SLIDE

[State 5000, 7]
type = ChangeState
trigger1 = HitShakeOver
value = 5030

;------------------------------------------------------------------------------

[Statedef 5020]
type    = A
movetype= H
physics = N
velset = 0,0

[State 5020, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) != [2,3]
value = ifelse((GetHitVar(airtype) = 1),5031, 5033) + GetHitVar(animtype)

[State 5020, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [2,3]
value = 5033

[State 5020, 3] ;Anim for HIT_UP/HIT_DIAGUP (only if it exists)
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5047 + GetHitVar(animtype) ;5051 - 4 + type

[State 5020, 4] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5020, 5]
type = ChangeState
trigger1 = HitShakeOver
value = 5030

;------------------------------------------------------------------------------

; HITA_FALL (knocked up, falling)
[Statedef 5050]
type    = A
movetype= H
physics = N

[State 5050, 1] ;Change anim when done with transition
type = ChangeAnim
trigger1 = AnimTime = 0
trigger1 = Anim = 5035
trigger2 = Time = 0     ;If no transition anim
trigger2 = Anim != 5035
trigger2 = (Anim != [5051, 5059]) && (Anim != [5061, 5069])
trigger2 = Anim != 5090 ;Not if hit off ground anim
value = 5050

[State 5050, 2] ;Coming down anim
type = ChangeAnim
trigger1 = anim = [5050,5059]
trigger1 = Vel Y >= ifelse(anim = 5050, 1, -2)
trigger1 = SelfAnimExist(anim+10)
value = anim+10
persistent = 0

[State 5050, 3] ;Gravity
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5050, 4] ;Recover near ground
type = ChangeState
triggerall = Vel Y > 0
triggerall = Pos Y >= -20
triggerall = alive
triggerall = CanRecover
trigger1 = Command = "recovery"
value = 5200 ;HITFALL_RECOVER

[State 5050, 5]; Recover in mid air
type = ChangeState
triggerall = Vel Y > -1
triggerall = alive
triggerall = CanRecover
trigger1 = Command = "recovery"
value = 5210 ;HITFALL_AIRRECOVER

[State 5050: Null]
type = Null
trigger1 = (!Time)
trigger1 = (Var(10) := 0)
trigger2 = (Vel Y > -1) && (Alive) && (Command = "rolling")
trigger2 = (Var(10) := 1)

[State 5050: ChangeState]
type = ChangeState
trigger1 = (Vel Y > 0) && (Pos Y >= IfElse((Anim = [5051,5059]) || (Anim = [5061,5069]),0,25))
value = IfElse(Var(10) = 1,7007,5100)

;------------------------------------------------------------------------------

; HIT_TRIP2 (fall through air)
[Statedef 5071]
type    = A
movetype= H
physics = N

[State 5071, 1]
type = HitVelSet
trigger1 = Time = 0
x = 1
y = 1

[State 5071, 2] ;Acceleration
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5071: Null]
type = Null
trigger1 = (!Time)
trigger1 = (Var(10) := 0)
trigger2 = (Vel Y > -1) && (Alive) && (Command = "rolling")
trigger2 = (Var(10) := 1)

[State 5071: ChangeState]
type = ChangeState
trigger1 = (Vel Y > 0) && (Pos Y >= 15)
value = IfElse(Var(10) = 1,7007,5110)

;------------------------------------------------------------------------------

; HIT_LIEDEAD
[Statedef 5150]
type    = L
movetype= H
physics = N
sprpriority = -3

[State 5150, 1] ;Normal anim
type = ChangeAnim
triggerall = prevstateno != 5950
triggerall = Time = 0
triggerall = SelfAnimExist(5140)
trigger1 = (anim != [5111,5119]) && (anim != [5171,5179])
trigger2 = !SelfAnimExist(5140 + (anim % 10))
value = 5140
[State 5150, 1] ;Normal anim
type = ChangeAnim
triggerall = prevstateno = 5950
triggerall = SelfAnimExist(5140)
trigger1 = anim = 5950 && animelem = 11
trigger2 = !SelfAnimExist(5140 + (anim % 10))
value = 5140

[State 5150, 3] ;Hit up type anim
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (anim = [5111,5119]) || (anim = [5171,5179])
trigger1 = SelfAnimExist(5140 + (anim % 10))
value = 5140 + (anim % 10)

[State 5150, 4] ;Match over anim
type = ChangeAnim
persistent = 0
;trigger1 = Time = 0
trigger1 = MatchOver = 1
trigger1 = Anim = [5140,5149]
trigger1 = SelfAnimExist(anim+10)
value = anim+10

[State 5150, 5] ;Switch to 5110 if liedead anim does not exist
type = ChangeAnim
triggerall = prevstateno != 5950
trigger1 = Time = 0
trigger1 = Anim != [5140,5159]
trigger1 = Anim != [5110,5119]
value = 5110
[State 5150, 5] ;Switch to 5110 if liedead anim does not exist
type = ChangeAnim
triggerall = prevstateno = 5950
trigger1 = anim = 5950 && animelem = 11
value = 5110

[State 5150, 6] ;Friction
type = VelMul
trigger1 = 1
x = 0.85

[State 5150, 7] ;Friction
type = VelSet
trigger1 = Vel x < .05
persistent = 0
x = 0

;==========<CONTINUE?>==========
[Statedef 5500]
type = S
anim = 5300
ctrl = 0
VelSet = 0,0
[State 5500, anim]
type = ChangeAnim
trigger1=!time
value = 5300


;==========<INITIALIZE>==========
[Statedef 5900]
type = S

[State 5900, reset]
type = varrangeset
trigger1=!roundsexisted
value = 0
[State 5900, reset]
type = varrangeset
trigger1=!roundsexisted
fvalue = 0

[State 5900, end]
type = ChangeState
trigger1=!time
value = ifelse(roundno = 1,190,0)


;---------------------------------------------------------------------------
; HIT_FALLRECOVER (on the ground)
[Statedef 5201]
type    = A
movetype= H
physics = A
anim = 5040

[State 5201, Playsnd]
type = Playsnd
trigger1 = time = 0
value = s1000, 0

[State 5201, 1] ;Turn if not facing opponent
type = Turn
trigger1 = Time = 0
trigger1 = p2dist X < -5

[State 5201, 2]
type = VelSet
trigger1 = Time = 0
x = -.15
y = -3.5

[State 5201, 3]
type = PosSet
trigger1 = Time = 0
y = 0

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

[State 5201, 5] ;Blink white
type = PalFX
trigger1 = Time = 0
time = 3
add = 128,128,128 ;256,256,256

[State 5201, 6]
type = GameMakeAnim
trigger1 = Time = 1
value = 60
pos = 0, 0
under = 1

;---------------------------------------------------------------
; HIT_AIRFALLRECOVER
[Statedef 5210]
type    = A
movetype= I
physics = N
anim = 5040
ctrl = 0

[State 5210, Playsnd]
type = Playsnd
trigger1 = time = 0
value = s1000, 0

[State 5210, 1] ;Blink white
type = PalFX
trigger1 = Time = 0
time = 3
add = 128,128,128 ;256,256,256

[State 5210, 1]
type = PosFreeze
trigger1 = Time = 0
value = 4

[State 5210, 2] ;Turn if not facing opponent
type = Turn
trigger1 = Time = 0
trigger1 = p2dist X < -20

[State 5210, 1]
type = VelMul
trigger1 = Time = 4
x = .8
y = .8

[State 5210, 1]
type = VelAdd
trigger1 = Time = 4
y = -4.5

[State 5210, 1]
type = VelMul
trigger1 = Time = 4
trigger1 = Vel Y > 0
y = .5

[State 5210, 1]
type = VelAdd
trigger1 = Time = 4
trigger1 = Vel Y > -3
y = -2

[State 5210, 1]
type = VelAdd
trigger1 = Time = 4
trigger1 = Vel Y > -2
y = -1

[State 5210, 2] ;Go up
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holdup"
y = -2

[State 5210, 2] ;Go down
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holddown"
y = 1.5

[State 5210, 2] ;Go fwd
type = VelMul
trigger1 = Time = 4
trigger1 = Command = "holdfwd"
x = 1

[State 5210, 2] ;Go back
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holdback"
x = -1

[State 5210, 3]
type = NotHitBy
trigger1 = Time = 0
value = SCA
time = 15

[State 5210, 4]
type = CtrlSet
trigger1 = Time = 20
value = 1

[State 5210, 5]
type = VelAdd;Gravity
trigger1 = Time >= 4
y = .35

[State 5210, 5] ;Land on ground
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 52 ;JUMP_LAND
ctrl = 1

;---------------------------------------------------------------------------

[Statedef 7007]
type = L
movetype = I
physics = N
anim = 7007
velset = 0,0
ctrl = 0
poweradd = 0
juggle = 0
facep2 = 1
hitdefpersist = 0
movehitpersist = 0
hitcountpersist = 0
sprpriority = 0

[State 7007: NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA

[State 7007: PlayerPush]
type = PlayerPush
trigger1 = 1
value = 0

[State 7007: PosSet]
type = PosSet
trigger1 = (!Time)
y = 0

[State 7007: VelSet]
type = VelSet
trigger1 = (!Time)
x = 6
y = 0

[State 7007: ChangeState]
type = ChangeState
trigger1 = ((Time > 25) && (Command != "holdfwd")) || ((Time > 35) && (Command = "holdfwd"))
value = 5120

