; Stand
[Statedef 2051]
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, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow

[State 0, Trans]
type = Trans
trigger1 = 1
trans = add

[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
time = 1
;*********************************
[State 0, turn]
type = ChangeState
trigger1 = rootdist x = [-10,10]
trigger1 = facing != parent,facing
value = 2056

[State 0, walk]
type = ChangeState
trigger1 = rootdist x != [-10,10]
value = 2071

[State 0, StandtoCrouch]
type = ChangeState
trigger1 = rootdist x = [-10,10]
trigger1 = root,stateno = 11
value = 2061

[State 0, 4]
type = null;ChangeState
trigger1 = parent,var(8) % 10 = 6
trigger1 = (parent,var(8)/10) != 0 && (parent,var(8)/10) != 20
trigger1 = rootdist x = [-10,10]
value = (parent,var(8)/10) + 2051
;-------------------------------------------------------------
[Statedef 2056];turn
anim = 5
type = S
physics = S

[State 0, Turn]
type = Turn
trigger1 = time = 0

[State 0, ChangeState]
type = ChangeState
trigger1 = time = 1
value = 2051
;---------------------------------------------------------------------------
; Stand to Crouch
[Statedef 2061]
type    = C
physics = C
anim = 10

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow

[State 0, Trans]
type = Trans
trigger1 = 1
trans = add

[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
time = 1

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

;***************************
[State 10, 2]
type = ChangeState
trigger1 = AnimTime = 0
value = 2062
;---------------------------------------------------------------------------
; Crouching
[Statedef 2062]
type    = C
physics = C
anim = 11
sprpriority = 0

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow

[State 0, Trans]
type = Trans
trigger1 = 1
trans = add

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

[State 0, 4]
type = ChangeState
trigger1 = parent,var(8) % 10 = 6
trigger1 = (parent,var(8)/10) != 11
value = (parent,var(8)/10) + 2051
;---------------------------------------------------------------------------
; Crouch to Stand
[Statedef 2063]
type    = S
physics = S
anim = 12

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow

[State 0, Trans]
type = Trans
trigger1 = 1
trans = add

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

[State 0, 4]
type = ChangeState
trigger1 = parent,var(8) % 10 = 6
trigger1 = (parent,var(8)/10) != 12
value = (parent,var(8)/10) + 2051
;---------------------------------------------------------------------------
; Walk
[Statedef 2071]
type    = S
physics = N
sprpriority = 0

[State 20, 1]
type = VelSet
trigger1 = rootdist x > 0
x = const(velocity.walk.fwd.x)

[State 20, 2]
type = VelSet
trigger1 = rootdist x < 0
x = const(velocity.walk.back.x)

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

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

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow

[State 0, Trans]
type = Trans
trigger1 = 1
trans = add
;**********************************
[State 0, 4]
type = ChangeState
trigger1 = rootdist x = 0
value = 2051
;---------------------------------------------------------------------------
; Jump Start
[Statedef 2091]
type    = S
physics = S
anim = 40
sprpriority = 1

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

[State 40, 2]
type = VarSet
trigger1 = parent,sysvar(1) != 0
sysvar(1) = root,sysvar(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 = 2151 ;RUN_FWD
trigger1 = sysvar(1) = 1
x = const(velocity.runjump.fwd.x)

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 2101
;---------------------------------------------------------------------------
; AirJump Start
[Statedef 2096]
type    = A
physics = N
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 0, VarAdd]
type = VarAdd
trigger1 = time = 0
v = 1
value = 10

[State 45, 4]
type = VarSet
trigger1 = 1
sysvar(1) = parent,sysvar(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 = 2101
;---------------------------------------------------------------------------
; Jump Up
[Statedef 2101]
type    = A
physics = N

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

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

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

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

[State 0, ChangeState]
type = ChangeState
trigger1 = vel y >0 && pos y >= 0
value = 2103
;---------------------------------------------------------------------------
; Jump Down (empty state for compatibility)
[Statedef 2102]
type    = A
physics = A

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

;---------------------------------------------------------------------------
; Jump Land
[Statedef 2103]
type    = S
physics = S
ctrl = 0
anim = 47

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

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

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

[State 52, 4]
type = ChangeState
trigger1 = AnimTime = 0
value = 2051
;---------------------------------------------------------------------------
; RUN_FWD
[Statedef 2151]
type    = S
physics = S
anim = 100
sprpriority = 1

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

[State 100, Helper]
type = Helper
trigger1 = Time = 1
ID = 6102
stateno = 6102
pos = 70,-45
postype = p1
keyctrl = 0
ownpal = 0
supermove = 9999
pausemove = 9999

[State 0, PlaySnd]
type = PlaySnd
trigger1 = Time = 1
value = S3,1
channel = 6
volume = 256

[State 0, Explod]
type = Explod
trigger1 = Time = 1
anim = 6100
ID = 6100
pos = 35,-45
postype = p1
supermove = 9999
pausemove = 9999
scale = 1,1
sprpriority = 8
ownpal = 0

[State 0, Explod]
type = Explod
trigger1 = Time >= 11
anim = 6101
ID = 6101
pos = -10,-60+random%60
postype = p1
vel = -4,0
supermove =9999
pausemove =9999
sprpriority = 8
ownpal = 0
persistent = 15

[State 0, AfterImage]
type = AfterImage
trigger1 = 1
time = 4
length = 20
palbright = 0,0,0
palcontrast = 0,0,150
paladd = 0,0,0
palmul = .5,.5,.5
trans = Add

[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 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = ,AP
time = 1

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

;-------------------------------------------------
[Statedef 2152]
Type = S
Physics = S
Anim  = 101
Ctrl = 0

[State 0, VelMul]
type = VelMul
trigger1 = 1
x = .9

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = NoWalk
flag2 = NoAutoturn

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

[State 0, ChangeState]
type = ChangeState
trigger1 = command = "holdback"
trigger1 = InGuardDist
value = 120

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

[State 105, NotHitBy]
type = NotHitBy
trigger1 = time = 0
value = SCA
time = 13

[State 105, AfterImage]
type = AfterImage
trigger1 = Time = 1
trans = add
time = 2
length = 10
palbright = 0,0,0
palcontrast = 0,0,150
paladd = 0,0,0
palmul = .5,.5,.5

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

[State 105, PlaySnd]
type = PlaySnd
trigger1 = time = 2
value = S3,1
volume = 256

[State 0, Helper]
type = Helper
trigger1 = AnimElemTime(2) = 1
helpertype = normal
ID = 6102
stateno = 6102
pos = -30,-50
postype = p1    ;p2,front,back,left,right
facing = -1
keyctrl = 0
ownpal = 0
supermove = 9999
pausemove = 9999

[State 0, Explod]
type = Explod
trigger1 = AnimElemTime(2) = 1
anim = 6100
ID = 6100
pos = 40,-40
postype = p1
facing = -1
supermove = 9999
pausemove = 9999
sprpriority = 8
ownpal = 0

[State 0, Explod]
type = Explod
trigger1 = AnimElemTime(2) >= 1
anim = 6101
ID = 6101
pos = 10,-60+Random%2
postype = p1
vel = 4,0
supermove = 9999
pausemove = 9999
sprpriority = 8
ownpal = 0
persistent = 15

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

[State 105, 3]
type = ChangeState
trigger1 = time > 13
trigger1 = command = "holdback"
trigger1 = InGuardDist
value = 120

;---------------------------------------------------------------------------
; RUN_BACK2 (land)
[Statedef 2157]
type    = S
physics = S
ctrl = 0
anim = 47

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

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

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

[State 105, 3]
type = ChangeState
trigger1 = time > 13
trigger1 = command = "holdback"
trigger1 = InGuardDist
value = 120
