; Apocalypse States
;---------------------------------------------------------------------------
; Stand
[Statedef 10000]
type = S
movetype = I
physics = S
anim = 10000
velset = 0,0

[State 10000, 0]
type = PosSet
trigger1 = Pos Y != 0
y = 0

;---------------------------------------------------------------------------
; Crouch
[Statedef 10010]

[State 10010, Dash]
type = ChangeState
value = 10105
triggerall = Var(10040) > 0
triggerall = Var(10040) < 10
;trigger1 = P2Dist X >= -300
trigger1 = P2Dist X <= -200
trigger2 = P2BodyDist X > 0
trigger2 = P2BodyDist X < 10

[State 10010, Dash]
type = ChangeState
value = 10100
triggerall = Var(10040) > 0
triggerall = Var(10040) < 10
trigger1 = P2BodyDist X >= 400
;trigger1 = P2BodyDist X <= 500

[State 10010, 0]
type = ChangeState
trigger1 = 1
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Walk
[Statedef 10020]
type    = S
physics = S

[State 10020, 1]
type = VelSet
triggerall = Time < 15
triggerall = command = "holdfwd"
trigger1 = P2BodyDist X < 0
trigger2 = P2BodyDist X >= 0
trigger2 = FrontEdgeDist >= 150
x = Const(movement.stand.friction)

[State 10020, 2]
type = VelSet
triggerall = Time < 15
triggerall = command = "holdback"
trigger1 = P2BodyDist X > 0
trigger2 = P2BodyDist X <= 0
trigger2 = BackEdgeDist >= 150
x = Const(movement.stand.friction)

[State 10020, 3]
type = PosAdd
triggerall = Time > 0
triggerall = Time <= 15
trigger1 = TimeMod = 3,0
y = -1

[State 10020, 4]
type = PosAdd
trigger1 = Time > 15
trigger1 = Time <= 20
y = 1

[State 10020, 5]
type = PosSet
trigger1 = Time <= 0
trigger2 = Time >= 20
y = 0

[State 10020, 6]
type = ChangeState
trigger1 = Time >= 20
value = 10021

;---------------------------------------------------------------------------
; Walk Stop
[Statedef 10021]
type    = S
physics = S
velset = 0,0
ctrl = 0

[State 10021, 0]
type = PosSet
trigger1 = Pos Y != 0
y = 0

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

[State 10021, 2]
type = EnvShake
trigger1 = Time = 0
time = 30
freq = 100
ampl = -4

[State 10021, 3]
type = ChangeState
triggerall = Time > 20
trigger1 = command = "holdfwd"
trigger2 = command = "holdback"
value = 10020
ctrl = 1

[State 10021, 4]
type = ChangeState
triggerall = Time > 20
trigger1 = command != "holdfwd"
trigger2 = command != "holdback"
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Jump
[Statedef 10040]

[State 10040, Dash]
type = ChangeState
value = 10105
triggerall = Var(10040) > 0
triggerall = Var(10040) < 10
;trigger1 = P2Dist X >= -300
trigger1 = P2Dist X <= -200
trigger2 = P2BodyDist X > 0
trigger2 = P2BodyDist X < 10

[State 10040, Dash]
type = ChangeState
value = 10100
triggerall = Var(10040) > 0
triggerall = Var(10040) < 10
trigger1 = P2BodyDist X >= 400
;trigger1 = P2BodyDist X <= 500

[State 10040, 0]
type = ChangeState
trigger1 = 1
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Dash Fwd
[Statedef 10100]
type    = S
physics = S
velset = 0,0
ctrl = 0

[State 10100, 0]
type = EnvShake
trigger1 = Time = 0
time = 80
freq = 100
ampl = -2

[State 10100, 1]
type = VelSet
triggerall = Time >= 10
triggerall = Time < 40
trigger1 = P2BodyDist X < 0
trigger2 = P2BodyDist X >= 0
trigger2 = FrontEdgeDist >= 150
x = const(velocity.run.fwd.x)

[State 10100, 2]
type = ChangeState
trigger1 = Time >= 50
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Dash Back
[Statedef 10105]
type    = S
physics = S
velset = 0,0
ctrl = 0

[State 10105, 0]
type = EnvShake
trigger1 = Time = 0
time = 80
freq = 100
ampl = -2

[State 10105, 1]
type = VelSet
triggerall = Time >= 10
triggerall = Time < 40
trigger1 = P2BodyDist X > 0
trigger2 = P2BodyDist X <= 0
trigger2 = BackEdgeDist >= 150
x = const(velocity.run.back.x)

[State 10105, 2]
type = ChangeState
trigger1 = Time >= 50
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Lose by Time Over
[Statedef 10170]
type = S
ctrl = 0
velset = 0,0

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

;---------------------------------------------------------------------------
; Win State
[Statedef 10180]
type = S
ctrl = 0
velset = 0,0

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

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

[State 10180, 2]
type = VarRandom
trigger1 = Time = 0
v = 5
range = 1,4

[State 10180, 3]
type = PlaySnd
trigger1 = var(5) = 1
trigger1 = Time = 0
value = 1, 3
channel = 0

[State 10180, 3]
type = PlaySnd
trigger1 = var(5) = 2
trigger1 = Time = 0
value = 1, 4
channel = 0

[State 10180, 3]
type = PlaySnd
trigger1 = var(5) = 3
trigger1 = Time = 0
value = 1, 5
channel = 0

[State 10180, 3]
type = PlaySnd
trigger1 = var(5) = 4
trigger1 = Time = 0
value = 1, 6
channel = 0

;---------------------------------------------------------------------------
; Intro
[Statedef 10190]
type = S
ctrl = 0
velset = 0,0
anim = 10000

[State 10190, 0]
type = AssertSpecial
trigger1 = 1
flag = Intro
;nnew
flag2=nomusic
flag3=nobardisplay
;new end

[State 10190, 0]
type = Helper
trigger1 = Time = 0
helpertype = normal
name = "Apocalypse"
id = 10190
pos = 0,0
postype = p1
stateno = 10191
keyctrl = 0
ownpal = 1

[State 10190, 1]
type = PosSet
trigger1 = Time = 1
y = 300

[State 10190, Floor]
type = ModifyExplod
trigger1 = Time < 360
sprpriority = 0
id = 19990

[State 10190, Floor]
type = ModifyExplod
trigger1 = Time = 360
sprpriority = -3
id = 19990

[State 10190, 1]
type = PosAdd
triggerall = Time > 220
triggerall = Time < 370
trigger1 = Pos Y > 0
y = -2

[State 10190, 1]
type = PosSet
trigger1 = Pos Y <= 0
trigger2 = Time >= 370
y = 0

[State 10190, 5]
type = ChangeState
trigger1 = Time >= 430
value = 10000

;---------------------------------------------------------------------------
; Apocalypse Intro
[Statedef 10191]
type    = S
ctrl = 0
velset = 0,0
anim = 10190

[State 10190, VarSet]
type = VarSet
trigger1 = Time <= 0
trigger2 = Time = 225
trigger3 = Time >= 250
v = 0
value = 10000

[State 10190, 1]
type = VarRandom
trigger1 = Time = 0
v = 5
range = 1,5

[State 10190, 1]
type = PlaySnd
trigger1 = Var(5) = 1
trigger1 = Time = 10
value = 1, 0
channel = 0

[State 10190, 1]
type = PlaySnd
trigger1 = Var(5) = 2
trigger1 = Time = 50
;value = 1, 3
value = 1, 0
channel = 0

[State 10190, 1]
type = PlaySnd
trigger1 = Var(5) = 3
trigger1 = Time = 50
;value = 1, 4
value = 1, 0
channel = 0

[State 10190, 1]
type = PlaySnd
trigger1 = Var(5) = 4
trigger1 = Time = 50
;value = 1, 5
value = 1, 0
channel = 0

[State 10190, 1]
type = PlaySnd
trigger1 = Var(5) = 5
trigger1 = Time = 10
;value = 1, 6
value = 1, 0
channel = 0

[State 10190, 2]
type = PlaySnd
trigger1 = Time = 270
value = 1, 1
channel = 0

;new
[State 10190, bg1]
type=explod
trigger1= Time = 190
anim=15600
ID=190990
sprpriority=-15
postype=left
pos=0,0
bindtime=-1
removetime=-1
scale = 1.1,1.1
;ontop=1
ownpal=1

[State 10190, bg2]
type=explod
trigger1= Time = 190
anim=15601
ID=190989
sprpriority = -14
postype=left
pos=0,75
bindtime=-1
removetime=-1
;ontop=1
ownpal=1

[State 10190, bg2]
type=explod
trigger1= Time = 190
anim=15602
ID=190989
sprpriority=-13
postype=left
pos=0,75
bindtime=-1
removetime=-1
;ontop=1
ownpal=1

[State 10190, 2]
type = PlaySnd
trigger1 = Time = 210
value = 99, 1
channel = 0

[State 10190, end]
type=removeexplod
trigger1= time>=240
trigger1= numexplod(190989)
ID=190989

[State 10190, end]
type=removeexplod
trigger1= time>=390
trigger1= numexplod(190990)
ID=190990
;new emd

[State 10190, 2]
type = ChangeAnim
trigger1 = Time = 200
value = 10191

[State 10190, 3]
type = VarAdd
trigger1 = Time > 200
trigger1 = Time < 250
v = 0
value = 10010

[State 10190, 3]
type = PalFX
trigger1 = Time > 200
trigger1 = Time < 225
time = 1
add = var(0),Var(0),Var(0)

[State 10190, 4]
type = ChangeAnim
trigger1 = Time = 225
value = 10190

[State 10190, 4]
type = PalFX
trigger1 = Time > 225
trigger1 = Time < 250
time = 1
add = -var(0),-Var(0),-Var(0)

[State 10190, 4]
type = AssertSpecial
trigger1 = Time > 225
flag = Invisible

[State 10190, 4]
type = Explod
trigger1 = Time = 226
id = 10190
anim = 10192
pos = 0,0
postype = p1
sprpriority = 1
shadow = 100,100,100
scale = 1,1

[State 10190, 4]
type = Explod
trigger1 = Time = 228
id = 10190
anim = 10192
pos = 0,0
postype = p1
sprpriority = 1
shadow = 100,100,100
scale = 1.1,1.1

[State 10190, 4]
type = Explod
trigger1 = Time = 230
id = 10190
anim = 10192
pos = 0,0
postype = p1
sprpriority = 1
shadow = 100,100,100
scale = 1.2,1.2

[State 10190, 4]
type = Explod
trigger1 = Time = 232
id = 10190
anim = 10192
pos = 0,0
postype = p1
sprpriority = 1
shadow = 100,100,100
scale = 1.3,1.3

[State 10190, 4]
type = Explod
trigger1 = Time = 234
id = 10190
anim = 10192
pos = 0,0
postype = p1
sprpriority = 1
shadow = 100,100,100
scale = 1.4,1.4

[State 10190, 4]
type = Explod
trigger1 = Time = 236
id = 10190
anim = 10192
pos = 0,0
postype = p1
sprpriority = 1
shadow = 100,100,100
scale = 1.5,1.5

[State 10190, 4]
type = Explod
trigger1 = Time = 238
id = 10190
anim = 10192
pos = 0,0
postype = p1
sprpriority = 1
shadow = 100,100,100
scale = 1.6,1.6

[State 10190, 4]
type = Explod
trigger1 = Time = 240
id = 10190
anim = 10192
pos = 0,0
postype = p1
sprpriority = 1
shadow = 100,100,100
scale = 1.7,1.7

[State 10190, 4]
type = Explod
trigger1 = Time = 242
id = 10190
anim = 10192
pos = 0,0
postype = p1
sprpriority = 1
shadow = 100,100,100
scale = 1.8,1.8

[State 10190, 4]
type = Explod
trigger1 = Time = 244
id = 10190
anim = 10192
pos = 0,0
postype = p1
sprpriority = 1
shadow = 100,100,100
scale = 1.9,1.9

[State 10190, 4]
type = Explod
trigger1 = Time = 246
id = 10190
anim = 10192
pos = 0,0
postype = p1
sprpriority = 1
shadow = 100,100,100
scale = 2,2

;new
[State 10190, bg3]
type=explod
trigger1= Time = 390
anim=15603
ID=190991
sprpriority=-15
postype=left
pos=0,0
bindtime=-1
removetime=-1
scale = 1.1,1.1
;ontop=1
ownpal=1

[State 10190, 2]
type = PlaySnd
trigger1 = Time = 390
value = 99, 0
channel = 0

[State 10190, end]
type=removeexplod
trigger1= time>=430
trigger1= numexplod(190991)
ID=190991
;end new

[State 10190, 5]
type = DestroySelf
trigger1 = Time >=  450;250
trigger2 = Root, StateNo != 190

;---------------------------------------------------------------------------
; Trigger On
[Statedef 10195]
type = S
ctrl = 0
velset = 0,0

[State 10195, VarSet]
type = VarSet
trigger1 = Time <= 0
v = 40
value = 10010

[State 10195, State]
type = ChangeState
trigger1 = Time > 0
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Trigger Off
[Statedef 10196]
type = S
ctrl = 0
velset = 0,0

[State 10196, VarSet]
type = VarSet
trigger1 = Time <= 0
v = 40
value = 10000

[State 10196, State]
type = ChangeState
trigger1 = Time > 0
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Electric
[Statedef 10200]
type = S
physics = S
velset = 0,0
ctrl = 0

[State 10200, 2]
type = ChangeState
triggerall = Time > 0
trigger1 = NumHelper(70) = 0
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Clamp
[Statedef 10205]
type = S
physics = S
velset = 0,0
ctrl = 0

[State 10205, 0]
type = EnvShake
triggerall = Helper(4), AnimElem = 12, >= 0
triggerall = Helper(4), AnimElem = 14, < 0
trigger1 = P2BodyDist X >= 30
trigger1 = TimeMod = 20,0
time = 5
freq = 100
ampl = -5
phase = 10

[State 10205, 1]
type = VelSet
triggerall = Helper(4), AnimElem = 12, >= 0
triggerall = Helper(4), AnimElem = 14, < 0
trigger1 = P2BodyDist X >= 30
x = 2

[State 10205, 2]
type = ChangeState
triggerall = Time > 0
trigger1 = Helper(4), StateNo = 4
trigger2 = Helper(4), AnimTime = 0
trigger3 = Helper(4), StateNo != 4
trigger3 = Helper(4), StateNo != 360
trigger3 = Helper(4), StateNo != 362
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Shoulder Cannon
[Statedef 10210]
type = S
physics = S
velset = 0,0
ctrl = 0

[State 10210, VarSet]
type = VarSet
triggerall = Time <= 1
trigger1 = Var(40) = 0
trigger1 = command = "HSCannon"
trigger2 = Var(40)
trigger2 = command = "b"
v = 1
value = 10002

[State 10210, VarSet]
type = VarSet
triggerall = Time <= 1
trigger1 = Var(40) = 0
trigger1 = command = "SCannon"
trigger2 = Var(40)
trigger2 = command = "y"
v = 1
value = 10001

[State 10210, 2]
type = ChangeState
triggerall = Time > 0
trigger1 = NumHelper(80) = 0
trigger1 = NumHelper(81) = 0
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Spike Ball
[Statedef 10215]
type = S
physics = S
velset = 0,0
ctrl = 0

[State 10215, 2]
type = ChangeState
triggerall = Time > 0
trigger1 = Helper(4), StateNo = 4
trigger2 = Helper(4), AnimTime = 0
trigger3 = Helper(4), StateNo != 4
trigger3 = Helper(4), StateNo != 340
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Eye Beams
[Statedef 10220]
type = S
physics = S
velset = 0,0
ctrl = 0

[State 10220, 0]
type = EnvShake
triggerall = NumHelper(90) > 0
trigger1 = Helper(90), AnimElem = 6, < 0
trigger1 = TimeMod = 20,0
time = 5
freq = 100
ampl = -5
phase = 10

[State 10220, 1]
type = VelSet
triggerall = NumHelper(90) > 0
trigger1 = Helper(90), AnimElem = 5, < 40
x = -5

[State 10220, 1]
type = VelSet
triggerall = FrontEdgeDist >= 200
trigger1 = Time < 150
trigger1 = NumHelper(90) > 0
trigger1 = Helper(90), AnimElem = 6, > 0
x = 5

[State 10220, 2]
type = ChangeState
trigger1 = Time > 0
trigger1 = NumHelper(90) = 0
trigger2 = Time >= 160
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Shock Wave
[Statedef 10225]
type = S
physics = S
velset = 0,0
ctrl = 0

[State 10225, VarRandom]
type = VarRandom
triggerall = Time <= 1
trigger1 = Var(40)
v = 1
range = 1,3

[State 10225, VarSet]
type = VarSet
triggerall = Time <= 1
trigger1 = command = "Shockwave_x"
v = 1
value = 10001

[State 10225, VarSet]
type = VarSet
triggerall = Time <= 1
trigger1 = command = "Shockwave_y"
v = 1
value = 10002

[State 10225, VarSet]
type = VarSet
triggerall = Time <= 1
trigger1 = command = "Shockwave_z"
v = 1
value = 10003

[State 10225, 2]
type = ChangeState
triggerall = Time > 0
trigger1 = Helper(4), StateNo = 4
trigger2 = Helper(4), AnimTime = 0
trigger3 = Helper(4), StateNo != 4
trigger3 = Helper(4), StateNo != 320
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Drill
[Statedef 10230]
type = S
physics = S
velset = 0,0
ctrl = 0

[State 10230, 0]
type = EnvShake
trigger1 = Helper(4), AnimElem = 3, >= 0
trigger1 = Helper(4), AnimElem = 4, < 0
trigger1 = TimeMod = 20,0
time = 5
freq = 100
ampl = -5
phase = 10

[State 10230, 1]
type = VelSet
trigger1 = Helper(4), AnimElem = 3, >= 0
trigger1 = Helper(4), AnimElem = 4, < 0
x = -8

[State 10230, 1]
type = VelSet
triggerall = FrontEdgeDist >= 200
trigger1 = Helper(4), AnimElem = 4, >= 0
x = 8

[State 10230, 2]
type = ChangeState
triggerall = Time > 0
trigger1 = Helper(4), StateNo = 4
trigger2 = Helper(4), StateNo != 4
trigger2 = Helper(4), StateNo != 350
value = 10000
ctrl = 1

;---------------------------------------------------------------------------
; Dead
[Statedef 15150]
type    = L
movetype= H
physics = N
velset = 0,0
sprpriority = -3
anim = 15150
ctrl = 0

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

[State 15150, 1]
type = PosSet
trigger1 = Pos Y <= 0
y = 0

[State 15150, 1]
type = AssertSpecial
trigger1 = NumHelper > 0
flag = Invisible

[State 15150, 2]
type = PlaySnd
trigger1 = NumHelper > 0
trigger1 = Time = 1
value = 2, 0
channel = 0

[State 15150, 2]
type = VarSet
trigger1 = Time = 0
v = 0
value = 10000

[State 15150, 3]
type = VarAdd
trigger1 = Time < 30
v = 0
value = 10010

[State 15150, 3]
type = VarAdd
trigger1 = Time >= 30
trigger1 = Time <= 60
v = 0
value = -10010

[State 15150, 3]
type = AllPalFX
trigger1 = Time < 60
time = 1
add = var(0),Var(0),Var(0)

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

[State 15900, 1] ;Clear all int variables
type = VarRangeSet
trigger1 = RoundNo = 1
value = 10000

[State 15900, 2] ;Clear all float variables
type = VarRangeSet
trigger1 = RoundNo = 1
fvalue = 0

[State 15900, 3] ;Intro
type = ChangeState
trigger1 = RoundNo = 1
;trigger1 = Time = 300
value = 10190

[state 15900, 4] ;Turns Mode Intro
type = ChangeState
trigger1 = RoundsExisted = 0 && TeamMode = Turns && Roundno > 1
value = 100190

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


