;-------------------------------------------------------------------------------
;Shoryureppa
[Statedef 3100]
type = S
movetype = A
physics = N
ctrl = 0
velset = 0,0
facep2 = 1

[State 0, var]
type = varset
triggerall = !var(15)
trigger1 = !time
var(19) = IfElse((Command = "Shoryureppay" && Power >= 2000) || (Command = "Shoryureppaz" && (Power >= 2000 && Power < 3000)), 1, IfElse(Command = "Shoryureppaz" && Power >= 3000,2,0))

[State 0, varset]
type = varset
triggerall = var(15)
trigger1 = !time
var(19) = 0

[State 0, poweradd]
type = poweradd
trigger1 = !time
value = ifelse(!var(19), -1000, ifelse(var(19) = 1, -2000, -3000))

[State 0, anim]
type = changeanim
trigger1 = !time
value = ifelse(!var(19), 3100, ifelse(var(19) = 1, 3101, 3102))

[State 0, AfterImage]
type = AfterImage
trigger1 = AnimElem = 1
time = 999
TimeGap = 3
FrameGap = 4
length = 10
PalBright = 1,1,1
PalContrast = ifElse(!Var(19), 128, ifElse(Var(19) = 1, 50, 150)),ifElse(!Var(19), 128, ifelse(Var(19) = 1, 50, 50)),ifElse(!Var(19), 128, ifElse(Var(19) = 1, 150, 50))
PalAdd = 0,0,0
PalMul = .5,.5,.5
trans = add1

[State 0, var]
type = varset
triggerall = var(15) > 0
trigger1 = !time
var(2) = 0

[State 0, die]
type = varset
triggerall = var(15) > 0
trigger1 = !time ;= 5
var(15) = 0

[State 0, assert]
type = assertspecial
triggerall = (enemynear, stateno != [120, 155])
trigger1 = (Time = [5, 46])
flag = unguardable
ignorehitpause = 1

[State 0, Super]
type = superpause
trigger1 = time = 5
time = 40
movetime = 40
p2defmul = 1
unhittable = 1
anim = -1
sound = S8000, ifelse(var(19) = 2, 1,0)
darken = 0

[State 0, FX]
type = helper
trigger1 = time = 5
helpertype = normal
stateno = 8500+(10*var(19));8510
ID = 8500
name = "Superpause FX"
postype = p1
pos = ceil(11 * const(size.xscale)), ceil(-54 * const(size.yscale))
supermovetime = 255
size.xscale = 1
size.yscale = 1
ownpal = 1

[State 0, Dust]
type = explod
trigger1 = animelem = 4
trigger2 = AnimElem = 14
trigger3 = AnimElem = 24
anim = 10050
sprpriority = 3
postype = p1
pos = 0, ceil(pos y)
ownpal = 1
scale = 0.5, 0.5
pausemovetime = -1
supermovetime = -1

[State 0, State]
type = StateTypeSet
trigger1 = AnimElem = 12 && var(19) != 2
trigger2 = AnimElem = 23 && var(19) = 2
statetype = A
movetype = A
physics = N

[State 0, snd]
type = PlaySnd
trigger1 = time = 3
value = 4, 5
channel = 0

[State 0, snd]
type = PlaySnd
trigger1 = AnimElem = 2
value = 3,1
channel = 0

[State 0, snd]
type = PlaySnd
trigger1 = AnimElem = 12
value = 3,9
channel = 0

[State 0, snd]
type = PlaySnd
trigger1 = AnimElem = 23
value = 3, 11
channel = 0

[State 0, assert]
type = assertspecial
triggerall = Time = [5, 45]
trigger1 = (EnemyNear, StateNo != [120,155])
flag = unguardable
ignorehitpause = 1

[State 0, cancel]
type = RemoveExplod
trigger1 = !time
ID = 1395

[State 0, cancel]
type = RemoveExplod
trigger1 = !time
ID = 1396

[State 0, cheat]
type = NotHitBy
trigger1 = AnimElemTime(4) <= 0
trigger2 = AnimElemtime(5) <= 0 && var(19) = 1
trigger3 = AnimElemtime(6) <= 0 && var(19) = 2
value = SCA

[State 0, snd]
type = playsnd
trigger1 = AnimElem = 1
value = S3000, 0
channel = 0

[State 0, snd]
type = playsnd
trigger1 = AnimElem = 2
value = S3000, 1
channel = 0

[State 0, snd]
type = playsnd
trigger1 = AnimElem = 2
trigger2 = AnimElem = 12
trigger3 = AnimElem = 22 && var(19) = 2
value = S51, 3

[State 0, snd]
type = playsnd
trigger1 = AnimElem = 4
trigger2 = AnimElem = 14
trigger3 = AnimElem = 24
value = S40, 0

[State 0, Vel]
type = VelSet
trigger1 = AnimElem = 2
x = 6

[State 0, Vel]
type = VelSet
trigger1 = AnimElem = 12
x = ifelse(var(19) = 1, 10, 6)

[State 0, vel]
type = velset
trigger1 = AnimElem = 23
x = 12

[State 0, vel]
type = veladd
trigger1 = AnimElemtime(2) > 0 && AnimElemtime(5) < 0
trigger2 = AnimElemtime(12) > 0 && AnimElemtime(16) < 0
trigger3 = AnimElemtime(23) > 0 && AnimElemtime(27) < 0 && var(19) = 2
x = ifElse(Vel X <= 0, 0, -.5)

[State 0, vel]
type = velset
trigger1 = AnimElem = 5
trigger2 = AnimElem = 16 
trigger3 = AnimElemtime(26) = 10 && var(19) = 2
x = 0

[State 0, Vel]
type = VelSet
trigger1 = AnimElemtime(15) = 2 && var(19) != 2
trigger2 = AnimElemtime(26) = 2 && var(19) = 2
y = ifelse(!var(19), -9, ifelse(var(19) = 1, -10.5, -11.5))

[State 0, vel]
type = velset
trigger1 = AnimElem = 16 && var(19) != 2
trigger2 = AnimElem = 27 && var(19) = 2
y = 0

[State 0, VelAdd]
type = VelAdd
trigger1 = AnimElemTime(15) > 0 && var(19) != 2
trigger2 = AnimElemtime(26) > 0 && var(19) = 2
y = .5

[State 0, hit1]
type = Hitdef
triggerall = var(19)
triggerall = !var(4) && (var(2) < 1 || var(15)) || numtarget(1200) || numtarget(3100)
trigger1 = AnimElem = 2
trigger2 = AnimElem = 13
trigger3 = AnimElem = 24 && var(19) = 2
attr = A, HA
damage = ceil(ifelse(fvar(11) * 42 < 7, 7, fvar(11) * 42)), 5
animtype = Hard
air.animtype = back
fall.animtype = back
priority = 7, hit
hitflag = MAF
guardflag = MA
pausetime = 6, 6
hitsound = S2, 2
guardsound = S6, 0
ground.type = High
ground.slidetime = 20
ground.hittime = 20
guard.hittime = 12
ground.velocity = -4
guard.velocity = -5.77
airguard.velocity = -5.33,-1
air.type = Low
air.velocity = -2, -4
air.hittime = 120
getpower = 0, 0
ground.cornerpush.veloff = 0
air.cornerpush.veloff = 0
air.fall = 1
air.recover = 0
fall = 0
fall.recover = 0
yaccel = .5
Id = 3100
envshake.time = 7
fall.envshake.time = 0
fall.envshake.freq = 0.0
fall.envshake.ampl = 0
fall.envshake.phase = 0.0
sparkno = S-1 + 0 * (var(33) := 8014)
guard.sparkno = S-1 + 0 * (var(34) := 8001)
sparkxy = -10 + 0 * (var(35) := 35), var(36) := -30

[State 0, hit2]
type = Hitdef
triggerall = !var(4) && (var(2) < 1 || var(15)) || numtarget(1200) || numtarget(3100)
trigger1 = AnimElem = 3
trigger2 = AnimElem = 14
trigger3 = AnimElem = 25 && var(19) = 2
attr = A, HA
damage = ceil(ifelse(fvar(11) * 42 < 7, 7, fvar(11) * 42)), 5
animtype = Hard
air.animtype = back
fall.animtype = back
priority = 7,hit
hitflag = MAF
guardflag = M
ID = 3100
pausetime = 6, 6
hitsound = S2, 2
guardsound = S6, 0
ground.type = High
ground.slidetime = 20
ground.hittime = 20
guard.hittime = 12
ground.velocity = -4
guard.velocity = -5.77
airguard.velocity = -5.33,-1
air.type = Low
air.velocity = -2, -4
air.hittime = 120
getpower = 0, 0
ground.cornerpush.veloff = 0
air.cornerpush.veloff = 0
air.fall = 1 
air.recover = 0
fall = 0
fall.recover = 0
yaccel = .5
envshake.time = 7
fall.envshake.time = 0
fall.envshake.freq = 0.0
fall.envshake.ampl = 0
fall.envshake.phase = 0.0
sparkno = S-1 + 0 * (var(33) := 8014)
guard.sparkno = S-1 + 0 * (var(34) := 8001)
sparkxy = -10 + 0 * (var(35) := 35), var(36) := -80

[State 0, hit3]
type = Hitdef
triggerall = !var(4) && (var(2) < 1 || var(15)) || numtarget(1200) || numtarget(3100)
trigger1 = AnimElem = 4
trigger2 = AnimElem = 15 && var(19) = 2
attr = A, HA
damage = ceil(ifelse(fvar(11) * 42 < 7, 7, fvar(11) * 42)), 5
animtype = Hard
air.animtype = back
fall.animtype = back
priority = 7,hit
hitflag = MAF
guardflag = M
ID = 3100
pausetime = 6, 6 
hitsound = S2, 2
guardsound = S6, 0
ground.type = High
ground.slidetime = 20
ground.hittime = 20
guard.hittime = 12
ground.velocity = -4
guard.velocity = -5.77
airguard.velocity = -5.33,-1
air.type = Low
air.velocity = -2, -4
air.hittime = 120
fall = 0
fall.recover = 0
ground.cornerpush.veloff = 0
air.cornerpush.veloff = 0
air.fall = 1
air.recover = 0
yaccel = .5
getpower = 0, 0
forcestand = 1
envshake.time = 8
fall.envshake.time = 0
fall.envshake.freq = 0.0
fall.envshake.ampl = 0
fall.envshake.phase = 0.0
sparkno = S-1 + 0 * (var(33) := 8014)
guard.sparkno = S-1 + 0 * (var(34) := 8001)
sparkxy = -10 + 0 * (var(35) := 21), var(36) := -110

[State 0, hit5]
type = HitDef
triggerall = !var(4) && (var(2) < 1 || var(15)) || numtarget(1200) || numtarget(3100)
trigger1 = AnimElem = 14
attr = A, HA
damage = ceil(ifelse(fvar(11) * 49 < 7, 7, fvar(11) * 49)), 6
animtype = Heavy
air.animtype = back
fall.animtype = back
hitflag = MAF
guardflag = M
priority = 7, Hit
pausetime = 8, 8
hitsound = S2,2
guardsound = S6, 0
ground.type = High
ground.slidetime = 20
ground.hittime = 20
guard.hittime = 12
ground.velocity = -4
guard.velocity = -5.77
airguard.velocity = -5.33,-1
air.type = High
air.velocity = -2, -5
air.hittime = 120
ground.cornerpush.veloff = 0
air.cornerpush.veloff = 0
air.fall = 1
fall.recover = 0
air.recover = 0
forcestand = 1
getpower = 0, 0
yaccel = .5
envshake.time = 10
fall.envshake.time = 0
fall.envshake.freq = 0.0
fall.envshake.ampl = 0
fall.envshake.phase = 0.0
sparkno = S-1 + 0 * (var(33) := 8014)
guard.sparkno = S-1 + 0 * (var(34) := 8001)
sparkxy = -10 + 0 * (var(35) := 35), var(36) := -80

[State 0, hit6]
type = HitDef
triggerall = !var(4) && (var(2) < 1 || var(15)) || numtarget(1200) || numtarget(3100)
triggerall = var(19) != 2
trigger1 = AnimElem = 15
attr = A, HA
damage = ceil(ifelse(fvar(11) * ifelse(var(19) != 2, 49, 56) < 7, 7, fvar(11) * ifelse(var(19) != 2, 49, 56))), 6
animtype = Heavy
air.animtype = back
fall.animtype = back
hitflag = MAF
guardflag = M
Id = 3100
priority = 7, Hit
pausetime = 10, 10
hitsound = S2,2
guardsound = S6, 0
ground.type = High
ground.slidetime = 20
ground.hittime = 20
guard.hittime = 12
ground.velocity = -5, -6
guard.velocity = -5.77
airguard.velocity = -5.33,-1
air.type = High
air.velocity = -5, -6
air.hittime = 120
ground.cornerpush.veloff = 0
air.cornerpush.veloff = 0
fall = 1
fall.recover = 1
fall.recovertime = 120
getpower = 0, 0
yaccel = .5
envshake.time = 12
fall.envshake.time = 0
fall.envshake.freq = 0.0
fall.envshake.ampl = 0
fall.envshake.phase = 0.0
sparkno = S-1 + 0 * (var(33) := 8014)
guard.sparkno = S-1 + 0 * (var(34) := 8001)
sparkxy = -10 + 0 * (var(35) := 21), var(36) := -110

[State 0, hit6]
type = HitDef
triggerall = !var(4) && (var(2) < 1 || var(15)) || numtarget(1200) || numtarget(3100)
triggerall = var(19) = 2
trigger1 = AnimElem = 26
attr = A, HA
damage = ceil(ifelse(fvar(11) * 49 < 7, 7, fvar(11) * 49)), 5
animtype = UP
hitflag = MAF
guardflag = M
ID = 3100
priority = 7, Hit
pausetime = 12, 12
hitsound = S2,2
guardsound = S6, 0
ground.type = High
ground.slidetime = 20
ground.hittime = 20
guard.hittime = 12
ground.velocity = -5, -6
guard.velocity = -5.77
air.type = High
air.velocity = -5, -7
air.hittime = 120
ground.cornerpush.veloff = 0
air.cornerpush.veloff = 0
fall = 1
fall.recover = 1
fall.recovertime = 120
getpower = 0, 0
yaccel = .5
envshake.time = 12
fall.envshake.time = 0
fall.envshake.freq = 0.0
fall.envshake.ampl = 0
fall.envshake.phase = 0.0
sparkno = S-1 + 0 * (var(33) := 8014)
guard.sparkno = S-1 + 0 * (var(34) := 8001)
sparkxy = -10 + 0 * (var(35) := 21), var(36) := -110

[State 0, idle]
type = statetypeset
trigger1 = AnimElemtime(16) >= 0 && var(19) != 2
trigger2 = AnimElemtime(27) >= 0 && var(19) = 2
movetype = I

[State 0, end]
type = changestate
triggerall = (AnimElemtime(16) > 0 && var(19) != 2) || (var(19) = 2 && AnimElemtime(27) >= 0)
trigger1 = pos Y >= 0 && Vel Y > 0
value = 1007

;Shinkuu hadouken
[Statedef 3000]
type = S
movetype = A
Physics = S
anim = 3000
ctrl = 0
velset = 0,0
facep2 = 1

[State 0, width]
type = width
trigger1 = AnimElemtime(27) = 0
value = 25, 0
ignorehitpause = 1

[State 0, var]
type = varset
triggerall = !var(15)
trigger1 = !time
var(19) = IfElse((Command = "Shinku2" && Power >= 2000) || (Command = "Shinku3" && (Power >= 2000 && Power < 3000)), 1, IfElse(Command = "Shinku3" && Power >= 3000,2,0))

[State 0, varset]
type = varset
triggerall = var(15)
trigger1 = !time
var(19) = 0

[State 0, nhb]
type = nothitby
trigger1 = AnimElemtime(24) < 0 && !var(19)
trigger2 = AnimElemtime(26) < 0 && var(19) = 1
trigger3 = AnimElemtime(28) < 0 && var(19) = 2
value = SCA

[State 0, Aura]
type = helper
trigger1 = animelem = 1
helpertype = normal
stateno = 6000
ID = 6000
postype = p1
ownpal = 1
persistent = 0
supermovetime = 9999
pausemovetime = 9999

[State 0, power]
type = poweradd
trigger1 = !time
value = ifelse(!var(19), -1000, ifelse(var(19) = 1, -2000, -3000))

[State 0, AfterImage]
type = AfterImage
trigger1 = AnimElem = 1
time = 999
TimeGap = 3
FrameGap = 4
length = 10
PalBright = 1,1,1
PalContrast = ifElse(!Var(19), 128, ifElse(Var(19) = 1, 50, 150)),ifElse(!Var(19), 128, ifelse(Var(19) = 1, 50, 50)),ifElse(!Var(19), 128, ifElse(Var(19) = 1, 150, 50))
PalAdd = 0,0,0
PalMul = .5,.5,.5
trans = add1

[State 0, var]
type = varset
triggerall = var(15) > 0
trigger1 = !time
var(2) = 0

[State 0, die]
type = varset
triggerall = var(15) > 0
trigger1 = time = 5
var(15) = 0

[State 0, assert]
type = assertspecial
triggerall = Time = [5, 45]
trigger1 = (EnemyNear, StateNo != [120,155])
flag = unguardable
ignorehitpause = 1

[State 0, Super]
type = superpause
trigger1 = time = 2
time = 43
movetime = 43
p2defmul = 1
unhittable = 1
anim = -1
sound = S8000, ifelse(var(19) = 2, 1,0)
darken = 0

[State 0, FX]
type = helper
trigger1 = time = 2
helpertype = normal
stateno = 8500+(10*var(19))
ID = 8500
name = "Superpause FX"
postype = p1
pos = ceil(-13 * const(size.xscale)), ceil(-73 * const(size.yscale))
supermovetime = 255
size.xscale = 1
size.yscale = 1
ownpal = 1

[State 0, snd]
type = playsnd
trigger1 = Animelem = 1
value = S4, 5
channel = 0

[State 0, snd]
type = playsnd
trigger1 = AnimElemTime(27) = 1
value = S1000, 5
channel = 0

[State 0, snd]
type = playsnd
trigger1= AnimElem = 27
value = S3, 7

[State 0, Hadouken]
type = helper
trigger1 = animelemtime(27) = 1
helpertype = normal
stateno = 30000
ID = 1000
name = "Hadouken"
postype = p1
pos = 72, -65
size.xscale = 1
size.yscale = 1
ownpal = 1

[State 0, AI]
type = changestate
triggerall = AILevel && frontedgedist < 25 && enemy, statetype = A && numtarget
triggerall = p2bodydist x < 30 && p2bodydist y = [0, -35]
triggerall = !var(4) && var(2) < 1
trigger1 = !Animtime
value = 1100
ignorehitpause = 1

[State 0, end]
type = ChangeState
trigger1 = !AnimTime
value = 0
ctrl = 1

;Shinkuu hadouken
[Statedef 3050]
type = A
movetype = A
Physics = N
ctrl = 0
velset = 0,0
facep2 = 1
anim = 3050

[State 0, width]
type = width
trigger1 = AnimElemtime(8) = 0
value = 25, 0
ignorehitpause = 1

[State 0, var]
type = varset
triggerall = !var(15)
trigger1 = !time
var(19) = IfElse((Command = "Shoryureppay" && Power >= 2000) || (Command = "Shoryureppaz" && (Power >= 2000 && Power < 3000)), 1, IfElse(Command = "Shoryureppaz" && Power >= 3000,2,0))

[State 0, varset]
type = varset
triggerall = var(15)
trigger1 = !time
var(19) = 0

[State 0, power]
type = poweradd
trigger1 = !time
value = ifelse(!var(19), -1000, ifelse(var(19) = 1, -2000, -3000))

[State 0, AfterImage]
type = AfterImage
trigger1 = AnimElem = 1
time = 999
TimeGap = 3
FrameGap = 4
length = 10
PalBright = 1,1,1
PalContrast = ifElse(!Var(19), 128, ifElse(Var(19) = 1, 50, 150)),ifElse(!Var(19), 128, ifelse(Var(19) = 1, 50, 50)),ifElse(!Var(19), 128, ifElse(Var(19) = 1, 150, 50))
PalAdd = 0,0,0
PalMul = .5,.5,.5
trans = add1

[State 0, var]
type = varset
triggerall = var(15) > 0
trigger1 = !time
var(2) = 0

[State 0, die]
type = varset
triggerall = var(15) > 0
trigger1 = time = 5
var(15) = 0

[State 0, assert]
type = assertspecial
triggerall = Time = [5, 45]
trigger1 = (EnemyNear, StateNo != [120,155])
flag = unguardable
ignorehitpause = 1

[State 0, Super]
type = superpause
trigger1 = time = 5
time = 41
movetime = 41
p2defmul = 1
unhittable = 1
anim = -1
sound = S8000, ifelse(var(19) = 2, 1,0)
darken = 0

[State 0, nhb]
type = nothitby
trigger1 = AnimElemtime(12) < 0
value = SCA

[State 0, FX]
type = helper
trigger1 = time = 5
helpertype = normal
stateno = 8500+(10*var(19))
ID = 8500
name = "Superpause FX"
postype = p1
pos = ceil(61 * const(size.xscale)), ceil(-51 * const(size.yscale))
supermovetime = 255
size.xscale = 1
size.yscale = 1
ownpal = 1

[State 0, pos]
type = Posfreeze
trigger1 = AnimElemTime(12) < 0

[State 0, Vel]
type = VelSet
trigger1 = AnimElem = 12
x = -2;-1.5

[State 0, Vel]
type = VelSet
trigger1 = AnimElem = 12
y = -8-var(19)

[State 0, vel]
type = Veladd
trigger1 = AnimElemTime(12) > 0
y = .5

[State 0, snd]
type = playsnd
trigger1 = Animelem = 1
value = S3, 6
channel = 0

[State 0, snd]
type = playsnd
trigger1 = AnimElemTime(8) = 1
value = S1000, 5
channel = 0

[State 0, snd]
type = playsnd
trigger1= AnimElem = 8
value = S4, 0

[State 0, Hadouken]
type = helper
trigger1 = animelemtime(8) = 1
helpertype = normal
stateno = 30050
ID = 1000
name = "Hadouken"
postype = p1
pos = 77, -58
size.xscale = 1
size.yscale = 1
ownpal = 1

[State 0, end]
type = ChangeState
trigger1 = pos y >= 0 && vel y > 0
value = 52
ctrl = 1

;Fall and land
[Statedef 3101]
type = S
movetype = A
physics = N
velset = 0,0
ctrl = 0
anim = 1305

[State 0, pos]
type = posset
trigger1 = time = 0
y = 0

[State 0, Dust]
type = explod
trigger1 = !time
vel = 0, 0
anim = 10055
sprpriority = 0
postype = p1
pos = 0, 0
ownpal = 1
scale = 0.5, 0.5
pausemovetime = -1
supermovetime = -1

[State 0, snd]
type = playsnd
trigger1 = !time
value = S47, 0

[State 0, end]
type = Changestate
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;SGS
[Statedef 3300]
type = S
physics = N;S
movetype = A
anim = 4000
ctrl = 0
velset = 0, 0
facep2 = 1
poweradd = -3000
sprpriority = 1

[State 0, AfterImage]
type = AfterImage
trigger1 = AnimElem = 1
time = 999
TimeGap = 3
FrameGap = 4
length = 10
PalBright = 1,1,1
PalContrast = 150, 50, 50
PalAdd = 0,0,0
PalMul = .5,.5,.5
trans = add1

[State 0, Super]
type = superpause
trigger1 = time = 5
time = 40;60
movetime = 40
p2defmul = 1
unhittable = 1
anim = -1
sound = S8000, 1
darken = 0

[State 0, FX]
type = helper
trigger1 = time = 5
helpertype = normal
stateno = 8520
ID = 8500
name = "Superpause FX"
postype = p1
pos = ceil(5 * const(size.xscale)), ceil(-100 * const(size.yscale))
supermovetime = 255
size.xscale = 1
size.yscale = 1
ownpal = 1

[State 0, Strength]
type = varset
trigger1 = var(10) != 7
var(10) = 7

[State 0, Snd]
type = playsnd
trigger1 = !time
value = 4, 13
channel = 0

[State 0, NHB]
type = nothitby
trigger1 = time < 10
time = 1
value = SCA

[State 0, Vel]
type = velset
trigger1 = AnimElem = 2
x = 8

[State 0, Snd]
type = playsnd
trigger1 = animelemtime(1) > 1
value = 5, 6
persistent = 0

[State 0, Miss]
type = hitdef
trigger1 = time
attr = S, HT
hitflag = 

[State 0, Hit]
type = hitdef
triggerall = !var(4) && var(2) < 1
trigger1 = !var(38)
trigger1 = time
trigger1 = p2dist x >= 0 && p2bodydist x <= 20
attr = S, HT
hitflag = M-
priority = 6, Miss
numhits = 0
sparkno = -1
p1facing = 1
p1stateno = 4001
fall = 1 
fall.recover = 0

[State 0, End]
type = changestate
trigger1 = !animtime
value = 0
ctrl = 1

;--- PLAYER ---
[Statedef 4001]
type = S
physics = N
movetype = A
anim = 4001
ctrl = 0
velset = 0, 0

[State 0, throw]
type = targetstate
trigger1 = !time
value = 1114002
[State 0, throw]
type = targetfacing
trigger1 = !time
value = -1

[State 0, Snd]
type = playsnd
trigger1 = !time
value = 4, 10
channel = 0
[State 0, snd]
type = playsnd
trigger1 = !time
value = 0, 800
[State 0, Snd]
type = playsnd
trigger1 = !time
value = 5, 8

[State 0, vsothers]
type = varset
trigger1 = !time
var(30) = 345

[State 0, Recover]
type = varadd
triggerall = animelemtime(2) > 0 && animelemtime(3) < 0
triggerall = (var(30) = [1, 99]) && numtarget
triggerall = target, life >= 0.33 * (target, lifemax)
trigger1 = (target, command = "x") || (target, command = "y") || (target, command = "z")
trigger2 = (target, command = "a") || (target, command = "b") || (target, command = "c")
trigger3 = (target, command = "up") || (target, command = "down") || (target, command = "back") || (target, command = "fwd")
var(30) = -1

[State 0, preventrecover]
type = varadd
triggerall = animelemtime(2) > 0 && animelemtime(3) < 0
triggerall = (var(30) = [1, 98]) && numtarget
trigger1 = command = "x" || command = "y" || command = "z"
trigger2 = command = "a" || command = "b" || command = "c"
trigger3 = command = "up" || command = "down" || command = "back" || command = "fwd"
var(30) = 1

[State 0, Debug]
type = displaytoclipboard
trigger1 = var(30) < 100
text = " %d button presses to recover"
params = var(30)
[State 0, Debug]
type = displaytoclipboard
trigger1 = var(30) = 345
text = "Normal Damage"
[State 0, Debug]
type = displaytoclipboard
trigger1 = var(30) = 456
text = "Extra Damage"

[State 0, Pause]
type = pause
trigger1 = animelemtime(2) >= 0 && animelemtime(3) < 0
time = 2
movetime = 2

[State 0, Push]
type = playerpush
trigger1 = 1
value = 0

[State 0, nhb]
type = nothitby
trigger1 = animelemtime(3) < 0
value = SCA
time = 1

[State 0, off]
type = afterimagetime
trigger1 = animelemtime(2) > 0
time = 0

;[State 0, fadeout]
;type = allpalfx
;trigger1 = animelemtime(1) = 10
;time = 30
;sinadd = -255, -255, -255, 120

;[State 0, black]
;type = envcolor
;trigger1 = animelemtime(2) >= 0 && animelemtime(35) < 0
;time = 4
;value = 0, 0, 0

[State 0, Assert]
type = AssertSpecial
trigger1 = Time = [24,144]
trigger2 = (AnimElemtime(3) > 0 && AnimElemtime(4) < 0) && win
flag = NoBG
flag2 = NoFG
flag3 = timerfreeze

[State 0, Flames]
type = Explod
trigger1 = Win
anim = 3320
id = 3310
pos = -24,-40
postype = Left
sprpriority = -4
bindtime = -1
ownpal = 1
ignorehitpause = 1
persistent = 0
scale = 1.44,1.44

[State 0, spr]
type = sprpriority
trigger1 = animelemtime(3) >= 0
value = 1

[State 0, Bind]
type = targetbind
trigger1 = animelemtime(3) < 0
pos = 45, 0

[State 0, hit]
type = hitadd
;triggerall = var(30) > 0
trigger1 = Time = 32 || Time = 35 || Time = 47 || Time = 77 || Time = 83 || Time = 89 || Time = 145
trigger2 = (Time = [48,65]) && Time % 6 = 5
trigger3 = (Time = [92,113]) && Time % 3 = 2
trigger4 = (Time = [115,143]) && Time % 2 = 1
;trigger1 = animelem = 2 || animelem = 3 || animelem = 4 || animelem = 5 || animelem = 6 || animelem = 7 || animelem = 8 || animelem = 9
;trigger2 = animelem = 10 || animelem = 11 || animelem = 12 || animelem = 13 || animelem = 14 || animelem = 15
;trigger3 = animelem = 16 || animelem = 17 || animelem = 18 || animelem = 19 || animelem = 20 || animelem = 21 || animelem = 22 || animelem = 23 || animelem = 24 || animelem = 25
;trigger4 = animelem = 26 || animelem = 27 || animelem = 28 || animelem = 29 || animelem = 30 || animelem = 31 || animelem = 32 || animelem = 33 || animelem = 34
value = 1

[State 0, ow]
type = targetlifeadd
trigger1 = Time = 32 || Time = 35 || Time = 47 || Time = 77 || Time = 83 || Time = 89 || Time = 145
trigger2 = (Time = [48,65]) && Time % 6 = 5
trigger3 = (Time = [92,113]) && Time % 3 = 2
trigger4 = (Time = [115,143]) && Time % 2 = 1

;triggerall = numtarget
;trigger1 = animelem = 2 || animelem = 3 || animelem = 4 || animelem = 5 || animelem = 6 || animelem = 7 || animelem = 8 || animelem = 9 || animelem = 10
;trigger2 = animelem = 10 || animelem = 11 || animelem = 12 || animelem = 13 || animelem = 14 || animelem = 15 || animelem = 16 || animelem = 17
;trigger3 = animelem = 18 || animelem = 19 || animelem = 20 || animelem = 21 || animelem = 22 || animelem = 23 || animelem = 24 || animelem = 25 || animelem = 26
;trigger4 = animelem = 27 || animelem = 28 || animelem = 29 || animelem = 30 || animelem = 31 || animelem = 32 || animelem = 33 || animelem = 34
value = -17 -(var(30) = 456) * 4 + (!var(30)) * 12
;-ceil(ifelse((var(30) = 456), (target, lifemax * 0.8), (target, lifemax * 0.6)) / 33)
kill = animelem = 3
absolute = 1

[State 0, power]
type = targetpoweradd
trigger1 = Time = 32 || Time = 35 || Time = 47 || Time = 77 || Time = 83 || Time = 89 || Time = 145
trigger2 = (Time = [48,65]) && Time % 6 = 5
trigger3 = (Time = [92,113]) && Time % 3 = 2
trigger4 = (Time = [115,143]) && Time % 2 = 1
value = 35

[State 0, Snd]
type = playsnd
trigger1 = Time = 32 || Time = 35 || Time = 47 || Time = 77 || Time = 83 || Time = 89 || Time = 145
trigger2 = (Time = [48,65]) && Time % 6 = 5
trigger3 = (Time = [92,113]) && Time % 3 = 2
trigger4 = (Time = [115,143]) && Time % 2 = 1
value = ifelse(!var(30), 6, 2), ifelse(!var(30), 0, ifelse((animelem = 34), 10, 2))
channel = 2

[State 0, Spark]
type = Helper
trigger1 = Time = 32 || Time = 35 || Time = 47 || Time = 77 || Time = 83 || Time = 89 || Time = 145
trigger2 = (Time = [48,65]) && Time % 6 = 5
trigger3 = (Time = [92,113]) && Time % 3 = 2
trigger4 = (Time = [115,143]) && Time % 2 = 1
helperType = Normal
stateNo = 8015
ID = 8000
name = "Spark"
posType = P1
sprpriority = 5
postype = p2
pos = 0+random%120, 0-random%120;120(ifelse(random < 500, -1, 1) * (target, const(size.mid.pos.y))+random%100);-70
facing = -1
ownpal = 1
pauseMoveTime = 65535
superMoveTime = 65535
ignoreHitPause = 1

[State 0, Shake]
type = envshake
trigger1 = Time = 32 || Time = 35 || Time = 47 || Time = 77 || Time = 83 || Time = 89 || Time = 145
trigger2 = (Time = [48,65]) && Time % 6 = 5
trigger3 = (Time = [92,113]) && Time % 3 = 2
trigger4 = (Time = [115,143]) && Time % 2 = 1
time = 6
freq = 120
ampl = -4

[State 0, Kanji]
type = explod
trigger1 = animelem = 3
anim = 6013
ID = 6013
sprpriority = 2
postype = p1
facing = ifelse(facing = 1, 1, -1)
pos = ifelse(facing = 1, 0, 32)
bindtime = -1
removeongethit = 1
ownpal = 1

[State 0, Snd]
type = playsnd
trigger1 = animelemtime(3) = 10
value = 4, 9
channel = 0

[State 0, throw]
type = targetstate
trigger1 = animelemtime(3) >= 0 && numtarget ;34
value = 1114003
persistent = 0

[State 0, interrupt]
type = changestate
triggerall = animelemtime(2) > 0 && animelemtime(3) < 0
trigger1 = !var(30) && numtarget
trigger2 = target, stateno = 1114010
value = 4009

[State 0, var]
type = varset
trigger1 = winko
var(41) = 1

[State 0, End]
type = changestate
trigger1 = animelemtime(3) >= 0 && winko
value = 185

[State 0, End]
type = changestate
trigger1 = !animtime
value = 0
ctrl = 1

;--- TARGET ---
[Statedef 1114002]
type = S
physics = N
movetype = H
velset = 0, 0
ctrl = 0
sprpriority = -2

[State 0, Anim]
type = changeanim2
trigger1 = !time
value = 4002

[Statedef 1114003]
type = L
physics = C
movetype = H
velset = 0, 0
ctrl = 0
sprpriority = -2

[State 0, Anim]
type = changeanim2
trigger1 = !time
value = 4003

[State 0, End]
type = selfstate
trigger1 = !alive
value = 5150

[State 0, End]
type = selfstate
trigger1 = time >= 97 && alive
value = 5120

;--- PLAYER ---
[Statedef 4009]
type = S
physics = S
movetype = H
anim = 5910
velset = -5, 0
ctrl = 0
sprpriority = -2

[State 0, target]
type = targetstate
trigger1 = !time && numtarget
value = 1114010

[State 0, imageoff]
type = afterimagetime
trigger1 = 1
time = 0

[State 0, Snd]
type = playsnd
trigger1 = !time
value = 5000, 4
channel = 0

[State 0, Anim]
type = changeanim
trigger1 = anim = 5910 && time = 45
value = 5911

[State 0, Flash]
type = palfx
trigger1 = !time
add = 30, 30, 100
sinadd = 30, 30, 100, 8
time = 8

[State 0, Snd]
type = playsnd
trigger1 = !time
value = 7, 1

[State 0, lightning]
type = helper
trigger1 = !time
helpertype = normal
stateno = 4012
ID = 4012
postype = p1
pos = 0, -60
ownpal = 1
persistent = 0
pausemovetime = 99
supermovetime = 99

[State 0, End]
type = changestate
trigger1 = anim = 5911 && !animtime
value = 0
ctrl = 1

;--- PLAYER ---
[Statedef 1114010]
type = S
physics = S
movetype = H
anim = 0
velset = -5, 0
ctrl = 0

[State 0, Anim]
type = changeanim
trigger1 = !time && selfanimexist(150)
value = 150

[State 0, Anim]
type = changeanim
trigger1 = anim = 150 && selfanimexist(140) && time >= 45
value = 140

[State 0, Flash]
type = palfx
trigger1 = !time
add = 30, 30, 100
sinadd = 30, 30, 100, 8
time = 8

[State 0, End]
type = selfstate
trigger1 = anim = 140 && !animtime
trigger2 = anim = 0 && time >= 54
value = 0
ctrl = 1

;Misogi
[Statedef 3400]
type = S
physics = S
movetype = A
anim = 4100
ctrl = 0
velset = 0, 0
facep2 = 1
poweradd = -3000
sprpriority = 1

[State 0, AfterImage]
type = AfterImage
trigger1 = AnimElem = 1
time = 999
TimeGap = 3
FrameGap = 4
length = 10
PalBright = 1,1,1
PalContrast = 150, 50, 50
PalAdd = 0,0,0
PalMul = .5,.5,.5
trans = add1

[State 0, Super]
type = superpause
triggerall = anim = 4100
trigger1 = AnimElem = 3
time = 40;60
movetime = 40
p2defmul = 1
unhittable = 1
anim = -1
sound = S8000, 1
darken = 0

[State 0, FX]
type = helper
triggerall = anim = 4100
trigger1 = AnimElem = 3
helpertype = normal
stateno = 8520
ID = 8500
name = "Superpause FX"
postype = p1
pos = ceil(-5 * const(size.xscale)), ceil(-45 * const(size.yscale))
supermovetime = 255
size.xscale = 1
size.yscale = 1
ownpal = 1

[State 0, Strength]
type = varset
trigger1 = var(10) != 7
var(10) = 7

[State 0, Strength]
type = varset
trigger1 = var(10) != 7
var(10) = 7

[State 0, Snd]
type = playsnd
trigger1 = !time
value = 4, 3
channel = 0

[State Corner Push]
type = varset
trigger1 = anim = 4100 && animelem = 3
fvar(5) = 0

[State 0, NHB]
type = nothitby
trigger1 = anim = 4100
time = 1
value = SCA

[State 0, Anim]
type = changeanim
trigger1 = anim = 4100 && time = 46;63
value = 4101
[State 0, statetype]
type = statetypeset
trigger1 = anim != 4101
statetype = S
physics = S
[State 0, statetype]
type = statetypeset
trigger1 = anim = 4101
statetype = A
physics = N

[State 0, Push]
type = playerpush
trigger1 = anim != 4100 && anim != 4103
value = 0
ignorehitpause = 1
[State 0, sprpriority]
type = sprpriority
trigger1 = anim != 4100
value = -1
ignorehitpause = 1

[State 0, illusions]
type = helper
trigger1 = anim = 4100 && time = 61
helpertype = normal
stateno = 4104
ID = 4104
name = "Misogi Illusion"
postype = p1
ownpal = 1
persistent = 0
pausemovetime = 999
supermovetime = 999

[State 0, Pos]
type = posadd
trigger1 = anim = 4101 && animelem = 1
x = p2dist x -10
y = p2dist y -240
[State 0, Snd]
type = playsnd
trigger1 = anim = 4101 && animelem = 1
value = 5, 9
persistent = 0

[State 0, Vel]
type = velset
trigger1 = anim = 4101 && animelemtime(2) < 0
x = 0
y = 0

[State 0, Vel]
type = velset
trigger1 = anim = 4101 && animelem = 2
y = 20
[State 0, Accel]
type = gravity
trigger1 = anim = 4101 && animelemtime(2) > 0

[State 0, Anim]
type = changeanim
trigger1 = anim = 4101 && animelemtime(2) > 3 && p2dist y < (enemynear, const(size.height) + 20)
trigger2 = anim = 4101 && animelemtime(1) > 0 && pos y > -30
value = 4101
elem = 3
persistent = 0

[State 0, Snd]
type = playsnd
trigger1 = anim = 4101 && animelemtime(2) > 3 && p2dist y < (enemynear, const(size.height) + 20)
trigger2 = anim = 4101 && animelemtime(1) > 0 && pos y > -30
value = 4, 11
channel = 0
persistent = 0

[State 0, Hit]
type = hitdef
triggerall = !var(4) && var(2) < 1
trigger1 = anim = 4101 && animelem = 3
attr = A, HA
damage = ceil(ifelse(fvar(11) * 560 < 7, 7, fvar(11) * 560)), 70
animtype = Hard 
guardflag = M
hitflag = MAF
priority = 7, Hit
pausetime = 0, 0
guard.pausetime = 0, 30
hitsound = s90, 0 
guardsound = s6, 0
ground.type = High
air.type = High
ground.slidetime = 16
ground.hittime = 16
ground.velocity = -2, 0
guard.velocity = -10
air.velocity = 0, 20
ground.cornerpush.veloff = 0
guard.velocity = -10.52
guard.cornerpush.veloff = 0;-12.74
getpower = 0
givepower = 35, 35
envshake.time = 18
envshake.freq = 120
envshake.ampl = 6
fall = 1
fall.recover = 0
sprpriority = -1
ID = 4100
airguard.ctrltime = 16
airguard.velocity = -8, -1.5
forcestand = 1
fall.envshake.time = 0
fall.envshake.freq = 0.0
fall.envshake.ampl = 0
fall.envshake.phase = 0.0
sparkno = S-1 + 0 * (var(33) := 8015)
guard.sparkno = S-1 + 0 * (var(34) := 8001)
sparkxy = -10 + 0 * (var(35) := 58), var(36) := -32

[State 0, p2state]
type = targetstate
trigger1 = movehit && numtarget(4100)
trigger1 = (target(4100), stateno = 5000) || (target(4100), stateno = 5010)
value = 1114100
ID = 4100
ignorehitpause = 1
[State 0, p2state]
type = targetstate
trigger1 = movehit && numtarget(4100)
trigger1 = (target(4100), stateno = 5020)
value = 1114110
ID = 4100
ignorehitpause = 1

[State 0, Anim]
type = changeanim
trigger1 = anim = 4101 && pos y >= -5
value = ifelse(movehit, 4102, 4103)
[State 0, Stop]
type = posset
trigger1 = anim = [4102, 4103]
y = 0
[State 0, Stop]
type = velset
trigger1 = anim = [4102, 4103]
y = 0

[State 0, Shake]
type = envshake
trigger1 = (anim = 4102 || anim = 4103) && animelem = 1
time = ifelse((anim = 4102), 30, 15)
time = 18
freq = 120
ampl = 12

[State 0, Snd]
type = playsnd
trigger1 = anim = 4102 && animelem = 1
value = 5, 7
[State 0, fire]
type = explod
trigger1 = anim = 4102 && animelem = 1
vel = 0, 0
anim = 4105
sprpriority = 4
postype = p1
pos = 0, 0
ownpal = 1

[State 0, Snd]
type = playsnd
trigger1 = anim = 4103 && animelem = 1
value = 5, 10

[State 0, fire]
type = explod
trigger1 = anim = 4103 && animelem = 1
vel = 0, 0
anim = 4106
sprpriority = 4
postype = p1
pos = 0, 0
ownpal = 1

[State 0, Dust]
type = explod
trigger1 = anim = 4102 && animelemtime(1) = 13
vel = 0, 0
anim = 7602
ID = 7602
sprpriority = 5
postype = p1
pos = 0, 0
ownpal = 1
scale = 2, 2

[State Idle]
type = statetypeset
trigger1 = anim = 4102 || anim = 4103
movetype = I

[State 0, End]
type = changestate
trigger1 = anim = 4102 && animelemtime(17) >= 0 && winko
value = 186
persistent = 0
[State 0, End]
type = changestate
trigger1 = (anim = [4102, 4103]) && !animtime
value = 0
ctrl = 1

;--- TARGET STANDING ---
[Statedef 1114100]
type = S
physics = S
movetype = H
ctrl = 0
velset = gethitvar(xvel), 0
sprpriority = 1

[State 0, NHB]
type = nothitby
trigger1 = 1
time = 1
value = SCA

[State 0, Anim]
type = changeanim
trigger1 = !time && selfanimexist(5950)
value = 5950
[State 0, Anim]
type = changeanim2
trigger1 = !time && !selfanimexist(5950)
value = 1114100

[State 0, Stop]
type = posset
trigger1 = 1
y = 0
[State 0, Stop]
type = velset
trigger1 = 1
y = 0
[State 0, dust]
type = gamemakeanim
trigger1 = anim = 1114100 && animelem = 7
value = 60
pos = 0, 0
under = sysvar(1) <= 14
[State 0, snd]
type = playsnd
trigger1 = anim = 1114100 && animelem = 7
value = f7, 0

[State 0, Anim]
type = changeanim
trigger1 = time >= 110 && selfanimexist(5111)
value = 5111
[State 0, End]
type = selfstate
trigger1 = time >= 110
value = ifelse(alive, 5120, 5150)

;--- TARGET MID -AIR ---
[Statedef 1114110]
type = A
physics = N
movetype = H
ctrl = 0
velset = gethitvar(xvel), gethitvar(yvel)
sprpriority = 1

[State 0, NHB]
type = nothitby
trigger1 = 1
time = 1
value = SCA

[State 0, Anim]
type = changeanim2
trigger1 = !time
value = 1114110

[State 0, Accel]
type = gravity
trigger1 = animelemtime(5) < 0

[State 0, Stop]
type = posset
trigger1 = pos y >= 0
y = 0

[State 0, Stop]
type = velset
trigger1 = pos y >= 0
y = 0

[State 0, sts]
type = statetypeset
trigger1 = pos y >= 0
type = L
physics = C

[State 0, Anim]
type = changeanim2
trigger1 = pos y >= 0
value = 1114110
elem = 5
persistent = 0

[State 0, dust]
type = gamemakeanim
trigger1 = animelem = 5
value = 62
pos = 0, 0
under = sysvar(1) <= 14

[State 0, snd]
type = playsnd
trigger1 = animelem = 5
value = f7, 2

[State 0, End]
type = selfstate
trigger1 = animelemtime(7) >= 110
value = ifelse(alive, 5120, 5150)

[Statedef 2750]
movetype = H
physics = S
ctrl = 0
velset = 0,0
anim = 5030

[State 0, anim]
type = changeanim
triggerall = anim != 5950 && anim != 4003 ;&& anim != 5110
trigger1 = selfanimexist(5950)
value = 5950

[State 0, anim2]
type = changeanim2
trigger1 = anim = 5950 && !Animtime && anim != 4003 ;&& anim != 5110
value = 4003

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

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

[State 0, Change]
type = selfState
trigger1 = (Anim = 4003 && !animtime) || !alive || time > 110
value = ifelse(alive, 5120, 5100)