;----------------------------------------------------------------------------
;默认站立姿势
;----------------------------------------------------------------------------
[Statedef 0]
type = S
physics = S
velset = 0,0
anim = 0
;sprpriority = 1

[State 0, 4]
type = CtrlSet
trigger1 = prevstateno = 140
value = 1

[State 0, 4]
type = varset
trigger1 = time = 0
fvar(36) = 0

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

;----------------------------------------------------------------------------
;站立到蹲下
;----------------------------------------------------------------------------
[Statedef 10]
type    = C
physics = C
velset = 0,0
anim = 10

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

;----------------------------------------------------------------------------
;蹲下
;----------------------------------------------------------------------------
[Statedef 11]
type = C
physics = C
velset = 0,0
anim = 11

[State 0, 4]
type = CtrlSet
trigger1 = prevstateno = 140
value = 1

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

;----------------------------------------------------------------------------
;蹲下到站立
;----------------------------------------------------------------------------
[Statedef 12]
type    = S
physics = S
velset = 0,0
anim = 12

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

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

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

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

[State 20, 3]
type = ChangeAnim
triggerall = command = "holdfwd";vel x > 0
trigger1 = Anim != 20 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 20

[State 20, 4]
type = Changestate
triggerall = command = "holdback" 
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 21

[Statedef 21]
type    = S
physics = S
sprpriority = 0

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

[State 20, 4]
type = ChangeAnim
triggerall = command = "holdback";vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 21

;----------------------------------------------------------------------------
;跳前准备动作
;----------------------------------------------------------------------------
[Statedef 40]
type    = S
physics = S
anim = 40
ctrl = 0

[State 40, 3]
type = AssertSpecial
trigger1 = 1
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard

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

[State 40, 1] ; Play sound when jumping (normal)
type = PlaySnd
trigger1 = Time = 0
trigger1 = var(8) != -2
trigger1 = var(8) != 2
value = 1,30

[State 40, turn]
type = turn
trigger1 = time = 0 && P2dist X < 0

[State 40, Disable AI jump]
type = ChangeState
trigger1 = Var(58)
trigger1 = time = 0
trigger1 = Pos Y = 0
value = 105 + (BackEdgeDist < 50)*9939; hop back
ctrl = 1

[State 40, AI jump]
type = VarSet
trigger1 = stateno = 40
trigger1 = var(20)
trigger1 = p2bodydist x <= 70
trigger1 = var(8) != 2
trigger1 = random<=400
var(8) = 1

[State 40, AI long jump]
type = VarSet
triggerall = stateno = 40
trigger1 = var(20)
trigger1 = p2bodydist x > 70
trigger1 = random<=400
trigger2 = PrevStateNo = 100
var(8) = 2

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

[State 40, 1]
type = VarSet
triggerall = !var(20)
trigger1 = command = "holdfwd"
trigger1 = var(8) != 2
var(8) = 1

[State 40, 2]
type = VarSet
triggerall = !var(20)
trigger1 = command = "holdback"
trigger1 = var(8) != -2
var(8) = -1

[State 40, 3]
type = VarSet
triggerall = !var(20)
triggerall = Time = 0
triggerall = command = "holdfwd"
trigger1 = command = "longjump"
trigger2 = prevstateno = 100 ;RUN_FWD
var(8) = 2

[State 40, 4]
type = VarSet
triggerall = !var(20)
trigger1 = Time = 0
trigger1 = command = "holdback"
trigger1 = command = "longjump"
var(8) = -2

[State 40, 5]
type = Afterimage
trigger1 = prevstateno = 100 ;RUN_FWD
trigger1 = sysvar(1) = 1
time = 15
length = 6
PalBright = 0, 0, 0
PalContrast = 128,128,128
PalAdd = 0, 0, 0
PalMul = 1,1,1
FrameGap = 4
Trans = Add1

[State 40, 6]
type = ChangeState
triggerall = AnimTime = 0
trigger1 = var(8) != 0
trigger1 = var(8) != 1
trigger1 = var(8) != -1
trigger1 = command = "holdup"
trigger2 = command != "holdup"
value = 2041

[State 40, 7]
type = VelSet
trigger1 = AnimTime = 0
x = ifelse(var(8)=0, const(velocity.jump.neu.x), ifelse(var(8)>0, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 8]
type = ChangeState
trigger1 = AnimTime = 0
value = 50 + (var(20) = 1)*1991
ctrl = 1

;----------------------------------------------------------------------------
;跳
;----------------------------------------------------------------------------
[Statedef 50]
type    = A
physics = A

[State 50, 3]
type = AssertSpecial
trigger1 = 1
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard

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

[State 50, 3]
type = ChangeAnim
triggerall = anim != 41 && anim != 42 && anim != 43 && anim != 2042
trigger1 = Vel y > -2
trigger1 = SelfAnimExist(anim + 3)
persistent = 0
value = Anim + 3

;----------------------------------------------------------------------------
;矮跳
;----------------------------------------------------------------------------
[Statedef 2041]
type    = A
physics = N
velset = 0, -7.96
ctrl = 1

[State 105, 4]
type = VelAdd
trigger1 = 1
y = .6

[State 2041, 3]
type = AssertSpecial
trigger1 = 1
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard

[State 2041, 2] ; Play sound when jumping (long)
type = PlaySnd
triggerall = Time = 0
trigger1 = var(8) = -2
trigger2 = var(8) = 2
value = 1,30

[State 2041, 3] ; Shadows
type = Afterimage
triggerall = Time = 0
trigger1 = var(8) = -2
trigger2 = var(8) = 2
time = 7
length = 9
PalBright   =   0,  0,  0
PalContrast = 128,128,128
PalAdd      =   0,  0,  0
PalMul      =  1,1,1;.9, .9, .9
FrameGap = 3
Trans = Add1

[State 2041, Afterimage]
type = AfterImagetime
triggerall = time%2 = 0 && time <=7
trigger1 = var(8) = -2
trigger2 = var(8) = 2
time = 2

[State 2041, 4] ; Shadows off
type = Afterimage
triggerall = Time = 14
trigger1 = var(8) = -2
trigger2 = var(8) = 2
time = 0

[State 2041, 6]
type = VelSet
trigger1 = Time = 0
trigger1 = Var(8) = 1
x = 5	;矮跳

[State 2041, 7]
type = VelSet
trigger1 = Time = 0
trigger1 = Var(8) = 2
x = 5.5	;大矮跳

[State 2041, 8]
type = VelSet
trigger1 = Time = 0
trigger1 = Var(8) = -1
x = -5	;矮跳

[State 2041, 9]
type = VelSet
trigger1 = Time = 0
trigger1 = Var(8) = -2
x = -5.5;大矮跳

[State 2041, 10]
type = ChangeState
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X = 0
trigger1 = command = "holdup"
value = 2045

[State 2041, 11] ;Short
type = ChangeAnim
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X = 0
trigger1 = command != "holdup"
value = 2041

[State 2041, 12]
type = ChangeState
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X > 0
trigger1 = command = "holdup"
value = 2045

[State 2041, 13] ;Short
type = ChangeAnim
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X > 0
trigger1 = command != "holdup"
value = 2042

[State 2041, 12]
type = ChangeState
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X < 0
trigger1 = command = "holdup"
value = 2045

[State 2041, 13] ;Short
type = ChangeAnim
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X < 0
trigger1 = command != "holdup"
value = 2043

[State 2041, 1.5]
type = null;veladd
trigger1 = anim = 2041		;[2041,2043]
trigger1 = Time >= 2
y = 0.02

[State 2041, 1.5]
type = null;veladd
trigger1 = Time >= 4
y = 0.14

[State 2041,1]
type = ChangeState
trigger1 = Pos Y >= -6 && Vel Y > 0
value = 52

;----------------------------------------------------------------------------
;高跳
;----------------------------------------------------------------------------
[Statedef 2045]
type    = A
physics = A
velset = 0,-10
ctrl = 1

[State 2045, 3]
type = AssertSpecial
trigger1 = 1
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard

[State 2045, AI anim]
type = ChangeAnim
triggerall = var(59)
trigger1 = Time = 0
trigger1 = Vel X = 0
value = 2041

[State 2045, AI anim]
type = ChangeAnim
triggerall = var(59)
trigger1 = Time = 0
trigger1 = Vel X >  0
value = 2041

[State 2045, AI anim]
type = ChangeAnim
triggerall = var(59)
trigger1 = Time = 0
trigger1 = Vel X <  0
value = 2041

[State 2045, 3] ; Shadows
type = Afterimage
triggerall = Time = 0
trigger1 = var(8) = -2
trigger2 = var(8) = 2
time = 7
length = 9
PalBright   =   0,  0,  0
PalContrast = 128,128,128
PalAdd      =   0,  0,  0
PalMul      =  1,1,1;.9, .9, .9
FrameGap = 3
Trans = Add1

[State 2045, Afterimage]
type = AfterImagetime
trigger1 = time%2 = 0 && time <=7
time = 2

[State 2045, 4] ; Shadows off
type = Afterimage
trigger1 = Time = 14
time = 0

[State 2045, 6]
type = VelSet
trigger1 = Time = 0
trigger1 = Var(8) = 1
x = 5.5;高跳

[State 2045, 7]
type = VelSet
trigger1 = Time = 0
trigger1 = Var(8) = 2
x = 5.5;大高跳

[State 2045, 8]
type = VelSet
trigger1 = Time = 0
trigger1 = Var(8) = -1
x = -5.5;高跳

[State 2045, 9]
type = VelSet
trigger1 = Time = 0
trigger1 = Var(8) = -2
x = -5.5;大高跳

[State 2045, 10]
type = ChangeAnim
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X = 0
trigger1 = command = "holdup"
value = 41

[State 2045, 11] ;Short
type = ChangeAnim
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X = 0
trigger1 = command != "holdup"
value = 2041

[State 2045, 12]
type = ChangeAnim
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X > 0
trigger1 = command = "holdup"
value = 42

[State 2045, 13] ;Short
type = ChangeAnim
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X > 0
trigger1 = command != "holdup"
value = 2041

[State 2045, 12]
type = ChangeAnim
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X < 0
trigger1 = command = "holdup"
value = 43

[State 2045, 13] ;Short
type = ChangeAnim
triggerall = !var(59)
trigger1 = Time = 0
trigger1 = Vel X < 0
trigger1 = command != "holdup"
value = 2041

[State 2045, 1.5]
type = null;veladd
trigger1 = anim = 2041		;[2041,2043]
trigger1 = Time >= 2
y = 0.02

[State 2045, 1.5]
type = null;veladd
trigger1 = Time >= 4
y = 0.14

;----------------------------------------------------------------------------
;落地
;----------------------------------------------------------------------------
[Statedef 52]
type    = S
physics = S
anim = 47
ctrl = 0
velset = 0,0

[State 52, 3]
type = AssertSpecial
trigger1 = 1
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard

[State 52, 3]
type = RemoveExplod
trigger1 = Time = 0
ID = 602
ignorehitpause = 1

[State 52, 3]
type = RemoveExplod
trigger1 = Time = 0
ID = 612
ignorehitpause = 1

[State 52, 3]
type = RemoveExplod
trigger1 = Time = 0
ID = 613
ignorehitpause = 1

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

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

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

;Play sound when landing
[State 52, 3]
type = PlaySnd
trigger1 = Time = 0
value = 1,5

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

;----------------------------------------------------------------------------
;跑
;----------------------------------------------------------------------------
[Statedef 100]
type    = S
physics = S
anim = 100
ctrl = 0

[State 100, Playsnd]
type = PlaySnd
trigger1 = AnimElem = 2
value = 1,2
channel = 5

[State 100, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = NoWalk

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

[State 100, 8]
type = ChangeState
trigger1 = AnimElem = 2,>=0
trigger1 = command = "holdfwd" && command = "holdup"
value = 40
ctrl = 0

[State 100, 8]
type = ChangeState
trigger1 = AnimElem = 2,>=0
trigger1 = command != "holdfwd" && Time >= 13
value = 101
ctrl = 0

;----------------------------------------------------------------------------
;跑急停
;----------------------------------------------------------------------------
[Statedef 101]
type    = S
physics = S
ctrl = 0
anim = 101

[State 101, VelSet]
type = VelSet
trigger1 = time = 0
x = 0

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

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

[State 105,StateTypeSet]
type = StateTypeSet
trigger1 = AnimElem = 2
statetype = A
physics = N

[State 105,VelSet]
type = VelSet
trigger1 = AnimElem = 2
x = -5.7
y = -4.8

[State 105, 4]
type = VelAdd
trigger1 = AnimElem = 2, > 0
y = .65

[State 105,0]
type = PlaySnd
trigger1 = AnimElem = 2
value = 1, 6

[State 105,1]
type = ChangeState
trigger1 = Pos Y >= -4 && Vel Y > 0
value = 106

;----------------------------------------------------------------------------
;急退落地
;----------------------------------------------------------------------------
[Statedef 106]
type = S
movetype = I
physics = S
anim = 106
ctrl = 0
velset = 0, 0

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

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

[State 106,2]
type = MakeDust
trigger1 = Time >= 0
pos = -30, 0

[State 106,3]
type = PlaySnd
trigger1 = Time = 0
value = 1, 5

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

;----------------------------------------------------------------------------
;防御准备动作
;----------------------------------------------------------------------------
[Statedef 120]
type = U    ;Leave state type unchanged
physics = U ;Leave physics unchanged
ctrl = 1

[State 120, VarSet]
type = VarSet
trigger1 = Time = 0
var(6) = 0

[State 120, 1]
type = ChangeAnim
trigger1 = Time = 0
value = 120 + (statetype = C) + (statetype = A)*2

[State 120, 1]
type = ChangeAnim
trigger1 = Time = 0 && var(54) = 1
value = 125 + (statetype = C) + (statetype = A)*2

[State 120, 1]
type = ctrlset
trigger1 = Command != "holdback"
trigger2 = AnimTime = 0
trigger3 = command = "x" || command = "y" || command = "z" || command = "a" || command = "b" || command = "c" || command = "start"
trigger4 = Command = "holdfwd" || Command = "holdup"
value = 1

[State 120, Hi to Lo]
type = ChangeState
trigger1 = (anim = 120 || anim = 125) && ifelse(var(20)=0,command = "holddown",1)
value = 131

[State 120, Hi to Lo]
type = ChangeState
trigger1 = (anim = 121 || anim = 126) && ifelse(var(20)=0,command = "holddown",1)
value = 130

[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, 5]
type = ChangeState
trigger1 = P2MoveType != A
value = 130 + (statetype = C) + (statetype = A)*2

;----------------------------------------------------------------------------
;站立防御动作
;----------------------------------------------------------------------------
[Statedef 130]
type    = S
physics = S
ctrl = 0

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

[State 130, 1]
type = ChangeAnim
trigger1 = Anim != 135 && var(54) = 1
value = 135
persistent = 0

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

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

[State 130, 1]
type = ctrlset
trigger1 = Command != "holdback"
trigger2 = AnimTime = 0
trigger3 = command = "x" || command = "y" || command = "z" || command = "a" || command = "b" || command = "c" || command = "start"
trigger4 = Command = "holdfwd" || Command = "holdup"
value = 1

[State 130, Hi to Lo]
type = ChangeState
trigger1 = command = "holddown"
value = 131

[State 130, 2]
type = ChangeState
trigger1 = P2MoveType != A
value = 140

;----------------------------------------------------------------------------
;蹲下防御动作
;----------------------------------------------------------------------------
[Statedef 131]
type    = C
physics = C
ctrl = 0

[State 131, 1]
type = ChangeAnim
trigger1 = Anim != 131
value = 131
persistent = 0

[State 131, 1]
type = ChangeAnim
trigger1 = Anim != 136 && var(54) = 1
value = 136
persistent = 0

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

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

[State 131, 1]
type = ctrlset
trigger1 = Command != "holdback"
trigger2 = AnimTime = 0
trigger3 = command = "x" || command = "y" || command = "z" || command = "a" || command = "b" || command = "c" || command = "start"
trigger4 = Command = "holdfwd" || Command = "holdup"
value = 1

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

[State 131, 2]
type = ChangeState
trigger1 = P2MoveType != A
value = 140

;----------------------------------------------------------------------------
;空防动作
;----------------------------------------------------------------------------
[Statedef 132]
type    = A
physics = N
ctrl = 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)
y = 0

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

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

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

;----------------------------------------------------------------------------
;防御动作
;----------------------------------------------------------------------------
[Statedef 150]
type    = S
movetype= H
physics = N
velset = 0,0
ctrl = 0

[State 150, 2]
type = ChangeAnim
trigger1 = Anim != 150
value = 150
persistent = 0

[State 150, 2]
type = ChangeAnim
trigger1 = Anim != 155 && var(54) = 1
value = 155
persistent = 0

[State 150, ChangeState]
type = varset
trigger1 = (command = "CD" && (command != "holddown")) || ((command = "holddown") && command = "CD")
var(6) = 1
ignorehitpause = 1

[State 150, ChangeState]
type = ChangeState
trigger1 = HitShakeOver && power >= 1000 && var(6) = 1
value = 260
ignorehitpause = 1

[State 150, ChangeState]
type = varset
trigger1 = command = "900"
var(6) = 2
ignorehitpause = 1

[State 150, ChangeState]
type = ChangeState
trigger1 = HitShakeOver && power >= 1000 && ((var(6) = 2 && Command = "holdback")||(var(20)=1&&(NumProj >0 || NumHelper>0)))
value = 960
ignorehitpause = 1

[State 150, ChangeState]
type = ChangeState
trigger1 = HitShakeOver && power >= 1000 && ((var(6) = 2 && Command != "holdback")||(var(20)=1&&(NumProj >0 || NumHelper>0)))
value = 920
ignorehitpause = 1

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

[State 150, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown"
statetype = C
physics = C

[State 150, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C && command != "holddown"
statetype = S
physics = S

;----------------------------------------------------------------------------
;防御动作
;----------------------------------------------------------------------------
[Statedef 151]
type    = S
movetype= H
physics = S
ctrl = 0

[State 151, 2]
type = ChangeAnim
trigger1 = command != "holddown"
trigger1 = Anim != 150
value = 150
persistent = 1

[State 151, 2]
type = ChangeAnim
trigger1 = command != "holddown"
trigger1 = Anim != 155 && var(54) = 1
value = 155
persistent = 1

[State 151, 2]
type = ChangeAnim
trigger1 = command = "holddown"
trigger1 = Anim != 151
value = 151
persistent = 1

[State 151, 2]
type = ChangeAnim
trigger1 = command = "holddown"
trigger1 = Anim != 151 && var(54) = 1
value = 151
persistent = 1

[State 151, 2]
type = StateTypeSet
trigger1 = Time = 0 && statetype = S
trigger2 = command != "holddown"
physics = S
persistent = 1

[State 151, 3]
type = StateTypeSet
trigger1 = Time = 0 && statetype = C
trigger2 = command = "holddown"
physics = C
persistent = 1

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

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

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

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

[State 151, 4]
type = ChangeState
trigger1 = Time >= GetHitVar(hittime)
value = 130

;----------------------------------------------------------------------------
;防御反击及防御闪避
;----------------------------------------------------------------------------
[Statedef 152]
type    = C
movetype= H
physics = N
velset = 0,0
ctrl = 0
value = 151
persistent = 0

[State 152, 2]
type = ChangeAnim
trigger1 = command = "holddown"
trigger1 = Anim != 156 && var(54) = 1
value = 156
persistent = 0

[State 150, ChangeState]
type = varset
trigger1 = (command = "CD" && (command != "holddown")) || ((command = "holddown") && command = "CD")
var(6) = 1
ignorehitpause = 1

[State 150, ChangeState]
type = ChangeState
trigger1 = HitShakeOver && power >= 1000 && var(6) = 1
value = 260
ignorehitpause = 1

[State 150, ChangeState]
type = varset
trigger1 = command = "900"
var(6) = 2
ignorehitpause = 1

[State 150, ChangeState]
type = ChangeState
trigger1 = HitShakeOver && power >= 1000 && ((var(6) = 2 && Command = "holdback"))
value = 960
ignorehitpause = 1

[State 150, ChangeState]
type = ChangeState
trigger1 = HitShakeOver && power >= 1000 && ((var(6) = 2 && Command != "holdback"))
value = 920
ignorehitpause = 1

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

[State 152, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown"
statetype = C
physics = C

[State 152, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C && command != "holddown"
statetype = S
physics = S

;----------------------------------------------------------------------------
;防御
;----------------------------------------------------------------------------
[Statedef 153]
type    = C
movetype= H
physics = C
ctrl = 0

[State 153, 2]
type = ChangeAnim
trigger1 = Anim != 151
value = 151
persistent = 1

[State 153, 2]
type = ChangeAnim
trigger1 = Anim != 151 && var(54) = 1
value = 151
persistent = 1

[State 153, 2]
type = ChangeAnim
trigger1 = command != "holddown"
trigger1 = Anim != 150
value = 150
persistent = 1

[State 153, 2]
type = ChangeAnim
trigger1 = command != "holddown"
trigger1 = Anim != 155 && var(54) = 1
value = 155
persistent = 1

[State 153, 2]
type = StateTypeSet
trigger1 = Time = 0 && statetype = S
trigger2 = command != "holddown"
physics = S
persistent = 1

[State 153, 3]
type = StateTypeSet
trigger1 = Time = 0 && statetype = C
trigger2 = command = "holddown"
physics = C
persistent = 1

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

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

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

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

[State 153, 4]
type = ChangeState
trigger1 = Time >= GetHitVar(hittime)
value = 131

;----------------------------------------------------------------------------
;防御结束
;----------------------------------------------------------------------------
[Statedef 140]
type = U    ;Leave state type unchanged
physics = U ;Leave physics unchanged
ctrl = 0

[State 140, 1]
type = ChangeAnim
trigger1 = Time = 0
value = 140 + (statetype = C) + (statetype = A)*2

[State 140, 1]
type = ChangeAnim
trigger1 = Time = 0 && var(54) = 1
value = 145 + (statetype = C) + (statetype = A)*2

[State 140, 2]
type = StateTypeSet
trigger1 = Time = 0 && statetype = S && Command = "holdback"
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, 4]
type = CtrlSet
trigger1 = Command != "holdback"
trigger2 = AnimTime = 0
trigger3 = command = "x" || command = "y" || command = "z" || command = "a" || command = "b" || command = "c" || command = "start"
trigger4 = Command = "holdfwd" || Command = "holdup"
value = 1

;----------------------------------------------------------------------------
;time over
;----------------------------------------------------------------------------
[Statedef 170]
type = S
ctrl = 0
anim = 170
velset = 0,0

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

;----------------------------------------------------------------------------
;draw game
;----------------------------------------------------------------------------
[Statedef 175]
type = S
ctrl = 0
velset = 0,0

[State 175, 1] 
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

;----------------------------------------------------------------------------
;开场姿势
;----------------------------------------------------------------------------
[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

;----------------------------------------------------------------------------
;开场姿势
;----------------------------------------------------------------------------
[Statedef 191]
type = S
ctrl = 0

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

;----------------------------------------------------------------------------
;被击打
;----------------------------------------------------------------------------
[Statedef 5000]
type    = S
movetype= H
physics = N
velset = 0,0

[State 5001, 1]
type = varset
trigger1 = 1
fvar(22) = 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+(ifelse(GetHitVar(yvel)<-11,1,0))+ifelse((GetHitVar(yvel)>-11 && GetHitVar(yvel)<0) && GetHitVar(groundtype)= 2,4,0)

[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))+(ifelse(GetHitVar(animtype)=4 && GetHitVar(yvel)<-11,4,0))+ifelse(GetHitVar(animtype)=5 && P2StateNo>=3000,5,0)

[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

;----------------------------------------------------------------------------
;被击打
;----------------------------------------------------------------------------
[Statedef 5001]
type    = S
movetype= H
physics = S

[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

[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

;----------------------------------------------------------------------------
;被击打
;----------------------------------------------------------------------------
[Statedef 5010]
type    = C
movetype= H
physics = N
velset = 0,0

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

[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

;----------------------------------------------------------------------------
;被击打
;----------------------------------------------------------------------------
[Statedef 5011]
type    = C
movetype= H
physics = C

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

[State 5011, 2]
type = ChangeAnim
trigger1 = AnimTime = 0
value = 5025 + GetHitVar(animtype)

[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

;----------------------------------------------------------------------------
;被击打
;----------------------------------------------------------------------------
[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) != [3,5]
value = ifelse((GetHitVar(airtype) = 1),5000,5010) + GetHitVar(animtype)

[State 5020, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
;value = 5030+(ifelse(GetHitVar(yvel)<-11,1,0))
value = ifelse(GetHitVar(yvel)<0,5030+(ifelse(GetHitVar(yvel)<-11,1,0)),5058)+ifelse((GetHitVar(yvel)>-11 && GetHitVar(yvel)<0) && GetHitVar(groundtype)= 2,4,0)

[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))+(ifelse(GetHitVar(animtype)=4 && GetHitVar(yvel)<-11,4,0))+ifelse(GetHitVar(animtype)=5 && P2StateNo>=3000,5,0)

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

[State 5020, 6]
type = varset
trigger1 = ((P2StateNo = [200,249]) || (P2StateNo = [400,439]) || (P2StateNo = [600,649])) && time = 0; && movecontact = 1
var(6) = 1

[State 5020, 6]
type = ChangeState
trigger1 = RoundState = 2
trigger1 = HitShakeOver && var(6) = 1
value = 5040

[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

;----------------------------------------------------------------------------
[Statedef 5030]
type    = A
movetype= H
physics = N
ctrl = 0

[State 5030, 4]
type = varset
trigger1 = anim = 5058
fvar(36) = 1

[State 5030, 4]
type = varset
trigger1 = anim != 5058
fvar(36) = 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 = ChangeState
triggerall = !HitFall
trigger1 = HitOver
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= 10  ;.
value = 5040 ;HITA_RECOV

[State 5030, 4]
type = ChangeState
triggerall = HitFall
triggerall = AnimTime = 0
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)

[State 5030, 6]
type = ChangeState
trigger1 = Pos Y >= 0 && Vel Y > 0 
value = 5100 ;HIT_BOUNCE

;----------------------------------------------------------------------------
[Statedef 5035]
type    = A
movetype= H
physics = N

[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

;----------------------------------------------------------------------------
[Statedef 5040]
type    = A
movetype= H
physics = N

[State 5040, 1]
type = varset
trigger1 = time = 0
var(6) = 0

[State 5040,0]
type = NotHitBy
trigger1 = 1
value = SCA

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

[State 5040, 2]
type = ChangeAnim
trigger1 = AnimTime = 0
trigger1 = Anim != 5040
trigger2 = Time = 0
trigger2 = Anim != 5035
value = 5040

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

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

[State 5040, 2]
type = VelSet
trigger1 = Time = 0
x = ifelse(P2Dist x >= 0,-3.84,3.84)
y = -7.3

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

[State 5040, 6]
type = ChangeState
trigger1 = Pos Y >= -14 && Vel Y > 0
value = 5045 ;JUMPLAND

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

[State 5045,0]
type = NotHitBy
trigger1 = 1
value = SCA

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

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

;Play sound when landing
[State 5045, 3]
type = PlaySnd
trigger1 = Time = 0
value = 1,5

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

;----------------------------------------------------------------------------
[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+(ifelse(anim = 5031,6,0))+ifelse((GetHitVar(yvel)>-11 && GetHitVar(yvel)<0) && GetHitVar(groundtype)= 2,4,0)

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

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

[State 5050, ChangeState]
type = varset
trigger1 = time = 0
var(6) = 0
ignorehitpause = 1

[State 5050, ChangeState]
type = varset
triggerall = alive && Vel Y > 0 && Pos Y >= -40
triggerall = CanRecover
trigger1 = (var(26) = [900,905]) || command = "900" || Command = "recovery"
var(6) = 1
ignorehitpause = 1

[State 5050, ChangeState]
type = SelfState
trigger1 = Pos Y >= -14 && Vel Y > 0
triggerall = GetHitVar(yvel) < -1
trigger1 = var(6) = 1
value = 5200

[State 5050, 6]
type = ChangeState
trigger1 = Pos Y >= -14 && Vel Y > 0
value = 5100 ;HIT_BOUNCE

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

[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

;----------------------------------------------------------------------------
[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 5050, ChangeState]
type = varset
trigger1 = time = 0
var(6) = 0
ignorehitpause = 1

[State 5050, ChangeState]
type = varset
triggerall = alive && Vel Y > 0 && Pos Y >= -40
triggerall = CanRecover
trigger1 = (var(26) = [900,905]) || command = "900" || Command = "recovery"
var(6) = 1
ignorehitpause = 1

[State 5050, ChangeState]
type = SelfState
trigger1 = Pos Y >= -14 && Vel Y > 0
trigger1 = var(6) = 1
value = 5200

[State 5050, 6]
type = ChangeState
trigger1 = Pos Y >= -14 && Vel Y > 0
value = 5100 ;HIT_BOUNCE

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

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

;----------------------------------------------------------------------------
[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 +ifelse(anim = 5065||anim = 5067,(anim % 2),0)+ifelse(anim = 5058 && P2stateno < 2999,4,ifelse(anim = 5058 && P2stateno > 2999,1,0))+ifelse(anim = 5976,3,0)

[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 != 5062 && anim != 5054) && 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

;----------------------------------------------------------------------------
[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 +ifelse(anim = 5103,816,0)

[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 = velset
triggerall = fvar(36) = 1
trigger1 = Time = 0
x = -1.5
y = -7.2

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

[State 5101, 6]
type = ChangeState
trigger1 = Pos Y >= -8 && Vel Y > 0
value = 5110

;----------------------------------------------------------------------------
[Statedef 5110]
type    = L
movetype= H
physics = N

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

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

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

[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, 4]
type = velSet
trigger1 = 1
x = 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

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

[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 = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

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

[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 5200]
type    = A
movetype= H
physics = N

[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

;----------------------------------------------------------------------------
[Statedef 5201]
type    = A
movetype= H
physics = A
anim = 5200

[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

[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

;----------------------------------------------------------------------------
[Statedef 5210]
type    = A
movetype= I
physics = N
anim = 5210
ctrl = 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 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

;----------------------------------------------------------------------------
[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, 3] ;Intro for round 1
type = ChangeState
trigger1 = roundno = 1
value = 190
