;---------------------------------------------------------------------------
; 立ち
[Statedef 0]
type = S
physics = S
sprpriority = 0

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

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

[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]
Type = VarSet
Trigger1 = 1
V = 3
Value = 0

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

;---------------------------------------------------------------------------
; 着地
[Statedef 52]
type    = S
physics = S
ctrl = 0
anim = 47

[State -1]
Type     = Turn
Trigger1 = P2Dist X < 0

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

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

[State 52, 3]
Type = VarSet
Trigger1 = 1
V = 3
Value = 0

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

[State 52, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
;---------------------------------------------------------------------------
; 前?ッシュ
[Statedef 100]
type    = S
physics = S
anim = 100
Ctrl = 0


[State 100, 1]
type = VelSet
trigger1 = time = 0
x = 0

[State 100, 2]
type = VelSet
trigger1 = time >= 15
x = const(velocity.run.fwd.x)

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

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

[State 100, 5]
type = ChangeState
trigger1 = time >= 25
trigger1 = command != "holdfwd"
trigger2 = time >= 60
value = 101

[State -1]
Type     = PlaySnd
Trigger1 = Time = 12
Value    = s2, 0
Channel  = 6

[State -1]
Type        = AfterImage
Trigger1    = Time = 15
Time        = 60
Trans       = Add
Length      = 20
TimeGap     = 1
FrameFap    = 1
PalBright   = 0  , 0  , 0
PalContrast = 0  , 0  , 150
PalAdd      = 0  , 0  , 0
PalMul      = .5 , .5 , .5
Peresistent = 1

[State -1]
Type        = Helper
Trigger1    = Time = 15
Stateno     = 7002
ID          = 7002
Pos         = 10,-40
PosType     = P1
Ownpal      = 1
Keyctrl     = 0

[State 100]
type = reversaldef
trigger1 = enemy,ishelper
reversal.attr = SCA, AA, AT, AP
priority = 7, hit
pausetime = 0, 0
HitFlag = MAFDP
p2stateno = 7042

;---------------------------------------------------------------------------
; 前?ッシュ終了
[Statedef 101]
type    = S
physics = C
anim = 101
Ctrl = 1

[State -1]
Type     = AfterImageTime
Trigger1 = Time = 0
Time     = 0

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

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

[State 101, 4]
type = ChangeState
trigger1 = animtime = 0
value = 0
Ctrl = 1

;---------------------------------------------------------------------------
; バクステ
[Statedef 105]
type    = A
physics = S
ctrl = 0
anim = 105

[State -1]
Type     = StateTypeSet
Trigger1 = Time = 4
Type     = A
Physics  = N

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

[State -1]
Type     = VelAdd
Trigger1 = Time >= 2
Y        = 0.4

[State 105, 3]
type = ChangeState
Trigger1 = Time >= 6
trigger1 = Pos Y >= 0
value = 106

[State -1]
Type     = PlaySnd
Trigger1 = Time = 4
Value    = s2, 0
Channel  = 6

[State -1]
Type        = AfterImage
Trigger1    = Time = 2
Time        = 18
Trans       = Add
Length      = 20
TimeGap     = 1
FrameFap    = 1
PalBright   = 0  , 0  , 0
PalContrast = 0  , 0  , 150
PalAdd      = 0  , 0  , 0
PalMul      = .5 , .5 , .5
Peresistent = 1

[State -1]
Type        = Helper
Trigger1    = Time = 4
Stateno     = 7002
ID          = 7002
Pos         = -10,-40
PosType     = P1
Ownpal      = 1
Keyctrl     = 0
Facing      = -1

;---------------------------------------------------------------------------
; バクステ終了
[Statedef 106]
type    = S
physics = S
ctrl = 0
anim = 106

[State -1]
Type     = AfterImageTime
Trigger1 = Time = 0
Time     = 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, 4]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; 空中?ッシュ
[Statedef 110]
type    = A
physics = N
VelSet = 0,0
Anim = 110
Ctrl = 0

[State 110, 1]
type = VelSet
trigger1 = time >= 15
x = const(velocity.run.fwd.x)

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

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

[State 110, 4]
type = ChangeState
trigger1 = time >= 25
trigger1 = command != "holdfwd"
trigger2 = time >= 60
value = 111

[State -1]
Type     = PlaySnd
Trigger1 = Time = 12
Value    = s2, 0
Channel  = 6

[State -1]
Type        = AfterImage
Trigger1    = Time = 15
Time        = 60
Trans       = Add
Length      = 20
TimeGap     = 1
FrameFap    = 1
PalBright   = 0  , 0  , 0
PalContrast = 0  , 0  , 150
PalAdd      = 0  , 0  , 0
PalMul      = .5 , .5 , .5
Peresistent = 1

[State -1]
Type        = Helper
Trigger1    = Time = 15
Stateno     = 7002
ID          = 7002
Pos         = 10,-40
PosType     = P1
Ownpal      = 1
Keyctrl     = 0

[State 110]
type = reversaldef
trigger1 = enemy,ishelper
reversal.attr = SCA, AA, AT, AP
priority = 7, hit
pausetime = 0, 0
HitFlag = MAFDP
p2stateno = 7042

;---------------------------------------------------------------------------
; 空中?ッシュ終了
[Statedef 111]
type    = U
physics = A
anim = 111
Ctrl = 1

[State -1]
Type     = AfterImageTime
Trigger1 = Time = 0
Time     = 0

[State 111, 1]
type = VarAdd
trigger1 = Time = 0
v = 3
value = -1

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

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

[State 111, 4]
type = ChangeState
trigger1 = animtime = 0
value = 0
Ctrl = 1

;---------------------------------------------------------------------------
;?ッシュエフェクト
[StateDef 7002]
Type        = A
Physics     = N
Anim        = 9999
SprPriority = 8
VelSet      = 0,0

[State -1]
Type        = Explod
Trigger1    = Time = 0
Anim        = 7002
ID          = 7002
PosType     = P1
Pos         = 0,0
OwnPal      = 0
Scale       = 0.4,0.4
ReMoveTime  = 12
SprPriority = 8
Vel         = -1

[State -1]
Type        = Explod
Trigger1    = Time = 0
Anim        = 7003
ID          = 7002
PosType     = P1
Pos         = 0,0
OwnPal      = 0
Scale       = 0.4,0.4
ReMoveTime  = 12
SprPriority = -5
Vel         = -1

[State -1]
Type     = VarAdd
Trigger1 = 1
V        = 4
Value    = 36

[State -1]
Type     = VarAdd
Trigger1 = 1
V        = 12
Value    = 21

[State -1]
Type     = PalFx
Trigger1 = 1
Time     = 1
Add      = 0,0,0
Mul      = 256-Var(4),256-Var(4),256-Var(12)

[State -1]
Type     = VarAdd
Trigger1 = 1
FV       = 1
Value    = 0.05+FVar(2)

[State -1]
Type     = VarAdd
Trigger1 = 1
FV       = 2
Value    = -0.002

[State -1]
Type     = ModifyExplod
Trigger1 = 1
ID       = 7002
Scale    = 0.4+FVar(1) , 0.4+FVar(1)

[State -1]
Type     = DestroySelf
Trigger1 = Time = 12

;---------------------------------------------------------------------------
; ?ウン1
[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 = Null;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 = Null;PlaySnd
trigger1 = Time = 1
value = s2,2;F7, (sysvar(1) > 5) + (sysvar(1) > 14)

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

[State 5100, 12]
type = ChangeState
trigger1 = AnimTime = 0
value = 5110;01

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

;---------------------------------------------------------------------------
; ?ウン2
[Statedef 5110]
type    = L
movetype= H
physics = N

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

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

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

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

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

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

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

[State 5110, 6]
type = PlaySnd
trigger1 = Time = 0
trigger1 = !SysVar(0)
value = s2,2;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