; Luigi General States
;---------------------------------------------------------------------------
; 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

;---------------------------------------------------------------------------
; Jump Start
[Statedef 40]
type    = S
physics = S

[State 40, State]
type = ChangeState
triggerall = Var(40) > 0
trigger1 = Command = "holdback"
trigger2 = Command = "holdfwd"
value = 20
ctrl = 1

[State 40, State]
type = ChangeState
triggerall = Var(40) > 0
trigger1 = Command = "holddown"
value = 10
ctrl = 1

[State 40, State]
type = ChangeState
trigger1 = Var(40) > 0
value = 0
ctrl = 1

[State 40, Ctrl]
type = CtrlSet
trigger1 = Time <= 0
value = 0

[State 40, Anim]
type = ChangeAnim
trigger1 = Time <= 0
value = 40

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

[State 40, 2]
type = VarSet
trigger1 = command = "holdfwd"
sysvar(1) = 1

[State 40, 3]
type = VarSet
trigger1 = command = "holdback"
sysvar(1) = -1

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

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = Command = "holdup"
y = const(velocity.jump.y)

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = Command != "holdup"
y = const(velocity.jump.y)/1.5

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

[State 40, 6]
type = PlaySnd
trigger1 = AnimTime = 0
value = 10,26
channel = 0

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

;---------------------------------------------------------------------------
; Air Jump Start
[Statedef 45]
type    = A
physics = N
velset = 0,0
ctrl = 0

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

[State 45, 2]
type = VarSet
trigger1 = command = "holdfwd"
sysvar(1) = 1

[State 45, 3]
type = VarSet
trigger1 = command = "holdback"
sysvar(1) = -1

[State 45, 4]
type = VelSet
trigger1 = Time > 1
x = ifelse(sysvar(1)=0, const(velocity.airjump.neu.x), ifelse(sysvar(1)=1, const(velocity.airjump.fwd.x), const(velocity.airjump.back.x)))

[State 45, 4]
type = VelSet
trigger1 = Time > 1
trigger1 = command = "holdup"
y = const(velocity.airjump.y)

[State 45, 4]
type = VelSet
trigger1 = Time > 1
trigger1 = command != "holdup"
y = const(velocity.airjump.y)/1.5

[State 45, 5]
type = PlaySnd
trigger1 = Time > 1
value = 10,27
channel = 0

[State 45, 6]
type = ChangeState
trigger1 = Time > 1
value = 51
ctrl = 1

;---------------------------------------------------------------------------
; Air Jump
[Statedef 51]
type    = A
physics = A

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

[State 51, 2]
type = ChangeAnim
trigger1 = Time <= 0
trigger1 = SelfAnimExist(50)
trigger1 = SelfAnimExist(51)
value = ifelse((vel x)<0, 51, ifelse((vel x)>0, 50, 50))

[State 51, 3]
type = ChangeAnim
trigger1 = Time <= 0
trigger1 = !SelfAnimExist(50)
trigger1 = !SelfAnimExist(51)
value = ifelse((vel x)=0, 41, ifelse((vel x)>0, 42, 43))

[State 51, 4]
type = ChangeAnim
trigger1 = Anim != 50
trigger1 = Anim != 51
trigger1 = Vel y > -2
trigger1 = SelfAnimExist(anim + 3)
persistent = 0
value = Anim + 3

[State 51, AngleDraw]
type = AngleDraw
triggerall = Pos Y < -10
trigger1 = Anim = 50
trigger1 = AnimElem = 2, >= 0
trigger1 = AnimElem = 14, < 0
trigger2 = Anim = 51
trigger2 = AnimElem = 7, >= 0

[State 51, AngleSet]
type = AngleSet
trigger1 = AnimElem = 2, < 0
trigger2 = Pos Y >= -10
trigger3 = Anim = 50
trigger3 = AnimElem = 14, >= 0
trigger4 = Anim != 50
trigger4 = Anim != 51
value = 0

[State 51, AngleAdd]
type = AngleAdd
trigger1 = Anim = 50
trigger1 = AnimElem = 2, > 0
value = -10

[State 51, AngleAdd]
type = AngleAdd
trigger1 = Anim = 51
trigger1 = AnimElem = 7, > 0
value = 30

[State 51, AngleSet]
type = AngleSet
trigger1 = Anim = 51
trigger1 = AnimElem = 8
value = -180

;---------------------------------------------------------------------------
; Jump Fall Down
[Statedef 55]
type    = A
movetype= I
physics = A
anim = 41
ctrl = 1

[State 55, Anim]
type = ChangeAnim
trigger1 = Vel Y > 0
trigger1 = SelfAnimExist(Anim + 3)
persistent = 0
value = Anim + 3

;---------------------------------------------------------------------------
; RUN_BACK
[Statedef 105]
type    = A
physics = A
anim = 105
sprpriority = 1
ctrl = 0

[State 105, 1]
type = VelSet
trigger1 = Time = 0
x = const(velocity.run.back.x)
y = const(velocity.run.back.y)

[State 105, 2]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 106

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

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

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

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

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

[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, Sound]
type = PlaySnd
trigger1 = AnimTime = 0
value = 2,10
channel = 1

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

[State 120, Stop Guarding]
type = ChangeState
trigger1 = Var(50) >= 0
trigger1 = command != "hold_z"
trigger2 = Var(50) < 0
trigger2 = command != "hold_z" && command != "hold_c"
value = 140

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

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

[State 130, Hi to Lo]
type = ChangeState
trigger1 = command = "holddown"
value = 10
ctrl = 1

[State 130, Stop Guarding]
type = ChangeState
trigger1 = Var(50) >= 0
trigger1 = command != "hold_z"
trigger2 = Var(50) < 0
trigger2 = command != "hold_z" && command != "hold_c"
value = 140

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

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

[State 131, Lo to Hi]
type = ChangeState
trigger1 = command != "holddown"
value = 12
ctrl = 1

[State 131, Stop Guarding]
type = ChangeState
trigger1 = Var(50) >= 0
trigger1 = command != "hold_z"
trigger2 = Var(50) < 0
trigger2 = command != "hold_z" && command != "hold_c"
value = 140

;---------------------------------------------------------------------------
; Lose by Time Over
[Statedef 170]
velset = 0,0
anim = 170
ctrl = 0

[State 170, 0]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

;---------------------------------------------------------------------------
; Win State

[State 180, VarRandom]
type = VarRandom
trigger1 =  time = 1
v = 50
range = 150
;ignorehitpause =
;persistent =


[Statedef 180]
velset = 0,0
anim = 180
ctrl = 0

[State 180, 0]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 180, 1]
type = AssertSpecial
trigger1 = Time <= 150
flag = RoundNotOver

[State 180, 2]
type = VarRandom
trigger1 = Time <= 0
v = 0
range = 0,9

[State 180, Sound]
type = PlaySnd
trigger1 = AnimElem = 2
value = 10, 30
channel = 0

[State 180, 2]
type = ChangeState
trigger1 = Var(0) <= 5
value = 185

;---------------------------------------------------------------------------
; Win State
[Statedef 185]
velset = 0,0
anim = 185
ctrl = 0

[State 185, 0]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 185, 1]
type = AssertSpecial
trigger1 = Time <= 200
flag = RoundNotOver

[State 185, 2]
type = PlaySnd
trigger1 = AnimElem = 5
trigger2 = AnimElem = 19
value = 0, 2
channel = 1

[State 185, Turn]
type = Turn
trigger1 = AnimElem = 2
trigger2 = AnimElem = 17

[State 185, Sound]
type = PlaySnd
trigger1 = AnimElem = 32
value = 10,24
channel = 0

;---------------------------------------------------------------------------
; Intro
[Statedef 190]
type = A
movetype = I
physics = N
sprpriority = 0
velset = 0,0
anim = 190
ctrl = 0

[State 190, Special]
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 190, Anim]
type = ChangeAnim
trigger1 = RoundState = 0
value = Anim

[State 190, Special]
type = AssertSpecial
triggerall = Anim = 190
trigger1 = AnimElem = 2, < 0
flag = Invisible

[State 190, Special]
type = AssertSpecial
triggerall = Anim = 190
trigger1 = AnimElem = 4, < 0
flag = NoShadow 

[State 190, Sound]
type = PlaySnd
trigger1 = Time = 20
value = 4,1
channel = 1

[State 190, Sound 2]
type = PlaySnd
trigger1 = time = 21
value = 11,6
Channel = 2

[State 190, Pipe]
type = Helper
trigger1 = Time = 20
helpertype = normal
name = "Pipe"
size.xscale = 1
size.yscale = 1
id = 191
pos = 0, 0
postype = p1
stateno = 191
keyctrl = 0
ownpal = 1

[State 190, ScreenBound]
type = ScreenBound
trigger1 = Pos Y != 0
value = 0
movecamera = 0,0

[State 190, VelSet]
type = VelSet
triggerall = Anim = 190
trigger1 = AnimElem = 2
y = -2

[State 190, VelSet]
type = VelSet
trigger1 = Vel Y < 0
trigger1 = Anim = 190
trigger1 = AnimElem = 2, > 0
trigger1 = AnimElem = 3, < 0
trigger1 = NumHelper(191) > 0
trigger1 = Pos Y <= Helper(191), Pos Y - 20
trigger2 = Anim = 190
trigger2 = AnimElem = 3, > 0
trigger2 = Pos Y >= -10
trigger2 = Vel Y > 0
trigger3 = Anim != 190
y = 0

[State 190, VelSet]
type = VelSet
trigger1 = Anim = 190
trigger1 = AnimElem = 3
y = -5

[State 190, VelAdd]
type = VelAdd
trigger1 = Anim = 190
trigger1 = AnimElem = 3, > 0
y = .5

[State 190, Anim]
type = ChangeAnim
triggerall = Anim = 190
trigger1 = Pos Y >= 0
trigger1 = Vel Y > 0
value = 40

[State 190, StateType]
type = StateTypeSet
trigger1 = Pos Y >= 0
trigger1 = Anim != 190
statetype = S

[State 190, PosSet]
type = PosSet
trigger1 = Pos Y >= -10
trigger1 = Vel Y > 0
trigger2 = Anim != 190
y = 0

[State 190, State]
type = ChangeState
trigger1 = Anim != 190
trigger1 = AnimTime = 0
value = 0

;---------------------------------------------------------------------------
; Pipe
[Statedef 191]
type = S
movetype = I
physics = N
sprpriority = 10
velset = 0,0
anim = 191
ctrl = 0

[State 190, 0]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 190, Push]
type = PlayerPush
trigger1 = 1
value = 0

[State 190, 1]
type = AssertSpecial
trigger1 = 1
flag = Invisible

[State 190, 2]
type = Explod
trigger1 = Time <= 0
sprpriority = 5
pos = 0, 0
id = 191
postype = p1
bindtime = -1
removetime = -1
anim = 191

[State 190, 2]
type = RemoveExplod
triggerall = Time >= 60
triggerall = NumExplod(191) > 0
trigger1 = Pos Y >= 0
trigger1 = Vel Y >= 0
id = 191

[State 190, Pipe]
type = Helper
trigger1 = Time <= 0
helpertype = normal
name = "Pipe"
size.xscale = 1
size.yscale = 1
id = 192
pos = 0, 0
postype = p1
stateno = 192
keyctrl = 0
ownpal = 1

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

[State 190, 2]
type = VelSet
trigger1 = Pos Y <= -40
y = 0

[State 190, 2]
type = VelSet
trigger1 = Time = 60
y = 2

[State 190, 5]
type = DestroySelf
triggerall = Time >= 60
trigger1 = Pos Y >= 0
trigger1 = Vel Y >= 0

;---------------------------------------------------------------------------
; Pipe Line
[Statedef 192]
type = S
movetype = I
physics = N
sprpriority = 5
velset = 0,0
anim = 192
ctrl = 0

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

[State 190, Push]
type = PlayerPush
trigger1 = 1
value = 0

[State 190, 2]
type = AssertSpecial
trigger1 = 1
flag = Invisible

[State 190, 3]
type = PosSet
trigger1 = 1
y = 0

[State 190, 4]
type = Explod
trigger1 = Time <= 0
sprpriority = 5
pos = 0, 0
id = 192
postype = p1
bindtime = -1
removetime = -1
anim = 192

[State 190, 4]
type = ModifyExplod
trigger1 = NumExplod(192) > 0
scale = 1, ParentDist Y
id = 192

[State 190, 4]
type = RemoveExplod
trigger1 = Time > 0
trigger1 = NumHelper(191) = 0
trigger1 = NumExplod(192) > 0
id = 192

[State 190, 5]
type = DestroySelf
triggerall = Time > 0
trigger1 = NumHelper(191) = 0
trigger1 = NumExplod(192) = 0

;---------------------------------------------------------------------------
; Taunt
[Statedef 195]
type = S
movetype = a
physics = S
ctrl = 0
velset = 0,0
anim = 195

[State 195, 1]
type = HitDef
trigger1 = AnimElem = 6
trigger2 = AnimElem = 11
attr = S, NA
damage = 1, 0
animtype = Light
guardflag = MA
hitflag = MAFD
priority = 3, Hit
pausetime = 6, 6
sparkno = 0
sparkxy = -10, -10
hitsound = S1, 0
guardsound = S2, 0
ground.type = High
ground.slidetime = 10
ground.hittime  = 16
ground.velocity = -2
airguard.velocity = -1,-1
air.type = High
air.velocity = -2,-2
air.hittime = 16

[state 195 , end]
type = changestate
trigger1 =  animtime = 0
ctrl = 1
value = 0

;---------------------------------------------------------------------------
; Shield
[Statedef 950]
type = A
movetype = I
physics = N
sprpriority = 5
anim = 950
ctrl = 0

[State 950, 0]
type = BindToRoot
trigger1 = 1
pos = 0, -35
facing = 1

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

[State 950, 2]
type = AssertSpecial
trigger1 = 1
flag = Invisible

[State 950, 3]
type = VarSet
trigger1 = 1
fv = 10
value = Root, FVar(10) * 2

[State 950, 4]
type = Explod
trigger1 = 1
scale = FVar(10), FVar(10)
sprpriority = 5
bindtime = -1
postype = p1
anim = 950
pos = 0,0
id = 950

[State 950, 5]
type = ChangeState
trigger1 = Root, HitShakeOver = 0
trigger1 = Root, MoveType = H
value = 951

[State 950, 6]
type = DestroySelf
trigger1 = Root, StateNo < 130
trigger2 = Root, StateNo >= 140
trigger2 = Root, StateNo < 150
trigger3 = Root, StateNo >= 160 

;---------------------------------------------------------------------------
; Shield Hit
[Statedef 951]
type = A
movetype = H
physics = N
sprpriority = 1
anim = 950
ctrl = 0

[State 950, 0]
type = BindToRoot
trigger1 = 1
pos = 0, -35
facing = 1

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

[State 950, 2]
type = AssertSpecial
trigger1 = 1
flag = Invisible

[State 950, 3]
type = VarSet
trigger1 = Root, HitShakeOver
fv = 10
value = Root, FVar(10) * 2

[State 950, 4]
type = Explod
trigger1 = 1
scale = FVar(10), FVar(10)
sprpriority = 1
bindtime = -1
postype = p1
anim = 950
pos = 0,0
id = 950

[State 950, 5]
type = PlaySnd
trigger1 = Time <= 0
value = 2,11
channel = 1

[State 950, 6]
type = PalFX
trigger1 = Time <= 0
time = 2
add = 150,150,150

[State 950, 7]
type = ChangeState
trigger1 = Root, HitShakeOver
trigger1 = Root, MoveType != H
value = 950

[State 950, 8]
type = DestroySelf
trigger1 = Root, StateNo < 130
trigger2 = Root, StateNo >= 140
trigger2 = Root, StateNo < 150
trigger3 = Root, StateNo >= 160 

;---------------------------------------------------------------------------
; Big Shield
[Statedef 955]
type = A
movetype = I
physics = N
sprpriority = 5
anim = 955
ctrl = 0

[State 955, 0]
type = BindToRoot
trigger1 = 1
pos = 0, -35
facing = 1

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

[State 955, 2]
type = AssertSpecial
trigger1 = 1
flag = Invisible

[State 955, 3]
type = VarSet
trigger1 = 1
fv = 10
value = Root, FVar(10) * 1

[State 955, 4]
type = Explod
trigger1 = 1
scale = FVar(10), FVar(10)
sprpriority = 5
bindtime = -1
postype = p1
anim = 955
pos = 0,0
id = 955

[State 955, 5]
type = ChangeState
trigger1 = Root, HitShakeOver = 0
trigger1 = Root, MoveType = H
value = 956

[State 955, 6]
type = DestroySelf
trigger1 = Root, StateNo < 130
trigger2 = Root, StateNo >= 140
trigger2 = Root, StateNo < 150
trigger3 = Root, StateNo >= 160 

;---------------------------------------------------------------------------
; Big Shield Hit
[Statedef 956]
type = A
movetype = H
physics = N
sprpriority = 1
anim = 955
ctrl = 0

[State 955, 0]
type = BindToRoot
trigger1 = 1
pos = 0, -35
facing = 1

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

[State 955, 2]
type = AssertSpecial
trigger1 = 1
flag = Invisible

[State 955, 3]
type = VarSet
trigger1 = Root, HitShakeOver
fv = 10
value = Root, FVar(10) * 1

[State 955, 4]
type = Explod
trigger1 = 1
scale = FVar(10), FVar(10)
sprpriority = 1
bindtime = -1
postype = p1
anim = 955
pos = 0,0
id = 955

[State 955, 5]
type = PlaySnd
trigger1 = Time <= 0
value = 2,11
channel = 1

[State 955, 6]
type = PalFX
trigger1 = Time <= 0
time = 2
add = 150,150,150

[State 955, 7]
type = ChangeState
trigger1 = Root, HitShakeOver
trigger1 = Root, MoveType != H
value = 955

[State 955, 8]
type = DestroySelf
trigger1 = Root, StateNo < 130
trigger2 = Root, StateNo >= 140
trigger2 = Root, StateNo < 150
trigger3 = Root, StateNo >= 160 

;---------------------------------------------------------------------------
; Roll
[Statedef 5130]
type    = C
movetype= I
physics = N
velset = 0,0
anim = 10
ctrl = 0

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

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

[State 5130, AngleDraw]
type = AngleDraw
trigger1 = 1

[State 5130, 1]
type = VarSet
trigger1 = Time <= 0
var(0) = 0

[State 5130, 2]
type = VarSet
trigger1 = Time <= 0
trigger1 = command = "holdfwd"
var(0) = 5

[State 5130, 3]
type = VarSet
trigger1 = Time <= 0
trigger1 = command = "holdback"
var(0) = -5

[State 5130, PosSet]
type = PosSet
trigger1 = Time <= 0
y = 0

[State 5130, AngleSet]
type = AngleSet
trigger1 = Time <= 0
trigger2 = Anim = 5130
trigger2 = AnimTime = 0
value = 0

[State 5130, Anim]
type = ChangeAnim
trigger1 = Anim = 10
trigger1 = AnimTime = 0
value = 11

[State 5130, Sound]
type = PlaySnd
trigger1 = Anim = 11
trigger1 = AnimTime = 0
value = 2,20
channel = 1

[State 5130, VelSet]
type = VelSet
trigger1 = Anim = 11
trigger1 = AnimTime = 0
x = Var(0)

[State 5130, AngleSet]
type = AngleSet
trigger1 = Var(0) >= 0
trigger1 = Anim = 11
trigger1 = AnimTime = 0
value = -180

[State 5130, Anim]
type = ChangeAnim
trigger1 = Anim = 11
trigger1 = AnimTime = 0
value = 5130

[State 5130, PalFX]
type = PalFX
triggerall = TimeMod = 2,0
trigger1 = Anim = 10
trigger2 = Anim = 11
trigger3 = Anim = 5130
trigger3 = AnimElem = 2, < 0
time = 1
add = 150,150,150

[State 5130, AngleAdd]
type = AngleAdd
triggerall = Var(0) >= 0
trigger1 = Anim = 5130
trigger1 = AnimElem = 1, > 0
value = -30

[State 5130, AngleAdd]
type = AngleAdd
triggerall = Var(0) < 0
trigger1 = Anim = 5130
trigger1 = AnimElem = 1, > 0
value = 30

[State 5130, AngleAdd]
type = AngleAdd
trigger1 = Anim = 5130
trigger1 = AnimElem = 2
value = 90

[State 5130, 6]
type = ChangeState
trigger1 = Anim = 5130
trigger1 = AnimTime = 0
value = 5131

;---------------------------------------------------------------------------
; Roll End
[Statedef 5131]
type    = C
movetype= I
physics = N
velset = 0,0
anim = 11
ctrl = 0

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

[State 5130, AngleSet]
type = AngleSet
trigger1 = 1
value = 0

[State 5130, 1]
type = VarSet
trigger1 = 1
var(0) = 0

[State 5130, Turn]
type = Turn
trigger1 = P2Dist X < 0

[State 5130, Anim]
type = ChangeAnim
trigger1 = Anim = 11
trigger1 = AnimTime = 0
value = 12

[State 5130, 6]
type = ChangeState
trigger1 = Anim = 12
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Dizzy
[Statedef 5300]
type    = S
movetype= H
physics = S
velset = 0,0
ctrl = 0

[State 5300, 0]
type = ChangeAnim
trigger1 = Anim = 5110
value = 5120

[State 5300, 1]
type = NotHitBy
trigger1 = Anim = 5120
value = SCA
time = 2

[State 5300, 2]
type = ChangeAnim
trigger1 = Anim = 5120
trigger1 = AnimTime = 0
trigger2 = Anim != 5120
trigger2 = Anim != 5300
value = 5300

[State 5300, Sound]
type = PlaySnd
triggerall = Anim = 5300
trigger1 = Time <= 20
trigger1 = AnimElem = 1
trigger2 = TimeMod = 100,0
value = 4,1
channel = 0

[State 5300, 5]
type = ChangeState
trigger1 = Time >= 300
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Guard Damaged
[Statedef 5310]
type    = A
movetype= H
physics = N
anim = 5310
velset = 0,-10
ctrl = 0

[State 5310, Sound]
type = PlaySnd
trigger1 = Time = 0
value = 10, 29
channel = 0

[State 5310, Sound]
type = PlaySnd
trigger1 = Time = 0
value = 2,12
channel = 1

[State 5310, 1]
type = EnvShake
trigger1 = Time = 0
time = 20
freq = 100
ampl = -10
phase = 10

[State 5310, 2]
type = NotHitBy
trigger1 = 1
value = SCA
time = 2

[State 5310, 3]
type = VelAdd
trigger1 = 1
y = .4

[State 5310, 4]
type = PalFX
trigger1 = Time = 0
time = 20
add = 0,0,0
color = 0
sinadd = 80,60,40,20

[State 5310, 5]
type = AngleSet
trigger1 = Time = 0
value = 0

[State 5310, 6]
type = AngleAdd
trigger1 = Time > 0
value = 22.5

[State 5310, 7]
type = AngleDraw
trigger1 = Time > 0
trigger1 = Pos Y < 0

[State 5310, 8]
type = ChangeState
trigger1 = Time > 0
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 5311

;---------------------------------------------------------------------------
; Guard Damaged Hit Ground
[Statedef 5311]
type    = L
movetype= H
physics = N
anim = 5100
velset = 0,0
ctrl = 0

[State 5310, 0]
type = NotHitBy
trigger1 = 1
value = SCA
time = 2

[State 5310, 0]
type = PosSet
trigger1 = 1
Y = 0

[State 5310, 1]
type = PlaySnd
trigger1 = Time = 0
value = F7, 0

[State 5310, 2]
type = GameMakeAnim
trigger1 = Time = 0
value = 60
pos = 0, 0
under = 1

[State 5310, 4]
type = ChangeAnim
trigger1 = Time = 5
value = 5110

[State 5310, 5]
type = ChangeState
trigger1 = Time >= 20
value = 5300

;---------------------------------------------------------------------------
; AI State
[Statedef 6660]
velset = 0,0
anim = 6666
ctrl = 0

[State 6660, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = NoShadow
flag2 = Invisible

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

[State 6660, VarSet]
type = VarSet
trigger1 = 1
var(50) = Parent, Var(50)

[State 6660, Turn]
type = Turn
trigger1 = Facing != Parent, Facing

[State 6660, Variables]
type = DisplayToClipboard
trigger1 = Var(50) = 0
text = "AI Trigger:"

[State 6660, Variables]
type = DisplayToClipboard
trigger1 = Var(50) > 0
text = "AI Trigger: Player"

[State 6660, Variables]
type = DisplayToClipboard
trigger1 = Var(50) < 0
text = "AI Trigger: CPU"

[State 6660, State]
type = ChangeState
trigger1 = Parent, StateNo = 0
value = 6666

;---------------------------------------------------------------------------
; AI Trigger
[Statedef 6666]
velset = 0,0
anim = 6666
ctrl = 0

[State 6666, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = NoShadow
flag2 = Invisible

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

[State 6666, VarSet]
type = VarSet
trigger1 = 1
var(50) = Parent, Var(50)

[State 6666, Turn]
type = Turn
trigger1 = Facing != Parent, Facing

[State 6666, CPU]
type = ParentVarSet
triggerall = Parent, Ctrl
triggerall = Parent, RoundState = 2
trigger1 = Command != "fwd" && Parent, Command = "fwd"
trigger2 = Command != "back" && Parent, Command = "back"
trigger3 = Command != "down" && Parent, Command = "down"
trigger4 = Command != "up" && Parent, Command = "up"
trigger5 = Command != "x" && Parent, Command = "x"
trigger6 = Command != "y" && Parent, Command = "y"
trigger7 = Command != "z" && Parent, Command = "z"
trigger8 = Command != "a" && Parent, Command = "a"
trigger9 = Command != "b" && Parent, Command = "b"
trigger10 = Command != "c" && Parent, Command = "c"
trigger11 = Command != "s" && Parent, Command = "s"
var(50) = -1

[State 6666, Player]
type = ParentVarSet
triggerall = Parent, Ctrl
triggerall = Parent, RoundState = 2
trigger1 = Command = "fwd" && Parent, Command = "fwd"
trigger2 = Command = "back" && Parent, Command = "back"
trigger3 = Command = "down" && Parent, Command = "down"
trigger4 = Command = "up" && Parent, Command = "up"
trigger5 = Command = "x" && Parent, Command = "x"
trigger6 = Command = "y" && Parent, Command = "y"
trigger7 = Command = "z" && Parent, Command = "z"
trigger8 = Command = "a" && Parent, Command = "a"
trigger9 = Command = "b" && Parent, Command = "b"
trigger10 = Command = "c" && Parent, Command = "c"
trigger11 = Command = "s" && Parent, Command = "s"
var(50) = 1

[State 6666, Variables]
type = DisplayToClipboard
trigger1 = Var(50) = 0
text = "AI Trigger:"

[State 6666, Variables]
type = DisplayToClipboard
trigger1 = Var(50) > 0
text = "AI Trigger: Player"

[State 6666, Variables]
type = DisplayToClipboard
trigger1 = Var(50) < 0
text = "AI Trigger: CPU"

[State 6666, State]
type = ChangeState
trigger1 = Parent, StateNo > 0
value = 6660

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