;---------------------------------------------------------------------------
; Wake Up Jump
;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; Wake Up Jump Forward
[Statedef 850]
type    = A
physics = N
ctrl = 0
anim = 100
sprpriority = 0

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

[State 850, Lock Anim]
type = ChangeAnim
trigger1 = 1
value = 100

[State 850, Pass Through]
type = PlayerPush
trigger1 = Vel Y <= 0
trigger2 = Pos Y < 0
value = 0

[State 850, Sound]
type = PlaySnd
trigger1 = time = 0
trigger1 = SelfAnimExist(66167100)
value = 10,12
channel = 0

[State 850, 1]
type = VelSet
trigger1 = Time = 0
x = 8.0
y = -3

[State 850, Gravity]
type = VelAdd
trigger1 = 1
y = 0.3125

[State 850, BOFS Pass Through]
type = PlayerPush
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 1

[State 850, BOFS 1] ; Implement this in wake up jump some time.
type = ScreenBound
triggerall = Vel Y > 0
triggerall = Pos Y >= 0
trigger1 = 1
value = 0
movecamera = 1,1

[State 850, BOFS 2]
type = PosAdd
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
trigger1 = pos x = enemynear, pos x
trigger1 = abs(pos x) = 145
trigger2 = abs(pos x) > 145
x = 1;facing * 146

[State 850, BOFS 3]
type = PosAdd
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
trigger1 = pos x = enemynear, pos x
x = 1;facing

[State 850, 3]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 851

;---------------------------------------------------------------------------
; Wake Up Jump Forward 2 (land)
[Statedef 851]
type    = S
physics = S
ctrl = 0
anim = 47
sprpriority = 1

[State 851, Landing Sound]
type = PlaySnd
trigger1 = time = 0
trigger1 = SelfAnimExist(66167100)
value = 9,3

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

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

;[State 853, 3]
;type = MakeDust
;trigger1 = Time = 2
;trigger1 = !SelfAnimExist(66167100)
;pos = -5,-2
;spacing = 1

[State 851, Dust1]
type = Explod
trigger1 = time = 0
trigger1 = SelfAnimExist(66167100)
anim = 949
ID = 949
pos = -28 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 0, -(((random%11)-5) / 20.0 + 1)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 851, Dust2]
type = Explod
trigger1 = time = 0
trigger1 = SelfAnimExist(66167100)
anim = 949
ID = 949
pos = -14 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 0, -(((random%11)-5) / 20.0 + 1)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 851, Dust3]
type = Explod
trigger1 = time = 0
trigger1 = SelfAnimExist(66167100)
anim = 949
ID = 949
pos = (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 0, -(((random%11)-5) / 20.0 + 1)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 851, Dust4]
type = Explod
trigger1 = time = 0
trigger1 = SelfAnimExist(66167100)
anim = 949
ID = 949
pos = 14 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 0, -(((random%11)-5) / 20.0 + 1)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 851, Dust5]
type = Explod
trigger1 = time = 0
trigger1 = SelfAnimExist(66167100)
anim = 949
ID = 949
pos = 28 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 0, -(((random%11)-5) / 20.0 + 1)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

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

[State 851, 3]
type = NotHitBy
trigger1 = time = 7
value2 = SCA
time = 2

[State 851, 4]
type = SelfState
trigger1 = Time = 7
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Wake Up Jump Back
[Statedef 852]
type    = A
physics = N
ctrl = 0
anim = 100
sprpriority = 0

[State 852, Turn]
type = Turn
trigger1 = 1

[State 852, 4]
type = ChangeState
trigger1 = 1
value = 850

;---------------------------------------------------------------------------
; AI Air Dash Back Turn
[Statedef 859]
type    = A
physics = N
ctrl = 0
anim = 855
velset = 0,0
sprpriority = 2
;sysvar(1) = -1

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

[State 859, Cancel to Guard]
type = ChangeState
trigger1 = time > 1
value = 120

;---------------------------------------------------------------------------
; Throw/Wire
;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
;Normal Throw - Throw Teched
[Statedef 901]
type    = S
movetype= A
physics = S
anim = 5002
velset = -6,0
sprpriority = 2

[State -2, Make Teched Throw Helper]
type = Helper
trigger1 = time = 0
name = "Teched Throw"
ID = 160
pos = Floor(Const(size.xscale) * Const(size.mid.pos.x)), Floor(Const(size.yscale) * Const(size.mid.pos.y))
postype = p1
facing = 1
stateno = 940
keyctrl = 0
ownpal = 1
supermovetime = 0
pausemovetime = 0
size.xscale = Const(size.xscale)
size.yscale = Const(size.yscale)
size.ground.back = 0
size.ground.front = 0
size.air.back = 0
size.air.front = 0
size.height = 0
size.head.pos = 0,0
size.mid.pos = 0,0
size.shadowoffset = 0

[State 901, Freeze Anim]
type = ChangeAnim
trigger1 = 1
value = Anim

[State 901, Opponent tech state]
type = TargetState
trigger1 = time = 0
value = 902

;[State 901, Tech VA]
;type = PlaySnd
;trigger1 = time = 0
;value = 2,7
;channel = 0
;volumescale = 75

[State 901, Tech Sound]
type = PlaySnd
trigger1 = time = 0
value = 10,11

[State 901, State End]
type = ChangeState
trigger1 = time = 22
value = 0
ctrl = 1

;---------------------------------------------------------------------------
;Thrown by Normal Throw - Teched the Throw
[Statedef 902]
type    = S
movetype= H
physics = S
anim = 5002
velset = -6,0

[State 902, Freeze Anim]
type = ChangeAnim
trigger1 = 1
value = Anim

[State 902, State End]
type = SelfState
trigger1 = time = 22
value = 0
ctrl = 1

;---------------------------------------------------------------------------
;Air Normal Throw - Throw Teched
[Statedef 903]
type    = A
movetype= A
physics = N
anim = 5002
velset = 0,-4

[State 903, 1]
type = VelAdd
trigger1 = 1
y = .1875

[State -2, Make Teched Throw Helper]
type = Helper
trigger1 = time = 0
name = "Teched Throw"
ID = 160
pos = Floor(Const(size.xscale) * Const(size.mid.pos.x)), Floor(Const(size.yscale) * Const(size.mid.pos.y))
postype = p1
facing = 1
stateno = 940
keyctrl = 0
ownpal = 1
supermovetime = 0
pausemovetime = 0
size.xscale = Const(size.xscale)
size.yscale = Const(size.yscale)
size.ground.back = 0
size.ground.front = 0
size.air.back = 0
size.air.front = 0
size.height = 0
size.head.pos = 0,0
size.mid.pos = 0,0
size.shadowoffset = 0

[State 903, Freeze Anim]
type = ChangeAnim
trigger1 = 1
value = Anim

[State 903, Opponent tech state]
type = TargetState
trigger1 = time = 0
value = 904

[State 903, Tech Sound]
type = PlaySnd
trigger1 = time = 0
value = 10,11

[State 903, State End]
type = ChangeState
trigger1 = time = 22
value = 50
ctrl = 1

;---------------------------------------------------------------------------
;Air Thrown by Normal Throw - Teched the Throw
[Statedef 904]
type    = A
movetype= H
physics = N
anim = 5002
velset = 0,-4

[State 904, 1]
type = VelAdd
trigger1 = 1
y = .1875

[State 904, Freeze Anim]
type = ChangeAnim
trigger1 = 1
value = Anim

[State 904, State End]
type = SelfState
trigger1 = time = 22
value = 50
ctrl = 1

;---------------------------------------------------------------------------
;Thrown by Normal Throw
[Statedef 920]
type    = S
movetype= H
physics = N
sprpriority = 1
velset = 0,0

[State 920, 1]
type = ChangeAnim2
Trigger1 = Time = 0
value = 920

[State 920, Invincible]
type = NotHitBy
trigger1 = time < 22
value = SCA

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

;In case attacker loses binding on player for any reason, this controller
;guarantees that the player will never get stuck in this thrown state.
[State 920, 2]
type = SelfState
trigger1 = !gethitvar(isbound)
value = 5050

;---------------------------------------------------------------------------
;Thrown by Normal Throw - thrown into the air
[Statedef 921]
type    = A
movetype= H
physics = N
sprpriority = 1
facep2 = 1
velset = 0,0 ;velset = -10,0

[State 921, Statetype]
type = StateTypeSet
trigger1 = pos y >= 0
statetype = S

[State 921, VelSet]
type = VelSet
trigger1 = HitShakeOver
trigger1 = vel x != -10
;trigger1 = time = 0
x = -10
y = 0

[State 921, Damage Cancel Check 1]
type = VarSet
trigger1 = SelfAnimExist(66167100)
var(14) = 1

[State 921, Damage Cancel Check 2]
type = VarSet
triggerall = SelfAnimExist(66167100)
trigger1 = (NumEnemy = 1) && ((playerID(var(35)), HitDefAttr = SCA, HA, HT, HP) || (playerID(var(35)), stateno = [3000,4999]))
trigger2 = (NumEnemy > 1)
trigger2 = var(36) != 0
trigger2 = ((playerID(var(35)), HitDefAttr = SCA, HA, HT, HP) || (playerID(var(35)), stateno = [3000,4999]))
trigger2 = ((playerID(var(36)), HitDefAttr = SCA, HA, HT, HP) || (playerID(var(36)), stateno = [3000,4999]))
var(14) = 0

[State 921, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

;[State 921, Go to stand state if hit]
;type = HitOverride
;trigger1 = 1
;time = 1
;attr = SCA,NA,SA,HA,NP,SP,HP,ST,HT
;value = 5000

[State 921, Go to stand state if hit]
type = NotHitBy
trigger1 = 1
value = , NT

[State 921, 1]
type = ChangeAnim
triggerall = SelfAnimExist(66167100)
trigger1 = Time = 0
trigger1 = SelfAnimExist(5900)
value = 5902

[State 921, 1]
type = ChangeAnim
triggerall = !SelfAnimExist(66167100)
trigger1 = Time = 0
trigger1 = SelfAnimExist(5900)
value = 5900

[State 921, 2]
type = ChangeAnim2 ;2
trigger1 = Time = 0
trigger1 = !SelfAnimExist(5900)
value = 5030

[State 921, HitDef1]
type = HitDef
triggerall = SelfAnimExist(66167100)
trigger1 = Time = 0
trigger1 = SelfAnimExist(5900)
attr = S, NT
damage = 24
guardflag = MA
pausetime = 8,8
sparkno = S974
guard.sparkno = S973
sparkxy = -14, 0
hitsound = S3,7
guardsound = S10,8
affectteam = F
animtype = Hard
ground.type = High
ground.slidetime = 22
ground.hittime  = 22
ground.velocity = 1, -2
air.velocity = 1, -2
yaccel = .25
air.hittime = 22
guard.velocity = -6
airguard.velocity = 0,0
ground.cornerpush.veloff = -0
air.cornerpush.veloff = 0
guard.cornerpush.veloff = 0
airguard.cornerpush.veloff = 0
getpower = 120, 0
givepower = 0, 0
fall = 1
fall.recover = 0

[State 921, Target State]
type = TargetState
triggerall = SelfAnimExist(66167100)
trigger1 = MoveHit = 1
trigger1 = numtarget > 0
value = 974

[State 921, Target State]
type = ChangeState
triggerall = SelfAnimExist(66167100)
trigger1 = MoveHit = 1
value = 974

[State 921, Pass Through]
type = PlayerPush
trigger1 = 1
value = 0

[State 921, ScreenBound]
type = ScreenBound
trigger1 = numenemy = 1
value = 0
movecamera = ifelse((enemy(0), stateno = 101 || enemy(0), stateno = 910), 1, !((enemy(0), pos x - pos x < -250) || (pos x - enemy(0), pos x < -250))),1

[State 921, ScreenBound]
type = ScreenBound
trigger1 = numenemy = 2
value = 0
movecamera = ifelse(((enemy(0), stateno = 101 || enemy(0), stateno = 910) || (enemy(1), stateno = 101 || enemy(1), stateno = 910)), 0, 1),1

[State 921, Hit wall]
type = ChangeState
triggerall = HitShakeOver
trigger1 = pos x <= (-160 + Const(size.ground.back)) ;BackEdgeBodyDist <= 5.5
trigger2 = pos x >= (160 - Const(size.ground.back)) ;FrontEdgeBodyDist <= 5.5
trigger3 = P2BodyDist x >= 480
;trigger3 = numenemy = 1
;trigger3 = ((enemy(0), pos x - pos x < -290) || (pos x - enemy(0), pos x < -290))
;trigger4 = numenemy = 2
;trigger4 = ((enemy(0), pos x - pos x < -290) || (pos x - enemy(0), pos x < -290)) || ((enemy(1), pos x - pos x < -290) || (pos x - enemy(1), pos x < -290))
value = 922

;---------------------------------------------------------------------------
;Thrown by Normal Throw - just hit the wall?
[Statedef 922]
type    = U
movetype= H
physics = N
velset = 0,0

;[State 922, Go to stand state if hit]
;type = HitOverride
;trigger1 = 1
;time = 1
;attr = SCA
;value = 5000

[State 922, Pass Through]
type = PlayerPush
trigger1 = 1
value = 0

[State 922, ScreenBound]
type = ScreenBound
trigger1 = numenemy = 1
value = 0
movecamera = ifelse((enemy(0), stateno = 101 || enemy(0), stateno = 910), 1, !((enemy(0), pos x - pos x < -250) || (pos x - enemy(0), pos x < -250))),1

[State 922, ScreenBound]
type = ScreenBound
trigger1 = numenemy = 2
value = 0
movecamera = ifelse(((enemy(0), stateno = 101 || enemy(0), stateno = 910) || (enemy(1), stateno = 101 || enemy(1), stateno = 910)), 0, 1),1

[State 922, Hit wall]
type = ChangeState
trigger1 = time = 1
value = 923

;---------------------------------------------------------------------------
; Thrown by Normal Throw - bounce off wall
; (a custom gethit state)
[Statedef 923]
type    = A
movetype= H
physics = N

[State 923, ScreenBound]
type = ScreenBound
trigger1 = numenemy = 1
value = 0
movecamera = ifelse((enemy(0), stateno = 101 || enemy(0), stateno = 910), 1, !((enemy(0), pos x - pos x < -250) || (pos x - enemy(0), pos x < -250))),1

[State 923, ScreenBound]
type = ScreenBound
trigger1 = numenemy = 2
value = 0
movecamera = ifelse(((enemy(0), stateno = 101 || enemy(0), stateno = 910) || (enemy(1), stateno = 101 || enemy(1), stateno = 910)), 0, 1),1

[State 923, Gravity]
type = VelAdd
trigger1 = 1
y = .1875

[State 923, Vel Y]
type = VelSet
trigger1 = Time = 0
y = -2

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

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

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

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

[State 923, OTG]
type = StateTypeSet
trigger1 = (Vel y > 0) && (Pos y >= 0)
statetype = S

[State 923, Vel Y]
type = PosSet
trigger1 = (Vel y > 0) && (Pos y >= 0)
y = 0

[State 923, Vel Y]
type = VelSet
trigger1 = (Vel y > 0) && (Pos y >= 0)
y = 0

[State 923, ChangeState]
type = ChangeState
trigger1 = statetype = S
value = 924

;---------------------------------------------------------------------------
; Thrown by Normal Throw - landing
; (a custom gethit state)
[Statedef 924]
type    = S
movetype= H
physics = N

[State 924, Var] ;Save fall velocity
type = VarSet
trigger1 = time = 0
sysvar(1) = 1

[State 924, Hit ground]
type = SelfState
trigger1 = time = 3
value = 5100

;---------------------------------------------------------------------------
; Wire Dust Clouds 1
[Statedef 925]
type    = S
movetype= I
physics = N
anim = 3604
velset = 0,0
sprpriority = 2
juggle = 0

[State 925, Target]
type = VarSet
trigger1 = time = 0
var(39) = root, var(35)

[State 925, Turn]
type = Turn
trigger1 = time = 0
trigger1 = enemynear, facing != facing

[State 925, Pos]
type = PosSet
trigger1 = 1
x = playerID(var(39)), pos x
y = playerID(var(39)), pos y

[State 925, No shadow]
type = AssertSpecial
trigger1 = 1
flag = noshadow
ignorehitpause = 1

[State 925, Sound]
type = PlaySnd
trigger1 = (PlayerID(var(39)), stateno = 923)
trigger1 = var(1) = 0
trigger1 = var(1) := 1
value = 10,6
channel = 1

[State 925, Sound]
type = Null
trigger1 = !(PlayerID(var(39)), stateno = 923)
trigger1 = var(1) := 0

[State 925, Dust 933]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 5100)
trigger1 = var(2) = 0
anim = 949
ID = 949
pos = 0, 10
postype = p1
facing = 1
bindtime = 1
vel = 0, 0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 4, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 925, Sound]
type = PlaySnd
trigger1 = (PlayerID(var(39)), stateno = 5100)
trigger1 = var(2) = 0
trigger1 = var(2) := 1
value = 10,7

[State 925, Erase Check]
type = DestroySelf
trigger1 = ((playerID(var(39)), movetype != H) && (playerID(var(39)), stateno != 935) && (playerID(var(39)), stateno != 5110)) || ((playerID(var(39)), stateno = 5110) && (playerID(var(39)), time = 2))
trigger2 = parent, numhelper(925) > 1
trigger2 = time > 0
ignorehitpause = 1

;---------------------------------------------------------------------------
; Wire Dust Clouds 2
[Statedef 926]
type    = S
movetype= I
physics = N
anim = 3604
velset = 0,0
sprpriority = 2
juggle = 0

[State 926, Transparency]
type = Trans
trigger1 = 1
trans = addalpha
alpha = 256,128

[State 926, Target]
type = VarSet
trigger1 = time = 0
var(39) = root, var(36)

[State 926, Turn]
type = Turn
trigger1 = time = 0
trigger1 = enemynear, facing != facing

[State 926, Pos]
type = PosSet
trigger1 = 1
x = playerID(var(39)), pos x
y = playerID(var(39)), pos y

[State 926, No shadow]
type = AssertSpecial
trigger1 = 1
flag = noshadow
ignorehitpause = 1

[State 926, Sound]
type = PlaySnd
trigger1 = (PlayerID(var(39)), stateno = 923)
trigger1 = var(1) = 0
trigger1 = var(1) := 1
value = 10,6

[State 926, Dust 933]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 5100)
trigger1 = var(2) = 0
anim = 949
ID = 949
pos = 0, 10
postype = p1
facing = 1
bindtime = 1
vel = 0, 0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 4, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 926, Sound]
type = PlaySnd
trigger1 = (PlayerID(var(39)), stateno = 5100)
trigger1 = var(2) = 0
trigger1 = var(2) := 1
value = 10,7

[State 926, Erase Check]
type = DestroySelf
trigger1 = ((playerID(var(39)), movetype != H) && (playerID(var(39)), stateno != 935) && (playerID(var(39)), stateno != 5110)) || ((playerID(var(39)), stateno = 5110) && (playerID(var(39)), time = 2))

;---------------------------------------------------------------------------
; Spiked
;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; Spiked
; (a custom gethit state)
[Statedef 930]
type    = U
movetype= H
physics = N
facep2 = 1

[State 921, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

[State 930, Invincible]
type = NotHitBy
trigger1 = 1
value = SCA

[State 930, Not in the Air lol]
type = SelfState
triggerall = time = 0
trigger1 = pos y >= 0
trigger2 = (!alive) && (statetype != A)
value = (5000 + (10 * (statetype = C)))

[State 930, StateTypeSet]
type = StateTypeSet
trigger1 = time = 0
statetype = A

[State 930, Anim]
type = ChangeAnim2
trigger1 = time = 0
value = ifelse(SelfAnimExist(5060), 5060, 5050)

[State 930, Turn]
type = Turn
trigger1 = time = 0
trigger1 = enemynear, facing = facing
ignorehitpause = 1

[State 930, Velocity]
type = VelSet
trigger1 = HitShakeOver
x = -8
y = 12

[State 930, Pass Through]
type = PlayerPush
trigger1 = 1
value = 0

[State 930, Hit Floor]
type = ChangeState
trigger1 = pos y >= 0
value = 931

;---------------------------------------------------------------------------
; HIT_BOUNCE (hit ground)
[Statedef 931]
type    = L
movetype= H
physics = N

[State 931, Sound]
type = PlaySnd
trigger1 = time = 0
trigger1 = SelfAnimExist(66167100)
value = 10,14
channel = 0

[State 931, Invincible]
type = NotHitBy
trigger1 = 1
value = SCA

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

[State 931, Var] ;Save fall velocity
type = VarSet
trigger1 = Time = 0
sysvar(1) = floor(vel y)

[State 931, 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 931, 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 931, 4]
type = PosSet
trigger1 = Time = 0
y = 0

[State 931, 5]
type = VelSet
trigger1 = Time = 0
y = 0

[State 931, 6]
type = VelSet
trigger1 = Time = 0
x = -4

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

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

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

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

;---------------------------------------------------------------------------
; HIT_BOUNCE (bounce into air)
[Statedef 932]
type    = L
movetype= H
physics = N

[State 932, Invincible]
type = NotHitBy
trigger1 = 1
value = SCA

[State 932, 1] ;Acceleration
type = VelAdd
trigger1 = 1
y = 0.3125

[State 932, 2]
type = VelSet
trigger1 = time = 0
y = -4

[State 932, Up] ;Coming hit ground anim (normal)
type = ChangeAnim
trigger1 = time = 0
value = 5002

[State 932, Down] ;Coming hit ground anim (normal)
type = ChangeAnim
triggerall = vel y < 0
trigger1 = anim != 5050
value = 5050

[State 932, 6] ;Hit ground
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 933

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

[State 933, Invincible]
type = NotHitBy
trigger1 = 1
value = SCA

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

[State 933, Var] ;Save fall velocity
type = VarSet
trigger1 = Time = 0
sysvar(1) = floor(vel y)

[State 933, 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 933, 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 933, 4]
type = PosSet
trigger1 = Time = 0
y = 0

[State 933, 5]
type = VelSet
trigger1 = Time = 0
y = 0

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

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

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

;---------------------------------------------------------------------------
; HIT_BOUNCE (bounce into air)
[Statedef 934]
type    = L
movetype= H
physics = N

[State 934, Invincible]
type = NotHitBy
trigger1 = 1
value = SCA

[State 934, 1] ;Coming hit ground anim (normal)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim != [5101,5109]
trigger2 = !SelfAnimExist(5160 + (anim % 10))
value = 5160

[State 934, 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 934, 1] ;Acceleration
type = VelAdd
trigger1 = 1
y = 0.3125

[State 932, 2]
type = VelSet
trigger1 = time = 0
y = -3

[State 934, 6] ;Hit ground
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
type = ChangeState
value = 935

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

[State 935, Var] ;Save fall velocity
type = VarSet
trigger1 = 1
sysvar(1) = 0

[State 935, Invincible]
type = NotHitBy
trigger1 = 1
value = SCA

[State 935, 1]
type = SelfState
trigger1 = 1
value = 5110

;---------------------------------------------------------------------------
; Spiked Dust Clouds 1
[Statedef 936]
type    = A
movetype= I
physics = N
anim = 3604
velset = 0,0
sprpriority = 2
juggle = 0

[State 936, Target]
type = VarSet
trigger1 = time = 0
var(39) = root, var(35)

[State 936, Target]
type = DestroySelf
triggerall = time = 0
trigger1 = (playerID(var(39)), stateno != [930,935])
trigger2 = (playerID(var(39)), stateno = [930,935])
trigger2 = (playerID(var(39)), movetype != H)

[State 936, Turn]
type = Turn
trigger1 = time = 0
trigger1 = enemynear, facing != facing

[State 936, Pos]
type = PosSet
trigger1 = 1
x = playerID(var(39)), pos x
y = playerID(var(39)), pos y

[State 936, No shadow]
type = AssertSpecial
trigger1 = 1
flag = noshadow
ignorehitpause = 1

[State 931, Dust 931]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 931) || (PlayerID(var(39)), stateno = 932)
trigger1 = var(1) = 0
anim = 949
ID = 949
pos = 0, 10
postype = p1
facing = 1
bindtime = 1
vel = 0, 0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 4, 5
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 936, Sound]
type = PlaySnd
trigger1 = (PlayerID(var(39)), stateno = 931) || (PlayerID(var(39)), stateno = 932)
trigger1 = var(1) = 0
trigger1 = var(1) := 1
value = 10,7

[State 936, Dust 933]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 933) || (PlayerID(var(39)), stateno = 934)
trigger1 = var(2) = 0
anim = 949
ID = 949
pos = 0, 10
postype = p1
facing = 1
bindtime = 1
vel = 0, 0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 5, 4
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 936, Sound]
type = PlaySnd
trigger1 = (PlayerID(var(39)), stateno = 933) || (PlayerID(var(39)), stateno = 934)
trigger1 = var(2) = 0
trigger1 = var(2) := 1
value = 10,7

[State 936, Dust1 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(3) = 0
trigger1 = var(3) := 1
anim = 949
ID = 949
pos = -42 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 936, Dust2 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(4) = 0
trigger1 = var(4) := 1
anim = 949
ID = 949
pos = -28 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 936, Dust3 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(5) = 0
trigger1 = var(5) := 1
anim = 949
ID = 949
pos = -14 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 936, Dust4 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(6) = 0
trigger1 = var(6) := 1
anim = 949
ID = 949
pos = (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 936, Dust5 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(7) = 0
trigger1 = var(7) := 1
anim = 949
ID = 949
pos = 14 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 936, Dust6 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(8) = 0
trigger1 = var(8) := 1
anim = 949
ID = 949
pos = 28 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 936, Dust7 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(9) = 0
trigger1 = var(9) := 1
anim = 949
ID = 949
pos = 42 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 936, Dust8 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(10) = 0
trigger1 = var(10) := 1
anim = 949
ID = 949
pos = 56 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 936, Sound]
type = Null;PlaySnd
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = PlayerID(var(39)), time = 1
value = 10,7

[State 936, Erase Check]
type = DestroySelf
trigger1 = ((playerID(var(39)), movetype != H) && (playerID(var(39)), stateno != 935) && (playerID(var(39)), stateno != 5110)) || ((playerID(var(39)), stateno = 5110) && (playerID(var(39)), time = 2))
trigger2 = (playerID(var(39)), stateno = 5000)

;---------------------------------------------------------------------------
; Spiked Dust Clouds 2
[Statedef 937]
type    = A
movetype= I
physics = N
anim = 3604
velset = 0,0
sprpriority = 2
juggle = 0

[State 937, Transparency]
type = Trans
trigger1 = 1
trans = addalpha
alpha = 256,128

[State 937, Target]
type = VarSet
trigger1 = time = 0
var(39) = root, var(36)

[State 937, Target]
type = DestroySelf
triggerall = time = 0
trigger1 = (playerID(var(39)), stateno != [930,935])
trigger2 = (playerID(var(39)), stateno = [930,935])
trigger2 = (playerID(var(39)), movetype != H)

[State 937, Turn]
type = Turn
trigger1 = time = 0
trigger1 = enemynear, facing != facing

[State 937, Pos]
type = PosSet
trigger1 = 1
x = playerID(var(39)), pos x
y = playerID(var(39)), pos y

[State 937, No shadow]
type = AssertSpecial
trigger1 = 1
flag = noshadow
ignorehitpause = 1

[State 937, Dust 931]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 931) || (PlayerID(var(39)), stateno = 932)
trigger1 = var(1) = 0
anim = 949
ID = 949
pos = 0, 10
postype = p1
facing = 1
bindtime = 1
vel = 0, 0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 4, 5
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 937, Sound]
type = PlaySnd
trigger1 = (PlayerID(var(39)), stateno = 931) || (PlayerID(var(39)), stateno = 932)
trigger1 = var(1) = 0
trigger1 = var(1) := 1
value = 10,7

[State 937, Dust 933]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 933) || (PlayerID(var(39)), stateno = 934)
trigger1 = var(2) = 0
anim = 949
ID = 949
pos = 0, 10
postype = p1
facing = 1
bindtime = 1
vel = 0, 0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 5, 4
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 937, Sound]
type = PlaySnd
trigger1 = (PlayerID(var(39)), stateno = 933) || (PlayerID(var(39)), stateno = 934)
trigger1 = var(2) = 0
trigger1 = var(2) := 1
value = 10,7

[State 937, Dust1 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(3) = 0
trigger1 = var(3) := 1
anim = 949
ID = 949
pos = -42 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 937, Dust2 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(4) = 0
trigger1 = var(4) := 1
anim = 949
ID = 949
pos = -28 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 937, Dust3 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(5) = 0
trigger1 = var(5) := 1
anim = 949
ID = 949
pos = -14 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 937, Dust4 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(6) = 0
trigger1 = var(6) := 1
anim = 949
ID = 949
pos = (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 937, Dust5 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(7) = 0
trigger1 = var(7) := 1
anim = 949
ID = 949
pos = 14 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 937, Dust6 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(8) = 0
trigger1 = var(8) := 1
anim = 949
ID = 949
pos = 28 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 937, Dust7 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(9) = 0
trigger1 = var(9) := 1
anim = 949
ID = 949
pos = 42 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 937, Dust8 935]
type = Explod
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = var(10) = 0
trigger1 = var(10) := 1
anim = 949
ID = 949
pos = 56 + (random%5 - 2), 10
postype = p1
facing = 1
bindtime = 1
vel = 4, ((random%5 - 2) * .2)
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 937, Sound]
type = Null;PlaySnd
trigger1 = (PlayerID(var(39)), stateno = 935) || (PlayerID(var(39)), stateno = 5110)
trigger1 = PlayerID(var(39)), time = 1
value = 10,7

[State 937, Erase Check]
type = DestroySelf
trigger1 = ((playerID(var(39)), movetype != H) && (playerID(var(39)), stateno != 935) && (playerID(var(39)), stateno != 5110)) || ((playerID(var(39)), stateno = 5110) && (playerID(var(39)), time = 2))
trigger2 = (playerID(var(39)), stateno = 5000)

;---------------------------------------------------------------------------
; Teched Throw
;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; Teched Throw Graphic Helper
[Statedef 940]
type    = S
movetype= A
physics = N
anim    = 975
velset = 0,0
sprpriority = 2

[State 940, No shadow]
type = AssertSpecial
trigger1 = 1
flag = noshadow
ignorehitpause = 1

[State 940, Remove]
type = DestroySelf
trigger1 = AnimTime = 0

;---------------------------------------------------------------------------
; Damage Cancel
;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; Damage Cancel
[Statedef 950]
type    = U
movetype= A
physics = N
anim    = 950
velset = 0,0

[State 950, Sound]
type = PlaySnd
trigger1 = time = 0
value = 10,9

[State 950, Stock Use]
type = PowerAdd
trigger1 = time = 0
value = -1000

[State 950, 1]
type = HitDef
trigger1 = time =0
attr = S, NA
priority = 7, Hit ; Seriously, no ignoring the combo breaker
damage= 0, 0
hitflag = MAF
guardflag = MA
;sparkno = S974
;guard.sparkno = S973
;sparkxy = 0, -50
pausetime = 8,8
guardsound = S10,8
animtype = Medium
ground.type = High
guard.dist = 85
ground.velocity = -1, -2
air.velocity = -1,-2
guard.velocity = -0
airguard.velocity = 0,0
fall = 1
fall.recover = 0

[State 974, Target State]
type = TargetState
trigger1 = MoveHit = 1
trigger1 = numtarget > 0
value = 974

[State 950, DC Burst Effect]
type = Explod
trigger1 = time = 0
anim = 951
ID = 951
pos = Floor(Const(size.xscale) * Const(size.mid.pos.x)), Floor(Const(size.yscale) * Const(size.mid.pos.y))
postype = p1
facing = 1
vfacing = 1
bindtime = 1
accel = 0,0
random = 0,0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1,1
sprpriority = 4
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[State 950, DC Ring Effect1]
type = Explod
trigger1 = time = 0
anim = 952
ID = 952
pos = Floor(Const(size.xscale) * Const(size.mid.pos.x)), Floor(Const(size.yscale) * Const(size.mid.pos.y))
postype = p1
facing = 1
vfacing = 1
bindtime = 1
accel = 0,0
random = 0,0
removetime = 19
supermovetime = 0
pausemovetime = 0
scale = 1,1
sprpriority = 3
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[State 950, DC Ring Effect2]
type = Explod
trigger1 = time = 2
anim = 952
ID = 952
pos = Floor(Const(size.xscale) * Const(size.mid.pos.x)), Floor(Const(size.yscale) * Const(size.mid.pos.y))
postype = p1
facing = 1
vfacing = 1
bindtime = 1
accel = 0,0
random = 0,0
removetime = 17
supermovetime = 0
pausemovetime = 0
scale = 1,1
sprpriority = 2
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
trans = addalpha
alpha = 192, 256

[State 950, DC Ring Effect3]
type = Explod
trigger1 = time = 4
anim = 952
ID = 952
pos = Floor(Const(size.xscale) * Const(size.mid.pos.x)), Floor(Const(size.yscale) * Const(size.mid.pos.y))
postype = p1
facing = 1
vfacing = 1
bindtime = 1
accel = 0,0
random = 0,0
removetime = 15
supermovetime = 0
pausemovetime = 0
scale = 1,1
sprpriority = 2
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
trans = addalpha
alpha = 128, 256

[State 950, Damage Cancel Hitspark]
type = Explod
trigger1 = var(32) = var(33)
trigger1 = NumTarget > 0
trigger1 = MoveHit = 1
;trigger1 = NumExplod(50) < 1
anim = 974
ID = 50
pos = (target, Const(size.mid.pos.x)), (target, Const(size.mid.pos.y))
postype = p2
facing = 1
vfacing = 1
bindtime = 1
accel = 0,0
random = 0,0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1,1
sprpriority = 3
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[State -2, Guardspark]
type = Explod
trigger1 = var(32) = var(33)
trigger1 = NumTarget > 0
trigger1 = MoveGuarded = 1
;trigger1 = NumExplod(50) < 1
anim = 973
ID = 50
pos = (target, Const(size.mid.pos.x)), (target, Const(size.mid.pos.y))
postype = p2
facing = 1
vfacing = 1
bindtime = 1
accel = 0,0
random = 0,0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1,1
sprpriority = 3
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[State 950, 2]
type = PosSet
trigger1 = time = 0
trigger1 = Pos y > 0
y = 0

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

[State 950, 3]
type = NotHitBy
trigger1 = time = 12
value2 = SCA
time = 2

[State 950, 3]
type = ChangeState
trigger1 = time = 12
value = ifelse(Pos y < 0,50,0)
ctrl = 1

;---------------------------------------------------------------------------
; Guard Cancel
;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; Guard Cancel Graphic Helper
[Statedef 960]
type    = S
movetype= A
physics = N
anim    = 972
velset = 0,0
sprpriority = 2

[State 960, No shadow]
type = AssertSpecial
trigger1 = 1
flag = noshadow
ignorehitpause = 1

[State 960, Guard Cancel Effect]
type = Explod
trigger1 = time = 0
anim = 973
ID = 150
pos = 0, 0
postype = p1
facing = 1
vfacing = 1
bindtime = 1
accel = 0,0
random = 0,0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 1,1
sprpriority = 4
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[State 960, Remove]
type = DestroySelf
trigger1 = AnimTime = 0

;---------------------------------------------------------------------------
; Get Hit States
;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; Locked in Place
[Statedef 970]
type    = U
movetype= H
physics = N
ctrl = 0
velset = 0,0

[State 970, Not in the air lol]
type = SelfState
trigger1 = statetype != A
value = 5000

[State 970, Freeze Anim]
type = ChangeAnim
trigger1 = 1
value = Anim

[State 970, No Gravity]
type = VelAdd;Gravity
trigger1 = 1
y = 0; GetHitVar(yaccel)

[State 970, Get Hit Velocities]
type = HitVelSet
trigger1 = Time = 0
x = 0
y = 0

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

[State 970, Air State]
type = SelfState
trigger1 = alive
trigger1 = HitOver
value = 50
ctrl = 1

;---------------------------------------------------------------------------
; Paralyzed
[Statedef 971]
type    = U
movetype= H
physics = N
ctrl = 0
velset = 0,0

[State 971, Anim]
type = ChangeAnim
trigger1 = time = 0
value = ifelse(SelfAnimExist(66167100), 5120, 11)

[State -2, Damage Cancel Check 1]
type = VarSet
trigger1 = SelfAnimExist(66167100)
var(14) = 1

[State -2, Damage Cancel Check 2]
type = VarSet
triggerall = SelfAnimExist(66167100)
trigger1 = (NumEnemy = 1) && ((playerID(var(35)), HitDefAttr = SCA, HA, HT, HP) || (playerID(var(35)), stateno = [3000,4999]))
trigger2 = (NumEnemy > 1)
trigger2 = var(36) != 0
trigger2 = ((playerID(var(35)), HitDefAttr = SCA, HA, HT, HP) || (playerID(var(35)), stateno = [3000,4999]))
trigger2 = ((playerID(var(36)), HitDefAttr = SCA, HA, HT, HP) || (playerID(var(36)), stateno = [3000,4999]))
var(14) = 0

[State 971, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

[State 971, Unparalyzed]
type = SelfState
trigger1 = alive
trigger1 = time = 60
value = ifelse(statetype = A, 50, 0)
ctrl = 1

[State 971, Freeze Anim]
type = ChangeAnim
trigger1 = 1
value = Anim

[State 971, Gravity]
type = VelAdd
trigger1 = statetype = A
y = Const(movement.yaccel)

[State 971, Land 1]
type = VelSet
trigger1 = pos y >= 0
x = 0
y = 0

[State 971, Land 2]
type = PosSet
trigger1 = pos y >= 0
y = 0

[State 971, Land 3]
type = StateTypeSet
trigger1 = pos y >= 0
statetype = S
physics = S

[State 971, Get Hit Velocities]
type = HitVelSet
trigger1 = Time = 0
x = 0
y = 0

[State 971, Are you dead?]
type = SelfState
trigger1 = !alive
value = 5050

;---------------------------------------------------------------------------
; Paralyze effect 1
[Statedef 972]
type    = S
movetype= I
physics = N
anim = 971
velset = 0,0
sprpriority = 2
juggle = 0

[State 972, Transparency]
type = Trans
trigger1 = 1
trans = addalpha
alpha = 256,128

[State 972, Target]
type = VarSet
trigger1 = time = 0
var(39) = root, var(35)

[State 972, Turn]
type = Turn
trigger1 = time = 0
trigger1 = enemynear, facing != facing

[State 972, Pos]
type = PosSet
trigger1 = 1
x = playerID(var(39)), pos x
y = playerID(var(39)), pos y

[State 972, No shadow]
type = AssertSpecial
trigger1 = 1
flag = noshadow
ignorehitpause = 1

[State 972, Erase Check]
type = DestroySelf
trigger1 = time = 60
trigger2 = (playerID(var(39)), movetype != H) || (playerID(var(39)), stateno != 971)

[State 972, Sound]
type = PlaySnd
trigger1 = time%15 = 0
value = 10,13

;---------------------------------------------------------------------------
; Paralyze effect 2
[Statedef 973]
type    = S
movetype= I
physics = N
anim = 971
velset = 0,0
sprpriority = 2
juggle = 0

[State 973, Transparency]
type = Trans
trigger1 = 1
trans = addalpha
alpha = 256,128

[State 973, Target]
type = VarSet
trigger1 = time = 0
var(39) = root, var(36)

[State 973, Turn]
type = Turn
trigger1 = time = 0
trigger1 = enemynear, facing != facing

[State 973, Pos]
type = PosSet
trigger1 = 1
x = playerID(var(39)), pos x
y = playerID(var(39)), pos y

[State 973, No shadow]
type = AssertSpecial
trigger1 = 1
flag = noshadow
ignorehitpause = 1

[State 973, Erase Check]
type = DestroySelf
trigger1 = time = 60
trigger2 = (playerID(var(39)), movetype != H) || (playerID(var(39)), stateno != 971)

[State 973, Sound]
type = PlaySnd
trigger1 = time%15 = 0
value = 10,13

;---------------------------------------------------------------------------
; Special HITA_SHAKE
[Statedef 974]
type    = A
movetype= H
physics = N
velset = 0,0

[State 974, 2]
type = HitVelSet
trigger1 = Time = 0
trigger1 = prevstateno != 921
x = 1
y = 1

[State 974, Turn]
type = Turn
trigger1 = vel x > 0

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

[State 974, 2]
type = VelSet
trigger1 = Time = 0
trigger1 = prevstateno != 921
x = 0
y = 0

[State 974, 2]
type = VelAdd
trigger1 = Time = 0
trigger1 = prevstateno = 921
x = vel x
y = vel y

[State 974, 2]
type = VelSet
trigger1 = Time = 0
trigger1 = prevstateno = 921
x = -1
y = -2

;[State 974, Turn]
;type = Turn
;trigger1 = time = 0
;trigger1 = GetHitVar(xvel) > 0

[State 974, 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 974, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5030

[State 974, 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 974, 4] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 974, 5]
type = HitVelSet
trigger1 = HitShakeOver
trigger1 = prevstateno != 921
x = 1
y = 1

[State 974, 5]
type = ChangeState
trigger1 = HitShakeOver
value = 975

[State 974, FFB Light]
type = ForceFeedback
trigger1 = anim = 5000
trigger2 = anim = 5010
persistent = 0
time = 6
waveform = square

[State 974, FFB Medium]
type = ForceFeedback
trigger1 = anim = 5001
trigger2 = anim = 5011
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 974, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5012
trigger2 = anim = 5002
trigger3 = anim = 974
trigger4 = anim = [5051,5059]
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

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

[State 921, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

[State 975, Turn]
type = Turn
trigger1 = vel x > 0

[State 975 1]
type = VelAdd;Gravity
trigger1 = 1
y = GetHitVar(yaccel)

[State 975, 4]
type = ChangeState
trigger1 = HitOver
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= 10  ;.
value = 977 ;HITA_FALL

[State 975, 5]
type = ChangeState
trigger1 = time = 24
trigger2 = AnimTime = 0
value = 976 ;HITA_UP (transition)

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

[State 921, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

[State 976, 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 976, 2]
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 976, 4]
type = ChangeState
trigger1 = HitOver  ;Hit is over
trigger2 = Vel Y > 1    ;Falling
;trigger2 = Pos Y >= 10
;trigger3 = AnimTime = 0 ;Anim is over
value = 977 ;HITA_FALL

;---------------------------------------------------------------------------
; Special HITA_FALL (knocked up, falling)
[Statedef 977]
type    = A
movetype= H
physics = N

[State 921, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

[State 977, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA

[State 977, 1] ;Change anim when done with transition
type = ChangeAnim
trigger1 = AnimTime = 0
trigger1 = Anim = 975
trigger2 = Time = 0     ;If no transition anim
trigger2 = Anim != 975
trigger2 = (Anim != [5051, 5059]) && (Anim != [5061, 5069])
trigger2 = Anim != 5090 ;Not if hit off ground anim
value = 5050

[State 977, 2] ;Coming down anim
type = ChangeAnim
trigger1 = anim = [5050,5059]
trigger1 = Vel Y >= ifelse(anim = 977, 1, -2)
trigger1 = SelfAnimExist(anim+10)
value = anim+10
persistent = 0

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

[State 977, 4] ;Recover near ground
type = SelfState
triggerall = Vel Y > 0
triggerall = Pos Y >= -20
triggerall = alive
triggerall = CanRecover
trigger1 = Command = "recovery"
trigger2 = SelfAnimExist(66167100)
value = 5200 ;HITFALL_RECOVER

[State 977, 5]; Recover in mid air
type = SelfState
triggerall = Vel Y > -1
triggerall = alive
triggerall = CanRecover
trigger1 = Command = "recovery"
value = 5210 ;HITFALL_AIRRECOVER

[State 977, 6]
type = SelfState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= ifelse((anim = [5051,5059]) || (anim = [5061,5069]), 0, 25)
value = 5100 ;HIT_BOUNCE

;---------------------------------------------------------------------------
; Hit by Launcher 1
[Statedef 980]
type    = S
movetype= H
physics = N
velset = 0,0

[State 921, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

[State 980, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
value = ifelse(5009 + GetHitVar(animtype) < 5010, 5010, 5009 + GetHitVar(animtype))

[State 980, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 10
value = 5000 + GetHitVar(animtype)

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

[State 980, 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 980, 7]
type = ChangeState
trigger1 = HitShakeOver
value = 981

[State 980, FFB Light]
type = ForceFeedback
trigger1 = anim = 5000
trigger2 = anim = 5010
persistent = 0
time = 6
waveform = square

[State 980, FFB Medium]
type = ForceFeedback
trigger1 = anim = 5001
trigger2 = anim = 5011
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 980, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5012
trigger2 = anim = 5002
trigger3 = anim = 5030
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

;---------------------------------------------------------------------------
;Hit by Launcher 2
[Statedef 981]
type    = A
movetype= H
physics = N
ctrl = 0

[State 921, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

[State 981, 1]
type = VelAdd;Gravity
trigger1 = 1
y = .25 ;GetHitVar(yaccel)

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

[State 981, AnimFreeze]
type = ChangeAnim
trigger1 = AnimTime = -1
value = anim
elem = AnimElemNo(0)

[State 981, 2]
type = VelSet
trigger1 = HitOver ;AnimTime = 0
y = 0

[State 981, 5]
type = SelfState
trigger1 = HitOver ;AnimTime = 0
value = 5035 ;HITA_UP (transition)

;---------------------------------------------------------------------------
; Override common states (use same number to override) :
;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; RUN_FWD (After throw)
[Statedef 101]
type    = S
physics = S
anim = 100
sprpriority = 1
ctrl = 0

[State 101, 4]
type = ChangeState
triggerall = time = 0
triggerall = ifelse(facing = 1, ScreenPos x >= 5, ScreenPos x <= 314)
trigger1 = numenemy = 1
trigger1 = (enemy, stateno = 922 && enemy, movetype = H)
trigger2 = numenemy = 2
trigger2 = (var(35) != 0) && (var(36) != 0)
trigger2 = (PlayerID(var(35)), stateno = 922 && PlayerID(var(35)), movetype = H) || (PlayerID(var(36)), stateno = 922 && PlayerID(var(36)), movetype = H)
value = 0
ctrl = 1

[State 101, 4p failsafe]
type = ChangeState
trigger1 = numenemy = 2
trigger1 = (var(35) != 0) && (var(36) != 0)
trigger1 = (playerID(var(35)), alive) && (playerID(var(36)), alive)
value = 100

[State 101, Turn]
type = Null
triggerall = time = 0
trigger1 = facing = 1
trigger1 = !(fvar(9) >= 61)
trigger1 = fvar(10) >= 61
trigger2 = facing = -1
trigger2 = fvar(9) >= 61
trigger2 = !(fvar(10) >= 61)

[State 101, Hold Back blocking lawl wut]
type = ChangeState
triggerall = var(42) != 1
triggerall = !var(0)
triggerall = statetype != A
triggerall = InGuardDist
triggerall = var(16) >= 5
triggerall = command = "holdfwd"
trigger1 = ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x))
trigger1 = numenemy = 1
trigger2 = numenemy = 2
trigger2 = (var(35) != 0) && (var(36) != 0)
trigger2 = ifelse(!(playerID(var(35)), alive), ifelse(facing = -1, (pos x < playerID(var(36)), pos x), (pos x > playerID(var(36)), pos x)), 0)
trigger3 = numenemy = 2
trigger3 = (var(35) != 0) && (var(36) != 0)
trigger3 = ifelse(!(playerID(var(36)), alive), ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x)), 0)
value = 120

[State 101, Hold Back blocking lawl wut]
type = ChangeState
triggerall = var(42) != 1
triggerall = !var(0)
triggerall = statetype != A
triggerall = InGuardDist
triggerall = var(16) >= 5
triggerall = command = "holdback"
trigger1 = ifelse(facing = -1, (pos x > playerID(var(35)), pos x), (pos x < playerID(var(35)), pos x))
trigger1 = numenemy = 1
trigger2 = numenemy = 2
trigger2 = (var(35) != 0) && (var(36) != 0)
trigger2 = ifelse(!(playerID(var(35)), alive), ifelse(facing = -1, (pos x > playerID(var(36)), pos x), (pos x < playerID(var(36)), pos x)), 0)
trigger3 = numenemy = 2
trigger3 = (var(35) != 0) && (var(36) != 0)
trigger3 = ifelse(!(playerID(var(36)), alive), ifelse(facing = -1, (pos x > playerID(var(35)), pos x), (pos x < playerID(var(35)), pos x)), 0)
value = 120

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

[State 101, Sound]
type = PlaySnd
trigger1 = time % 10 = 0 ; AnimElem = 1, = 0 || AnimTime = 0
value = 9,6

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

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

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

[State 101, 4]
type = ChangeState
triggerall = ifelse(facing = 1, ScreenPos x >= 5, ScreenPos x <= 314)
trigger1 = time > 29
value = ifelse(command = "holdfwd", 100, 0)
ctrl = ifelse(command = "holdfwd", 0, 1)

[State 101, 4]
type = ChangeState
triggerall = ifelse(facing = 1, ScreenPos x >= 5, ScreenPos x <= 314)
trigger1 = numenemy = 1
trigger1 = (enemy, stateno = 922 && enemy, movetype = H)
trigger2 = numenemy = 2
trigger2 = (var(35) != 0) && (var(36) != 0)
trigger2 = (PlayerID(var(35)), stateno = 922 && PlayerID(var(35)), movetype = H) || (PlayerID(var(36)), stateno = 922 && PlayerID(var(36)), movetype = H)
value = 100

[State 101, 4]
type = ChangeState
trigger1 = enemy, movetype != H
trigger1 = time >= 240
value = 0

;---------------------------------------------------------------------------
; GUARD (start)
[Statedef 120]
type = U    ;Leave state type unchanged
physics = U ;Leave physics unchanged
ctrl = 0

[State 120, AI Guard Time Reset]
type = VarSet
trigger1 = time = 0
v = 17
value = 0

[State 120, No auto turn]
type = AssertSpecial
trigger1 = 1
flag = noautoturn
ignorehitpause = 1

[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, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown"
statetype = C
physics = C

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

[State 120, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 130 + (statetype = C) + (statetype = A)*2

[State 120, Turn controls]
type = ChangeAnim
triggerall = ifelse(var(16) >= 5, command = "holdz", 1)
triggerall = statetype != A
triggerall = (command != "holdfwd")
trigger1 = numenemy = 1
trigger1 = ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x))
trigger2 = numenemy = 2
trigger2 = (var(35) != 0) && (var(36) != 0)
trigger2 = ifelse(!(playerID(var(35)), alive), ifelse(facing = -1, (pos x < playerID(var(36)), pos x), (pos x > playerID(var(36)), pos x)), 0)
trigger3 = numenemy = 2
trigger3 = (var(35) != 0) && (var(36) != 0)
trigger3 = ifelse(!(playerID(var(36)), alive), ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x)), 0)
trigger4 = (command = "holdback")
value = 5 + (statetype != S)

[State 120, Turn controls]
type = Turn
triggerall = ifelse(var(16) >= 5, command = "holdz", 1)
triggerall = statetype != A
triggerall = (command != "holdfwd")
trigger1 = numenemy = 1
trigger1 = ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x))
trigger2 = numenemy = 2
trigger2 = (var(35) != 0) && (var(36) != 0)
trigger2 = ifelse(!(playerID(var(35)), alive), ifelse(facing = -1, (pos x < playerID(var(36)), pos x), (pos x > playerID(var(36)), pos x)), 0)
trigger3 = numenemy = 2
trigger3 = (var(35) != 0) && (var(36) != 0)
trigger3 = ifelse(!(playerID(var(36)), alive), ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x)), 0)
trigger4 = (command = "holdback")

[State 120, 1]
type = ChangeAnim
trigger1 = (Anim != (120 + (statetype = C) + (statetype = A)*2)) && Anim != [5,6]
trigger2 = (Anim = [5,6]) && AnimTime = 0
value = 120 + (statetype = C) + (statetype = A)*2

;[State 120, Air Turn]
;type = ChangeAnim
;trigger1 = statetype = A
;trigger1 = Time = 0
;trigger1 = vel X < 0
;value = 822

;[State 120, Stop Guarding]
;type = ChangeState
;trigger1 = command != "holdz"
;trigger1 = ifelse(var(16) >= 5, !InGuardDist, 1)
;trigger1 = command = "AFF"
;trigger1 = statetype != A
;value = 100

;[State 120, Stop Guarding]
;type = ChangeState
;trigger1 = command != "holdz"
;trigger1 = ifelse(var(16) >= 5, !InGuardDist, 1)
;trigger1 = command = "ABB"
;trigger1 = statetype != A
;value = 105

;[State 120, Stop Guarding]
;type = ChangeState
;trigger1 = command != "holdz"
;trigger1 = ifelse(var(16) >= 5, !InGuardDist, 1)
;value = 140

;---------------------------------------------------------------------------
; STAND GUARD (guarding)
[Statedef 130]
type    = S
physics = S
ctrl = 0

[State 130, AI Guard Time]
type = VarAdd
trigger1 = prevstateno != 130 || time > 0
v = 17
value = 1

[State 130, No auto turn]
type = AssertSpecial
trigger1 = 1
flag = noautoturn
ignorehitpause = 1

[State 130, Turn controls]
type = ChangeAnim
triggerall = ifelse(var(16) >= 5, command = "holdz", 1)
triggerall = statetype != A
triggerall = (command != "holdfwd")
trigger1 = numenemy = 1
trigger1 = ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x))
trigger2 = numenemy = 2
trigger2 = (var(35) != 0) && (var(36) != 0)
trigger2 = ifelse(!(playerID(var(35)), alive), ifelse(facing = -1, (pos x < playerID(var(36)), pos x), (pos x > playerID(var(36)), pos x)), 0)
trigger3 = numenemy = 2
trigger3 = (var(35) != 0) && (var(36) != 0)
trigger3 = ifelse(!(playerID(var(36)), alive), ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x)), 0)
trigger4 = (command = "holdback")
value = 5 + (statetype != S)

[State 130, Turn controls]
type = Turn
triggerall = ifelse(var(16) >= 5, command = "holdz", 1)
triggerall = (command != "holdfwd")
trigger1 = numenemy = 1
trigger1 = ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x))
trigger2 = numenemy = 2
trigger2 = (var(35) != 0) && (var(36) != 0)
trigger2 = ifelse(!(playerID(var(35)), alive), ifelse(facing = -1, (pos x < playerID(var(36)), pos x), (pos x > playerID(var(36)), pos x)), 0)
trigger3 = numenemy = 2
trigger3 = (var(35) != 0) && (var(36) != 0)
trigger3 = ifelse(!(playerID(var(36)), alive), ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x)), 0)
trigger4 = (command = "holdback")

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

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

;[State 130, Stop Guarding]
;type = ChangeState
;trigger1 = command != "holdz"
;trigger1 = ifelse(var(16) >= 5, !InGuardDist, 1)
;trigger1 = command = "AFF"
;value = 100

;[State 130, Stop Guarding]
;type = ChangeState
;trigger1 = command != "holdz"
;trigger1 = ifelse(var(16) >= 5, !InGuardDist, 1)
;trigger1 = command = "ABB"
;value = 105

[State 130, Stop Guarding]
type = ChangeState
triggerall = !var(0)
trigger1 = command != "holdz"
trigger1 = ifelse(var(16) >= 5, !InGuardDist, 1)
value = 140
ctrl = 1

;---------------------------------------------------------------------------
; CROUCH GUARD (guarding)
[Statedef 131]
type    = C
physics = C
ctrl = 0

[State 131, AI Guard Time]
type = VarAdd
trigger1 = prevstateno != 131 || time > 0
v = 17
value = 1

[State 131, No auto turn]
type = AssertSpecial
trigger1 = 1
flag = noautoturn
ignorehitpause = 1

[State 131, Turn controls]
type = ChangeAnim
triggerall = ifelse(var(16) >= 5, command = "holdz", 1)
triggerall = statetype != A
triggerall = (command != "holdfwd")
trigger1 = numenemy = 1
trigger1 = ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x))
trigger2 = numenemy = 2
trigger2 = (var(35) != 0) && (var(36) != 0)
trigger2 = ifelse(!(playerID(var(35)), alive), ifelse(facing = -1, (pos x < playerID(var(36)), pos x), (pos x > playerID(var(36)), pos x)), 0)
trigger3 = numenemy = 2
trigger3 = (var(35) != 0) && (var(36) != 0)
trigger3 = ifelse(!(playerID(var(36)), alive), ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x)), 0)
trigger4 = (command = "holdback")
value = 5 + (statetype != S)

[State 131, Turn controls]
type = Turn
triggerall = ifelse(var(16) >= 5, command = "holdz", 1)
triggerall = (command != "holdfwd")
trigger1 = numenemy = 1
trigger1 = ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x))
trigger2 = numenemy = 2
trigger2 = (var(35) != 0) && (var(36) != 0)
trigger2 = ifelse(!(playerID(var(35)), alive), ifelse(facing = -1, (pos x < playerID(var(36)), pos x), (pos x > playerID(var(36)), pos x)), 0)
trigger3 = numenemy = 2
trigger3 = (var(35) != 0) && (var(36) != 0)
trigger3 = ifelse(!(playerID(var(36)), alive), ifelse(facing = -1, (pos x < playerID(var(35)), pos x), (pos x > playerID(var(35)), pos x)), 0)
trigger4 = (command = "holdback")

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

[State 131, Lo to Hi]
type = ChangeState
triggerall = !var(0)
trigger1 = statetype = C && command != "holddown"
value = 130

;[State 131, Stop Guarding]
;type = ChangeState
;trigger1 = command != "holdz"
;trigger1 = ifelse(var(16) >= 5, !InGuardDist, 1)
;trigger1 = command = "AFF"
;value = 100

;[State 131, Stop Guarding]
;type = ChangeState
;trigger1 = command != "holdz"
;trigger1 = ifelse(var(16) >= 5, !InGuardDist, 1)
;trigger1 = command = "ABB"
;value = 105

[State 131, Stop Guarding]
type = ChangeState
triggerall = !var(0)
trigger1 = command != "holdz"
trigger1 = ifelse(var(16) >= 5, !InGuardDist, 1)
value = 140
ctrl = 1

;---------------------------------------------------------------------------
; AIR GUARD (guarding)
[Statedef 132]
type    = A
physics = N
ctrl = 0

[State 132, AI Guard Time]
type = VarAdd
trigger1 = prevstateno != 132 || time > 0
v = 17
value = 1

[State 132, 1]
type = ChangeAnim
trigger1 = Time = 0
value = 132

[State 132, Air Turn]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = vel X < 0
value = 827

[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, Stop Guarding]
type = ChangeState
triggerall = !var(0)
trigger1 = command != "holdz"
;trigger1 = ifelse(var(16) >= 5, ifelse(vel x < 0, (command != "holdfwd"), (command != "holdback")) && !InGuardDist, 1)
value = 140
ctrl = 1

[State 132, 6]
type = ChangeState
trigger1 = sysvar(0)
;trigger2 = command = "holdback"
;trigger2 = inguarddist
value = 130

;---------------------------------------------------------------------------
; GUARD (end)
[Statedef 140]
type = U    ;Leave state type unchanged
physics = U ;Leave physics unchanged
ctrl = 1

[State 140, AI Guard Time Reset]
type = VarSet
trigger1 = time = 0
v = 17
value = 0

[State 140, No auto turn]
type = AssertSpecial
trigger1 = 1
flag = noautoturn
ignorehitpause = 1

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

[State 140, Air Turn]
type = ChangeAnim
trigger1 = statetype = A
trigger1 = Time = 0
trigger1 = vel X < 0
value = 832

[State 140, 2]
type = StateTypeSet
trigger1 = Time = 0 && statetype = S
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, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown"
statetype = C
physics = C

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

[State 140, 5]
type = ChangeAnim
trigger1 = statetype = A
trigger1 = AnimTime = 0
trigger1 = vel X >= 0
value = 41

[State 140, 6]
type = ChangeAnim
trigger1 = statetype = A
trigger1 = AnimTime = 0
trigger1 = vel X < 0
value = 43

[State 120, Stop Guarding]
type = ChangeState
triggerall = !var(0)
trigger1 = ifelse(var(16) >= 5, !InGuardDist, 1)
trigger1 = command = "AFF" || command = "ABB"
trigger1 = command != "holdup"
trigger1 = statetype != A
value = 100

;[State 120, Stop Guarding]
;type = ChangeState
;trigger1 = ifelse(var(16) >= 5, !InGuardDist, 1)
;trigger1 = command = "ABB"
;trigger1 = command != "holdup"
;trigger1 = statetype != A
;value = 105

;[State 140, 7] ;Implemented within engine
;type = ChangeState
;trigger1 = AnimTime = 0
;value = (statetype = C)*11 + (statetype = A)*50

;---------------------------------------------------------------------------
; SGUARDHIT (shaking)
[Statedef 150]
type    = S
movetype= H
physics = N
velset = 0,0
ctrl = 0

[State 150, AI Guard Time Reset]
type = VarSet
trigger1 = 1
v = 17
value = 0

[State 150, 1]
type = ChangeAnim
trigger1 = 1
value = 150

[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

[State 150, 3]
type = ForceFeedback
trigger1 = time = 0
waveform = square
time = 3

;---------------------------------------------------------------------------
; SGUARDHIT2 (knocked back)
[Statedef 151]
type    = S
movetype= H
physics = S
anim = 150
ctrl = 0

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

[State 151, 2]
type = VelSet
trigger1 = Time = GetHitVar(slidetime)
trigger2 = HitOver
x = 0

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

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

[State 151, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C && command != "holddown"
statetype = S
physics = S
	
;[State 151, Guard Cancel]
;type = ChangeState
;trigger1 = AnimTime > -18
;trigger1 = (var(0) = [200,220]) || (var(0) = [400,420]) || (var(0) = [800,801])
;value = var(0) 

[State 151, 4]
type = ChangeState
trigger1 = HitOver
value = 130

;---------------------------------------------------------------------------
; CGUARDHIT (shaking)
[Statedef 152]
type    = C
movetype= H
physics = N
velset = 0,0
ctrl = 0

[State 142, AI Guard Time Reset]
type = VarSet
trigger1 = 1
v = 17
value = 0

[State 152, 1]
type = ChangeAnim
trigger1 = 1
value = 151

[State 152, 3]
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

[State 152, 4]
type = ForceFeedback
trigger1 = time = 0
waveform = square
time = 4

;---------------------------------------------------------------------------
; CGUARDHIT2 (knocked back)
[Statedef 153]
type    = C
movetype= H
physics = C
anim = 151
ctrl = 0

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

[State 153, 2]
type = VelSet
trigger1 = Time = GetHitVar(slidetime)
trigger2 = HitOver
x = 0

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

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

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

[State 153, 4]
type = ChangeState
trigger1 = HitOver
value = 131

;---------------------------------------------------------------------------
; AGUARDHIT (shaking)
[Statedef 154]
type    = A
movetype= H
physics = N
velset = 0,0
ctrl = 0

[State 154, AI Guard Time Reset]
type = VarSet
trigger1 = 1
v = 17
value = 0

[State 154, 1]
type = ChangeAnim
trigger1 = 1
value = 152

[State 150, Air Turn]
type = ChangeAnim
trigger1 = statetype = A
trigger1 = Time = 0
trigger1 = vel X < 0
value = 837

[State 154, 2]
type = ChangeState
trigger1 = HitShakeOver
value = 155 ;AGUARDHIT2

[State 154, 3]
type = ForceFeedback
trigger1 = time = 0
waveform = square
time = 4

;---------------------------------------------------------------------------
; AGUARDHIT2 (knocked away)
[Statedef 155]
type    = A
movetype= H
physics = N
ctrl = 0

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

[State 155, 2]
type = VelAdd
trigger1 = 1
y = Const(movement.yaccel)

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

[State 155, 4]
type = VarSet
trigger1 = 1
sysvar(0) = (pos y >= 0) && (vel y > 0)

[State 155, 5]
type = VelSet
trigger1 = sysvar(0)
y = 0

[State 155, 6]
type = PosSet
trigger1 = sysvar(0)
y = 0

[State 155, 6]
type = ChangeState
triggerall = sysvar(0)
trigger1 = command = "holdz"
trigger2 = command = "holdback"
trigger2 = inguarddist
value = 130

[State 155, 7]
type = ChangeState
trigger1 = sysvar(0)
value = 52

;---------------------------------------------------------------------------
; HITG_SHAKE
[Statedef 5000]
type    = S
movetype= H
physics = N
velset = 0,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

[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) ;5051 - 4 + type

[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

;---------------------------------------------------------------------------
; HITA_SHAKE
[Statedef 5020]
type    = U
movetype= H
physics = N
velset = 0,0

[State 921, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

[State 5020, Not in the Air lol]
type = SelfState
triggerall = time = 0
trigger1 = pos y >= 0
trigger2 = (!alive) && (statetype != A)
value = (5000 + (10 * (statetype = C)))
ignorehitpause = 1

[State 5020, StateTypeSet]
type = StateTypeSet
trigger1 = time = 0
statetype = A
ignorehitpause = 1

[State 5020, Hit Ceiling]
type = PosSet
trigger1 = enemy(0), SelfAnimExist(66167100)
;trigger1 = enemy(0), numhelper(789) > 0
trigger1 = Floor(pos y - Const(size.height)) < Floor(enemy(0), fvar(22))
y = enemy(0), fvar(22) + Const(size.height)
ignorehitpause = 1

[State 5020, Hit Ceiling]
type = PosSet
trigger1 = numenemy = 2
trigger1 = !(enemy(0), SelfAnimExist(66167100))
trigger1 = enemy(1), SelfAnimExist(66167100)
;trigger1 = enemy(1), numhelper(789) > 0
trigger1 = Floor(pos y - Const(size.height)) < Floor(enemy(1), fvar(22))
y = enemy(1), fvar(22) + Const(size.height)
ignorehitpause = 1

[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

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

;---------------------------------------------------------------------------
; HITA_SHAKE, Stop falling plz
[Statedef 5021]
type    = U
movetype= H
physics = N
velset = 0,0

[State 5021, 1]
type = HitFallSet
trigger1 = 1
value = 0
ignorehitpause = 1

[State 5021, 2]
type = ChangeState
trigger1 = 1
value = 5020
ignorehitpause = 1

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

[State 921, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

[State 5030, Hit Ceiling]
type = PosSet
trigger1 = enemy(0), SelfAnimExist(66167100)
;trigger1 = enemy(0), numhelper(789) > 0
trigger1 = Floor(pos y - Const(size.height)) < Floor(enemy(0), fvar(22))
y = enemy(0), fvar(22) + Const(size.height)
ignorehitpause = 1

[State 5030, Hit Ceiling]
type = PosSet
trigger1 = numenemy = 2
trigger1 = !(enemy(0), SelfAnimExist(66167100))
trigger1 = enemy(1), SelfAnimExist(66167100)
;trigger1 = enemy(1), numhelper(789) > 0
trigger1 = Floor(pos y - Const(size.height)) < Floor(enemy(1), fvar(22))
y = enemy(1), fvar(22) + Const(size.height)
ignorehitpause = 1

[State 5030, 1]
type = VelAdd;Gravity
trigger1 = 1
y = ifelse((GetHitVar(yaccel) = .35), .1875, GetHitVar(yaccel)) ; Const(movement.yaccel)

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

[State 5030, 2]
type = VelSet
triggerall = !HitFall
trigger1 = HitOver
trigger1 = Pos Y < 10
y = 0

[State 5030, AnimFreeze]
type = ChangeAnim
trigger1 = AnimTime = -1
value = anim
elem = AnimElemNo(0)

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

[State 5030, 3]
type = SelfState
triggerall = !HitFall
triggerall = Alive
trigger1 = HitOver
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= 10  ;.
value = 50 ;5040 ;HITA_RECOV

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

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

[State 921, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

[State 5035, Hit Ceiling]
type = PosSet
trigger1 = enemy(0), SelfAnimExist(66167100)
;trigger1 = enemy(0), numhelper(789) > 0
trigger1 = Floor(pos y - Const(size.height)) < Floor(enemy(0), fvar(22))
y = enemy(0), fvar(22) + Const(size.height)
ignorehitpause = 1

[State 5035, Hit Ceiling]
type = PosSet
trigger1 = numenemy = 2
trigger1 = !(enemy(0), SelfAnimExist(66167100))
trigger1 = enemy(1), SelfAnimExist(66167100)
;trigger1 = enemy(1), numhelper(789) > 0
trigger1 = Floor(pos y - Const(size.height)) < Floor(enemy(1), fvar(22))
y = enemy(1), fvar(22) + Const(size.height)
ignorehitpause = 1

[State 5035, 1]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = HitFall
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, 1]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = HitFall
trigger1 = !SelfAnimExist(5035)
trigger1 = AnimTime = -1
value = anim
elem = AnimElemNo(0)

[State 5035, AnimFreeze]
type = ChangeAnim
trigger1 = AnimTime = -1
value = anim
elem = AnimElemNo(0)

[State 5035, 1]
type = VelAdd;Gravity
trigger1 = 1
y = ifelse((GetHitVar(yaccel) = .35), .1875, GetHitVar(yaccel)) ; Const(movement.yaccel)

[State 5035, 2]
type = VelSet
triggerall = !HitFall
trigger1 = HitOver
trigger1 = Pos Y < 10
y = 0

[State 5035, 3]
type = SelfState
triggerall = !HitFall
trigger1 = HitOver  ;Hit is over
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= 10  ;.
value = 50 ;Jump Up

[State 5035, 4]
type = SelfState
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

;---------------------------------------------------------------------------
; HITA_RECOV (recovering in air, not falling)
[Statedef 5040]
type    = A
movetype= H
physics = N

[State 921, Damage Cancel]
type = ChangeState
triggerall = !AILevel
trigger1 = SelfAnimExist(66167100)
trigger1 = command = "DC"
trigger1 = power >= 1000
trigger1 = alive
trigger1 = movetype = H
trigger1 = var(14) = 1
value = 950

[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, 5]
type = VelAdd
trigger1 = 1
y = Const(movement.yaccel) ; GetHitVar(yaccel)

[State 5040, 6]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 52 ;JUMPLAND

;---------------------------------------------------------------------------
; HITA_FALL (knocked up, falling)
[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

[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

[State 5050, 3]
type = Null;NotHitBy
trigger1 = !CanRecover
trigger1 = Vel Y >= 1
value = SCA
time = 1

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

[State 5050, land pos y] ;Don't go through the floor
type = PosSet
trigger1 = pos y >= 0
y = 0

[State 5050, 4] ;Recover near ground
type = ChangeState
triggerall = Vel Y > 0
triggerall = Pos Y >= -20
triggerall = alive
triggerall = CanRecover
;trigger1 = Command = "recovery"
trigger1 = 0
value = 5200 ;HITFALL_RECOVER

[State 5210, 2] ;Turn if not facing opponent
type = Turn
triggerall = Vel Y > -1
triggerall = alive
triggerall = CanRecover
trigger1 = facing = enemynear, facing

[State 5050, 5]; Recover in mid air
type = ChangeState
triggerall = Vel Y > -1
triggerall = alive
triggerall = CanRecover
;trigger1 = Command = "recovery"
trigger1 = 1
value = 50 ; 5210 ;HITFALL_AIRRECOVER

[State 5050, 6]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0 ;ifelse((anim = [5051,5059]) || (anim = [5061,5069]), 0, 25)
value = 5100 ;HIT_BOUNCE

;---------------------------------------------------------------------------
; HIT_BOUNCE (hit ground)
[Statedef 5100]
type    = L
movetype= H
physics = N

[State 5100, Dust]
type = Explod
trigger1 = time = 0
anim = 949
ID = 949
pos = -10, 10
postype = p1
facing = 1
bindtime = 1
vel = 0, 0
removetime = -2
supermovetime = 0
pausemovetime = 0
scale = 4, 1
sprpriority = 5
ownpal = 1
ignorehitpause = 1

[State 5100, Sound]
type = PlaySnd
trigger1 = time = 0
value = 10,7

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

;---------------------------------------------------------------------------
; HIT_BOUNCE (bounce into air)
[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

[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, 3]
type = VelSet
trigger1 = Time = 0
y = vel y / 1.5

[State 5101, 4]
type = Null;PosSet
trigger1 = Time = 0
y = 20

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

[State 5101, 6] ;Hit ground
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
type = ChangeState
value = 5110

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

[State 5100, Sound]
type = PlaySnd
trigger1 = time = 0
value = 10,7

[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, 7]
type = Null;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, Normal Wake Up] ;For normal wake up
type = ChangeState
triggerall = alive
triggerall = Anim != [5111,5119]
;triggerall = command != "holdfwd"
;triggerall = command != "holdback"
trigger1 = time >= 20
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground frame
value = 5120

[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.89

[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

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

[State 5110, Jump Toward Wake Up] ;For jump toward
type = ChangeState
triggerall = command != "holdback"
triggerall = command = "holdfwd"
trigger1 = time = 0
value = 850

[State 5110, Jump Away Wake Up] ;For jump away
type = ChangeState
triggerall = command != "holdfwd"
triggerall = command = "holdback"
trigger1 = time = 0
value = 852

; This isn't working in state -1
[State -1, AI Jump Toward Wake Up]
type = ChangeState
triggerall = var(0)
trigger1 = time = 0
trigger2 = random % 5
value = 850

[State 5120, Sound]
type = PlaySnd
trigger1 = time = 0
value = 10,12
channel = 0

[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, 3]
type = NotHitBy
trigger1 = AnimTime = 0
value2 = SCA
time = 2

[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

;---------------------------------------------------------------------------
; HIT_AIRFALLRECOVER
[Statedef 5210]
type    = A
movetype= I
physics = N
ctrl = 0

[State 5210, 5] ;Air
type = ChangeState
trigger1 = time = 0
value = 50
ctrl = 1
