;======================================================================================
;--------------------------------------------------------------------------------------
;var(0): 0 = background, 1 = foreground
;var(1): element (0 = fire, 1 = ice, 2 = lightning, 3 = poison)
;var(2): hover sine time offset
;var(3): temp variable
;var(4): switch timer

;fvar(0): home x pos
;fvar(1): home y pos
;fvar(2): target x pos
;fvar(3): target y pos
;fvar(4): angle to target

;======================================================================================
;--------------------------------------------------------------------------------------
; Init States
[Statedef 15900]
type = S
ctrl = 0
velset = 0, 0
movetype = I
physics = N

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

[State Init, VarSet]
type = VarSet
trigger1 = 1
var(1) = parent, var(13)

[State Init, ChangeState]
type = ChangeState
trigger1 = 1
value = 10190

[Statedef 15910]
type = S
ctrl = 0
velset = 0, 0
movetype = I
physics = N

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

[State Init, VarSet]
type = VarSet
trigger1 = 1
var(1) = parent, var(14)

[State Init, VarSet]
type = VarSet
trigger1 = 1
var(2) = 30

[State Init, ChangeState]
type = ChangeState
trigger1 = 1
value = 10190

;======================================================================================
;--------------------------------------------------------------------------------------
; Intro
[Statedef 10190]
type = S
ctrl = 0
velset = 0, 0
movetype = I
physics = N

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

[State 10190, VarSet]
type = VarSet
trigger1 = !var(0)
var(1) = parent, var(13)

[State 10190, VarSet]
type = VarSet
trigger1 = var(0)
var(1) = parent, var(14)

[State 10190, ChangeAnim]
type = ChangeAnim
trigger1 = 1
value = 10000 + 1000*var(1)
elem = var(2)/5 + 1

[State 10190, Bind]
type = BindToParent
trigger1 = var(0) = 0
pos = floor(15*root, const(size.xscale)), floor((sin((var(2) + 1)*pi/30.0)*15 - 90)*root, const(size.yscale))

[State 10190, Bind]
type = BindToParent
trigger1 = var(0) = 1
pos = floor(-25*root, const(size.xscale)), floor((sin((var(2) + 1)*pi/30.0)*15 - 70)*root, const(size.yscale))

[State 10190, AngleDraw]
type = AngleDraw
trigger1 = time < 20
scale = time*0.05, time*0.0125

[State 10190, AngleDraw]
type = AngleDraw
trigger1 = time > 19
scale = 1, (time - 10)*0.025

[State 10190, ChangeState]
type = ChangeState
trigger1 = time > 50
trigger2 = roundstate > 1
value = 10000

;--------------------------------------------------------------------------------------
; Outro
[Statedef 15150]
type = S
ctrl = 0
velset = 0, 0
movetype = I
physics = N

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

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

[State 15150, AngleDraw]
type = AngleDraw
trigger1 = time < 30
scale = 1, (40 - time)*0.025

[State 15150, AngleDraw]
type = AngleDraw
trigger1 = time > 29
scale = (50 - time)*0.05, (50 - time)*0.0125

[State 15150, DestroySelf]
type = DestroySelf
trigger1 = time = 50
trigger2 = roundstate < 2

;======================================================================================
;--------------------------------------------------------------------------------------
; Idle
[Statedef 10000]
type = S
ctrl = 0
movetype = I
physics = N

[State 10000, KO]
type = ChangeState
trigger1 = !root, alive
value = 15150

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

[State 10000, Turn]
type = ChangeState
trigger1 = facing != root, facing
value = 10005

[State 10000, Dash Fwd]
type = ChangeState
trigger1 = root, stateno = 100
value = 10010

[State 10000, Dash Back]
type = ChangeState
trigger1 = root, stateno = 105
value = 10015

;[State 10000, PosAdd]
;type = PosAdd
;trigger1 = var(0) = 0
;y = -floor((sin(var(2)*pi/30.0)*15 - 80)*root, const(size.yscale))

[State 10000, VarSet]
type = VarSet
trigger1 = var(0) = 0
fvar(0) = root, pos x + 15*root, facing*root, const(size.xscale) - pos x

[State 10000, VarSet]
type = VarSet
trigger1 = var(0) = 1
fvar(0) = root, pos x - 25*root, facing*root, const(size.xscale) - pos x

[State 10000, VarSet]
type = VarSet
trigger1 = var(0) = 0
fvar(1) = root, pos y + (sin((var(2) + 1)*pi/30.0)*15 - 90)*root, const(size.yscale) - pos y

[State 10000, VarSet]
type = VarSet
trigger1 = var(0) = 1
fvar(1) = root, pos y + (sin((var(2) + 1)*pi/30.0)*15 - 70)*root, const(size.yscale) - pos y

[State 10000, VelSet]
type = VelAdd
trigger1 = fvar(0) < 0
x = -0.9*facing

[State 10000, VelSet]
type = VelAdd
trigger1 = fvar(0) > 0
x = 0.9*facing

[State 10000, VelSet]
type = VelSet
triggerall = vel x > 9
trigger1 = fvar(0) > 90
trigger1 = facing = 1
trigger2 = fvar(0) < -90
trigger2 = facing = -1
x = 9

[State 10000, VelSet]
type = VelSet
triggerall = vel x < -9
trigger1 = fvar(0) > 90
trigger1 = facing = -1
trigger2 = fvar(0) < -90
trigger2 = facing = 1
x = -9

[State 10000, VelSet]
type = VelSet
triggerall = facing = 1
trigger1 = fvar(0) > 0.5 && fvar(0) <= 90
trigger1 = vel x > 0.1*fvar(0)
trigger2 = fvar(0) < -0.5 && fvar(0) >= -90
trigger2 = vel x < 0.1*fvar(0)
x = 0.1*fvar(0)

[State 10000, VelSet]
type = VelSet
triggerall = facing = -1
trigger1 = fvar(0) > 0.5 && fvar(0) <= 90
trigger1 = vel x < 0.1*fvar(0)
trigger2 = fvar(0) < -0.5 && fvar(0) >= -90
trigger2 = vel x > -0.1*fvar(0)
x = -0.1*fvar(0)

[State 10000, VelSet]
type = VelSet
trigger1 = fvar(0) = [-0.5,0.5]
x = 0

[State 10000, VelAdd]
type = VelAdd
trigger1 = fvar(1) < 0
y = -0.6

[State 10000, VelAdd]
type = VelAdd
trigger1 = fvar(1) > 0
y = 0.6

[State 10000, VelSet]
type = VelSet
trigger1 = fvar(1) < -60
trigger1 = vel y < -6
y = -6

[State 10000, VelSet]
type = VelSet
trigger1 = fvar(1) > 60
trigger1 = vel y > 6
y = 6

[State 10000, VelSet]
type = VelSet
trigger1 = vel y > 0
trigger1 = fvar(1) > 0.5
trigger1 = fvar(1) <= 60
trigger2 = vel y < 0
trigger2 = fvar(1) < 0.5
trigger2 = fvar(1) >= -60
y =  0.1*fvar(1)

[State 10000, VelSet]
type = VelSet
trigger1 = fvar(1) = [-0.5,0.5]
y = 0

[State 10000, PosSet]
type = PosSet
trigger1 = pos y > ifelse(var(0), 5, -5)
;trigger1 = root, pos y <= 0
y = ifelse(var(0), 5, -5)

[State 10000, VarSet]
type = VarSet
triggerall = var(0) = 0
trigger1 = (parent, var(11)%100)/10 = 2
var(4) = 15

[State 10000, ParentVarAdd]
type = ParentVarAdd
triggerall = var(0) = 0
trigger1 = (parent, var(11)%100)/10 = 2
var(11) = -10

[State 10000, ParentVarSet]
type = ParentVarAdd
triggerall = var(0) = 0
trigger1 = !var(4)
trigger1 = (parent, var(11)%100)/10 = 1
var(11) = -10

[State 10000, VarSet]
type = VarSet
triggerall = var(0) = 1
trigger1 = parent, var(11)%10 = 2
var(4) = 15

[State 10000, ParentVarSet]
type = ParentVarAdd
triggerall = var(0) = 1
trigger1 = parent, var(11)%10 = 2
var(11) = -1

[State 10000, ParentVarSet]
type = ParentVarAdd
triggerall = var(0) = 1
trigger1 = !var(4)
trigger1 = parent, var(11)%10 = 1
var(11) = -1

[State 10000, PalFX]
type = PalFX
trigger1 = var(4) = 15
time = 15
sinadd = 192, 192, 192, 15

[State 10000, VarSet]
type = VarSet
triggerall = var(4) = 3
trigger1 = var(0)
trigger1 = helper(10000), stateno != [10000, 10005]
trigger2 = !var(0)
trigger2 = helper(10001), stateno != [10000, 10005]
var(4) = 16

[State 10000, VarSet]
type = VarSet
trigger1 = root, var(11) < 100
trigger1 = var(4) = 3
var(1) = ifelse(var(1) = (root, var(13)), (root, var(14)), (root, var(13)))

[State 10000, VarSet]
type = VarSet
trigger1 = root, var(11) > 99
trigger1 = var(4) = 3
var(1) = (var(1) + 2)%4

[State 10000, VarAdd]
type = VarAdd
trigger1 = var(4)
var(4) = -1

[State 10000, VarSet]
type = VarSet
trigger1 = !var(0)
trigger1 = !parent, var(11)
var(1) = parent, var(13)

[State 10000, VarSet]
type = VarSet
trigger1 = var(0)
trigger1 = !parent, var(11)
var(1) = parent, var(14)

[State 10000, ChangeAnim]
type = ChangeAnim
trigger1 = 1
value = 10000 + 1000*var(1)
elem = var(2)/5 + 1

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

[State 10000, VarSet]
type = VarSet
trigger1 = var(2) = 60
var(2) = 0

[State 10000, ChangeState]
type = ChangeState
triggerall = root, anim != 9999
triggerall = time
trigger1 = root, anim = [20, 21]
trigger2 = rootdist x - 5 != [-50, 50]
trigger3 = root, stateno = 50
value = 10001

[State 10000, ChangeState]
type = ChangeState
triggerall = root, stateno = 1350
triggerall = time
trigger1 = rootdist x - 5 != [-50, 50]
value = 10001

[State 10000, ChangeState]
type = ChangeState
triggerall = root, stateno = 200
trigger1 = root, var(9) = 1 && var(0) = 0
trigger2 = root, var(9) = 4 && var(0) = 1
value = 10020

[State 10000, ChangeState]
type = ChangeState
triggerall = root, stateno = 200
trigger1 = root, var(9) = 2 && var(0) = 0
trigger2 = root, var(9) = 5 && var(0) = 1
value = 10030

[State 10000, ChangeState]
type = ChangeState
triggerall = root, stateno = 200
trigger1 = root, var(9) = 8 && var(0) = 0
trigger2 = root, var(9) = 10 && var(0) = 1
value = 10035

[State 10000, ChangeState]
type = ChangeState
triggerall = root, stateno = 200
trigger1 = root, var(9) = 7
trigger2 = root, var(9) = 9
trigger3 = helper(10000), anim - 1000*helper(10000), var(1) = [10040, 10041]
trigger4 = helper(10001), anim - 1000*helper(10001), var(1) = [10040, 10041]
value = 10040

[State 10000, ChangeState]
type = ChangeState
triggerall = root, stateno = 200
trigger1 = root, var(9) = 3 && var(0) = 0
trigger2 = root, var(9) = 6 && var(0) = 1
value = 10050

[State 10000, ChangeState]
type = ChangeState
triggerall = root, stateno = 3000
trigger1 = root, var(1) = 3000
value = 10300

;======================================================================================
;--------------------------------------------------------------------------------------
; Follow
[Statedef 10001]
type = S
ctrl = 0
movetype = I
physics = N
anim = 10001 + 1000*var(1) + (anim = 10022 + 1000*var(1))

[State 10001, KO]
type = ChangeState
trigger1 = !root, alive
value = 15150

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

[State 10001, VarSet]
type = VarSet
triggerall = var(0) = 0
trigger1 = (parent, var(11)%100)/10 = 2
var(4) = 15

[State 10001, ParentVarSet]
type = ParentVarAdd
triggerall = var(0) = 0
trigger1 = (parent, var(11)%100)/10 = 2
var(11) = -10

[State 10001, ParentVarSet]
type = ParentVarAdd
triggerall = var(0) = 0
trigger1 = !var(4)
trigger1 = (parent, var(11)%100)/10 = 1
var(11) = -10

[State 10001, VarSet]
type = VarSet
triggerall = var(0) = 1
trigger1 = parent, var(11)%10 = 2
var(4) = 15

[State 10001, ParentVarSet]
type = ParentVarAdd
triggerall = var(0) = 1
trigger1 = parent, var(11)%10 = 2
var(11) = -1

[State 10001, ParentVarSet]
type = ParentVarAdd
triggerall = var(0) = 1
trigger1 = !var(4)
trigger1 = parent, var(11)%10 = 1
var(11) = -1

[State 10001, PalFX]
type = PalFX
trigger1 = var(4) = 15
time = 15
sinadd = 192, 192, 192, 15

[State 10001, VarSet]
type = VarSet
triggerall = var(4) = 3
trigger1 = var(0)
trigger1 = helper(10000), stateno != [10000, 10005]
trigger2 = !var(0)
trigger2 = helper(10001), stateno != [10000, 10005]
var(4) = 16

[State 10001, VarSet]
type = VarSet
trigger1 = root, var(11) < 100
trigger1 = var(4) = 3
var(1) = ifelse(var(1) = (root, var(13)), (root, var(14)), (root, var(13)))

[State 10001, VarSet]
type = VarSet
trigger1 = root, var(11) > 99
trigger1 = var(4) = 3
var(1) = (var(1) + 2)%4

[State 10001, VarAdd]
type = VarAdd
trigger1 = var(4)
var(4) = -1

[State 10001, VarSet]
type = VarSet
trigger1 = !var(0)
trigger1 = !parent, var(11)
var(1) = parent, var(13)

[State 10001, VarSet]
type = VarSet
trigger1 = var(0)
trigger1 = !parent, var(11)
var(1) = parent, var(14)

[State 10001, ChangeAnim]
type = ChangeAnim
trigger1 = anim/1000 != 10 + var(1)
value = 10000 + 1000*var(1) + anim%10
elem = animelemno(0)

[State 10001, ChangeAnim]
type = ChangeAnim
triggerall = anim = 10002 + 1000*var(1)
trigger1 = root, anim = 20
trigger2 = prevstateno < 10006
trigger2 = rootdist x - 5 > 21
trigger3 = root, stateno = 50
trigger3 = root, vel x > 0 || (root, vel x = 0 && root, vel y < 0)
value = 10001 + 1000*var(1)

[State 10001, ChangeAnim]
type = ChangeAnim
triggerall = anim != 10002 + 1000*var(1)
trigger1 = root, anim = 21
trigger2 = prevstateno < 10006
trigger2 = rootdist x - 5 < -21
trigger3 = root, stateno = 50
trigger3 = root, vel x < 0 || (root, vel x = 0 && root, vel y > 0)
value = 10002 + 1000*var(1)

[State 10001, Turn]
type = ChangeState
trigger1 = facing != root, facing
value = 10005

[State 10001, Dash Fwd]
type = ChangeState
trigger1 = root, stateno = 100
value = 10010

[State 10001, Dash Back]
type = ChangeState
trigger1 = root, stateno = 105
value = 10015

[State 10001, VarSet]
type = VarSet
trigger1 = var(0) = 0
fvar(0) = root, pos x + 15*root, facing*root, const(size.xscale) - pos x

[State 10001, VarSet]
type = VarSet
trigger1 = var(0) = 1
fvar(0) = root, pos x - 25*root, facing*root, const(size.xscale) - pos x

[State 10001, VarSet]
type = VarSet
trigger1 = var(0) = 0
fvar(1) = root, pos y + (sin((var(2) + 1)*pi/30.0)*15 - 90)*root, const(size.yscale) - pos y

[State 10001, VarSet]
type = VarSet
trigger1 = var(0) = 1
fvar(1) = root, pos y + (sin((var(2) + 1)*pi/30.0)*15 - 70)*root, const(size.yscale) - pos y

[State 10001, VelSet]
type = VelSet
trigger1 = prevstateno = 10020
trigger2 = prevstateno = 10030
trigger3 = prevstateno = 10040
trigger4 = prevstateno = 10050
trigger5 = prevstateno = 10300
trigger6 = prevstateno = 10310
x = ifelse(fvar(0) > 0, 9, -9)*facing
y = ifelse(fvar(1) > 0, 6, -6)

[State 10001, VelSet]
type = VelAdd
trigger1 = fvar(0) < 0
x = -0.9*facing

[State 10001, VelSet]
type = VelAdd
trigger1 = fvar(0) > 0
x = 0.9*facing

[State 10001, VelSet]
type = VelSet
triggerall = vel x > 9
trigger1 = fvar(0) > 90
trigger1 = facing = 1
trigger2 = fvar(0) < -90
trigger2 = facing = -1
x = 9

[State 10001, VelSet]
type = VelSet
triggerall = vel x < -9
trigger1 = fvar(0) > 90
trigger1 = facing = -1
trigger2 = fvar(0) < -90
trigger2 = facing = 1
x = -9

[State 10001, VelSet]
type = VelSet
triggerall = facing = 1
trigger1 = fvar(0) > 0.5 && fvar(0) <= 90
trigger1 = vel x > 0.1*fvar(0)
trigger2 = fvar(0) < -0.5 && fvar(0) >= -90
trigger2 = vel x < 0.1*fvar(0)
x = 0.1*fvar(0)

[State 10001, VelSet]
type = VelSet
triggerall = facing = -1
trigger1 = fvar(0) > 0.5 && fvar(0) <= 90
trigger1 = vel x < 0.1*fvar(0)
trigger2 = fvar(0) < -0.5 && fvar(0) >= -90
trigger2 = vel x > -0.1*fvar(0)
x = -0.1*fvar(0)

[State 10001, VelSet]
type = VelSet
trigger1 = fvar(0) = [-0.5,0.5]
x = 0

[State 10001, VelAdd]
type = VelAdd
trigger1 = fvar(1) < 0
y = -0.6

[State 10001, VelAdd]
type = VelAdd
trigger1 = fvar(1) > 0
y = 0.6

[State 10001, VelSet]
type = VelSet
trigger1 = fvar(1) < -60
trigger1 = vel y < -6
y = -6

[State 10001, VelSet]
type = VelSet
trigger1 = fvar(1) > 60
trigger1 = vel y > 6
y = 6

[State 10001, VelSet]
type = VelSet
trigger1 = vel y > 0
trigger1 = fvar(1) > 0.5
trigger1 = fvar(1) <= 60
trigger2 = vel y < 0
trigger2 = fvar(1) < 0.5
trigger2 = fvar(1) >= -60
y =  0.1*fvar(1)

[State 10001, VelSet]
type = VelSet
trigger1 = fvar(1) = [-0.5,0.5]
y = 0

[State 10001, PosSet]
type = PosSet
trigger1 = pos y > ifelse(var(0), 5, -5)
;trigger1 = root, pos y <= 0
y = ifelse(var(0), 5, -5)

[State 10001, ChangeState]
type = ChangeState
trigger1 = root, stateno != 20
trigger1 = root, stateno != [40, 50]
trigger1 = vel x = [-8, 8]
trigger1 = vel y = [-5, 5]
trigger1 = root, vel x = [-1, 1]
trigger1 = root, vel y = [-1, 1]
trigger1 = rootdist x - 5 = [-50, 50]
value = 10000

[State 10001, ChangeState]
type = ChangeState
triggerall = root, stateno = 200
trigger1 = root, var(9) = 1 && var(0) = 0
trigger2 = root, var(9) = 4 && var(0) = 1
value = 10020

[State 10001, ChangeState]
type = ChangeState
triggerall = root, stateno = 200
trigger1 = root, var(9) = 2 && var(0) = 0
trigger2 = root, var(9) = 5 && var(0) = 1
value = 10030

[State 10001, ChangeState]
type = ChangeState
triggerall = root, stateno = 200
trigger1 = root, var(9) = 8 && var(0) = 0
trigger2 = root, var(9) = 10 && var(0) = 1
value = 10035

[State 10001, ChangeState]
type = ChangeState
triggerall = root, stateno = 200
trigger1 = root, var(9) = 7
trigger2 = root, var(9) = 9
trigger3 = helper(10000), anim - 1000*helper(10000), var(1) = [10040, 10041]
trigger4 = helper(10001), anim - 1000*helper(10001), var(1) = [10040, 10041]
value = 10040

[State 10001, ChangeState]
type = ChangeState
triggerall = root, stateno = 200
trigger1 = root, var(9) = 3 && var(0) = 0
trigger2 = root, var(9) = 6 && var(0) = 1
value = 10050

;======================================================================================
;--------------------------------------------------------------------------------------
;Turn
[Statedef 10005]
type = S
ctrl = 0
velset = 0, 0
movetype = I
physics = N
anim = 10005 + 1000*var(1)

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

[State 10005, VarSet]
type = VarSet
triggerall = var(0) = 0
trigger1 = (parent, var(11)%100)/10 = 2
var(4) = 15

[State 10005, ParentVarSet]
type = ParentVarAdd
triggerall = var(0) = 0
trigger1 = (parent, var(11)%100)/10 = 2
var(11) = -10

[State 10005, ParentVarSet]
type = ParentVarAdd
triggerall = var(0) = 0
trigger1 = !var(4)
trigger1 = (parent, var(11)%100)/10 = 1
var(11) = -10

[State 10005, VarSet]
type = VarSet
triggerall = var(0) = 1
trigger1 = parent, var(11)%10 = 2
var(4) = 15

[State 10005, ParentVarSet]
type = ParentVarAdd
triggerall = var(0) = 1
trigger1 = parent, var(11)%10 = 2
var(11) = -1

[State 10005, ParentVarSet]
type = ParentVarAdd
triggerall = var(0) = 1
trigger1 = !var(4)
trigger1 = parent, var(11)%10 = 1
var(11) = -1

[State 10005, PalFX]
type = PalFX
trigger1 = var(4) = 15
time = 15
sinadd = 192, 192, 192, 15

[State 10005, VarSet]
type = VarSet
triggerall = var(4) = 3
trigger1 = var(0)
trigger1 = helper(10000), stateno != [10000, 10005]
trigger2 = !var(0)
trigger2 = helper(10001), stateno != [10000, 10005]
var(4) = 16

[State 10005, VarSet]
type = VarSet
trigger1 = root, var(11) < 100
trigger1 = var(4) = 3
var(1) = ifelse(var(1) = (root, var(13)), (root, var(14)), (root, var(13)))

[State 10005, VarSet]
type = VarSet
trigger1 = root, var(11) > 99
trigger1 = var(4) = 3
var(1) = (var(1) + 2)%4

[State 10005, VarAdd]
type = VarAdd
trigger1 = var(4)
var(4) = -1

[State 10005, VarSet]
type = VarSet
trigger1 = !var(0)
trigger1 = !parent, var(11)
var(1) = parent, var(13)

[State 10005, VarSet]
type = VarSet
trigger1 = var(0)
trigger1 = !parent, var(11)
var(1) = parent, var(14)

[State 10005, ChangeAnim]
type = ChangeAnim
trigger1 = anim/1000 != 10 + var(1)
value = 10000 + 1000*var(1) + anim%10
elem = animelemno(0)

[State 10005, Turn]
type = Turn
trigger1 = time = 0

[State 10005, ChangeState]
type = ChangeState
trigger1 = animtime = 0
trigger2 = frontedgedist < -70
trigger3 = backedgedist < -70
value = 10001

;======================================================================================
;--------------------------------------------------------------------------------------
;Dash Forward
[Statedef 10010]
type = S
ctrl = 0
velset = 0, 0
movetype = I
physics = N
anim = 10010 + 1000*var(1)

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

[State 10010, Explod]
type = Explod
trigger1 = time = 0
id = 10002
anim = 102 + 10*(root, var(23) != 0)
sprpriority = ifelse(var(0), 3, 0)
bindtime = -1
ownpal = 1
scale = const(size.xscale), const(size.yscale)
pos = floor(-11*const(size.yscale)), floor(const(size.yscale))
removeongethit = 1

[State 10010, PalFX]
type = PalFX
trigger1 = 1
time = 1
add = 128 - time*36, 128 - time*36, 128 - time*36

[State 10010, Stop]
type = ChangeState
trigger1 = animtime = 0
value = 10011
ctrl = 1

[State 10010, VelAdd]
type = VelAdd
trigger1 = animelemno(0) = 1
x = 0.45

[Statedef 10011]
type    = S
physics = N
ctrl = 0
anim = 10011 + 1000*var(1)
sprpriority = 0
velset = 0,0

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

[State 10010, Explod]
type = Explod
trigger1 = time = 0
id = 10003
anim = 103 + 10*(root, var(23) != 0)
sprpriority = ifelse(var(0), 3, 0)
bindtime = -1
ownpal = 1
scale = const(size.xscale), const(size.yscale)
pos = floor(-11*const(size.yscale)), floor(const(size.yscale))
removeongethit = 1

[State 10011, PalFX]
type = PalFX
trigger1 = time < 11
time = 1
add = time*45 - 232, time*45 - 232, time*45 - 232

[State 10011, PalFX]
type = PalFX
trigger1 = time = 11
time = 1
add = 96, 96, 96

[State 10011, VelSet]
type = VelSet
trigger1 = animtime = 0
x = 0
y = 0

[State 10011, End]
type = ChangeState
trigger1 = animtime = 0
value = 10001
ctrl = 1

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

;======================================================================================
;--------------------------------------------------------------------------------------
;Dash Backward
[Statedef 10015]
type = S
ctrl = 0
velset = 0, 0
movetype = I
physics = N
anim = 10010 + 1000*var(1)

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

[State 10015, Explod]
type = Explod
trigger1 = time = 0
id = 10002
anim = 102 + 10*(root, var(23) != 0)
sprpriority = ifelse(var(0), 3, 0)
bindtime = -1
ownpal = 1
facing = -1
scale = const(size.xscale), const(size.yscale)
pos = floor(41*const(size.yscale)), floor(const(size.yscale))
removeongethit = 1

[State 10015, PalFX]
type = PalFX
trigger1 = 1
time = 1
add = 128 - time*36, 128 - time*36, 128 - time*36

[State 10015, Stop]
type = ChangeState
trigger1 = animtime = 0
value = 10016
ctrl = 1

[State 10015, VelAdd]
type = VelAdd
trigger1 = animelemno(0) = 1
x = -0.45

[Statedef 10016]
type    = S
physics = N
ctrl = 0
anim = 10011 + 1000*var(1)
sprpriority = 0
velset = 0,0

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

[State 10016, Explod]
type = Explod
trigger1 = time = 0
id = 10003
anim = 103 + 10*(root, var(23) != 0)
sprpriority = ifelse(var(0), 3, 0)
bindtime = -1
ownpal = 1
facing = -1
scale = const(size.xscale), const(size.yscale)
pos = floor(41*const(size.yscale)), floor(const(size.yscale))
removeongethit = 1

[State 10016, PalFX]
type = PalFX
trigger1 = time < 11
time = 1
add = time*45 - 232, time*45 - 232, time*45 - 232

[State 10016, PalFX]
type = PalFX
trigger1 = time = 11
time = 1
add = 96, 96, 96

[State 10016, VelSet]
type = VelSet
trigger1 = animtime = 0
x = 0
y = 0

[State 10016, End]
type = ChangeState
trigger1 = animtime = 0
value = 10001
ctrl = 1

[State 10016, VelAdd]
type = VelAdd
trigger1 = 1
x = -0.45

;======================================================================================
;--------------------------------------------------------------------------------------
; Bite
[Statedef 10020]
type = S
ctrl = 0
velset = 0, 0
movetype = A
physics = N
anim = 10020 + 1000*var(1)
hitdefpersist = 1
movehitpersist = 1
hitcountpersist = 1

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

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

[State 10020, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 10020

[State 10020, VarSet]
type = varSet
trigger1 = time = 0
trigger2 = enemynear, movetype = H
fvar(2) = enemynear, pos x - helper(9999), pos x - 40*const(size.xscale)*facing

[State 10020, VarSet]
type = varSet
trigger1 = time = 0
trigger2 = enemynear, movetype = H
fvar(3) = enemynear, pos y/2 + ifelse(((!numhelper(10300) && !numhelper(10301)) || p2movetype != H || enemynear, stateno != [30000, 35000]), enemynear, const(size.mid.pos.y) + 30*const(size.yscale), -20*const(size.yscale))

[State 10020, VarSet]
type = varSet
trigger1 = fvar(3) > ifelse(((!numhelper(10300) && !numhelper(10301)) || p2movetype != H || enemynear, stateno != [32000, 32999]), 0, -28*const(size.yscale))
fvar(3) = ifelse(((!numhelper(10300) && !numhelper(10301)) || p2movetype != H || enemynear, stateno != [32000, 32999]), 0, -28*const(size.yscale))

[State 10020, VarSet]
type = VarSet
trigger1 = fvar(2) - pos x + helper(9999), pos x != 0
fvar(4) = atan((fvar(3) - pos y)/(fvar(2) - pos x + helper(9999), pos x))

[State 10020, VarAdd]
type = VarAdd
trigger1 = fvar(2) - pos x + helper(9999), pos x < 0
fvar(4) = pi

[State 10020, VarSet]
type = VarSet
trigger1 = fvar(2) - pos x + helper(9999), pos x = 0
fvar(4) = ifelse(fvar(3) - pos y < 0, -pi/2, pi/2)

[State 10020, VelSet]
type = VelSet
trigger1 = time < 15
x = time*cos(fvar(4))*facing
y = time*sin(fvar(4))

[State 10020, VelSet]
type = VelSet
trigger1 = time > 14
trigger2 = prevstateno = 10020
x = 15*cos(fvar(4))*facing
y = 15*sin(fvar(4))

[State 10020, VelAdd]
type = VelAdd
trigger1 = time < 10
trigger1 = prevstateno != 10020
y = 0.6*(10 - time)

[State 10020, Sound]
type = ParentVarSet
trigger1 = time = 0
var(10) = 1 + 10*var(0)

[State 10020, 1]
type = HitDef
triggerall = root, var(22)
trigger1 = anim = 10021 + 1000*var(1)
trigger1 = animelem = 3
attr = S, NA                     ;Attribute: Standing, Normal Attack
damage = 80, 0                   ;Damage that move inflicts, guard damage
animtype = Medium                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA                   ;Flags on how move is to be guarded against
hitflag = MA                    ;Flags of conditions that move can hit
;Hit/Miss/Dodge type (Def: Hit)
pausetime = 8, 11                 ;Time attacker pauses, time opponent shakes
sparkno = s7001				;Spark anim no (Def: set above)
guard.sparkno = s7006
sparkxy = -30, floor(-30*const(size.yscale))               ;X-offset for the "hit spark" rel. to p2,
;Y-offset for the spark rel. to p1
hitsound = s5, 1                  ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = High               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20             ;Time that the opponent slides back
ground.hittime  = 20             ;Time opponent is in hit state
ground.velocity = -10             ;Velocity at which opponent is pushed
air.type = Low
air.velocity = -3, -6.43
airguard.velocity = -3, -6.43
yaccel = .536
;Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
sprpriority = ifelse(var(0), 2, -1)
ground.cornerpush.veloff = 0

[State 10020, 1]
type = HitDef
triggerall = root, var(22)
trigger1 = anim = 10022 + 1000*var(1)
trigger1 = animelem = 4
attr = S, NA                     ;Attribute: Standing, Normal Attack
damage = 80, 0                   ;Damage that move inflicts, guard damage
animtype = Medium                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = HA                   ;Flags on how move is to be guarded against
hitflag = MA                    ;Flags of conditions that move can hit
;Hit/Miss/Dodge type (Def: Hit)
pausetime = 6, 9                 ;Time attacker pauses, time opponent shakes
sparkno = s7001				;Spark anim no (Def: set above)
guard.sparkno = s7006
sparkxy = -20, 0;*const(size.yscale)               ;X-offset for the "hit spark" rel. to p2,
;Y-offset for the spark rel. to p1
hitsound = s5, 1                  ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = Low               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20             ;Time that the opponent slides back
ground.hittime  = 20             ;Time opponent is in hit state
ground.velocity = -10             ;Velocity at which opponent is pushed
air.type = Low
air.velocity = -3, -6.43
airguard.velocity = -3, -6.43
yaccel = .536
;Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
sprpriority = ifelse(var(0), 2, -1)
ground.cornerpush.veloff = 0

[State 10020, 1]
type = HitDef
triggerall = root, var(22)
trigger1 = anim = 10023 + 1000*var(1)
trigger1 = animelem = 5
attr = S, NA                     ;Attribute: Standing, Normal Attack
damage = 80, 0                   ;Damage that move inflicts, guard damage
animtype = Medium                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA                   ;Flags on how move is to be guarded against
hitflag = MA                    ;Flags of conditions that move can hit
;Hit/Miss/Dodge type (Def: Hit)
pausetime = 8, 11                 ;Time attacker pauses, time opponent shakes
sparkno = s7001				;Spark anim no (Def: set above)
guard.sparkno = s7006
sparkxy = -25, floor(-105*const(size.yscale))               ;X-offset for the "hit spark" rel. to p2,
;Y-offset for the spark rel. to p1
hitsound = s5, 1                  ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = High               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20             ;Time that the opponent slides back
ground.hittime  = 20             ;Time opponent is in hit state
ground.velocity = -10             ;Velocity at which opponent is pushed
air.type = Low
air.velocity = -3, -6.43
airguard.velocity = -3, -6.43
yaccel = .536
;Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
sprpriority = ifelse(var(0), 2, -1)
ground.cornerpush.veloff = 0

;nospark

[State 10020, 1]
type = HitDef
triggerall = !root, var(22)
trigger1 = anim = 10021 + 1000*var(1)
trigger1 = animelem = 3
attr = S, NA                     ;Attribute: Standing, Normal Attack
damage = 80, 0                   ;Damage that move inflicts, guard damage
animtype = Medium                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA                   ;Flags on how move is to be guarded against
hitflag = MA                    ;Flags of conditions that move can hit
;Hit/Miss/Dodge type (Def: Hit)
pausetime = 8, 11                 ;Time attacker pauses, time opponent shakes
sparkno = 1				;Spark anim no (Def: set above)
guard.sparkno = 40
sparkxy = -30, floor(-30*const(size.yscale))               ;X-offset for the "hit spark" rel. to p2,
;Y-offset for the spark rel. to p1
hitsound = s5, 1                  ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = High               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20             ;Time that the opponent slides back
ground.hittime  = 20             ;Time opponent is in hit state
ground.velocity = -10             ;Velocity at which opponent is pushed
air.type = Low
air.velocity = -3, -6.43
airguard.velocity = -3, -6.43
yaccel = .536
;Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
sprpriority = ifelse(var(0), 2, -1)
ground.cornerpush.veloff = 0

[State 10020, 1]
type = HitDef
triggerall = !root, var(22)
trigger1 = anim = 10022 + 1000*var(1)
trigger1 = animelem = 4
attr = S, NA                     ;Attribute: Standing, Normal Attack
damage = 80, 0                   ;Damage that move inflicts, guard damage
animtype = Medium                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = HA                   ;Flags on how move is to be guarded against
hitflag = MA                    ;Flags of conditions that move can hit
;Hit/Miss/Dodge type (Def: Hit)
pausetime = 6, 9                 ;Time attacker pauses, time opponent shakes
sparkno = 1				;Spark anim no (Def: set above)
guard.sparkno = 40
sparkxy = -20, 0;*const(size.yscale)               ;X-offset for the "hit spark" rel. to p2,
;Y-offset for the spark rel. to p1
hitsound = s5, 1                  ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = Low               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20             ;Time that the opponent slides back
ground.hittime  = 20             ;Time opponent is in hit state
ground.velocity = -10             ;Velocity at which opponent is pushed
air.type = Low
air.velocity = -3, -6.43
airguard.velocity = -3, -6.43
yaccel = .536
;Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
sprpriority = ifelse(var(0), 2, -1)
ground.cornerpush.veloff = 0

[State 10020, 1]
type = HitDef
triggerall = !root, var(22)
trigger1 = anim = 10023 + 1000*var(1)
trigger1 = animelem = 5
attr = S, NA                     ;Attribute: Standing, Normal Attack
damage = 80, 0                   ;Damage that move inflicts, guard damage
animtype = Medium                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA                   ;Flags on how move is to be guarded against
hitflag = MA                    ;Flags of conditions that move can hit
;Hit/Miss/Dodge type (Def: Hit)
pausetime = 8, 11                 ;Time attacker pauses, time opponent shakes
sparkno = 1				;Spark anim no (Def: set above)
guard.sparkno = 40
sparkxy = -25, floor(-105*const(size.yscale))               ;X-offset for the "hit spark" rel. to p2,
;Y-offset for the spark rel. to p1
hitsound = s5, 1                  ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = High               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20             ;Time that the opponent slides back
ground.hittime  = 20             ;Time opponent is in hit state
ground.velocity = -10             ;Velocity at which opponent is pushed
air.type = Low
air.velocity = -3, -6.43
airguard.velocity = -3, -6.43
yaccel = .536
;Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
sprpriority = ifelse(var(0), 2, -1)
ground.cornerpush.veloff = 0

[State 10020, PosFreeze]
type = PosFreeze
trigger1 = fvar(2) - pos x + helper(9999), pos x = [-15, 15]
trigger1 = fvar(3) - pos y = [-15, 15]
trigger2 = anim = 10021 + 1000*var(1)
trigger2 = animelemno(0) > 2
trigger3 = anim = 10022 + 1000*var(1)
trigger3 = animelemno(0) > 3
trigger4 = anim = 10023 + 1000*var(1)
trigger4 = animelemno(0) > 4

[State 10020, ChangeAnim]
type = ChangeAnim
triggerall = anim = 10020 + 1000*var(1)
triggerall = (!numhelper(10300) && !numhelper(10301)) || p2movetype != H || enemynear, stateno != [30000, 35000]
trigger1 = ifelse(15*cos(fvar(4))*facing > 0, 15*cos(fvar(4))*4*facing > fvar(2) - pos x + helper(9999), pos x, ifelse(15*cos(fvar(4))*facing < 0, 15*cos(fvar(4))*4*facing < fvar(2)  - pos x + helper(9999), pos x, 1))
trigger1 = ifelse(15*sin(fvar(4)) > 0, 15*sin(fvar(4))*4 > fvar(3) - pos y, ifelse(15*sin(fvar(4)) < 0, 15*sin(fvar(4))*4 < fvar(3) - pos y, 1))
trigger2 = fvar(2) + 20*enemynear, statetype = C  - pos x + helper(9999), pos x = [-15, 15]
trigger2 = fvar(3) - pos y = [-15, 15]
value = ifelse(p2statetype = A, 10023, ifelse(p2statetype = C, 10022, 10021)) + 1000*var(1)

[State 10020, ChangeAnim]
type = ChangeAnim
triggerall = anim = 10020 + 1000*var(1)
trigger1 = ifelse(15*cos(fvar(4))*facing > 0, 15*cos(fvar(4))*4*facing > fvar(2) - pos x + helper(9999), pos x, ifelse(15*cos(fvar(4))*facing < 0, 15*cos(fvar(4))*4*facing < fvar(2) - pos x + helper(9999), pos x, 1))
trigger1 = ifelse(15*sin(fvar(4)) > 0, 15*sin(fvar(4))*4 > fvar(3) - pos y, ifelse(15*sin(fvar(4)) < 0, 15*sin(fvar(4))*4 < fvar(3) - pos y, 1))
trigger2 = fvar(2) - pos x + helper(9999), pos x = [-15, 15]
trigger2 = fvar(3) - pos y = [-15, 15]
value = ifelse(p2dist y < (-100*(enemynear, anim != [32000, 32999]))*const(size.yscale), 10023, ifelse(p2dist y > (-25 + 64*(enemynear, anim = [32000, 32999]))*const(size.yscale), 10022, 10021)) + 1000*var(1)

[State 10020, ChangeState]
type = ChangeState
triggerall = animtime = 0
trigger1 = anim = 10021 + 1000*var(1)
trigger2 = anim = 10022 + 1000*var(1)
trigger3 = anim = 10023 + 1000*var(1)
value = 10001

;======================================================================================
;--------------------------------------------------------------------------------------
; Dive Down
[Statedef 10030]
type = S
ctrl = 0
velset = -3, 0
movetype = A
physics = N
hitdefpersist = 1
movehitpersist = 1
hitcountpersist = 1

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

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

[State 10030, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 10030

[State 10030, ChangeState]
type = ChangeState
triggerall = anim = 10031 + 1000*var(1)
trigger1 = animtime = 0
value = 10001

[State 10030, Sound]
type = ParentVarSet
trigger1 = time = 0
trigger1 = prevstateno != 10030
var(10) = 2 + 10*var(0)

[State 10030, VarSet]
type = VarSet
trigger1 = time = 0
trigger1 = prevstateno != 10030
var(3) = 0

[State 10030, VelSet]
type = VelSet
trigger1 = var(3) = 0
trigger1 = time = 10
x = 0
y = -10

[State 10030, VarSet]
type = VarSet
trigger1 = var(3) = 0
trigger1 = time = 10
var(3) = 1

[State 10030, ChangeAnim]
type = ChangeAnim
trigger1 = time = 10
value = 10000 + 1000*var(1)
elem = 3

[State 10030, ChangeAnim]
type = ChangeAnim
triggerall = anim = 10000 + 1000*var(1)
triggerall = var(3)
trigger1 = (2.4*p2dist y - 60)*const(size.yscale) + enemynear, const(size.mid.pos.y) > p2dist x*const(size.xscale)
trigger2 = time = 40
value = 10030 + 1000*var(1)

[State 10030, ChangeAnim]
type = ChangeAnim
trigger1 = anim = 10030 + 1000*var(1)
trigger1 = pos y > 0
value = 10031 + 1000*var(1)

[State 10030, VelSet]
type = VelSet
trigger1 = anim = 10030 + 1000*var(1)
x = 9.6*const(size.xscale)
y = 4*const(size.yscale)

[State 10030, VelSet]
type = VelSet
trigger1 = anim = 10031 + 1000*var(1)
trigger1 = animelem = 1
x = 0
y = 0

[State 10030, 1]
type = HitDef
triggerall = root, var(22)
trigger1 = anim = 10030 + 1000*var(1)
trigger1 = animelem = 1
attr = S, NA                     ;Attribute: Standing, Normal Attack
damage = 50, 0                   ;Damage that move inflicts, guard damage
animtype = Heavy                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA                   ;Flags on how move is to be guarded against
hitflag = MA                    ;Flags of conditions that move can hit
;Hit/Miss/Dodge type (Def: Hit)
pausetime = 0, 9                 ;Time attacker pauses, time opponent shakes
sparkno = s7002			;Spark anim no (Def: set above)
guard.sparkno = s7006
sparkxy = -20, floor(-25*const(size.yscale))              ;X-offset for the "hit spark" rel. to p2,
;Y-offset for the spark rel. to p1
hitsound = s5, 2                 ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = High               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20             ;Time that the opponent slides back
ground.hittime  = 20             ;Time opponent is in hit state
ground.velocity = -10             ;Velocity at which opponent is pushed
air.type = Low
air.velocity = -3, -6.43
airguard.velocity = -3, -6.43
yaccel = .536
;Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
sprpriority = ifelse(var(0), 2, -1)
ground.cornerpush.veloff = 0

;nospark

[State 10030, 1]
type = HitDef
triggerall = !root, var(22)
trigger1 = anim = 10030 + 1000*var(1)
trigger1 = animelem = 1
attr = S, NA                     ;Attribute: Standing, Normal Attack
damage = 50, 0                   ;Damage that move inflicts, guard damage
animtype = Heavy                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA                   ;Flags on how move is to be guarded against
hitflag = MA                    ;Flags of conditions that move can hit
;Hit/Miss/Dodge type (Def: Hit)
pausetime = 0, 9                 ;Time attacker pauses, time opponent shakes
sparkno = 2			;Spark anim no (Def: set above)
guard.sparkno = 40
sparkxy = -20, floor(-25*const(size.yscale))              ;X-offset for the "hit spark" rel. to p2,
;Y-offset for the spark rel. to p1
hitsound = s5, 2                 ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = High               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20             ;Time that the opponent slides back
ground.hittime  = 20             ;Time opponent is in hit state
ground.velocity = -10             ;Velocity at which opponent is pushed
air.type = Low
air.velocity = -3, -6.43
airguard.velocity = -3, -6.43
yaccel = .536
;Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
sprpriority = ifelse(var(0), 2, -1)
ground.cornerpush.veloff = 0

;======================================================================================
;--------------------------------------------------------------------------------------
; Dive Up
[Statedef 10035]
type = S
ctrl = 0
velset = -3, 0
movetype = A
physics = N
hitdefpersist = 1
movehitpersist = 1
hitcountpersist = 1

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

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

[State 10035, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 10035

[State 10035, VarSet]
type = VarSet
trigger1 = time = 0
trigger1 = prevstateno != 10035
var(3) = 0

[State 10035, VelSet]
type = VelSet
trigger1 = var(3) = 0
trigger1 = time = 10
x = 0
y = 10

[State 10035, VarSet]
type = VarSet
trigger1 = var(3) = 0
trigger1 = time = 10
var(3) = 1

[State 10035, ChangeAnim]
type = ChangeAnim
trigger1 = time = 10
value = 10000 + 1000*var(1)
elem = 3

[State 10035, ChangeState]
type = ChangeState
triggerall = anim = 10031 + 1000*var(1)
trigger1 = animtime = 0
value = 10001

[State 10035, Sound]
type = ParentVarSet
trigger1 = time = 0
trigger1 = prevstateno != 10035
var(10) = 2 + 10*var(0)

[State 10035, ChangeAnim]
type = ChangeAnim
triggerall = anim = 10000 + 1000*var(1)
triggerall = var(3)
trigger1 = (2.4*p2dist y - 60)*const(size.yscale) + enemynear, const(size.mid.pos.y) < -p2dist x*const(size.xscale)
trigger2 = time = 40
trigger3 = pos y > 10
value = 10035 + 1000*var(1)

[State 10035, ChangeAnim]
type = ChangeAnim
triggerall = anim = 10035 + 1000*var(1)
trigger1 = animtime = 0
value = 10031 + 1000*var(1)

[State 10035, PosAdd]
type = PosAdd
trigger1 = anim = 10035 + 1000*var(1)
trigger1 = animelem = 1
y = 20*const(size.yscale)

[State 10035, VelSet]
type = VelSet
trigger1 = anim = 10035 + 1000*var(1)
x = 12*const(size.xscale)
y = -5*const(size.yscale)

[State 10035, VelSet]
type = VelSet
trigger1 = anim = 10031 + 1000*var(1)
trigger1 = animelem = 1
x = 0
y = 0

[State 10035, 1]
type = HitDef
triggerall = root, var(22)
trigger1 = anim = 10035 + 1000*var(1)
trigger1 = animelem = 1
attr = S, NA                     ;Attribute: Standing, Normal Attack
damage = 50, 0                   ;Damage that move inflicts, guard damage
animtype = Heavy                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA                   ;Flags on how move is to be guarded against
hitflag = MA                    ;Flags of conditions that move can hit
;Hit/Miss/Dodge type (Def: Hit)
pausetime = 0, 9                 ;Time attacker pauses, time opponent shakes
sparkno = s7002			;Spark anim no (Def: set above)
guard.sparkno = s7006
sparkxy = -20, floor(-95*const(size.yscale))               ;X-offset for the "hit spark" rel. to p2,
;Y-offset for the spark rel. to p1
hitsound = s5, 2                 ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = High               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20             ;Time that the opponent slides back
ground.hittime  = 20             ;Time opponent is in hit state
ground.velocity = -10             ;Velocity at which opponent is pushed
air.type = Low
air.velocity = -3, -6.43
airguard.velocity = -3, -6.43
yaccel = .536
;Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
sprpriority = ifelse(var(0), 2, -1)
ground.cornerpush.veloff = 0

;nospark

[State 10035, 1]
type = HitDef
triggerall = !root, var(22)
trigger1 = anim = 10035 + 1000*var(1)
trigger1 = animelem = 1
attr = S, NA                     ;Attribute: Standing, Normal Attack
damage = 50, 0                   ;Damage that move inflicts, guard damage
animtype = Heavy                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA                   ;Flags on how move is to be guarded against
hitflag = MA                    ;Flags of conditions that move can hit
;Hit/Miss/Dodge type (Def: Hit)
pausetime = 0, 9                 ;Time attacker pauses, time opponent shakes
sparkno = 2			;Spark anim no (Def: set above)
guard.sparkno = 40
sparkxy = -20, floor(-95*const(size.yscale))               ;X-offset for the "hit spark" rel. to p2,
;Y-offset for the spark rel. to p1
hitsound = s5, 2                 ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = High               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20             ;Time that the opponent slides back
ground.hittime  = 20             ;Time opponent is in hit state
ground.velocity = -10             ;Velocity at which opponent is pushed
air.type = Low
air.velocity = -3, -6.43
airguard.velocity = -3, -6.43
yaccel = .536
;Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
sprpriority = ifelse(var(0), 2, -1)
ground.cornerpush.veloff = 0

;======================================================================================
;--------------------------------------------------------------------------------------
; Sweep
[Statedef 10040]
type = S
ctrl = 0
velset = 0, 0
movetype = A
physics = N
anim = 10020 + 1000*var(1)
hitdefpersist = 1
movehitpersist = 1
hitcountpersist = 1

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

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

[State 10040, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 10040

[State 10040, VarSet]
type = varSet
trigger1 = time = 0
trigger2 = enemynear, movetype = H
fvar(2) = enemynear, pos x - helper(9999), pos x - 30*const(size.xscale)*facing

[State 10040, VarSet]
type = varSet
trigger1 = time = 0
trigger2 = enemynear, movetype = H
fvar(3) = enemynear, pos y/2 - 30*const(size.yscale) ;+ enemynear, const(size.mid.pos.y)

[State 10040, VarSet]
type = VarSet
trigger1 = fvar(2) - pos x + helper(9999), pos x != 0
fvar(4) = atan((fvar(3) - pos y)/(fvar(2) - pos x + helper(9999), pos x))

[State 10040, VarAdd]
type = VarAdd
trigger1 = fvar(2) - pos x + helper(9999), pos x < 0
fvar(4) = pi

[State 10040, VarSet]
type = VarSet
trigger1 = fvar(2) - pos x + helper(9999), pos x = 0
fvar(4) = ifelse(fvar(3) - pos y < 0, -pi/2, pi/2)

[State 10040, VelSet]
type = VelSet
trigger1 = time < 15
x = time*cos(fvar(4))*facing
y = time*sin(fvar(4))

[State 10040, VelSet]
type = VelSet
trigger1 = time > 14
trigger2 = prevstateno = 10040
x = 15*cos(fvar(4))*facing
y = 15*sin(fvar(4))

[State 10040, VelAdd]
type = VelAdd
trigger1 = time < 10
trigger1 = prevstateno != 10040
y = 0.6*(10 - time)

[State 10040, Sound]
type = ParentVarSet
trigger1 = time = 0
var(10) = 1 + 10*var(0)

[State 10040, HitDef]
type = HitDef
triggerall = root, var(22)
trigger1 = time = 0
attr = S, NA			;Attribute: Standing, Normal Attack
damage = 75, 0
animtype = Back			;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA			;Flags on how move is to be guarded against
hitflag = MAF			;Flags of conditions that move can hit
pausetime = 6, 15
sparkno = s7002				;Spark anim no (Def: set above)
guard.sparkno = s7006
sparkxy = -10, floor(5*const(size.yscale))		;X-offset for the "hit spark" rel. to p2,
					;Y-offset for the spark rel. to p1
hitsound = s5, 2			;Sound to play on hit
guardsound = s6, 0			;Sound to play on guard
ground.type = Trip		;Type: High, Low, Trip (def: Normal)
ground.slidetime = 22		;Time that the opponent slides back
ground.hittime  = 22		;Time opponent is in hit state
ground.velocity = 0, -7.5		;Velocity at which opponent is pushed
guard.velocity = -15
ground.cornerpush.veloff = 0
airguard.velocity = -3,-6.43	;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.velocity = -3, -6.43		;X-velocity at which opponent is pushed,
;air.type = Trip
air.hittime = 22			;Time before opponent regains control in air
yaccel = .536
fall = 1
fall.recover = 0
sprpriority = ifelse(var(0), 2, -1)

;nospark

[State 10040, HitDef]
type = HitDef
triggerall = !root, var(22)
trigger1 = time = 0
attr = S, NA			;Attribute: Standing, Normal Attack
damage = 75, 0
animtype = Back			;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA			;Flags on how move is to be guarded against
hitflag = MAF			;Flags of conditions that move can hit
pausetime = 6, 15
sparkno = 2				;Spark anim no (Def: set above)
guard.sparkno = 40
sparkxy = -10, floor(5*const(size.yscale))		;X-offset for the "hit spark" rel. to p2,
					;Y-offset for the spark rel. to p1
hitsound = s5, 2			;Sound to play on hit
guardsound = s6, 0			;Sound to play on guard
ground.type = Trip		;Type: High, Low, Trip (def: Normal)
ground.slidetime = 22		;Time that the opponent slides back
ground.hittime  = 22		;Time opponent is in hit state
ground.velocity = 0, -7.5		;Velocity at which opponent is pushed
guard.velocity = -15
ground.cornerpush.veloff = 0
airguard.velocity = -3,-6.43	;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.velocity = -3, -6.43		;X-velocity at which opponent is pushed,
;air.type = Trip
air.hittime = 22			;Time before opponent regains control in air
yaccel = .536
fall = 1
fall.recover = 0
sprpriority = ifelse(var(0), 2, -1)

[State 10040, VelSet]
type = VelSet
trigger1 = fvar(2) - pos x + helper(9999), pos x = [-15, 15]
trigger1 = fvar(3) - pos y = [-15, 15]
trigger2 = anim = 10045 + 1000*var(1)
trigger3 = anim = 10046 + 1000*var(1)
x = 0
y = 0

[State 10040, VarSet]
type = VarSet
trigger1 = time = 0
var(3) = 0

[State 10040, VarSet]
type = VarSet
triggerall = vel x || vel y
trigger1 = var(0) = 0
trigger1 = helper(10001), vel x = 0
trigger1 = helper(10001), vel y = 0
trigger2 = var(0) = 1
trigger2 = helper(10000), vel x = 0
trigger2 = helper(10000), vel y = 0
var(3) = 3

[State 10040, VarAdd]
type = VarAdd
trigger1 = var(3)
var(3) = -1

[State 10040, ChangeAnim]
type = ChangeAnim
triggerall = anim = 10020 + 1000*var(1)
trigger1 = ifelse(15*cos(fvar(4))*facing > 0, 15*cos(fvar(4))*4*facing > fvar(2) - pos x + helper(9999), pos x, ifelse(15*cos(fvar(4))*facing < 0, 15*cos(fvar(4))*4*facing < fvar(2) - pos x + helper(9999), pos x, 1))
trigger1 = ifelse(15*sin(fvar(4)) > 0, 15*sin(fvar(4))*4 > fvar(3) - pos y, ifelse(15*sin(fvar(4)) < 0, 15*sin(fvar(4))*4 < fvar(3) - pos y, 1))
trigger2 = fvar(2) - pos x + helper(9999), pos x = [-15, 15]
trigger2 = fvar(3) - pos y = [-15, 15]
value = 10040 + 1000*var(1) + (var(0) = 0)

[State 10040, ChangeAnim]
type = ChangeAnim
triggerall = !var(3)
triggerall = anim - 1000*var(1) = [10040, 10041]
trigger1 = helper(10000), vel x = 0
trigger1 = helper(10000), vel y = 0
trigger1 = helper(10001), vel x = 0
trigger1 = helper(10001), vel y = 0
value = anim + 5

[State 10040, ChangeAnim]
type = ChangeAnim
triggerall = anim - 1000*var(1) = [10040, 10041]
trigger1 = var(0) = 0
trigger1 = helper(10001), stateno != 10040
trigger2 = var(0) = 1
trigger2 = helper(10000), stateno != 10040
value = anim + 5

[State 10040, ChangeState]
type = ChangeState
triggerall = animtime = 0
trigger1 = anim = 10045 + 1000*var(1)
trigger2 = anim = 10046 + 1000*var(1)
value = 10001

;======================================================================================
;--------------------------------------------------------------------------------------
; Breath
[Statedef 10050]
type = S
ctrl = 0
movetype = A
physics = N
anim = 10020 + 1000*var(1)
hitdefpersist = 1
movehitpersist = 1
hitcountpersist = 1

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

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

[State 10050, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 10050

[State 10050, VarSet]
type = VarSet
trigger1 = time = 0
var(3) = floor(ifelse(p2dist x - 150*const(size.xscale) < 20, 2, 0.1*(p2dist x - 150*const(size.xscale))))

[State 10050, VarAdd]
type = VarAdd
trigger1 = time = 0
var(3) = ifelse(var(0), -2, 1)

[State 10050, VelSet]
type = VelSet
trigger1 = time = 0
x = 10

[State 10050, VelAdd]
type = VelAdd
trigger1 = time = 0
trigger1 = var(0) = 0
trigger1 = var(3)
y = floor((-60.0*root, const(size.yscale) - pos y)/(var(3) + 1.0))

[State 10050, VelAdd]
type = VelAdd
trigger1 = time = 0
trigger1 = var(0) = 1
trigger1 = var(3)
y = floor((-40.0*root, const(size.yscale) - pos y)/(var(3) + 1.0))

[State 10050, PosAdd]
type = PosAdd
trigger1 = time = 0
trigger1 = var(0) = 0
trigger1 = !var(3)
y = floor(-70.0*root, const(size.yscale) - pos y)

[State 10050, PosAdd]
type = PosAdd
trigger1 = time = 0
trigger1 = var(0) = 1
trigger1 = !var(3)
y = floor(-50.0*root, const(size.yscale) - pos y)

[State 10050, VelAdd]
type = VelAdd
trigger1 = time = [var(3) - 3, var(3)]
y = -0.8

[State 10050, ChangeAnim]
type = ChangeAnim
trigger1 = time = var(3) + 1
value = 10050 + 1000*var(1)

[State 10050, PosFreeze]
type = PosFreeze
trigger1 = anim = 10050 + 1000*var(1)

[State 10050, Sound]
type = ParentVarSet
trigger1 = anim = 10050 + 1000*var(1)
trigger1 = animelem = 5, = 8
var(10) = 2 + 10*var(0)

[State 10050, Helper]
type = Helper
trigger1 = anim = 10050 + 1000*var(1)
trigger1 = animelem = 6
name = "breath"
id = 10051 + var(1)
stateno = 10051
ownpal = 1

[State 10050, ChangeState]
type = ChangeState
triggerall = animtime = 0
trigger1 = anim = 10050 + 1000*var(1)
value = 10001

[Statedef 10051]

;var(2) = contact count
;var(3) = miss time
;var(4) = guard count
;var(5) = guard break


type    = S				;State-type: S-stand, C-crouch, A-air, L-liedown
movetype= A				;Move-type: A-attack, I-idle, H-gethit
physics = N				;Physics: S-stand, C-crouch, A-air
;Commonly-used controllers:
velset = 0,0			;Set velocity (x,y) (Def: no change)
ctrl = 0				;Set ctrl (Def: no change)
sprpriority = 2			;Set layering priority to 2 (in front)
hitdefpersist = 1
movehitpersist = 1
hitcountpersist = 1

[State 10051, VarSet]
type = VarSet
trigger1 = !anim
var(1) = parent, var(1)

[State 10051, VarSet]
type = VarSet
trigger1 = !anim
var(0) = parent, var(0)

[State 10051, PlaySnd]
type = PlaySnd
trigger1 = !anim
value = 10000, 3 + var(1)
channel = 3

[State 10051, ChangeAnim]
type = ChangeAnim
trigger1 = !anim
value = 10051 + 1000*var(1) + 10*(root, var(23) != 0)

[State 10051, SprPriority]
type = SprPriority
trigger1 = 1
value = ifelse(var(0), 3, 1)

[State 10051, BindToParent]
type = BindToParent
trigger1 = parent, stateno = 10051

[State 10051, HitOverride]
type = HitOverride
trigger1 = 1
stateno = 10051
attr = SCA, AA, AP, AT
time = -1

[State 10051, HitBy]
type = HitBy
trigger1 = 1
value = SCA, NP, SP, HP
time = -1

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

[State 10051, VarSet]
type = VarSet
trigger1 = root, projcontacttime(10051 + 1000*var(0) + var(5)) = [0, 1]
var(3) = 8

[State 10051, StopSnd]
type = StopSnd
trigger1 = root, projhittime(10051 + 1000*var(0) + var(5)) = [0, 1]
channel = 3

[State -2, Debug Info]
type = DisplayToClipboard
trigger1 = 1
text = "pct %d, %d, %d, %d"
params = root, projcontacttime(10051), root, projcontacttime(10052), root, projcontacttime(11051), root, projcontacttime(11052)
ignorehitpause = 1

[State 10051, Fire Projectile]
type = Projectile
triggerall = root, var(22)
trigger1 = var(1) = 0
trigger1 = gametime%2 = var(0)
trigger1 = animtime
trigger1 = animelemno(0) < 25
trigger1 = root, projcontacttime(10051 + 1000*var(0) + var(5)) != [0, 7]
trigger1 = var(2) < 3
trigger1 = !var(3)
projanim = ifelse(animelemno(0) = 1 || (animelemno(0) = [11, 12]) || (animelemno(0) = [23, 24]), 10052, 10053)
projid = 10051 + 1000*var(0) + var(5)
projremovetime = 1
id = 10051 + 1000*var(0) + var(5) 
attr = S, SP			;Attribute: Standing, Normal Attack
damage = ifelse(!var(2),80,ifelse(var(2)=1,50,30)),ifelse(!var(2),8,ifelse(var(2)=1,5,3))
animtype = Heavy			;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA			;Flags on how move is to be guarded against
hitflag = MAF			;Flags of conditions that move can hit
pausetime = 0, 11			;Time attacker pauses, time opponent shakes
sparkno = s7004				;Spark anim no (Def: set above)
guard.sparkno = s7006 + var(5)
sparkxy = floor(150*const(size.xscale)), floor(-10*const(size.yscale))
hitsound = s5, 2			;Sound to play on hit
guardsound = s6, 0			;Sound to play on guard
ground.type = High		;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20		;Time that the opponent slides back
ground.hittime  = 20		;Time opponent is in hit state
ground.cornerpush.veloff = 0
ground.velocity = -5
guard.velocity = -10		;Velocity at which opponent is pushed
airguard.velocity = -3,-6.43	;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.velocity = -3, -6.43		;X-velocity at which opponent is pushed,
air.type = Low
yaccel = .536
air.hittime = 20			;Time before opponent regains control in air
air.fall = 1
fall.recover = 0
palfx.time = 50
palfx.color = 0
palfx.mul = 256, 64, 0
palfx.sinadd = -64, -64, 0, 20

[State 10051, Ice Projectile]
type = Projectile
triggerall = root, var(22)
trigger1 = var(1) = 1
trigger1 = gametime%2 = var(0)
trigger1 = animtime
trigger1 = animelemno(0) < 25
trigger1 = root, projcontacttime(10051 + 1000*var(0) + var(5)) != [0, 7]
trigger1 = var(2) < 2
trigger1 = !var(3)
projanim = 11052
projid = 10051 + 1000*var(0) + var(5)
projremovetime = 1
id = 10051 + 1000*var(0) + var(5) 
attr = S, SP			;Attribute: Standing, Normal Attack
damage = ifelse(!var(2),80,50),ifelse(!var(2),8,5)
animtype = Medium			;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA			;Flags on how move is to be guarded against
hitflag = MAF			;Flags of conditions that move can hit
pausetime = 0, 10			;Time attacker pauses, time opponent shakes
sparkno = s7002				;Spark anim no (Def: set above)
guard.sparkno = s7006
sparkxy = floor(120*const(size.xscale)), floor(15*const(size.yscale))
hitsound = s5, 2			;Sound to play on hit
guardsound = s6, 0			;Sound to play on guard
ground.type = High		;Type: High, Low, Trip (def: Normal)
ground.slidetime = 10		;Time that the opponent slides back
ground.hittime  = 50		;Time opponent is in hit state
ground.velocity = 0
ground.cornerpush.veloff = 0
guard.velocity = -10		;Velocity at which opponent is pushed
guard.slidetime = 20		;Time that the opponent slides back
guard.hittime  = 20		;Time opponent is in hit state
airguard.velocity = -3,-6.43	;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.velocity = -3, -6.43		;X-velocity at which opponent is pushed,
air.type = Low
yaccel = .536
air.hittime = 20			;Time before opponent regains control in air
air.fall = 1
fall.recover = 0
p2stateno = 5706

[State 10051, Thunder Projectile]
type = Projectile
triggerall = root, var(22)
trigger1 = var(1) = 2
trigger1 = gametime%2 = var(0)
trigger1 = animtime
trigger1 = animelemno(0) < 14
trigger1 = root, projcontacttime(10051 + 1000*var(0) + var(5)) != [0, 7]
trigger1 = var(2) < 4
trigger1 = !var(3)
projanim = ifelse(animelemno(0) = 6, 12052, 12052 + ifelse(animelemno(0) < 9,ifelse(animelemno(0)%2 = 1,animelemno(0)/2,(animelemno(0)/2 + 2)%4),(animelemno(0) - 9)%4))
projid = 10051 + 1000*var(0) + var(5)
projremovetime = 1
id = 10051 + 1000*var(0) + var(5) 
attr = S, SP			;Attribute: Standing, Normal Attack
damage = ifelse(!var(2),80,ifelse(var(2)=1,50,ifelse(var(2)=2,30,20))),ifelse(!var(2),8,ifelse(var(2)=1,5,ifelse(var(2)=2,3,2)))
animtype = Heavy			;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA			;Flags on how move is to be guarded against
hitflag = MAF			;Flags of conditions that move can hit
pausetime = 0, 11			;Time attacker pauses, time opponent shakes
sparkno = s7002				;Spark anim no (Def: set above)
guard.sparkno = s7006 + var(5)
sparkxy = floor(150*const(size.xscale)), floor(-10*const(size.yscale))
hitsound = s5, 2			;Sound to play on hit
guardsound = s6, 0			;Sound to play on guard
ground.type = High		;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20		;Time that the opponent slides back
ground.hittime  = 20		;Time opponent is in hit state
ground.cornerpush.veloff = 0
ground.velocity = -5
guard.velocity = -10		;Velocity at which opponent is pushed
airguard.velocity = -3,-6.43	;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.velocity = -3, -6.43		;X-velocity at which opponent is pushed,
air.type = Low
yaccel = .536
air.hittime = 20			;Time before opponent regains control in air
air.fall = 1
fall.recover = 0
palfx.time = 50
palfx.color = 0
palfx.invertall = 1
palfx.mul = 256,256,256
palfx.add = -64,-96,-160
palfx.sinadd = 64,96,128, 10

[State 10051, Poison Projectile]
type = Projectile
triggerall = root, var(22)
trigger1 = var(1) = 3
trigger1 = gametime%2 = var(0)
trigger1 = animtime
trigger1 = animelemno(0) < 6
trigger1 = root, projcontacttime(10051 + 1000*var(0) + var(5)) != [0, 7]
trigger1 = var(2) < 2
trigger1 = !var(3)
projanim = 13051 + animelemno(0)
projid = 10051 + 1000*var(0) + var(5)
projremovetime = 1
id = 10051 + 1000*var(0) + var(5) 
attr = S, SP			;Attribute: Standing, Normal Attack
damage = ifelse(!var(2),80,50),ifelse(!var(2),8,5)
animtype = Heavy			;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA			;Flags on how move is to be guarded against
hitflag = MAF			;Flags of conditions that move can hit
pausetime = 0, 11			;Time attacker pauses, time opponent shakes
sparkno = s7002				;Spark anim no (Def: set above)
guard.sparkno = s7006 + var(5)
sparkxy = floor(ifelse(animelemno(0) < 4, 90, 120)*const(size.xscale)), floor(ifelse(animelemno(0) < 4, -5, 15)*const(size.yscale))
hitsound = s5, 2			;Sound to play on hit
guardsound = s6, 0			;Sound to play on guard
ground.type = High		;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20		;Time that the opponent slides back
ground.hittime  = 20		;Time opponent is in hit state
ground.cornerpush.veloff = 0
ground.velocity = -5
guard.velocity = -10		;Velocity at which opponent is pushed
airguard.velocity = -3,-6.43	;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.velocity = -3, -6.43		;X-velocity at which opponent is pushed,
air.type = Low
yaccel = .536
air.hittime = 20			;Time before opponent regains control in air
air.fall = 1
fall.recover = 0
palfx.time = 50
palfx.color = 128
palfx.mul = 128, 64, 160
palfx.add = 160, 0, 128
palfx.sinadd = 64, 64, 64, 20
p2stateno = 25000

;nospark

[State 10051, Fire Projectile]
type = Projectile
triggerall = !root, var(22)
trigger1 = var(1) = 0
trigger1 = gametime%2 = var(0)
trigger1 = animtime
trigger1 = animelemno(0) < 25
trigger1 = root, projcontacttime(10051 + 1000*var(0) + var(5)) != [0, 7]
trigger1 = var(2) < 3
trigger1 = !var(3)
projanim = ifelse(animelemno(0) = 1 || (animelemno(0) = [11, 12]) || (animelemno(0) = [23, 24]), 10052, 10053)
projid = 10051 + 1000*var(0) + var(5)
projremovetime = 1
id = 10051 + 1000*var(0) + var(5) 
attr = S, SP			;Attribute: Standing, Normal Attack
damage = ifelse(!var(2),80,ifelse(var(2)=1,50,30)),ifelse(!var(2),8,ifelse(var(2)=1,5,3))
animtype = Heavy			;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA			;Flags on how move is to be guarded against
hitflag = MAF			;Flags of conditions that move can hit
pausetime = 0, 11			;Time attacker pauses, time opponent shakes
sparkno = 3				;Spark anim no (Def: set above)
guard.sparkno = 40
sparkxy = floor(150*const(size.xscale)), floor(-10*const(size.yscale))
hitsound = s5, 2			;Sound to play on hit
guardsound = s6, 0			;Sound to play on guard
ground.type = High		;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20		;Time that the opponent slides back
ground.hittime  = 20		;Time opponent is in hit state
ground.cornerpush.veloff = 0
ground.velocity = -5
guard.velocity = -10		;Velocity at which opponent is pushed
airguard.velocity = -3,-6.43	;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.velocity = -3, -6.43		;X-velocity at which opponent is pushed,
air.type = Low
yaccel = .536
air.hittime = 20			;Time before opponent regains control in air
air.fall = 1
fall.recover = 0
palfx.time = 50
palfx.color = 0
palfx.mul = 256, 64, 0
palfx.sinadd = -64, -64, 0, 20

[State 10051, Ice Projectile]
type = Projectile
triggerall = !root, var(22)
trigger1 = var(1) = 1
trigger1 = gametime%2 = var(0)
trigger1 = animtime
trigger1 = animelemno(0) < 25
trigger1 = root, projcontacttime(10051 + 1000*var(0) + var(5)) != [0, 7]
trigger1 = var(2) < 2
trigger1 = !var(3)
projanim = 11052
projid = 10051 + 1000*var(0) + var(5)
projremovetime = 1
id = 10051 + 1000*var(0) + var(5) 
attr = S, SP			;Attribute: Standing, Normal Attack
damage = ifelse(!var(2),80,50),ifelse(!var(2),8,5)
animtype = Medium			;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA			;Flags on how move is to be guarded against
hitflag = MAF			;Flags of conditions that move can hit
pausetime = 0, 10			;Time attacker pauses, time opponent shakes
sparkno = 3				;Spark anim no (Def: set above)
guard.sparkno = 40
sparkxy = floor(120*const(size.xscale)), floor(15*const(size.yscale))
hitsound = s5, 2			;Sound to play on hit
guardsound = s6, 0			;Sound to play on guard
ground.type = High		;Type: High, Low, Trip (def: Normal)
ground.slidetime = 10		;Time that the opponent slides back
ground.hittime  = 50		;Time opponent is in hit state
ground.velocity = 0
ground.cornerpush.veloff = 0
guard.velocity = -10		;Velocity at which opponent is pushed
guard.slidetime = 20		;Time that the opponent slides back
guard.hittime  = 20		;Time opponent is in hit state
airguard.velocity = -3,-6.43	;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.velocity = -3, -6.43		;X-velocity at which opponent is pushed,
air.type = Low
yaccel = .536
air.hittime = 20			;Time before opponent regains control in air
air.fall = 1
fall.recover = 0
p2stateno = 5706

[State 10051, Thunder Projectile]
type = Projectile
triggerall = !root, var(22)
trigger1 = var(1) = 2
trigger1 = gametime%2 = var(0)
trigger1 = animtime
trigger1 = animelemno(0) < 14
trigger1 = root, projcontacttime(10051 + 1000*var(0) + var(5)) != [0, 7]
trigger1 = var(2) < 4
trigger1 = !var(3)
projanim = ifelse(animelemno(0) = 6, 12052, 12052 + ifelse(animelemno(0) < 9,ifelse(animelemno(0)%2 = 1,animelemno(0)/2,(animelemno(0)/2 + 2)%4),(animelemno(0) - 9)%4))
projid = 10051 + 1000*var(0) + var(5)
projremovetime = 1
id = 10051 + 1000*var(0) + var(5) 
attr = S, SP			;Attribute: Standing, Normal Attack
damage = ifelse(!var(2),80,ifelse(var(2)=1,50,ifelse(var(2)=2,30,20))),ifelse(!var(2),8,ifelse(var(2)=1,5,ifelse(var(2)=2,3,2)))
animtype = Heavy			;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA			;Flags on how move is to be guarded against
hitflag = MAF			;Flags of conditions that move can hit
pausetime = 0, 11			;Time attacker pauses, time opponent shakes
sparkno = 3				;Spark anim no (Def: set above)
guard.sparkno = 40
sparkxy = floor(150*const(size.xscale)), floor(-10*const(size.yscale))
hitsound = s5, 2			;Sound to play on hit
guardsound = s6, 0			;Sound to play on guard
ground.type = High		;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20		;Time that the opponent slides back
ground.hittime  = 20		;Time opponent is in hit state
ground.cornerpush.veloff = 0
ground.velocity = -5
guard.velocity = -10		;Velocity at which opponent is pushed
airguard.velocity = -3,-6.43	;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.velocity = -3, -6.43		;X-velocity at which opponent is pushed,
air.type = Low
yaccel = .536
air.hittime = 20			;Time before opponent regains control in air
air.fall = 1
fall.recover = 0
palfx.time = 50
palfx.color = 0
palfx.invertall = 1
palfx.mul = 256,256,256
palfx.add = -64,-96,-160
palfx.sinadd = 64,96,128, 10

[State 10051, Poison Projectile]
type = Projectile
triggerall = !root, var(22)
trigger1 = var(1) = 3
trigger1 = gametime%2 = var(0)
trigger1 = animtime
trigger1 = animelemno(0) < 6
trigger1 = root, projcontacttime(10051 + 1000*var(0) + var(5)) != [0, 7]
trigger1 = var(2) < 2
trigger1 = !var(3)
projanim = 13051 + animelemno(0)
projid = 10051 + 1000*var(0) + var(5)
projremovetime = 1
id = 10051 + 1000*var(0) + var(5) 
attr = S, SP			;Attribute: Standing, Normal Attack
damage = ifelse(!var(2),80,50),ifelse(!var(2),8,5)
animtype = Heavy			;Animation type: Light, Medium, Heavy, Back (def: Light)
guardflag = MA			;Flags on how move is to be guarded against
hitflag = MAF			;Flags of conditions that move can hit
pausetime = 0, 11			;Time attacker pauses, time opponent shakes
sparkno = 3				;Spark anim no (Def: set above)
guard.sparkno = 40
sparkxy = floor(ifelse(animelemno(0) < 4, 90, 120)*const(size.xscale)), floor(ifelse(animelemno(0) < 4, -5, 15)*const(size.yscale))
hitsound = s5, 2			;Sound to play on hit
guardsound = s6, 0			;Sound to play on guard
ground.type = High		;Type: High, Low, Trip (def: Normal)
ground.slidetime = 20		;Time that the opponent slides back
ground.hittime  = 20		;Time opponent is in hit state
ground.cornerpush.veloff = 0
ground.velocity = -5
guard.velocity = -10		;Velocity at which opponent is pushed
airguard.velocity = -3,-6.43	;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.velocity = -3, -6.43		;X-velocity at which opponent is pushed,
air.type = Low
yaccel = .536
air.hittime = 20			;Time before opponent regains control in air
air.fall = 1
fall.recover = 0
palfx.time = 50
palfx.color = 128
palfx.mul = 128, 64, 160
palfx.add = 160, 0, 128
palfx.sinadd = 64, 64, 64, 20
p2stateno = 25000

[State 10051, Fire]
type = Explod
trigger1 = var(1) = 0
trigger1 = root, projhittime(10051 + 1000*var(0) + var(5)) = [0, 1]
trigger1 = root, numtarget(10051 + 1000*var(0) + var(5))
id = 7050
anim = 7050 + random%3
sprpriority = 2
postype = p2
bindtime = 45 
pos = -20, floor(enemynear, const(size.mid.pos.y))
random = floor((enemynear, const(size.ground.front)+enemynear, const(size.ground.back))*(hitcount != 0)*0.4), floor((enemynear, const(size.mid.pos.y)-enemynear, const(size.head.pos.y))*(var(2) != 0)*0.8)

[State 10051, Ice]
type = helper
trigger1 = var(1) = 1
trigger1 = root, projhittime(10051 + 1000*var(0) + var(5)) = [0, 1]
trigger1 = root, numtarget(10051 + 1000*var(0) + var(5))
name = "ice"
id = 7060
stateno = 7060
postype = p2
pos = -40, floor(enemynear, const(size.mid.pos.y))
ownpal = 1
random = floor((enemynear, const(size.ground.front)+enemynear, const(size.ground.back))*(var(0) != 0)*0.2), floor((enemynear, const(size.mid.pos.y)-enemynear, const(size.head.pos.y))*(var(2) != 0)*0.2)

[State 10051, Shock]
type = Explod
trigger1 = var(1) = 2
trigger1 = root, projhittime(10051 + 1000*var(0) + var(5)) = [0, 1]
trigger1 = root, numtarget(10051 + 1000*var(0) + var(5))
id = 7070
anim = 7070 + random%5
sprpriority = 2
postype = p2
bindtime = -1
pos = -20, floor(enemynear, const(size.mid.pos.y))
random = floor((enemynear, const(size.ground.front)+enemynear, const(size.ground.back))*(hitcount != 0)*0.4), floor((enemynear, const(size.mid.pos.y)-enemynear, const(size.head.pos.y))*(var(2) != 0)*0.8)

[State 10051, Poison]
type = Explod
trigger1 = var(1) = 3
trigger1 = root, projhittime(10051 + 1000*var(0) + var(5)) = [0, 1]
trigger1 = root, numtarget(10051 + 1000*var(0) + var(5))
id = 7080
anim = 7080 + random%3
sprpriority = 2
postype = p2
bindtime = 53
pos = 0, enemynear, const(size.head.pos.y)/2
random = floor((enemynear, const(size.ground.front)+enemynear, const(size.ground.back))*(var(0) != 0)*0.4), floor(-enemynear, const(size.head.pos.y)*(var(2) != 0)*0.7)

[State 10051, PlaySnd]
type = PlaySnd
trigger1 = root, projhittime(10051 + 1000*var(0) + var(5)) = [0, 1]
trigger1 = root, numtarget(10051 + 1000*var(0) + var(5))
value = 5, 8 + var(1)
ignorehitpause = 1

[State 10051, VarAdd]
type = VarAdd
trigger1 = root, projcontacttime(10051 + 1000*var(0) + var(5)) = [0, 1]
;trigger1 = root, numtarget(10051 + 1000*var(0) + var(5))
var(2) = 1

[State 10051, VarAdd]
type = VarAdd
trigger1 = root, projguardedtime(10051 + 1000*var(0) + var(5)) = [0, 1]
;trigger1 = root, numtarget(10051 + 1000*var(0) + var(5))
var(4) = 1

[State 10051, VarSet]
type = VarSet
trigger1 = var(1) = 0 || var(1) = 2
trigger1 = var(4) = 2
var(5) = 1

[State 10051, VarAdd]
type = VarAdd
trigger1 = var(3)
var(3) = -1

[State 10051, DestroySelf]
type = DestroySelf
trigger1 = AnimTime = 0
trigger2 = parent, stateno = 10500
trigger3 = parent, stateno = 10530

;======================================================================================
;--------------------------------------------------------------------------------------
; Chaos Destiny Grab
[Statedef 10300]
type = S
ctrl = 0
velset = 0, 0
movetype = A
physics = N
anim = 10300 + 1000*var(1)
hitdefpersist = 1
movehitpersist = 1
hitcountpersist = 1

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

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

[State 10300, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 10300

[State 10300, VarSet]
type = VarSet
trigger1 = !var(0)
trigger1 = p2dist x - 30*const(size.xscale) > 0
fvar(2) = atan((p2dist y - 70.0)/(p2dist x - 30.0*const(size.xscale)))

[State 10300, VarSet]
type = VarSet
trigger1 = var(0)
trigger1 = helper(10000), pos x - pos x - 30*const(size.xscale) != 0
fvar(2) = atan((helper(10000), pos y - pos y + 20*const(size.yscale))/(helper(10000), pos x - pos x - 30*const(size.xscale)))

[State 10300, VarAdd]
type = VarAdd
trigger1 = var(0)
trigger1 = helper(10000), pos x - pos x - 30*const(size.xscale) < 0
fvar(2) = pi

[State 10300, VarSet]
type = VarSet
trigger1 = var(0)
trigger1 = helper(10000), pos x - pos x - 30*const(size.xscale) = 0
fvar(2) = ifelse((helper(10000), pos y - pos y + 20*const(size.yscale)) < 0, -pi/2, pi/2)

[State 10300, VarAdd] ;for ease of calculation
type = VarAdd
trigger1 = fvar(2) < 0
fvar(2) = 2*pi

[State 10300, VarAdd] ;for ease of calculation
type = VarAdd
trigger1 = fvar(2) > 2*pi
fvar(2) = -2*pi

[State 10300, VarSet]
type = VarSet
trigger1 = time = 0
trigger1 = prevstateno != 10300
trigger2 = fvar(2) - fvar(3) = [-0.1, 0.1]
trigger3 = var(0)
fvar(3) = fvar(2)

[State 10300, VarAdd]
type = VarAdd
trigger1 = fvar(3) < fvar(2)
fvar(3) = ifelse((fvar(2) - fvar(3) = [0, pi]), 0.1, -0.1)

[State 10300, VarAdd]
type = VarAdd
trigger1 = fvar(3) > fvar(2)
fvar(3) = ifelse((fvar(3) - fvar(2) = [0, pi]), -0.1, 0.1)

[State 10300, VarAdd] ;for ease of calculation
type = VarAdd
trigger1 = fvar(3) < 0
fvar(3) = 2*pi

[State 10300, VarAdd] ;for ease of calculation
type = VarAdd
trigger1 = fvar(3) > 2*pi
fvar(3) = -2*pi

[State 10300, VelSet]
type = VelSet
trigger1 = 1
x = 7*cos(fvar(3))*ifelse(var(0), facing, 1)
y = 7*sin(fvar(3))

[State 10300, Debug Info]
type = DisplayToClipboard
trigger1 = 1
text = "fvar(2) %.3f, fvar(3) %.3f"
params = fvar(2), fvar(3)
ignorehitpause = 1

[State 10300, Helper]
type = Helper
trigger1 = animelem = 3
trigger1 = !numhelper(10300 + var(0))
name = "Chaos Destiny Helper"
id = 10300 + var(0)
stateno = 10301
;size.xscale = 1
;size.yscale = 1
size.shadowoffset = 0
ownpal = 1

[State 10300, ChangeState]
type = ChangeState
trigger1 = numhelper(10300)
trigger1 = helper(10300), stateno = 10311
trigger2 = numhelper(10301)
trigger2 = helper(10301), stateno = 10311
value = 10310

[State 10300, ChangeState]
type = ChangeState
trigger1 = animtime = 0
trigger2 = !var(0)
trigger2 = pos y > 0
trigger3 = var(0)
trigger3 = helper(10000), stateno != 10300
trigger4 = var(0)
trigger4 = animelemno(0) > 2
trigger4 = !numhelper(10301)
trigger5 = !var(0)
trigger5 = animelemno(0) > 2
trigger5 = !numhelper(10300)
value = 10001

;======================================================================================
;--------------------------------------------------------------------------------------
; Chaos Destiny Grab Helper
[Statedef 10301]
type = S
ctrl = 0
velset = 0, 0
movetype = A
physics = N
anim = 10301
hitdefpersist = 1
movehitpersist = 1
hitcountpersist = 1

[State 10301, DestroySelf]
type = DestroySelf
trigger1 = parent, stateno != 10300

[State 10301, Bind]
type = BindToParent
trigger1 = 1

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

[State 10301, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 10301

[State 10301, HitDef]
type = HitDef
triggerall = root, var(22)
trigger1 = animelem = 1
attr = A, HT                     ;Attribute: Standing, Normal Attack
damage = 20, 0                   ;Damage that move inflicts, guard damage
getpower = 0
animtype = Light                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
hitflag = MAFD                    ;Flags of conditions that move can hit
pausetime = 0, 10                 ;Time attacker pauses, time opponent shakes
sparkno = s7000				;Spark anim no (Def: set above)
guard.sparkno = s7006
sparkxy = 0, floor(-30*const(size.yscale))               ;X-offset for the "hit spark" rel. to p2,
Y-offset for the spark rel. to p1
hitsound = s8, 0                  ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = High               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 12             ;Time that the opponent slides back
ground.hittime  = 12             ;Time opponent is in hit state
ground.velocity = -6             ;Velocity at which opponent is pushed
airguard.velocity = -2,-3     ;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.type = High                  ;Type: High, Low, Trip (def: same as ground.type)
air.velocity = -2,-3           ;X-velocity at which opponent is pushed,
Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
kill = 0
ground.cornerpush.veloff = 0
p1stateno = 10311
p2stateno = 3002
p2facing = 1

;nospark

[State 10301, HitDef]
type = HitDef
triggerall = !root, var(22)
trigger1 = animelem = 1
attr = A, HT                     ;Attribute: Standing, Normal Attack
damage = 20, 0                   ;Damage that move inflicts, guard damage
getpower = 0
animtype = Light                 ;Animation type: Light, Medium, Heavy, Back (def: Light)
hitflag = MAFD                    ;Flags of conditions that move can hit
pausetime = 0, 10                 ;Time attacker pauses, time opponent shakes
sparkno = 0				;Spark anim no (Def: set above)
guard.sparkno = 40
sparkxy = 0, floor(-30*const(size.yscale))               ;X-offset for the "hit spark" rel. to p2,
Y-offset for the spark rel. to p1
hitsound = s8, 0                  ;Sound to play on hit
guardsound = s6, 0                ;Sound to play on guard
ground.type = High               ;Type: High, Low, Trip (def: Normal)
ground.slidetime = 12             ;Time that the opponent slides back
ground.hittime  = 12             ;Time opponent is in hit state
ground.velocity = -6             ;Velocity at which opponent is pushed
airguard.velocity = -2,-3     ;Guard velocity in air (def: (air.xvel*1.5, air.yvel/2))
air.type = High                  ;Type: High, Low, Trip (def: same as ground.type)
air.velocity = -2,-3           ;X-velocity at which opponent is pushed,
Y-velocity at which opponent is pushed
air.hittime = 22                 ;Time before opponent regains control in air
kill = 0
ground.cornerpush.veloff = 0
p1stateno = 10311
p2stateno = 3002
p2facing = 1

;--------------------------------------------------------------------------------------
; Chaos Destiny Capture
[Statedef 10310]
type = S
ctrl = 0
velset = 0, 0
movetype = A
physics = N
hitdefpersist = 1
movehitpersist = 1
hitcountpersist = 1

[State Stunned]
type = ChangeState
trigger1 = root, movetype = H
trigger1 = root, stateno != [120, 155]
trigger1 = !root, hitshakeover
trigger1 = root, time < 2
value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = 1
value = ifelse((animelemno(0) = [3, 7]), -1, 3)

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

[State 10310, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 10310

[State 10310, ChangeAnim]
type = ChangeAnim
trigger1 = time = 0
trigger1 = prevstateno != 10310
value = 10310 + 1000*var(1)
elem = 6*var(0)

[State 10310, PosSet]
type = PosSet
trigger1 = numhelper(10300)
trigger1 = helper(10300), numtarget
x = helper(10300), pos x
y = helper(10300), pos y + ifelse(var(0), 15*const(size.yscale), -15*const(size.yscale))

[State 10310, PosSet]
type = PosSet
trigger1 = numhelper(10301)
trigger1 = helper(10301), numtarget
x = helper(10301), pos x
y = helper(10301), pos y + ifelse(var(0), 15*const(size.yscale), -15*const(size.yscale))

[State 10310, ChangeState]
type = ChangeState
triggerall = time
trigger1 = time > 103
trigger2 = var(0)
trigger2 = helper(10000), stateno != 10310
trigger3 = !var(0)
trigger3 = helper(10001), stateno != 10310
trigger4 = root, stateno != 3000
value = 10001

;--------------------------------------------------------------------------------------
; Chaos Destiny Capture
[Statedef 10311]
type = S
ctrl = 0
velset = 0, 0
movetype = A
physics = N
hitdefpersist = 1
movehitpersist = 1
hitcountpersist = 1
anim = 9999

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

[State 10311, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 10311

[State 10311, TargetDrop]
type = TargetDrop
trigger1 = time = 0
trigger1 = prevstateno != 10311
trigger1 = numhelper(10300) && numhelper(10301)
trigger1 = helper(10300), numtarget && helper(10301), numtarget
trigger1 = parent, var(0)

[State 10311, DestroySelf]
type = DestroySelf
trigger1 = !numtarget
trigger2 = root, stateno != 3000

[State 10311, TargetDrop]
type = TargetDrop
trigger1 = numtarget > 1
keepone = 1

[State 10311, PosSet]
type = PosSet
trigger1 = time = 0
trigger1 = prevstateno != 10311
x = (helper(10000), pos x + helper(10001), pos x)/2
y = (helper(10000), pos y + helper(10001), pos y)/2

[State 10311, PosSet]
type = PosSet
triggerall = numtarget
trigger1 = time = 0
trigger1 = prevstateno != 10311
x = target, pos x + 15*facing; + pos x)/2
y = (target, pos y + pos y)/2

[State 10311, VarSet]
type = VarSet
trigger1 = rootdist x + 130*root, const(size.xscale) != 0
fvar(4) = atan((rootdist y - 100*root, const(size.yscale))/(rootdist x + 130*root, const(size.xscale)))

[State 10311, VarAdd]
type = VarAdd
trigger1 = rootdist x + 130*root, const(size.xscale) < 0
fvar(4) = pi

[State 10311, VarSet]
type = VarSet
trigger1 = rootdist x + 130*root, const(size.xscale) = 0
fvar(4) = ifelse((rootdist y - 100*root, const(size.yscale)) < 0, -pi/2, pi/2)

[State 10311, VelSet]
type = VelSet
trigger1 = 1
x = ifelse(abs(rootdist x + 130*root, const(size.xscale)) < abs(7*cos(fvar(4))), 0, 7*cos(fvar(4)))
y = ifelse(abs(rootdist y - 100*root, const(size.yscale)) < abs(7*sin(fvar(4))), 0, 7*sin(fvar(4)))

[State 10311, PosSet]
type = PosSet
trigger1 = abs(rootdist x + 130*root, const(size.xscale)) < abs(7*cos(fvar(4)))
x = root, pos x + 130*root, const(size.xscale)*root, facing

[State 10311, PosSet]
type = PosSet
trigger1 = abs(rootdist y - 100*root, const(size.yscale)) < abs(7*sin(fvar(4)))
y = root, pos y - 100*root, const(size.yscale)

[State 10311, TargetBind]
type = TargetBind
trigger1 = time < 103
pos = -20*const(size.xscale), -70*const(size.yscale)

[State 10311, Helper]
type = Helper
trigger1 = time = 89
name = "cloudmaker"
id = 10350
stateno = 10350
ownpal = 1
pos = -15, floor(-50*const(size.yscale))

;[State 10311, Explod]
;type = Explod
;trigger1 = time = 89
;trigger2 = time = 92
;trigger3 = time = 95
;trigger4 = time = 98
;id = 10302
;anim = 21203
;sprpriority = ifelse(time = 89 || time = 98, 1, 2)
;postype = p1
;bindtime = 1
;facing = -1
;pos = -15, floor(-50*const(size.yscale))
;scale = 2*root, const(size.xscale), 2*root, const(size.yscale)
;random = floor(90*root, const(size.xscale)), floor(60*root, const(size.yscale))

[State 10311, VarSet]
type = VarSet
trigger1 = time = 103
var(0) = random%4
;0 = Leo
;1 = Tao
;2 = Mukuro
;3 = Tabasa

[State 10311, VarSet]
type = VarSet
triggerall = numtarget
triggerall = time = 103
trigger1 = target, name = "cvsleo"
trigger2 = target, name = "leo"
trigger3 = target, name = "Leo"
var(0) = 0

[State 10311, VarSet]
type = VarSet
triggerall = numtarget
triggerall = time = 103
trigger1 = target, name = "tao"
trigger2 = target, name = "Tao"
trigger3 = target, name = "mai-ling"
trigger4 = target, name = "Mai-Ling"
trigger5 = target, name = "mai ling"
trigger6 = target, name = "Mai Ling"
var(0) = 1

[State 10311, VarSet]
type = VarSet
triggerall = numtarget
triggerall = time = 103
trigger1 = target, name = "mukuro"
trigger2 = target, name = "Mukuro"
trigger3 = target, name = "kenji"
trigger4 = target, name = "Kenji"
var(0) = 2

[State 10311, VarSet]
type = VarSet
triggerall = numtarget
triggerall = time = 103
trigger1 = target, name = "tabasa"
trigger2 = target, name = "Tabasa"
trigger3 = target, name = "tessa"
trigger4 = target, name = "Tessa"
var(0) = 3

[State 10311, TargetState]
type = TargetState
trigger1 = time = 103
value = 30500 + 1000*var(0)

[State 10311, ChangeState]
type = ChangeState
triggerall = time
trigger1 = time = 103
value = 39999

; Cloud Dispenser

[Statedef 10350]
type = S
ctrl = 0
velset = 0, 0
movetype = A
physics = N
anim = 9999

[State 10350, PosSet]
type = PosSet
trigger1 = pos y > 0
y = 0

[State 10350, PlaySnd]
type = PlaySnd
trigger1 = !prevstateno
trigger1 = time = 0
value = 1200, 0

[State 10350, Explod]
type = Explod
trigger1 = time%3 = 0
id = 10302
anim = 21203 + 10*(root, var(23) != 0)
sprpriority = ifelse(time = 0 || time = 9, 1, 2)
postype = p1
bindtime = 1
facing = -1
scale = 2*root, const(size.xscale), 2*root, const(size.yscale)
random = floor(50*root, const(size.xscale)), floor(50*root, const(size.yscale))

[State 10350, DestroySelf]
type = DestroySelf
trigger1 = time = 10

;======================================================================================
;--------------------------------------------------------------------------------------
;Stunned
[Statedef 10500]
type = S
ctrl = 0
velset = 0, 0
movetype = H
physics = N
anim = 10000

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

[State 10500, RemoveExplod]
type = RemoveExplod
trigger1 = time = 0
id = 10002

[State 10500, RemoveExplod]
type = RemoveExplod
trigger1 = time = 0
id = 10003

[State 10500, ChangeState]
type = ChangeState
trigger1 = root, gethitvar(animtype) = [3, 5]
trigger1 = root, var(12) != 2
value = 10530

[State 10500, ChangeAnim]
type = ChangeAnim
trigger1 = anim != ifelse(root, gethitvar(animtype) < 3, 10500 + root, gethitvar(animtype), 10502) + 1000*var(1)
trigger1 = root, gethitvar(groundtype) != 2
value = ifelse(root, gethitvar(animtype) < 3, 10500 + root, gethitvar(animtype), 10502) + 1000*var(1)

[State 10500, ChangeAnim]
type = ChangeAnim
trigger1 = anim != ifelse(root, gethitvar(animtype) < 3, 10510 + root, gethitvar(animtype), 10512) + 1000*var(1)
trigger1 = root, gethitvar(groundtype) = 2
value = ifelse(root, gethitvar(animtype) < 3, 10510 + root, gethitvar(animtype), 10512) + 1000*var(1)

[State 10500, ChangeAnim]
type = ChangeAnim
trigger1 = !root, hitshakeover
value = anim

[State 10500, PosAdd]
type = PosAdd
trigger1 = !root, hitshakeover
x = ifelse(time%2, 1, -1)

[State 10500, PosFreeze]
type = PosFreeze
trigger1 = !root, hitshakeover

[State 10500, VarSet]
type = VarSet
trigger1 = var(0) = 0
fvar(0) = root, pos x + 20*root, facing*root, const(size.xscale) - pos x

[State 10500, VarSet]
type = VarSet
trigger1 = var(0) = 1
fvar(0) = root, pos x - 20*root, facing*root, const(size.xscale) - pos x

[State 10500, VarSet]
type = VarSet
trigger1 = var(0) = 0
fvar(1) = root, pos y + (sin((var(2) + 1)*pi/30.0)*15 - 100)*root, const(size.yscale) - pos y

[State 10500, VarSet]
type = VarSet
trigger1 = var(0) = 1
fvar(1) = root, pos y + (sin((var(2) + 1)*pi/30.0)*15 - 80)*root, const(size.yscale) - pos y

[State 10500, VelSet]
type = VelSet
trigger1 = !root, hitshakeover
x = 0
y = 0

[State 10500, VelSet]
type = VelSet
;triggerall = vel x > 9
trigger1 = fvar(0) > 90
trigger1 = facing = 1
trigger2 = fvar(0) < -90
trigger2 = facing = -1
x = 9

[State 10500, VelSet]
type = VelSet
;triggerall = vel x < -9
trigger1 = fvar(0) > 90
trigger1 = facing = -1
trigger2 = fvar(0) < -90
trigger2 = facing = 1
x = -9

[State 10500, VelSet]
type = VelSet
triggerall = facing = 1
trigger1 = fvar(0) > 0.5 && fvar(0) <= 90
;trigger1 = vel x > 0.1*fvar(0)
trigger2 = fvar(0) < -0.5 && fvar(0) >= -90
;trigger2 = vel x < 0.1*fvar(0)
x = 0.1*fvar(0)

[State 10500, VelSet]
type = VelSet
triggerall = facing = -1
trigger1 = fvar(0) > 0.5 && fvar(0) <= 90
;trigger1 = vel x < 0.1*fvar(0)
trigger2 = fvar(0) < -0.5 && fvar(0) >= -90
;trigger2 = vel x > -0.1*fvar(0)
x = -0.1*fvar(0)

[State 10500, VelSet]
type = VelSet
trigger1 = fvar(0) = [-0.5,0.5]
x = 0

[State 10500, VelSet]
type = VelSet
trigger1 = fvar(1) < -60
;trigger1 = vel y < -6
y = -6

[State 10500, VelSet]
type = VelSet
trigger1 = fvar(1) > 60
;trigger1 = vel y > 6
y = 6

[State 10500, VelSet]
type = VelSet
trigger1 = fvar(1) = [-60, 60]
y =  0.1*fvar(1)

[State 10500, VelSet]
type = VelSet
trigger1 = fvar(1) = [-0.5,0.5]
y = 0

[State 10500, PosSet]
type = PosSet
trigger1 = pos y > ifelse(var(0), 5, -5)
;trigger1 = root, pos y <= 0
y = ifelse(var(0), 5, -5)

[State 10500, ChangeState]
type = ChangeState
triggerall = animelemno(0) > 1 || root, movetype != H
trigger1 = vel x = [-8, 8]
trigger1 = vel y = [-5, 5]
trigger1 = root, vel x = [-1, 1]
trigger1 = root, vel y = [-1, 1]
trigger1 = rootdist x - 5 = [-50, 50]
value = 10000

;Knocked Back
[Statedef 10530]
type = S
ctrl = 0
velset = 0, 0
movetype = H
physics = N
anim = 10530 + 1000*var(1)

;[State Stunned] ;Doesn't get stunned here in Warzard
;type = ChangeState
;triggerall = time
;trigger1 = root, movetype = H
;trigger1 = !root, hitshakeover
;trigger1 = root, time < 2
;value = 10500

[State Back/Foreground]
type = SprPriority
trigger1 = time = 0
value = ifelse(var(0), 2, -1)

[State 10530, ChangeAnim]
type = ChangeAnim
trigger1 = animelemno(0) = 1
trigger1 = !root, hitshakeover
value = anim

[State 10530, PosAdd]
type = PosAdd
trigger1 = animelemno(0) = 1
trigger1 = !root, hitshakeover
x = ifelse(time%2, 1, -1)

[State 10530, PosSet]
type = PosSet
trigger1 = pos y > 0
y = 0

[State 10530, PosFreeze]
type = PosFreeze
trigger1 = animelemno(0) = 1
trigger1 = !root, hitshakeover

[State 10530, VelSet]
type = VelSet
trigger1 = animelemno(0) = 1
trigger1 = !root, hitshakeover
x = -3
y = -3

[State 10530, VelAdd]
type = VelAdd
trigger1 = root, hitshakeover
trigger2 = animelemno(0) != 1
x = ifelse(vel x < -0.05, 0.05, 0)
y = 0.3

[State 10530, VelSet]
type = VelMul
trigger1 = animelemno(0) > 5
trigger1 = pos y > -40
x = 0.5
y = 0.5

[State 10530, ChangeState]
type = ChangeState
trigger1 = animelemno(0) > 5
trigger1 = pos y > -40
value = 10000

;======================================================================================
;--------------------------------------------------------------------------------------
; Origin Marker
[Statedef 9999]
type = S
ctrl = 0
velset = 0, 0
movetype = I
physics = N
anim = 9999

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

[State 9999, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA, AA, AP, AT
stateno = 9999

[State 9999, DestroySelf]
type = DestroySelf
trigger1 = 0

;======================================================================================
;--------------------------------------------------------------------------------------
;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) > 1
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

