
;============================
; Overide Common States
;============================
;<><><><<><><><><>>>><><><><<><><<><>><<>><<<>>><<><><<><><><<><<><<<<><><><>>><<<>><><><><
; HIT_FALLRECOVER (on the ground)
[Statedef 5201]
type    = S
movetype= H
physics = S
anim = 5200
ctrl = 0

[State 5201, snd]
type = PlaySnd
trigger1 = Time = 0
value = 5,3
channel = 0

[State 5201, 1] ;Turn if not facing opponent
type = Turn
trigger1 = Time = 0
trigger1 = P2Dist X < -5

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

[State 5201, 2.1]
type = VelSet
trigger1 = Time >= 5
trigger1 = Time <= 12
x = -5

[State 5201, 3]
type = PosSet
trigger1 = Time = 0
y = 0

[State 5201, 4]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 5201, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
;-------------------------------

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

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

[State 150, GCRUSH CODE]
type = ChangeState
trigger1 = var(12) >= 1000 && time = 0
value = 307
ctrl = 0

[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

[State 150, GCRUSH CODE]
type = VarAdd
trigger1 = GetHitVar(slidetime) <= 0 && GetHitVar(hittime) <= 0 && time = 0 && var(12) <= 999
persistent = 0
var(12) = 125
persistent = 0
ignorehitpause = 1 

[State 150, GCRUSH CODE]
type = VarAdd
trigger1 = (GetHitVar(slidetime) = [1,16]) && (GetHitVar(hittime) = [1,16]) && time = 0 && var(12) <= 999
persistent = 0
var(12) = ifelse((Gethitvar(slidetime) = [1,9]),50,75)
ignorehitpause = 1 

[State 150, GCRUSH CODE]
type = VarAdd
trigger1 = GetHitVar(slidetime) >= 17 && GetHitVar(hittime) >= 17 && time = 0 && var(12) <= 999
persistent = 0
var(12) = 100
persistent = 0
ignorehitpause = 1 

;---------------------------------------------------------------------------

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

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

[State 152, GCRUSH CODE]
type = ChangeState
trigger1 = var(12) >= 1000 && time = 0
value = 307
ctrl = 0

[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

[State 152, GCRUSH CODE]
type = VarAdd
trigger1 = GetHitVar(slidetime) <= 0 && GetHitVar(hittime) <= 0 && time = 0 && var(12) <= 999
persistent = 0
var(12) = 125
persistent = 0
ignorehitpause = 1 

[State 152, GCRUSH CODE]
type = VarAdd
trigger1 = (GetHitVar(slidetime) = [1,16]) && (GetHitVar(hittime) = [1,16]) && time = 0 && var(12) <= 999
persistent = 0
var(12) = ifelse((Gethitvar(slidetime) = [1,9]),50,75)
ignorehitpause = 1 

[State 152, GCRUSH CODE]
type = VarAdd
trigger1 = GetHitVar(slidetime) >= 17 && GetHitVar(hittime) >= 17 && time = 0 && var(12) <= 999
persistent = 0
var(12) = 100
persistent = 0
ignorehitpause = 1 

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

[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 = 1
value = 0

[State 5040, 4]
type = StateTypeSet
trigger1 = HitOver
movetype = I

[State 5040, 5]
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

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














;----------------------------------------------------------------------
; HIT_TRIP (shaking)
[Statedef 5070]
type    = A
movetype= H
physics = N
velset = 0,0

[State 5070, DIZZY CODE]
type = Varset
trigger1 = prevstateno = 5250
trigger1 = time = 0
var(11) = 0
persistent = 0
ignorehitpause = 1 

[State 5070, DIZZY CODE]
type = VarAdd
trigger1 = prevstateno != 5250
trigger1 = time = 0
var(11) = 50
persistent = 0
ignorehitpause = 1 

[State 5070, EXTRA MODE]
type = VarAdd
trigger1 = prevstateno != 5250
trigger1 = time = 0
var(18) = 50
persistent = 0
ignorehitpause = 1 

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

[State 5070, 2]
type = ChangeState
trigger1 = var(37) > 0
trigger1 = time = 0
value = 5000
ctrl = 0

[State 5070, 2]
type = ChangeState
trigger1 = var(37) <= 0
trigger1 = HitShakeOver
value = 5071

[State 5070, 3]
type = ForceFeedback
trigger1 = Time = 0
time = 12
waveform = sinesquare
ampl = 140

;---------------------------------------------------------------------------
; HIT_TRIP2 (fall through air)
[Statedef 5071]
type    = A
movetype= H
physics = N

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

[State 5071, 2] ;Acceleration
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

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

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

[State 5071, 3] ;Hit ground
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 15
type = ChangeState
value = 5100

;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; HITG_SHAKE
[Statedef 5000]
type    = S
movetype= H
physics = N
velset = 0,0
ctrl = 0

;----------------------------------------
[State 5000, DIZZY CODE]
type = Varset
trigger1 = prevstateno = 5250
trigger1 = time = 0
var(11) = 0
persistent = 0
ignorehitpause = 1 

[State 5000, DIZZY CODE]
type = VarAdd
trigger1 = prevstateno != 5250
trigger1 = time = 0
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) = 0 
var(11) = 50
persistent = 0
ignorehitpause = 1 

[State 5000, DIZZY CODE]
type = VarAdd
trigger1 = prevstateno != 5250
trigger1 = time = 0
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) = 1 
var(11) = 100
persistent = 0
ignorehitpause = 1 

[State 5000, DIZZY CODE]
type = VarAdd
trigger1 = prevstateno != 5250
trigger1 = time = 0
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) = 2 
var(11) = 125
persistent = 0
ignorehitpause = 1 

[State 5000, DIZZY CODE]
type = VarAdd
trigger1 = prevstateno != 5250
trigger1 = time = 0
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) >= 3 
var(11) = 75
persistent = 0
ignorehitpause = 1 

[State 5120, 7]
type = ChangeState
trigger1 = prevstateno != 5250
trigger1 = var(11) >= 1000
trigger1 = HitShakeOver
value = 5249
ctrl = 0
;-----------------------------------------

;----------------------------------------
; Play "ouch" sound when hit light or medium
[State 5000, ouch]
type = PlaySnd
triggerall = Random < 400
triggerall = Time = 1
trigger1 = GetHitVar(animtype) = [0,1]
value = 9,1
volume = -10

; Play "ouch" sound when hit hard
[State 5000, ouch2]
type = PlaySnd
triggerall = Random < 400
triggerall = Time = 1
trigger1 = GetHitVar(animtype) = [2,5]
value = 9,2
volume = -10

[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 = var(37) > 0
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5002

[State 5000, 3] ;Anim for HIT_UP/HIT_DIAGUP (only if it exists)
type = ChangeAnim
trigger1 = var(37) > 0
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5002

[State 5000, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = var(37) <= 0
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 = var(37) <= 0
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)
trigger2 = var(37) > 0
trigger2 = Time >= Floor(GetHitVar(hittime) * 0.3)
trigger2 = life > 0
value = 5001 ;HITG_SLIDE

[State 5000, 7]
type = ChangeState
triggerall = HitShakeOver
trigger1 = var(37) <= 0
trigger2 = life <= 0
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

;--------------------------------------------------------------------------
; HITG_SLIDE
[Statedef 5001]
type    = S
movetype= H
physics = S

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

[State 5001, 2]
type = ChangeAnim
trigger1 = var(37) <= 0
trigger1 = AnimTime = 0
value = 5005 + GetHitVar(animtype) + (GetHitVar(groundtype)=2)*10

[State 5001, 3] ;Stop sliding back
type = VelMul
trigger1 = Time >= GetHitVar(slidetime)
x = .6

[State 5001, 4]
type = VelSet
trigger1 = HitOver
x = 0

[State 5001, 5]
type = DefenceMulSet
trigger1 = HitOver
value = 1

[State 5001, 6]
type = ChangeState
trigger1 = var(37) > 0
trigger1 = Time >= Floor(GetHitVar(hittime) * 0.3)
value = 0
ctrl = 1

[State 5001, 6]
type = ChangeState
trigger1 = var(37) <= 0
trigger1 = HitOver
value = 0
ctrl = 1

;---------------------------------------------------------------------------


;---------------------------------------------------------------------------
; HITC_SHAKE
[Statedef 5010]
type    = C
movetype= H
physics = N
velset = 0,0

;----------------------------------------
[State 5010, DIZZY CODE]
type = Varset
trigger1 = prevstateno = 5250
trigger1 = time = 0
var(11) = 0
persistent = 0
ignorehitpause = 1 

[State 5010, DIZZY CODE]
type = VarAdd
trigger1 = time = 0
trigger1 = prevstateno != 5250
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) = 0 
var(11) = 50
persistent = 0
ignorehitpause = 1 

[State 5010, DIZZY CODE]
type = VarAdd
trigger1 = time = 0
trigger1 = prevstateno != 5250
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) = 1 
var(11) = 100
persistent = 0
ignorehitpause = 1 

[State 5010, DIZZY CODE]
type = VarAdd
trigger1 = time = 0
trigger1 = prevstateno != 5250
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) = 2 
var(11) = 150
persistent = 0
ignorehitpause = 1 

[State 5010, DIZZY CODE]
type = VarAdd
trigger1 = time = 0
trigger1 = prevstateno != 5250
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) >= 3 
var(11) = 200
persistent = 0
ignorehitpause = 1 

[State 5010, 0]
type = ChangeState
trigger1 = prevstateno != 5250
trigger1 = var(11) >= 1000
trigger1 = HitShakeOver
value = 5249
ctrl = 0
;-----------------------------------------

; Play "ouch" sound when hit light or medium
[State 5010, ouch]
type = PlaySnd
triggerall = Random < 400
triggerall = Time = 1
trigger1 = GetHitVar(animtype) = [0,1]
value = 9,1
volume = -10

; Play "ouch" sound when hit hard
[State 5010, ouch2]
type = PlaySnd
triggerall = Random < 400
triggerall = Time = 1
trigger1 = GetHitVar(animtype) = [2,5]
value = 9,2
volume = -10

[State 5010, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) != [3,5]
value = 5020 + GetHitVar(animtype)

[State 5010, ARMOR1] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = var(37) > 0
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5022

[State 5010, ARMOR2] ;Anim for HIT_UP/HIT_DIAGUP (only if it exists)
type = ChangeAnim
trigger1 = var(37) > 0
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5022 

[State 5010, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = var(37) <= 0
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5030

[State 5010, 3] ;Anim for HIT_UP/HIT_DIAGUP (only if it exists)
type = ChangeAnim
trigger1 = var(37) <= 0
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5047 + GetHitVar(animtype) ;5051 - 4 + type

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

[State 5010, 5] ;State type gets set to aerial if getting hit up
type = StateTypeSet
triggerall = Time = 0
trigger1 = GetHitVar(yvel) != 0 || GetHitVar(fall)
trigger2 = Pos Y != 0
statetype = a

[State 5010, 6]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0 && !GetHitVar(fall)
trigger2 = var(37) > 0
trigger2 = Time >= Floor(GetHitVar(hittime) * 0.3)
trigger2 = life > 0
value = 5011 ;HITC_SLIDE

[State 5010, 7]
type = ChangeState
triggerall = HitShakeOver
trigger1 = var(37) <= 0
trigger2 = life <= 0
value = 5030

[State 5010, FFB Light]
type = ForceFeedback
trigger1 = Anim = 5020
persistent = 0
time = 6
waveform = square

[State 5010, FFB Medium]
type = ForceFeedback
trigger1 = Anim = 5021
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 5010, FFB Hard]
type = ForceFeedback
trigger1 = Anim = 5022
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; HITC_SLIDE
[Statedef 5011]
type    = C
movetype= H
physics = C

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

[State 5011, 2]
type = ChangeAnim
trigger1 = var(37) <= 0
trigger1 = AnimTime = 0
value = 5025 + GetHitVar(animtype)

[State 5011, 3] ;Stop sliding back
type = VelMul
trigger1 = Time >= GetHitVar(slidetime)
x = .6

[State 5011, 4]
type = VelSet
trigger1 = HitOver
x = 0

[State 5011, 5]
type = DefenceMulSet
trigger1 = HitOver
value = 1

[State 5011, 6]
type = ChangeState
trigger1 = var(37) > 0
trigger1 = Time >= Floor(GetHitVar(hittime) * 0.3)
value = 11
ctrl = 1

[State 5011, 6]
type = ChangeState
trigger1 = var(37) <= 0
trigger1 = HitOver
value = 11
ctrl = 1

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

;----------------------------------------
[State 5020, DIZZY CODE]
type = Varset
trigger1 = prevstateno = 5250
trigger1 = time = 0
var(11) = 0
persistent = 0
ignorehitpause = 1 

[State 5020, DIZZY CODE]
type = VarAdd
trigger1 = time = 0
trigger1 = prevstateno != 5250
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) = 0 
var(11) = 50
persistent = 0
ignorehitpause = 1 

[State 5020, DIZZY CODE]
type = VarAdd
trigger1 = time = 0
trigger1 = prevstateno != 5250
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) = 1 
var(11) = 100
persistent = 0
ignorehitpause = 1 

[State 5020, DIZZY CODE]
type = VarAdd
trigger1 = time = 0
trigger1 = prevstateno != 5250
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) = 2 
var(11) = 150
persistent = 0
ignorehitpause = 1 

[State 5020, DIZZY CODE]
type = VarAdd
trigger1 = time = 0
trigger1 = prevstateno != 5250
trigger1 = var(11) <= 999
trigger1 = gethitvar(animtype) >= 3 
var(11) = 75
persistent = 0
ignorehitpause = 1 

[State 5020, CS]
type = ChangeState
trigger1 = prevstateno != 5250
trigger1 = var(11) >= 1000
trigger1 = HitShakeOver
value = 5249
ctrl = 0
;-----------------------------------------
; Play "ouch" sound when hit light or medium
[State 5020, ouch]
type = PlaySnd
triggerall = Random < 500
triggerall = Time = 1
trigger1 = GetHitVar(animtype) = [0,1]
value = 9,1
volume = -10

; Play "ouch" sound when hit hard
[State 5020, ouch2]
type = PlaySnd
triggerall = Random < 500
triggerall = Time = 1
trigger1 = GetHitVar(animtype) = [2,5]
value = 9,2
volume = -10

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

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

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

; Play "ouch" when landing on back
[State 5100, ouch]
type = PlaySnd
trigger1 = life > 0
trigger1 = random <= 500
trigger1 = Time = 0
value = 9,3
volume = -10

[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 = 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_GETUP
[Statedef 5120]
type    = L
movetype= I
physics = N
ctrl = 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, 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 = var(11) >= 1000
trigger1 = AnimTime = 0
value = 5250
ctrl = 0

[State 5120, 7]
type = ChangeState
trigger1 = var(11) < 1000
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; DIZZY falling
[Statedef 5249]
type    = A
movetype= H
anim = 5050
velset = -4,-6
physics = N

[State 5249, 1]
type = hitvelset
trigger1 = gethitvar(fall)=  1
trigger1 = time = 0
value = 1

[State 5249, 1]
type = nothitby
trigger1 = 1
value = SCA

[State 5249, 2]
type = veladd
trigger1 = time >=0
y = .5

[State 5249, 3]
type = ChangeState
trigger1 = time > 1
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 5100

;--------------------------------------------------------------------------------------
; DIZZY
[Statedef 5250]
type = S
anim = 5300
ctrl = 0

[State 103, 2]
type = ctrlset
trigger1 = 1
value = 0

[State 103, 2]
type = PlaySnd
trigger1 = Time = 0
value = 1,10

[State 5250, VA1]
type = Varadd
trigger1 = 1
trigger1 = var(11) > 0
var(11) = -5

[State 5250, VA2]
type = Varadd
trigger1 = command = "a" ||command = "b" ||command = "c" || command = "d" 
trigger1 = time >= 0
trigger1 = var(11) > 0
var(11) = -150

[State 5250, END]
type = ChangeState
trigger1 = var(11) <= 0
value = 0
ctrl = 1
;---------------------------------------------------------------------------------------


;P1 GUARD CRUSH
[Statedef 307]
type    = S
movetype= I
physics = S
velset = -7,0
anim = 307
ctrl = 0

[State 307, GUARD CRUSH EXPLOD1]
type = Explod
trigger1 = teamside = 1
trigger1 = time = 0
trigger1 = numexplod(309) <= 0
ignorehitpause = 1 
anim = 309
id   = 309
pos = -50,85
postype = right
supermove = 1
bindtime = -1
facing = 1
sprpriority = -4
pausemovetime = 9999999999
supermovetime = 9999999999
ontop = 0
ownpal = 1

[State 307, GUARD CRUSH EXPLOD2]
type = Explod
trigger1 = teamside = 2
trigger1 = time = 0
trigger1 = numexplod(309) <= 0
ignorehitpause = 1 
anim = 309
id   = 309
pos = 50,85
postype = left
supermove = 1
bindtime = -1
facing = 1
sprpriority = -4
pausemovetime = 9999999999
supermovetime = 9999999999
ontop = 0
ownpal = 1

[State 307, MD]
type = makedust
Trigger1 = 1
pos = 0,0
spacing = 3

[State 307, MD]
type = varset
Trigger1 = time = 0
var(12) = 0

[State 307, END]
type = changestate
Trigger1 = AnimTime = 0
value = 0
ctrl = 1

;--------------------------------------------------------------



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

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

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

[State 1022, 5]
type = ChangeState
trigger1 = HitShakeOver
value = 1023

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

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

[State 1022, 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_UP (initial going up)
[Statedef 1023]
type    = A
movetype= H
physics = N
ctrl = 0

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

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

[State 1023, 3]
type = ChangeState
trigger1 = HitOver
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= 0  ;.
value = 1025 ;HITA_FALL

[State 1023, 4]
type = ChangeState
trigger1 = AnimTime = 0
value = 1024 ;HITA_UP (transition)

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

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

[State 1024, 3]
type = ChangeState
trigger1 = HitOver  ;Hit is over
trigger2 = AnimTime = 0 ;Anim is over
trigger3 = Vel Y > 0    ;Hit ground
trigger3 = Pos Y >= 0  ;.
trigger4 = Time = 0     ;No transition anim
trigger4 = Anim != 5035 ;.
value = 1028 ;HITA_FALL
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; HITA_FALL (knocked up, falling)
[Statedef 1028]
type    = A
movetype= H
physics = N

[State 1028, 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 1028, 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 1028, 3] ;Gravity
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 1028, 4]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 1026 ;HIT_BOUNCE

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

[State 1025, 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 1025, 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 1025, 3] ;Gravity
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 1025, 4]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 1026 ;HIT_BOUNCE

;---------------------------------------------------------------------------

;-----------------------------------
;subsob
[Statedef 1026]
type    = S
movetype= H
physics = N

[State 1026, VelSet]
type = VelSet
trigger1 = Time = 0
trigger1 =  Vel x > 0
x = 4
y = 0

[State 1026, VelSet]
type = VelSet
trigger1 = Time = 0
trigger1 =  Vel x < 0
x = -4
y = 0

[State 1026, NH]
type = NotHitBy
trigger1 = Time >= 0
value = SCA
time = 1

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

[State 1026, var]
type = VarSet
trigger1 = Time = 0
;trigger1 = GetHitVar(fall.yvel) = 0
sysvar(1) = Floor(Vel y)

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

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

[State 1026, 3] ;Reduce speed
type = VelMul
trigger1 = Time = 0
x = 0.75

[State 1026, 4]
type = GameMakeAnim
trigger1 = Time = 1
value = 61
pos = 0, 0
under = SysVar(1) <= 10

[State 1026, 5]
type = HitFallDamage
trigger1 = Time = 3

[State 1026, 6]
type = PlaySnd
trigger1 = Time = 1
;value = F7, 0 ;Hit ground
value = F7, (SysVar(1) > 5) + (SysVar(1) > 14)

[State 1026, 7]
type = ChangeState
trigger1 = Time = 20
value = 1027

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

; HIT_LIEDOWN
[Statedef 1027]
type    = L
movetype= H
physics = N
ctrl = 0

[State 1027, SCRN]
type = ScreenBound
trigger1 = Time >= 0
value = 1
movecamera = 1,0

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

9[State 1027, 1]
type = HitFallDamage
trigger1 = Time = 0

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

[State 5100, 3]
type = ChangeAnim
trigger1 = Time = 0
value = 5110

[State 1027, var] ;Get fall velocity
type = VarSet
trigger1 = Time = 0
trigger1 = GetHitVar(fall.yvel) != 0
sysvar(1) = Floor(Vel y)

[State 1027, 4]
type = VelSet
trigger1 = Time = 0
y = 0

[State 1027, 5] ;If just died
type = SelfState
triggerall = !Alive
trigger1 = AnimTime = 0
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground frame
trigger3 = Anim = [5110,5119]
value = 5150

[State 1027, 6]
type = SelfState
triggerall = Alive
trigger1 = Time = 50
value = 5120

[State 1027, 7]
type = VarSet
trigger1 = SysVar(0)
trigger1 = Time = 0
sysvar(0) = 0

[State 1027, 8] ;Friction
type = VelMul
trigger1 = 1
x = 0.85

[State 1027, 9]
type = ForceFeedback
trigger1 = Alive
trigger1 = Time = 0
time = 8
ampl = 240
waveform = sine

[State 1027, 10]
type = ForceFeedback
trigger1 = !Alive
trigger1 = Time = 0
ampl = 200, 7, -.467
time = 30
waveform = sine
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; SLAM FACE DOWN shaking
[Statedef 1103]
type    = S
movetype= H
physics = N
velset = 0,0

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

[State 5000, 3] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5000, 5]
type = ChangeState
trigger1 = HitShakeOver
value = 1104

[State 5000, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5012
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

;---------------------------------------------------------------------------

;-----------------------------------
;subsob
[Statedef 1104]
type    = A
movetype= H
physics = N
velset = 0,0

[State 1104, Envshake]
type = envshake
Trigger1 = time = 0
time = 9
ampl = -3
freq = 110

[State 1104, posadd]
type = posadd
trigger1 = Time = 0
x = -20

[State 1104,1]
type = nothitby
trigger1 = Time >= 0
value = SCA
time = 1

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

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

[State 1104, 2]
type = ChangeAnim
triggerall = time = 0
trigger1 = SelfAnimExist(5102)
value = 5102

[State 1104, 2]
type = ChangeAnim
triggerall = time = 0
trigger1 = SelfAnimExist(5101)
trigger1 = !SelfAnimExist(5102)
value = 5101

[State 1104, 2]
type = ChangeAnim
triggerall = time = 0
trigger1 = !SelfAnimExist(5101)
trigger1 = !SelfAnimExist(5102)
value = 5100

[State 1104, 4]
type = PosSet
trigger1 = Time = 0
y = 0

[State 1104, 6] ;Reduce speed
type = VelMul
trigger1 = Time = 0
x = 0.75

[State 1104, 8]
type = GameMakeAnim
trigger1 = Time = 1
value = 61
pos = 0, 0
under = sysvar(1) <= 10

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

[State 1104, 10]
type = PlaySnd
trigger1 = Time = 1
;value = F7, 0 ;Hit ground
value = F7, (sysvar(1) > 5) + (sysvar(1) > 14)

[State 1104, 12]
type = selfState
trigger1 = Time = 10
value = 5101

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


;--------------------------------------
;WIRE DAMAGE SYSTEM :P
;------------------
; Hit by Fast Kung Fu Palm - shaking from the hit
; (a custom gethit state)
[Statedef 3300]
type    = A
movetype= H
physics = N
velset = 0,0

[State 3300, Flash]
type = PalFX
trigger1 = Time % 2
time = 1
add = 0,15,75
color = 0
invertall = 1

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

[State 3300, State]
type = ChangeState
trigger1 = HitShakeOver = 1
value = 3305

;------------------
; Hit by Fast Kung Fu Palm - flying through the air
; (a custom gethit state)
[Statedef 3305]
type    = A
movetype= H
physics = N

[State 3305, Flash]
type = PalFX
trigger1 = Time % 2
time = 1
add = 0,15,75
color = 0
invertall = 1

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

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

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

[State 3305, Hit wall]
type = ChangeState
triggerall = Pos y < -15
trigger1 = BackEdgeBodyDist <= 20
trigger2 = FrontEdgeBodyDist <= 20
value = 3310

[State 3305, Hit ground]
type = SelfState
trigger1 = (Vel y > 0) && (Pos y >= 0)
value = 5100

;------------------
; Hit by Fast Kung Fu Palm - hit wall
; (a custom gethit state)
[Statedef 3310]
type    = A
movetype= H
physics = N

[State 3310, Flash]
type = PalFX
trigger1 = Time % 2
time = 1
add = 0,15,75
color = 0
invertall = 1

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

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

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

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

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

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

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

[State 3310, State]
type = ChangeState
trigger1 = AnimTime = 0
value = 3315

;------------------
; Hit by Fast Kung Fu Palm - bounce off wall
; (a custom gethit state)
[Statedef 3315]
type    = A
movetype= H
physics = N

[State 3315, Flash]
type = PalFX
trigger1 = Time % 2
time = 1
add = 0,15,75
color = 0
invertall = 1

[State 3315, Vel Y]
type = Hitfallset
trigger1 = Time = 0
value = 0

[State 3315, Vel Y]
type = VelSet
trigger1 = Time = 0
y = -11

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

[State 3315, Turn]
type = Turn
trigger1 = (Time = 0) && (BackEdgeDist < 30)

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

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

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

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

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

[State 3315, Hit ground]
type = SelfState
trigger1 = (Vel y > 0) && (Pos y >= 0)
value = 5100


;---------------------------------------------------------------------------
;
; AI activation code by Winane.
; (Credit to ANMC, Bagaliao, and FlowaGirl for the basic helper method concept.)
;
;------------------
; AI Activation Helper State - Primary Version
; (Credit to YongMing for the basic HitPause bugfix concept.)
;
; var(1) - First tick button activation prevention.
; var(2) - Used for pause/superpause and custom state check, basically.
; var(3) - (Super/)Pause & custom state-triggered dir detection disabler.
; var(4) - Persistent direction command detection enabler (due to 2002.04.14).
; var(9) - AutoTurn bug fixer.
; parent's var(58) - Parent's GameTime var, for pause and custom state check.
; parent's var(59) - Parent's primary AI variable.

[StateDef 9741]
type = S
movetype = I
physics = N
anim = 9741
ctrl = 0

[State 9741, Safety]; Just in case your opponent is very poorly coded.
type = SelfState
trigger1 = !IsHelper
value = 0

[State 9741, PauseCheck]
type = VarSet
trigger1 = (GameTime>(Parent,var(58)))
trigger2 = !(Parent,Alive)
trigger3 = (RoundState != 2)
trigger4 = Parent,var(59)
trigger5 = (var(3):=0)
var(2) = (var(3):=1)+(var(4):=0)

[State 9741, Facing]
type = Turn
trigger1 = (var(9):=(Facing != Parent,Facing))

[State 9741, DirTurnOnAI]
type = ParentVarSet
triggerall = !var(3)
triggerall = !var(9)
trigger1 = (Parent,command = "holdfwd")
trigger2 = (Parent,command = "holdback")
trigger3 = (Parent,command = "holdup")
trigger4 = (Parent,command = "holddown")
trigger5 = !(var(4):=1)
var(59) = var(4)

[State 9741, DirTurnOffAI]
type = ParentVarSet
triggerall = !var(3)
triggerall = Parent,var(59)
trigger1 = (command = "holdfwd")
trigger1 = (Parent,command = "holdfwd")
trigger2 = (command = "holdback")
trigger2 = (Parent,command = "holdback")
trigger3 = (command = "holdup")
trigger3 = (Parent,command = "holdup")
trigger4 = (command = "holddown")
trigger4 = (Parent,command = "holddown")
var(59) = (var(4):=0)

[State 9741, ButtonTurnOnAI]
type = ParentVarSet
triggerall = var(1)
triggerall = !var(2)
trigger1 = (Parent,command = "b")
trigger2 = (Parent,command = "d")
trigger3 = (Parent,command = "c1")
trigger4 = (Parent,command = "x")
trigger5 = (Parent,command = "y")
trigger6 = (Parent,command = "z")
trigger7 = (Parent,command = "s")
var(59) = 1

[State 9741, ButtonTurnOffAI]
type = ParentVarSet
triggerall = !var(2)
trigger1 = (command = "b")
trigger1 = (Parent,command = "b")
trigger2 = (command = "d")
trigger2 = (Parent,command = "d")
trigger3 = (command = "c1")
trigger3 = (Parent,command = "c1")
trigger4 = (command = "x")
trigger4 = (Parent,command = "x")
trigger5 = (command = "y")
trigger5 = (Parent,command = "y")
trigger6 = (command = "z")
trigger6 = (Parent,command = "z")
trigger7 = (command = "s")
trigger7 = (Parent,command = "s")
var(59) = -1

[State 9741, UnPauseCheck]
type = VarSet
triggerall = var(2)
trigger1 = (Parent,command = "b")
trigger2 = (Parent,command = "d")
trigger3 = (Parent,command = "c1")
trigger4 = (Parent,command = "x")
trigger5 = (Parent,command = "y")
trigger6 = (Parent,command = "z")
trigger7 = (Parent,command = "s")
trigger8 = (var(2) = 2)
trigger8 = (var(2):=0)
var(2) = 2

[State 9741, Goodbye]
type = DestroySelf
triggerall = (var(1):=1)
trigger1 = Parent,var(59)
trigger2 = !(Parent,Alive)
trigger3 = (RoundState != 2)


;------------------
; AI Activation Helper State - Compatibly Partnered Version
;
; var(1) - First tick dir activation prevention
; var(2) - Used for pause/superpause and custom state check, basically.
; var(3) - (Super/)Pause & custom state-triggered dir detection disabler.
; var(4) - Hitpause check.
; var(5) - No button on previous tick.
; var(6) - Any dir on this tick.
; var(7) - Any button on this tick.
; var(8) - Matching partner button detected.
; var(9) - AutoTurn bug fixer.
; parent's var(58) - Parent's GameTime var, for pause and custom state check.
; parent's var(59) - Parent's primary AI variable.

[StateDef 9742]
type = S
movetype = I
physics = N
anim = 9741
ctrl = 0

[State 9742, Safety]; Just in case your opponent is very poorly coded.
type = SelfState
trigger1 = !IsHelper
value = 0

[State 9742, PauseCheck]
type = VarSet
trigger1 = (GameTime>Parent,var(58))
trigger2 = !(Parent,Alive)
trigger3 = (RoundState != 2)
trigger4 = Parent,var(59)
trigger5 = (var(3):=0)
var(2) = (var(3):=1)

[State 9742, Facing]
type = Turn
trigger1 = (var(9):=(Facing != Parent,Facing))

[State 9742, ParentDirCheck]
type = VarSet
trigger1 = (Parent,command = "holdfwd")
trigger2 = (Parent,command = "holdback")
trigger3 = (Parent,command = "holdup")
trigger4 = (Parent,command = "holddown")
trigger5 = (var(6):=0)
var(6) = 1

[State 9742, ParentButtonCheck]
type = VarSet
trigger1 = (Parent,command = "b")
trigger2 = (Parent,command = "d")
trigger3 = (Parent,command = "c1")
trigger4 = (Parent,command = "x")
trigger5 = (Parent,command = "y")
trigger6 = (Parent,command = "z")
trigger7 = (Parent,command = "s")
trigger8 = (var(7):=0)
var(7) = 1

[State 9742, SameButtonCheck]
type = VarSet
triggerall = var(7)
triggerall = !var(2)
triggerall = NumPartner
trigger1 = (Parent,command = "b")
trigger1 = (Partner,command = "b")
trigger2 = (Parent,command = "d")
trigger2 = (Partner,command = "d")
trigger3 = (Parent,command = "c1")
trigger3 = (Partner,command = "c1")
trigger4 = (Parent,command = "x")
trigger4 = (Partner,command = "x")
trigger5 = (Parent,command = "y")
trigger5 = (Partner,command = "y")
trigger6 = (Parent,command = "z")
trigger6 = (Partner,command = "z")
trigger7 = (Parent,command = "s")
trigger7 = (Partner,command = "s")
trigger8 = (var(8):=0)
var(8) = 1

[State 9742, DirTurnOnAI]
type = ParentVarSet
trigger1 = var(1)
trigger1 = var(6)
trigger1 = !var(3)
trigger1 = !var(4)
trigger1 = !var(9)
var(59) = 1

[State 9742, DirTurnOffAI]
type = ParentVarSet
triggerall = var(6)
triggerall = !var(3)
triggerall = Parent,var(59)
trigger1 = (command = "holdfwd")
trigger1 = (Parent,command = "holdfwd")
trigger2 = (command = "holdback")
trigger2 = (Parent,command = "holdback")
trigger3 = (command = "holdup")
trigger3 = (Parent,command = "holdup")
trigger4 = (command = "holddown")
trigger4 = (Parent,command = "holddown")
var(59) = 0

[State 9742, ButtonTurnOnAI]
type = ParentVarSet
trigger1 = var(5)
trigger1 = var(7)
trigger1 = !var(2)
trigger1 = !var(8)
var(59) = 1

[State 9742, ButtonTurnOffAI]
type = ParentVarSet
triggerall = var(7)
triggerall = !var(2)
triggerall = !var(8)
trigger1 = (command = "b")
trigger1 = (Parent,command = "b")
trigger2 = (command = "d")
trigger2 = (Parent,command = "d")
trigger3 = (command = "c1")
trigger3 = (Parent,command = "c1")
trigger4 = (command = "x")
trigger4 = (Parent,command = "x")
trigger5 = (command = "y")
trigger5 = (Parent,command = "y")
trigger6 = (command = "z")
trigger6 = (Parent,command = "z")
trigger7 = (command = "s")
trigger7 = (Parent,command = "s")
var(59) = -1

[State 9742, UnPauseCheck]
type = VarSet
triggerall = var(2)
triggerall = !var(4)
trigger1 = var(7)
trigger2 = (var(2) = 2)
trigger2 = (var(2):=0)
var(2) = 2

[State 9742, Goodbye]
type = DestroySelf
trigger1 = Parent,var(59)
trigger2 = !(Parent,Alive)
trigger3 = (RoundState != 2)

[State 9742, HitPauseCheck]
type = VarSet
trigger1 = var(6)
trigger2 = var(7)
trigger3 = !(Parent,HitPauseTime)
var(4) = Parent,HitPauseTime

[State 9742, Delay]
type = VarSet
trigger1 = (var(1):=1)
var(5) = !var(7)
