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

;[State 0, 1]
;type = ChangeAnim
;triggerall = life > 300 && var(42) != 0
;trigger1 = Anim != 1 && Anim != 5
;trigger2 = Anim = 5 && AnimTime = 0 ;Turn anim over
;value = 1

[State 0, 1]
type = ChangeAnim
triggerall = life > 255 ;&& var(42) = 0 && var(44) = 0
trigger1 = Anim != 0 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0 ;Turn anim over
value = 0

[State 0, 1]
type = ChangeAnim
triggerall = life <= 250 ;95 ;&& Var(15)=0
trigger1 = Anim != 2 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0 ;Turn anim over
value = 2 ;3

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

[State 0, 2]
type = VelSet
trigger1 = Time = 0
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, 4] ;Are you dead?
type = ChangeState
trigger1 = !alive
value = 5050
ctrl = 0

;---------------------------------------------------------------------------
; Jump Land
[Statedef 52]
type    = S
physics = S
ctrl = 0
anim = 47

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

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

[State 52, 3]
type = CtrlSet
trigger1 = Time = 3
value = 1

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

[State 52, Dust]
type = Explod
trigger1 = !time
anim = 7104 ;F60 ;7104
ID = 7104 ;60 ;7104
sprpriority = -2
postype = p1
scale = 1,1 ;0.4,0.4
ownpal = 1
pausemovetime = -1
supermovetime = -1

; RUN_BACK2 (land)
[Statedef 106]
type    = S
physics = S
ctrl = 0
anim = 47

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

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

[State 106, 3]
type = MakeDust
trigger1 = Time = 2
pos = -5,-2
spacing = 1

[State 106, 4]
type = ChangeState
trigger1 = Time = 7
value = 0
ctrl = 1

[State 106, Dust]
type = Explod
trigger1 = !time
anim = 7104 ;F60 ;7104
ID = 7104 ;60 ;7104
sprpriority = -2
postype = p1
scale = 1,1 ;0.4,0.4
ownpal = 1
pausemovetime = -1
supermovetime = -1

;---------------------------------------------------------------------------
; RUN_FWD
[Statedef 100]
type    = S
physics = S
anim = 100
sprpriority = 1

[State 200,Anim]
type = ChangeAnim
trigger1 = time = 0 && var(11)=1
value = 106

[State 200,Anim]
type = VelAdd
trigger1 = time = 0 && var(11)=1
x= 9

[State 100, Explod]
type = Explod
trigger1 = AnimElem = 1
trigger2 = AnimElem = 2
trigger3 = AnimElem = 3
trigger4 = animelem = 4
anim = 8500
ID = 8500
pos = -5,0
postype = p1
bindtime = 1
removetime = -2
scale = 1.1,1.1
sprpriority = 3
ownpal = 1

;[State 100, Explod]
;type = Explod
;trigger1 = AnimElem = 1
;trigger2 = AnimElem = 2
;trigger3 = AnimElem = 3
;trigger4 = animelem = 4
;anim = F120 ;8500
;ID = 120 ;8500
;pos = -8,0
;postype = p1
;bindtime = 1
;removetime = -2
;scale = 2,2
;sprpriority = 3
;ownpal = 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, 4]
type = ChangeState
triggerall=!var(1) ;the AI doens't activate
trigger1 = command != "holdfwd"
trigger2 = command = "holdback"
value = 101

[State 100, PlaySnd]
type = PlaySnd
trigger1 = time = 0
value = S100,0

;-------------------------------------------------------------------------
;Run Stop
[Statedef 101]
type    = S
physics = S
anim = 101
sprpriority = 1

[State 101, NO GUARD]
type = AssertSpecial
trigger1 = 1
flag = noairguard
flag2 = nocrouchguard
flag3 = nostandguard

[State 101, VelSet]
type = VelSet
trigger1 = time = 0
x = 6

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

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

[state 101, AfterImage]
type = AfterImage
triggerall = prevstateno = 100 || prevstateno = 102
trigger1 = time = 0
time = 30
length = 13
paladd = 10, 10, 10
palmul = 1,1,1
palcontrast = 80,80,80
framegap = 5
trans = add1

[State 101, Explod]
type = Explod
trigger1 = AnimElem = 1
anim = 8500
ID = 8500
pos = -5,0
postype = p1
bindtime = 1
removetime = -2
scale = 1.1,1.1
sprpriority = 3
ownpal = 1

;[State 101, Explod]
;type = Explod
;trigger1 = AnimElem = 1
;;trigger2 = AnimElem = 2
;;trigger3 = AnimElem = 3
;;trigger4 = animelem = 4
;anim = F120 ;8500
;ID = 120 ;8500
;pos = -6,0
;postype = p1
;bindtime = 1
;removetime = -2
;scale = 2,2
;sprpriority = 3
;ownpal = 1

[State 101, PlaySnd]
type = PlaySnd
trigger1 = time = 0
value = S101,0
volume = 200
channel = -1

[State 101, End]
type = ChangeState
trigger1 = animtime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; RUN_FWD (AI)
[Statedef 102]
type    = S
physics = S
anim = 100
sprpriority = 1
ctrl = 0

[State 200,Anim]
type = ChangeAnim
trigger1 = time = 0 && var(11)=1
value = 106

[State 200,Anim]
type = VelAdd
trigger1 = time = 0 && var(11)=1
x= 9

[State 100, Explod]
type = Explod
trigger1 = AnimElem = 1
trigger2 = AnimElem = 2
trigger3 = AnimElem = 3
trigger4 = animelem = 4
anim = 8500
ID = 8500
pos = -5,0
postype = p1
bindtime = 1
removetime = -2
scale = 1.1,1.1
sprpriority = 3
ownpal = 1

;[State 100, Explod]
;type = Explod
;trigger1 = AnimElem = 1
;trigger2 = AnimElem = 2
;trigger3 = AnimElem = 3
;trigger4 = animelem = 4
;anim = F120 ;8500
;ID = 120 ;8500
;pos = -8,0
;postype = p1
;bindtime = 1
;removetime = -2
;scale = 2,2
;sprpriority = 3
;ownpal = 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 106, 4]
type = CtrlSet
trigger1 = p2bodydist X < 40 ;30
value = 1

[State 8, 0]
type = ChangeState
triggerall = var(8) = [0,2]
trigger1 = p2bodydist X < 10
value = 400

[State 8, 0]
type = ChangeState
triggerall = var(8) = 3
trigger1 = p2bodydist X < 10
value = 410

[State 100, 4]
type = ChangeState
;triggerall=!var(1) ;the AI doens't activate
;trigger1 = command != "holdfwd"
;trigger2 = command = "holdback"
;trigger1 = p2bodydist X < 50
trigger1 = Time = 50
value = 101

[State 100, PlaySnd]
type = PlaySnd
trigger1 = time = 0
value = S100,0

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

[State 5100, 2004.04.14 behavior]
type = null;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 ;Downed get-hit (lying down)

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

[State 5100,BGAire]
type=Explod
trigger1=Time
anim=7003
sprpriority=0
postype=p1
pos=0,-10
velocity=0,0
removetime=-2
scale=1,1 ;.65,.65
persistent=0
ownpal=1

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

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

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

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

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

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

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

[State 5110, 1] ;For hit up/up-diag type (from state 5081)
type = ChangeAnim
persistent = 0
trigger1 = SelfAnimExist(5110 + (anim % 10))
trigger1 = anim = [5081,5089]
value = 5110 + (anim % 10)

[State 5110, 2] ;Hit ground anim (normal)
type = ChangeAnim
triggerall = time = 0
triggerall = anim != [5110,5119] ;Not already changed anim
trigger1 = anim != [5161,5169]
trigger2 = !SelfAnimExist(5170 + (anim % 10))
value = 5170

[State 5110, 3] ;Hit ground anim (for hit up)
type = ChangeAnim
triggerall = time = 0
triggerall = anim != [5110,5119] ;Not already changed anim
trigger1 = anim = [5161,5169]
trigger1 = SelfAnimExist(5170 + (anim % 10))
value = 5170 + (anim % 10)

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

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

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

[State 5110, 6]
type = PlaySnd
trigger1 = Time = 0
trigger1 = !SysVar(0)
value = s8, (sysvar(1) > 5) + (sysvar(1) > 14) ;(sysvar(1) > Const720p(20)) + (sysvar(1) > Const720p(56))

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

[State 5100,BGAire]
type=Explod
trigger1=Time
anim=7003
sprpriority=0
postype=p1
pos=0,-10
velocity=0,0
removetime=-2
scale=1,1 ;.65,.65
persistent=0
ownpal=1

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

[State 5110, 9] ;For hit up type
type = ChangeAnim
persistent = 0
triggerall = anim = [5171,5179]
triggerall = SelfAnimExist(5110 + (anim % 10))
trigger1 = AnimTime = 0
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground anim
value = 5110 + (anim % 10)

[State 5110, 10] ;For normal
type = ChangeAnim
persistent = 0
triggerall = Anim != [5111,5119]
trigger1 = AnimTime = 0
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground frame
value = 5110

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

[State 5110, 12]
type = VarSet
trigger1 = SysVar(0)
trigger1 = Time = 0
sysvar(0) = 0

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

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

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

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

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

; Walk
[Statedef 20]
type    = S
physics = S
sprpriority = 0

[State 20, 1]
type = VelSet
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)

[State 20, 2]
type = VelSet
trigger1 = command = "holdback"
x = const(velocity.walk.back.x)

[State 20, 3]
type = ChangeAnim
triggerall = vel x > 0
trigger1 = Anim != 20 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 20

[State 20, 4]
type = ChangeAnim
triggerall = vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 21

[State 20, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 3
trigger2 = AnimElem = 6
value = S40,0
volume = 10000
channel = -1

;[State 21, PlaySnd]
;type = PlaySnd
;trigger1 = anim = 21
;trigger2 = AnimElem = 2
;trigger3 = AnimElem = 4
;trigger4 = AnimElem = 6
;value = S40,0
;volume = 10000
;channel = -1

[State 21, PlaySnd]
type = PlaySnd
;trigger1 =
anim = 21
;value = S0,0
;trigger1 = anim = 21
trigger1 = AnimElem = 3
trigger2 = AnimElem = 6
;trigger3 = AnimElem = 6
value = S40,0
volume = 255 ;0
channel = -1
lowpriority = -1
freqmul = 1.0
loop = 0
pan = 0
abspan = 0
ignorehitpause = 0
persistent = 0

;---------------------------------------------------------------------------
; Downed get-hit (getting up)
[Statedef 5120]
type    = L
movetype= I
physics = N

[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,1]
type = PlaySnd
trigger1 = time = 0
trigger1 = random < 500
value = S5120,0+random%2
channel = 0

[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

;------------------------------------------------------------------------
;Hammer smashed

[Statedef 1242]
type = S
movetype = H
physics = N
velset = 0,0

[State 1242]
type = changestate
trigger1 = time = 0
trigger1 = selfanimexist(7689) = 0
value = 1243

[State 1242]
type = ChangeAnim2
trigger1 = Time = 0
value = 7689

[State 1242]
type = ChangeAnim2
trigger1 = Time = [1,3]
value = 7689
elem = 2

[State 1242]
type = ChangeAnim2
trigger1 = Time = [6,9]
value = 7689
elem = 3

[State 1242]
type = ChangeAnim2
trigger1 = Time = [10,60]
value = 7689
elem = 4

[State 1242]
type = ChangeAnim
trigger1 = Time = 60
trigger1 = selfanimexist(7100)
value = 7100
persistent = 0

[State 1242]
type = ChangeAnim2
trigger1 = Time >= 69
value = 5110

[State 1242]
type = SelfState
trigger1 = Time = 90
value = 5110

;------------------------------------------------------------------------------------------------------------
;Because there is no anim 7689

[Statedef 1243]
type = S
movetype = H
physics = N
velset = 0,0

[State 1243]
type = AngleDraw
trigger1 = time = [0,25]
value = 0
scale = 1.2,0.45

[State 1243]
type = ChangeAnim2
trigger1 = Time = 0
value = 5110

[State 1243]
type = SelfState
trigger1 = Time = 30
value = 5110

;------------------------------------------------------------------------------------------
; Hit by  - shaking from the hit
; (a custom gethit state)

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

[State 9020, Anim] ;Custom animation
type = null;ChangeAnim2
trigger1 = 1
value = 5012


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


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

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



[State 5050, 2] ; anim for trip
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(groundtype) = 3
trigger1 = SelfAnimExist(5070)
value = 5070


[State 9020, State]
type = ChangeState
trigger1 = HitShakeOver = 1
value = 9030

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

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

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

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

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


[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
trigger2 = Anim != 5070

[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, 2] ;Coming down anim for trip
type = ChangeAnim
trigger1 = anim = 5070
trigger1 = Vel Y >= 0
trigger1 = SelfAnimExist(anim-10) || SelfAnimExist(5071)
value = ifelse(SelfAnimExist(5071),5071,anim-10)
persistent = 0


[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 9030, Hit ground]
type = SelfState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= ifelse((anim = [5051,5059]) || (anim = [5061,5071]), 0, 25)
value = 5100 ;HIT_BOUNCE

;-----------------------------------------------------------------------------------------------------
; Hit by  - hit wall
; (a custom gethit state)
[Statedef 9027]
type    = A
movetype= H
physics = N

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

[State 9027, Pos]
type = null;PosAdd
trigger1 = Time = 0
x = 15 - BackEdgeBodyDist

[State 9027, Stop moving]
type = null;PosFreeze
trigger1 = 1
x = 1
y = 1

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

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

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

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

[State 9027, State]
type = ChangeState
trigger1 = Time = 5
value = 9028

;------------------
; Hit by  - bounce off wall
; (a custom gethit state)
[Statedef 9028]
type    = A
movetype= H
physics = N

[State 9028, 1]
type = NotHitBy
trigger1 = 1
value = , NA, NP

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

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

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

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

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

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

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

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

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

;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; マックバースト
;
[Statedef 16500]
type    = A
movetype= A
physics = A
juggle  = 6
poweradd= -5000
velset = 0,-6
anim = 16500
ctrl = 0
sprpriority = 2

[State 16500, 音を鳴らす]
type = PlaySnd
trigger1 = Time = 1
value = 16500, 0 ;3

[State 1160, 位置調整]
type = PosSet
trigger1 = Time = 30
y = 0

[State 16500, 速度加算]
type = VelAdd
trigger1 = AnimElem = 7
y = .43

[State 16500,00]
type = AllPalFx
trigger1 = AnimElem = 3
add = 200,0,0
sinadd = 10, 10, 10
time = 10

[State 16500, ヒット定義]
type = HitDef
trigger1 = time = 0
attr = A, HA
animtype  = up
damage    = 10, 5
getpower  = 0
priority  = 5
pausetime = 30,30
gurad.pausetime = 12,12
sparkxy = -10,-60
;sparkno = 3
sparkno = s8003+random%3
guard.sparkno = S8011
hitsound   = s5,12 ;10 ;4
guardsound = S6,0
ground.type = Low
ground.slidetime = 20
ground.hittime  = 20
ground.velocity = -7,-20
guard.hittime = 8
guard.velocity = -16
air.velocity = -7,-20
airguard.velocity = -7,-2
envshake.time = 30
envshake.ampl = 12
envshake.freq = 170
fall = 1

[State 16500, ステート変更]
type = ChangeState
trigger1 = Vel Y > 0 && Pos Y >= 0
value = 1052

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

[Statedef 1052]
type    = S
movetype= I
physics = S
anim = 1052
sprpriority = 1
velset = 0,0

[State 1052, 軸位置設定]
type = PosSet
trigger1 = 1
y = 0

[State 1052, 音を鳴らす]
type = PlaySnd
trigger1 = Time = 0
value = 40, 1 ;0

[State 191, Dust]
type = Explod
trigger1 = AnimElem = 1 ;31
anim = 7104 ;f60
ID = 7104 ;60
sprpriority = -2
postype = p1
scale = 1,1 ;0.5,0.5
ownpal = 1
pausemovetime = -1
supermovetime = -1

[State 1052, コントロール可否]
type = CtrlSet
trigger1 = AnimElem = 3, -1
value = 1

[State 1052, 軸位置移動]
type = PosAdd
trigger1 = AnimElem = 4
x = -15

[State 1052, ステート変更]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Downed get-hit (lying defeated)
[Statedef 5150]
type    = L
movetype= H
physics = N
sprpriority = -3
ctrl = 0

[State 5150, gone]
type=assertspecial
trigger1= sysvar(3)=2423
flag=invisible
[State 5150, gone]
type=screenbound
trigger1= sysvar(3)=2423
value=0
movecamera=0,0
[State 5150, gone]
type=playerpush
trigger1= sysvar(3)=2423
value=0
[State 5150, gone]
type=posset
trigger1= sysvar(3)=2423
y= 0

[State 5150, 1] ;Normal anim
type = ChangeAnim
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
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
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
trigger1 = Time = 0
trigger1 = Anim != [5140,5159]
trigger1 = Anim != [5110,5119]
value = 5110

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

[State 0, ChangeState]
type = ChangeAnim
triggerall = anim=5150
trigger1 = roundstate>=4 && matchover=1 && Anim!=5140 ;6150
value = 6150+random%2
ctrl = 0

[State 0, ChangeState]
type = Null ;ChangeAnim
triggerall = anim=5140
trigger1 = roundstate>=4 && matchover!=1 && Anim!=6150+random%2
value = 6150+random%2
ctrl = 0

[State 0, Turn]
type = Turn
triggerall = anim=6150
trigger1 = P2dist X < 0

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

[State 6150, AnimTime]
type = PlaySnd
triggerall = anim=6150
trigger1 = AnimElem=32 ;30 ;34
value = S5150, 0 ;S11,1 ;6150,0

;---------------------------------------------------------------------------
; 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 5900, 3] ;Intro for round 1
type = ChangeState
trigger1 = roundno = 1
value = 190

[State 5900, 4] ;Intro for round 1
type = ChangeState ;palno = 12 ;[11,12] ;[10,12] ;12
;triggerall = palno != 12
trigger1 = roundno != 1
value = 1950 ;19551
