;--------------------------------------------------------------
; Grabbed
[Statedef 50801]
type = S
physics = N
movetype = H
ctrl = 0
velset = 0,0
sprpriority = 1

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

[State 50801, ChangeAnim2]
type = ChangeAnim2
trigger1 = !Time
value = StateNo
elem = 1

;--------------------------------------------------------------
; Thrown
[Statedef 50802]
type = A
physics = N
movetype = H
ctrl = 0
velset = 3,0
poweradd = 150

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

[State 50802, VelAdd]
type = VelAdd
trigger1 = 1
y = 0.5

[State 50802, EnvShake]
type = EnvShake
trigger1 = Vel Y > 0 && Vel Y + Pos Y >= 0
time = 15
freq = 90
ampl = -4
phase = 180

[State 50802, ChangeState]
type = ChangeState
trigger1 = Vel Y > 0 && Vel Y + Pos Y >= 0
value = 55100

;--------------------------------------------------------------
; Grabbed
[Statedef 50811]
type = S
physics = N
movetype = H
ctrl = 0
velset = 0,0
sprpriority = 1

[State 50811, ChangeAnim2]
type = ChangeAnim2
trigger1 = !Time
value = StateNo
elem = 1

;--------------------------------------------------------------
; Thrown
[Statedef 50812]
type = S
physics = N
movetype = H
ctrl = 0
velset = -5, 7
poweradd = 150

[State 50812, VelAdd]
type = VelAdd
trigger1 = 1
y = 0.5

[State 50812, EnvShake]
type = EnvShake
trigger1 = Vel Y > 0 && Vel Y + Pos Y >= 0
time = 15
freq = 90
ampl = -4
phase = 180

[State 50812, ChangeState]
type = ChangeState
trigger1 = Vel Y > 0 && Vel Y + Pos Y >= 0
value = 55100

;---------------------------------------------------------------------------
; Wallbounce (till 53003)
[Statedef 53000]
type    = S
movetype= H
physics = N
velset = 0,0

[State 53000, Anim] ;Custom animation
type = ChangeAnim2
trigger1 = 1
value = 53000

[State 53000, State]
type = ChangeState
trigger1 = HitShakeOver = 1
value = 53001

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

[State 53001, Velocity]
type = VelSet
trigger1 = Time = 0
x = -12

[State 0, PosSet]
type = PosSet
trigger1 = !Time
y = -50

[State 53001, Gravity]
type = VelAdd
trigger1 = 1
y = .5

[State 53001, No scroll]
type = ScreenBound
triggerall = Pos y < -15
trigger1 = BackEdgeBodyDist < 65
trigger2 = FrontEdgeBodyDist < 65
value = 1
movecamera = 0,1

[State 53001, Hit wall]
type = ChangeState
triggerall = Pos Y < -15
trigger1 = BackEdgeBodyDist < 20
trigger2 = FrontEdgeBodyDist < 20
value = 53002

[State 53001, Hit ground]
type = ChangeState
trigger1 = (Vel y > 0) && (Pos y >= 0)
value = 55100

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

[State 53002, Turn]
type = Turn
trigger1 = (Time = 0) && (FrontEdgeBodyDist <= 30)

[State 53002, Pos]
type = PosAdd
trigger1 = Time = 0
x = 15 - BackEdgeBodyDist

[State 53002, Stop moving]
type = PosFreeze
trigger1 = 1
x = 1
y = 1

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

[State 53002, Spark]
type = Explod
trigger1 = Time = 0
anim = F70
pos = 0, floor (screenpos y) - 50
postype = back
sprpriority = 3
persistent = 0

[State 53002, Anim]
type = ChangeAnim2
trigger1 = Time = 0
value = 53002

[State 53002, Sound]
type = PlaySnd
trigger1 = Time = 0
value = F7,0

[State 53002, State]
type = ChangeState
trigger1 = AnimTime = 0
value = 53003

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

[State 53003, HitFallSet]
type = HitFallSet
trigger1 = !Time
value = 1

[State 53003, Vel Y]
type = VelSet
trigger1 = Time = 0
y = -10

[State 53003, Vel X]
type = VelSet
trigger1 = Time = 0
x = 0

[State 53003, Gravity]
type = VelAdd
trigger1 = 1
y = .4

[State 53003, Anim 5050] ;Self falling animation
type = ChangeAnim
trigger1 = Time = 0
trigger1 = !SelfAnimExist(5052)
value = 5050

[State 53003, Anim 5052] ;Self falling animation (diagup type)
type = ChangeAnim
trigger1 = Time = 0
trigger1 = SelfAnimExist(5052)
value = 5052

[State 53003, Anim 5060] ;Coming down - normal
type = ChangeAnim
trigger1 = Vel Y > -2
trigger1 = Anim = 5050
trigger1 = SelfAnimExist(5060)
persistent = 0
value = 5060

[State 53003, Anim 5062] ;Coming down - diagup type
type = ChangeAnim
trigger1 = Vel Y > -2
trigger1 = Anim = 5052
trigger1 = SelfAnimExist(5062)
persistent = 0
value = 5062

[State 53003, Hit ground]
type = ChangeState
trigger1 = (Vel y > 0) && (Pos y >= 0)
value = 55100

;--------------------------------------------------------------
; Grabbed
[Statedef 53010]
type = S
physics = N
movetype = H
ctrl = 0
velset = 0,0
sprpriority = 1

[State 53010, PosSet]
type = PosSet
trigger1 = 1
y = 0 

[State 53010, ChangeAnim2]
type = ChangeAnim2
trigger1 = !Time
value = StateNo
elem = 1

;--------------------------------------------------------------
; Thrown (MEoDP)
[Statedef 53011]
type = A
physics = N
movetype = H
ctrl = 0
velset = 0, -7
poweradd = 150

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

[State 53011, ChangeAnim2]
type = ChangeAnim2
trigger1 = !Time
value = StateNo
elem = 1

[State 53011, VelAdd]
type = VelAdd
trigger1 = 1
y = 0.4

[State 53011, ChangeState]
type = ChangeState
trigger1 = Vel Y > 0 && Vel Y + Pos Y >= 0
value = 55100

;--------------------------------------------------------------
; Thrown (MEoDP: Instant Death)
[Statedef 53016]
type = A
physics = N
movetype = H
ctrl = 0
velset = 0, -7
poweradd = -Power

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

[State 53016, ChangeAnim2]
type = ChangeAnim2
trigger1 = !Time
value = 53011
elem = 1

[State 53016, VelAdd]
type = VelAdd
trigger1 = 1
y = 0.4

[State 53016, ChangeState]
type = ChangeState
trigger1 = Vel Y > 0 && Vel Y + Pos Y >= 0
value = 55100

;--------------------------------------------------------------
; Grabbed
[Statedef 53021]
type = S
physics = N
movetype = H
ctrl = 0
sprpriority = 1
velset = 0,0

[State 53021, ChangeAnim2]
type = ChangeAnim2
trigger1 = !Time
value = StateNo
elem = 1

[State 53021, VelSet]
type = VelSet
trigger1 = Time = 258
y = -1

[State 53021, VelSet]
type = VelSet
trigger1 = Time = 327
y = 0

;--------------------------------------------------------------
; Thrown (17 Dissection)
[Statedef 53022]
type = A
physics = N
movetype = H
ctrl = 0
velset = 0, -10
poweradd = 150

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

[State 53022, ChangeAnim2]
type = ChangeAnim2
trigger1 = !Time
value = StateNo
elem = 1

[State 53022, VelAdd]
type = VelAdd
trigger1 = 1
y = 0.3

[State 53011, ChangeState]
type = ChangeState
trigger1 = Vel Y > 0 && Vel Y + Pos Y >= 0
value = 55100

;--------------------------------------------------------------
; Hit High Custom State
[Statedef 55000]
type = S
physics = N
movetype = H
ctrl = 0
velset = 0,0
anim = 5002

[State 55000, HitBy]
type = HitBy
trigger1 = 1
value = SCA,HA,HP

[State 55000, HitFallSet]
type = HitFallSet
trigger1 = 1
value = 0

[State 55000, PosSet]
type = posset
trigger1 = time = 0
y = 0

[State 55000, 2]
type = Velset
trigger1 = !gethitvar(isbound)
x = 0

[State 55000, ChangeAnim]
type = ChangeAnim
trigger1 = anim = 5002 && !animtime
value = 5007
persistent = 0

[State 55000, SelfState]
type = SelfState
trigger1 = time = 300
value = 0

;--------------------------------------------------------------
; Hit Low Custom State
[Statedef 55010]
type = S
physics = N
movetype = H
ctrl = 0
velset = 0,0
anim = 5012

[State 55010, HitBy]
type = HitBy
trigger1 = 1
value = SCA,HA,HP

[State 55010, HitFallSet]
type = HitFallSet
trigger1 = 1
value = 0

[State 55010, PosSet]
type = posset
trigger1 = time = 0
y = 0

[State 55010, 2]
type = Velset
trigger1 = !gethitvar(isbound)
x = 0

[State 55010, ChangeAnim]
type = ChangeAnim
trigger1 = anim = 5012 && !animtime
value = 5017
persistent = 0

[State 55010, SelfState]
type = SelfState
trigger1 = time = 300
value = 0

;---------------------------------------------------------------------------
; Stand Light Punch
; CNS difficulty: easy
[Statedef 55020]
type    = A
movetype= H
physics = N
velset = 0,0

[State 5020, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0 && selfanimexist(5061)
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 && selfanimexist(5061)
trigger1 = GetHitVar(animtype) = [3,5]
value = 5061

[State 5050, 1] ;Change anim when done with transition
type = ChangeAnim
trigger1 = AnimTime = 0 && !selfanimexist(5061)
value = 5050

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

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

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

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

[State 5030, 3]
type = ChangeState
triggerall = !HitFall
trigger1 = HitOver && (gethitvar(hittime)<time) 
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= 10  ;.
value = 5040 ;HITA_RECOV

[State 5030, 4]
type = selfState
triggerall = HitFall
trigger1 = HitOver&& (gethitvar(hittime)<time) 
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= 10  ;.
value = 5050 ;HITA_FALL

[State 0, SelfState]
type = SelfState
triggerall =canrecover && HitOver&& (gethitvar(hittime)<time); && enemy,var(22)=0 
trigger1 = command="recovery"
value = 5200
;ctrl =
;ignorehitpause = 0
;persistent = 1

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

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

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

[State 5035, 2]
type = VelAdd
trigger1 = time>0
y = GetHitVar(yaccel)

[State 5035, 3]
type = selfState
triggerall = !HitFall
trigger1 = HitOver  && (gethitvar(hittime)<time) 
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= 10  ;.
trigger3 = Time = 0     ;No transition anim
trigger3 = Anim != 5061 ;.
value = 5040 ;HITA_RECOV

[State 5035, 4]
type=selfState
triggerall = HitFall
trigger1 = HitOver && (gethitvar(hittime)<time) 
trigger2 = Vel Y > 0    ;Hit ground
trigger3 = Pos Y >= 10  ;.
trigger4 = Time = 0     ;No transition anim
trigger5 = Anim != 5061 ;.
value = 5050 ;HITA_FALL

[State 5035, 4]
type=selfState
triggerall = HitFall
trigger1 = HitOver && (gethitvar(hittime)<time) 
trigger2 = Vel Y > 0    ;Hit ground
trigger3 = Pos Y >= 10  ;.
trigger4 = Time = 0     ;No transition anim
trigger5 = Anim = 5061 ;.
value = 5050 ;HITA_FALL

[State 0, SelfState]
type = SelfState
triggerall =canrecover && HitOver&& (gethitvar(hittime)<time); && enemy,var(22)=0 
trigger1 = command="recovery"
value = 5200

;---------------------------------------------------------------------------
; Air get-hit (falling)
[Statedef 55050]
type    = A
movetype= H
physics = N
anim = 5050

[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, Const720p(4), Const720p(-8))
trigger1 = SelfAnimExist(anim+10)
value = anim+10
persistent = 0

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

[State 5050, 4]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= ifelse((anim = [5051,5059]) || (anim = [5061,5069]), 0, Const(movement.air.gethit.groundlevel))
value = 55100 ;Downed get-hit (hit ground from fall)

;---------------------------------------------------------------------------
; Downed get-hit (hit ground from fall)
[Statedef 55100]
type    = A
movetype= H
physics = N

[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
value = 55110 ;Downed get-hit (lying down)

[State 5100, 8]
type = Explod
trigger1 = Time = 1
anim = F(60 + (sysvar(1) > Const720p(20)) + (sysvar(1) > Const720p(56)))
pos = 0, 0
sprpriority = ifelse (sysvar(1) <= Const720p(56), -10, 10)

[State 5100, 9]
type = HitFallDamage
trigger1 = Time = 3

[State 5100, 10]
type = PlaySnd
trigger1 = Time = 1
value = F7, (sysvar(1) > Const720p(20)) + (sysvar(1) > Const720p(56))

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

[State 5100, 12]
type = ChangeState
trigger1 = AnimTime = 0
value = 55101 ;Downed get-hit (bounce off ground)

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

;---------------------------------------------------------------------------
; Downed get-hit (bounce off ground)
[Statedef 55101]
type    = A
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 = Const(movement.down.bounce.offset.y)

[State 5101, 5]
type = PosAdd
trigger1 = Time = 0
x = Const(movement.down.bounce.offset.x)

[State 5101, 6] ;Acceleration
type = VelAdd
trigger1 = 1
y = Const(movement.down.bounce.yaccel)

[State 5101, 7] ;Hit ground
triggerall = Enemy, StateNo = 221
trigger1 = !Time
type = ChangeState
value = 55100

[State 5101, 8] ;Hit ground
trigger1 = Vel Y > 0 && Vel Y + Pos Y >= 0
type = SelfState
value = 5110

;---------------------------------------------------------------------------
; Downed get-hit (lying down)
[Statedef 55110]
type    = L
movetype= H
physics = N

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

[State 55110, 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 55110, 2] ;Hit ground anim (normal)
type = ChangeAnim
triggerall = time = 0
trigger1 = Anim = 5060
value = 5170

[State 55110, 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(5171)
value = 5171

[State 55110, 2] ;Hit ground anim (trip)
type = ChangeAnim
triggerall = !Time
trigger1 = anim = 5070
value = 5171
elem = 5

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

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

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

[State 55110, 6]
type = PlaySnd
trigger1 = Time = 0
trigger1 = !SysVar(0)
value = F7, (sysvar(1) > Const720p(20)) + (sysvar(1) > Const720p(56))

;[State 55110, 7]
;type = Null
;trigger1 = Time = 0
;trigger1 = !SysVar(0)
;anim = F(60 + (sysvar(1) > Const720p(20)) + (sysvar(1) > Const720p(56)))
;pos = 0, 0
;sprpriority = ifelse (sysvar(1) <= Const720p(56), -10, 10)

[State 55110, 8]
type = VelSet
trigger1 = Time = 0
y = 0

[State 55110, 9] ;For hit up type
type = ChangeAnim
persistent = 0
triggerall = (anim = [5171,5179]) || (Anim = [5101,5102])
trigger1 = AnimTime = 0
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground anim
value = 5111

[State 55110, 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 55110, 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 55110, 12]
type = VarSet
trigger1 = SysVar(0)
trigger1 = Time = 0
sysvar(0) = 0

[State 55110, 13] ;Friction
type = VelMul
trigger1 = 1
x = 0.85

[State 55110, 14] ;Friction
type = VelSet
trigger1 = abs(Vel x) < Const(movement.down.friction.threshold)
persistent = 0
x = 0

[State 55110, 15]
type = ForceFeedback
trigger1 = alive
trigger1 = Time = 0
time = 8
ampl = 240
waveform = sine

[State 55110, 16]
type = ForceFeedback
trigger1 = !alive
trigger1 = Time = 0
ampl = 200, 7, -.467
time = 30
waveform = sine

[State 55110, ChangeState]
type = SelfState
trigger1 = Time = 30
value = 5120
ctrl = 0