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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

[State 0, VarSet]
type = VarSet
trigger1 = !time
v = 29    ;fv = 10
value = 1000

[State 50000, 4]
type = HitOverride
triggerall = stateno != 52222
trigger1 = Time = 0
attr = SCA, NT, ST, HT, NA, SA, HA,NP,SP,HP
stateno = 52222
time = -1

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

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

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

[State 0, HitOverride]
type = HitOverride
trigger1 = time = 0
attr = SCA, NT, ST, HT, NA, SA, HA,NP,SP,HP
stateno = 16010
time = -1

[State 50000, Turn]
type = Turn
trigger1 = p2bodydist x <=-20

[State 50000, 4]
type = ChangeState
trigger1 = P2BodyDist x >=120 & stateno != 50020 & time >=1 & random <= 900
value = 50020


[State 50000, 4]
type = ChangeState
trigger1 = random <= 500 & time >= 1 & p2bodydist x <= 100
value = 50200

[State 0, Die when lose]
type = Changestate
trigger1 = parent, life = 0
value = 16010

[State 0, Die when win]
type = Changestate
trigger1 = p2life = 0 && Numenemy = 0
value = 16010

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

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

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

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

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


[State 20000, 4]
type = ChangeState
trigger1 = random <= 300
value = 50012

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

[State 12, 1]
type = ChangeState
trigger1 = AnimTime = 0
value = 50000
;----------------------------------------------------------------------
; Walk
[Statedef 50020]
type    = S
physics = S
sprpriority = 0

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

[State 50020, 1]
type = VelSet
trigger1 = time >= 30 & random <= 300 & p2bodydist x >= 100
x = 7

[State 50020, 1]
type = VelSet
trigger1 = time >= 30 & random <= 200 & p2bodydist x <=100
x = -7

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

[State 50020, 4]
type = ChangeAnim
triggerall = vel x < 0
trigger1 = Anim != 50021 && Anim != 50005
trigger2 = Anim = 50005 && AnimTime = 0
value = 50021


[State 50000, 4]
type = ChangeState
trigger1 = time >= 80
value = 50000

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

[State 40, 1]
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 = 50050
ctrl = 1

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

[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 = stateno = 10052
var(13) = 1

[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 = 50050
ctrl = 1

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

[State 45, 3]
type = VarSet
trigger1 = stateno = 10052
var(13) = 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

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

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

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

[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 = 50000
ctrl = 1

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

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

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

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

[State 20100, 4]
type = ChangeState
trigger1 = random <= 700
value = 50000

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

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

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

[State 105, 3]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 50106

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

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

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

[State 106, 3]
type = MakeDust
trigger1 = Time = 2
pos = -5,-2
spacing = 1

[State 106, 4]
type = ChangeState
trigger1 = Time = 1
value = 50000
ctrl = 1

;------------------------------------------------------------------------
[StateDef 50200]
type = A
movetype= A
physics = S
juggle  = 1
velset = 0,0
ctrl = 0
anim = 50200
poweradd = -100
sprpriority = 2

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

[State 200,***]
type = AssertSpecial
trigger1 =1
flag = noautoturn

[State 200, 1]
type = HitDef
trigger1 = time = 0
attr = S, NA
damage = 13
animtype = Light
guardflag = MA
hitflag = MAF
priority = 3, Hit
pausetime = 0, 10
sparkno = s10500
sparkxy = 31, -60
hitsound = s200, 2
guardsound = 6, 0
ground.type = High
ground.slidetime = 5
ground.hittime  = 12
ground.velocity = -7
airguard.velocity = -1.9,-.8
air.type = High
air.velocity = -1.4,-3
air.hittime = 12
fall = 1

[state 3]
type = helper
trigger1 = animelem = 6
helpertype = normal
id = 52224
postype = p1
pos = 0, 0
stateno = 52224
ontop = 1
bindtime = -1
removetime = -2

[State 200, end]
type = ChangeState
trigger1 = AnimTime = 0
value = 50000
ctrl = 1

;-----------------------------------------------------------------------
[StateDef 52224]
type = A
movetype= A
physics = S
juggle  = 1
velset = 0,0
ctrl = 0
anim = 52224
poweradd = 0
sprpriority = 2

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

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 0

[State 200,***]
type = AssertSpecial
trigger1 =1
flag = noautoturn

[State 200, 1]
type = HitDef
trigger1 = time = 1
attr = S, NA
damage = 13
animtype = Light
guardflag = MA
hitflag = MAF
priority = 3, Hit
pausetime = 0, 10
sparkno = s10500
sparkxy = 31, -60
hitsound = s200, 2
guardsound = 6, 0
ground.type = High
ground.slidetime = 5
ground.hittime  = 12
ground.velocity = -7
airguard.velocity = -1.9,-.8
air.type = High
air.velocity = -1.4,-3
air.hittime = 12
fall = 1
palfx.time = 40
palfx.mul	= 180,0,180
palfx.add	= 180,0,180
palfx.sinadd = 255,100,0,4

[State 3000]
type = destroyself
trigger1 = movecontact
trigger2 = time = 75
value = 0
ctrl = 1

;-----------------------------------------------------------------------
[StateDef 16010]
type = S
movetype= A
physics = S
juggle  = 1
velset = 0,0
ctrl = 0
anim = 52223
poweradd = 0
sprpriority = 2

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

[State 0, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 1
movecamera = 0,0

[State 0, VarAdd]
type = VarAdd
trigger1 = !time
v = 29    ;fv =
value = -gethitvar(damage)

[State 0, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

[State 15008, end]
type = changestate
trigger1 = time = 12
value = Ifelse(var(29) <= 0,52222,50000)
ctrl = 1

;-----------------------------------------------------------------------
;dead
[Statedef 52222]
type    = S
movetype= A
physics = S
juggle  = 1
velset = 0,0
ctrl = 0
anim = 52222
poweradd = 0
sprpriority = 2

[State 1000,***]
type = AssertSpecial
trigger1 =1
flag = noautoturn

[State 6003, DestroySelf]
type = DestroySelf
trigger1 =animtime = 0
