;Creator: P.O.T.S
;========================< KATAMARI >=============================
[Statedef 3405]
type = A
physics = N
movetype = A
anim = 3405+random%3
ctrl = 0
juggle = 0
sprpriority = 2

[State 3405, hitoverride]
type = hitoverride
trigger1 = 1
time = -1
attr = SCA, AA, AP, AT
stateno = 3405
ignorehitpause = 1
[State 3405, hitby]
type = nothitby
trigger1 = 1
time = -1
value = SCA
ignorehitpause = 1

[State 3405, Vel]
type = velset
trigger1 = 1
x = ifelse(numtarget, 4, 12)
y = 0
[State 3405, Pos]
type = posset
trigger1 = 1
y = -180

[State 3405, spin]
type = angleset
trigger1 = !time && !prevstateno
value = 3 * (random % 120)
ignorehitpause = 1
[State 3405, spin]
type = angleadd
trigger1 = 1
value = ifelse(numtarget, -1, -3)
ignorehitpause = 1
[State 3405, spin]
type = angledraw
trigger1 = 1
scale = 1, 1
ignorehitpause = 1

[State 3405, Camera]
type = screenbound
trigger1 = 1
value = 0
movecamera = ((facing = 1 && pos x >= 0) || (facing = -1 && pos x <= 0)), 0

[State 3405, snd]
type = playsnd
trigger1 = 1
value = 5, 31
channel = 0
lowpriority = 1
[State 3405, snd]
type = sndpan
trigger1 = 1
channel = 0
pan = 0

[State 3405, hitsnd]
type = playsnd
trigger1 = moveguarded = 1
value = 5, 32
channel = 1
ignorehitpause = 1

[State 3405, grab]
type = reversaldef
trigger1 = (gametime % 2) = 1
reversal.attr = SCA, AA, AP, AT
damage = 7, 1
affectteam = B
ID = 3400 + numtarget
p2facing = 1
p2stateno = 3430
pausetime = 0, 0
hitsound = 5, 32
sparkno = 2
guard.sparkno = 2
sparkxy = 0, 0
sprpriority = 2
kill = 0

[State 3405, hit]
type = hitdef
trigger1 = (gametime % 2) = 0
ID = 3400 + numtarget
attr = S, HA
damage = 7, 1
affectteam = B
animtype = Hard
fall.animtype = Hard
hitflag = MAFD
guardflag = MA
priority = 4, Hit
pausetime = 0, 0
guard.dist = 320
sparkno = S9003;2
guard.sparkno = 40
sparkxy = -10, ceil(p2dist y -48)
hitsound = 5, 32
guardsound = -1
ground.type = High
ground.slidetime = 16
ground.hittime = 16
ground.velocity = -4, 0
ground.cornerpush.veloff = 0
air.velocity = -4, -4
airguard.velocity = -2, -3
down.velocity = -4, -4
getpower = ifelse(p2movetype = H, 96, 192), 48
fall = 0
air.fall = 1
forcestand = 1
fall.recover = 0
sprpriority = 2
yaccel = 0.5
p2facing = 1
p2stateno = 3430
kill = 0
guard.kill = 1

[State 3405, p2state]
type = targetfacing
trigger1 = numtarget
value = -1
ignorehitpause = 1

[State 3405, hurt]
type = hitadd
trigger1 = numtarget && !(time % 4)
trigger1 = target, stateno = 3430
value = numtarget
[State 3405, hurt]
type = targetlifeadd
trigger1 = numtarget && !(time % 4)
trigger1 = target, stateno = 3430
value = floor(-7 * ifelse((enemynear, lifemax <= 2000), 2000, (enemynear, lifemax)) / 2000.0)
absolute = 1
kill = 0
[State 3405, hurt]
type = playsnd
trigger1 = numtarget && !(time % 4)
trigger1 = target, stateno = 3430
value = 5, 32
channel = 1
ignorehitpause = 1

[State 3405, sparks]
type = explod
trigger1 = numtarget = 1 && !moveguarded && !(time % 4)
anim = f2
ID = 7000
sprpriority = 5
postype = left
pos = ceil(target, pos x) + 160, ceil(target, screenpos y) + target, const(size.mid.pos.y)
random = 80, 80
facing = ifelse(random < 500, -1, 1)
vfacing = ifelse(random < 500, -1, 1)
ownpal = 1
pausemovetime = -1
supermovetime = -1
[State 3405, sparks]
type = explod
trigger1 = numtarget >= 2 && !moveguarded && !(time % 4)
anim = f2
ID = 7000
sprpriority = 5
postype = p1
pos = 0, 0
random = 240, 240
facing = ifelse(random < 500, -1, 1)
vfacing = ifelse(random < 500, -1, 1)
ownpal = 1
pausemovetime = -1
supermovetime = -1

[State 3405, bind]
type = targetbind
trigger1 = numtarget
trigger1 = target, stateno = 3430
pos = ceil(140 * cos(gametime / 180.0 * pi)), ceil(140 * sin(gametime / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3400)
trigger1 = target(3400), stateno = 3430
ID = 3400
pos = ceil(140 * cos((gametime + 7) / 180.0 * pi)), ceil(140 * sin((gametime + 7) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3401)
trigger1 = target(3401), stateno = 3430
ID = 3401
pos = ceil(140 * cos((gametime + 37) / 180.0 * pi)), ceil(140 * sin((gametime + 37) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3402)
trigger1 = target(3402), stateno = 3430
ID = 3402
pos = ceil(140 * cos((gametime + 67) / 180.0 * pi)), ceil(140 * sin((gametime + 67) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3403)
trigger1 = target(3403), stateno = 3430
ID = 3403
pos = ceil(140 * cos((gametime + 97) / 180.0 * pi)), ceil(140 * sin((gametime + 97) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3404)
trigger1 = target(3404), stateno = 3430
ID = 3404
pos = ceil(120 * cos((gametime + 14) / 180.0 * pi)), ceil(120 * sin((gametime + 14) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3405)
trigger1 = target(3405), stateno = 3430
ID = 3405
pos = ceil(120 * cos((gametime + 44) / 180.0 * pi)), ceil(120 * sin((gametime + 44) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3406)
trigger1 = target(3406), stateno = 3430
ID = 3406
pos = ceil(120 * cos((gametime + 74) / 180.0 * pi)), ceil(120 * sin((gametime + 74) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3407)
trigger1 = target(3407), stateno = 3430
ID = 3407
pos = ceil(120 * cos((gametime + 104) / 180.0 * pi)), ceil(120 * sin((gametime + 104) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3408)
trigger1 = target(3408), stateno = 3430
ID = 3408
pos = ceil(100 * cos((gametime + 21) / 180.0 * pi)), ceil(100 * sin((gametime + 21) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3409)
trigger1 = target(3409), stateno = 3430
ID = 3409
pos = ceil(100 * cos((gametime + 51) / 180.0 * pi)), ceil(100 * sin((gametime + 51) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3410)
trigger1 = target(3410), stateno = 3430
ID = 3410
pos = ceil(100 * cos((gametime + 81) / 180.0 * pi)), ceil(100 * sin((gametime + 81) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3411)
trigger1 = target(3411), stateno = 3430
ID = 3411
pos = ceil(100 * cos((gametime + 111) / 180.0 * pi)), ceil(100 * sin((gametime + 111) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3412)
trigger1 = target(3412), stateno = 3430
ID = 3412
pos = ceil(80 * cos((gametime + 28) / 180.0 * pi)), ceil(80 * sin((gametime + 28) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3413)
trigger1 = target(3413), stateno = 3430
ID = 3413
pos = ceil(80 * cos((gametime + 58) / 180.0 * pi)), ceil(80 * sin((gametime + 58) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3414)
trigger1 = target(3414), stateno = 3430
ID = 3414
pos = ceil(80 * cos((gametime + 88) / 180.0 * pi)), ceil(80 * sin((gametime + 88) / 180.0 * pi))
[State 3405, bind]
type = targetbind
trigger1 = numtarget(3415)
trigger1 = target(3415), stateno = 3430
ID = 3415
pos = ceil(80 * cos((gametime + 128) / 180.0 * pi)), ceil(80 * sin((gametime + 128) / 180.0 * pi))

[State 3405, End]
type = changestate
trigger1 = time >= 60 && (pos x != [ -320, 320])
trigger2 = time >= 10 && root, stateno != 3401
trigger3 = time >= 10 && !(playerIDexist(root, ID))
value = 3406
ignorehitpause = 1


[Statedef 3406]
type = A
physics = N
movetype = I
ctrl = 0
sprpriority = 2
[State 3406, NHB]
type = nothitby
trigger1 = 1
value = SCA, AA, AP, AT
time = -1
ignorehitpause = 1

[State 3406, hurt]
type = targetlifeadd
trigger1 = !time
value = -7
absolute = 1
kill = 1

[State 3406, p2state]
type = targetstate
trigger1 = !(root, win) && time
value = 3431
[State 3406, End]
type = targetdrop
trigger1 = !(root, win) && time

[State 3406, Vel]
type = velset
trigger1 = 1
x = 12
y = 0
[State 3406, Pos]
type = posset
trigger1 = 1
y = -180
[State 3406, spin]
type = angleadd
trigger1 = 1
value = -3
ignorehitpause = 1
[State 3406, spin]
type = angledraw
trigger1 = 1
scale = 1, 1
ignorehitpause = 1

[State 3406, win]
type = changestate
trigger1 = root, win
value = 3410
[State 3406, End]
type = changestate
trigger1 = !(root, win) && time
trigger1 = time >= 60 || (pos x != [ -320, 320])
value = 3407


[Statedef 3407]
type = A
physics = N
movetype = I
ctrl = 0
sprpriority = 2
[State 3407, NHB]
type = nothitby
trigger1 = 1
value = SCA, AA, AP, AT
time = -1
ignorehitpause = 1

[State 3407, End]
type = targetdrop
trigger1 = 1

[State 3407, Vel]
type = velset
trigger1 = 1
x = 12
y = 0
[State 3407, Pos]
type = posset
trigger1 = 1
y = -180
[State 3407, spin]
type = angleadd
trigger1 = 1
value = -3
ignorehitpause = 1
[State 3407, spin]
type = angledraw
trigger1 = 1
scale = 1, 1
ignorehitpause = 1

[State 3407, trans]
type = trans
trigger1 = 1
trans = addalpha
alpha = 256 -(time * 16), 256
[State 3407, End]
type = destroyself
trigger1 = time >= 16


;--- Outer space ---
[Statedef 3410]
type = A
physics = N
movetype = I
ctrl = 0
velset = 0, 0
sprpriority = 2

[State 3410, hitby]
type = nothitby
trigger1 = 1
time = -1
value = SCA
ignorehitpause = 1

[State 3410, p2state]
type = targetstate
trigger1 = !time
value = 3432

[State 3410, Vel]
type = velset
trigger1 = !time
x = 2
y = -7.5
[State 3410, Vel]
type = veladd
trigger1 = vel x > -5
x = -.25
[State 3410, Vel]
type = veladd
trigger1 = vel y < 0
y = 0.125

[State 3410, Pos]
type = posset
trigger1 = screenpos y < 20 && vel y < 0
y = ceil(pos y -screenpos y) + 20

[State 3410, spin]
type = angleadd
trigger1 = 1
value = -3
ignorehitpause = 1
[State 3410, spin]
type = angledraw
trigger1 = 1
scale = 1 -(0.01 * time), 1 -(0.01 * time)
ignorehitpause = 1

[State 3410, snd]
type = playsnd
trigger1 = 1
value = 5, 31
volume = ceil(-25.6 * time)
channel = 0
lowpriority = 1
[State 3410, snd]
type = sndpan
trigger1 = 1
channel = 0
pan = 0

[State 3410, bind]
type = targetbind
trigger1 = numtarget
pos = 0, 0

[State 3410, End]
type = changestate
trigger1 = time >= 100
value = 3411
ignorehitpause = 1


[Statedef 3411]
type = A
physics = N
movetype = I
ctrl = 0
velset = 0, 0
sprpriority = 2

[State 3411, hitby]
type = nothitby
trigger1 = 1
time = -1
value = SCA
ignorehitpause = 1
[State 3411, mc]
type = screenbound
trigger1 = 1
value = 0
movecamera = 0, 1

[State 3411, spin]
type = angledraw
trigger1 = 1
scale = 0, 0
ignorehitpause = 1

[State 3411, snd]
type = playsnd
trigger1 = !time
value = 5, 45
channel = 0
[State 3411, Flash]
type = explod
trigger1 = !time
anim = 6104
sprpriority = -3
postype = p1
scale = 0.5, 0.5
ownpal = 1
pausemovetime = -1
supermovetime = -1

[State 3411, p2state]
type = targetstate
trigger1 = !time
value = 3433
[State 3411, End]
type = destroyself
trigger1 = time >= 60
