; Robotnik CNS.
; Format (case insensitive):
;  [groupname]        
;  constname = "value"

[Data]
life = 800          ;Amount of life to start with
power = 1000
attack = 100        ;100% attack power (more is stronger)
defence = 100        ;100% defensive power (more is stronger)
fall.defence_up = 50 ;Def goes up by 50% everytime player is hit on ground
liedown.time = 60    ;Time player takes before getting up from HIT_LIEDOWN
airjuggle = 15       ;Can do 15 points of juggling
sparkno = 1        ;Default spark number
guard.sparkno = 40 ;Default guard spark number
KO.echo = 0          ;1 to enable echo on KO
volume = 1           ;Volume offset (negative for softer)
IntPersistIndex = 57

[Size]
xscale = 1          ;Horizontal scaling factor.
yscale = 1           ;Vertical scaling factor.
ground.back = 6     ;Player width (back, ground)
ground.front = 10    ;Player width (front, ground)
air.back = 6        ;Player width (back, air)
air.front = 10       ;Player width (front, air)
z.width = 3          ;Player width (into and out)
height = 40	     ;Height of player (for opponent to jump over)
attack.width = 4,4   ;Default attack width: back, front
attack.dist = 50    ;Default attack distance
proj.attack.dist = 90 ;Default attack distance for projectiles
proj.doscale = 1     ;Set to 1 to scale projectiles too   
head.pos = 1,-27   ;Approximate position of head
mid.pos = 1, -25    ;Approximate position of midsection
shadowoffset = 0     ;Number of pixels to vertically offset the shadow
draw.offset = 0,0    ;Player drawing offset in pixels (x, y)

[Velocity]
walk.fwd  = 4     ;Walk forward
walk.back = -4     ;Walk backward
run.fwd  = 6, -4.5    ;Run forward (x, y)  - if y<0, player will hop
run.back = -6, -4.5 ;Run backward (x, y) - if y=0, player will run
jump.neu = 0,-9.5    ;Neutral jumping velocity (x, y)
jump.back = -3,-9    ;Jump back Speed (x, y)
jump.fwd = 3,-9       ;Jump forward Speed (x, y)
runjump.back = -6,-8 ;Running jump speeds (opt)
runjump.fwd = 6,-8      ;.
airjump.neu = 0,-5      ;.
airjump.back = -2,-5 ;Air jump speeds (opt)
airjump.fwd = 2,-5    ;.

[Movement]
airjump.num = 1      ;Number of air jumps allowed (opt)
airjump.height = 3  ;Minimum distance from ground before you can air jump (opt)
yaccel = .57         ;Vertical acceleration
stand.friction = .8  ;Friction coefficient when standing
crouch.friction = .8 ;Friction coefficient when crouching

;---------------------------------------------------------------------------
; Format:
; [Statedef STATENO]
; type = ?      S/C/A/L  stand/crouch/air/liedown
; movetype = ?  I/A/H    idle/attack/gethit
; physics = ?   S/C/A/N  stand/crouch/air/none
; juggle = ?             air juggle points move requires
;
; [State STATENO, ?]     ? - any number you choose
; type = ?
; ...
;---------------------------------------------------------------------------
; LOSE (Time over)
[Statedef 170]
type = S
ctrl = 0
anim = 0
velset = 0,0,0

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

;---------------------------------------------------------------------------
; WIN
[Statedef 180]
type = S
anim = ifelse(var(59) = 2, 501, 0)

[state 180]
type = assertspecial
trigger1 = time = [0,240]
flag = roundnotover

[state 180]
type = changeanim
trigger1 = time = 0 && var(59) = 2 && anim != 502
value = 502

[state 180]
type = screenbound
trigger1 = 1
value = 0
movecamera = 0,0

[state 2002,3]
type = turn
trigger1 = time = 0 && frontedgedist < 100 && var(59) = 2
persistent = 0

[state 180]
type = velset
trigger1 = time > 0
x = 3

[state 180]
type = playsnd
trigger1 = time = 2
value = 2,1
volume = 255

[State 183, 2]
type = changestate
trigger1 = time = 0 && var(59) = 1
value = 600

;---------------------------------------------------------------------------
; INTRO
[Statedef 191]
type = S
anim = 190
velset = 0,0,0

[state 191]
type = varset
trigger1 = time = 0
v = 10
value = 1

[state 191]
type = changeanim
trigger1 = anim = 190 && time > 50 && anim != 191
trigger1 = numhelper = 0
value = 191

[state 191]
type = playsnd
trigger1 = anim = 191 && animelem = 3
value = F45,4
volume = 255

[state 191]
type = changestate
trigger1 = anim = 191 && animtime = 0 && anim != 0
value = 0
ctrl = 0

[state 1010]
type = helper
trigger1 = time = 0
helpertype = normal
name = "gem"
ID = 190
pos = 0,-100
stateno = 192

[state 1010]
type = helper
trigger1 = time = 15
helpertype = normal
name = "gem"
ID = 190
pos = 6,-100
stateno = 193

[state 1010]
type = helper
trigger1 = time = 30
helpertype = normal
name = "gem"
ID = 190
pos = -15,-100
stateno = 194

[state 1010]
type = helper
trigger1 = time = 45
helpertype = normal
name = "gem"
ID = 190
pos = 18,-100
stateno = 195

[state 1010]
type = helper
trigger1 = time = 60
helpertype = normal
name = "gem"
ID = 190
pos = -5,-100
stateno = 196

[state 1010]
type = helper
trigger1 = time = 30
helpertype = normal
name = "gem"
ID = 190
pos = 10,-100
stateno = 197

[state 1010]
type = helper
trigger1 = time = 70
helpertype = normal
name = "gem"
ID = 190
pos = -12,-100
stateno = 198

[State 191, 1]
type = AssertSpecial
trigger1 = Time = [0,300]
flag = Intro

;--====----===----===----====----==-----=====----====-----=====----===-----===----
[statedef 192]
type = S
movetype = I
physics = N
anim = 6000
ctrl = 0

[state 192]
type = velset
trigger1 = time = 0
x = 0.8
y = 0.3

[state 192]
type = veladd
trigger1 = var(1) = 0
x = 0.2

[state 192]
type = veladd
trigger1 = var(1) = 1
x = -0.2

[state 192]
type = varset
trigger1 = time = 4
trigger2 = vel X>= 1.8
v = 1
value = 1

[state 192]
type = varset
trigger1 = vel X<= -1.8
v = 1
value = 0

[state 192]
type = explod
trigger1 = time%12 = 0
removetime = 16
removeongethit = 1
bindtime = 1
ID = 5
pos = 0,-8
random = 12, 0
anim = 6011
;vel = 2,0
;accel = 0.2,0

[state 192]
type = destroyself
trigger1 = parentdist X<= 20
trigger1 = parentdist X>= -20
trigger1 = parentdist Y<= 20
trigger2 = roundstate = 2

;--====----===----===----====----==-----=====----====-----=====----===-----===----
[statedef 193]
type = S
movetype = I
physics = N
anim = 6001
ctrl = 0

[state 192]
type = velset
trigger1 = time = 0
x = 0.8
y = 0.3

[state 192]
type = veladd
trigger1 = var(1) = 0
x = 0.2

[state 192]
type = veladd
trigger1 = var(1) = 1
x = -0.2

[state 192]
type = varset
trigger1 = time = 4
trigger2 = vel X>= 1.8
v = 1
value = 1

[state 192]
type = varset
trigger1 = vel X<= -1.8
v = 1
value = 0

[state 192]
type = explod
trigger1 = time%12 = 0
removetime = 16
removeongethit = 1
bindtime = 1
ID = 5
pos = 0,-8
random = 12, 0
anim = 6011
;vel = 2,0
;accel = 0.2,0

[state 192]
type = destroyself
trigger1 = parentdist X<= 20
trigger1 = parentdist X>= -20
trigger1 = parentdist Y<= 20
trigger2 = roundstate = 2

;--====----===----===----====----==-----=====----====-----=====----===-----===----
[statedef 194]
type = S
movetype = I
physics = N
anim = 6002
ctrl = 0

[state 192]
type = velset
trigger1 = time = 0
x = 0.8
y = 0.3

[state 192]
type = veladd
trigger1 = var(1) = 0
x = 0.2

[state 192]
type = veladd
trigger1 = var(1) = 1
x = -0.2

[state 192]
type = varset
trigger1 = time = 4
trigger2 = vel X>= 1.8
v = 1
value = 1

[state 192]
type = varset
trigger1 = vel X<= -1.8
v = 1
value = 0

[state 192]
type = explod
trigger1 = time%12 = 0
removetime = 16
removeongethit = 1
bindtime = 1
ID = 5
pos = 0,-8
random = 12, 0
anim = 6011
;vel = 2,0
;accel = 0.2,0

[state 192]
type = destroyself
trigger1 = parentdist X<= 20
trigger1 = parentdist X>= -20
trigger1 = parentdist Y<= 20
trigger2 = roundstate = 2

;--====----===----===----====----==-----=====----====-----=====----===-----===----
[statedef 195]
type = S
movetype = I
physics = N
anim = 6003
ctrl = 0

[state 192]
type = velset
trigger1 = time = 0
x = 0.8
y = 0.3

[state 192]
type = veladd
trigger1 = var(1) = 0
x = 0.2

[state 192]
type = veladd
trigger1 = var(1) = 1
x = -0.2

[state 192]
type = varset
trigger1 = time = 4
trigger2 = vel X>= 1.8
v = 1
value = 1

[state 192]
type = varset
trigger1 = vel X<= -1.8
v = 1
value = 0

[state 192]
type = explod
trigger1 = time%12 = 0
removetime = 16
removeongethit = 1
bindtime = 1
ID = 5
pos = 0,-8
random = 12, 0
anim = 6011
;vel = 2,0
;accel = 0.2,0

[state 192]
type = destroyself
trigger1 = parentdist X<= 20
trigger1 = parentdist X>= -20
trigger1 = parentdist Y<= 20
trigger2 = roundstate = 2

;--====----===----===----====----==-----=====----====-----=====----===-----===----
[statedef 196]
type = S
movetype = I
physics = N
anim = 6004
ctrl = 0

[state 192]
type = velset
trigger1 = time = 0
x = 0.8
y = 0.3

[state 192]
type = veladd
trigger1 = var(1) = 0
x = 0.2

[state 192]
type = veladd
trigger1 = var(1) = 1
x = -0.2

[state 192]
type = varset
trigger1 = time = 4
trigger2 = vel X>= 1.8
v = 1
value = 1

[state 192]
type = varset
trigger1 = vel X<= -1.8
v = 1
value = 0

[state 192]
type = explod
trigger1 = time%12 = 0
removetime = 16
removeongethit = 1
bindtime = 1
ID = 5
pos = 0,-8
random = 12, 0
anim = 6011
;vel = 2,0
;accel = 0.2,0

[state 192]
type = destroyself
trigger1 = parentdist X<= 20
trigger1 = parentdist X>= -20
trigger1 = parentdist Y<= 20
trigger2 = roundstate = 2

;--====----===----===----====----==-----=====----====-----=====----===-----===----
[statedef 197]
type = S
movetype = I
physics = N
anim = 6005
ctrl = 0

[state 192]
type = velset
trigger1 = time = 0
x = 0.8
y = 0.3

[state 192]
type = veladd
trigger1 = var(1) = 0
x = 0.2

[state 192]
type = veladd
trigger1 = var(1) = 1
x = -0.2

[state 192]
type = varset
trigger1 = time = 4
trigger2 = vel X>= 1.8
v = 1
value = 1

[state 192]
type = varset
trigger1 = vel X<= -1.8
v = 1
value = 0

[state 192]
type = explod
trigger1 = time%6 = 0
removetime = -2
removeongethit = 1
bindtime = 1
ID = 5
pos = 0,-8
random = 12, 0
anim = 6011
;vel = 2,0
;accel = 0.2,0

[state 192]
type = destroyself
trigger1 = parentdist X<= 20
trigger1 = parentdist X>= -20
trigger1 = parentdist Y<= 20
trigger2 = roundstate = 2

;--====----===----===----====----==-----=====----====-----=====----===-----===----
[statedef 198]
type = S
movetype = I
physics = N
anim = 6006
ctrl = 0

[state 192]
type = velset
trigger1 = time = 0
x = 0.8
y = 0.3

[state 192]
type = veladd
trigger1 = var(1) = 0
x = 0.2

[state 192]
type = veladd
trigger1 = var(1) = 1
x = -0.2

[state 192]
type = varset
trigger1 = time = 4
trigger2 = vel X>= 1.8
v = 1
value = 1

[state 192]
type = varset
trigger1 = vel X<= -1.8
v = 1
value = 0

[state 192]
type = explod
trigger1 = time%12 = 0
removetime = 16
removeongethit = 1
bindtime = 1
ID = 5
pos = 0,-8
random = 12, 0
anim = 6011
;vel = 2,0
;accel = 0.2,0

[state 192]
type = destroyself
trigger1 = parentdist X<= 20
trigger1 = parentdist X>= -20
trigger1 = parentdist Y<= 20

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;robotnik's states
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; hover in place
[Statedef 501]
type    = S
movetype= I
physics = S
sprpriority = 4
ctrl = 0

[state 501]
type = nothitby
trigger1 = roundstate > 2
value = SCA

[state 501]
type = varset
trigger1 = time = 0 && prevstateno = 0
v = 58
value = 1

[state 1010]
type = helper
trigger1 = time = 0 && prevstateno != 2001
helpertype = normal
name = "timer"
ID = 5
pos = 0,0
stateno = 9002

[state 501]
type = posset
trigger1 = time = 0 && pos Y>= -70
trigger2 = pos Y>= -15
y = -15

[state 501]
type = velset
trigger1 = time = 0 && pos Y< -15
y = 4
x = 0

[state 501]
type = velset
trigger1 = pos Y>= -15
y = 0

[state 501]
type = turn
trigger1 = p2dist X< -15

[state 501]
type = changeanim
trigger1 = time = 0 && anim != 501 && anim != 511
trigger2 = anim = 511 && animtime = 0
trigger2 = anim != 501
value = 501

[state 501]
type = varset
trigger1 = time = 0
v = 2
value = 501

[state 501]
type = hitoverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 2001

[state 501]
type = varrandom
trigger1 = time = 0
v = 3
range = 0,4

[state 501]
type = changestate
trigger1 = numhelper(5) = 0 && var(3) = 0
value = 2010

[state 501]
type = changestate
trigger1 = numhelper(5) = 0 && var(3) = 1
value = 2020

[state 501]
type = changestate
trigger1 = numhelper(5) = 0 && var(3) = 2
value = 2030

[state 501]
type = changestate
trigger1 = numhelper(5) = 0 && var(3) = 3
value = 2040

[state 501]
type = changestate
trigger1 = numhelper(5) = 0 && var(3) = 4
value = 2050

[state 501]
type = changestate
trigger1 = win && pos Y>= -15
value = 0
ctrl = 1

;-----------------------------------------------------------
[statedef 2001]
movetype = H
anim = 511
sprpriority = 4

[state 2001]
type = playsnd
trigger1 = time = 0 && random < 300
value = 3,8
volume = 255

[state 2001]
type = playsnd
trigger1 = time = 0 && random > 800
value = 3,9
volume = 255

[state 2001]
type = posadd
trigger1 = time = 0
x = -2
y = 0

[state 1001]
type = palfx
trigger1 = time = 0
time = 60
add = 0,0,0
mul = 205,205,205
sinadd = 100,100,100, 10

[state 1001]
type = lifeset
trigger1 = gethitvar(damage) >= life
value = 1

[state 2001]
type = nothitby
trigger1 = time = 0
value = SCA
time = 2

[state 9000]
type = changestate
trigger1 = life = 1
value = 2002
ctrl = 0

[state 2001]
type = changestate
trigger1 = time = 1 && life > 1
value = var(2)

;death
[statedef 2002]
type = S
movetype = H
physics = N
ctrl = 0
anim = 515
velset = 0,0

[state 2002]
type = playsnd
trigger1 = time = 0
value = 1,1
volume = 255

[state 2002]
type = playsnd
trigger1 = anim = 516
persistent = 0
value = 1,2
volume = 255

[state 1011]
type = explod
trigger1 = time%8 = 0
trigger1 = anim = 515
removetime = -2
removeongethit = 1
bindtime = -1
ID = 220
pos = 0,-15
anim = F220
ontop = 1
random = 80, 50

[state 2002]
type = screenbound
trigger1 = pos Y<= -70
movecamera = 0,0
value = 0

[state 2002,1]
type = velset
trigger1 = time = 0
y = -3

[state 2002,2]
type = velset
trigger1 = pos Y<= -70
y = 0

[state 2002,3]
type = turn
trigger1 = pos Y<= -70 && anim = 516 && frontedgedist < 100 && animelem = 1
persistent = 0

[state 2002,4]
type = velset
trigger1 = pos Y<= -70 && anim = 516
x = 3

[state 2002,5]
type = changeanim
trigger1 = pos Y<= -70 && anim != 516 && time >= 80
value = 516

[state 2002,6]
type = lifeadd
trigger1 = anim = 516
value = -1
kill = 1

[state 2002]
type = changestate
trigger1 = frontedgedist < -20
value = 5150

[state 2002]
type = assertspecial
trigger1 = frontedgedist < -20
flag = invisible

;drill around
[statedef 2010]
type = S
movetype = A
physics = N
ctrl = 0
sprpriority = 4

[state 501]
type = posset
trigger1 = time = 0
y = -15

[state 501]
type = turn
trigger1 = p2dist X< -15 && time < 5 && prevstateno != 2001

[state 501]
type = changeanim
trigger1 = time = 0 && anim != 501 && anim != 511
trigger2 = anim = 511 && animtime = 0
trigger2 = anim != 501
value = 501

[state 501]
type = varset
trigger1 = time = 0
v = 2
value = 2010

[state 501]
type = hitoverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 2001

[state 2010]
type = playsnd
trigger1 = movehit && !moveguarded
value = 3,5
volume = 255
persistent = 0

[state 1010]
type = helper
trigger1 = time = 0 && prevstateno != 2001
trigger1 = numhelper(2011) = 0
helpertype = normal
name = "drill"
ID = 2011
pos = 0,0
ownpal = 0
keyctrl = 0
stateno = 2011

[state 2010]
type = velset
trigger1 = numhelper(2011)
trigger1 = helper(2011), time >= 5
x = 7

[state 1010]
type = HitDef
trigger1 = numhelper(2011) 
trigger1 = helper(2011), time >= 5
trigger1 = time%7 = 1
attr = S, HA
damage    = 4,6
animtype  = light
hitflag = MA
guardflag = MA
pausetime = 0,0
sparkxy = 0,-10
sparkno = 1
hitsound   = ifelse(enemy, animexist(7997), 8,5),ifelse(enemy, animexist(7996), 4,3)
guardsound = 6,0
ground.type = low
ground.slidetime = 0
ground.hittime  = 10
ground.velocity = -5,0
air.velocity = -2,-1
down.velocity = -4,0
down.hittime = 20

[state 2010]
type = changestate
trigger1 = !numhelper(2011) 
trigger1 = time > 0
value = 501
ctrl = 0

[statedef 2011]
type = S
movetype = A
physics = N
ctrl = 0
anim = 6030
sprpriority = 5

[state 2011]
type = playsnd
trigger1 = time = 5
value = 3,4
volume = 255

[state 2011]
type = turn
trigger1 = p2dist X< -15 && time < 5

[state 2011]
type = bindtoparent
trigger1 = 1
pos = 0,0
time = -1
ignorehitpause = 1

[state 2011]
type = changeanim
trigger1 = time >= 90 && anim != 6031
trigger2 = parent, life<= 1 && anim != 6031
trigger3 = frontedgedist <= 10 && anim != 6031
value = 6031

[state 2011]
type = destroyself
trigger1 = anim = 6031 && animtime = 0

;----------------------------------------------------------------------------------------
;horizontal beam
[statedef 2020]
type = S
movetype = A
physics = N
ctrl = 0
sprpriority = 1

[state 501]
type = posset
trigger1 = time = 0
y = -15

[state 501]
type = turn
trigger1 = p2dist X< -15 && time = 5

[state 501]
type = changeanim
trigger1 = time = 0 && anim != 501 && anim != 511
trigger2 = anim = 511 && animtime = 0
trigger2 = anim != 501
value = 501

[state 501]
type = varset
trigger1 = time = 0
v = 2
value = 2020

[state 501]
type = hitoverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 2001

[state 1010]
type = helper
trigger1 = time = 0 && prevstateno != 2001
helpertype = normal
name = "Hbeam"
ID = 2021
pos = 15,-5
stateno = 2021
ownpal = 0
facing = 1

[state 2020]
type = changestate
trigger1 = numhelper(2021) = 0
value = 501
ctrl = 0

;horizontal beam thingy
[statedef 2021]
type = S
movetype = A
physics = N
ctrl = 0
anim = 6050

[state 2021]
type = playsnd
trigger1 = time = 20
value = 3,10
volume = 255

[state 2021]
type = bindtoparent
trigger1 = 1
pos = 15, -5
ignorehitpause = 1

[state 2021]
type = changeanim
trigger1 = time = 40 || time = 70
value = 6050

[state 2021]
type = turn
trigger1 = parent, p2dist X< -15 && parent, time = 5

[State 213, 4]
type = Projectile
trigger1 = time = 20 || time = 50 || time = 80
projanim = 6060
projhits = 1
projmisstime = 50 
projpriority = 1
projshadow = -1
projremove = 0
projremovetime = 20
offset = 7,-1
velocity = 0,0
attr = S, SP
damage   = 25,10
animtype = light
guardflag = MA
hitflag = MAF
pausetime = 0,0
hitsound   = ifelse(enemy, animexist(7997), 8,5),ifelse(enemy, animexist(7996), 4,3)
sparkno = 1
sparkxy = floor(p2dist X),0
guardsound = 6,0
ground.type = high
ground.slidetime = 10
ground.hittime  = 10
ground.velocity = -4,0
air.animtype = Back
air.velocity = -4,-2
getpower = 60,0
givepower = 0,60
projscale = 7, 0.8
projsprpriority = 0

[state 2021]
type = destroyself
trigger1 = time > 110
trigger2 = root, life<= 1

;----------------------------------------------------------------------------------------
;multi missile
[statedef 2030]
type = S
physics = N
movetype = A
ctrl = 0
sprpriority = 1

[state 501]
type = posset
trigger1 = time = 0
y = -15

[state 501]
type = turn
trigger1 = p2dist X< -15 && time = 0

[state 501]
type = changeanim
trigger1 = time = 0 && anim != 501 && anim != 511
trigger2 = anim = 511 && animtime = 0
trigger2 = anim != 501
value = 501

[state 501]
type = varset
trigger1 = time = 0
v = 2
value = 2030

[state 501]
type = hitoverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 2001

[state 2030]
type = helper
trigger1 = numhelper(5) = 0 && time = 0 && prevstateno != 2001
helpertype = normal
name = "timer"
ID = 5
pos = 0,0
stateno = 9002
ownpal = 1
keyctrl = 0

[state 1010]
type = helper
trigger1 = numhelper(5) > 0
trigger1 = helper(5), time%10 = 11
helpertype = normal
name = "miss1"
ID = 6
pos = 5,-10
stateno = 2031
facing = 1
ownpal = 1

[state 1010]
type = helper
trigger1 = numhelper(5) > 0 
trigger1 = helper(5), time%10 = 1
helpertype = normal
name = "miss2"
ID = 7
pos = 5,-10
stateno = 2031
facing = 1
ownpal = 1

[state 2030]
type = changestate
trigger1 = numhelper(5) = 0
value = 501
ctrl = 0

;missiles
[statedef 2031]
type = S
movetype = A
physics = N
ctrl = 0
anim = 6040
velset = 9,0

[state 2031]
type = playsnd
trigger1 = time = 0 && random < 700
value = 3,2
volume = 255

[state 2031]
type = sprpriority
trigger1 = ishelper(6)
value  = 5

[state 2031]
type = sprpriority
trigger1 = ishelper(7)
value  = -1

[state 2031]
type = explod
trigger1 = time%5 = 0
removetime = -2
bindtime = 1
ID = 6042
pos = 0,0
anim = 6042
ontop = 0

[state 2031]
type = varrandom
trigger1 = time = 0
v = 10
range = -3,2

[state 2031]
type = velset
trigger1 = time = 0
y = var(10)

[state 2031]
type = veladd
trigger1 = vel Y> 0 && time > 10
y = -0.5

[state 2031]
type = veladd
trigger1 = vel Y< 0 && time > 10
y = 0.5

[state 1010]
type = HitDef
trigger1 = !movehit
attr = S, NT
damage    = 5,2
animtype  = light
hitflag = MA
guardflag = MA
pausetime = 0,12
sparkxy = 0,-10
sparkno = 220
guard.sparkno = 220
hitsound   = ifelse(enemy, animexist(7997), 8,5),ifelse(enemy, animexist(7996), 4,3)
guardsound = 6,0
ground.type = high
ground.slidetime = 0
ground.hittime  = 10
ground.velocity = 0
air.velocity = -1.3,-3
down.velocity = -4,0
down.hittime = 20
persistent = 0

[state 2031]
type = destroyself
trigger1 = frontedgedist < -20
trigger2 = movecontact || moveguarded

;------------------------------------------------------------------------------------
;giant downwards laser
[statedef 2040]
type = S
movetype = A
physics = N
ctrl = 0

[state 2040]
type = playsnd
trigger1 = time = 0 && prevstateno != 2001
value = 3,7
volume = 255

[state 2040]
type = screenbound
trigger1 = 1
value = 0
movecamera = 1,0

[state 2040]
type = playerpush
trigger1 = 1
value = 0

[state 2040]
type = velset
trigger1 = pos Y> -70 && prevstateno != 2001 && time = 0
y = -4

[state 2040]
type = velset
trigger1 = pos Y<= -70
y = 0

[state 2040]
type = velset
trigger1 = pos Y>= -70
trigger2 = frontedgedist > 20
x = 4

[state 501]
type = turn
trigger1 = frontedgedist < 20

[state 501]
type = changeanim
trigger1 = time = 0 && anim != 501 && anim != 511
trigger2 = anim = 511 && animtime = 0
trigger2 = anim != 501
value = 501

[state 501]
type = varset
trigger1 = time = 0
v = 2
value = 2040

[state 501]
type = hitoverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 2001

[state 1010]
type = helper
trigger1 = numhelper(8) = 0 && pos Y<= -70
helpertype = normal
name = "laser1"
ID = 8
pos = 0,-5
stateno = 2041
facing = 1
ownpal = 0

[state 1010]
type = helper
trigger1 = numhelper(5) = 0 && time = 0 && prevstateno != 2001
helpertype = normal
name = "timer"
ID = 5
pos = 0,0
stateno = 9002
facing = 1

[state 2040]
type = changestate
trigger1 = numhelper(5) = 0
value = 501
ctrl = 0

;beam socket
[statedef 2041]
type = S
movetype = A
physics = N
ctrl = 0
anim = 6051
sprpriority = 0

[state 2041]
type = playsnd
trigger1 = time = 90
value = 3,6
volume = 255

[state 2041]
type = assertspecial
trigger1 = 1
flag = noshadow

[state 2041]
type = bindtoparent
trigger1 = 1
pos = 0,-5
ignorhitpause = 1

[state 1010]
type = helper
trigger1 = numhelper(9) = 0 && time = 0
helpertype = normal
name = "laser2"
ID = 9
pos = 0,0
stateno = 2042
facing = 1
ownpal = 0

[state 2041]
type = destroyself
trigger1 = root, stateno = 501
trigger2 = root, life<= 1

[statedef 2042]
type = S
movetype = A
physics = S
ctrl = 0
anim = 6061
sprpriority = -1

[state 2041]
type = assertspecial
trigger1 = 1
flag = noshadow

[state 2042]
type = angleset
trigger1 = time = 0
value = 270
scale = 2.2,1.2

[state 2042]
type = angledraw
trigger1 = 1

[state 2042]
type = bindtoparent
trigger1 = 1
pos = 0,0

[state 1010]
type = HitDef
trigger1 = time > 0
attr = S, SP
damage    = 20,5
animtype  = light
hitflag = MA
guardflag = MA
pausetime = 0,0
sparkxy = 0,floor(p2dist Y) - 10
sparkno = 1
hitsound   = ifelse(enemy, animexist(7997), 8,5),ifelse(enemy, animexist(7996), 4,3)
guardsound = 6,0
ground.type = high
ground.slidetime = 0
ground.hittime  = 10
ground.velocity = -2
air.velocity = -1.3,-1
down.velocity = -4,0
down.hittime = 20
persistent = 30

[state 1011]
type = explod
trigger1 = time%10 = 0
removetime = -2
removeongethit = 1
bindtime = 5
ID = 220
pos = 0,155 - floor(screenpos Y)
random = 50,0
anim = F220
ontop = 1

[state 2042]
type = changeanim
trigger1 = time >= 150 && anim != 6062
trigger2 = root, life<= 1 && anim != 6062
value = 6062

[state 2042]
type = destroyself
trigger1 = anim = 6062 && animtime = 0

;---------------------------------------------------------------------------
;missile drop from sky
[statedef 2050]
type = S
movetype = A
physics = S
ctrl = 0

[state 2040]
type = screenbound
trigger1 = 1
value = 1
movecamera = 0,0

[state 2040]
type = playerpush
trigger1 = 1
value = 0

[state 2040]
type = velset
trigger1 = pos Y> -70 && prevstateno != 2001 && time = 0
y = -4

[state 2040]
type = velset
trigger1 = pos Y<= -70
y = 0

[state 2040]
type = velset
trigger1 = pos Y>= -70
trigger2 = frontedgedist > 20
x = 3

[state 501]
type = turn
trigger1 = frontedgedist < 20

[state 501]
type = changeanim
trigger1 = time = 0 && anim != 501 && anim != 511
trigger2 = anim = 511 && animtime = 0
trigger2 = anim != 501
value = 501

[state 501]
type = varset
trigger1 = time = 0
v = 2
value = 2050

[state 501]
type = hitoverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 2001

[state 1010]
type = helper
trigger1 = numhelper(9) = 0 && pos Y<= -70
helpertype = normal
name = "bomb1"
ID = 9
pos = 0,-5
stateno = 2051
facing = 1
ownpal = 0

[state 1010]
type = helper
trigger1 = numhelper(5) = 0 && time = 0 && prevstateno != 2001
helpertype = normal
name = "timer"
ID = 5
pos = 0,0
stateno = 9002
facing = 1

[state 1010]
type = changestate
trigger1 = numhelper(5) = 0
value = 501
ctrl = 0

[statedef 2051]
type = S
movetype = I
physics = S
ctrl = 0
anim = 6051
sprpriority = -1

[state 2051]
type = playsnd
trigger1 = time = 0
value = 3,1
volume = 255

[state 2051]
type = playsnd
trigger1 = time = 60
value = 3,ifelse(random < 500, 5,6)
volume = 255

[state 2051]
type = bindtoparent
trigger1 = 1
pos = 0,-5

[state 2051, freeze anim]
type = changeanim
trigger1 = 1
value = 6051
elem = 1

[state 1010]
type = helper
trigger1 = time%10 = 0
helpertype = normal
name = "bomb2"
ID = 10
pos = 0,-5
stateno = 2052
facing = 1
ownpal = 0

[state 2051]
type = destroyself
trigger1 = parent, stateno = 501
trigger2 = root, life<= 1

[statedef 2052]
type = S
movetype = A
physics = N
velset = 0, 2
anim = 6041
sprpriority = -2

[state 2052]
type = veladd
trigger1 = pos Y!= -5
y = 0.5

[state 2052]
type = velset
trigger1 = pos Y>= -5
y = 0

[state 2052]
type = posset
trigger1 = pos Y>= -5
y = -5

[state 2052]
type = changestate
trigger1 = pos Y= -5
value = 2053
ctrl = 0

[statedef 2053]
type = S
movetype = A
physics = S
ctrl = 0
velset = 0,0
anim = 6043

[state 1010]
type = HitDef
trigger1 = !movehit
attr = S, NT
damage    = 20,5
animtype  = light
hitflag = MA
guardflag = MA
pausetime = 0,12
sparkxy = 0,-10
sparkno = 1
hitsound   = ifelse(enemy, animexist(7997), 8,5),ifelse(enemy, animexist(7996), 4,3)
guardsound = 6,0
ground.type = high
ground.slidetime = 0
ground.hittime  = 10
ground.velocity = -3
air.velocity = -1.3,-2
down.velocity = -4,0
down.hittime = 20
persistent = 0

[state 1121]
type = explod
trigger1 = numexplod(440) = 0
anim = F440
ID = 440 
pos = 0,5
removetime = -2
bindtime = 1
sprpriority = 1
ontop = 1
ignorehitpause = 1
persistent = 0

[state 2053]
type = destroyself
trigger1 = time = 1

;robotniks timer helper
[statedef 9002]
type = S
movetype = I
physics = N
ctrl = 0
anim = 512
velset = 0,0

[state 9002]
type = destroyself
trigger1 = time >= 60 && parent, stateno = 501
trigger2 = time >= 120 && parent, stateno = 2030
trigger3 = time >= 180 && parent, stateno = 2040
trigger4 = time >= 140 && parent, stateno = 2050

[state 1010]
type = null;HitDef
trigger1 = time = 6 || time = 12 || time = 18 
attr = S, NA
damage    = 8
animtype  = hard
hitflag = MA
guardflag = MA
pausetime = 0,12
sparkxy = 0,-10
sparkno = 1
hitsound   = ifelse(enemy, animexist(7997), 8,5),ifelse(enemy, animexist(7996), 4,3)
guardsound = 6,0
ground.type = high
ground.slidetime = 0
ground.hittime  = 10
ground.velocity = 0
air.velocity = -1.3,-3
down.velocity = -4,0
down.hittime = 20

[state 1010]
type = null;helper
trigger1 = time = 24
helpertype = normal
name = "wave"
ID = 1011
pos = 10,-5
stateno = 1011

[state 1011]
type = null;explod
trigger1 = time = 0
removetime = -1
removeongethit = 1
bindtime = -1
ID = 1011
pos = 0,0
anim = F160
ontop = 1
;vel = 2,0
;accel = 0.2,0

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

;---------------------------------------------------------------------------
; Override common states (use same number to override) :
;---------------------------------------------------------------------------
[statedef -2]

[state -2]
type = assertspecial
trigger1 = alive
flag = timerfreeze

[state -2]
type = assertspecial
trigger1 = life<= 1
flag = noKOslow

;---------------------------------------------------------------------------
; States that are executed when in self's state file (use statedef -3)
;---------------------------------------------------------------------------

[Statedef -3]

[State -3, Landing Sound]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 1127 ;Jump land
trigger2 = stateno = 106 ;Run-back land
value = F23, 0

[State -3, jump noise]
type = PlaySnd
triggerall = Time = 2
triggerall = var(59) != 3
trigger1 = stateno = 40 ;Jump land
value = F24, 1

;---------------------------------------------------------------------------
;special hit states
;------------------
; Wall hit start after being hit by /F, c
[Statedef 6025]
type    = A
movetype= H
physics = N
;velset = 0,0

[state 6025]
type = posset
trigger1 = 1
ignorehitpause = 1
y = -5

[State 6025, Anim] ;Custom animation
type = ChangeAnim2
trigger1 = 1
value = 1025

[State 6025, State]
type = ChangeState
trigger1 = HitShakeOver = 1
value = 6026

;------------------
; hit by /F, c - flying through the air
; (a custom gethit state)
[Statedef 6026]
type    = A
movetype= H
physics = N

[State 6026, Velocity]
type = HitVelSet
trigger1 = Time = 0
x = -5
y = -8

[State 6026, Gravity]
type = VelAdd
trigger1 = 1
y = .45

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

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

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

;------------------
; hit by /F, c - hit wall
; (a custom gethit state)
[Statedef 6027]
type    = A
movetype= H
physics = N

[state 6027]
type = playsnd
trigger1 = time = 0 && selfanimexist(7997)
value = F8,6
volume = 255

[state 6027]
type = playsnd
trigger1 = time = 0 && selfanimexist(7996)
value = F7,4
volume = 255

[state 6027]
type = playsnd
trigger1 = time = 0 && !selfanimexist(7997) && !selfanimexist(7996)
value = F7,6
volume = 255

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

[State 6027, Pos]
type = PosAdd
trigger1 = Time = 0
x = 15 - BackEdgeBodyDist

[State 6027, Stop moving]
type = PosFreeze
trigger1 = 1
x = 1
y = 1

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

;wall hit spark
[State 6027, Spark]
type = Explod
trigger1 = Time = 0
anim = F72
pos = 25, floor(screenpos Y) - 20
postype = back
sprpriority = 3

[State 6027, Anim]
type = ChangeAnim2
trigger1 = Time = 0
value = 1027

[State 6027, State]
type = ChangeState
trigger1 = AnimTime = 0
value = 6028

;------------------
; Hit by /F, z - bounce off wall
; (a custom gethit state)
[Statedef 6028]
type    = A
movetype= H
physics = N

[State 6028, 1]
type = null;NotHitBy
trigger1 = 1
value = , NA, NP

[State 6028, Vel Y]
type = VelSet
trigger1 = Time = 0
y = -6

[State 6028, Vel X]
type = VelSet
trigger1 = Time = 0
x = 1.6

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

[State 6028, Gravity]
type = VelAdd
trigger1 = 1
y = .35

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

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

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

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

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