; Common state file for M.U.G.E.N beta 2002.04.14
;
; System variables usage
; ----------------------
; Var name    Type   Purpose
; --------    ----   -------
; sysvar(0)   Temp   Set by state 5081 (HITL_SLIDE) to 1 to prevent
;                    showing ground hit frame in state 5110 (HIT_LIEDOWN).
;                    Used by guarding states.
; sysvar(1)   Temp   Used by state 40 (Jump Start) amd 45 (Air Jump Start)
;                    to keep track of which way to jump.
;                    Used by state 5100 and 5110 to remember downward
;                    velocity of player just before hitting the ground.
;                    Used in state 5080 for storing the anim # to display.

; The following states have special handling within MUGEN, and should be
; overridden with caution:
; Jump Start (40): airjumping bookkeeping at time = 0
; All guard states (120-155): guard handling throughout state
; Hit_trip, shaking (5070): defence increases at time = 0
; Hit_bounce (5100): defence increases at time = 0, player becomes
;                    invincible if within 10 ticks of getting up
; Hit_liedown (5110): player changes to get-up state (5120) when ready
; Hit_getup (5120): player's defence is restored to normal at time = 0
; Hitfall_recover (5200): player's defence is restored at time = 0
; Hitfall_airrecover (5210): player's defence is restored at time = 0

;---------------------------------------------------------------------------
; Stand
[Statedef 0]
type = S
physics = S
sprpriority = 0

[State 0, 2]
type = PosSet
trigger1 = Time = 0
trigger1 = var(11)
y = fvar(2)

[State 0, 2]
type = VelSet
trigger1 = Time = 0
y = 0

[State Jump]
type = ChangeState
trigger1 = command = "holdup"
trigger1 = ctrl
trigger1 = var(59) < 1
value = 40
ctrl = 0

[State Walk]
type = ChangeState
triggerall = var(59) < 1
triggerall = ctrl
trigger1 = command = "holdfwd"
trigger2 = command = "holdback"
value = 20
ctrl = 1

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 0, StateTypeSet]
type = StateTypeSet
trigger1 = command = "holddown"
statetype = C

[State 0, StateTypeSet]
type = StateTypeSet
trigger1 = command != "holddown"
statetype = S

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = var(11)
flag = NoAutoTurn

[State 0, 1]
type = ChangeAnim
trigger1 = p2dist x < 0
value = 5

[State 0, 1]
type = Turn
trigger1 = p2dist x < 0

;[State 0, debug]
;type = PosAdd
;trigger1 = anim = 5
;y = -10

[State 0, 1]
type = ChangeAnim
trigger1 = anim = 6
value = 5

[State 0, 3]
type = ChangeAnim
triggerall = var(11)
trigger1 = anim = 5
value = 15

[State 0, 1]
type = VarSet
trigger1 = anim = 5 || anim = 15
trigger2 = anim = 20
var(9) = 65

[State 0, 1]
type = VarSet
trigger1 = anim = [5005, 5027]
trigger2 = anim = [5505, 5527]
var(9) = 69

[State 0, 1]
type = VarSet
trigger1 = anim = [140, 142]
var(9) = 21

[State 0, 1]
type = VarSet
trigger1 = anim = 0
trigger2 = anim = [21, 22]
trigger3 = anim = 100
var(9) = animelemno(0)

[State 0, 1]
type = ChangeAnim
trigger1 = (anim != [1, 2]) && (Anim != 5 && anim != 15)
trigger1 = fvar(0) := 8*sin(var(9)*pi/36.5 + pi*1.5)*const(size.yscale) || 1
trigger1 = var(0) := 30
trigger2 = (Anim = 5 || anim = 15) && AnimTime = 0 ;Turn anim over
trigger2 = fvar(0) := 8*sin(var(9)*pi/36.5 + pi*1.5)*const(size.yscale) || 1
trigger2 = var(0) := 30
value = ifelse( var(11), 2, 1 )
elem = ifelse(var(9) > 0, var(9), 1)

[State 0, 1]
type = VarSet
trigger1 = anim = [1, 2]
var(9) = 0

[State 0, 1]
type = VarSet
trigger1 = var(0) < 90
fvar(1) = fvar(0)*(0.5 + 0.5*sin(var(0)*pi/60))

[State 0, 1]
type = VarSet
trigger1 = var(0) = 90
fvar(1) = 0

[State 0, 1]
type = VarAdd
trigger1 = var(0) < 90
var(0) = 1

[State 0, Sine]
type = Offset
trigger1 = anim = [1, 2]
y = fvar(1) - 8*sin(animelemno(0)*pi/36.5 + pi*1.5)*const(size.yscale)

[State 0, 3] ;Stop moving if low velocity or 4 ticks pass
type = VelSet
trigger1 = abs(vel x) < 2
trigger2 = Time = 4
x = 0

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

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
trigger2 = roundstate > 2
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; Stand to Crouch
[Statedef 10]
type    = C
physics = C

[State Jump]
type = ChangeState
trigger1 = command = "holdup"
trigger1 = var(59) < 1
value = 40
ctrl = 0

[State Walk]
type = ChangeState
triggerall = var(59) < 1
trigger1 = command = "holdfwd"
trigger2 = command = "holdback"
value = 20
ctrl = 1

[State Cancel]
type = ChangeState
trigger1 = prevstateno = 52
value = 52
ctrl = 1

[State 10, 1]
type = ChangeState
trigger1 = 1
value = 0

[State 10, 1]
type = VelMul
trigger1 = Time = 0
x = .75

[State 10, 2]
type = ChangeState
trigger1 = AnimTime = 0
value = 11

;---------------------------------------------------------------------------
; Crouching
[Statedef 11]
type    = C
physics = C
sprpriority = 0

[State Jump]
type = ChangeState
trigger1 = command = "holdup"
trigger1 = var(59) < 1
value = 40
ctrl = 0

[State Walk]
type = ChangeState
triggerall = var(59) < 1
trigger1 = command = "holdfwd"
trigger2 = command = "holdback"
value = 20
ctrl = 1

[State 12, 1]
type = ChangeState
trigger1 = 1
value = 0

[State 11, 1] ;Change from turning animation
type = ChangeAnim
trigger1 = Anim = 6 && AnimTime = 0
value = 11

;---------------------------------------------------------------------------
; Crouch to Stand
[Statedef 12]
type    = S
physics = S

[State Jump]
type = ChangeState
trigger1 = command = "holdup"
trigger1 = var(59) < 1
value = 40
ctrl = 0

[State Walk]
type = ChangeState
triggerall = var(59) < 1
trigger1 = command = "holdfwd"
trigger2 = command = "holdback"
value = 20
ctrl = 1

[State 12, 1]
type = ChangeState
trigger1 = 1
value = 0

;---------------------------------------------------------------------------
; Walk
[Statedef 20]
type    = S
physics = S
sprpriority = 0

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 20, 1]
type = VelSet
trigger1 = 1
x = 0

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

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

[State 20, 1a]
type = VelSet
trigger1 = var(59) > 0
trigger1 = var(51) = [1, 59]
trigger1 = frontedgebodydist > 0
trigger1 = var(51) := var(51) - 1 || 1
x = const(velocity.walk.fwd.x)

[State 20, 2b]
type = VelSet
trigger1 = var(59) > 0
trigger1 = var(51) = [-59, -1]
trigger1 = backedgebodydist > 0
trigger1 = var(51) := var(51) + 1 || 1
x = const(velocity.walk.back.x)

[State 20, 1c]
type = VelSet
trigger1 = var(59) > 0
trigger1 = var(51) = 60
trigger1 = frontedgebodydist > 0
x = const(velocity.walk.fwd.x)

[State 20, 2d]
type = VelSet
trigger1 = var(59) > 0
trigger1 = var(51) < -60
trigger1 = backedgebodydist > 0
x = const(velocity.walk.back.x)

[State 20, 1]
type = ChangeState
trigger1 = !vel x
value = 0
ctrl = 1

[State 20, AssertSpecial]
type = AssertSpecial
trigger1 = var(11)
flag = NoAutoTurn

[State 20, 1]
type = ChangeAnim
trigger1 = p2dist x < 0
value = 5

[State 20, 1]
type = Turn
trigger1 = p2dist x < 0
trigger1 = var(51) := -var(51) || 1
value = 5

[State 20, 3]
type = ChangeAnim
triggerall = var(11)
trigger1 = anim = 5
value = 15

[State 20, 3]
type = ChangeAnim
triggerall = !var(11)
triggerall = vel x > 0
trigger1 = Anim != 20 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 20
elem = ifelse(anim = 1212, 6, 1)

[State 20, 4]
type = ChangeAnim
triggerall = !var(11)
triggerall = vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 21
elem = ifelse(anim = 15, 65, 1)

[State 20, 3]
type = ChangeAnim
triggerall = var(11)
triggerall = vel x > 0
trigger1 = Anim != 100 && Anim != 15
trigger2 = Anim = 15 && AnimTime = 0
value = 100
elem = ifelse((anim = [1, 2]) || anim = 22, animelemno(0), 1)

[State 20, 4]
type = ChangeAnim
triggerall = var(11)
triggerall = vel x < 0
trigger1 = Anim != 22 && Anim != 15
trigger2 = Anim = 15 && AnimTime = 0
value = 22
elem = ifelse(anim = 15, 65, 1)

[State 20, 3]
type = ChangeAnim
trigger1 = p2dist x < 0
value = ifelse(var(11), 15, 5)

[State 20, 3]
type = Turn
trigger1 = p2dist x < 0

[State 20, 1]
type = VelSet
triggerall = !var(12)
trigger1 = anim = 20
trigger1 = animelemno(0) < 5
x = 0

[State 20, 1]
type = PosAdd
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 1
x = const(size.xscale)*8

[State 20, 1]
type = PosAdd
triggerall = anim = 20
triggerall = !var(12)
trigger1 = animelem = 2
trigger2 = animelem = 5
x = const(size.xscale)*24

[State 20, 1]
type = PosAdd
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 3
trigger2 = animelem = 4
x = const(size.xscale)*32

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 1, = 0
edge = floor(-8*const(size.xscale)), floor(8*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 1, = 1
edge = floor(-6*const(size.xscale)), floor(6*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 1, = 2
edge = floor(-4*const(size.xscale)), floor(4*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 1, = 3
edge = floor(-2*const(size.xscale)), floor(2*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 2, = 0
trigger2 = animelem = 5, = 0
edge = floor(-24*const(size.xscale)), floor(24*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 2, = 1
trigger2 = animelem = 5, = 1
edge = floor(-18*const(size.xscale)), floor(18*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 2, = 2
trigger2 = animelem = 5, = 2
edge = floor(-12*const(size.xscale)), floor(12*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 2, = 3
trigger2 = animelem = 5, = 3
edge = floor(-6*const(size.xscale)), floor(6*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 3, = 0
trigger2 = animelem = 4, = 0
edge = floor(-32*const(size.xscale)), floor(32*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 3, = 1
trigger2 = animelem = 4, = 1
edge = floor(-24*const(size.xscale)), floor(24*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 3, = 2
trigger2 = animelem = 4, = 2
edge = floor(-16*const(size.xscale)), floor(16*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State 20, Width]
type = Width
triggerall = !var(12)
triggerall = anim = 20
trigger1 = animelem = 3, = 3
trigger2 = animelem = 4, = 3
edge = floor(-8*const(size.xscale)), floor(8*const(size.xscale))
;player = floor(8*const(size.xscale)), 0

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

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

[State AI Cancel]
type = ChangeState
triggerall = !time
triggerall = var(59) > 0
triggerall = random%3 = 0 && (random%3 = 0 || !var(11))
trigger1 = prevstateno = [0, 11]
trigger2 = prevstateno = 100
value = prevstateno
ctrl = 1

[State 40, ChangeAnim]
type = ChangeAnim
trigger1 = !time
value = ifelse(var(11), 50, 40)

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 40, 2]
type = Turn
trigger1 = Time = 0
trigger1 = p2dist x < 0

[State 40, PlaySnd]
type = PlaySnd
trigger1 = !time
value = 40, 2
channel = 2

[State 40, 2]
type = VarSet
trigger1 = Time = 0
var(11) = 0

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

[State 40, 2]
type = VarSet
trigger1 = command = "holdfwd"
sysvar(1) = 1

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

[State 40, 4]
type = VelSet
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 = const(velocity.jump.y)

[State 40, 5]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = prevstateno = 100 ;RUN_FWD
trigger1 = sysvar(1) = 1
x = const(velocity.runjump.fwd.x)

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; AirJump Start
[Statedef 45]
type    = A
physics = N
ctrl = 0
velset = 0,0

[State 45, 1]
type = ChangeAnim
trigger1 = SelfAnimExist(44)
value = 44

[State 45, 2]
type = ChangeAnim
trigger1 = !SelfAnimExist(44)
value = 41

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

[State 45, 4]
type = VarSet
trigger1 = command = "holdfwd"
sysvar(1) = 1

[State 45, 5]
type = VarSet
trigger1 = command = "holdback"
sysvar(1) = -1

[State 45, 6]
type = VelSet
trigger1 = Time = 2
x = ifelse(sysvar(1)=0, const(velocity.airjump.neu.x), ifelse(sysvar(1)=1, const(velocity.airjump.fwd.x), const(velocity.airjump.back.x)))
y = const(velocity.airjump.y)

[State 45, 7]
type = ChangeState
trigger1 = Time = 2
value = 50
ctrl = 1

;---------------------------------------------------------------------------
; Jump Up
[Statedef 50]
type    = A
physics = A

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 50, 2]
type = VarSet
trigger1 = Time = 0
var(11) = 0

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

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

[State 50, 2]
type = ChangeAnim
trigger1 = !time
trigger1 = anim = [41, 43]
trigger1 = vel y >= -1
value = anim
elem = ifelse(prevstateno = 1300, 10, 8)

[State 50, 3]
type = ChangeAnim
trigger1 = Vel y > -2
trigger1 = SelfAnimExist(anim + 3)
persistent = 0
value = Anim + 3

;---------------------------------------------------------------------------
; Jump Down (empty state for compatibility)
[Statedef 51]
type    = A
physics = N

[State 51, 1]
type = ChangeState
trigger1 = var(11)
trigger1 = var(10) < 3
value = 0

[State 51, 1]
type = ChangeState
trigger1 = 1
value = 50

;---------------------------------------------------------------------------
; Jump Land
[Statedef 52]
type    = S
physics = S
ctrl = 0
velset = 0, 0

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 52, 1]
type = ChangeAnim
trigger1 = anim = 5040
trigger1 = fvar(0) := 8*sin(var(9)*pi/36.5 + pi*1.5)*const(size.yscale) || 1
value = 0
elem = (animelemno(0) + 50)%72 + 1

[State 52, 1]
type = ChangeAnim
trigger1 = anim = 5041
trigger1 = fvar(0) := 8*sin(var(9)*pi/36.5 + pi*1.5)*const(size.yscale) || 1
trigger2 = anim = [5200, 5210]
trigger2 = fvar(0) := 8*sin(var(9)*pi/36.5 + pi*1.5)*const(size.yscale) || 1
value = 0
elem = (animelemno(0) + 47)%72 + 1

[State 52, 1]
type = ChangeAnim
trigger1 = anim != 47
trigger1 = anim != 5
trigger1 = anim
value = 47

[State 52, 1]
type = VelSet
trigger1 = Time = 0
trigger1 = prevstateno != 10
y = 0

[State 52, 2]
type = PosSet
trigger1 = Time = 0
trigger1 = prevstateno != 10
y = 0

[State 52, 3]
type = CtrlSet
trigger1 = animelemno(1) = 2
trigger2 = anim = [1, 2]
trigger3 = prevstateno = 10
value = 1

[State 52, 4]
type = ChangeState
trigger1 = AnimTime = 0
trigger1 = var(9) := 57
trigger2 = anim = 5
trigger2 = var(9) := 57
trigger3 = anim = [0, 2]
trigger3 = var(9) := animelemno(0)
value = 0
ctrl = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; RUN_FWD
[Statedef 100]
type    = S
physics = S
sprpriority = 1

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 100, ChangeAnim]
type = ChangeAnim
trigger1 = anim != 100
value = 100
elem = ifelse((anim = [1, 2]) || (anim = [21, 22]), animelemno(0), 0)

[State 100, ChangeAnim]
type = ChangeAnim
trigger1 = anim = 100
trigger1 = animelemno(0)%4 = 2
value = 100
elem = animelemno(0)+1

[State 100, 1]
type = VelSet
trigger1 = 1
x = const(velocity.run.fwd.x)

[State 100, 2] ;Prevent run from canceling into walk
type = AssertSpecial
trigger1 = 1
flag = NoWalk

[State 100, 3] ;Prevent from turning
type = AssertSpecial
trigger1 = 1
flag = NoAutoTurn

[State 100, 4]
type = ChangeState
trigger1 = time > 3
trigger1 = command != "holdfwd"
value = 0

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; RUN_BACK
[Statedef 105]
type    = A
physics = A
ctrl = 0
anim = 105
sprpriority = 1

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 105, PlaySnd]
type = PlaySnd
trigger1 = !time
value = 40, 2
channel = 2

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

[State 105, 3]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= ifelse(var(11), fvar(2), 0)
value = 106

;---------------------------------------------------------------------------
; RUN_BACK2 (land)
[Statedef 106]
type    = S
physics = S
ctrl = 0
anim = ifelse(var(16), 108, 106)+ (var(11) != 0)
velset = 0, 0

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

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

[State 106, 2]
type = PosSet
trigger1 = Time = 0
y = ifelse(var(11), fvar(2), 0)

[State 106, 3]
type = MakeDust
trigger1 = Time = 0
trigger1 = !var(11)
pos = -5,-2
spacing = 1

[State 106, 4]
type = ChangeState
trigger1 = !animtime
value = 0
ctrl = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; RUN_UP
[Statedef 110]
type    = S
physics = N

[State 110, 0]
type = CtrlSet
trigger1 = Time = 0
value = 0

[State 110, 1]
type = ChangeAnim
trigger1 = Time = 0
value = 110

[State 110, 2]
type = HitBy
trigger1 = Time = 0
value = SCA, NT, ST, HT
time = 30

[State 110, 3]
type = VelSet
trigger1 = Time = 0
x = 0
z = -7

[State 110, 4]
type = VelMul
trigger1 = 1
z = 0.8

[State 110, 5]
type = VelSet
trigger1 = AnimTime = -8
z = 0

[State 110, 7]
type = CtrlSet
trigger1 = AnimTime = 0
value = 1

[State 110, 8]
type = ChangeState
trigger1 = AnimTime = 0
value = 0

;---------------------------------------------------------------------------
; RUN_DOWN
[Statedef 115]
type    = S
physics = N

[State 115, 0]
type = CtrlSet
trigger1 = Time = 0
value = 0

[State 115, 1]
type = ChangeAnim
trigger1 = Time = 0
value = 110

[State 115, 2]
type = HitBy
trigger1 = Time = 0
value = SCA, NT, ST, HT
time = 30

[State 115, 3]
type = VelSet
trigger1 = Time = 0
x = 0
z = 7

[State 115, 4]
type = VelMul
trigger1 = 1
z = 0.8

[State 115, 5]
type = VelSet
trigger1 = AnimTime = -8
z = 0

[State 115, 7]
type = CtrlSet
trigger1 = AnimTime = 0
value = 1

[State 115, 8]
type = ChangeState
trigger1 = AnimTime = 0
value = 0

;---------------------------------------------------------------------------
; GUARD (start)
[Statedef 120]
type = U    ;Leave state type unchanged
physics = U ;Leave physics unchanged

[State 120, 2]
type = StateTypeSet
triggerall = var(11)
trigger1 = var(10) = 1
statetype = S

[State 120, 2]
type = StateTypeSet
triggerall = var(11)
trigger1 = var(10) = 2
statetype = C

[State 120, 2]
type = StateTypeSet
triggerall = var(11)
trigger1 = var(10) = 3
statetype = A

[State 120, 1]
type = ChangeAnim
trigger1 = Time = 0
value = ifelse(var(11), 123, 120 + (statetype = C) + (statetype = A)*2)
elem = ifelse( (anim = [140, 241]) || anim = 143, ifelse(animelemno(0) < 5, 8 + animelemno(0), ifelse(animelemno(0) < 9, animelemno(0), animelemno(0) - 8 ) ), 0 )

[State 120, 2]
type = StateTypeSet
trigger1 = Time = 0 && statetype = S
physics = S

[State 120, 3]
type = StateTypeSet
trigger1 = Time = 0 && statetype = C
physics = C

[State 120, 4]
type = StateTypeSet
trigger1 = Time = 0 && statetype = A
physics = A

[State 120, Hi to Lo]
type = StateTypeSet
triggerall = statetype = S
trigger1 = command = "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = C, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time - fvar(39))
trigger3 = var(59) > 0
trigger3 = time = 0
trigger3 = random < 500 - fvar(39)*10
statetype = C
physics = C

[State 120, Lo to Hi]
type = StateTypeSet
triggerall = statetype = C
trigger1 = command != "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = SA, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time + fvar(39))
statetype = S
physics = S

[State 120, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 130 + (statetype = C) + (statetype = A)*2

[State 120, Stop Guarding]
type = ChangeState
trigger1 = var(59) < 1
trigger1 = command != "holdback"
trigger2 = !inguarddist
value = 140

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S ;not a typo... always S to always block jump attacks
ignorehitpause = 1

;---------------------------------------------------------------------------
; STAND GUARD (guarding)
[Statedef 130]
type    = S
physics = S

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 130, 1]
type = ChangeAnim
trigger1 = Anim != 130
value = 130 + (var(11) != 0)*3

[State 130, Hi to Lo]
type = ChangeState
trigger1 = command = "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = C, NA, SA, HA
trigger2 = random < (12 + (p2statetype = C)*6)*(30 + enemynear, time)
value = 131

[State 130, Stop Guarding]
type = ChangeState
trigger1 = var(59) < 1
trigger1 = command != "holdback"
trigger2 = !inguarddist
trigger3 = var(59) > 0
trigger3 = enemynear, movecontact
trigger3 = !enemynear, hitdefattr = SCA, AA, AP, AT || time > 10
value = 140

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; CROUCH GUARD (guarding)
[Statedef 131]
type    = C
physics = C

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 131, 1]
type = ChangeAnim
trigger1 = Anim != 131
value = 131 + (var(11) != 0)*2

[State 131, Lo to Hi]
type = ChangeState
trigger1 = command != "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = SA, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time + fvar(39))
value = 130

[State 131, Stop Guarding]
type = ChangeState
trigger1 = var(59) < 1
trigger1 = command != "holdback"
trigger2 = !inguarddist
trigger3 = var(59) > 0
trigger3 = enemynear, movecontact
trigger3 = !enemynear, hitdefattr = SCA, AA, AP, AT || time > 10
trigger3 = !enemynear, numproj
value = 140

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; AIR GUARD (guarding)
[Statedef 132]
type    = A
physics = N

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 132, 1]
type = ChangeAnim
trigger1 = Anim != 132
value = 132

[State 132, 2]
type = VelAdd
trigger1 = 1
y = Const(movement.yaccel)

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

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

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

[State 132, 6]
type = ChangeState
trigger1 = sysvar(0)
trigger1 = command = "holdback"
trigger1 = inguarddist
value = 130

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

[State 132, Stop Guarding]
type = ChangeState
trigger1 = var(59) < 1
trigger1 = command != "holdback"
trigger2 = !inguarddist
trigger3 = var(59) > 0
trigger3 = enemynear, movecontact
trigger3 = !enemynear, hitdefattr = SCA, AA, AP, AT || time > 10
trigger3 = !enemynear, numproj
value = 140

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; GUARD (end)
[Statedef 140]
type = U    ;Leave state type unchanged
physics = U ;Leave physics unchanged
ctrl = 1

[State 140, 2]
type = StateTypeSet
triggerall = var(11)
trigger1 = var(10) = 1
statetype = S

[State 140, 2]
type = StateTypeSet
triggerall = var(11)
trigger1 = var(10) = 2
statetype = C

[State 140, 2]
type = StateTypeSet
triggerall = var(11)
trigger1 = var(10) = 3
statetype = A

[State 140, 2]
type = ChangeAnim
trigger1 = Time = 0
value = ifelse(var(11) && statetype != A, 143, 140 + (statetype = C) + (statetype = A)*2)
;elem = ifelse( (anim = [120, 121]) || anim = 123, ifelse(animelemno(0) < 5, 8 + animelemno(0), ifelse(animelemno(0) < 9, animelemno(0), animelemno(0) - 8 ) ), 0 )

[State 140, 2]
type = StateTypeSet
trigger1 = Time = 0 && statetype = S
physics = S

[State 140, 3]
type = StateTypeSet
trigger1 = Time = 0 && statetype = C
physics = C

[State 140, 4]
type = StateTypeSet
trigger1 = Time = 0 && statetype = A
physics = A

[State 140, Hi to Lo]
type = StateTypeSet
triggerall = statetype = S
trigger1 = command = "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = C, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time - fvar(39))
statetype = C
physics = C

[State 140, Lo to Hi]
type = StateTypeSet
triggerall = statetype = C
trigger1 = command != "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = SA, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time + fvar(39))
statetype = S
physics = S

;[State 140, 5] ;Implemented within engine
;type = ChangeState
;trigger1 = AnimTime = 0
;value = (statetype = C)*11 + (statetype = A)*51

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; SGUARDHIT (shaking)
[Statedef 150]
type    = S
movetype= H
physics = N
velset = 0,0

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 150, 1]
type = ChangeAnim
trigger1 = 1
value = 150 + (var(11) != 0)*3

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

[State 150, Hi to Lo]
type = StateTypeSet
triggerall = statetype = S
trigger1 = command = "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = C, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time - fvar(39))
statetype = C
physics = C

[State 150, Lo to Hi]
type = StateTypeSet
triggerall = statetype = C
trigger1 = command != "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = SA, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time + fvar(39))
statetype = S
physics = S

[State 150, 3]
type = ForceFeedback
trigger1 = time = 0
waveform = square
time = 3

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; SGUARDHIT2 (knocked back)
[Statedef 151]
type    = S
movetype= H
physics = S
anim = 150 + (var(11) != 0)*3

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

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

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

[State 151, 3]
type = CtrlSet
trigger1 = Time = GetHitVar(ctrltime)
value = 1


[State 151, Hi to Lo]
type = StateTypeSet
triggerall = statetype = S
trigger1 = command = "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = C, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time - fvar(39))
statetype = C
physics = C

[State 151, Lo to Hi]
type = StateTypeSet
triggerall = statetype = C
trigger1 = command != "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = SA, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time + fvar(39))
statetype = S
physics = S

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

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; CGUARDHIT (shaking)
[Statedef 152]
type    = C
movetype= H
physics = N
velset = 0,0

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 152, 1]
type = ChangeAnim
trigger1 = 1
value = 151 + (var(11) != 0)*2

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

[State 152, Hi to Lo]
type = StateTypeSet
triggerall = statetype = S
trigger1 = command = "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = C, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time - fvar(39))
statetype = C
physics = C

[State 152, Lo to Hi]
type = StateTypeSet
triggerall = statetype = C
trigger1 = command != "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = SA, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time + fvar(39))
statetype = S
physics = S

[State 152, 4]
type = ForceFeedback
trigger1 = time = 0
waveform = square
time = 4

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; CGUARDHIT2 (knocked back)
[Statedef 153]
type    = C
movetype= H
physics = C
anim = 151 + (var(11) != 0)*2

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

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

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

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

[State 153, Hi to Lo]
type = StateTypeSet
triggerall = statetype = S
trigger1 = command = "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = C, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time - fvar(39))
statetype = C
physics = C

[State 153, Lo to Hi]
type = StateTypeSet
triggerall = statetype = C
trigger1 = command != "holddown"
trigger1 = var(59) < 1
trigger2 = var(59) > 0
trigger2 = enemynear, hitdefattr = SA, NA, SA, HA
trigger2 = random < 12*(30 + enemynear, time + fvar(39))
statetype = S
physics = S

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

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; AGUARDHIT (shaking)
[Statedef 154]
type    = A
movetype= H
physics = N
velset = 0,0

[State 154, ChangeState]
type = ChangeState
trigger1 = !time
trigger1 = var(10) = 1
value = 150

[State 154, ChangeState]
type = ChangeState
trigger1 = !time
trigger1 = var(10) = 2
value = 152

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

[State 154, 2]
type = ChangeState
trigger1 = HitShakeOver
value = 155 ;AGUARDHIT2

[State 154, 3]
type = ForceFeedback
trigger1 = time = 0
waveform = square
time = 4

;---------------------------------------------------------------------------
; AGUARDHIT2 (knocked away)
[Statedef 155]
type    = A
movetype= H
physics = N
anim = 152

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

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

[State 155, 2]
type = VelAdd
trigger1 = 1
y = Const(movement.yaccel)

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

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

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

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

[State 155, 6]
type = ChangeState
trigger1 = sysvar(0)
trigger1 = command = "holdback"
trigger1 = inguarddist
value = 130

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

;---------------------------------------------------------------------------
; LOSE (Time over)
[Statedef 170]
type = S
ctrl = 0
anim = 170
velset = 0,0

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

;---------------------------------------------------------------------------
; DRAWGAME (Time over)
[Statedef 175]
type = S
ctrl = 0
velset = 0,0

[State 175, 1] ; If no anim, use go to lose state.
type = ChangeState
trigger1 = Time = 0
trigger1 = !SelfAnimExist(175)
value = 170

[State 175, 2]
type = ChangeAnim
trigger1 = Time = 0
value = 175

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

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

[State 190, 1]
type = ChangeAnim
trigger1 = SelfAnimExist(190)
value = 190

[State 190, 2] ;Go straight to intro.
type = ChangeState
trigger1 = Time = 0
value = 191

;---------------------------------------------------------------------------
; INTRO (override this state to give character an intro)
[Statedef 191]
type = S
ctrl = 0

[State 191, 1]
type = ChangeState
trigger1 = Time = 0
value = 0

;---------------------------------------------------------------------------
; HITG_SHAKE
[Statedef 5000]
type    = S
movetype= H
physics = N
velset = 0,0
movehitpersist = 1
hitcountpersist = 1

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[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) + (var(11) != 0)*500

[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
statetype = a

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

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

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

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

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

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

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

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

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

[State 5001, 2]
type = ChangeAnim
trigger1 = AnimTime = 0
value = 5005 + GetHitVar(animtype) + (GetHitVar(groundtype)=2)*10 + (var(11) != 0)*500

[State 5001, 3] ;Stop sliding back
type = VelMul
trigger1 = Time >= GetHitVar(slidetime)
x = .6

[State 5001, 4]
type = VelSet
trigger1 = HitOver
x = 0

[State 5001, 5]
type = DefenceMulSet
trigger1 = HitOver
value = 1

[State 5001, 6]
type = ChangeState
trigger1 = HitOver
value = 0
ctrl = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; HITC_SHAKE
[Statedef 5010]
type    = C
movetype= H
physics = N
velset = 0,0
movehitpersist = 1
hitcountpersist = 1

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 5010, 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) + (var(11) != 0)*500

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

[State 5010, 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 5010, 4] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

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

[State 5010, 6]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0 && !GetHitVar(fall)
value = 5011 ;HITC_SLIDE

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

[State 5010, FFB Light]
type = ForceFeedback
trigger1 = anim = 5020
persistent = 0
time = 6
waveform = square

[State 5010, FFB Medium]
type = ForceFeedback
trigger1 = anim = 5021
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 5010, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5022
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; HITC_SLIDE
[Statedef 5011]
type    = C
movetype= H
physics = C

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

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

[State 5011, 2]
type = ChangeAnim
trigger1 = AnimTime = 0
value = 5005 + GetHitVar(animtype) + (GetHitVar(groundtype)=2)*10 + (var(11) != 0)*500

[State 5011, 3] ;Stop sliding back
type = VelMul
trigger1 = Time >= GetHitVar(slidetime)
x = .6

[State 5011, 4]
type = VelSet
trigger1 = HitOver
x = 0

[State 5011, 5]
type = DefenceMulSet
trigger1 = HitOver
value = 1

[State 5011, 6]
type = ChangeState
trigger1 = HitOver
value = 11
ctrl = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
statetype = A
ignorehitpause = 1

[State StateType Change]
type = StateTypeSet
trigger1 = var(11)
trigger1 = inguarddist
trigger1 = !var(13)
trigger1 = p2statetype != A || p2movetype != A || !(enemynear, hitdefattr = SCA, AT)
statetype = S
ignorehitpause = 1

;---------------------------------------------------------------------------
; HITA_SHAKE
[Statedef 5020]
type    = A
movetype= H
physics = N
velset = 0,0
movehitpersist = 1
hitcountpersist = 1

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

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

[State 5020, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = ifelse( hitfall, 5030, ifelse(GetHitVar(airtype) = 1,5501,5511) )

[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

[State 5020, FFB Light]
type = ForceFeedback
trigger1 = anim = 5000
trigger2 = anim = 5010
persistent = 0
time = 6
waveform = square

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

[State 5020, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5012
trigger2 = anim = 5002
trigger3 = anim = 5030
trigger4 = anim = [5051,5059]
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

;---------------------------------------------------------------------------
; HITA_UP (initial going up)
[Statedef 5030]
type    = A
movetype= H
physics = N
ctrl = 0

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 5030, 2]
type = VarSet
trigger1 = Time = 0
var(11) = 0

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

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

[State 5030, 3]
type = ChangeAnim
triggerall = !HitFall
triggerall = !animtime || ((anim != [5000, 5029]) && (anim != [5500, 5529]))
trigger1 = HitShakeOver
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= 10  ;.
value = 5031

[State 5030, 3]
type = ChangeState
triggerall = !HitFall
trigger1 = HitShakeOver
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= 10  ;.
value = 5040 ;HITA_RECOV

[State 5030, 4]
type = ChangeState
triggerall = HitFall
trigger1 = HitOver
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= 10  ;.
value = 5050 ;HITA_FALL

[State 5030, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 5035 ;HITA_UP (transition)

;---------------------------------------------------------------------------
; HITA_UP_T (transition)
[Statedef 5035]
type    = A
movetype= H
physics = N

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 5035, 2]
type = VarSet
trigger1 = Time = 0
var(11) = 0

[State 5035, 1]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = SelfAnimExist(5035)
trigger1 = Anim != [5051,5059] ;Not if in hit up anim
trigger1 = Anim != 5090 ;Not if hit off ground anim
value = 5035

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

[State 5035, 3]
type = ChangeState
triggerall = !HitFall
trigger1 = HitOver  ;Hit is over
trigger2 = AnimTime = 0 ;Animation over
trigger3 = Vel Y > 0    ;Hit ground
trigger3 = Pos Y >= 10  ;.
trigger4 = Time = 0     ;No transition anim
trigger4 = Anim != 5035 ;.
value = 5040 ;HITA_RECOV

[State 5035, 4]
type = ChangeState
triggerall = HitFall
trigger1 = HitOver  ;Hit is over
trigger2 = AnimTime = 0 ;Anim is over
trigger3 = Vel Y > 0    ;Hit ground
trigger3 = Pos Y >= 10  ;.
trigger4 = Time = 0     ;No transition anim
trigger4 = Anim != 5035 ;.
value = 5050 ;HITA_FALL

;---------------------------------------------------------------------------
; HITA_RECOV (recovering in air, not falling)
[Statedef 5040]
type    = A
movetype= H
physics = N

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 5040, 2]
type = VarSet
trigger1 = Time = 0
var(11) = 0

[State 5040, 2]
type = ChangeState
trigger1 = !Alive
value = 5050

[State 5040, 2]
type = ChangeAnim
trigger1 = AnimTime = 0
trigger1 = Anim != [5040, 5041]
trigger2 = Time = 0
trigger2 = Anim != 5035
trigger2 = anim != [5000, 5029]
trigger2 = anim != [5500, 5529]
value = ifelse(((anim = [5030, 5035]) && animtime > -6) || anim = 5050 || anim = 5061, 5040, 5041)

[State 5040, 3]
type = CtrlSet
trigger1 = HitOver
value = 1

[State 5040, 4]
type = StateTypeSet
trigger1 = HitOver
movetype = I

[State 5040, 5]
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5040, 6]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 52 ;JUMPLAND

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

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 5050, 2]
type = VarSet
trigger1 = Time = 0
var(11) = 0

[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, 6]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= ifelse((anim = [5051,5059]) || (anim = [5061,5069]), 0, 25)
value = 5100 ;HIT_BOUNCE

;---------------------------------------------------------------------------
; HIT_TRIP (shaking)
[Statedef 5070]
type    = A
movetype= H
physics = N
velset = 0,0

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

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

[State 5070, 2]
type = ChangeState
trigger1 = HitShakeOver
value = 5071

[State 5070, 3]
type = ForceFeedback
trigger1 = time = 0
time = 12
waveform = sinesquare
ampl = 140

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

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[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, 3] ;Hit ground
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 15
type = ChangeState
value = 5110

;---------------------------------------------------------------------------
; HITL_SHAKE
[Statedef 5080]
type    = L
movetype= H
physics = N
velset = 0,0

[State 5080, 1] ;Set default anim
type = VarSet
trigger1 = time = 0
sysvar(2) = ifelse (GetHitVar(yvel) = 0, 5080, 5090)

[State 5080, 2]
type = VarAdd
trigger1 = time = 0
trigger1 = (anim = [5081,5089]) || (anim = [5111,5119])
trigger1 = SelfAnimExist(sysvar(2) + (anim % 10))
sysvar(2) = anim % 10

[State 5080, 3] ;If 5090 doesn't exist, default to 5030
type = VarSet
trigger1 = time = 0
trigger1 = sysvar(2) = 5090
trigger1 = !SelfAnimExist(5090)
sysvar(2) = 5030

[State 5080, 3] ;Freeze
type = ChangeAnim
trigger1 = 1
value = sysvar(2)

[State 5080, 4]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0
value = 5081 ;HITL_SLIDE

[State 5080, 5]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) != 0
value = 5030 ;HITA_UP

;---------------------------------------------------------------------------
; HITL_SLIDE
[Statedef 5081]
type    = L
movetype= H
physics = C

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

[State 5081, 2]
type = VelSet
trigger1 = HitOver
x = 0

[State 5081, 3] ;Don't show hit ground frame
type = VarSet
trigger1 = Time = 0
sysvar(0) = 1

[State 5081, 4]
type = ChangeState
trigger1 = HitOver
value = 5110 ;HIT_LIEDOWN

;---------------------------------------------------------------------------
; HIT_BOUNCE (hit ground)
[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]
type = PlaySnd
trigger1 = Time = 1
value = F7, (sysvar(1) > 5) + (sysvar(1) > 14)

[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_BOUNCE (bounce into air)
[Statedef 5101]
type    = L
movetype= H
physics = N

[State 5101, 1] ;Coming hit ground anim (normal)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim != [5101,5109]
trigger2 = !SelfAnimExist(5160 + (anim % 10))
value = 5160

[State 5101, 2] ;Coming hit ground anim (for hit up)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim = [5101,5109]
trigger1 = SelfAnimExist(5160 + (anim % 10))
value = 5160 + (anim % 10)

[State 5101, 3]
type = HitFallVel
trigger1 = Time = 0

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

[State 5101, 5] ;Acceleration
type = VelAdd
trigger1 = 1
y = .4

[State 5101, 6] ;Hit ground
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 12
type = ChangeState
value = 5110

;---------------------------------------------------------------------------
; 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, 1] ;For hit up/up-diag type (from state 5081)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim = 5070
value = 5117

[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]
type = PlaySnd
trigger1 = Time = 0
trigger1 = !SysVar(0)
value = F7, (sysvar(1) > 5) + (sysvar(1) > 14)

[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

;---------------------------------------------------------------------------
; HIT_GETUP
[Statedef 5120]
type    = L
movetype= I
physics = N

[State 5120, 7]
type = VarSet
trigger1 = !time
var(1) = 0

[State 5120, 1a] ;Get up anim (normal)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim != [5111,5119]
trigger2 = !SelfAnimExist(5120 + (anim % 10))
value = 5120

[State 5120, 1b] ;Get up anim (for hit up/diag-up)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim = [5111,5119]
trigger1 = SelfAnimExist(5120 + (anim % 10))
value = 5120 + (anim % 10)

[State 5120, 2]
type = VelSet
trigger1 = Time = 0
x = 0

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

[State 5120, 4]
type = HitFallSet
trigger1 = AnimTime = 0
value = 1

[State 5120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = AnimTime = 0
value = , NT,ST,HT
time = 12

[State 5120, 6] ;Can't be hit right after getting up (short time)
type = NotHitBy
trigger1 = AnimTime = 0
value2 = SCA
time = 3

[State 5120, 7]
type = VarSet
trigger1 = command = "DPX"
trigger1 = var(0) := 0 || 1
trigger2 = command = "DPY"
trigger2 = var(0) := 1
var(1) = 1

[State 5120, 7]
type = ChangeState
triggerall = AnimTime = 0
triggerall = var(1)
trigger1 = var(0) = 0
trigger1 = command = "holdx"
trigger2 = var(0) = 1
trigger2 = command = "holdy"
value = 1100
ctrl = 1

[State 5120, 7]
type = ChangeState
trigger1 = AnimTime = 0
trigger1 = var(9) := 57
value = 0
ctrl = 1

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

[State 5150, 8]
type = ChangeState
trigger1 = matchover = 1
trigger1 = lose
trigger1 = roundstate > 3
value = 5151

[State 5150, 1] ;Normal anim
type = ChangeAnim
triggerall = Time = 0
triggerall = SelfAnimExist(5140)
trigger1 = (anim != [5111,5119]) && (anim != [5171,5179])
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
trigger1 = Time = 0
trigger1 = Anim != [5140,5159]
trigger1 = Anim != [5110,5119]
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

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

[Statedef 5151]
type    = L
movetype= H
physics = N
sprpriority = -3
anim = 5151

[State 5151, VarSet]
type = VarSet
trigger1 = !time
var(0) = random%2

[State 5151, Helper]
type = Helper
trigger1 = anim = 5151
trigger1 = animelem = 2
id = 5155
name = "seal"
stateno = 5155
ownpal = 1
postype = p1
pos = floor( 40*const(size.xscale) + 0.5), floor( -4*const(size.yscale) + 0.5)

[State 5151, Helper]
type = Helper
trigger1 = anim = 5152
trigger1 = animelem = 9
id = 5160
name = "spirit"
stateno = 5160
ownpal = 1
postype = p1
pos = 0, floor( -16*const(size.yscale) + 0.5)

[State 5151, ChangeAnim]
type = ChangeAnim
trigger1 = anim = 5151
trigger1 = animelem = 8
value = 5152

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

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

[State 5151, AssertSpecial]
type = AssertSpecial
trigger1 = time < 400
flag = RoundNotOver

[State Invisible]
type = AssertSpecial
trigger1 = time > 240
trigger1 = time%2
trigger2 = time > 300
flag = Invisible

[State 5151, PalFX]
type = PalFx
trigger1 = anim = 5152
trigger1 = animelemno(0) > 2
add = floor(sin(gametime*pi/30)*16) - 16, floor(sin(gametime*pi/30)*8) - 24, floor(sin(gametime*pi/30)*16) - 48
mul = 526 + floor(sin(gametime*pi/30)*96), 192 + floor(sin(gametime*pi/30)*114), 16 + floor(sin(gametime*pi/30)*16)
color = 96 - floor(sin(gametime*pi/30)*32)
time = 1
ignorehitpause = 1

[State 5151, PlaySnd]
type = PlaySnd
trigger1 = time = 88
value = 5, 8

[State 5151, Fire FX]
type = Explod
trigger1 = time = 88
id = 5170
anim = 15170 + var(0)*2
sprpriority = -2 + random%3
postype = p1
bindtime = -1
pos = floor(8*const(size.yscale)), floor(-16*const(size.yscale))
random = ceil(const(size.xscale)*16), ceil(const(size.yscale)*8)
ignorehitpause = 1
ownpal = 1

[State 5151, Fire FX]
type = Explod
trigger1 = time = 90
id = 5171
anim = 15172 - var(0)*2
sprpriority = -2 + random%3
postype = p1
bindtime = -1
pos = floor(-16*const(size.yscale)), floor(-8*const(size.yscale))
random = ceil(const(size.xscale)*16), ceil(const(size.yscale)*8)
ignorehitpause = 1
ownpal = 1

;Note: if timing changes, change fire anim length

[Statedef 5155]
type    = A
movetype= I
physics = N
sprpriority = -2
anim = 5155
velset = 2.7, -5.36

[State 5155, ChangeStaet]
type = ChangeState
trigger1 = vel y + pos y >= 0
value = 5156

[State 5155, VelAdd]
type = VelAdd
trigger1 = 1
y = .321

[State 5155, PlaySnd]
type = PlaySnd
trigger1 = !time
value = 5150, 0

[Statedef 5156]
type    = A
movetype= I
physics = N
sprpriority = -2
anim = 5156
velset = 0, 0

[State 5156, PosSet]
type = PosSet
trigger1 = !time
y = 0

[State Invisible]
type = AssertSpecial
trigger1 = root, time-1 > 240
trigger1 = (root, time-1)%2
trigger2 = root, time-1 > 300
flag = Invisible

[Statedef 5160]
type    = A
movetype= I
physics = N
sprpriority = -3
anim = 15160
velset = 0, -1.6

[State 5160, ChangeState]
type = ChangeState
trigger1 = pos y < -120
value = 5165

[State NoShadow]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[State 5160, ExplodS]
type = Explod
trigger1 = time%12 = 0
id = 950
postype = p1
anim = 950
bindtime = 1
pos = 0,0
sprpriority = 2
facing = ifelse(random%2, -1, 1)
ownpal = 1
scale = const(size.xscale), const(size.yscale)
random = floor(8*const(size.xscale)), floor(4*const(size.yscale))

[Statedef 5165]
type    = A
movetype= I
physics = N
sprpriority = -3
anim = 15165

[State 5165, PlaySnd]
type = PlaySnd
trigger1 = !time
value = 5150, 1

[State 5165, VelSet]
type = VelSet
trigger1 = time < 20
y = (-1.6 + time*.02679)*cos(time*pi/40)

[State 5165, VelSet]
type = VelSet
trigger1 = time = [20, 139]
y = -1.0714*cos(time*pi/40)

[State 5165, VelSet]
type = VelSet
trigger1 = time = [140, 150]
y = (-1.0714 - (time-140)*.05357)*cos(time*pi/40)

[State 5165, VelAdd]
type = VelAdd
trigger1 = time > 150
y = -0.107

[State NoShadow]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[State 5167, ExplodS]
type = Explod
trigger1 = time%15 = 0
id = 950
postype = p1
anim = 950 + random%3
bindtime = 1
pos = 0,0
sprpriority = 2
facing = ifelse(random%2, -1, 1)
ownpal = 1
scale = const(size.xscale), const(size.yscale)
random = floor(144*const(size.xscale)), floor(84*const(size.yscale))

;---------------------------------------------------------------------------
; HIT_FALLRECOVER (still falling)
[Statedef 5200]
type    = A
movetype= H
physics = N

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[State 5200, 1] ;Change anim if done with transition
type = ChangeAnim
trigger1 = Anim = 5035
trigger1 = AnimTime = 0
value = 5050

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

[State 5200, 3]
type = SelfState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 10
value = 5201

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

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[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 = -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 = 5210
ctrl = 0

[State StateType Flag]
type = VarSet
trigger1 = !time
var(10) = ifelse( statetype = A, 3, ifelse( statetype = C, 2, 1 ) )
ignorehitpause = 1

[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 = -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

;---------------------------------------------------------------------------
; Continue?
[Statedef 5500]
type = S
ctrl = 0
anim = 5300
velset = 0,0

[State 5500, 1] ;Use continue animation if available
type = ChangeAnim
trigger1 = time = 0
trigger1 = SelfAnimExist(5500)
value = 5500

;---------------------------------------------------------------------------
; Initialize (at the start of the round)
[Statedef 5900]
type = S

[State 5900, 1] ;Clear all int variables
type = VarRangeSet
trigger1 = roundsexisted = 0
value = 0

[State 5900, 2] ;Clear all float variables
type = VarRangeSet
trigger1 = roundsexisted = 0
fvalue = 0

[State 5900, Enemy 1 ID]
type = VarSet
trigger1 = numenemy
var(2) = enemy(0), id

[State 5900, Enemy 2 ID]
type = VarSet
trigger1 = numenemy > 1
var(4) = enemy(1), id

[State 5900, Init]
type = VarSet
trigger1 = 1
var(16) = 1

[State 5900, Init]
type = VarSet
trigger1 = 1
var(22) = 1

[State 5900, Init]
type = VarSet
trigger1 = 1
fvar(2) = -64

[State 5900, Init]
type = VarSet
trigger1 = 1
fvar(12) = 1

[State 5900, Init]
type = VarSet
trigger1 = 1
fvar(14) = 0.9

[State 5900, 3]
type = ChangeState
trigger1 = 1
value = 5901

