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

[State 0, 1]
type = ChangeAnim
trigger1 = (Anim != [0,1]) && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0 ;Turn anim over
value = 0+var(4)

[State 0, 1]
type = ChangeAnim
trigger1 = (Anim != 0) && Anim != 5 && !var(4)
value = 0
[State 0, 2]
type = VelSet
trigger1 =1
y = 0

[State 0, 3] ;Stop moving if low velocity or 4 ticks pass
type = VelSet
trigger1 = abs(vel x) < 2
trigger2 = Time = 4
x = 0
[State 0, Block]
type = ChangeState
triggerall = prevstateno != [200,3000]
trigger1 = InGuardDist 
trigger1 = command = "holdback" 
trigger1 = enemy,numproj>0 && time <3
trigger1 = command = "holdback" 
value = 120
[State 0, Block]
type = ChangeState
triggerall = prevstateno != [200,3000]
triggerall = AILevel > 0
trigger1 = InGuardDist || enemy,numproj >0 && time <3
value = 120
[State 0, CtrlSet]
type = CtrlSet
triggerall = roundstate = 2
triggerall= prevstateno = 20||prevstateno=9000|| !ctrl && winko
trigger1 =time = 0
value = 1
[State 0, 4] ;Are you dead?
type = ChangeState
trigger1 = !alive
value = 5050
;====================<WALKING>====================
[StateDef 20]
type = S
physics = S
moveType = I
sprPriority = 0

[State 20, 1]
type = VelSet
triggerall = AILevel = 0
trigger1 = command = "holdfwd";&& vel x <= 0
x = const(velocity.walk.fwd.x)

[State 20, 2]
type = VelSet
triggerall = AILevel = 0
trigger1 = command = "holdback";&& vel x >= 0
x = const(velocity.walk.back.x)

[State 20, 1]
type = VelSet
triggerall = AILevel > 0
trigger1 = helper(10003),var(25);&& vel x <= 0
x = const(velocity.walk.fwd.x)

[State 20, 2]
type = VelSet
triggerall = AILevel > 0
trigger1 =!helper(10003),var(25);&& vel x >= 0
x = const(velocity.walk.back.x)

[State 20, ChangeAnim]
type = ChangeAnim
triggerAll = vel x > 0
trigger1 = Anim != 20 && Anim != 5
trigger2 = Anim = 5 && AnimElemTime(1) >= 1
value = 20

[State 20, ChangeAnim]
type = ChangeAnim
triggerAll = vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimElemTime(1) >= 1
value = 21
[State 0, CtrlSet]
type = CtrlSet
triggerall = AILevel > 0
trigger1 = time > 20|| p2bodydist x < 25 || p2movetype=A
value = 1

[State 0, CtrlSet]
type = CtrlSet
triggerall = AILevel > 0
trigger1 = time = 0
value = 0
[State 0, ChangeState]
type = ChangeState
trigger1 = vel x =0 
value =0
ctrl = 1
;--------------------------------------------------

[Statedef 40]
type    = S
physics = S
velset =0,0
ctrl = 0
sprpriority = 1
facep2 = 1
[State 40, 1]
type = VarSet
trigger1 = Time = 0
sysvar(1) = 0
[State 0, VarSet]
type = VarSet
trigger1 = time=0
v = 0    ;fv = 10
value = 0
;ignorehitpause = 
;persistent = 
[State 0, PlaySnd]
type = PlaySnd
trigger1 = animtime=0
value =S40,1


[State 40, 2]
type = VarSet
triggerall = AILevel=0
trigger1 = time=[1,2]
sysvar(1) = facing * helper(10006),facing * (((helper(10006), Var(4)&136) > 0) - ((helper(10006), Var(4)&68) > 0))

[State 40, 2]
type = VarSet
triggerall = AILevel>0
trigger1 = (p2bodydist x = [5,90]) || p2movetype =H || backedgebodydist <30
sysvar(1) = 1

[State 40, 2]
type = VarSet
triggerall = AILevel >0
trigger1 = p2bodydist x >=40
trigger2= p2stateno=5120
trigger3= p2movetype=H && p2statetype=A
sysvar(1) = 1

[State 40, 3]
type = VarSet
triggerall = AILevel>0
trigger1 = p2bodydist x < 15 && p2movetype =A && backedgebodydist >30
sysvar(1) = -1
;
;[State 40, 2]
;type = VarSet
;triggerall = AILevel=0
;trigger1 = helper(10006),command = "holdback"
;sysvar(1) = -1

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




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

[State 40, 5]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = prevstateno = 100
trigger1 = sysvar(1) = 1
x = const(velocity.runjump.fwd.x)

;ignorehitpause = 
;persistent = 

;[State 0, Null]
;type = Null
;triggerall = AIlevel =0
;trigger1 = command="x" 
;trigger1=var(0):=1
;trigger2 = command="y" 
;trigger2=var(0):=2
;trigger3 = command="a" 
;trigger3=var(0):=3
;trigger4 = command="b" 
;trigger4=var(0):=4
[State 0, VelSet]
type = VelSet
trigger1 = helper(10003),var(30)=0 && vel y !=0 && AILevel>0
y = 0

[State 40, 6]
type = ChangeState
trigger1 = helper(10003),var(30)=0 &&Time = 0  && AILevel>0
value =cond(prevstateno=140,0,cond(prevstateno<100,0,100))
ctrl = cond(prevstateno<100,1,0)
[State 0, ChangeAnim]
type = ChangeAnim
triggerall=time=0
trigger1 = !AIlevel || helper(10003),var(30)
value = 40

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1
;---------------------------------------------------------------------------
; Jump Land
[Statedef 52]
type    = S
physics = S
ctrl = 0
;anim = 47
facep2=1
[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = time=0 && prevstateno!=9000
value =47

[State 52, 3]
type = CtrlSet
trigger1 = Time = 2 || time=0 && prevstateno!=[600,650]
trigger2 = prevstateno=[5030,5040]
value = 1
[State 0, NotHitBy]
type = NotHitBy
trigger1 = prevstateno=[5030,5040]
trigger1=time=0
value = SCA
;value2 = S,NA
time = 1

[State 0, Block]
type = ChangeState
triggerall = prevstateno != [200,3000]
trigger1 = InGuardDist 
trigger1 = helper(10006),command = "holdback" 
trigger1 = enemy,numproj>0 && time <3
trigger1 = helper(10006),command = "holdback" 
value = 120
[State 0, Block]
type = ChangeState
triggerall = prevstateno != [200,3000]
triggerall = AILevel > 0
trigger1 = InGuardDist || enemy,numproj >0 && time <3
value = 120

;ignorehitpause =
;persistent =
[State 0, Explod]
type = Explod
trigger1 = animelem = 1
anim = 7050
ID = 8302
pos = -18,5
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
scale = .3,.3
sprpriority = 3
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause=1
[State 0, Explod]
type = Explod
trigger1 = animelem = 1
anim = 7050
ID = 8302
pos = 18,0
postype = p1  ;p2,front,back,left,right
facing = -1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
scale = .3,.3
sprpriority = 3
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause=1

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

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

[State 52, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Run forward
[Statedef 100]
type    = S
physics = S
;anim = 100
sprpriority = 1
velset=0,0
[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = (prevstateno!=40||anim!=100)&&time=0
value = 100
[State 0, PosSet]
type = PosSet
trigger1 = time=0
y = 0



[State 0, MakeDust]
type = MakeDust
trigger1 = animelem = 2
trigger2 = animelem = 5
pos = 20,0
;pos2 =
spacing = 1
;ignorehitpause =
;persistent =

[State 0, PlaySnd]
type = PlaySnd
trigger1 = animelem = 3
trigger2 = animelem = 6
value = S100,0
channel = 2

;abspan =
;ignorehitpause =
;persistent =

[State 0, Explod]
type = Explod
trigger1 = animelem = 3
trigger2 = animelem = 6
anim = 7050
ID = 8302
pos = -5,0
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
scale = .5,.5
sprpriority = 3
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause=1


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

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

[State 100, 3] ;Prevent from turning
type = AssertSpecial
trigger1 = 1
flag = NoAutoTurn
[State 100, Jump]
type= changestate
trigger1= ((helper(10006), var(3)&129) > 0 || (helper(10006), var(4)&129) > 0)&& ((helper(10006), var(3)&17) > 0 || (helper(10006), var(4)&17) > 0)&& AIlevel =0
trigger2 = helper(10003),var(30)=1 && AIlevel >0 && fvar(15)>120
value= 40000


[State 100, 4]
type = ChangeState
triggerall = AILevel>0
trigger1 = time > 75 || p2bodydist x  < 25 && p2statetype!=L  || p2bodydist x  < 80 && p2statetype=L
value =101
ctrl =1
[State 100, 4]
type = ChangeState
triggerall = AILevel=0
trigger1 = command != "holdfwd" 
value = 101
;---------------------------
;Runstop
[StateDef 101]
type = S
movetype= I
physics = S
juggle =0;  = 1
ctrl = 0
anim = 101
poweradd = 0
sprpriority = 2
velset=const(velocity.run.fwd.x),0
[State 0, PlaySnd]
type = PlaySnd
trigger1 = animelem =1
value = S100,1
channel = 2

[State 0, Explod]
type = Explod
trigger1 = animelem = 1
anim = 7051
ID = 8302
pos = -5,0
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
scale = .5,.5
sprpriority = 3
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause=1

[State 0, MakeDust]
type = MakeDust
trigger1 = time = [1,5]
pos = 20,0
;pos2 =
spacing = 2
;ignorehitpause =
;persistent =

[State 0, PlaySnd]
type = PlaySnd
trigger1 = time = 0
value =S100,1
channel = 2

;abspan =
;ignorehitpause =
;persistent =


[State 101, end]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1
;---------------------------------------------------------------------------
; GUARD (start)
[Statedef 120]
type = U    ;Leave state type unchanged
physics = U ;Leave physics unchanged

;anim =
;ignorehitpause = 
;persistent = 

;[State 0, ChangeState]
;type = ChangeState
;triggerall =name!="Dark Nation"|| var(58)!=[1010,1013]
;triggerall =  var(58)=[200,4999]
;trigger1 = time=0 
;value = var(58)
;ctrl = 0
;anim =
;ignorehitpause = 
;persistent = 
[State 0, PosSet]
type = PosSet
trigger1 = statetype!=A
y = 0
[State 0, PosSet]
type = velSet
trigger1 = statetype!=A
y = 0
;ignorehitpause = 
;persistent = 

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

[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" && AIlevel =0
trigger2 = Statetype=S &&  p2statetype=C && AIlevel >0 && time =0 && random <(320 * (AIlevel ** 2 / 64.0))
statetype = C
physics = C

[State 120, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C && command != "holddown"&& AIlevel =0
trigger2 = Statetype=C &&  p2statetype=A && AIlevel >0 && time =0 && random <(280 * (AIlevel ** 2 / 64.0))
statetype = S
physics = S

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

;anim =
;ignorehitpause = 
;persistent = 

[State 120, Stop Guarding]
type = ChangeState
triggerall= AILevel =0
trigger1 = command != "holdback"
trigger2 = !inguarddist
value = 140



[State 120, Stop Guarding]
type = ChangeState
triggerall= AILevel >0
triggerall =  p2movetype!=A|| p2bodydist x >140&&  enemy,vel x <=0
trigger1 = !inguarddist
value = 140
;---------------------------------------------------------------------------
; STAND GUARD (guarding)
[Statedef 130]
type    = S
physics = S
[State 0, PosSet]
type = PosSet
trigger1 =1
y = 0
[State 130, 1]
type = ChangeAnim
trigger1 = Anim != 130
value = 130
;[State 0, ChangeState]
;type = ChangeState
;triggerall =name!="Dark Nation"|| var(58)!=[1010,1013]
;triggerall =  var(58)=[200,4999]
;trigger1 = time=0 
;value = var(58)
[State 130, Hi to Lo]
type = ChangeState
trigger1 = command = "holddown" && Ailevel =0
trigger2 =   p2statetype=C && AIlevel >0  && random <(256 * (AIlevel ** 2 / 64.0))
value = 131

[State 120, Stop Guarding]
type = ChangeState
triggerall= AILevel =0
trigger1 = command != "holdback" 
trigger2 = !inguarddist
value = 140



[State 120, Stop Guarding]
type = ChangeState
triggerall= AILevel >0
triggerall =  p2movetype!=A|| p2bodydist x>140&&  enemy,vel x <=0
trigger1 = !inguarddist
value = 140

;---------------------------------------------------------------------------
; CROUCH GUARD (guarding)
[Statedef 131]
type    = C
physics = C
[State 0, PosSet]
type = PosSet
trigger1 =1
y = 0
[State 131, 1]
type = ChangeAnim
trigger1 = Anim != 131
value = 131

[State 131, Lo to Hi]
type = ChangeState
trigger1 = command != "holddown" && AIlevel =0
trigger2 =   p2statetype=A && AIlevel >0  && random <(256 * (AIlevel ** 2 / 64.0))
value = 130



[State 131, Stop Guarding]
type = ChangeState
trigger1 = command != "holdback"
trigger2 = !inguarddist
value = 140

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

[State 132, 1]
type = ChangeAnim
trigger1 = Anim != 132
value = 132

[State 0, Gravity]
type = Gravity
trigger1 = 1
;ignorehitpause = 
;persistent = 


[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, 6]
type = ChangeState
trigger1 = sysvar(0)
trigger1 = command = "holdback"
trigger1 = inguarddist
value = 130

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

[State 132, Stop Guarding]
type = ChangeState
trigger1 = command != "holdback"||  p2bodydist x <40 && enemy,numproj>0 && AIlevel >5
trigger2 = !inguarddist
value = 140

;---------------------------------------------------------------------------
; GUARD (end)
[Statedef 140]
type = U    ;Leave state type unchanged
physics = U ;Leave physics unchanged
ctrl = 1
;[State 0, ChangeState]
;type = ChangeState
;triggerall =name!="Dark Nation"|| var(58)!=[1010,1013]
;triggerall =  var(58)=[200,4999]
;trigger1 = time=0 
;value = var(58)
[State 140, 1]
type = ChangeAnim
trigger1 = Time = 0
value = 140 + (statetype = C) + (statetype = A)*2

[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 120, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown" && AIlevel =0
trigger2 = Statetype=S &&  p2statetype=C && AIlevel >0  && random <(256 * (AIlevel ** 2 / 64.0))
statetype = C
physics = C

[State 120, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C && command != "holddown"&& AIlevel =0
trigger2 = Statetype=C &&  p2statetype=A && AIlevel >0  && random <(256 * (AIlevel ** 2 / 64.0))
statetype = S
physics = S

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

;---------------------------------------------------------------------------
; SGUARDHIT (shaking)
[Statedef 150]
type    = S
movetype= H
physics = N
velset = 0,0
[State 0, PosSet]
type = PosSet
trigger1 =1
y = 0
[State 150, 1]
type = ChangeAnim
trigger1 = 1
value = 150
;[State 0, ChangeState]
;type = ChangeState
;triggerall =name!="Dark Nation"|| var(58)!=[1010,1013]
;triggerall =  var(58)=[200,4999]
;trigger1 = time=0 
;value = var(58)
[State 150, 2]
type = ChangeState
trigger1 = HitShakeOver
value = 151; + 2*(command = "holddown")
[State 0, PalFX]
type = PalFX
trigger1 = GuardPoints < ceil(GuardPointsMax*.35) 
time = 8
add = 200,-100,-100
mul = 256,256,256
sinadd = -200,100,100,24
invertall = 0
color = 256


[State 120, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown" && AIlevel =0
trigger2 = Statetype=S &&  p2statetype=C && AIlevel >0&& random <(256 * (AIlevel ** 2 / 64.0))
statetype = C
physics = C

[State 120, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C &&command != "holddown"&& AIlevel =0
trigger2 = Statetype=C &&  p2statetype=A && AIlevel >0 && random <(256 * (AIlevel ** 2 / 64.0))
statetype = S
physics = S



;anim =
;ignorehitpause = 
;persistent = 

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

;---------------------------------------------------------------------------
; Stand guard hit (knocked back)
[Statedef 151]
type    = S
movetype= H
physics = S
anim = 150
;[State 0, ChangeState]
;type = ChangeState
;triggerall =name!="Dark Nation"|| var(58)!=[1010,1013]
;triggerall =  var(58)=[200,4999]
;trigger1 = time=0 
;value = var(58)
[State 151, 1]
type = HitVelSet
trigger1 = Time = 0
x = 1
[State 0, PosSet]
type = PosSet
trigger1 =1
y = 0
[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, 4]
type = ChangeState
trigger1 = HitOver
value = 130
ctrl = 1

;---------------------------------------------------------------------------
; Crouch guard hit (shaking)
[Statedef 152]
type    = C
movetype= H
physics = N
velset = 0,0

[State 152, 1]
type = ChangeAnim
trigger1 = 1
value = 151
[State 0, PosSet]
type = PosSet
trigger1 =1
y = 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 0, PalFX]
type = PalFX
trigger1 = GuardPoints < ceil(GuardPointsMax*.35) 
time = 8
add = 200,-100,-100
mul = 256,256,256
sinadd = -200,100,100,24
invertall = 0
color = 256

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

;---------------------------------------------------------------------------
; Crouch guard hit (knocked back)
[Statedef 153]
type    = C
movetype= H
physics = C
anim = 151;ifelse((prevstateno = [150,151]),150,151)


[State 0, PosSet]
type = PosSet
trigger1 =1
y = 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
ctrl = 1

;---------------------------------------------------------------------------
; Air guard hit (shaking)
[Statedef 154]
type    = A
movetype= H
physics = N
velset = 0,0

[State 154, 1]
type = ChangeAnim
trigger1 = 1
value = 152
[State 0, PalFX]
type = PalFX
trigger1 = GuardPoints < ceil(GuardPointsMax*.35) 
time = 8
add = 200,-100,-100
mul = 256,256,256
sinadd = -200,100,100,24
invertall = 0
color = 256
[State 154, 2]
type = ChangeState
trigger1 = HitShakeOver
value = 155 ;AGUARDHIT2

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

;---------------------------------------------------------------------------
; Air guard hit (knocked away)
[Statedef 155]
type    = A
movetype= H
physics = N
anim = 152

[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, 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
trigger1 = sysvar(0)
trigger1 = command = "holdback"
trigger1 = inguarddist
value = 130

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

;---------------------------------------------------------------------------
; 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] ;Gravity
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 = (helper(10006), var(0)>0)||AIlevel >0 &&hitover&& random < (100*(AILevel**2/64.0)) 
value = 5200 ;HITFALL_RECOVER

[State 5050, 5]; Recover in mid air
type = ChangeState
triggerall = Vel Y > -1
triggerall = alive
triggerall = CanRecover
trigger1 = (helper(10006), var(0)>0)||AIlevel >0 &&hitover&& random < (100*(AILevel**2/64.0)) 
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
;---------------------------------------------------------------------------
; Downed get-hit (getting up)
[Statedef 5120]
type    = L
movetype= I
physics = N
facep2=1

[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 = AnimTime = 0
value = 0
ctrl = 1
;---------------------------------------------------------------------------
; Air get-hit (fall recovery in air)
[Statedef 5211]
type    = A
movetype= I
physics = N
anim = 5210
ctrl = 0

[State 0, VarSet]
type = Varadd
trigger1 = 1
v = 59   ;fv = 10
value = -10000
;ignorehitpause = 
;persistent = 

[State 0, ChangeState]
type = ChangeState
trigger1 = 1
value =5210
ctrl = 0
;---------------------------------------------------------------------------
; Air get-hit (fall recovery in air)
[Statedef 5210]
type    = A
movetype= I
physics = N
anim = 5210
ctrl = 0
[State -3, Hit0]
type = PlaySnd
trigger1 =Time = 0
value = S5120, 3+random%2
channel=0
[State 5210, 1] ;Blink white
type = PalFX
trigger1 = Time = 0
time = 3
add = 128,128,128

[State 5210, 1]
type = PosFreeze
trigger1 = Time < 4

[State 5210, 2] ;Turn if not facing opponent
type = Turn
trigger1 = Time = 0
trigger1 = p2dist X < Const720p(-80)

[State 5210, 1.0 behavior 1]
type = VelMul
trigger1 = Time = 4
x = Const(velocity.air.gethit.airrecover.mul.x)*cond(prevstateno=5211,2,1)
y = Const(velocity.air.gethit.airrecover.mul.y)

[State 5210, 1.0 behavior 2]
type = VelAdd
trigger1 = Time = 4
x = Const(velocity.air.gethit.airrecover.add.x)*cond(prevstateno=5211,2,1)
y = Const(velocity.air.gethit.airrecover.add.y)

[State 5210, 2002.04.14 behavior 1]
type = null;VelMul
trigger1 = Time = 4
x = .8
y = .8

[State 5210, 2002.04.14 behavior 2]
type = null;VelAdd
trigger1 = Time = 4
x = 0 
y = -4.5

[State 5210, 2002.04.14 behavior 3]
type = null;VelMul
trigger1 = Time = 4
trigger1 = Vel Y > 0
y = .5

[State 5210, 2002.04.14 behavior 4]
type = null;VelAdd
trigger1 = Time = 4
trigger1 = Vel Y > -3
y = -2

[State 5210, 2002.04.14 behavior 5]
type = null;VelAdd
trigger1 = Time = 4
trigger1 = Vel Y > -2
y = -1

;[State 5210, 2] ;Go up
;type = VelAdd
;trigger1 = Time = 4
;trigger1 = Command = "holdup"
;y = Const(velocity.air.gethit.airrecover.up)

;[State 5210, 2] ;Go down
;type = VelAdd
;trigger1 = Time = 4
;trigger1 = Command = "holddown"
;y = Const(velocity.air.gethit.airrecover.down)

[State 5210, 2] ;Go fwd
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holdfwd"
x = Const(velocity.air.gethit.airrecover.fwd)*cond(prevstateno=5211,2,1)

[State 5210, 2] ;Go back
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holdback"
x = Const(velocity.air.gethit.airrecover.back)*cond(prevstateno=5211,2,1)

[State 5210, 3]
type = NotHitBy
trigger1 = Time = 0
value = SCA
time = 15

[State 5210, 4]
type = CtrlSet
trigger1 = Time =14
value = 1

[State 5210, 5]
type = VelAdd
trigger1 = Time >= 4
y = Const(movement.air.gethit.airrecover.yaccel)

[State 5210, 5] ;Land on ground
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 52 ;Jump land
ctrl = 1

;---------------------------------------------------------------------------
; Initialize (at the start of the round)
[Statedef 5900]
type = S

[State 5900, 1] ;Clear all int variables
type = VarRangeSet
trigger1 = roundsexisted = 0
value = 0

[State 5900, 2] ;Clear all float variables
type = VarRangeSet
trigger1 = roundsexisted = 0
fvalue = 0
[State 0, RemapPal]
type = RemapPal
trigger1 =1
source = 1,1
dest = 1,palno


[State 5900, 3] ;Intro for round 1
type = ChangeState
trigger1 = roundno = 1
value = 190