;---------------------------------------------------------------------------
; Ultimate Repel Push
[Statedef 168]
type = S
physics = N
anim = 168

[State 168, DestroySelf]
type = DestroySelf
trigger1 = time = 8

[State 168, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA

[State 168, PlayerPush]
type = PlayerPush
trigger1 = 1
value = 1

[State 168, VelSet] 
type = VelSet
trigger1 = time
x = 250.0/(5 + time*time)

[State 168, VarAdd] 
type = VarAdd
trigger1 = time
fvar(0) = -250.0/(5 + time*time)

;[State 168, PosSet] 
;type = PosSet
;trigger1 = 1
;x = root, pos x + root, facing*fvar(0)

;---------------------------------------------------------------------------
; Chronos Trail
[Statedef 1030]
type = S
physics = N
anim = ifelse((root, var(9) = [6, 8]), 2000000 + (root, var(9)*10000) + (root, anim - root, anim%10) + (root, var(23) != 0), 1030)

[State NoShadow]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[State 1030, ChangeState]
type = ChangeState
trigger1 = root, stateno = 1050
value = 1080

[State 1030, DestroySelf]
type = DestroySelf
triggerall = anim = 1030 || animelemno(-1) < 14
trigger1 = root, anim != [1000, 1029]
trigger2 = root, stateno != [1000,1001]
trigger3 = root, movetype = H
trigger4 = root, statetype != S
trigger5 = time
trigger5 = var(11) != root, var(11) || var(12) != root, var(12)

[State 1030, DestroySelf]
type = DestroySelf
trigger1 = animtime = 0
trigger2 = !time
trigger2 = anim != 1030
trigger2 = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) > 14

[State 1030, VarSet]
type = VarSet
trigger1 = 1
var(11) = root, var(11)

[State 1030, VarSet]
type = VarSet
trigger1 = 1
var(12) = root, var(12)

[State 1030, VarSet]
type = VarSet
trigger1 = !time
var(0) = 1

[State 1030, SprPriority]
type = SprPriority
trigger1 = 1
value = root, var(13) + (root, teamside = 1)

[State 1030, ChangeAnim]
type = ChangeAnim
trigger1 = anim = 1030
trigger2 = animelemno(-1) < 15
value = anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0))

[State 1030, Bind]
type = BindToRoot
trigger1 = anim = 1030
trigger2 = animelemno(0) < 15
facing = 1

;---------------------------------------------------------------------------
; Achilles Trail
[Statedef 1080]
type = S
physics = N
anim = ifelse((root, var(9) = [6, 8]), 2000000 + (root, var(9)*10000) + (root, anim - root, anim%10) + (root, var(23) != 0), 1080)

[State NoShadow]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[State 1080, DestroySelf]
type = DestroySelf
triggerall = anim = 1080 || animelemno(-1) < 4
trigger1 = root, anim != [1050, 1079]
trigger2 = root, stateno != 1050
trigger3 = root, movetype = H
trigger4 = root, statetype != S
trigger5 = var(0)
trigger5 = var(11) != root, var(11) || var(12) != root, var(12)

[State 1080, DestroySelf]
type = DestroySelf
trigger1 = var(0)
trigger1 = animtime = 0
trigger2 = !var(0)
trigger2 = anim != 1080
trigger2 = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) > 4

[State 1080, VarSet]
type = VarSet
trigger1 = 1
var(11) = root, var(11)

[State 1080, VarSet]
type = VarSet
trigger1 = 1
var(12) = root, var(12)

[State 1080, VarSet]
type = VarSet
trigger1 = !time
var(0) = 1

[State 1080, SprPriority]
type = SprPriority
trigger1 = 1
value = root, var(13) + (root, teamside = 1)

[State 1080, ChangeAnim]
type = ChangeAnim
trigger1 = anim = 1080
trigger2 = animelemno(-1) < 5
value = anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0))

[State 1080, Bind]
type = BindToRoot
trigger1 = anim = 1080
trigger2 = animelemno(0) < 5
facing = 1

;---------------------------------------------------------------------------
; Mars Slash
[Statedef 1130]
type = S
physics = N
anim = ifelse((root, var(9) = [6, 8]), 2000000 + (root, var(9)*10000) + (root, anim - root, anim%10) + (root, var(23) != 0), 1130)

[State NoShadow]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[State 1130, DestroySelf]
type = DestroySelf
triggerall = anim = 1130 || animelemno(-1) < 13
trigger1 = root, anim != [1100, 1129]
trigger2 = root, stateno != 1100
trigger3 = root, movetype = H
trigger4 = root, statetype != S
trigger5 = time
trigger5 = var(11) != root, var(11) || var(12) != root, var(12)

[State 1130, DestroySelf]
type = DestroySelf
trigger1 = animtime = 0
trigger2 = !time
trigger2 = anim != 1130
trigger2 = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) > 13

[State 1130, VarSet]
type = VarSet
trigger1 = 1
var(11) = root, var(11)

[State 1130, VarSet]
type = VarSet
trigger1 = 1
var(12) = root, var(12)

[State 1130, VarSet]
type = VarSet
trigger1 = !time
var(0) = 1

[State 1130, SprPriority]
type = SprPriority
trigger1 = 1
value = root, var(13) + (root, teamside = 1)

[State 1130, ChangeAnim]
type = ChangeAnim
trigger1 = anim = 1130
trigger2 = animelemno(-1) < 14
value = anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0))

[State 1130, Bind]
type = BindToRoot
trigger1 = anim = 1130
trigger2 = animelemno(0) < 14
facing = 1

;---------------------------------------------------------------------------
; Hercules Trail
[Statedef 2030]
type = S
physics = N
anim = ifelse((root, var(9) = [6, 8]), 2000000 + (root, var(9)*10000) + (root, anim - root, anim%10) + (root, var(23) != 0), 2030)

[State NoShadow]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[State 2030, DestroySelf]
type = DestroySelf
triggerall = anim = 2030 || animelemno(-1) < 17
trigger1 = root, anim != [2000, 2009]
trigger2 = root, stateno != [2000, 2001]
trigger3 = root, movetype = H
trigger4 = root, statetype != S
trigger5 = time
trigger5 = var(11) != root, var(11) || var(12) != root, var(12)

[State 2030, DestroySelf]
type = DestroySelf
trigger1 = animtime = 0
trigger2 = !time
trigger2 = anim != 2030
trigger2 = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) > 17

[State 2030, VarSet]
type = VarSet
trigger1 = 1
var(11) = root, var(11)

[State 2030, VarSet]
type = VarSet
trigger1 = 1
var(12) = root, var(12)

[State 2030, SprPriority]
type = SprPriority
trigger1 = 1
value = root, var(13) + (root, teamside = 1)

[State 2030, ChangeAnim]
type = ChangeAnim
trigger1 = anim = 2030
trigger2 = animelemno(-1) < 18
value = anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0))

[State 2030, Bind]
type = BindToRoot
trigger1 = anim = 2030
trigger2 = animelemno(0) < 18
facing = 1

;---------------------------------------------------------------------------
; Jupiter Rave
[Statedef 2230]
type = S
physics = N
anim = ifelse((root, var(9) = [6, 8]), 2000000 + (root, var(9)*10000) + (root, anim - root, anim%10), 2230)

[State NoShadow]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[State 2230, DestroySelf]
type = DestroySelf
triggerall = anim = 2230 || animelemno(-1) < 9
trigger1 = root, anim != [2210, 2213]
trigger2 = root, stateno != 2210
trigger3 = root, movetype = H
trigger4 = root, statetype != S
trigger5 = time
trigger5 = var(11) != root, var(11) || var(12) != root, var(12)

[State 2230, DestroySelf]
type = DestroySelf
trigger1 = animtime = 0
trigger2 = !time
trigger2 = anim != 2230
trigger2 = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) > 49

[State 2230, VarSet]
type = VarSet
trigger1 = 1
var(11) = root, var(11)

[State 2230, VarSet]
type = VarSet
trigger1 = 1
var(12) = root, var(12)

[State 2230, VarSet]
type = VarSet
trigger1 = !time
var(0) = 1

[State 2230, SprPriority]
type = SprPriority
trigger1 = 1
value = root, var(13) + (root, teamside = 1)

[State 2230, ChangeAnim]
type = ChangeAnim
trigger1 = anim = 2230
trigger2 = animelemno(-1) < 10
value = anim
elem = ifelse(root, animelemno(ifelse(gametime > root, var(56), -1, 0)) > 40, root, animelemno(ifelse(gametime > root, var(56), -1, 0)) - 40, 15)

[State 2230, Bind]
type = BindToRoot
trigger1 = anim = 2230
trigger2 = animelemno(0) < 10
facing = 1

;---------------------------------------------------------------------------
; Jupiter Rave BG Handler

[Statedef 2240]
type = A
physics = N
movetype = A
anim = 9999

[State 2240, AssertSpecial]
type = AssertSpecial
trigger1 = numexplod(7501)
trigger2 = numexplod(7502)
trigger3 = numexplod(7503)
flag = NoBG
flag2 = NoFG

[State 2240, ChangeState]
type = ChangeState
trigger1 = parent, anim != [2210, 2213]
trigger1 = parent, anim != [200, 203]
trigger2 = parent, stateno != 2210 || parent, animelemno(0) > 48
trigger2 = parent, stateno != 2200 || (parent, animelem = 7 && !parent, movehit)
trigger3 = parent, movetype = H
trigger4 = parent, statetype != S
value = 2241

[State 2240, Explod]
type = Explod
trigger1 = time = 0
postype = left
id = 7501
anim = 7551
bindtime = -1
sprpriority = -5
supermovetime = 99999
ownpal = 1

[State 2240, Explod]
type = Explod
trigger1 = (time - 24)%32 = 0
postype = left
id = 7502
anim = 7552
bindtime = -1
sprpriority = -5
supermovetime = 99999
ownpal = 1

[Statedef 2241]
type = A
physics = N
movetype = A
anim = 9999

[State 2241, RemoveExplod]
type = RemoveExplod
trigger1 = !time
id = 7501

[State 2241, RemoveExplod]
type = RemoveExplod
trigger1 = !time
id = 7502

[State 2241, Explod]
type = Explod
trigger1 = !time
postype = left
id = 7503
anim = 7553
bindtime = -1
sprpriority = -5
supermovetime = 99999
ownpal = 1

[State 2241, RemoveExplod]
type = RemoveExplod
trigger1 = !numexplod(7503)
id = 4310

[State 2241, AssertSpecial]
type = AssertSpecial
trigger1 = numexplod(7503)
flag = NoBG
flag2 = NoFG

[State 2241, DestroySelf]
type = DestroySelf
trigger1 = !numexplod(7503)
value = prevstateno

;---------------------------------------------------------------------------
; Jupiter Rave Screenbounder
[Statedef 2250]
type = S
physics = N
anim = 9999
velset = 1.2, 0

[State 2250, DestroySelf]
type = DestroySelf
trigger1 = time > 165

[State 2250, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 1
movecamera = (root, numtarget), 0


;---------------------------------------------------------------------------
; Screenbounder
[Statedef 1040]
type = S
physics = N
anim = 9999

[State 1040, DestroySelf]
type = DestroySelf
trigger1 = time > 10
trigger2 = vel x > 0
trigger2 = rootdist x < 1
trigger3 = vel x < 0
trigger3 = rootdist x > -1

[State 1040, VelSet]
type = VelSet
trigger1 = 1
x = (root, vel x*facing*root, facing)*(1 - 0.1*time) + (rootdist x + (root, vel x*facing*root, facing))*0.1*time

[State 1040, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 1
movecamera = 1, 1


;---------------------------------------------------------------------------
; Apollo Screenbounder
[Statedef 1450]
type = S
physics = N
anim = 9999

[State 1450, ChangeState]
type = ChangeState
trigger1 = root, stateno = 1401
value = 1451

[State 1450, BindToParent]
type = BindToParent
trigger1 = 1

[Statedef 1451]
type = S
physics = N
anim = 9999

[State 1451, ChangeState]
type = ChangeState
trigger1 = root, stateno = 1402
value = 1452

[State 1451, DestroySelf]
type = DestroySelf
trigger1 = root, stateno != 1401
trigger2 = root, movetype != A
trigger3 = root, statetype != A
trigger4 = root, animelemno(0) > 4

[State 1451, VarSet]
type = VarSet
trigger1 = 1
var(0) = floor(root, p2dist y)

[State 1451, VarSet]
type = VarSet
trigger1 = var(0) > 0
var(0) = 0

[State 1451, BindToParent]
type = PosAdd
trigger1 = 1
x = (root, vel x*facing*root, facing)*(1 - 0.1*var(1)) + (rootdist x + (root, vel x*facing*root, facing))*0.1*var(1)

[State 1451, BindToParent]
type = PosSet
trigger1 = 1
y = root, pos y + var(0)

[State 1451, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 1
movecamera = 1, 1

[State 1451, VarAdd]
type = VarAdd
trigger1 = var(1) < 10
var(1) = 1


; Apollo Screenbounder
[Statedef 1452]
type = S
physics = N
anim = 9999

[State 1452, DestroySelf]
type = DestroySelf
trigger1 = root, stateno != 1402
trigger2 = root, movetype != A
trigger3 = root, statetype != A

[State 1452, VarAdd]
type = VarAdd
trigger1 = var(1) < 10
var(1) = 1

[State 1452, ChangeState]
type = ChangeState
trigger1 = root, animelem = 6, = 2
trigger1 = fvar(0) := 0 || 1
value = 1453

[State 1452, VarAdd]
type = VarAdd
trigger1 = fvar(0) < 1
trigger1 = !root, hitpausetime
fvar(0) = 0.07

[State 1452, VarAdd]
type = VarSet
trigger1 = fvar(0) > 1
fvar(0) = 1

[State 1452, BindToParent]
type = PosAdd
trigger1 = 1
x = (root, vel x*facing*root, facing)*(1 - 0.1*var(1)) + (rootdist x + 88*const(size.xscale)*fvar(0) + (root, vel x*facing*root, facing))*0.1*var(1)

[State 1452, BindToParent]
type = PosSet
trigger1 = 1
y = root, pos y - 32*fvar(0) + root, fvar(0)*(1 - fvar(0))

[State 1452, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 1
movecamera = 1, 1


; Apollo Screenbounder
[Statedef 1453]
type = S
physics = N
anim = 9999

[State 1453, DestroySelf]
type = DestroySelf
trigger1 = root, movetype = H
trigger2 = root, statetype != A
trigger3 = vel y > 0
trigger3 = rootdist y > 1
trigger4 = vel y < 0
trigger4 = rootdist y < -1

[State 1453, VarSet]
type = VarSet
trigger1 = time < 21
fvar(0) = time*0.05

[State 1453, VarSet]
type = VarSet
trigger1 = !time
fvar(1) = -rootdist y

[State 1453, BindToParent]
type = BindToParent
trigger1 = 1
pos = 0, floor(fvar(1)*(1 - fvar(0)))

[State 1453, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 1
movecamera = 0, 1


;---------------------------------------------------------------------------
; Perseus Trail
[Statedef 1530]
type = S
physics = N
anim = ifelse((root, var(9) = [6, 8]), 2000000 + (root, var(9)*10000) + 1000 + (root, var(23) != 0), 1030)

[State NoShadow]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[State 1530, DestroySelf]
type = DestroySelf
triggerall = anim != 2081555 + (root, var(23) != 0) || animelemno(-1) < 8
trigger1 = root, anim != 1506
trigger1 = root, anim != 1505
trigger1 = root, anim != [420, 429]
trigger2 = root, stateno != 1505
trigger3 = root, movetype = H
trigger4 = root, statetype != S
trigger4 = root, statetype != C
trigger5 = var(0)
trigger5 = var(11) != root, var(11) || var(12) != root, var(12)

[State 1530, DestroySelf]
type = DestroySelf
trigger1 = var(0)
trigger1 = anim%100 > 50
trigger1 = animtime = 0
trigger2 = !var(0)
trigger2 = abs(root, var(9)) = 8
trigger2 = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) > 6 || root, anim = 1506

[State 1530, VarSet]
type = VarSet
trigger1 = 1
var(11) = root, var(11)

[State 1530, VarSet]
type = VarSet
trigger1 = 1
var(12) = root, var(12)

[State 1530, VarSet]
type = VarSet
trigger1 = !time
var(0) = 1

[State 1530, SprPriority]
type = SprPriority
trigger1 = 1
value = root, var(13) + (root, teamside = 1)

[State 1530, ChangeAnim]
type = ChangeAnim
trigger1 = root, anim = 1505
trigger1 = root, animelemno(0) < 3
value = anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) + 8

[State 1530, ChangeAnim]
type = ChangeAnim
trigger1 = root, anim = 1505
trigger1 = root, animelemno(0) > 2
value = ifelse((root, var(9) = [6, 8]), 2000000 + (root, var(9)*10000) + 1050 + (root, var(23) != 0), 1080)
persistent = 0

[State 1530, ChangeAnim]
type = ChangeAnim
trigger1 = root, anim = 1505
trigger1 = root, animelemno(0) > 2
value = anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) - 2

[State 1530, ChangeAnim]
type = ChangeAnim
trigger1 = root, anim = [420, 429]
value = ifelse((root, var(9) = [6, 8]), 2000000 + (root, var(9)*10000) + 1555 + (root, var(23) != 0), 1580)
persistent = 0

[State 1530, ChangeAnim]
type = ChangeAnim
triggerall = anim != 2081555 + (root, var(23) != 0) || animelemno(-1) < 8
trigger1 = root, anim = [420, 429]
value = anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) + 1

[State 1530, ChangeAnim]
type = ChangeAnim
trigger1 = root, anim = 1506
value = ifelse((root, var(9) = [6, 8]), 2000000 + (root, var(9)*10000) + 1555 + (root, var(23) != 0), 1580)
persistent = 0

[State 1530, ChangeAnim]
type = ChangeAnim
triggerall = anim != 2081555 + (root, var(23) != 0) || animelemno(-1) < 8
trigger1 = root, anim = 1506
value = anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) + 15

[State 1530, Bind]
type = BindToRoot
trigger1 = anim != 2081555 + (root, var(23) != 0)
trigger2 = animelemno(0) < 8
facing = 1

;---------------------------------------------------------------------------
; Perseus Trail
[Statedef 1580]
type = S
physics = N
anim = ifelse((root, var(9) = [6, 8]), 2000000 + (root, var(9)*10000) + 1555 + (root, var(23) != 0), 1580)

[State NoShadow]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[State 1580, DestroySelf]
type = DestroySelf
triggerall = anim != 2081555 + (root, var(23) != 0) || animelemno(-1) < 7
trigger1 = root, anim != 1506
trigger1 = root, anim != 1555
trigger1 = root, anim != [420, 429]
trigger2 = root, stateno != 1555
trigger3 = root, movetype = H
trigger4 = root, statetype != S
trigger4 = root, statetype != C
trigger5 = var(0)
trigger5 = var(11) != root, var(11) || var(12) != root, var(12)

[State 1580, DestroySelf]
type = DestroySelf
trigger1 = var(0)
trigger1 = animtime = 0
trigger2 = !var(0)
trigger2 = anim = 2081555 + (root, var(23) != 0)
trigger2 = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) > 6 || root, anim = 1506

[State 1580, VarSet]
type = VarSet
trigger1 = 1
var(11) = root, var(11)

[State 1580, VarSet]
type = VarSet
trigger1 = 1
var(12) = root, var(12)

[State 1580, VarSet]
type = VarSet
trigger1 = !time
var(0) = 1

[State 1580, SprPriority]
type = SprPriority
trigger1 = 1
value = root, var(13) + (root, teamside = 1)

[State 1580, ChangeAnim]
type = ChangeAnim
triggerall = anim != 2081555 + (root, var(23) != 0) || animelemno(-1) < 8
trigger1 = root, anim = 1555
value = anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0))

[State 1580, ChangeAnim]
type = ChangeAnim
triggerall = anim != 2081555 + (root, var(23) != 0) || animelemno(-1) < 8
trigger1 = root, anim = [420, 429]
value = anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) + 1

[State 1580, ChangeAnim]
type = ChangeAnim
triggerall = anim != 2081555 + (root, var(23) != 0) || animelemno(-1) < 8
trigger1 = root, anim = 1506
value = anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0)) + 15

[State 1580, Bind]
type = BindToRoot
trigger1 = anim != 2081555 + (root, var(23) != 0)
trigger2 = animelemno(0) < 8
facing = 1

;======================================================================================
;--------------------------------------------------------------------------------------
;Ice Helper
;Vars 0 and 1 = x/y offset
;Var(2) = destroyself

[Statedef 7060]
type = S
physics = N
sprpriority = 1

[State 7060, VarSet]
type = VarSet
trigger1 = time = 0
var(0) = random%11 - 5

[State 7060, VarSet]
type = VarSet
trigger1 = time = 0
var(1) = random%15 - 7

[State 7060, ChangeAnim]
type = ChangeAnim
trigger1 = time = 0
value = 7060 + random%4

[State 7060, Bind]
type = PosAdd
trigger1 = 1
x = p2dist x + var(0) - ifelse((enemynear, anim = [5000, 5002]), 0, 10) + enemynear, const(size.mid.pos.x)
y = p2dist y + var(1) + enemynear, const(size.mid.pos.y)

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

[State 7060, VarSet]
type = VarSet
trigger1 = root, numhelper(7060) > 2
trigger1 = time > 2
var(2) = 1

[State 7060, VarSet]
type = VarSet
trigger1 = p2movetype != H
trigger2 = enemynear, stateno != [5706, 5707]
trigger3 = enemynear, stateno = 5706
trigger3 = p2statetype != S
trigger4 = enemynear, stateno = 5707
trigger4 = p2statetype != A
var(2) = 2

[State 7060, VarAdd]
type = VarSet
trigger1 = !var(2)
var(3) = 0

[State 7060, VarAdd]
type = VarAdd
trigger1 = var(2)
var(3) = 1

[State 7060, PlaySnd]
type = PlaySnd
trigger1 = var(3) = 2
value = 7060, 0

[State 7060, Explod]
type = Explod
trigger1 = var(3) = 2
anim = 7064 + random%3
id = 7064
vel = 3, 4
sprpriority = 2

[State 7060, Explod]
type = Explod
trigger1 = var(3) = 2
anim = 7064 + random%3
id = 7064
bindtime = 1
vel = 4, -3
sprpriority = 2

[State 7060, Explod]
type = Explod
trigger1 = var(3) = 2
anim = 7067 + random%3
id = 7064
vel = -3, 4
sprpriority = 2

[State 7060, Explod]
type = Explod
trigger1 = var(3) = 2
anim = 7067 + random%3
id = 7064
bindtime = 1
vel = -4, -3
sprpriority = 2

[State 7060, DestroySelf]
type = DestroySelf
trigger1 = var(3) > 1


;===============================================================
;Helper Controller/Origin marker
;vars 11, 12, 26, 48 used
;vars 30-40 used by 19999

[Statedef 9999]
type = S
physics = N
anim = 9999
ctrl = 0

[State 9999, Width]
type = Width
trigger1 = 1
value = -const(size.ground.front), -const(size.ground.back)

[State 9999, FX Sound Reset]
type = VarSet
trigger1 = 1
var(26) = -1

[State 9999, Fire FX, 2nd Check]
type = Explod
triggerall = root, var(27) = -1
triggerall = root, var(26) = -1
trigger1 = numenemy
trigger1 = enemy(0), time < 2
trigger1 = enemy(0), movetype = H
trigger1 = var(26) := 0 || 1
trigger2 = numenemy > 1
trigger2 = enemy(1), time < 2
trigger2 = enemy(1), movetype = H
trigger2 = var(26) := 1
id = 7050
anim = 7050 + random%3
sprpriority = 2
postype = p2
bindtime = 45 
pos = 0, floor(enemy(var(26)), const(size.mid.pos.y))
random = floor((enemy(var(26)), const(size.ground.front)+enemy(var(26)), const(size.ground.back))*(root, hitcount != 0)*0.4), floor((enemy(var(26)), const(size.mid.pos.y)-enemy(var(26)), const(size.head.pos.y))*(root, hitcount != 0)*0.8)

[State 9999, Shock FX, 2nd Check]
type = Explod
triggerall = root, var(27) = -3
triggerall = root, var(26) = -1
trigger1 = numenemy
trigger1 = enemy(0), time < 2
trigger1 = enemy(0), movetype = H
trigger1 = var(26) := 0 || 1
trigger2 = numenemy > 1
trigger2 = enemy(1), time < 2
trigger2 = enemy(1), movetype = H
trigger2 = var(26) := 1
id = 7070
anim = 7070 + random%5
sprpriority = 2
postype = p2
bindtime = 45 
pos = 0, floor(enemy(var(26)), const(size.mid.pos.y))
random = floor((enemy(var(26)), const(size.ground.front)+enemy(var(26)), const(size.ground.back))*(root, hitcount != 0)*0.4), floor((enemy(var(26)), const(size.mid.pos.y)-enemy(var(26)), const(size.head.pos.y))*(root, hitcount != 0)*0.8)

[State 9999, FX Sound]
type = PlaySnd
trigger1 = var(26) = [0, 1]
value = 5, 7 - root, var(27)
abspan = floor(enemy(var(26)), pos x)

[State 9999, Turn]
type = Turn
trigger1 = facing != root, facing

[State 9999, PosSet]
type = PosSet
trigger1 = parent, statetype != A
x = parent, pos x + (parent, p2bodydist x/2 + parent, const(size.ground.front)*parent, const(size.xscale))*parent, facing
y = parent, pos y + parent, p2dist y/2

[State 9999, PosSet]
type = PosSet
trigger1 = parent, statetype = A
x = parent, pos x + (parent, p2bodydist x/2 + parent, const(size.air.front)*parent, const(size.xscale))*parent, facing
y = parent, pos y + parent, p2dist y/2

[State 9999, VarSet]
type = VarSet
trigger1 = inguarddist
var(0) = -1

[State 9999, VarSet]
type = VarSet
trigger1 = var(0) > 0
var(0) = 0

[State 9999, PosAdd]
type = PosAdd
trigger1 = var(0) = -1
trigger1 = !inguarddist
trigger1 = var(0) := 1
x = rootdist x*0.2

[State 9999, VarSet]
type = VarSet
trigger1 = var(0) = 1
trigger1 = inguarddist
var(0) = 2

[State 9999, PosSet]
type = PosSet
triggerall = var(0) > 0
trigger1 = parent, statetype != A
x = parent, pos x + (parent, p2bodydist x/2 + parent, const(size.ground.front)*parent, const(size.xscale))*parent, facing
y = parent, pos y + parent, p2dist y/2

[State 9999, PosSet]
type = PosSet
triggerall = var(0) > 0
trigger1 = parent, statetype = A
x = parent, pos x + (parent, p2bodydist x/2 + parent, const(size.air.front)*parent, const(size.xscale))*parent, facing
y = parent, pos y + parent, p2dist y/2

[State Debug Info]
type = DisplayToClipboard
trigger1 = 1
text = "%d, %d, %d, %d, %1f"
params = (root, movehit), (enemy, stateno), (enemy, time), (enemy, movetype = H), (parent, p2bodydist x)

[State 9999, Weapon Lost]
type = ParentVarSet
triggerall = root, var(9) > 0
trigger1 = root, movetype = H && root, time > -1 && root, anim = [200, 4999]
var(9) = -root, var(9)

[State 9999, Weapon Trails]
type = Helper
triggerall = var(11) != root, var(11) || var(12) != root, var(12)
trigger1 = root, var(17)
name = "trail"
id = root, var(17)
stateno = root, var(17)
ownpal = 1
pausemovetime = 99999
supermovetime = 99999

[State 9999, Force Respawn]
type = VarSet
triggerall = root, var(9) > 0
trigger1 = !numhelper(10000) || !numhelper(10001) || !numhelper(10002)
var(11) = 9999

[State 9999, Weapon]
type = Helper
triggerall = var(11) != root, var(11) || var(12) != root, var(12)
triggerall = root, var(9) > 0
trigger1 = root, var(11) > 0
trigger1 = root, var(11) >= root, var(12)
name = "w"
id = 10000
stateno = 10000
ownpal = 0
pausemovetime = 99999
supermovetime = 99999

[State 9999, Shield]
type = Helper
triggerall = var(11) != root, var(11) || var(12) != root, var(12)
triggerall = root, var(9) > 0
trigger1 = root, var(12) > 0
name = "s"
id = 10001
stateno = 10001
ownpal = 0
pausemovetime = 99999
supermovetime = 99999

[State 9999, Weapon]
type = Helper
triggerall = var(11) != root, var(11) || var(12) != root, var(12)
triggerall = root, var(9) > 0
trigger1 = root, var(11) > 0
trigger1 = root, var(11) < root, var(12)
name = "w"
id = 10000
stateno = 10000
ownpal = 0
pausemovetime = 99999
supermovetime = 99999

[State 9999, Body]
type = Helper
triggerall = var(11) != root, var(11) || var(12) != root, var(12)
trigger1 = root, var(9) > 0
name = "b"
id = 10002
stateno = 10002
ownpal = 0
pausemovetime = 99999
supermovetime = 99999

[State 9999, Shield]
type = Helper
triggerall = var(11) != root, var(11) || var(12) != root, var(12)
triggerall = root, var(9) > 0
trigger1 = root, var(12) < 1
trigger1 = root, var(12) > root, var(11)
name = "s"
id = 10001
stateno = 10001
ownpal = 0
pausemovetime = 99999
supermovetime = 99999

[State 9999, Weapon]
type = Helper
triggerall = var(11) != root, var(11) || var(12) != root, var(12)
triggerall = root, var(9) > 0
trigger1 = root, var(11) < 1
name = "w"
id = 10000
stateno = 10000
ownpal = 0
pausemovetime = 99999
supermovetime = 99999

[State 9999, Shield]
type = Helper
triggerall = var(11) != root, var(11) || var(12) != root, var(12)
triggerall = root, var(9) > 0
trigger1 = root, var(12) < 1
trigger1 = root, var(12) <= root, var(11)
name = "s"
id = 10001
stateno = 10001
ownpal = 0
pausemovetime = 99999
supermovetime = 99999

[State 9999, VarSet]
type = VarSet
trigger1 = 1
var(11) = root, var(11)

[State 9999, VarSet]
type = VarSet
trigger1 = 1
var(12) = root, var(12)

[State 9999, Super BG]
type = AssertSpecial
trigger1 = numexplod(7500)
trigger2 = numexplod(7501)
trigger3 = numexplod(7502)
trigger4 = numexplod(7503)
flag = NoFG
;flag2 = GlobalNoShadow

[State 9999, VarSet]
type = VarSet
triggerall = roundstate < 3
trigger1 = root, movetype = A
var(32) = root, stateno

[State AI, Perseus Charge Time]
type = ParentVarSet
trigger1 = root, var(59) > 0
var(50) = -root, var(50)
ignorehitpause = 1

[State AI, Perseus Charge Time]
type = ParentVarSet
triggerall = root, var(59) > 0
trigger1 = root, command = "holdback"
trigger1 = root, movetype != H
trigger2 = root, statetype = A
trigger3 = root, stateno = [10, 11]
trigger4 = root, stateno = [120, 132]
trigger5 = root, movetype = H
trigger6 = !root, ctrl
trigger6 = root, time
trigger7 = !root, ctrl
trigger7 = root, stateno != 100
trigger7 = root, stateno != [900, 910]
trigger7 = root, stateno != 1000
trigger7 = root, stateno != 1100
trigger7 = root, stateno != 1200
trigger7 = root, stateno != 1400
trigger7 = root, stateno != 1500
trigger7 = root, stateno != 1550
var(50) = -root, var(50) + 1
ignorehitpause = 1

[State AI, Perseus Charge Time]
type = ParentVarSet
trigger1 = root, var(59) > 0
trigger1 = root, var(50) < 0
var(50) = 0
ignorehitpause = 1

[State AI, Perseus Buffer Time]
type = ParentVarSet
trigger1 = root, var(59) > 0
trigger1 = root, var(50) > 44
var(49) = 10
ignorehitpause = 1

[State AI, Perseus Buffer Time]
type = ParentVarAdd
trigger1 = root, var(59) > 0
trigger1 = root, var(49) > 0
var(49) = -1
ignorehitpause = 1

[State AI, Enemy SuperAttack]
type = VarSet
triggerall = var(48)
triggerall = enemynear, time < 2
trigger1 = root, var(56) = gametime
var(48) = 0
ignorehitpause = 1

[State AI, Enemy SuperAttack]
type = ParentVarSet
trigger1 = root, var(56) != gametime
trigger1 = !root, hitpausetime
trigger1 = var(48) := 1
var(48) = 1
ignorehitpause = 1

[State AI, Enemy SuperAttack]
type = ParentVarSet
triggerall = root, var(48)
triggerall = !var(48)
trigger1 = root, p2movetype != A
trigger1 = !inguarddist
trigger1 = !root, inguarddist
var(48) = 0
ignorehitpause = 1

[State 9999, ChangeState]
type = ChangeState
trigger1 = root, var(20)
trigger1 = root, var(20) < root, var(40)
value = 19999 ;will return here next tick

;===============================================================
;Weapon Helper

[Statedef 10000]
type = S
physics = N
anim = 9999

[State 10000, VarSet]
type = VarSet
trigger1 = 1
var(1) = root, anim + root, var(9)*10000

[State 10000, VarSet]
type = VarSet
triggerall = !selfanimexist(var(1))
triggerall = root, movetype != H
trigger1 = root, anim = [200, 229]
trigger2 = root, anim = [260, 269]
trigger3 = root, anim = [400, 470]
trigger4 = root, anim = [600, 689]
trigger5 = root, anim = [900, 919]
trigger6 = root, anim = [1000, 1029]
trigger7 = root, anim = [1050, 1079]
trigger8 = root, anim = [1100, 1129]
trigger9 = root, anim = [1610, 1619]
trigger10 = root, anim = [2000, 2009]
trigger11 = root, anim = [2210, 2219]
var(1) = var(1) - var(1)%10 + ifelse(root, var(9) = 9, 1, ifelse(root, var(9) = 4, 2, ifelse(root, var(9) = 5, 3, 0)))

[State 10000, ChangeState]
type = ChangeState
trigger1 = !selfanimexist(var(1))
trigger2 = root, movetype = H && root, anim = [200, 4999]
trigger3 = root, anim > 5930
trigger4 = root, var(9) != 5
trigger4 = anim/10000 = 5
value = 10010

[State 10000, DestroySelf]
type = DestroySelf
trigger1 = time
trigger1 = var(11) != root, var(11) || var(12) != root, var(12) || numhelper(10000) > 1
trigger2 = numhelper(10000)
trigger2 = helper(10000), stateno != 10000 && root, var(9) < 1

[State 10000, VarSet]
type = VarSet
trigger1 = 1
var(0) = ifelse(gametime > root, var(56), -1, 0)

[State 10000, VarSet]
type = VarSet
trigger1 = 1
var(11) = root, var(11)

[State 10000, VarSet]
type = VarSet
trigger1 = 1
var(12) = root, var(12)

[State 10000, Bind]
type = BindToRoot
trigger1 = 1
facing = 1
pos = ifelse( root, hitshakeover || root, anim = 5080, 0, (root, time%2) ), 0

[State 10000, SprPriority]
type = SprPriority
trigger1 = 1
value = root, var(13) + ((root, stateno != 166) && (root, teamside = 1))

[State 10000, SprPriority for Gaia/Gigas Driver]
type = SprPriority
trigger1 = root, anim = 1203 || root, anim = 2103
trigger1 = root, movetype = A
trigger1 = root, statetype = A
value = -1

[State 10000, SprPriority for Hit States Default]
type = SprPriority
trigger1 = root, movetype = H
trigger1 = root, anim != 161 || root, statetype != S || root, stateno != [161, 162]
value = 1

[State 10000, SprPriority for Hit States]
type = SprPriority
trigger1 = root, anim = [5000, 5001]
trigger1 = root, animelemno(var(0)) > 1
value = -1

[State 10000, SprPriority for Hit States]
type = SprPriority
trigger1 = root, anim = 5040
trigger1 = (root, animelemno(var(0)) = [3, 4]) || root, animelemno(var(0)) = [5, 9]
trigger2 = root, anim = 5050
trigger2 = root, animelemno(var(0)) > 3
trigger3 = root, anim = 5061
trigger3 = root, animelemno(var(0)) = [7, 10]
trigger4 = root, anim = 5080
trigger5 = root, anim = [5101, 5102]
trigger5 = root, animelemno(var(0)) > 6
trigger6 = root, anim = 5110 || root, anim = 5150
trigger7 = root, anim = 5120
trigger7 = root, animelemno(var(0)) < 5
trigger8 = root, anim = 5163
trigger8 = root, animelemno(0) > 3
trigger9 = root, anim = 5173
trigger10 = root, anim = 5170
trigger10 = root, animelemno(var(0)) != 1
trigger11 = root, anim = [5171, 5172]
trigger12 = root, anim = 5180
trigger12 = root, animelemno(var(0)) > 3
trigger13 = root, anim = 5200 || root, anim = 5210
trigger13 = root, animelemno(var(0)) < 6
value = 0

[State 10000, SprPriority for Hit States]
type = SprPriority
trigger1 = root, stateno = 5150
trigger1 = !root, alive
value = -3

[State 10000, SprPriority for Hit States]
type = SprPriority
trigger1 = root, statetype = A
trigger1 = root, anim = [122, 155]
value = 2 - root, movetype = H

[State 10000, ChangeAnim]
type = ChangeAnim
trigger1 = 1
value = var(1)
elem = root, animelemno(var(0))

;===============================================================
;Weapon Lost

[Statedef 10010]
type = S
physics = N
velset = -2, -7.5
sprpriority = root, var(11)

[State 10010, Helper]
type = Helper
trigger1 = !time
trigger1 = !root, var(20)
trigger1 = anim/10000 = 5
trigger1 = abs(root, var(9)) != 5
name = "wfade"
id = 10020
stateno = 10020
ownpal = 1
pausemovetime = 99999
supermovetime = 99999
size.head.pos = anim, animelemno(0)

[State 10010, DestroySelf]
type = DestroySelf
trigger1 = !time
trigger1 = anim/10000 = 5
trigger1 = abs(root, var(9)) != 5

[State 10010, ChangeAnim]
type = ChangeAnim
trigger1 = 1
value = anim
elem = ifelse(animelemno(0) = 1, 1, animelemno(-1))

[State 10010, VelAdd]
type = VelAdd
trigger1 = 1
y = 0.45

[State 10010, AssertSpecial]
type = AssertSpecial
trigger1 = time > 9
trigger1 = time%2
flag = Invisible

[State 10010, AssertSpecial]
type = AssertSpecial
trigger1 = time > 9
flag = NoShadow

[State 10010, DestroySelf]
type = DestroySelf
trigger1 = time > 35
trigger1 = pos y > -vel y
trigger2 = anim = 9999
trigger3 = root, var(9) > 0
trigger3 = selfanimexist(root, anim + root, var(9)*10000)
trigger3 = root, movetype != H && root, anim < 5922

[Statedef 10020]
type = S
physics = N
velset = 0, 0
sprpriority = 4

[State 10020, PlaySnd]
type = PlaySnd
trigger1 = !time
value = 1310, 1

[State 10020, ChangeAnim]
type = ChangeAnim
trigger1 = !time
value = const(size.head.pos.x)
elem = const(size.head.pos.y)

[State 10020, PosAdd]
type = PosAdd
trigger1 = time
x = ifelse(time%2, -1, 1)*(time + (time + 1))*0.5
y = ifelse(time%2, 1, -1)*(time + (time + 1))*0.5

[State 10020, ChangeAnim]
type = ChangeAnim
trigger1 = 1
value = anim
elem = ifelse(animelemno(0) = 1, 1, animelemno(-1))

[State 10020, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[State 10020, DestroySelf]
type = DestroySelf
trigger1 = time > 16

[State 10020, Trans]
type = Trans
trigger1 = 1
trans = addalpha
alpha = 256 - 16*time, 0

;===============================================================
;Shield Helper

[Statedef 10001]
type = S
physics = N
anim = 9999

[State 10001, VarSet]
type = VarSet
trigger1 = 1
var(1) = root, anim + 1000000 + root, var(10)*10000

[State 10001, VarSet]
type = VarSet
triggerall = root, movetype != H
trigger1 = root, anim = [200, 229]
trigger2 = root, anim = [260, 269]
trigger3 = root, anim = [400, 470]
trigger4 = root, anim = [600, 689]
trigger5 = root, anim = [900, 919]
trigger6 = root, anim = [1000, 1029]
trigger7 = root, anim = [1050, 1079]
trigger8 = root, anim = [1100, 1129]
trigger9 = root, anim = [1610, 1619]
trigger10 = root, anim = [2000, 2009]
trigger11 = root, anim = [2210, 2219]
var(1) = var(1) - var(1)%10

[State 10001, ChangeState]
type = ChangeState
trigger1 = !selfanimexist(var(1))
trigger2 = root, movetype = H && root, anim = [200, 4999]
trigger3 = root, anim > 5930
trigger4 = root, var(10) != 5
trigger4 = anim/10000 = 105
value = 10011

[State 10001, DestroySelf]
type = DestroySelf
trigger1 = time
trigger1 = var(11) != root, var(11) || var(12) != root, var(12) || numhelper(10001) > 1
trigger2 = numhelper(10001)
trigger2 = helper(10001), stateno != 10001 && root, var(9) < 1

[State 10001, VarSet]
type = VarSet
trigger1 = 1
var(0) = ifelse(gametime > root, var(56), -1, 0)

[State 10001, VarSet]
type = VarSet
trigger1 = 1
var(11) = root, var(11)

[State 10001, VarSet]
type = VarSet
trigger1 = 1
var(12) = root, var(12)

[State 10001, Bind]
type = BindToRoot
trigger1 = 1
facing = 1
pos = ifelse( (root, hitshakeover), 0, (root, time%2) ), 0

[State 10001, SprPriority]
type = SprPriority
trigger1 = 1
value = root, var(13) + ((root, stateno != 166) && (root, teamside = 1))

[State 10001, SprPriority for Gaia/Gigas Driver]
type = SprPriority
trigger1 = root, anim = 1203 || root, anim = 2103
trigger1 = root, animelemno(0) = 1
trigger1 = root, movetype = A
trigger1 = root, statetype = A
value = -1

[State 10001, SprPriority for Hit States Default]
type = SprPriority
trigger1 = root, movetype = H
trigger1 = root, anim != 161 || root, statetype != S || root, stateno != [161, 162]
trigger2 = root, anim = 5120 || root, anim = 5125
value = -1

[State 10001, SprPriority for Hit States]
type = SprPriority
trigger1 = root, anim = [120, 151]
trigger2 = root, anim = [5000, 5002]
trigger2 = root, animelemno(var(0)) > 1
trigger3 = root, anim = [5005, 5006]
trigger3 = root, animelemno(var(0)) < 2
trigger4 = root, anim = 5007
trigger4 = root, animelemno(var(0)) = 1
trigger5 = root, anim = [5015, 5016]
trigger6 = root, anim = [5615, 5616]
trigger6 = root, animelemno(var(0)) = [1, 2]
trigger6 = root, movetype = H
trigger7 = root, anim = [5625, 5627]
trigger7 = root, movetype = H
trigger8 = root, anim = 5040
trigger8 = root, animelemno(var(0)) = 10
trigger9 = root, anim = 5120
trigger9 = root, animelemno(var(0)) = [3, 5]
trigger10 = root, anim = 5300
trigger11 = root, anim = 5910
trigger11 = root, animelemno(var(0)) = 1
trigger12 = root, anim = 5911
trigger12 = root, animelemno(var(0)) = [1, 2]
trigger13 = root, anim = [5920, 5921]
trigger14 = root, anim = 5930
value = 1

[State 10001, SprPriority for Hit States]
type = SprPriority
trigger1 = root, stateno = 5150
trigger1 = !root, alive
value = -3

[State 10001, SprPriority for Hit States]
type = SprPriority
trigger1 = root, statetype = A
trigger1 = root, anim = [122, 155]
trigger2 = root, anim = 5920
trigger2 = root, animelemno(0) = 2
value = 2 - root, movetype = H

[State 10001, SprPriority for Hit States]
type = SprPriority
trigger1 = root, anim = 5920
trigger1 = root, animelemno(0) = 2
value = 2

;[State 10001, SprPriority for Hit States]
;type = SprPriority
;trigger1 = root, anim = 5110 || root, anim = 5150
;trigger2 = root, anim = 5050
;trigger2 = root, animelemno(var(0)) > 3
;trigger3 = root, anim = 5061
;trigger3 = root, animelemno(var(0)) = [7, 10]
;trigger4 = root, anim = [5101, 5102]
;trigger4 = root, animelemno(var(0)) > 6
;trigger5 = root, anim = 5170
;trigger5 = root, animelemno(var(0)) != 1
;trigger6 = root, anim = [5171, 5172]
;trigger7 = root, anim = 5180
;trigger7 = root, animelemno(var(0)) > 3
;value = 0

[State 10001, ChangeAnim]
type = ChangeAnim
trigger1 = 1
value = var(1)
elem = root, animelemno(var(0))

;===============================================================
;Shield Lost

[Statedef 10011]
type = S
physics = N
velset = -2, -7.5
sprpriority = root, var(12)

[State 10011, Helper]
type = Helper
trigger1 = !time
trigger1 = !root, var(20)
trigger1 = anim/10000 = 105
trigger1 = abs(root, var(9)) != 5
name = "sfade"
id = 10021
stateno = 10021
ownpal = 1
pausemovetime = 99999
supermovetime = 99999
size.head.pos = anim, animelemno(0)

[State 10011, DestroySelf]
type = DestroySelf
trigger1 = !time
trigger1 = anim/10000 = 105
trigger1 = abs(root, var(9)) != 5

[State 10011, ChangeAnim]
type = ChangeAnim
trigger1 = 1
value = anim
elem = ifelse(animelemno(0) = 1, 1, animelemno(-1))

[State 10011, VelAdd]
type = VelAdd
trigger1 = 1
y = 0.45

[State 10011, AssertSpecial]
type = AssertSpecial
trigger1 = time > 9
trigger1 = time%2
flag = Invisible

[State 10011, AssertSpecial]
type = AssertSpecial
trigger1 = time > 9
flag = NoShadow

[State 10011, DestroySelf]
type = DestroySelf
trigger1 = time > 35
trigger1 = pos y > -vel y
trigger2 = anim = 9999
trigger3 = root, var(9) > 0
trigger3 = selfanimexist(root, anim + 1000000 + root, var(10)*10000)
trigger3 = root, movetype != H && root, anim < 5922

[Statedef 10021]
type = S
physics = N
velset = 0, 0
sprpriority = 4

[State 10021, ChangeAnim]
type = ChangeAnim
trigger1 = !time
value = const(size.head.pos.x)
elem = const(size.head.pos.y)

[State 10021, PosAdd]
type = PosAdd
trigger1 = time
x = ifelse(time%2, -1, 1)*(time + (time + 1))*0.5
y = ifelse(time%2, 1, -1)*(time + (time + 1))*0.5

[State 10021, ChangeAnim]
type = ChangeAnim
trigger1 = 1
value = anim
elem = ifelse(animelemno(0) = 1, 1, animelemno(-1))

[State 10021, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[State 10021, DestroySelf]
type = DestroySelf
trigger1 = time > 16

[State 10021, Trans]
type = Trans
trigger1 = 1
trans = addalpha
alpha = 256 - 16*time, 0

;===============================================================
;Body Helper

[Statedef 10002]
type = S
physics = N
anim = 9999

[State 10002, DestroySelf]
type = DestroySelf
trigger1 = time
trigger1 = var(11) != root, var(11) || var(12) != root, var(12) || numhelper(10002) > 1
trigger2 = !selfanimexist(root, anim)
trigger3 = root, movetype = H && root, anim = [200, 4999]
trigger4 = root, anim > 5930

[State 10002, VarSet]
type = VarSet
trigger1 = 1
var(11) = root, var(11)

[State 10002, VarSet]
type = VarSet
trigger1 = 1
var(12) = root, var(12)

[State 10002, NotHitBy]
type = NotHitBy
trigger1 = !time
value = SCA
time = -1

[State 10002, AssertSpecial]
type = AssertSpecial
triggerall = !root, var(41)
;triggerall = gametime = root, var(56) || root, time > 0
trigger1 = root, movetype = H
trigger1 = root, anim != 161 || root, statetype != S || root, stateno != [161, 162]
trigger2 = root, anim = 5300
flag = Invisible

[State 10002, Bind]
type = BindToRoot
trigger1 = 1
facing = 1
pos = ifelse( (root, hitshakeover), 0, (root, time%2) ), 0

[State 10002, SprPriority]
type = SprPriority
trigger1 = 1
value = root, var(13) + ((root, anim != [120, 155]) && (root, stateno != 166) && (root, teamside = 1))

[State 10002, SprPriority]
type = SprPriority
trigger1 = root, movetype = H
trigger2 = root, anim = 5120 || root, anim = 5125
value = 0

[State 10002, ChangeAnim]
type = ChangeAnim
trigger1 = selfanimexist(root, anim)
value = root, anim
elem = root, animelemno(ifelse(gametime > root, var(56), -1, 0))
