;================================================================================
;                    ANDY BOGARD: Parte 5... Miscellaneous/Varios.
;================================================================================
;Agarre 1: Zamorano Gol!!!
[Statedef 800]
type = S
movetype = A
physics = S
anim = 800; state principal
poweradd = 50
velset = 0
ctrl = 0
juggle = 15

[State 200, 2]
type = HitDef
trigger1 = AnimElem = 1
attr = S, NT
damage = 0
animtype = hard
hitflag = M, miss
guardflag = P
sparkno = -1
guard.sparkno = 40
sparkxy = 0,-60
hitsound = -1
guardsound = -1
pausetime = 0,0
p1stateno = 801; parte P1
p2stateno = 805; parte P2
hit.priority = 1

[State 200, 3]
type = ChangeState
trigger1 = AnimTime = 0
value = 225

;-----------------------------------------------------
;State Player 1
[Statedef 801]
type    = S
movetype= A
physics = N
anim = 801
poweradd =0

[State 1000, 5]
type = Explod
trigger1 = animelemtime(1) = 0
anim = 4090
sprpriority = 1
postype = p1
pos = 35,-83
bindtime = 1
supermove = 1
under = 0

[State 810, Grab Sound]
type = PlaySnd
trigger1 = AnimElem = 1
value = 0,5

; sonidos varios (reemplazar)
[State 810, Throw Sound]
type = PlaySnd
trigger1 = AnimElem = 5
value = 0,1
[State 810, Grab Sound]
type = PlaySnd
trigger1 = AnimElem = 6
value = 1, 1

[state a]
type = sprpriority
trigger1 = AnimElem = 5
value = -1

[state a]
type = velset
trigger1 = animelemtime(5) = 0
y = -10

[state a]
type = veladd
trigger1 = time = [28,999]
y = 0.5

[State 810, Bind 1]
type = TargetBind
trigger1 = animelem = 1
pos = 40, 0

[State 810, Bind 1]
type = TargetBind
trigger1 = animelem = 4
pos = 21, -50

[State 810, Bind 1]
type = TargetBind
trigger1 = animelemtime(5) = [0,999]
pos = 19, -126

[State 810, Bind 1]
type = TargetBind
trigger1 = animelemtime(6) = [0,999]
pos = 32, -102

[State 810, Bind 1]
type = TargetBind
trigger1 = animelemtime(7) = [0,999]
pos = 35, -59

[State 810, State End]
type = ChangeState
trigger1 = Vel Y > 0 && Pos Y >= 0
value = 802

;patada de milico
[Statedef 802]
type    = S
movetype= A
physics = N
anim = 802
velset = 0,0
poweradd =0

[State 810, Grab Sound]
type = PlaySnd
trigger1 = time = 0
value = 0,8
[State 810, Grab Sound]
type = PlaySnd
trigger1 = animelem = 8
value = 200,2

[State 810, Throw 11]
type = TargetState
trigger1 = time = 0
value = 806

[State 810, Bind 1]
type = TargetBind
trigger1 = time = 0
pos = 35, 0

[State 810, Throw 11]
type = TargetState
trigger1 = animelem = 8
value = 807

[State 1000, 5]
type = Explod
trigger1 = animelemtime(8) = 1
anim = 4050
sprpriority = 1
postype = p1
pos = 38,-18
bindtime = 1
supermove = 1
under = 0

[State 1020, 4]
type = EnvShake
trigger1 = time = 0
time = 9
ampl = -8
freq = 95
phase = 95

[State 810, Hurt 11]
type = TargetLifeAdd
trigger1 = time = 0
value = -80
kill = 0

[State 810, Hurt 11]
type = TargetLifeAdd
trigger1 = animelemtime(8) = 2
value = -40

[state a]
type = sprpriority
trigger1 = AnimElem = 4
value = 2

[State 810, State End]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; State Player 2
[Statedef 805]
type    = A
movetype= H
physics = N
velset = 0,0

[State 1]
type = screenbound
trigger1 = time = [0,200]
value = 1
movecamera = 1

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

[Statedef 806]
type    = A
movetype= H
physics = N
velset = 0,0

[State 1]
type = screenbound
trigger1 = time = [0,200]
value = 1
movecamera = 1

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

[Statedef 807]
type    = A
movetype= H
physics = N
velset = -6,-5

[state a]
type = null;velset
trigger1 = animelemtime(8) = 0
x = 6
y = -5

[state a]
type = turn
trigger1 = time = 0

[State 1]
type = screenbound
trigger1 = time = [0,200]
value = 1
movecamera = 1

[state a]
type = veladd
trigger1 = time = [0,999]
y = 0.4

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

[State 9]
type = selfstate
trigger1 = Vel Y > 0 && Pos Y >= 0
value = 5100

;================================================================================
;Agarre 2: el basico
[Statedef 830]
type = S
movetype = A
physics = S
anim = 800
poweradd = 0
velset = 0
ctrl = 0
juggle = 15

[State 200, 2]
type = HitDef
trigger1 = AnimElem = 1
attr = S, NT
damage = 0
animtype = hard
hitflag = M, miss
guardflag = P
sparkno = -1
guard.sparkno = 40
sparkxy = 0,-80
hitsound = -1
guardsound = -1
pausetime = 0,0
p1stateno = 831
p2stateno = 832
hit.priority = 1
hit.getpower = 40

[State 200, 3]
type = ChangeState
trigger1 = AnimTime = 0
value = 235

[Statedef 831]
type    = S
movetype= A
physics = S
anim = 831
juggle = 15
air.juggle = 15

[State 831, 0]
type = Explod
trigger1 = Time = 0
anim = 4090
pos = 37,-86
sprpriority = 3
postype = p1

[State 831, 1]
type = PlaySnd
trigger1 = Time = 0
value = S0,5

[State 831, 1]
type = PlaySnd
trigger1 = Time = 18
value = S1,2

[State 831, 2]
type = TargetBind
trigger1 = AnimElem = 1
pos = 45,-71

[State 831, 3]
type = TargetBind
trigger1 = AnimElem = 2
pos = 44,-59

[State 831, 4]
type = TargetBind
trigger1 = AnimElem = 3
pos = 18,-76

[State 831, 5]
type = TargetBind
trigger1 = AnimElem = 4
pos = -57,-76

;Drop at Animelem 4

[State 831, 6]
type = TargetLifeAdd
trigger1 = AnimElem = 4
value = -110

[State 831, 7]
type = PosAdd
trigger1 = AnimElem = 7
x = -14

[State 831, 8]
type = Turn
trigger1 = AnimTime = 0

[State 810, state]
type = changestate
trigger1 = animtime = 0
value = 0
ctrl = 1
;----------------------------------
; Kakae Komi - Opponent's State
[Statedef 832]
type    = A
movetype= H
physics = N
velset = 0,0
ctrl = 0

[State 832, 0]
type = ChangeAnim2
trigger1 = Time = 0
value = 832

[state turn]
type = turn
triggerall = P2Dist x < 0
trigger1 = time =1
persistent = 1

[State 833, 0]
type = VelAdd
Trigger1 = Time >= 24
y = .4

[State 833, 0]
type = VelSet
trigger1 = Time = 24
x = 5
y = -7

[State 833, 2]
type = ChangeState
triggerall = Vel Y > 0
triggerall = Pos Y >= -20
triggerall = alive
triggerall = CanRecover
trigger1 = Command = "recovery"
value = 5200 ;HITFALL_RECOVER

[State 833, 3]
type = SelfState
triggerall = Vel Y > 0
triggerall = alive
triggerall = CanRecover
trigger1 = Command = "recovery"
value = 5210 ;HITFALL_AIRRECOVER

[State 833, 4]
type = SelfState
trigger1 = Pos Y >= 0
value = 5100 ;Hit ground

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

;---------- JUMP FORWARD (for AI)
; Jump Start
[Statedef 39]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

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

[State 40, 2]
type = VarSet
trigger1 = Time = 0
var(5) = 0

[State 40, 3]
type = VarSet
trigger1 = command = "jump"
trigger2 = prevstateno = 101 && command = "holdfwd"
var(5) = 1

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

[State 40, 6]
type = VelSet
trigger1 = AnimTime = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 10]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;------------------- LONG JUMP (for AI)
; Jump Start
[Statedef 38]
type = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

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

[State 40, 2]
type = VarSet
trigger1 = Time = 0
var(5) = 0

[State 40, 3]
type = VarSet
trigger1 = time = 0
var(5) = 1

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

[State 40, 6]
type = VelSet
trigger1 = AnimTime = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 10]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;------------------------------ RANDOM ANTI AIR ATTACK (FOR AI)
[Statedef 2000]
type = S

[State 3000, choose]
type = VarRandom
trigger1 = time = 0
v = 8
range = 0,3

[State 180, 2]
type = ChangeState
trigger1 = Time = 0
trigger1 = Var(8) = [0,1]
value = 1500

[State 180, 2]
type = ChangeState
trigger1 = Time = 0
trigger1 = Var(8) = [2,3]
value = 1300

[State 180, 2]
type = ChangeState
triggerall = power >=1000
trigger1 = Time = 0
trigger1 = Var(8) = 1
value = 3000

[State 180, 2]
type = ChangeState
triggerall = power >=1000
trigger1 = Time = 0
trigger1 = Var(8) = 2
value = 3300


;------------------------------ RANDOM CLOSE ATTACK (FOR AI)
[Statedef 4001]
type = S

[State 3000, choose]
type = VarRandom
trigger1 = time = 0
v = 8
range = 0,14

[State 180, 2]
type = ChangeState
trigger1 = Time = 0
trigger1 = Var(8) = [0,2]
value = 200

[State 180, 2]
type = ChangeState
trigger1 = Time = 0
trigger1 = Var(8) = [3,6]
value = 210

[State 180, 2]
type = ChangeState
trigger1 = Time = 0
trigger1 = Var(8) = [7,9]
value = 220

[State 180, 2]
type = ChangeState
trigger1 = Time = 0
trigger1 = Var(8) = [10,11]
value = 230

[State 180, 2]
type = ChangeState
trigger1 = Time = 0
trigger1 = Var(8) = [12,14]
value = 430

;------------------------------ RANDOM SPECIAL/HYPER ATTACKS (FOR AI)
[Statedef 4002]
type = S

[State 3000, choose]
type = VarRandom
trigger1 = time = 0
v = 8
range = 0,8

[State 180, 2]
type = ChangeState
triggerall = Time = 0
trigger1 = Var(8) = [0,3]
value = 1300

[State 180, 2]
type = ChangeState
triggerall = Time = 0
trigger1 = Var(8) = [4,6]
value = 1316

[State 180, 2]
type = ChangeState
trigger1 = Time = 0
trigger1 = Var(8) = [7,8]
value = 1030

[State 180, 2]
type = ChangeState
triggerall = Time = 0
trigger1 = Var(8) = [7,8]
value = 1100

[Statedef 6010]
type = S
physics = S
;anim = 6010
poweradd = 0
sprpriority = -1
velset = 0,0
ctrl = 0
facep2 = 1

[State 6010, anim]
type = Changeanim2
trigger1 = time = 0
value = 6010

[State 6010, air]
type = Changestate
trigger1 = pos Y != 0
value = 5000

[State 220, 3]
type = ChangeState
trigger1 = AnimTime = 0
value = 5150

; HIT_LIEDEAD
[Statedef 5150]
type    = L
movetype= H
physics = N
sprpriority = -3

[State 5150, 1]
type = ChangeAnim
triggerall = 1
trigger1 = Prevstateno = 6010
value = 6011

[State 5000, 1]
type = ChangeAnim
trigger1 = time >= 0
trigger1 = NumHelper(6969) = 1
value = 25110

[State 5150, 1] ;Normal anim
type = ChangeAnim
triggerall = NumHelper(6969) = 0
triggerall = var(22) = 0
triggerall = Prevstateno != 6010
triggerall = Time = 0
triggerall = SelfAnimExist(5140)
trigger1 = (anim != [5111,5119]) && (anim != [5171,5179])
trigger2 = !SelfAnimExist(5140 + (anim % 10))
value = 5140

[State 5150, 3] ;Hit up type anim
type = ChangeAnim
triggerall = NumHelper(6969) = 0
triggerall = var(22) = 0
triggerall = Prevstateno != 6010
trigger1 = Time = 0
trigger1 = (anim = [5111,5119]) || (anim = [5171,5179])
trigger1 = SelfAnimExist(5140 + (anim % 10))
value = 5140 + (anim % 10)

[State 5150, 4] ;Match over anim
type = ChangeAnim
triggerall = NumHelper(6969) = 0
triggerall = var(22) = 0
triggerall = Prevstateno != 6010
persistent = 0
;trigger1 = Time = 0
trigger1 = MatchOver = 1
trigger1 = Anim = [5140,5149]
trigger1 = SelfAnimExist(anim+10)
value = anim+10

[State 5150, 5] ;Switch to 5110 if liedead anim does not exist
type = ChangeAnim
triggerall = NumHelper(6969) = 0
triggerall = var(22) = 0
triggerall = Prevstateno != 6010
trigger1 = Time = 0
trigger1 = Anim != [5140,5159]
trigger1 = Anim != [5110,5119]
value = 5110

[State 5150, 1] ;Normal anim
type = ChangeAnim
triggerall = NumHelper(6969) = 0
triggerall = var(22) != 0
triggerall = Prevstateno != 6010
triggerall = Time = 0
triggerall = SelfAnimExist(15140)
trigger1 = (anim != [15111,15119]) && (anim != [15171,15179])
trigger2 = !SelfAnimExist(15140 + (anim % 10))
value = 15140

[State 5150, 3] ;Hit up type anim
type = ChangeAnim
triggerall = NumHelper(6969) = 0
triggerall = var(22) != 0
triggerall = Prevstateno != 6010
trigger1 = Time = 0
trigger1 = (anim = [15111,15119]) || (anim = [15171,15179])
trigger1 = SelfAnimExist(15140 + (anim % 10))
value = 15140 + (anim % 10)

[State 5150, 4] ;Match over anim
type = ChangeAnim
triggerall = NumHelper(6969) = 0
triggerall = var(22) != 0
triggerall = Prevstateno != 6010
persistent = 0
;trigger1 = Time = 0
trigger1 = MatchOver = 1
trigger1 = Anim = [15140,15149]
trigger1 = SelfAnimExist(anim+10)
value = anim+10

[State 5150, 5] ;Switch to 5110 if liedead anim does not exist
type = ChangeAnim
triggerall = NumHelper(6969) = 0
triggerall = var(22) != 0
triggerall = Prevstateno != 6010
trigger1 = Time = 0
trigger1 = Anim != [15140,15159]
trigger1 = Anim != [15110,15119]
value = 15110

[State 5150, 6] ;Friction
type = VelMul
trigger1 = 1
x = 0.85

[State 5150, 7] ;Friction
type = VelSet
trigger1 = Vel x < .05
persistent = 0
x = 0

[State 5150, 8]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

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

[State 5000, 1]
type = ChangeAnim
trigger1 = time >= 0
trigger1 = NumHelper(6969) = 1
value = 25030

[State 5000, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
triggerall = NumHelper(6969) = 0
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
triggerall = NumHelper(6969) = 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
triggerall = NumHelper(6969) = 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)
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    = A
movetype= H
physics = N
velset = 0,0

[State 5000, 1]
type = ChangeAnim
trigger1 = time >= 0
trigger1 = NumHelper(6969) = 1
value = 25030
ignorehitpause

[State 5020, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
triggerall = NumHelper(6969) = 0
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
triggerall = NumHelper(6969) = 0
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
triggerall = NumHelper(6969) = 0
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_UP (initial going up)
[Statedef 5030]
type    = A
movetype= H
physics = N
ctrl = 0

[State 5000, 1]
type = ChangeAnim
trigger1 = time >= 0
trigger1 = NumHelper(6969) = 1
value = 25030

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

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

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

[State 5030, 4]
type = ChangeState
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 5000, 1]
type = ChangeAnim
trigger1 = time >= 0
trigger1 = NumHelper(6969) = 1
value = 25035

[State 5035, 1]
type = ChangeAnim
triggerall = NumHelper(6969) = 0
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 5035, 2]
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5035, 3]
type = ChangeState
triggerall = !HitFall
trigger1 = HitOver  ;Hit is over
trigger2 = AnimTime = 0 ;Animation over
trigger3 = Vel Y > 0    ;Hit ground
trigger3 = Pos Y >= 10  ;.
trigger4 = Time = 0     ;No transition anim
trigger4 = Anim != 5035 ;.
value = 5040 ;HITA_RECOV

[State 5035, 4]
type = ChangeState
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_FALL (knocked up, falling)
[Statedef 5050]
type    = A
movetype= H
physics = N

[State 5000, 1]
type = ChangeAnim
trigger1 = time >= 0
trigger1 = NumHelper(6969) = 1
value = 25050

[State 5050, 1] ;Change anim when done with transition
type = ChangeAnim
triggerall = NumHelper(6969) = 0
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
triggerall = NumHelper(6969) = 0
trigger1 = anim = [5050,5059]
trigger1 = Vel Y >= ifelse(anim = 5050, 1, -2)
trigger1 = SelfAnimExist(anim+10)
value = anim+10
persistent = 0

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

[State 5050, 4] ;Recover near ground
type = ChangeState
triggerall = Vel Y > 0
triggerall = Pos Y >= -30
triggerall = alive
triggerall = CanRecover
trigger1 = Command = "ab"
value = 370 ;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 5050, 6]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 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 5000, 1]
type = ChangeAnim
trigger1 = time >= 0
trigger1 = NumHelper(6969) = 1
value = 25100

[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 = NumHelper(6969) = 0
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
triggerall = NumHelper(6969) = 0
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
trigger2 = anim = 25100 && time = 5
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 5000, 1]
type = ChangeAnim
trigger1 = time >= 0
trigger1 = NumHelper(6969) = 1
value = 25160

[State 5101, 1] ;Coming hit ground anim (normal)
type = ChangeAnim
triggerall = NumHelper(6969) = 0
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 = NumHelper(6969) = 0
triggerall = time = 0
trigger1 = anim = [5101,5109]
trigger1 = SelfAnimExist(5160 + (anim % 10))
value = 5160 + (anim % 10)

[State 5101, 3]
type = HitFallVel
trigger1 = Time = 0

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

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

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

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

[State 5000, 1]
type = ChangeAnim
trigger1 = time >= 0
trigger1 = NumHelper(6969) = 1
value = 25170

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

[State 5110, 1] ;For hit up/up-diag type (from state 5081)
type = ChangeAnim
triggerall = NumHelper(6969) = 0
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 = NumHelper(6969) = 0
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 = NumHelper(6969) = 0
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, 6]
type = PlaySnd
trigger1 = Time = 0
trigger1 = !SysVar(0)
value = F7, (sysvar(1) > 5) + (sysvar(1) > 14)

[State 5110, 7]
type = 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
triggerall = NumHelper(6969) = 0
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
triggerall = NumHelper(6969) = 0
persistent = 0
triggerall = Anim != [5111,5119]
trigger1 = AnimTime = 0
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground frame
value = 5110

[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]
trigger4 = anim = 25170 && time = 5
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.85

[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
