; _________________________________________
;|  Pheromosa by Vorse_Raidier                |
; ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
;==============================================================================================
;=======================================<SYSTEM STATES>========================================
;==============================================================================================

;note to self 
;var(20) = custom combo (not used, may %$%^^ matters)
;ivar(15) = juggle count
;var(13) = hitcount reset
;---------------------- Integer variable list ----------------------
;---------------------- Integer variable list ----------------------

;---------------------- Integer variable list ----------------------

; var(0):= 765 - PARRY HELPER, 766 - PARRY SUCCESS, 8150 - FLAMES, 8600 - SUPER FINISH, 952 - Air Dash Smoke, 953 - beam outline, 40000 - System Helper, 33333333 - [Info], 35501 - attack reflect helper
; var(1):= 945 - Air Jump, 40000 - System Helper
; var(2):= 40000 - System Helper
; var(3):= 40 - JUMPING, 40000 - System Helper, 33333333 - [Info]
; var(4):= -3, 40000 - System Helper
; var(5):= -3
; var(6):= -3, 14250 - poipole arrives, 14253 - poipole leaves
; var(7):= -3
; var(8):= -3
; var(9):= -2, -3, 4900 - superarmor helper
;var(10):= 22222 - Catch 22, 900 - normal toss attempt, 911, normal toss (throw success), 810, CUF Main (throw success), 1050 - Special 1, 1075 - EX Special 1, 13008 - dizzy mark 1, 3000, 3050 - MAX Super 1, 35499 - reflect guide, 37499 - Tornado guide block
;var(11):= 490 - CROUCHING Medium Kick 2%, 640 - Jump Medium Kick%, 650 - Jump Heavy kick%, 1800 - low sweep, 1625 - Double Kick
;var(12):= -3, 212 - Standing slash hard
;var(13):= -2, 1010 - Throw
;var(14):= -2, 425 - Crouching Strong Punch%, 1900 - lunge
;var(15):= -2, 1010 - Throw, 1075 - EX Special 1, 3000, 3050 - MAX Super 1, 3500 - LVL 3 Super, 35501 - attack reflect helper
;var(16):= -2
;var(17):= 905 - CUSTOM COMBO AIR, -2, 3000, 3050 - MAX Super 1, 3500 - LVL 3 Super
;var(18):= -3
;var(19):= 771 - Quick Guard air, -3, 900 - normal toss attempt
;var(20):= 905 - CUSTOM COMBO AIR, -2, 1075 - EX Special 1, 3000, 3050 - MAX Super 1, 3500 - LVL 3 Super
;var(21):= -3, 22503 - drop movehit nil, 22777 - shocker caller, 3000, 3050 - MAX Super 1, 3500 - LVL 3 Super
;var(22):= -3, 22503 - drop movehit nil, 22777 - shocker caller, 3000, 3050 - MAX Super 1, 3500 - LVL 3 Super
;var(23):= -3
;var(25):= -3, 7700 - helper PowerGauge, 250 - Standing Strong Kick%, 2261 - Overpowering kick attempt ex, 1010 - Throw, 1075 - EX Special 1, 1725 - Drill ex Kick, 17800 - air drill run down
;var(26):= 760 - PARRY STANDING, 761 - PARRY CROUCHING, -3, 7700 - helper PowerGauge
;var(27):= -2, 7700 - helper PowerGauge
;var(28):= 700 - aglity, 7700 - helper PowerGauge, -1 - Don't remove the following line. It's required by the CMD standard.
;var(30):= -2
;var(31):= 211 - Standing slash light%, 212 - Standing slash hard, 241 - Standing Medium Kick combo 1%, 243 - Standing Medium Kick 3%, 440 - Crouching med Kick%, 900 - normal toss attempt, 1050 - Special 1
;var(32):= 211 - Standing slash light%, 212 - Standing slash hard, 241 - Standing Medium Kick combo 1%, 243 - Standing Medium Kick 3%, 440 - Crouching med Kick%, 900 - normal toss attempt, 1050 - Special 1
;var(33):= 200 - Standing Light Punch%, 201 - Standing Light Punch 2, 202 - Standing Light Punch 3, 211 - Standing slash light%, 212 - Standing slash hard, 230 - Standing Light Kick%, 235 - Standing Medium Kick, 241 - Standing Medium Kick combo 1%, 242 - Standing Medium Kick 2%, 243 - Standing Medium Kick 3%, 251 - Standing alt Strong Kick, 480 - launcher kick, 425 - Crouching Strong Punch%, 430 - Crouching Light Kick%, 440 - Crouching med Kick%, 490 - CROUCHING Medium Kick 2%, 491 - CROUCHING Medium Kick 2%, 600 - Jump Light rapid kick, 620 - Jump knockdown, 621 - Jump Strong Punch% landing, 640 - Jump Medium Kick%, 650 - Jump Heavy kick%, 900 - normal toss attempt, 910, normal toss fwd, 810, CUF Main (throw success), 1625 - Double Kick, 1050 - Special 1, 1200 - High Kick, 1225 - High dbl Kick, 1725 - Drill ex Kick, 2100 - Luxurious Kick, 2106 - Lux landed, 2900 - PUNCH ZERO COUNTER, 2901 - PUNCH ZERO COUNTER, 21000 - Luxurious Kick to tri axel, 21060 - Lux landed, 18052 - Lux landed, 18053 - spin to win
;var(34):= 200 - Standing Light Punch%, 201 - Standing Light Punch 2, 202 - Standing Light Punch 3, 211 - Standing slash light%, 212 - Standing slash hard, 230 - Standing Light Kick%, 235 - Standing Medium Kick, 241 - Standing Medium Kick combo 1%, 242 - Standing Medium Kick 2%, 243 - Standing Medium Kick 3%, 251 - Standing alt Strong Kick, 480 - launcher kick, 425 - Crouching Strong Punch%, 430 - Crouching Light Kick%, 440 - Crouching med Kick%, 490 - CROUCHING Medium Kick 2%, 491 - CROUCHING Medium Kick 2%, 600 - Jump Light rapid kick, 620 - Jump knockdown, 621 - Jump Strong Punch% landing, 640 - Jump Medium Kick%, 650 - Jump Heavy kick%, 900 - normal toss attempt, 1900 - lunge, 1625 - Double Kick, 1050 - Special 1, 1200 - High Kick, 1225 - High dbl Kick, 1725 - Drill ex Kick, 2100 - Luxurious Kick, 2900 - PUNCH ZERO COUNTER, 2901 - PUNCH ZERO COUNTER, 21000 - Luxurious Kick to tri axel
;var(35):= 200 - Standing Light Punch%, 201 - Standing Light Punch 2, 202 - Standing Light Punch 3, 211 - Standing slash light%, 212 - Standing slash hard, 220 - Bug Buzz, 230 - Standing Light Kick%, 235 - Standing Medium Kick, 241 - Standing Medium Kick combo 1%, 242 - Standing Medium Kick 2%, 243 - Standing Medium Kick 3%, 251 - Standing alt Strong Kick, 480 - launcher kick, 425 - Crouching Strong Punch%, 430 - Crouching Light Kick%, 440 - Crouching med Kick%, 490 - CROUCHING Medium Kick 2%, 491 - CROUCHING Medium Kick 2%, 600 - Jump Light rapid kick, 620 - Jump knockdown, 621 - Jump Strong Punch% landing, 640 - Jump Medium Kick%, 650 - Jump Heavy kick%, 900 - normal toss attempt, 1900 - lunge, 1625 - Double Kick, 1050 - Special 1, 1200 - High Kick, 1225 - High dbl Kick, 1725 - Drill ex Kick, 2100 - Luxurious Kick, 2900 - PUNCH ZERO COUNTER, 2901 - PUNCH ZERO COUNTER, 21000 - Luxurious Kick to tri axel
;var(36):= 200 - Standing Light Punch%, 201 - Standing Light Punch 2, 202 - Standing Light Punch 3, 211 - Standing slash light%, 212 - Standing slash hard, 220 - Bug Buzz, 230 - Standing Light Kick%, 235 - Standing Medium Kick, 241 - Standing Medium Kick combo 1%, 242 - Standing Medium Kick 2%, 243 - Standing Medium Kick 3%, 251 - Standing alt Strong Kick, 480 - launcher kick, 425 - Crouching Strong Punch%, 430 - Crouching Light Kick%, 440 - Crouching med Kick%, 490 - CROUCHING Medium Kick 2%, 491 - CROUCHING Medium Kick 2%, 600 - Jump Light rapid kick, 620 - Jump knockdown, 621 - Jump Strong Punch% landing, 640 - Jump Medium Kick%, 650 - Jump Heavy kick%, 900 - normal toss attempt, 1900 - lunge, 1625 - Double Kick, 1050 - Special 1, 1200 - High Kick, 1225 - High dbl Kick, 1725 - Drill ex Kick, 2100 - Luxurious Kick, 2900 - PUNCH ZERO COUNTER, 2901 - PUNCH ZERO COUNTER, 21000 - Luxurious Kick to tri axel
;var(38):= -2
;var(39):= -2, -3
;var(40):= -2, 22222 - Catch 22
;var(43):= -2
;var(44):= -3, 220 - Bug Buzz, 2900 - PUNCH ZERO COUNTER, 2901 - PUNCH ZERO COUNTER
;var(47):= -3, 4900 - superarmor helper, 7050 - Subsitute helper, 7051 - Subsitute helper take damage
;var(53):= -2, 1075 - EX Special 1
;var(54):= 5900 - Initialize Start Round
;var(58):= -3

;---------------------- Float variable list ----------------------

; fvar(2):= -3
; fvar(5):= 905 - CUSTOM COMBO AIR, -3, 3000, 3050 - MAX Super 1, 3500 - LVL 3 Super
; fvar(8):= -2
;fvar(10):= -2
;fvar(11):= -2













;---------------------------------------------------------------------------
;STANDING
[Statedef 0]
type = S
physics = S
movetype = I
velset = 0, 0
sprpriority = 0

[State 0, Remove Explods]
type = RemoveExplod
trigger1 = IsHelper

[State 0, Destroy Helpers]
type = DestroySelf
trigger1 = IsHelper

[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = Anim != 0 && Anim != 5
trigger2 = Anim = 5 && !AnimTime
value = 0

[State 0, Dead]
type = ChangeState
trigger1 = !Alive
value = 5050

;====================<CROUCHING>====================
;Stand to Crouch
[StateDef 10]
type = C
physics = C
moveType = I
velSet = 0,0
sprPriority = 0

[State 10, ChangeAnim]
type = ChangeAnim
trigger1 = !Time && Anim = 12
value = 10
elem = 3 - AnimElemNo(0)

[State 10, ChangeAnim]
type = ChangeAnim
trigger1 = Anim != 10
value = 10

[State 10, End]
type = ChangeState
trigger1 = !AnimTime
value = 11


;Crouching
[StateDef 11]
type = C
physics = C
moveType = I
anim = 11
velSet = 0,0
sprPriority = 0

[State 11, ChangeAnim]
type = ChangeAnim
trigger1 = Anim = 6 && !AnimTime
value = 11


;Crouch to Stand
[StateDef 12]
type = S
physics = S
moveType = I
velSet = 0,0
sprPriority = 0

[State 12, ChangeAnim]
type = ChangeAnim
trigger1 = !Time && Anim = 10
value = 12
elem = 3 - AnimElemNo(0)

[State 12, ChangeAnim]
type = ChangeAnim
trigger1 = Anim != 12
value = 12

[State 12, End]
type = ChangeState
trigger1 = command = "holddown" && command != "holdup"
value = 10

[State 12, End]
type = ChangeState
trigger1 = !AnimTime
value = 0

;WALKING
[Statedef 20]
type = S
physics = S
movetype = I
sprpriority = 0

[State 20, Vel]
type = velset
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)

[State 20, Vel]
type = velset
trigger1 = command = "holdback"
x = const(velocity.walk.back.x)

[State 20, Anim]
type = changeanim
triggerall = vel x > 0
trigger1 = anim != 20 && anim != 5
trigger2 = anim = 5 && animelemtime(1) >= 1
value = 20

[State 20, Anim]
type = changeanim
triggerall = vel x < 0
trigger1 = anim != 21 && anim != 5
trigger2 = anim = 5 && animelemtime(1) >= 1
value = 21


;JUMPING
[Statedef 40]
type = S
physics = S
movetype = I
anim = 40
ctrl = 0
velset = 0, 0
sprpriority = 1
facep2 = 1

[State 40, Direction]
type = varset
trigger1 = !AIlevel
sysvar(1) = ifelse(!time, 0, ifelse(command = "holdfwd", 1, ifelse(command = "holdback", -1, sysvar(1))))
[State 40, Direction]
type = varset
trigger1 = AIlevel
sysvar(1) = ifelse((enemynear, movetype != A || backedgebodydist <= 10), 1, ifelse((enemynear, movetype = A), -1, 0))

[State 40, High Jump]
type = varset
trigger1 = !time && !AIlevel
var(3) = ifelse(command = "highjump", 3, 0)
[State 40, High Jump]
type = varset
trigger1 = !time && AIlevel
var(3) = ifelse((p2bodydist x >= 160 || random < (125 * (AIlevel ** 2 / 64.0))), 3, 0)
[State 40, High Jump]
type = varset
trigger1 = !time && prevstateno = 100
var(3) = 3

[State 40, Low Jump]
type = varset
trigger1 = !AIlevel && command != "holdup" && (var(3) != [1, 2])
var(3) = ifelse((var(3) = 3 && sysvar(1)), 2, 1)
[State 40, Low Jump]
type = varset
trigger1 = AIlevel && (var(3) != [1, 2])
trigger1 = (enemynear, statetype = C) && random < 500
var(3) = ifelse((var(3) = 3 && sysvar(1)), 2, 1)

[State 40, Snd]
type = playsnd
trigger1 = !animtime
value = ifElse((var(3) = [2,3]), 41, 40), 0

[State 40, Dust]
type = null;helper
trigger1 = !animtime
stateno = 8100
ID = 8100
name = "Jump Dust"
postype = p1
ownpal = 1


[State 8100, Dust]
type = explod
trigger1 = !time
anim = 8100
sprpriority = 3
postype = p1
pos = 0, ceil(pos y)
scale = 0.5, 0.5
pausemovetime = -1
supermovetime = -1
ownpal = 1

[State 8100, Dust]
type = explod
trigger1 = !time || time = 2 || time = 6
anim = 8101
sprpriority = 3
postype = p1
scale = 0.5, 0.5
pausemovetime = -1
supermovetime = -1
ownpal = 1



[State 40, Velocity: Normal Jump]
type = VelSet
trigger1 = !AnimTime
x = ifElse(!sysvar(1), const(velocity.jump.neu.x), ifElse(sysvar(1) = 1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, Velocity: Low Jump]
type = VelSet
trigger1 = !AnimTime && var(3) = 1
x = ifElse(!sysvar(1), const(velocity.jump.neu.x), ifElse(sysvar(1) = 1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = 0.75 * const(velocity.jump.y)

[State 40, Velocity: Long Low Jump]
type = VelSet
trigger1 = !AnimTime && var(3) = 2
x = ifElse(!sysvar(1), const(velocity.jump.neu.x), ifElse(sysvar(1) = 1, const(velocity.runjump.fwd.x), const(velocity.runjump.back.x)))
y = 0.75 * const(velocity.jump.y)

[State 40, Velocity: Long Jump]
type = VelSet
trigger1 = !AnimTime && var(3) = 3
x = ifElse(!sysvar(1), const(velocity.jump.neu.x), ifElse(sysvar(1) = 1, const(velocity.runjump.fwd.x), const(velocity.runjump.back.x)))
y = const(velocity.jump.y)
;ifElse(!sysvar(1), const(velocity.runjump.y), 






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

[Statedef 50]
type = A
physics = N
movetype = I
sprpriority = 1

[State 50, Anim]
type = changeanim
trigger1 = !time
value = ifelse(!vel x, 41, ifelse(vel x > 0, 42, 43)) + 10 * (var(3) = [1, 2])
persistent = 0

[State 50, No Guard]
type = assertspecial
trigger1 = var(3) = [1, 2]
flag = noairguard
ignoreHitPause = 1

[State 50, Grounded Frame]
type = posfreeze
trigger1 = time < 1 && prevstateno = 40
value = 1

[State 50, Accel]
type = gravity
trigger1 = time >= 1 || prevstateno != 40

[State 50, Land]
type = changestate
trigger1 = pos y > -vel y
value = 52


[Statedef 51]
type = A
physics = N
movetype = I
sprpriority = 1
[State 51, Accel]
type = gravity
trigger1 = 1
[State 51, Land]
type = changestate
trigger1 = pos y > -vel y
value = 52


[Statedef 52]
type = S
physics = S
movetype = I
anim = 47
ctrl = 0
velset = 0, 0
sprpriority = 1

[State 52, anim 57]
type = changeanim
trigger1 = !time && (var(3) = 1 || var(3) = 2)
trigger1 = (prevstateno = [600, 699])
value = 57

[State 52, Pos]
type = posset
trigger1 = 1
y = 0

[State 52, Ctrl]
type = ctrlset
trigger1 = !time && (prevstateno != [600, 699])
trigger2 = time = 1 && anim != 57
value = 1

[State 52, Guard]
type = changestate
trigger1 = ctrl && command = "holdback"
trigger1 = inguarddist && (prevstateno != [600, 699])
value = 120

[State 52, No walking]
type = assertspecial
trigger1 = anim != 5
flag = nowalk
ignoreHitPause = 1

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

[State 52, Dust]
type = explod
trigger1 = !time
anim = 8102
sprpriority = -3
postype = p1
scale = 0.5, 0.5
pausemovetime = -1
supermovetime = -1
ownpal = 1

[State 52, Turn]
type = changeanim
trigger1 = ctrl && p2dist x < 0
trigger1 = anim != 5
value = 5

[State 52, Turn]
type = turn
trigger1 = anim = 5 && animelem = 1

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


;RUN
[Statedef 100]
type = S
physics = N
movetype = I
anim = 100
ctrl = 0
sprpriority = 1

[State 100, Vel]
type = velset
trigger1 = 1
x = const(velocity.run.fwd.x)

[State 905, AfterImage]
type = afterimage
trigger1 = stateno = 100
trigger1 = abs(vel x) >= 0 && time%10 = 1;!animtime
time = 5
timegap = 5
framegap = 1
length = 3
palbright = 0, 0, 0
palcontrast = 64, 128, 192
palpostbright = 0, 0, 0
paladd = 0, 0, 0
palmul = 0.75, 0.75, 0.75
trans = add1

[state 950, Air Dash Smoke]
type = helper
trigger1 = !animelemtime(2)
trigger1 = VEL X >= 5
helpertype = normal
name = "Air Dash Smoke"
ID = 952
stateno = 952
postype = P1
ownpal = 1
keyctrl = 0
size.xscale = 1.0
size.yscale = 1.0
supermovetime = 65536
pausemovetime = 65536

[State 100, Step Sound]
type = PlaySnd
trigger1 = (AnimElem = 1 || AnimElem = 4)
trigger2 = (AnimElem = 6 || AnimElem = 8)

value = ifElse((AnimElem = 1 || AnimElem = 6), 41, 40),0

[State 100, Jump]
type = changestate
trigger1 = !AIlevel
trigger1 = command = "holdfwd" && command = "holdup"
value = 40

[State 100, Jump]
type = changestate
trigger1 = AIlevel && random < 25
value = 40

[State 100, End]
type = ChangeState
trigger1 = !AILevel && command != "holdfwd"
trigger2 = AILevel && P2BodyDist x <= 90
value = 101


;--- STOP ---
[Statedef 101]
type = S
physics = S
movetype = I
anim = 101
ctrl = 0
sprpriority = 1

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

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

[State 101, Jump]
type = changestate
trigger1 = !AIlevel && command = "holdup"
value = 40

[State 101, End]
type = changestate
trigger1 = !animtime
value = ifelse(command = "holddown", 10, 0)
ctrl = 1


[Statedef 102]
type = S
physics = N
movetype = I
anim = 102
ctrl = 0
sprpriority = 1

[State 102, Snd]
type = playsnd
trigger1 = !time
value = 110,0

[State 102, Dust]
type = helper
trigger1 = animelem = 2
stateno = 8103
ID = 8103
name = "Dash Dust"
postype = p1
pausemovetime = 9999
supermovetime = 9999
ownpal = 1

[State 102, Run]
type = varset
trigger1 = !time
sysvar(1) = 1

[State 102, Run]
type = varset
triggerall = AnimElemTime(2) <= 0
trigger1 = !AIlevel && command != "holdfwd"
sysvar(1) = 0

[State 102, Run]
type = changestate
trigger1 = AnimElemTime(2) = 0 && sysvar(1)
value = 100

[State 102, Type]
type = statetypeset
trigger1 = animelemtime(2) >= 0
statetype = A
physics = N

[State 105, 1]
type = VelSet
trigger1 = AnimElem = 2
x = 6.75
y = -4

[State 105, 1]
type = VelMul
trigger1 = AnimElemTime(2) > 0
x = .98

[State 105, 1]
type = VelAdd
trigger1 = AnimElemTime(2) > 0
y = 0.65

[State 102, End]
type = changestate
trigger1 = animelemtime(2) >= 0
trigger1 = pos y > -vel y
value = 103


;--- LAND ---
[Statedef 103]
type = S
physics = S
ctrl = 1
anim = 103
velset = 0, 0

[State 103, Pos]
type = posset
trigger1 = 1
y = 0

[State 103, Snd]
type = playsnd
trigger1 = !time
value = 100,0

[State 103, Dust]
type = explod
trigger1 = !time
anim = 8102
sprpriority = -3
postype = p1
scale = 0.5, 0.5
pausemovetime = -1
supermovetime = -1
ownpal = 1

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


[Statedef 105]
type = A
physics = N
movetype = I
velset = 0, 0
anim = 110 ;105
ctrl = 0
sprpriority = 1

[State 105, Snd]
type = playsnd
trigger1 = animelem = 2
value = 105,0


[State 905, AfterImage]
type = afterimage
trigger1 = stateno = 105
trigger1 = abs(vel x) >= 0 && time%10 = 1;!animtime
time = 5
timegap = 5
framegap = 1
length = 3
palbright = 0, 0, 0
palcontrast = 128, 128, 128
palpostbright = 0, 0, 0
paladd = 0, 0, 0
palmul = 0.9, 0.9, 0.9
trans = add1

[State 105, Dust]
type = helper
trigger1 = animelem = 2
stateno = 8103
ID = 8103
name = "Dash Dust"
postype = p1
facing = -1
pausemovetime = 255
supermovetime = 255
ownpal = 1

[State 105, Vel]
type = velset
trigger1 = animelem = 2
x = const(velocity.run.back.x)
y = const(velocity.run.back.y)

[State 105, 1]
type = VelMul
trigger1 = AnimElemTime(2) > 0
x = .98

[State 105, 1]
type = VelAdd
trigger1 = AnimElemTime(2) > 0
y = 0.75

[State 110, Type]
type = StateTypeSet
trigger1 = AnimElemTime(2) >= 0
stateType = A
physics = N

[State 105, Land]
type = changestate
trigger1 = animelemtime(2) >= 0
trigger1 = pos y > -vel y
value = 106


;--- LAND ---
[Statedef 106]
type = S
physics = S
ctrl = 0
anim = 106
velset = 0, 0

[State 106, Pos]
type = posset
trigger1 = 1
y = 0

[State 106, Snd]
type = playsnd
trigger1 = !time
value = 100,1

[State 106, Dust]
type = explod
trigger1 = !time
anim = 8102
sprpriority = -3
postype = p1
scale = 0.5, 0.5
pausemovetime = -1
supermovetime = -1
ownpal = 1

[State 106, Ctrl]
type = ctrlset
trigger1 = time >= 2
value = 1

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

;aglity
[Statedef 700]
type = U
physics = N
ctrl = 0
anim = 700
velset = 0,0
[state ]
type = nothitby
trigger1 = 1
value = SCA
time = 1
[state ]
type = playsnd
trigger1 = time = 0
value = s4000,12

[State ]
type = null
triggerall = animelemtime(1)=0
triggerall = var(59)=0
trigger1 = var(28):=0
trigger2 = command = "holdfwd"
trigger2 = var(28):=1
trigger2 = 0
trigger3 = command = "holdback"
trigger3 = var(28):=2
trigger3 = 0
trigger4 = command = "holddown"
trigger4 = var(28):=3
trigger4 = 0




[State ]
type = Explod
trigger1 = animelemtime(5)>=0
trigger1 = animelemtime(5)<3
anim = 711
id = 711
sprpriority = 0
postype = p1
pos = 0,0
vel = 15,0
bindtime = 1
supermove = 0
under = 0
ownpal = 0
scale = const(size.xscale),const(size.yscale)
[State  ]
type = Explod
trigger1 = animelemtime(5)>=0
trigger1 = animelemtime(5)<3
anim =712
id = 712
sprpriority = 0
postype = p1
pos = 0,0
vel = -15,0
bindtime = 1
supermove = 0
under = 0
ownpal = 0
scale = const(size.xscale),const(size.yscale)
[state ]
type = changestate
trigger1 = animtime = 0
value = 721

[Statedef 721]
type = U
physics = N
ctrl = 0
anim = 701
velset = 0,0
facep2 = 1

[State 0, Turn]
type = Turn
triggeraLL = enemynear,facing = facing
trigger1 = time = 1 


[state ]
type = playsnd
trigger1 = time = 0
value = s4000,12
[state ]
type = nothitby
trigger1 = 1
value = SCA
time = 1
[state ]
type = posadd
trigger1 = animelemtime(1)=0
trigger1 = var(28)=1
x = 320
[state ]
type = posadd
trigger1 = animelemtime(1)=0
trigger1 = var(28)=2
x = -320
[state ]
type = posset
trigger1 = animelemtime(1)=0
trigger1 = var(28)=3
y = 0
[state ]
type = statetypeset
trigger1 = animelemtime(1)=0
trigger1 = var(28)=3
statetype = S
[state ]
type = ctrlset
trigger1 = animelem=2
value = 1
[State ]
type = Explod
trigger1 = animelemtime(1)<=3
anim = 711
id = 2201
sprpriority = 0
postype = p1
pos = -72,0
vel = 9,0
bindtime = 1
supermove = 0
under = 0
ownpal = 0
scale = const(size.xscale),const(size.yscale)
[State ]
type = Explod
trigger1 = animelemtime(1)<=3
anim = 712
id = 2201
sprpriority = 0
postype = p1
pos = 72,0
vel = -9,0
bindtime = 1
supermove = 0
under = 0
ownpal = 0
scale = const(size.xscale),const(size.yscale)
[State ]
type = changeanim
trigger1 = animtime = 0
trigger1 = statetype = A
value = 41
elem=12
[state ]
type = changestate
trigger1 = animtime = 0
trigger2 = anim=41
value = (statetype = A)*51
ctrl = 1




;ROLL Forward 
[Statedef 710]
type = S
physics = N
movetype = I
anim = 710
ctrl = 0
velset = 0, 0
sprpriority = 1

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

[State 710, HB]
type = hitby
trigger1 = animelemtime(6) < 0
value = SCA, AT
time = 1

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

[State 710, Snd]
type = playsnd
trigger1 = !time
value = 110,0
channel = 1

[State 810, Velocity]
type = VelSet
trigger1 = animelem = 3
x = 4.25

[State 810, Velocity]
type = VelSet
trigger1 = animelem =4
x = 0

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


;ROLL Backward 
[Statedef 715]
type = S
physics = N
movetype = I
anim = 715
ctrl = 0
velset = 0, 0
sprpriority = 1

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


[State 715, HB]
type = hitby
trigger1 = animelemtime(6) < 0
value = SCA, AT
time = 1

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

[State 715, Snd]
type = playsnd
trigger1 = !time
value = 110,0
channel = 1


[State 0, StateTypeSet]
type = StateTypeSet
trigger1 = AnimElem <= 2
statetype = A       ;S,A,C,L
movetype = I        ;I,A,H
physics = a         ;A,C,S,N

[State 0, Gravity]
type = Gravity
trigger1 =  animelemtime(2) < 15


[State 0, StateTypeSet]
type = StateTypeSet
trigger1 = AnimElem = 3
statetype = s       ;S,A,C,L
movetype = I        ;I,A,H
physics = s         ;A,C,S,N


[State 810, Velocity]
type = VelSet
trigger1 = AnimElem = 1
x = -7.25
y= -2.0

[State 810, Velocity]
type = VelSet
trigger1 = AnimElem = 5
x = 0

[State 0, PosSet]
type = PosSet
trigger1 = AnimElem = 3
y = 0


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





;ZERO COUNTER 
[Statedef 750]
type = S
physics = S
movetype = I
anim = 750
velset = 0, 0
ctrl = 0
sprpriority = 2
poweradd = -1000
facep2 = 1



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

[State 750, Stop]
type = posfreeze
trigger1 = 1
value = 1

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

[State 750, SuperPause FX]
type = helper
trigger1 = !time
stateno = 8350
ID = 8350
name = "Zero Counter"
postype = p1
pos = 35, -83
supermovetime = 255
ownpal = 1

[State 750, Super Pause]
type = superpause
trigger1 = !time
time = 15
movetime = 15
p2defmul = 1
anim = -1
sound = s750,0
darken = 0

[State 750, End]
type = changestate
trigger1 = time >= 15
value = ifelse(var(10) = 1, 2910, 2900)

;Quick guard
[Statedef 740]
type = S
physics = S
movetype = I
anim = 760
velset = 0, 0
ctrl = 0
sprpriority = 2
poweradd = 0
facep2 = 1

[State 1500, 3]
type = Helper
triggerall = numhelper(35500) = 0
trigger1 = animelemtime(1) = 0
name = "Buzz Coin"
ID = 35499
stateno = 35499
pos = 0,0
postype = p1
ownpal = 0
persistent = 0
facing = 1
size.xscale =1.25 
size.yscale = 1.25

[State 760, HB]
type = hitby
trigger1 = 1
value = SCA, AT
time = 1

[State 760, Snd]
type = playsnd
trigger1 = !time
value = 12,4
channel = 1


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



;EX Quick guard
[Statedef 741]
type = S
physics = S
movetype = I
anim = 760
velset = 0, 0
ctrl = 0
sprpriority = 2
poweradd = -1000
facep2 = 1

[State 1500, 3]
type = Helper
triggerall = numhelper(35500) = 0
trigger1 = animelemtime(1) = 0
name = "Buzz Coin"
ID = 35499
stateno = 35499
pos = 0,0
postype = p1
ownpal = 0
persistent = 0
facing = 1
size.xscale =1.25 
size.yscale = 1.25

[State 760, HB]
type = hitby
trigger1 = 1
value = SCA, AT
time = 1

[State 760, Snd]
type = playsnd
trigger1 = !time
value = 12,4
channel = 1

[State 760, Flash]
type = palfx
trigger1 = !time
add = 0, 64, 255
sinadd = 0, -64, -255, 60
time = 15


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



;PARRY STANDING
[Statedef 760]
type = S
physics = S
movetype = I
anim = 760
velset = 0, 0
ctrl = 0
sprpriority = 2
poweradd = 100
facep2 = 1



[State 0, Explod]
type = Explod
trigger1 = time= 0
anim = 17401
ID = 1
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = 9999
pausemovetime = 0
scale = 1,1
sprpriority = 0
ontop = 0
shadow = 0,0,0
ownpal = 0
removeongethit = 0
ignorehitpause =1



[State 760, HB]
type = hitby
trigger1 = 1
value = SCA, AT
time = 1

[State 760, Pause]
type = pause
trigger1 = !time
time = 15
movetime = 15
endcmdbuftime = 15
pausebg = 0

[State 760, Stop]
type = posfreeze
trigger1 = 1
value = 1

[State 760, No walking]
type = varset
trigger1 = 1
var(26) = 7

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

[State 760, Snd]
type = playsnd
trigger1 = !time
value = 0,24
channel = 1

[State 760, Flash]
type = palfx
trigger1 = !time
add = 0, 64, 255
sinadd = 0, -64, -255, 60
time = 15

[State 760, FX]
type = explod
trigger1 = !time
anim = 8360
sprpriority = 5
postype = p1
pos = 32, -59
pausemovetime = -1
supermovetime = -1
scale = 0.5, 0.5
ownpal = 1

[State 760, Shake]
type = envshake
trigger1 = !time
time = 0
ampl = 0

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


;PARRY CROUCHING
[Statedef 761]
type = C
physics = C
movetype = I
anim = 761
velset = 0, 0
ctrl = 0
sprpriority = 2
poweradd = 250
facep2 = 1



[State 761, HB]
type = hitby
trigger1 = 1
value = SCA, AT
time = 1

[State 761, Pause]
type = pause
trigger1 = !time
time = 15
movetime = 15
endcmdbuftime = 15
pausebg = 0

[State 761, Stop]
type = posfreeze
trigger1 = 1
value = 1

[State 761, No walking]
type = varset
trigger1 = 1
var(26) = 7

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

[State 761, Snd]
type = playsnd
trigger1 = !time
value = 0,24
channel = 1

[State 761, Flash]
type = palfx
trigger1 = !time
add = 0, 64, 255
sinadd = 0, -64, -255, 60
time = 15

[State 761, FX]
type = explod
trigger1 = !time
anim = 8360
sprpriority = 5
postype = p1
pos = 36,-40
pausemovetime = -1
supermovetime = -1
scale = 0.5, 0.5
ownpal = 1

[State 761, Shake]
type = envshake
trigger1 = !time
time = 0
ampl = 0

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


;PARRY JUMPING 
[Statedef 762]
type = A
physics = N
movetype = I
anim = 762
ctrl = 0
sprpriority = 2
poweradd = 250
facep2 = 1

[State 762, HB]
type = hitby
trigger1 = 1
value = SCA, AT
time = 1


[State 762, Pause]
type = pause
trigger1 = !time
time = 15
movetime = 15
endcmdbuftime = 15
pausebg = 0

[State 762, Stop]
type = posfreeze
trigger1 = 1
value = 1

[State 762, Snd]
type = playsnd
trigger1 = !time
value = s0,24
channel = 1

[State 762, Flash]
type = palfx
trigger1 = !time
add = 0, 64, 255
sinadd = 0, -64, -255, 60
time = 15

[State 762, FX]
type = explod
trigger1 = !time
anim = 8360
sprpriority = 5
postype = p1
pos = 28,-73
pausemovetime = -1
supermovetime = -1
scale = 0.5, 0.5
ownpal = 1

[State 762, Shake]
type = envshake
trigger1 = !time
time = 0
ampl = 0

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

;PARRY JUMP FINISH
[Statedef 763]
type = A
physics = N
movetype = I
anim = 763
ctrl = 1

[State 763, Vel]
type = velset
triggerall = (prevstateno != 771)
trigger1 = !time
x = ifelse(vel x > 2, 2, ifelse(vel x < -2, -2, vel x))
y = ifelse(vel y < -2, vel y, -2)


[State 763, Accel]
type = gravity
trigger1 = 1

[State 763, Land]
type = changestate
trigger1 = pos y > -vel y
value = 52


;PARRY HELPER
[StateDef 765]
type = A
physics = N
moveType = I
anim = ifElse(Root, StateType = C, 766, ifElse(Root, StateType = A, 767, 765))
velSet = 0,0
ctrl = 0

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

[State 765, BindToRoot]
type = BindToRoot
trigger1 = 1
time = -1

[State 765, Change to Crouching]
type = ChangeAnim
triggerAll = !Time
trigger1 = !(Root, AILevel) && Root, command = "down"
trigger2 = Root, AILevel && (Root, StateType != A) && P2StateType = C
value = 766

[State 765, Change to Standing / Jumping]
type = ChangeAnim
triggerAll = !Time
trigger1 = !(Root, AILevel) && Root, command = "fwd"
trigger2 = Root, AILevel && Anim != 766
value = ifElse((Root, StateType = A), 767, 765)

[State 765, Change to Standing / Jumping]
type = ChangeAnim
trigger1 = Anim = 765 || Anim = 767
value = ifElse((Root, StateType = A) , 767, 765)

[State 765, Disable]
type = VarSet
triggerAll =(Root, StateNo != [100,105]) && (Root, StateNo != 740) && (Root, StateNo != 760) && (Root, StateNo != 771) 
trigger1 = Time >= ifElse((Root, StateType = A), 10, 12)
trigger2 = Facing != (Root, Facing)
trigger3 = !(Root, ctrl)
trigger3 = (Root, StateNo != [760,762]) && (Root, StateNo != 5120) && (Root, StateNo != [100,105]) && (Root, StateNo != 740) && (Root, StateNo != 771) 
var(0) = 1

[State 765, Disable]
type = VarSet
triggerAll = !(Root, AILevel)
triggerAll =(Root, StateNo != [100,105]) && (Root, StateNo != 740) && (Root, StateNo != 771) 
trigger1 = (Root, command = "holdback")
trigger2 = Time < 4 && (Root, command = "holdfwd" + Root, command = "holddown") > 1
trigger3 = Time >= 4 && (Root, command = "holdfwd" || Root, command = "holddown")
trigger4 = Time >= 4 && (((Anim = 765 || Anim = 767) && Root, command = "fwd") || (Anim = 766 && Root, command = "down"))
var(0) = 1

[State 765, Disable]
type = ChangeAnim
trigger1 = var(0) = 1
value = 1

[State 765, Standing/Air]
type = ReversalDef
trigger1 = !var(0) && (Anim = 765 || Anim = 767)
trigger1 = (Root, StateNo != 5120) || !(Root, AnimTime)
reversal.attr = SCA,AA
p1StateNo = 766
pauseTime = 0,0
sparkNo = -1
numHits = 0

[State 765, Crouching]
type = ReversalDef
trigger1 = !var(0) && Anim = 766
reversal.attr = SC,AA
p1StateNo = 766
pauseTime = 0,0
sparkNo = -1
numHits = 0

[State 765, Disable]
type = ReversalDef
trigger1 = var(0) = 1
reversal.attr =
pauseTime = 0,0
sparkNo = -1
numHits = 0

[State 765, End]
type = DestroySelf
trigger1 = Time >= 25
trigger2 = (Root, MoveType != I)
trigger3 = !(Root, ctrl) && (Root, StateNo != [760,762]) && (Root, StateNo != 5120) && (Root, StateNo != [100,105]) && (Root, StateNo != 740) && (Root, StateNo != 771)
trigger4 = (Root, StateNo = [760,762]) && (Root, Time <= 25)
;trigger5 = (Root, StateNo = 771) && (Root, Time <= 15)
;trigger5 = (Root, StateNo = [100,105]) || (Root, StateNo = 740) 
;trigger5 = (Root, Time <= 15)

;PARRY SUCCESS
[StateDef 766]
moveType = I
ctrl = 0

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

[State 766, End]
type = DestroySelf
trigger1 = Root, StateNo = [760,762]
trigger2 = Time >= 2

;Quick Guard air
[Statedef 771]
type = A
physics = A
movetype = I
anim = 762
ctrl = 0
sprpriority = 2
facep2 = 1

[State 0, HitBy]
type = HitBy
trigger1 = 1
value = SCA,NT,ST,HT
;value2 = S,NA
time = 1

 
[State 762, Snd]
type = playsnd
trigger1 = !time
value = s12,1
channel = 1

[State 0, VarAdd]
type = Varset
trigger1 = 1
v =  19
value = 1


[state 937, End State]
type = changestate
trigger1 = pos y + vel y > 0
value = 52
ctrl = 1


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


;Subsitute BAR HELPER
[Statedef 780]
type = S
movetype = I
physics = N
anim = 1
sprpriority = 0
;ignorehitpause = 1

[State 780, BindToRoot]
type = BindToRoot
trigger1 = 1
time = -1
pos = 0,-165

[State 780, Meter BG]
type = Explod
trigger1 = !Time
anim = 780
id = 780
pos = 2,0
postype = p1
bindtime = -1
removetime = -1
scale = .5,.5
sprpriority = -1
ontop = 1
ownpal = 1
removeongethit = 0

[State 780, Meter Fill]
type = Explod
trigger1 = Time = 2
anim = 781
id = 781
pos = 24,0
postype = p1
bindtime = -1
removetime = -1
scale = .5,.5
sprpriority = 2
ontop = 1
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[State 780, Meter Container]
type = Explod
trigger1 = Time = 2
anim = 782
id = 782
pos = 0,0
postype = p1
bindtime = -1
removetime = -1
scale = .5,.5
sprpriority = 4
ontop = 1
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[State 780, ModifyExplod]
type = ModifyExplod
trigger1 = root, Var(47) > 0
id = 781
scale = .5*ceil(2000*root, fvar(2)) / 2000.0, .5;ifelse(ceil(2000*root,fvar(2)) >= 1000, .5, ceil(5 + 2000*root, fvar(2))) / 2000.0,.5
ignorehitpause = 1

[State 780, RemoveExplod]
type = RemoveExplod
trigger1 = !numhelper(7050);root, Var(47) <= 0
id = 780
ignorehitpause = 1

[State 780, RemoveExplod]
type = RemoveExplod
trigger1 =!numhelper(7050) ;root, Var(47) <= 0
id = 781
ignorehitpause = 1

[State 780, RemoveExplod]
type = RemoveExplod
trigger1 = !numhelper(7050);root, Var(47) <= 0
id = 782
ignorehitpause = 1

[State 780, DestroySelf]
type = DestroySelf
trigger1 = !numhelper(7050);root, Var(47) <= 0
ignorehitpause = 1

;Subsitute BAR HELPER 2
[Statedef 781]
type = S
movetype = I
physics = N
anim = 1
sprpriority = 0
;ignorehitpause = 1

[State 780, BindToRoot]
type = BindToparent
trigger1 = 1
time = -1
pos = 5,-60

[State 780, Meter BG]
type = Explod
trigger1 = !Time
anim = 780
id = 780
pos = 2,0
postype = p1
bindtime = -1
removetime = -1
scale = .5,.5
sprpriority = -1
ontop = 1
ownpal = 1
removeongethit = 0

[State 780, Meter Fill]
type = Explod
trigger1 = Time = 2
anim = 781
id = 781
pos = 24,0
postype = p1
bindtime = -1
removetime = -1
scale = .5,.5
sprpriority = 2
ontop = 1
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[State 780, Meter Container]
type = Explod
trigger1 = Time = 2
anim = 782
id = 782
pos = 0,0
postype = p1
bindtime = -1
removetime = -1
scale = .5,.5
sprpriority = 4
ontop = 1
ownpal = 1
removeongethit = 0
ignorehitpause = 1

[State 780, ModifyExplod]
type = ModifyExplod
trigger1 = root, Var(47) > 0
id = 781
scale = .5*ceil(2000*root, fvar(2)) / 2000.0, .5;ifelse(ceil(2000*root,fvar(2)) >= 1000, .5, ceil(5 + 2000*root, fvar(2))) / 2000.0,.5
ignorehitpause = 1

[State 780, RemoveExplod]
type = RemoveExplod
trigger1 = !numhelper(7050);root, Var(47) <= 0
id = 780
ignorehitpause = 1

[State 780, RemoveExplod]
type = RemoveExplod
trigger1 =!numhelper(7050) ;root, Var(47) <= 0
id = 781
ignorehitpause = 1

[State 780, RemoveExplod]
type = RemoveExplod
trigger1 = !numhelper(7050);root, Var(47) <= 0
id = 782
ignorehitpause = 1

[State 780, DestroySelf]
type = DestroySelf
trigger1 = !numhelper(7050);root, Var(47) <= 0
ignorehitpause = 1

;Shield HELPER
[Statedef 790]
type = S
movetype = I
physics = N
anim = 6666
sprpriority = 15
;ignorehitpause = 1




[State 780, BindToRoot]
type = BindToRoot
trigger1 = 1 
time = -1
pos =-5,-90+(45*(root,statetype = c))


[State 780, BindToRoot]
type = BindToRoot
trigger1 = root,statetype = c 
time = -1
pos =-5,-45

[State 780, DestroySelf]
type = DestroySelf
trigger1 = !numhelper(7050) && palno != 12


;CUSTOM COMBO AIR 
[Statedef 905]
type = A
physics = N
movetype = A
anim = 905
ctrl = 0
sprpriority = 2
poweradd = -1000

[State 905, Corner Push]
type = varset
trigger1 = time = 4
fvar(5) = 0

[State 905, Unguardable]
type = varset
trigger1 = time = 4 && numenemy
trigger1 = (enemynear, stateno != [120, 155])
var(17) = 30

[State 905, NHB]
type = nothitby
trigger1 = !time
value = SCA
time = 38

[State 905, Stop]
type = posfreeze
trigger1 = 1
value = 1

[State 905, Var]
type = varset
trigger1 = time >= 4
var(20) = 180

[State 905, Snd]
type = playsnd
trigger1 = time = 4
value = 181,0
channel = 0

[State 905, SuperPause FX]
type = helper
trigger1 = time = 4
stateno = 8400
ID = 8400
name = "Custom Combo Startup"
postype = p1
pos = 2,-90
supermovetime = 255
size.xscale = 1
size.yscale = 1
ownpal = 1

[State 905, Super Pause]
type = superpause
trigger1 = time = 4
time = 30
movetime = 30
anim = -1
sound = s900,0
p2defmul = 1
darken = 0

[State 905, AfterImage]
type = afterimage
trigger1 = !animtime
time = 2
timegap = 1
framegap = 4
length = 13
palbright = 0, 0, 0
palcontrast = 64, 128, 192
palpostbright = 0, 0, 0
paladd = 0, 0, 0
palmul = 0.75, 0.75, 0.75
trans = add1

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

;CUSTOM COMBO AIR FINISH
[Statedef 906]
type = A
physics = N
movetype = I
anim = 906
ctrl = 1

[State 906, Accel]
type = gravity
trigger1 = 1

[State 906, Land]
type = changestate
trigger1 = pos y > -vel y
value = 52



;GUARD START 
[Statedef 120]
type = U
physics = U
anim = 120 + (statetype = C) + (statetype = A) * 2
[State 120, Type]
type = statetypeset
trigger1 = !time && statetype = S
physics = S
[State 120, Type]
type = statetypeset
trigger1 = !time && statetype = C
physics = C
[State 120, Type]
type = statetypeset
trigger1 = !time && statetype = A
physics = A
[State 120, Vel]
type = velset
trigger1 = !time && statetype != A
x = 0
y = 0
[State 120, High to Low]
type = statetypeset
trigger1 = !AILevel && StateType = S && command = "holddown"
trigger2 = AILevel && StateType = S && (EnemyNear, MoveType = A) && (EnemyNear, StateType = C)
statetype = C
physics = C
[State 120, Low to High]
type = statetypeset
trigger1 = !AILevel && StateType = C && command != "holddown"
trigger2 = AILevel && StateType = C && (EnemyNear, MoveType = A) && (EnemyNear, StateType != C)
statetype = S
physics = S
[State 120, AI fix]
type = ctrlset
trigger1 = AIlevel && numenemy
value = (enemynear, time >= 120 || time >= 180)
[State 120, End]
type = changestate
trigger1 = !animtime || AIlevel
value = 130 + (statetype = C) + (statetype = A) * 2
[State 120, Stop]
type = changestate
trigger1 = (!AIlevel && command != "holdback")
trigger2 = !inguarddist
trigger3 = AIlevel && numenemy
trigger3 = enemynear, hitdefattr = SCA, AT
value = 140


;=========================================================================
; Air Jump
;=========================================================================
[Statedef 945]
type = A
movetype = I
physics = N
ctrl = 0
velset = 0, 0
sprpriority = 1

[state 945, Jump Direction]
type = varset
trigger1 = !ailevel
sysvar(1) = cond(command = "holdfwd", 1, cond(command = "holdback", -1, 0))

[state 945, Jump Direction]
type = varset
trigger1 = ailevel
sysvar(1) = cond(p2movetype = A || frontedgebodydist <= 16 && !numtarget, -1, cond(p2movetype != A || backedgebodydist <= 16 || numtarget || random < 250, 1, 0))

[state 945, Jump Direction]
type = varset
trigger1 = p2dist x < 0
trigger1 = sysvar(1)
trigger1 = !time
sysvar(1) = sysvar(1) * -1

[state 945, Long, Low, and High Jumps]
type = varset
trigger1 = !time
var(1) = 0

[state 945, Turn]
type = turn
trigger1 = p2dist x < 0
trigger1 = !time

[state 945, Sound]
type = playsnd
trigger1 = !time
value = 40, 0
volumescale = 100
  

[state 945, Set Velocity]
type = velset
trigger1 = !time
x = cond(sysvar(1) = 0, 0.0, cond(sysvar(1) = 1, 6, -5))
y = const(velocity.jump.y)

[state 945, Land Smoke]
type = helper
trigger1 = !time
helpertype = normal
name = "Land Smoke"
ID = 6010
stateno = 6010
postype = P1
ownpal = 1
keyctrl = 0
size.xscale = 1.0
size.yscale = 1.0
supermovetime = 65536
pausemovetime = 65536

[state 945, End State]
type = changestate
trigger1 = !time
value = 50
ctrl = 1

;=========================================================================
; Air Dash
;=========================================================================
[Statedef 950]
type = A
movetype = I
physics = N
ctrl = 0
velset = 0, 0
sprpriority = 1

[state 950, Dash Direction]
type = varset
trigger1 = !ailevel
trigger1 = !time
sysvar(1) = cond(command = "FF", 1, -1)

[state 950, Dash Direction]
type = varset
trigger1 = ailevel
trigger1 = !time
sysvar(1) = cond(p2movetype = A && backedgebodydist > 16 && prevstateno = 100 && !numtarget, -1, 1)

[state 950, Change Animation]
type = changeanim
trigger1 = !time
value = cond(sysvar(1) = 1, 42, 43)

[state 950, Voice]
type = playsnd
trigger1 = !animelemtime(2)
value = cond(anim = 42, 42, 43), cond(anim = 42, random % 2, 0)
volumescale = 100
channel = 0

[state 950, Sound]
type = playsnd
trigger1 = !animelemtime(2)
value = 100, 3
volumescale = 100

[state 950, Set Velocity]
type = velset
trigger1 = sysvar(1) = 1
trigger1 = !animelemtime(1)
x = 8.0

[state 950, Set Velocity]
type = velset
trigger1 = sysvar(1) = 1
trigger1 = !animelemtime(2)
x = 10.0
y = -10.0

[state 950, Increment Velocity]
type = veladd
trigger1 = sysvar(1) = 1
trigger1 = animelemtime(2) > 0
y = 0.75

[state 950, Set Velocity]
type = velset
trigger1 = sysvar(1) = -1
trigger1 = !animelemtime(1)
x = -5

[state 950, Set Velocity]
type = velset
trigger1 = sysvar(1) = -1
trigger1 = !animelemtime(2)
x = -7
y = -10

[state 950, Increment Velocity]
type = veladd
trigger1 = sysvar(1) = -1
trigger1 = animelemtime(2) > 0
y = 0.75

[state 950, Air Dash Smoke]
type = helper
trigger1 = !animelemtime(2)
helpertype = normal
name = "Air Dash Smoke"
ID = 952
stateno = 952
postype = P1
ownpal = 1
keyctrl = 0
size.xscale = 1.0
size.yscale = 1.0
supermovetime = 65536
pausemovetime = 65536

[state 950, Control]
type = ctrlset
trigger1 = !ctrl
trigger1 = time > 8
value = 1

[state 950, End State]
type = changestate
trigger1 = pos y + vel y > 0
value = 52
ctrl = 0



;STAND GUARD (guarding) ---
[Statedef 130]
type = S
physics = S
[State 130, Anim]
type = changeanim
trigger1 = anim != 130
value = 130
[State 130, AI fix]
type = ctrlset
trigger1 = AIlevel && numenemy
value = (enemynear, time >= 120 || time >= 180)
[State 130, High to Low]
type = changestate
trigger1 = !AIlevel && command = "holddown"
trigger2 = AILevel && Random < (250 * (AILevel ** 2 / 64.0))
trigger2 = (EnemyNear, MoveType = A) && (EnemyNear, StateType = C)
value = 131
[State 130, Stop Guarding]
type = changestate
trigger1 = (!AIlevel && command != "holdback")
trigger2 = !inguarddist
trigger3 = AIlevel && numenemy
trigger3 = enemynear, hitdefattr = SCA, AT
value = 140
[State 131, Stop Guarding]
type = changestate
triggerall =numhelper
trigger1 = AIlevel && numenemy
trigger1 = numhelper(4900)
value = 140
[State 130, Snd]
type = playsnd
trigger1 = !time
trigger1 = prevstateno = 132 || (prevstateno = [154, 155])
value = 52,0
[State 130, Dust]
type = explod
trigger1 = !time
trigger1 = prevstateno = 132 || (prevstateno = [154, 155])
anim = 8102
sprpriority = -3
postype = p1
scale = 0.5, 0.5
pausemovetime = -1
supermovetime = -1
ownpal = 1

;CROUCH GUARD (guarding) ---
[Statedef 131]
type = C
physics = C
[State 131, Anim]
type = changeanim
trigger1 = anim != 131
value = 131
[State 131, Low to High]
type = changestate
trigger1 = !AIlevel && command != "holddown"
trigger2 = AILevel && Random < (125 * (AILevel ** 2 / 64.0))
trigger2 = (EnemyNear, MoveType = A) && (EnemyNear, StateType != C)
value = 130
[State 131, AI fix]
type = ctrlset
trigger1 = AIlevel && numenemy
value = (enemynear, time >= 120 || time >= 180)
[State 131, Stop Guarding]
type = changestate
trigger1 = (!AIlevel && command != "holdback")
trigger2 = !inguarddist
trigger3 = AIlevel && numenemy
trigger3 = enemynear, hitdefattr = SCA, AT
trigger4 = AIlevel && numenemy
trigger4 = numhelper(4900)
value = 140

[State 131, Stop Guarding]
type = changestate
triggerall =numhelper
trigger1 = AIlevel && numenemy
trigger1 = numhelper(4900)
value = 140



;AIR GUARD (guarding) ---
[Statedef 132]
type = A
physics = N
[State 132, Anim]
type = changeanim
trigger1 = anim != 132
value = 132
[State 132, Accel]
type = veladd
trigger1 = 1
y = const(movement.yaccel)
[State 132, Var]
type = varset
trigger1 = 1
sysvar(0) = (pos y >= 0 && vel y > 0)
[State 132, Vel]
type = velset
trigger1 = sysvar(0)
y = 0
[State 132, Pos]
type = posset
trigger1 = sysvar(0)
y = 0
[State 132, AI fix]
type = ctrlset
trigger1 = AIlevel && numenemy
value = (enemynear, time >= 120 || time >= 180)
[State 132, End]
type = changestate
trigger1 = sysvar(0) && inguarddist
trigger1 = (!AIlevel && command = "holdback") || AIlevel
value = 130
[State 132, End]
type = changestate
trigger1 = sysvar(0)
value = 52
[State 132, stop guarding]
type = changestate
trigger1 = (!AIlevel && command != "holdback")
trigger2 = !inguarddist
trigger3 = AIlevel && numenemy
trigger3 = enemynear, hitdefattr = SCA, AT
value = 140


;GUARD (end) ---
[Statedef 140]
type = U
physics = U
ctrl = 1
[State 140, Anim]
type = changeanim
trigger1 = !time
value = 140 + (statetype = C) + (statetype = A) * 2
[State 140, Type]
type = statetypeset
trigger1 = !time && statetype = S
physics = S
[State 140, Type]
type = statetypeset
trigger1 = !time && statetype = C
physics = C
[State 140, Type]
type = statetypeset
trigger1 = !time && statetype = A
physics = A
[State 140, High to Low]
type = statetypeset
trigger1 = !AIlevel && statetype = S && command = "holddown"
trigger2 = AILevel && Random < (250 * (AILevel ** 2 / 64.0))
trigger2 = StateType = S && (EnemyNear, MoveType = A) && (EnemyNear, StateType = C)
statetype = C
physics = C
[State 140, Low to High]
type = statetypeset
trigger1 = !AIlevel && statetype = C && command != "holddown"
trigger2 = AILevel && Random < (125 * (AILevel ** 2 / 64.0))
trigger2 = StateType = C && (EnemyNear, MoveType = A) && (EnemyNear, StateType != C)
statetype = S
physics = S
[State 140, End]
type = changestate
trigger1 = !animtime
value = (statetype = C) * 11 + (statetype = A) * 51

;SGUARDHIT (shaking) ---
[Statedef 150]
type = S
movetype = H
physics = N
velset = 0, 0
[State 150, Anim]
type = changeanim
trigger1 = 1
value = 150
[State 150, End]
type = changestate
trigger1 = hitshakeover
value = 151 + 2 * ((!AIlevel && command = "holddown") || (AIlevel && (enemynear, movetype = A) && (enemynear, statetype = C)))
[State 150, High to Low]
type = statetypeset
trigger1 = !AIlevel && statetype = S && command = "holddown"
trigger2 = AILevel && Random < (250 * (AILevel ** 2 / 64.0))
statetype = C
physics = C
[State 150, Low to High]
type = statetypeset
trigger1 = !AIlevel && statetype = C && command != "holddown"
trigger2 = AIlevel && Random < (125 * (AILevel ** 2 / 64.0))
trigger2 = StateType = C && (EnemyNear, MoveType = A) && (EnemyNear, StateType != C)
statetype = S
physics = S
;SGUARDHIT2 (knocked back) ---
[Statedef 151]
type = S
movetype = H
physics = S
anim = 150
[State 151, Vel]
type = hitvelset
trigger1 = !time
x = 1
[State 151, Vel]
type = velset
trigger1 = time = gethitvar(slidetime)
trigger2 = hitover
x = 0
[State 151, Ctrl]
type = ctrlset
trigger1 = time = gethitvar(ctrltime)
value = 1
[State 151, High to Low]
type = statetypeset
trigger1 = !AIlevel && statetype = S && command = "holddown"
trigger2 = AILevel && Random < (250 * (AILevel ** 2 / 64.0))
trigger2 = StateType = S && (EnemyNear, MoveType = A) && (EnemyNear, StateType = C)
statetype = C
physics = C
[State 151, Low to High]
type = statetypeset
trigger1 = !AIlevel && statetype = C && command != "holddown"
trigger2 = AILevel && Random < (125 * (AILevel ** 2 / 64.0))
trigger2 = StateType = C && (EnemyNear, MoveType = A) && (EnemyNear, StateType != C)
statetype = S
physics = S

[State 151, End]
type = changestate
trigger1 = hitover
value = 130
ctrl = 1


;CGUARDHIT (shaking) ---
[Statedef 152]
type = C
movetype = H
physics = N
velset = 0, 0
[State 152, Anim]
type = changeanim
trigger1 = 1
value = 151
[State 152, End]
type = changestate
trigger1 = hitshakeover
value = 151 + 2 * ((!AIlevel && command = "holddown") || (AIlevel && (enemynear, movetype = A) && (enemynear, statetype = C)))
[State 152, High to Low]
type = statetypeset
trigger1 = !AIlevel && statetype = S && command = "holddown"
trigger2 = AILevel && Random < (250 * (AILevel ** 2 / 64.0))
trigger2 = StateType = S && (EnemyNear, MoveType = A) && (EnemyNear, StateType = C)
statetype = C
physics = C
[State 152, Low to High]
type = statetypeset
trigger1 = !AIlevel && statetype = C && command != "holddown"
trigger2 = AILevel && Random < (125 * (AILevel ** 2 / 64.0))
trigger2 = StateType = C && (EnemyNear, MoveType = A) && (EnemyNear, StateType != C)
statetype = S
physics = S


;CGUARDHIT2 (knocked back) ---
[Statedef 153]
type = C
movetype = H
physics = C
anim = 151
[State 153, Vel]
type = hitvelset
trigger1 = !time
x = 1
[State 153, Vel]
type = velset
trigger1 = time = gethitvar(slidetime)
trigger2 = hitover
x = 0
[State 153, Ctrl]
type = ctrlset
trigger1 = time = gethitvar(ctrltime)
value = 1
[State 153, High to Low]
type = statetypeset
trigger1 = !AIlevel && statetype = S && command = "holddown"
trigger2 = AILevel && Random < (250 * (AILevel ** 2 / 64.0))
trigger2 = StateType = S && (EnemyNear, MoveType = A) && (EnemyNear, StateType = C)
statetype = C
physics = C
[State 153, Low to High]
type = statetypeset
trigger1 = !AIlevel && statetype = C && command != "holddown"
trigger2 = AILevel && Random < (125 * (AILevel ** 2 / 64.0))
trigger2 = StateType = C && (EnemyNear, MoveType = A) && (EnemyNear, StateType != C)
statetype = S
physics = S
[State 153, End]
type = changestate
trigger1 = hitover
value = 131
ctrl = 1


;AGUARDHIT (shaking) ---
[Statedef 154]
type = A
movetype = H
physics = N
velset = 0, 0
[State 154, Anim]
type = changeanim
trigger1 = 1
value = 152
[State 154, End]
type = changestate
trigger1 = hitshakeover
value = 155


;AGUARDHIT2 (knocked away) ---
[Statedef 155]
type = A
movetype = H
physics = N
anim = 152
[State 155, Vel]
type = hitvelset
trigger1 = !time
x = 1
y = 1
[State 155, Vel]
type = veladd
trigger1 = 1
y = const(movement.yaccel)
[State 155, Ctrl]
type = ctrlset
trigger1 = time = gethitvar(ctrltime)
value = 1
[State 155, Var]
type = varset
trigger1 = 1
sysvar(0) = (pos y >= 0 && vel y > 0)
[State 155, Vel]
type = velset
trigger1 = sysvar(0)
y = 0
[State 155, Pos]
type = posset
trigger1 = sysvar(0)
y = 0
[State 155, End]
type = changestate
trigger1 = sysvar(0) && inguarddist
trigger1 = (!AIlevel && command = "holdback") || AIlevel
value = 130
[State 155, End]
type = changestate
trigger1 = sysvar(0)
value = 52

;LOSE 
[Statedef 170]
type = S
ctrl = 0
anim = 170
velset = 0, 0


[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
time = 1
 
[State 0, Trans]
type = Trans
trigger1 = Time = [30,128]
trans =  add
alpha = 256-ceil(2*time),0

[State 0, Trans]
type = Trans
trigger1 = time >= 129
trans =  add
alpha = 0,0
ignorehitpause= 1

[State 0, PlaySnd]
type = PlaySnd
trigger1 = animelem = 6
value = S7777,1
channel = 3

[State 0, PlaySnd]
type = PlaySnd
trigger1 = animelem =6
value = S11,0
channel = 1

[State 0, Helper]
type = Helper
trigger1 = animelem = 6
helpertype = normal ;player
name = "portal"
ID = 50120
stateno = 50120
pos = 0,const(size.mid.pos.y)
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 9999
pausemovetime = 9999


[State 170, Assert]
type = assertspecial
trigger1 = Time < 200
flag = roundnotover


;DRAW GAME
[Statedef 175]
type = S
ctrl = 0
velset = 0, 0
[State 175, switch]
type = changestate
trigger1 = !time
value = 170

;---------------------------------------------------------------------------
; Win state decider
[Statedef 180]
type = S

[State 180, Hurt]
Type = VictoryQuote
Trigger1 = time = 0
value = 1 + random%6

;[State 180, Unhurt]
;Type = VictoryQuote
;Trigger1 = life = lifemax ; > 90% life
;value = ifelse(random <=500, 7,8)


[State 180, Dumb Bunny]
Type =null; VictoryQuote
Trigger1 = enemy, name = "Elemental Lopunny"          
value = 10

[State 180, Dinner]
Type = null;VictoryQuote
Trigger1 = enemy, name = "Gardenvoir"          
value = 11


[State 0, ChangeState]
type = ChangeState
trigger1 = time = 0
value =ifelse(!matchover,184, 183)
ctrl = 0



[State 180, 1]
type = null;ChangeState
trigger1 = time = 0
triggerall = !matchover
value =ifelse(life = lifemax,184, 181+(random%2))


[State 180, 1]
type = null;ChangeState
trigger1 = time = 0
triggerall = matchover
value = ifelse(numexplod(4757) = 4777,181,183)

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

;win hip dance
[Statedef 181]
type = S
physics = S
ctrl = 0
velset = 0,0
anim = 181




[State 181, 1]
type = AssertSpecial
trigger1 = Time = [0, 270]
flag = RoundNotOver

;---------------------------------------------------------------------------
;win hip dance
[Statedef 182]
type = S
physics = S
ctrl = 0
velset = 0,0
anim = 181






[State 181, 1]
type = AssertSpecial
trigger1 = Time = [0, 270]
flag = RoundNotOver


;---------------------------------------------------------------------------------
[Statedef 183, Bug conquest wip]
type = s
ctrl = 0
anim = 20
velset = 0,0


[State 0, SprPriority]
type = SprPriority
trigger1 = anim =182
value = 5


[state 183]
type = ScreenBound
trigger1 = 1
value = 0
movecamera = 0,0

[state 183]
type = velset
trigger1 = anim = 20
x = 4

[state 182]
type = velset
trigger1 = anim = 20
trigger1 = pos x - (enemynear,pos x -(enemynear,const(size.head.pos.y)-enemynear,const(size.mid.pos.y))) = [-75,35]
x = 0

[state 182]
type = changeanim
trigger1 = anim = 20
trigger1 = pos x - (enemynear,pos x -(enemynear,const(size.head.pos.y)-enemynear,const(size.mid.pos.y))) = [-75,35]
value = 182


[State 184, Winner]
type = Helper
triggerall = !numhelper(18500)
trigger1 = matchover = 1
trigger1 = anim = 182
id = 18500
name = "Winner"
sprpriority = 1
pos = 0,0
postype = p1
stateno = 18500
pausemovetime = 9999
ownpal = 1
ignorehitpause = 1


[State 182,whoosh]
type = playsnd
trigger1 = anim = 182
trigger1 = time = 0
value=12,random%5
channel=0




[state 189, 終わらないでね]
type = AssertSpecial
Trigger1 = anim = 20
trigger1 = time <= 360
trigger2 =  anim = 182
trigger2 = time <= 200
flag = RoundNotOver 


;-----------------------------------------------------------------------------------------------
;win No Damage Pose wip
[Statedef 184]
type = S
physics = S
ctrl = 0
velset = 0,0
anim = 181



[State 181, 2]
type = PlaySnd
trigger1 = AnimElem = 1
value = s13, 2
channel = 1

[State 0, StopSnd]
type = StopSnd
trigger1 = AnimElem = 79
channel = 1


[State 181, 2]
type = PlaySnd
trigger1 = AnimElem = 80
value = s18, 1
channel = 1

[State 181, 1]
type = AssertSpecial
trigger1 = Time = [0, 270]
flag = RoundNotOver

















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

[State 190, 1]
type = ChangeState
trigger1 = Time = 0
value = 191
;---------------------------------------------------------------------------
; Introduction
[Statedef 191]
type = S
ctrl = 0
anim = 191
velset = 0,0


[State 0, BGPalFX]
type = BGPalFX
trigger1 = time = [0,120]
time = 1
mul = 2*time,2*time,2*time

[State 0, Helper]
type = Helper
trigger1 = animelem = 1
helpertype = normal ;player
name = "portal"
ID = 50120
stateno = 50120
pos = 0,const(size.mid.pos.y)
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 9999
pausemovetime = 9999
scale = 1,1

[State 0, PlaySnd]
type = PlaySnd
trigger1 = animelem = 3
value = S10,2
channel = 1

[State 0, NotHitBy]
type = NotHitBy
trigger1 = anim = 191
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
time = 1
 
[State 0, Trans]
type = Trans
trigger1 = Time = [0,145]
trans =  add
alpha = ceil(2*time)-80,256

[State 0, PlaySnd]
type = PlaySnd
trigger1 = animelem = 1
value = S7777,1
channel = 3

[State 2000]
type = Explod
trigger1 = AnimElem = 1
anim = 2559
pos = 0,6
sprpriority = 3
ownpal = 1
bindtime = 1
supermove = 1

[State 2000]
type = Explod
trigger1 = AnimElem = 1
anim = 2558
pos = 0,6
sprpriority = 3
ownpal = 1
bindtime = 1
supermove = 1




[State 190, 2]
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 190, 4]
type = ChangeState
trigger1 = AnimTime = 0
value = 0

;---------------------------------------------------------------------------
; Introduction Woke up mad
[Statedef 192]
type = S
physics = N
ctrl = 0
anim = 192
velset = 0,0


[State 0, NotHitBy]
type = NotHitBy
trigger1 = anim = 192
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
time = 1
 


[State 193, 2]
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = intro
;-----------------------
flag = nobardisplay
flag = nomusic


[State 0, BGPalFX]
type = BGPalFX
trigger1 = time = [0,3000]
time = 1
mul =ifelse(time <256, ceil(256-time*1),0),ifelse(time <256, ceil(256-time*1),0),ifelse(time <256, ceil(256-time*1),0)


[State 0, Explod]
type = Explod
trigger1 = time = 0
anim = 449
ID = 446
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = -2
pausemovetime = 0
scale =2.5,2.5
sprpriority = - 10
ontop =0
shadow = 0,0,0
ownpal = 0
removeongethit = 0
;ignorehitpause =
;trans = 
;persistent =
;supermove = 0
;pausemove = 0


[State 0, Explod]
type = Explod
trigger1 = time = 0
anim = 442
ID = 442
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = -2
pausemovetime = 0
scale =2.5,2.5
sprpriority = 10
ontop = 1
shadow = 0,0,0
ownpal = 0
removeongethit = 0






[State 193, darkness]
type = PlaySnd
trigger1 = AnimElem = 2
value = 300, 69
channel = 3


[State 193, darkness]
type =null
 stopSnd
trigger1 = AnimElemtime(33) = 0
channel = 3




[State 193, Voice]
type = PlaySnd
trigger1 = AnimElem = 8
value = 194, 0

[State 193, EnvShake]
type = EnvShake
trigger1 = time = 4
time = 16
ampl = 5

[State 193, EnvShake]
type = EnvShake
trigger1 = time = 75
time = 16
ampl = 5


[State 193, EnvShake]
type = EnvShake
trigger1 = time = 150
time = 16
ampl = 5



[State 193, heartbeat]
type = PlaySnd
trigger1 = time = 4
value = 300, 65



[State 193,  heartbeat]
type = PlaySnd
trigger1 = time = 75
value = 300, 65



[State 193,  heartbeat]
type = PlaySnd
trigger1 = time = 150
value = 300, 65





[State 193, die]
type = PlaySnd
trigger1 = AnimElem = 41
value = 180, 1
channel = 3









[State 193, ChangeState]
type = ChangeState
trigger1 = AnimTime = 0
value = 0


[Statedef 6900, team mode intro]
type = S
physics = N
ctrl = 0
anim = 191
velset = 0,0

[State 0, NotHitBy]
type = NotHitBy
trigger1 = anim = 191
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
time = 1
 


[State 181, 2]
type = PlaySnd
trigger1 = AnimElem = 10
value = s180, 7

[State 190, 2]
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 190, 4]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1







;---------------------------------------------------------------------------
; Taunt
[Statedef 195]
type = S
ctrl = 0
anim = 195
velset = 0,0
movetype = I
physics = S
sprpriority = 2
poweradd = 250


[State 200, Snd]
type=playsnd
trigger1= animelem =8 
value=s18,random%5
channel=0

[State 0, CtrlSet]
type = CtrlSet
trigger1 = animelemtime(9) >= 2
value = 1

[State 195, 2]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Continue?
[Statedef 5500]
type = S
ctrl = 0
anim = 170
velset = 0,0

[State 0, PlaySnd]
type = PlaySnd
trigger1 = animelem = 8
value = S180,7
channel = 6


[State 5500, 1] ;Use continue animation if available
type = null
ChangeAnim
trigger1 = time = 0
trigger1 = SelfAnimExist(5500)
value = 5500

;CHEAP K.O.
[Statedef 5950]
type = S
movetype = H
physics = S
anim = 5950
velset = 0, 0

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

[State 5950, Pos]
type = posset
trigger1 = 1
y = 0

[State 5950, KO Snd]
type = assertspecial
trigger1 = 1
flag = nokosnd

[State 5950, KO Snd]
type = stopsnd
trigger1 = !time && !alive
channel = 0

[State 5950, KO Snd]
type = playsnd
trigger1 = animelem = 2 && !alive
value = 5950,0

[State 5981, Snd]
type = playsnd
trigger1 = animelem = 10
value = f7, 0

[State 5981, FX]
type = explod
trigger1 = animelem = 10
anim = f60
postype = p1
pos = 0, 0
sprpriority = -3

[State 5950, End]
type = changestate
trigger1 = !animtime
value = ifelse(alive, 5110, 5150)




;AIR HIT TRANSITION 
[Statedef 5035]
type = A
movetype = H
physics = N

[State 5035, Anim]
type = changeanim
trigger1 = !time
trigger1 = selfanimexist(5035)
trigger1 = anim = [5000, 5029]
value = 5035

[State 5035, Accel]
type = veladd
trigger1 = 1
y = gethitvar(yaccel)

[State 5035, Recover]
type = changestate
triggerall = !hitfall
trigger1 = hitover
trigger2 = !animtime
trigger3 = vel y > 0 && pos y >= 10
trigger4 = !time
trigger4 = anim != 5035
value = 5040

[State 5035, fall]
type = changestate
triggerall = hitfall
trigger1 = hitover
trigger2 = !animtime
trigger3 = vel y > 0 && pos y >= 10
trigger4 = !time
trigger4 = anim != 5035
value = 5050


;FALL RECOVERY
[Statedef 5200]
type = A
movetype = H
physics = N

[State 5200, Anim]
type = changeanim
trigger1 = anim = 5035 && !animtime
value = 5050

[State 5200, Vel]
type = veladd
trigger1 = 1
y = gethitvar(yaccel)

[State 5200, End]
type = selfstate
trigger1 = vel y > 0 && pos y >= 10
value = 5201

;RECOVER NEAR GROUND
[Statedef 5201]
type = S
movetype = I
physics = N
anim = 5200
ctrl = 0
facep2 = 1

[State 5201, Pos]
type = posset
trigger1 = 1
y = 0

[State 5201, VelSet]
type = VelSet
trigger1 = Time = 0
x = -6

[State 5201, VelMul]
type = VelMul
trigger1 = 1
x = 0.9

[State 5201, VelSet]
type = VelSet
trigger1 = vel X > -0.1
x = 0

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

[State 5201, Snd]
type = playsnd
trigger1 = !time
value = 5200,0
channel = 1

[State 5201, Flash]
type = palfx
trigger1 = !time
add = 255, 255, 255
sinadd = -255, -255, -255, 40
time = 10

[State 5201, FX]
type = helper
trigger1 = !time
stateno = 8200
ID = 8200
name = "Recover FX"
postype = p1
pos = 0, ceil(-18 * const(size.yscale))
size.xscale = 1
size.yscale = 1
ownpal = 1

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

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


;FALL RECOVER AIR 
[Statedef 5210]
type = A
movetype = I
physics = N
anim = 5210
ctrl = 0
facep2 = 1

[State 5210, Accel]
type = veladd
trigger1 = 1
y = 0.6

[State 5210, Vel]
type = velset
trigger1 = !time
x = ifelse((command = "holdfwd" && command != "holdback"), 4, ifelse((command != "holdfwd" && command = "holdback"), -4, 0))
y = -7.55

[State 5210, Snd]
type = playsnd
trigger1 = !time
value = 820,0
channel = 0

[State 5210, Snd]
type = playsnd
trigger1 = !time
value = 5200,0
channel = 1

[State 5210, Flash]
type = palfx
trigger1 = !time
add = 255, 255, 255
sinadd = -255, -255, -255, 40
time = 10

[State 5210, FX]
type = helper
trigger1 = !time
stateno = 8200
ID = 8200
name = "Recover FX"
postype = p1
pos = 0, ceil(-66 * const(size.yscale))
size.xscale = 1
size.yscale = 1
ownpal = 1

[State 5210, NHB]
type = nothitby
trigger1 = AnimElemTime(5) < 0
value = SCA
time = 1

[State 5210, Ctrl]
type = ctrlset
trigger1 = AnimElemTime(5) < 0
value = 1

[State 5210, Land]
type = changestate
trigger1 = vel y > 0
trigger1 = pos y > -vel y
value = 52



;TARGET SAFE FALL
[Statedef 5205]
type = A
physics = N
movetype = H

[State 5205, Anim]
type = changeanim
trigger1 = !animtime
trigger1 = anim = 5035
value = 5050

[State 5205, Accel]
type = veladd
trigger1 = 1
y = gethitvar(yaccel)

[State 5205, Ground]
type = selfstate
trigger1 = vel y > 0
trigger1 = pos y >= const(movement.air.gethit.groundrecover.ground.threshold)
value = 5200

[State 5205, Air]
type = selfstate
trigger1 = time >= 60
value = 5210

;============<OFF SCREEN STAND BY>=========
;Stand by
[Statedef 7827]
type=S
movetype=I
physics=N
velset=0,0
ctrl=0
facep2=1

[State 0, ScreenBound]
type=ScreenBound
trigger1 =1
value =0
ignorehitpause =1
[State 7827]
type=PosSet
trigger1=!time
y=0
ignorehitpause=1
[State 7827]
type=ChangeState
trigger1=NumEnemy=[1,2]
trigger1=Enemy(0),statetype=L || Enemy(0),movetype != H
value=7828
[State 7827]
type=ChangeState
trigger1=NumEnemy=2
trigger1=Enemy(1),statetype=L || Enemy(1),movetype != H
value=7828
;============<OFF SCREEN RUN IN>=========
;Off Screen Run In
[Statedef 7828]
type   =S
physics=S
anim=100
ctrl=0
facep2=1

[State 7828, SND]
type=playsnd
trigger1=(animelem=3 || animelem=6)
value=100,0

[State 7828]
type=PosSet
trigger1=!Time
y=0
ignorehitpause=1
[State 7828]
type=VelSet
trigger1=AnimElem=1
x=7
ignorehitpause=1
[State 7828]
type=VelSet
trigger1=AnimElemNo(0)=[1,2]
x=9
ignorehitpause=1
[State 7828]
type=AssertSpecial
trigger1=1
flag=NoWalk
ignorehitpause=1
[State 7828]
type=AssertSpecial
trigger1=1
flag=NoAutoTurn
ignorehitpause=1

[State 7828]
type=ChangeState
trigger1= time>=20
value=7829
ctrl=0
;============<OFF SCREEN RUN STOP>=========
;Off Screen Run Stop
[Statedef 7829]
type   =S
physics=S
anim=101
ctrl=0

[State 7829,VelMul]
type=VelMul
trigger1 =time=2
x=.5
[State 7829,Dust]
type=MakeDust
trigger1=time%6
pos=30, 0

[State 7829, SND]
type=playsnd
trigger1 =!time
value=0, 101
persistent=0
[State 7829,END]
type=ChangeState
trigger1=!animtime
value=0
ctrl=1

;---------------------------------------------------------------------------
; Stand get-hit (shaking)
[Statedef 5000]
type    = S
movetype= H
physics = N
velset = 0,0

[State 5000, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) != [3,5]
value = ifelse((GetHitVar(groundtype) = 1),5000,5010) + GetHitVar(animtype)

[State 5000, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5030

[State 5000, 3] ;Anim for HIT_UP/HIT_DIAGUP (only if it exists)
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5047 + GetHitVar(animtype) ;5051 - 4 + type

[State 5000, 4] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5000, 5] ;State type gets set to aerial if getting hit up
type = StateTypeSet
trigger1 = Time = 0
trigger1 = GetHitVar(yvel) != 0 || GetHitVar(fall)
trigger2 = Pos Y != 0
statetype = a

[State 5000, FFB Light]
type = ForceFeedback
trigger1 = anim = 5000
trigger2 = anim = 5010
persistent = 0
time = 6
waveform = square

[State 5000, FFB Medium]
type = ForceFeedback
trigger1 = anim = 5001
trigger2 = anim = 5011
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 5000, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5012
trigger2 = anim = 5002
trigger3 = anim = 5030
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

[State 5000, 6]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0 && !GetHitVar(fall)
value = 5001 ;Stand get-hit (knocked back)

[State 5000, 7]
type = ChangeState
trigger1 = HitShakeOver
value = 5030

;---------------------------------------------------------------------------
; Stand get-hit (knocked back)
[Statedef 5001]
type    = S
movetype= H
physics = S

[State 5001, 1]
type = HitVelSet
trigger1 = Time = 0
x = 1

[State 5001, 2]
type = ChangeAnim
trigger1 = AnimTime = 0
value = 5005 + GetHitVar(animtype) + (GetHitVar(groundtype)=2)*10

[State 5001, 3] ;Stop sliding back
type = VelMul
trigger1 = Time >= GetHitVar(slidetime)
x = .6

[State 5001, 4]
type = VelSet
trigger1 = HitOver
x = 0

[State 5001, 5]
type = DefenceMulSet
trigger1 = HitOver
value = 1

[State 5001, 6]
type = ChangeState
trigger1 = HitOver
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Crouch get-hit (shaking)
[Statedef 5010]
type    = C
movetype= H
physics = N
velset = 0,0

[State 5010, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) != [3,5]
value = 5020 + GetHitVar(animtype)

[State 5010, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5030

[State 5010, 3] ;Anim for HIT_UP/HIT_DIAGUP (only if it exists)
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5047 + GetHitVar(animtype) ;5051 - 4 + type

[State 5010, 4] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5010, 5] ;State type gets set to aerial if getting hit up
type = StateTypeSet
triggerall = Time = 0
trigger1 = GetHitVar(yvel) != 0 || GetHitVar(fall)
trigger2 = Pos Y != 0
statetype = a

[State 5010, 6]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0 && !GetHitVar(fall)
value = 5011 ;Crouch get-hit (knocked back)

[State 5010, 7]
type = ChangeState
trigger1 = HitShakeOver
value = 5030

[State 5010, FFB Light]
type = ForceFeedback
trigger1 = anim = 5020
persistent = 0
time = 6
waveform = square

[State 5010, FFB Medium]
type = ForceFeedback
trigger1 = anim = 5021
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 5010, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5022
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

;---------------------------------------------------------------------------
; Crouch get-hit (knocked back)
[Statedef 5011]
type    = C
movetype= H
physics = C

[State 5011, 1]
type = HitVelSet
trigger1 = Time = 0
x = 1

[State 5011, 2]
type = ChangeAnim
trigger1 = AnimTime = 0
value = 5025 + GetHitVar(animtype)

[State 5011, 3] ;Stop sliding back
type = VelMul
trigger1 = Time >= GetHitVar(slidetime)
x = .6

[State 5011, 4]
type = VelSet
trigger1 = HitOver
x = 0

[State 5011, 5]
type = DefenceMulSet
trigger1 = HitOver
value = 1

[State 5011, 6]
type = ChangeState
trigger1 = HitOver
value = 11
ctrl = 1

;---------------------------------------------------------------------------
; Air get-hit (shaking)
[Statedef 5020]
type    = A
movetype= H
physics = N
velset = 0,0

[State 5020, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) != [3,5]
value = ifelse((GetHitVar(airtype) = 1),5000,5010) + GetHitVar(animtype)

[State 5020, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5030

[State 5020, 3] ;Anim for HIT_UP/HIT_DIAGUP (only if it exists)
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5047 + GetHitVar(animtype) ;5051 - 4 + type

[State 5020, 4] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5020, 5]
type = ChangeState
trigger1 = HitShakeOver
value = 5030

[State 5020, FFB Light]
type = ForceFeedback
trigger1 = anim = 5000
trigger2 = anim = 5010
persistent = 0
time = 6
waveform = square

[State 5020, FFB Medium]
type = ForceFeedback
trigger1 = anim = 5001
trigger2 = anim = 5011
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 5020, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5012
trigger2 = anim = 5002
trigger3 = anim = 5030
trigger4 = anim = [5051,5059]
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

;---------------------------------------------------------------------------
; Air get-hit (knocked away)
[Statedef 5030]
type    = A
movetype= H
physics = N
ctrl = 0

[State 5030, 1]
type = ChangeAnim
trigger1 = Anim != [5000, 5199]
trigger1 = SelfAnimExist(5030)
value = 5030

[State 5030, 2]
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5030, 3]
type = HitVelSet
trigger1 = Time = 0
x = 1
y = 1

[State 5030, 4]
type = ChangeState
triggerall = !HitFall
trigger1 = HitOver
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= Const(movement.air.gethit.groundlevel)
value = 5040 ;HITA_RECOV

[State 5030, 5]
type = ChangeState
triggerall = HitFall
trigger1 = HitOver
trigger2 = Vel Y > 0    ;Hit ground
trigger2 = Pos Y >= Const(movement.air.gethit.groundlevel)
value = 5050 ;HITA_FALL

[State 5030, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 5035 ;Air get-hit (transition)

;---------------------------------------------------------------------------
; Air get-hit (transition)
[Statedef 5035]
type    = A
movetype= H
physics = N

[State 5035, 1]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = SelfAnimExist(5035)
trigger1 = Anim != [5051,5059] ;Not if in hit up anim
trigger1 = Anim != 5090 ;Not if hit off ground anim
value = 5035

[State 5035, 2]
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5035, 3]
type = ChangeState
triggerall = !HitFall
trigger1 = HitOver  ;Hit is over
trigger2 = AnimTime = 0 ;Animation over
trigger3 = Vel Y > 0    ;Hit ground
trigger3 = Pos Y >= Const(movement.air.gethit.groundlevel)
trigger4 = Time = 0     ;No transition anim
trigger4 = Anim != 5035 ;.
value = 5040 ;Air get-hit (recovering in air, not falling)

[State 5035, 4]
type = ChangeState
triggerall = HitFall
trigger1 = HitOver  ;Hit is over
trigger2 = AnimTime = 0 ;Anim is over
trigger3 = Vel Y > 0    ;Hit ground
trigger3 = Pos Y >= Const(movement.air.gethit.groundlevel)
trigger4 = Time = 0     ;No transition anim
trigger4 = Anim != 5035 ;.
value = 5050 ;Air get-hit (falling)

;---------------------------------------------------------------------------
; Air get-hit (recovering in air, not falling)
[Statedef 5040]
type    = A
movetype= H
physics = N

[State 5040, 1]
type = ChangeState
trigger1 = !Alive
value = 5050
ctrl = 0

[State 5040, 2]
type = ChangeAnim
trigger1 = AnimTime = 0
trigger1 = Anim != 5040
trigger2 = Time = 0
trigger2 = Anim != 5035
value = 5040

[State 5040, 3]
type = CtrlSet
trigger1 = HitOver
value = 1

[State 5040, 4]
type = StateTypeSet
trigger1 = HitOver
movetype = I

[State 5040, 5]
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5040, 6]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 52 ;Jump land

;---------------------------------------------------------------------------
; Air get-hit (falling)
[Statedef 5050]
type    = A
movetype= H
physics = N

[state 5050, Change Animation]
type = changeanim
trigger1 = !animtime && anim = 5035
trigger2 = !time && anim != 5035
trigger2 = (anim != [5051, 5059]) && (anim != [5061, 5069]) && anim != [5090, 5099]
value = 5050

[state 5050, Change Animation]
type = changeanim
trigger1 = anim = [5050, 5059]
trigger1 = vel y >= cond(anim = 5050, const720p(4), const720p(-8))
trigger1 = selfanimexist(anim + 10)
value = anim + 10
persistent = 0

[state 5050, Increment Velocity]
type = veladd
trigger1 = 1
y = gethitvar(yaccel)

[state 5050, End State]
type = changestate
trigger1 = vel y > 0
trigger1 = pos y >= cond((anim = [5051, 5059]) || (anim = [5061, 5069]), 0, const(movement.air.gethit.groundlevel))
value = 5100

;---------------------------------------------------------------------------
; Tripped get-hit (shaking)
[Statedef 5070]
type    = A
movetype= H
physics = N
velset = 0,0

[State 5070, 1]
type = ChangeAnim
trigger1 = 1
value = 5070

[State 5070, 2]
type = ChangeState
trigger1 = HitShakeOver
value = 5071

[State 5070, 3]
type = ForceFeedback
trigger1 = time = 0
time = 12
waveform = sinesquare
ampl = 140

;---------------------------------------------------------------------------
; Tripped get-hit (knocked away)
[Statedef 5071]
type    = A
movetype= H
physics = N

[State 5071, 1]
type = HitVelSet
trigger1 = Time = 0
x = 1
y = 1

[State 5071, 2] ;Acceleration
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5071, 3] ;Hit ground
trigger1 = Vel Y > 0
trigger1 = Pos Y >= Const(movement.air.gethit.trip.groundlevel)
type = ChangeState
value = 5110

;---------------------------------------------------------------------------
; Downed get-hit (shaking)
[Statedef 5080]
type    = L
movetype= H
physics = N
velset = 0,0

[State 5080, 1] ;Set default anim
type = VarSet
trigger1 = time = 0
sysvar(2) = ifelse (GetHitVar(yvel) = 0, 5080, 5090)

[State 5080, 2]
type = VarAdd
trigger1 = time = 0
trigger1 = (anim = [5081,5089]) || (anim = [5111,5119])
trigger1 = SelfAnimExist(sysvar(2) + (anim % 10))
sysvar(2) = anim % 10

[State 5080, 3] ;If 5090 doesn't exist, default to 5030
type = VarSet
trigger1 = time = 0
trigger1 = sysvar(2) = 5090
trigger1 = !SelfAnimExist(5090)
sysvar(2) = 5030

[State 5080, 3] ;Freeze
type = ChangeAnim
trigger1 = 1
value = sysvar(2)

[State 5080, 4]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0
value = 5081 ;Downed get-hit (knocked back)

[State 5080, 5]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) != 0
value = 5030 ;Air get-hit (knocked away)

;---------------------------------------------------------------------------
; Downed get-hit (knocked back)
[Statedef 5081]
type    = L
movetype= H
physics = C

[State 5081, 1]
type = HitVelSet
trigger1 = Time = 0
x = 1

[State 5081, 2]
type = VelSet
trigger1 = HitOver
x = 0

[State 5081, 3] ;Don't show hit ground frame
type = VarSet
trigger1 = Time = 0
sysvar(0) = 1

[State 5081, 4]
type = ChangeState
trigger1 = HitOver
value = 5110 ;Downed get-hit (lying down)

;---------------------------------------------------------------------------
; Downed get-hit (hit ground from fall)
[Statedef 5100]
type    = L
movetype= H
physics = N

[State 5100, 2004.04.14 behavior]
type = null;VelSet
trigger1 = Time = 0
trigger1 = GetHitVar(fall.yvel) = 0
trigger1 = vel x < -1
x = -1

[State 5100, EnvShake]
type = FallEnvShake
trigger1 = Time = 0

[State 5100, Var] ;Save fall velocity
type = VarSet
trigger1 = Time = 0
sysvar(1) = floor(vel y)

[State 5100, 2] ;Hit ground anim (normal)
type = ChangeAnim
triggerall = time = 0
trigger1 = (anim != [5051,5059]) && (anim != [5061,5069])
trigger2 = !SelfAnimExist(5100 + (anim % 10))
value = 5100

[State 5100, 3] ;Hit ground anim (for hit up)
type = ChangeAnim
trigger1 = time = 0
trigger1 = (anim = [5051,5059]) || (anim = [5061,5069])
trigger1 = SelfAnimExist(5100 + (anim % 10))
value = 5100 + (anim % 10)

[State 5100, 4]
type = PosSet
trigger1 = Time = 0
y = 0

[State 5100, 5]
type = VelSet
trigger1 = Time = 0
y = 0

[State 5100, 6] ;Reduce speed
type = VelMul
trigger1 = Time = 0
x = 0.75

[State 5100, 7]
type = ChangeState
trigger1 = Time = 0
trigger1 = GetHitVar(fall.yvel) = 0
value = 5110 ;Downed get-hit (lying down)



[State 5110, 7] 
type = Explod 
trigger1 = Time = 0 
trigger1 = !SysVar(0) 
anim = F(60 + (sysvar(1) > Const720p(20)) + (sysvar(1) > Const720p(56))) 
pos = 0,0 
scale = 3,1
sprpriority = 5 
postype = p1 ;p2,front,back,left,right facing = 1 vfacing = 1 bindtime = 1






;[State 5100, 8]
;type = Explod
;trigger1 = Time = 1
;anim = F(60 + (sysvar(1) > Const720p(20)) + (sysvar(1) > Const720p(56)))
;pos = 0, 0
;sprpriority = ifelse (sysvar(1) <= Const720p(56), -10, 10)

[State 5100, 9]
type = HitFallDamage
trigger1 = Time = 3

[State 5100, 10]
type = PlaySnd
trigger1 = Time = 1
value = F7, (sysvar(1) > Const720p(20)) + (sysvar(1) > Const720p(56))

[State 5100, 11]
type = PosFreeze
trigger1 = 1

[State 5100, 12]
type = ChangeState
trigger1 = AnimTime = 0
value = 5101 ;Downed get-hit (bounce off ground)

[State 5100, 13]
type = ForceFeedback
trigger1 = Time = 0
waveform = sinesquare
ampl = 128,-3,-.2,.005
time = 20

;---------------------------------------------------------------------------
; Downed get-hit (bounce off ground)
[Statedef 5101]
type    = L
movetype= H
physics = N

[State 5101, 1] ;Coming hit ground anim (normal)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim != [5101,5109]
trigger2 = !SelfAnimExist(5160 + (anim % 10))
value = 5160

[State 5101, 2] ;Coming hit ground anim (for hit up)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim = [5101,5109]
trigger1 = SelfAnimExist(5160 + (anim % 10))
value = 5160 + (anim % 10)

[State 5101, 3]
type = HitFallVel
trigger1 = Time = 0

[State 5101, 4]
type = PosSet
trigger1 = Time = 0
y = Const(movement.down.bounce.offset.y)

[State 5101, 5]
type = PosAdd
trigger1 = Time = 0
x = Const(movement.down.bounce.offset.x)

[State 5101, 6] ;Acceleration
type = VelAdd
trigger1 = 1
y = Const(movement.down.bounce.yaccel)

[State 5101, 7] ;Hit ground
trigger1 = Vel Y > 0
trigger1 = Pos Y >= Const(movement.down.bounce.groundlevel)
type = ChangeState
value = 5110

;---------------------------------------------------------------------------
; Downed get-hit (lying down)
[Statedef 5110]
type    = L
movetype= H
physics = N

[State 5110, 7] 
type = Explod 
trigger1 = Time = 0 
trigger1 = !SysVar(0) 
anim = F(60 + (sysvar(1) > Const720p(20)) + (sysvar(1) > Const720p(56))) 
pos = 0,0 
scale = 3,1
sprpriority = 5 
postype = p1 ;p2,front,back,left,right facing = 1 vfacing = 1 bindtime = 1


[State 5110, EnvShake]
type = FallEnvShake
trigger1 = Time = 0

[State 5110, 1] ;For hit up/up-diag type (from state 5081)
type = ChangeAnim
persistent = 0
trigger1 = SelfAnimExist(5110 + (anim % 10))
trigger1 = anim = [5081,5089]
value = 5110 + (anim % 10)

[State 5110, 2] ;Hit ground anim (normal)
type = ChangeAnim
triggerall = time = 0
triggerall = anim != [5110,5119] ;Not already changed anim
trigger1 = anim != [5161,5169]
trigger2 = !SelfAnimExist(5170 + (anim % 10))
value = 5170

[State 5110, 3] ;Hit ground anim (for hit up)
type = ChangeAnim
triggerall = time = 0
triggerall = anim != [5110,5119] ;Not already changed anim
trigger1 = anim = [5161,5169]
trigger1 = SelfAnimExist(5170 + (anim % 10))
value = 5170 + (anim % 10)

[State 5110, 4]
type = HitFallDamage
trigger1 = Time = 0

[State 5110, 5]
type = PosSet
trigger1 = Time = 0
y = 0

[State 5110, Var] ;Get fall velocity
type = VarSet
trigger1 = Time = 0
trigger1 = GetHitVar(fall.yvel) != 0
sysvar(1) = floor(vel y)

[State 5110, 6]
type = PlaySnd
trigger1 = Time = 0
trigger1 = !SysVar(0)
value = F7, (sysvar(1) > Const720p(20)) + (sysvar(1) > Const720p(56))

;[State 5110, 7]
;type = Explod
;trigger1 = Time = 0
;trigger1 = !SysVar(0)
;anim = F(60 + (sysvar(1) > Const720p(20)) + (sysvar(1) > Const720p(56)))
;pos = 0, 0
;sprpriority = ifelse (sysvar(1) <= Const720p(56), -10, 10)

[State 5110, 8]
type = VelSet
trigger1 = Time = 0
y = 0

[State 5110, 9] ;For hit up type
type = ChangeAnim
persistent = 0
triggerall = anim = [5171,5179]
triggerall = SelfAnimExist(5110 + (anim % 10))
trigger1 = AnimTime = 0
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground anim
value = 5110 + (anim % 10)

[State 5110, 10] ;For normal
type = ChangeAnim
persistent = 0
triggerall = Anim != [5111,5119]
trigger1 = AnimTime = 0
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground frame
value = 5110

[State 5110, 11] ;If just died
type = ChangeState
triggerall = !alive
trigger1 = AnimTime = 0
trigger2 = SysVar(0) ;SysVar(0) = 1 avoids hit ground frame
trigger3 = Anim = [5110,5119]
value = 5150

[State 5110, 12]
type = VarSet
trigger1 = SysVar(0)
trigger1 = Time = 0
sysvar(0) = 0

[State 5110, 13] ;Friction
type = VelMul
trigger1 = 1
x = 0.85

[State 5110, 14] ;Friction
type = VelSet
trigger1 = abs(Vel x) < Const(movement.down.friction.threshold)
persistent = 0
x = 0

[State 5110, 15]
type = ForceFeedback
trigger1 = alive
trigger1 = Time = 0
time = 8
ampl = 240
waveform = sine

[State 5110, 16]
type = ForceFeedback
trigger1 = !alive
trigger1 = Time = 0
ampl = 200, 7, -.467
time = 30
waveform = sine

;---------------------------------------------------------------------------
; Downed get-hit (getting up)
[Statedef 5120]
type    = L
movetype= I
physics = N

[State 5120, 1a] ;Get up anim (normal)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim != [5111,5119]
trigger2 = !SelfAnimExist(5120 + (anim % 10))
value = 5120

[State 5120, 1b] ;Get up anim (for hit up/diag-up)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim = [5111,5119]
trigger1 = SelfAnimExist(5120 + (anim % 10))
value = 5120 + (anim % 10)

[State 5120, 2]
type = VelSet
trigger1 = Time = 0
x = 0

[State 5120, 3]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 5120, 4]
type = HitFallSet
trigger1 = AnimTime = 0
value = 1

[State 5120, 5] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = AnimTime = 0
value = , NT,ST,HT
time = 20

[State 5120, 6] ;Can't be hit right after getting up (short time)
type =NotHitBy
trigger1 = AnimTime = 0
value2 = SCA
time = 6

[State 5120, 7]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Downed get-hit (lying defeated)
[Statedef 5150]
type    = L
movetype= H
physics = N
sprpriority = -3
ctrl = 0


[state 5150, Change Animation]
type = changeanim
trigger1 = !time
trigger1 = anim != [5140, 5159]
trigger1 = anim != [5110, 5119]
value = 5110 + 40 * (anim = 5950)

[state 5150, Multiply Velocity]
type = velmul
trigger1 = 1
x = 0.85

[state 5150, Set Velocity]
type = velset
trigger1 = abs(vel x) < const(movement.down.friction.threshold)
x = 0.0
persistent = 0



[state 5150, Vulnerability]
type = nothitby
trigger1 = 1
value = SCA
time = 1

; Disallow helpers to survive in this state
[state 5150, Transparency]
type = trans
trigger1 = ishelper
trans = addalpha
alpha = 256 - 16 * time, 16 * time

[state 5150, Destroy Helper]
type = destroyself
trigger1 = ishelper
trigger1 = time > 16
[State 5150, 6] ;Friction
type = VelMul
trigger1 = 1
x = 0.85


[State 5150, 8]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

;---------------------------------------------------------------------------
; Air get-hit (fall recovery on ground; still falling)
[Statedef 5200]
type    = A
movetype= H
physics = N

[State 5200, 1] ;Change anim if done with transition
type = ChangeAnim
trigger1 = Anim = 5035
trigger1 = AnimTime = 0
value = 5050

[State 5200, 2]
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5200, 3]
type = SelfState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= Const(movement.air.gethit.groundrecover.groundlevel)
value = 5201

;---------------------------------------------------------------------------
; Air get-hit (fall recovery on ground)
[Statedef 5201]
type    = A
movetype= H
physics = A
anim = 5200

[State 5201, 1] ;Turn if not facing opponent
type = Turn
trigger1 = Time = 0
trigger1 = p2dist X < Const720p(-20)

[State 5201, 2]
type = VelSet
trigger1 = Time = 0
x = Const(velocity.air.gethit.groundrecover.x)
y = Const(velocity.air.gethit.groundrecover.y)

[State 5201, 3]
type = PosSet
trigger1 = Time = 0
y = 0

[State 5201, 4]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 5201, 5] ;Blink white
type = PalFX
trigger1 = Time = 0
time = 3
add = 128,128,128 ;256,256,256

[State 5201, 6]
type = Explod
trigger1 = Time = 0
anim = F60
pos = 0, -floor(vel y)
sprpriority = -10

;---------------------------------------------------------------------------
; Air get-hit (fall recovery in air)
[Statedef 5210]
type    = A
movetype= I
physics = N
anim = 5210
ctrl = 0

[State 5210, 1] ;Blink white
type = PalFX
trigger1 = Time = 0
time = 3
add = 128,128,128

[State 5210, 1]
type = PosFreeze
trigger1 = Time < 4

[State 5210, 2] ;Turn if not facing opponent
type = Turn
trigger1 = Time = 0
trigger1 = p2dist X < Const720p(-80)

[State 5210, 1.0 behavior 1]
type = VelMul
trigger1 = Time = 4
x = Const(velocity.air.gethit.airrecover.mul.x)
y = Const(velocity.air.gethit.airrecover.mul.y)

[State 5210, 1.0 behavior 2]
type = VelAdd
trigger1 = Time = 4
x = Const(velocity.air.gethit.airrecover.add.x)
y = Const(velocity.air.gethit.airrecover.add.y)

[State 5210, 2002.04.14 behavior 1]
type = null;VelMul
trigger1 = Time = 4
x = .8
y = .8

[State 5210, 2002.04.14 behavior 2]
type = null;VelAdd
trigger1 = Time = 4
x = 0 
y = -4.5

[State 5210, 2002.04.14 behavior 3]
type = null;VelMul
trigger1 = Time = 4
trigger1 = Vel Y > 0
y = .5

[State 5210, 2002.04.14 behavior 4]
type = null;VelAdd
trigger1 = Time = 4
trigger1 = Vel Y > -3
y = -2

[State 5210, 2002.04.14 behavior 5]
type = null;VelAdd
trigger1 = Time = 4
trigger1 = Vel Y > -2
y = -1

[State 5210, 2] ;Go up
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holdup"
y = Const(velocity.air.gethit.airrecover.up)

[State 5210, 2] ;Go down
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holddown"
y = Const(velocity.air.gethit.airrecover.down)

[State 5210, 2] ;Go fwd
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holdfwd"
x = Const(velocity.air.gethit.airrecover.fwd)

[State 5210, 2] ;Go back
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holdback"
x = Const(velocity.air.gethit.airrecover.back)

[State 5210, 3]
type = NotHitBy
trigger1 = Time = 0
value = SCA
time = 15

[State 5210, 4]
type = CtrlSet
trigger1 = Time = 20
value = 1

[State 5210, 5]
type = VelAdd
trigger1 = Time >= 4
y = Const(movement.air.gethit.airrecover.yaccel)

[State 5210, 5] ;Land on ground
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 52 ;Jump land
ctrl = 1

;==============================================================
;========================================================Syn===
;==============================================================



;DRAMATIC KO PAUSE
[Statedef 9944]
type = s
movetype = i
physics = n

[State 9944, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow
flag2 = invisible
ignorehitpause = 1
[State 9944, NHB]
type = NotHitBy
trigger1 = 1
value = SCA




[State 9944, Dramatic KO Helper]
type = helper
triggerall = (root,alive || enemy,alive)
trigger1 = roundstate = 3 && (root,life <= 0 || enemy,life <= 0)
helpertype = Normal
id = 9955
pos = 0,0
postype = p1
name = "K.O."
stateno = 9955
supermovetime = 9999999999
pausemovetime = 9999999999
persistent = 0
ignorehitpause = 1
;==============================================================
;=======================================================Syn====
;==============================================================
;DRAMATIC KO PAUSE HELPER
[Statedef 9955]
type = s
movetype = i
physics = n

[State 9955, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow
flag2 = invisible
flag3 = nokoslow;<------------optional
ignorehitpause = 1

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

[State 9955, pause]
type = Pause
trigger1 = 1
time = 0;<---adjust to your likings
ignorehitpause = 1
persistent = 0

[State 9955, DestroySelf]
type = DestroySelf
trigger1 = time >= 40;<---make the time match the time in the pause code above

;===========================================================================
;===============================< -2 STATES >=================================
;===========================================================================
[Statedef -2]


[State -2, ]
Type = VarSet
Trigger1 = P2StateType != L
V = 14
Value = 0




;costom state damage id
[State -2]
Type = Helper
triggerall = numhelper(22222) = 0
TriggerAll = movetype = h
trigger1 = stateno !=[5000,5300]
HelperType = Normal
Name = "catch 22"
ID = 22222
StateNo = 22222
Pos = 0,0
PosType = P1
Facing = 1
KeyCtrl = 0
OwnPal = 0

;ai weakness policy
[State -2, AssertSpecial]
type = AssertSpecial
triggerall = Var(40) >= 2000
trigger1 = ailevel >= 7
flag = noko

;ai weakness policy
[State -2, ChangeState]
type = ChangeState
triggerall = Var(40) >= 2000
trigger1 = ailevel >= 7
trigger1 = stateno =! 7777
trigger1 = movetype = h
value =7777
ctrl = 0


[State -2, remappal]
type = remappal
trigger1 = 1
source = 1,0
dest = 1,palno

[State -2, PowerAdd]
type = PowerAdd
triggerall = numhelper
triggerall = !numhelper(37132)   ;no power add when stars are shooting
triggerall = numhelper(35499)    ;energy shield
trigger1 = helper(35499),anim = 4065
trigger1 = time%5 =1
value = 10


[State -2, PowerAdd]
type = PowerAdd
triggerall = palno = 12
trigger1 = time%5 =1
value = 10

[State -2, PowerAdd]
type = lifeAdd
triggerall = palno = 12
trigger1 = time%5 =1
value = 1

[State -2, PowerAdd]
type = PowerAdd
triggerall = time%5 =1
triggerall = !numhelper(37132)
trigger1 = abs(vel x)  >= 1 && movetype != h
trigger2 = life <= lifemax/3
value = 3

[State -2, NotHitBy]
type = NotHitBy
triggerall = numhelper
triggerall = !numexplod(17401)   ;super
triggerall = !numhelper(4000)    ;subsitute  helper
triggerall = !numhelper(37499)   ;tornado is stronger
trigger1 = numhelper(35499)
value = ,NP,SP,HP
time = 1


[State -2, NotHitBy]
type = notHitBy
triggerall = numhelper
triggerall = !numexplod(17401)   ;super
triggerall = !numhelper(4000)    ;subsitute  helper
trigger1 = numhelper(37499) 
value =  ,AP,AT
time = 1  

[State -2, NotHitBy]
type = NotHitBy
trigger1 = numexplod(17401)
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
time = 1

;armor
[State -2]
Type = Helper
TriggerAll = numHelper(7050) || palno = 12
TriggerAll = NumHelper(4900) = 0
TriggerAll = !IsHelper
TriggerAll = RoundState = 2
;Trigger1 = Stateno = 7777 ;Add your specials' stateno here
Trigger1 = 1 
HelperType = Normal
Name = "superarmor"
ID = 4900
StateNo = 4900
Pos = 0,0
PosType = P1
Facing = 1
KeyCtrl = 0
OwnPal = 0

;need for dbl jump + air dash
[state -2, System Helper]
type = helper
trigger1 = !numhelper(40000)
name = "System"
ID = 40000
stateno = 40000
postype = p1
ownpal = 0
keyctrl = 0
size.xscale = 1.0
size.yscale = 1.0
supermovetime = 0
pausemovetime = 0
ignorehitpause = 1

[State -2, Helper]
type = Helper 
TriggerAll = !numexplod(70501) 
TriggerAll = NumHelper(24000) = 0 && palno != 12
trigger1= 1
name = "weakness gauge"
ID = 24000
stateno =24000
pos = 420,660
postype = left    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 999999
pausemovetime = 999999
size.xscale = .5
size.yscale = .5


[State -2, PalFXWiz]
type = PalFX
triggerall = numexplod(18005) ;|| numexplod(17401)
trigger1 = !(GameTime % 2)
time =1 
add = -104,-104,7
mul = 256,256,256
sinadd = 56,56,0,10
invertall = 0
color = 0
ignorehitpause = 1

[state -2, Status: In Own State]
type = varset
trigger1 = 1
var(39) = 0
ignorehitpause = 1

;armor
[State 0, NotHitBy]
type = NotHitBy
TriggerAll = !IsHelper
trigger1 = numhelper(4900) > 0
value = SCA,NA,SA,HA,NP,SP,HP
time = 3
ignorehitpause =  1



;--------------------------------------------------------------------------------------------------Weakness Meter Bar---------------------------------------------------------------------

;var(40) :damage points
;var(17) moved to 27 ;burst limit


[State -2, VarSet]
type = VarSet
trigger1 = roundstate = 1
trigger2 = numhelper(7050)
trigger3 = numexplod(70501)
v =40    
value = 0

[State -2] 
type = VarAdd 
triggerall = (stateno != [740,771])
triggerall = Var(40) <= 2000
Trigger1 = movetype = h 
var(40) = Floor(gethitvar(damage) *3.5)
ignorehitpause = 1
persistent = 0



[State -2] 
type = VarAdd 
triggerall = Var(40) <= 2000
Trigger1 = movetype = h 
Trigger1 = TIME%5 =1
var(40) = 2
ignorehitpause = 1

[State -2] 
type = VarAdd
triggerall = Var(40) <= 1999
triggerall = Var(40) >= 1
Trigger1 = movetype != h 
var(40) = -1
ignorehitpause = 1

;max hurt points
[State -2, VarSet]
type = VarSet
trigger1 = var(40) > 2001
v =40    
value = 2000

;min hurt points
[State -2, VarSet]
type = VarSet
trigger1 = var(40) < 0
v =40    
value = 0









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


[State -3];Burst use frequency
type = VarSet
trigger1 = var(27) = 0
var(27) = 1    ;By changing this number (initial setting 1) you can change the number of bursts that can be used for one round



;-----------------------------------------------------------------------------------------------end solar-------------------------------------------------------------------------------









[State 0, PalFXWiz]
type = PalFX
trigger1 = Var(53) =0
trigger1 = numexplod(7001)
time = 1
add = 0,0,0
mul = 256,256,256
sinadd = 0,0,0,1
invertall = 0
color = 256


[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = var(13) = 0 
id = 1490

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = var(13) = 0
id = 1491

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = var(13) = 0
id = 1430

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = var(13) = 0
id = 1431

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = var(13) = 0
id = 14801
ignorehitpause = 1

[State 3000,02]
type = BGPalfx
trigger1 = stateno =[4250,4260]
;trigger1 = movetype != h
time = 10
mul = 0,0,0
ignorehitpause = 1




;AI tweak
[State -2, Finish]
type = ScreenBound
trigger1 =numhelper
trigger1 =numhelper(22500) =1
value = 1
MoveCamera = 1,0
IgnoreHitPause = 1



;AI tweak
[State -2, Finish]
type = ScreenBound
triggerall = (Life <= 0) || (!Alive) || (Lose)
trigger1 = (StateNo = 5150) && (RoundState = 4)
value = 0
MoveCamera = 0,0
IgnoreHitPause = 1

[State -2,screen]
type=ScreenBound
trigger1=p2stateno=4020&&p2movetype=H
value=p2bodydist x < 30 && BackEdgeDist < 30


[State -2,screen]
type=ChangeState
triggerall=roundstate=2
triggerall=Movetype != H && Stateno != 7827
trigger1=BackEdgeDist < -10 -const(size.ground.front)-const(size.ground.back)
trigger1=StateType != A
value=7827

[State -2, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = nojugglecheck
IgnoreHitPause = 1

[State -2, Hit Detection]
type = varset
trigger1 = movecontact = 1 && var(30) < 0
var(30) = hitpausetime
ignorehitpause = 1

[State -2, HitSound]
type = playsnd
trigger1 = movecontact = 1 && var(30) = hitpausetime
trigger1 = movehit = 1 && var(31) >= 0
value = 5000, var(31)
channel = 2
ignorehitpause = 1

[State -2, GuardSound]
type = playsnd
trigger1 = movecontact = 1 && var(30) = hitpausetime
trigger1 = moveguarded = 1 && var(32) >= 0
value = 0, 10
channel = 2
ignorehitpause = 1

[State -2, Sparks]
type = helper
triggerall = movecontact = 1 && var(30) = hitpausetime
trigger1 = movehit = 1 && numenemy
trigger1 = var(33) = 8010 || var(33) = 8011 || var(33) = 8012 || var(33) = 8013 || var(33) = 8014 || var(33) = 8001
trigger2 = moveguarded = 1 && numenemy
trigger2 = var(34) = 8000 || var(34) = 8001
trigger3 = MoveHit = 1 && NumEnemy
trigger3 = var(33) = 8015 || var(33) = 8016 || var(33) = 8017
stateno = ifelse(moveguarded, var(34), var(33))
ID = 8000
name = "Spark"
postype = p1
pos = ifElse(P2Dist x < 0, 0, ifElse(P2Dist x < var(35), ceil(P2Dist x), var(35))), var(36)
facing = -1
ownpal = 1
pausemovetime = 65535
supermovetime = 65535
ignorehitpause = 1

[State -2, Counter FX]
type = helper
triggerAll = movehit = 1 && var(30) = hitpausetime
triggerAll = numenemy && var(9)
trigger1 = !(hitdefattr = SCA, AT) && (enemynear, movereversed != 1)
trigger2 = (EnemyNear, MoveReversed != 1) && StateNo = [1100,1299]
stateno = 8290
ID = 8290
name = "Counter FX"
postype = p1
pos = ifElse(P2Dist x < 0, 0, ifElse(P2Dist x < var(35), ceil(P2Dist x), var(35))), var(36)
facing = -1
ownpal = 1
pausemovetime = 255
supermovetime = 255
ignorehitpause = 1

[State -2, Counter Flag]
type = varset
trigger1 = numenemy
var(9) = (enemynear, movetype = A)
ignorehitpause = 1

[State -2, Hit Detection]
type = varset
trigger1 = 1
var(30) = -1

[State -2, Hit Detection]
type = varrangeset
trigger1 = movetype = I
trigger2 = movetype = H && time
first = 30
last = 36
value = -1
ignorehitpause = 1

[State -2, P2 Facing]
type = targetfacing
trigger1 = movecontact = 1 && numtarget
trigger1 = !(target, hitshakeover) && !(target, hitfall) && (target, time <= 1)
value = ifelse(p2dist x >= 0, -1, 1)
ignorehitpause = 1

[State -2, P2 Safe Fall]
type = targetstate
trigger1 = numtarget = 1
trigger1 = target, command = "recovery"
trigger1 = target, pos y >= -48 && target, vel y > 0
trigger1 = target, alive && target, hitfall && target, gethitvar(fall.recover)
trigger1 = target, stateno = 5030 || target, stateno = 5035 || target, stateno = 5050 || target, stateno = 5071
value = 5205
ignorehitpause = 1

[State -2, Prevent Guard]
type = assertspecial
trigger1 = var(17) > 0
trigger1 = var(17) := (var(17) -1)
flag = unguardable
ignorehitpause = 1

[State -2, Hitcount]
type = varadd
trigger1 = !IsHelper
trigger1 = movehit = 1
trigger1 = !HitPauseTime
trigger1 = !(hitdefattr = SCA, AT)
var(13) = 1

[State -2, Hitcount Reset]
type = varset
triggerall =(enemy, stateno != [480, 481]) || (enemy, movetype != H)
trigger1 = numenemy && var(13)
trigger1 = (enemynear, movetype != H) && (enemynear, stateno != 5300)
var(13) = 0
ignorehitpause = 1

[State -2, Juggle Count]
type=varadd
trigger1= movehit=1
trigger1= !(hitdefattr=SCA,AT)
var(15)=1

[State -2, Juggle Reset Single]
type = varset
triggerall = numenemy = 1 && var(15)
trigger1 = (enemy, statetype != A) && (enemy, stateno != [5100, 5109]) && (enemy, time >= 0)
trigger2 = (enemy, movetype != H) || (enemy, stateno = [120, 155]) || (enemy, ctrl)
var(15) = 0
ignorehitpause = 1

[State -2, Juggle Reset Simul]
type = varset
triggerall = numenemy >= 2 && var(15)
trigger1 = (enemynear(0), statetype != A) && (enemynear(0), time >= 0)
trigger2 = (enemynear(0), movetype != H) || (enemynear(0), stateno = [120, 155]) || (enemynear(0), ctrl)
trigger3 = (enemynear(1), statetype != A) && (enemynear(0), time >= 0)
trigger4 = (enemynear(1), movetype != H) || (enemynear(0), stateno = [120, 155]) || (enemynear(0), ctrl)
var(15) = 0
ignorehitpause = 1

[State -2, Free Juggling]
type = varset
trigger1 = roundstate != 2
var(15) = 0
ignorehitpause = 1

[State -2, Juggle Flag]
type = varset
trigger1 = numenemy && !var(16)
trigger1 = (enemynear, stateno = 5040) && !(enemynear, ctrl)
var(16) = 1
ignorehitpause = 1

[State -2, Juggle Flag Reset Single]
type = varset
triggerall = numenemy = 1 && var(16)
trigger1 = (enemy, movetype != H) && (enemy, stateno != 5040)
trigger2 = !(enemy, hitshakeover) || (enemy, statetype = L) || (enemy, ctrl)
var(16) = 0
ignorehitpause = 1

[State -2, Juggle Flag Reset Simul]
type = varset
triggerall = numenemy >= 2 && var(16)
trigger1 = (enemynear(0), movetype != H) && (enemynear(0), stateno != 5040)
trigger2 = !(enemynear(0), hitshakeover) || (enemynear(0), statetype = L) || (enemynear(0), ctrl)
trigger3 = (enemynear(1), movetype != H) && (enemynear(1), stateno != 5040)
trigger4 = !(enemynear(1), hitshakeover) || (enemynear(1), statetype = L) || (enemynear(1), ctrl)
var(16) = 0
ignorehitpause = 1

[State -2, Custom Combo End]
type = varset
trigger1 = var(20) < 0
trigger2 = movetype = H
trigger3 = roundstate != 2
trigger4 = (stateno = [3000, 4999])
var(20) = 0
ignorehitpause = 1

[State -2, Custom Combo Time]
type = varadd
trigger1 = var(20) > 0
var(20) = -1
ignorehitpause = 1

[State -2, Custom Combo Asserts]
type = assertspecial
trigger1 = var(20) > 0
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard
ignorehitpause = 1

[State -2, Custom Combo PalFX]
type = palfx
trigger1 = var(20) > 60
time = 2
add = 32 + ceil(sin(var(20) / 16.0 * pi) * 32), 32 + ceil(sin(var(20) / 16.0 * pi) * 32), 32 + ceil(sin(var(20) / 16.0 * pi) * 32)
ignorehitpause = 1

[State -2, Custom Combo PalFX]
type = palfx
trigger1 = var(20) = [1, 60]
time = 2
add = 64 + ceil(sin(var(20) / 8.0 * pi) * 64), 64 + ceil(sin(var(20) / 8.0 * pi) * 64), 64 + ceil(sin(var(20) / 8.0 * pi) * 64)
ignorehitpause = 1

[State -2, Throws Allowed]
type = varset
trigger1 = enemynear, movetype != H
trigger1 = enemynear, stateno != 140
trigger1 = (enemynear, ctrl && enemynear, time >= 1) || (enemynear, time >= 8)
trigger2 = enemynear, movetype = A
trigger3 = (enemynear, stateno != [0, 52]) && (enemynear, stateno != [120, 155]) && (enemynear, stateno != [5000, 5120])
trigger4 = var(20) || var(21) || var(22)
var(38) = 0

[State -2, Special/Super Throws Allowed]
type = VarSet
trigger1 = 1
var(43) = 0

[State -2, Special/Super Throws Disallowed]
type = VarSet
triggerall = NumEnemy
trigger1 = EnemyNear, StateNo = [150,155]
trigger2 = (EnemyNear, StateNo = 51 || EnemyNear, StateNo = 140) && (EnemyNear, PrevStateNo = [150, 155])
trigger3 = (EnemyNear, StateNo = [5020,5040]) && !(EnemyNear, HitFall)
trigger4 = ((EnemyNear, StateNo = 0) || (EnemyNear, StateNo = 52)) && (EnemyNear, PrevStateNo = [5000,5040]) && ((EnemyNear, Time <= 0) || !(EnemyNear, Ctrl))
trigger5 = (EnemyNear, StateNo = 0) && (EnemyNear, PrevStateNo = 52) && ((EnemyNear, Time <= 0) || !(EnemyNear, Ctrl))
trigger6 = (EnemyNear, StateNo = 40) && (EnemyNear, Time >= 1 || EnemyNear, PrevStateNo = 0 || EnemyNear, PrevStateNo = 52)
trigger7 = EnemyNear, StateNo = 5110
var(43) = 1
ignoreHitPause = 1


[State -2, Dampener]
type = VarSet
trigger1 = 1
fvar(10) = ifElse(var(13) < 6, 24, ifElse(var(13) >= 23, 1, 29 - var(13))) / 24.0
ignoreHitPause = 1

[State -2, Dampener - Custom Combo]
type = varset
trigger1 = var(20)
fvar(10) = 0.72 * (10 - ifElse(var(13) >= 10, 10, var(13))) / 10.0
ignorehitpause = 1

[State -2, Dampener - Custom Combo Limiter]
type = varset
trigger1 = var(20)
trigger1 = StateNo = 250
fvar(10) = ifElse(var(13), 0, 0.72)
ignorehitpause = 1

[State -2, Dampener - Supers]
type = varset
trigger1 = (stateno = [3000, 4999])
fvar(10) = ifelse(var(22), 0.6, ifelse(var(21), 0.8, 1.0))
ignorehitpause = 1

[State -2, Dampener Limit]
type = varset
trigger1 = fvar(10) < 0
fvar(10) = 0
ignorehitpause = 1

[State -2, Root Dampener]
type = varset
trigger1 = 1
fvar(11) = fvar(10) * ifelse(var(9), 2, 1)
ignorehitpause = 1
;1.2


[State -2, MAX Mode End]
type = VarSet
triggerall = (stateno != [4000,4999]) && stateno != 775 
trigger1 = var(53) < 0
trigger2 = RoundState != 2
trigger3 = !Alive
var(53) = 0
ignoreHitPause=1

[State -2, MAX Mode Time]
type = VarAdd
triggerall = (stateno != [4000,4999])
triggerall = stateno != 851
trigger1 = var(53) > 0
ignorehitpause = 1
var(53) = -1







[State 0, Helper]
type = Helper
triggerall = numhelper(9001) =0
trigger1 = stateno = 32000
trigger1 = movetype != h
helpertype = normal ;player
name = "darkness"
ID = 9001
stateno = 9001
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 99999
pausemovetime = 99999
size.xscale = 1111
size.yscale = 1111
;size.ground.back = 
;size.ground.front = 
;size.air.back = 
;size.air.front = 
;size.height = 
;size.proj.doscale = 
;size.head.pos = , 
;size.mid.pos = , 
;size.shadowoffset = 
ignorehitpause = 1
;persistent = 


;Spent Shadowform
[State -2, MAX Mode Time]
type = Varset
triggerall = var(53) > 0
;Midnight Dance missed
trigger1 = prevstateno = 4251
;Midnight Dance Finsh
trigger2 = prevstateno = 4261
trigger3 = prevstateno = 4259
;Card of Thorns Finsh
trigger4 = prevstateno = 10000
trigger5 = prevstateno = 11000

ignorehitpause = 1
var(53) = 0






[State -2, MAX Mode PowerSet]
type = PowerSet
trigger1 = var(53) > 0
ignorehitpause = 1
value = var(24)


[State -2, Shadowform PalFX]
type = PalFX
trigger1 = numhelper(7000) 
;!(GameTime % 2) &&
time =var(53);2000
add = 0,-200,-200
mul = 256,256,256
sinadd = 40,80,40,10
invertall = 0
color = 0











 [State -2, AssertSpecial] ; added damage taken for Solar charge %30
    type = AssertSpecial
    triggerall = Alive && MoveType = H
    triggerall = (FVar(8) - life) > 0
    trigger1 = life + (floor((.7 - 1.0) * ifElse((FVar(8)-life) < life, -(FVar(8) - life),0))) > 0
    ignorehitpause = 1
    flag = noKO

 [State -2, DefenseMulSet]  ; added damage taken for Solar charge
    type = LifeAdd
    triggerall = Alive && MoveType = H
    trigger1 = (FVar(8) - life) > 0
    value = floor( (.7 - 1.0) * ifElse((FVar(8)-life) < life, -(FVar(8) - life),0))


     
 [State -2, DefenseMulSet]  ;damage reduction vs  attacks in SF
    type = null;LifeAdd
    triggerall = Alive && MoveType = H
    trigger1 = (FVar(8) - life) > 0
    triggerall = var(53)
    value = floor( (.7 - 1.0) * ifElse((FVar(8)-life) < life, -(FVar(8) - life),0))



 [State -2, AssertSpecial] ; damage reduction vs  attacks in SF
    type = AssertSpecial
    triggerall = MoveType = H
    triggerall = ailevel >= 7 && numenemy
    triggerall = var(40) >= 2000
    trigger1 = numexplod(70501) = 0
    ignorehitpause = 1
    flag = noKO




[State -2, Life Holder];special thanks to Jesuszilla
type = VarSet
trigger1 = 1
fvar(8) = Life
ignorehitpause = 1

[State -2, Voice Pos]
type = sndpan
trigger1 = 1
channel = 0
pan = 0
ignorehitpause = 1

[State -2, collapse/cheese kill snd]
type = playsnd
trigger1 = StateNo != 5950
trigger1 = Anim = 5950 || Anim = 5955
trigger1 = animelem = 10
value = f7, 0

[State -2, collapse/cheese kill FX]
type = explod
trigger1 = StateNo != 5950
trigger1 = Anim = 5950 || Anim = 5955
trigger1 = animelem = 10
anim = f60
postype = p1
pos = 0, 0
sprpriority = -3

[State -2, guard crush/throw escape voice]
type = playsnd
trigger1 = Anim = 5910 || Anim = 5920 || Anim = 5930
trigger1 = animelemtime(1) = 1
trigger2 = Anim = 5940 || Anim = 5945
trigger2 = AnimElem = 2 && StateNo != 890
value = 5940,0
channel = 0
ignoreHitPause = 1

[State -2, Debug]
type = DisplayToClipboard
trigger1 = 1
text = "AI = %d Attack = %f Hits = %d Juggle = %d"
params = AILevel, fvar(11), var(13),var(40) ;var(47);var(44);
ignoreHitPause = 1

[State -2, Debug]
type = AppendToClipboard
trigger1 = 1
text = "\np2bodydist x = %f p2dist y = %f head pos y = %f"
params = p2bodydist x, p2dist y, EnemyNear, const(size.head.pos.y)
text = "\nBy You"
ignoreHitPause = 1

[State -2, Wall Impact Dust]
type = Helper
triggerall=!numhelper(8111) && numenemy
trigger1=P2movetype=H && p2stateno=1666 && enemy,time=1
;trigger2=P2movetype=H && p2stateno=4061 && enemy,time=1
stateNo = 8111
ID = 8111
name = "Wall Impact Dust"
posType = P2
facing = -1
pos= floor(-5*const(size.xscale)),ceil(-70*const(size.yscale))
ownPal = 1
ignorehitpause=1

[State -2, Ground Impact Dust]
type = Helper
triggerall=!numhelper(8112)  && numenemy
trigger1=P2movetype=H && p2stateno=810 && enemy,time=1
stateNo = 8112
ID = 8112
name = "Heavy Ground Impact Dust"
posType = P2
facing = -1
pos = 0,-10
ownPal = 1
ignorehitpause=1
persistent = 0

[State -2, Ground Impact Dust]
type = Helper
triggerall=!numhelper(8112)  && numenemy
trigger1=P2movetype=H && p2stateno=2116 && enemy,time=1
stateNo = 8112
ID = 8112
name = "Heavy Ground Impact Dust"
posType = P2
facing = -1
pos = 0,-10
ownPal = 1
ignorehitpause=1
persistent = 0


[State -2, Ground Impact Dust];Not used, but still added just incase...
type = Helper
triggerall=numenemy;!numhelper(8112)  && numenemy
trigger1=P2movetype=H && p2stateno=18011 && enemy,time=29
trigger2=P2movetype=H && p2stateno=18011 && enemy,time=64
trigger3=P2movetype=H && p2stateno=18011 && enemy,time=95
stateNo = 8113
ID = 8113
name = "Heavy Ground Impact Dust"
posType = P2
facing = -1
pos = 0,10
ownPal = 1
ignorehitpause=1
persistent = 0

[State -2, Ground Impact Dust];Not used, but still added just incase...
type = Helper
triggerall=numenemy;!numhelper(8112)  && numenemy
trigger1=P2movetype=H && p2stateno=18011 && enemy,time=147
stateNo = 8112
ID = 8112
name = "Heavy Ground Impact Dust"
posType = P2
facing = -1
pos = 0,10
ownPal = 1
ignorehitpause=1
persistent = 0









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

[State -2, DRAMATIC KO HELPER]
type = helper
trigger1 = teammode = single || teammode = turns
trigger1 = enemy, teammode = single || enemy, teammode = turns
trigger1 = roundstate = 2 && !numhelper(9944)
id = 9944
pos = 0,0
postype = p1
name = "DRAMATIC KO HELPER"
stateno = 9944
supermovetime = 9999999999
pausemovetime = 9999999999

;===========================================================================
;===============================< -3 STATES >=================================
;===========================================================================
[Statedef -3]


[state -3, AI Detect Projectile System]
type = helper
trigger1 = ailevel 
trigger1 = !numhelper(33333333)
name = "AI Detect Projectile System"
ID = 33333333
stateno = 33333333
postype = p1
ownpal = 1
keyctrl = 0
size.xscale = 1.0
size.yscale = 1.0
supermovetime = 2147483647
pausemovetime = 2147483647
ignorehitpause = 1


[state -3, AI Detect Projectile System]
type = helper
trigger1 = ailevel 
trigger1 = !numhelper(4444444)
name = "AI Detect Projectile System"
ID = 4444444
stateno = 4444444
postype = p1
ownpal = 1
keyctrl = 0
size.xscale = 1.0
size.yscale = 1.0
supermovetime = 2147483647
pausemovetime = 2147483647
ignorehitpause = 1


[State 770, Max Meter V2]
type = Helper
helpertype = Normal
trigger1 = palno = 12 && NumHelper(790) <= 1 
id = 790
pos = 0,0
postype = left
name = "Sheild"
stateno = 790
ignorehitpause = 1
ownpal = 1
ignorehitpause = 1
size.xscale = .65
size.yscale = .65


[State -3, VarSet]
type = Varset
trigger1 = var(47) < 0
v = 47  
Value = 0
ignorehitpause = 1




;set maxlife for sub
[State -3, VarSet]
type = Varset
trigger1 = 1
fv =  2 
Value = 1+(var(47)-ceil(lifemax*.33333333))*ceil(lifemax*.3333333)**-1

;1 -(-(var(47)+(lifemax*.3333))/(lifemax*.3333))



[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = numexplod(1379)
trigger1 = Stateno != 1725
id = 1379

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = numexplod(32111)
trigger1 = movetype != a
id = 32111


[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = numexplod(16251)
trigger1 = var(13) = 0
id = 16251
ignorehitpause = 1

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = numexplod(12011)
trigger1 = var(13) = 0
id = 12011
ignorehitpause = 1

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = numexplod(10161)
trigger1 = var(13) = 0
id = 10161
ignorehitpause = 1


[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != 1700
id = 17251
ignorehitpause = 1


[State -3, RemoveExplod]
type = RemoveExplod
triggerALL = NUMHELPER
trigger1= numhelper(37499) = 0
id = 2205
ignorehitpause = 1


[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno!= [18000,18010]
trigger1 = var(13) = 0
id = 18005
ignorehitpause = 1

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno!= 250
trigger1 = numexplod(260)
id = 260
ignorehitpause = 1

[State -3, RemoveExplod]
type = RemoveExplod
triggerall = numhelper
trigger1 = !numhelper(13008)
id = 118



[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = (stateno!= [740,780]) && movetype !=a
trigger1 = time >= 8
id = 17401
ignorehitpause = 1

[State -3, VarSet]
type = VarSet
trigger1 =statetype != a
trigger2 = stateno = 762 
v = 19    
value = 0
ignorehitpause =1 

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno!= 600
id = 601
ignorehitpause = 1

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno!= 2100
id = 2100
ignorehitpause = 1
 
[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = var(13) = 0
id = 420
ignorehitpause = 1

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = var(13) = 0
id = 808
ignorehitpause = 1

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = var(13) = 0
id = 12251
ignorehitpause = 1

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = var(13) = 0
id = 12531
ignorehitpause = 1

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = var(13) = 0
id = 12532
ignorehitpause = 1

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = var(13) = 0
id = 1620
ignorehitpause = 1


;superarmor hits
[State -3]
Type =LifeAdd
TriggerAll = !IsHelper
TriggerAll = palno = 12
Trigger1 = NumHelper(4900) > 0
Trigger1 = FVar(9) >=1
Value = -Floor(.4 *fVar(9)) 
IgnoreHitPause = 1


[State -3]
Type = VarAdd
TriggerAll = !IsHelper
Trigger1 = 1
FV = 9
Value = -Floor(fVar(9))
IgnoreHitPause = 1







;charging attack
[State -3]
type = VarSet
var(12) = 0 ; time (in gameticks)
trigger1 = stateno != 210 ; (the attack in question)


;charging Tail atk buildup
[State -3]
type = VarSet
var(44) = 0
trigger1 =  var(13) = 0


; countup
[state -3]
type = VarAdd
var(12) = 1
trigger1 = anim =210




[State -3, Gametime Var]
type = varset
trigger1 = 1
var(58) = gametime
ignorehitpause = 1

[State -3, ProjContact Reset]
type = varset
triggerall = var(18)
trigger1 = (StateNo != [1000,1030])
trigger1 = StateNo != 1050 && StateNo != 1080
var(18) = 0

[State -3, Projectile Flag Off]
type = VarSet
trigger1 = !NumHelper(1001)
var(39) = 0
ignoreHitPause = 1

[State -3, Chain Reset]
type = varset
trigger1 = 1
var(4) = 0
ignorehitpause = 1

[State -3, Chain Check]
type = varset
triggerall = (StateNo != [4000,4999])
trigger1 = var(20) && (StateNo = [200,699]) && MoveContact && (StateNo !=[215,218])
trigger2 = var(20) && (StateNo = [1000,2999]) && StateType != A && (MoveContact || var(18))
trigger2 = StateNo != [1300,1331]
var(4) = 1
ignorehitpause = 1

[State -3, Command Cancel Reset]
type = varset
trigger1 = 1
var(5) = 0
ignorehitpause = 1

[State -3, Command Cancel Check]
type = varset
triggerAll = !var(20)
triggerall = (StateNo != [4000,4999])
trigger1 = (StateNo = [200,201]) && Movecontact && (StateNo !=[215,218])
trigger2 = StateNo = 250 && MoveContact && AnimElemTime(11) < 0
;trigger3 = StateNo = 221 && MoveContact && AnimElemTime(6) < 0
;trigger4 = StateNo = 401 && MoveContact
;trigger5 = StateNo = 400 && MoveContact
trigger6 = StateNo = 410 && MoveContact && AnimElemTime(5) < 0
trigger7 = StateNo = 241 && MoveContact 
trigger8 = StateNo = 430 && MoveContact
trigger9 = StateNo = 450 && MoveContact && AnimElemTime(6) < 0
trigger10 =StateNo = 420 || StateNo = 421 && MoveContact && AnimElemTime(5) < 0
trigger11 = StateNo = 230 && MoveContact && AnimElemTime(8) < 0
trigger12 =StateNo =220 && animelemtime(3) >=1 && numprojid(225) = 0
var(5) = 1
ignorehitpause = 1

[State -3, Cancel Reset]
type = varset
trigger1 = 1
var(6) = 0
ignorehitpause = 1

[State -3, Cancel Check]
type = varset
triggerall = (StateNo != [4000,4999])
trigger1 = (StateNo = [200,699]) && movecontact
trigger3 = StateNo != 251 || (StateNo = 251 && movecontact && AnimElemTime(8) < 0 )
trigger4 = StateNo = [200,201] 
trigger5 = StateNo = 1800 && movecontact
trigger5 = StateNo = 1250 && movecontact&&AnimElemTime(3) < 0
trigger6 = StateNo = 1500 && movecontact&& AnimElemTime(20) < 0
trigger7 = StateNo = 242 && movecontact
;trigger8 = StateNo = 400 || StateNo = 401 && movecontact
trigger9 = StateNo = 410 && movecontact
trigger10 = StateNo = 430 && movecontact
trigger11 = StateNo = 600 && movecontact && AnimElemTime(10) >= 0
trigger12 = StateNo = 630
trigger12 = StateNo = 1700 && var(53)
trigger13 = StateNo = 1255 && Movehit && animelemtime(29)>= 0
trigger14 = StateNo =  (StateNo = [240,243]) && MoveContact ;&& AnimElemTime(5) < 0  
;trigger15 = StateNo = 251 && MoveContact && AnimElemTime(6) < 0
trigger16 = StateNo = 440 && Movehit 
trigger17 = StateNo = 1800 && Movehit 
trigger18 = StateNo =220 && animelemtime(3) >=1 && numprojid(225) = 0
var(6) = 1
ignorehitpause = 1

[State -3, Super Cancel Reset]
type = varset
trigger1 = 1
var(7) = 0
ignorehitpause = 1

[State -3, Super Cancel Flag Reset]
type = VarSet
trigger1 = var(21)
trigger1 = (StateNo != [3000,4999]) || MoveType = H
var(21) = 0
ignoreHitPause = 1

[State -3, Super Cancel Check]
type = varset
triggerall = (StateNo != [4000,4999])
trigger1 = var(20) && (StateNo = [200,699])  &&(StateNo !=[215,218])
trigger2 = var(20) && (StateNo = [1000,2999]) && (MoveContact || var(18))
trigger3 = (StateNo = [200,699]) && Time <= 1.5
trigger4 = StateNo = [200,201]
trigger5 = StateNo = 211 && (AnimElemTime(5) < 0 || (movecontact = [1, 8]))
trigger6 = StateNo = 220 && (AnimElemTime(5) < 0 || (movecontact = [1, 8]))
;trigger7 = StateNo = 221 && movecontact&&(AnimElemTime(6) < 0 || (movecontact = [1, 8]))
trigger8 = StateNo = [230,231]
trigger9 = StateNo = 251 && (AnimElemTime(6) < 0 || (movecontact = [1, 8]))
;trigger10 = StateNo = 400
trigger11 = StateNo = 410 && (AnimElemTime(5) < 0 || (movecontact = [1, 8]))
trigger12 = StateNo = 420 && (AnimElemTime(5) < 0 || (movecontact = [1, 8]))
trigger13 = StateNo = 430
trigger14 = StateNo = 440 && (AnimElemTime(5) < 0 || (movecontact = [1, 8]))
trigger15 = StateNo = 450 && (AnimElemTime(6) < 0 || (movecontact = [1, 8]))
trigger16 = (StateNo = [1000,1030]) && (AnimElemTime(7) = [1,8])
trigger17 = Stateno = 1101 
trigger18 = Stateno = 1400
trigger19 = Stateno = 1401
trigger20 = Stateno = 1101
trigger21 = Stateno = 1201
trigger22 = Stateno = 1301
trigger23 = Stateno = 1501
trigger24 = Stateno = 1430
trigger25 = StateNo = 421 && MoveContact && AnimElemTime(5) < 0
trigger26 = StateNo = 1600 || StateNo = 1630 && MoveContact
trigger27 = (StateNo = [1700,1730]) && MoveContact 
trigger28 = Stateno = 241 && MoveContact && animelemtime(5)>=0
trigger29 = Stateno = 252
var(7) = 1
ignorehitpause = 1

[State -3, Hyper Cancel Reset]
type = varset
trigger1 = 1
var(8) = 0
ignorehitpause = 1
[State -3, Hyper Cancel Reset]
type = varset
trigger1 = stateno = 3110 && AnimElemTime(87) < 0 && MoveContact
var(8) = 1
ignorehitpause = 1

[State -3, Hyper Cancel Flag Reset]
type = varset
trigger1 = var(22)
trigger1 = (stateno != [3000, 4999]) || movetype = H
var(22) = 0
ignorehitpause = 1

[State -3, Parry Detection]
type = helper
triggerall = roundstate = 2 && !numhelper(765) ;&& !var(20)
triggerall = (movetype = I && ctrl) || (stateno = [760, 762]) || stateno = 5120 || (stateno = [100, 105]) || stateno = 740 || stateno = 741 || stateno = 771
;triggerall = AIlevel
trigger1 = !AIlevel && (statetype = S || statetype = C || stateno = 5120) && (command = "fwd" || command = "down") 
trigger2 = !AIlevel && ( statetype = A && (var(3) != 1 && var(3) != 2) && command = "fwd" || stateno = 771)
trigger3 = AIlevel && (stateno != [760, 762]) && inguarddist && random < (999 * (AILevel ** 2 / 64.0)) ;50
trigger4 = AIlevel && (stateno = [760, 762]) && time = 20 && random < (999 * (AILevel ** 2 / 64.0))
trigger5 = (stateno = [100, 105]) || stateno = 740 || stateno = 760 || stateno = 741 || stateno = 771 || stateno = 763
stateno = 765
ID = 765
name = "Parry Detection"
postype = p1
pausemovetime = 65535
supermovetime = 65535

[State -3, Parry Attacks]
type = changestate
trigger1 = (stateno != [760, 762]) && numhelper(765)
trigger1 = helper(765), stateno = 766
value = ifelse((helper(765), anim = 767), 762, ifelse((helper(765), anim = 766), 761, 760))
ignorehitpause = 1

[State -3, Parry Projectiles]
type = hitoverride
trigger1 = (stateno != [760, 762]) && numhelper(765)
trigger1 = !(helper(765), var(0)) && (helper(765), anim = 765)
attr = SA, AP
stateno = 760
slot = 0
time = 1
ignorehitpause = 1

[State -3, Parry Projectiles]
type = hitoverride
trigger1 = (stateno != [760, 762]) && numhelper(765)
trigger1 = !(helper(765), var(0)) && (helper(765), anim = 766)
attr = C, AP
stateno = 761
slot = 0
time = 1
ignorehitpause = 1

[State -3, Parry Projectiles]
type = hitoverride
trigger1 = (stateno != [760, 762]) && numhelper(765)
trigger1 = !(helper(765), var(0)) && (helper(765), anim = 767)
attr = SCA, AP
stateno = 762
slot = 0
time = 1
ignorehitpause = 1

[State -3, NoWalk after Parry]
type = assertspecial
trigger1 = var(26) > 0
trigger1 = var(26) := (var(26) -1)
flag = nowalk
ignoreHitPause = 1

[State -3, Corner Push]
type = varset
triggerall= !var(53)
trigger1 = fvar(5)
trigger1 = numtarget
trigger1 = target, hitover || (target, gethitvar(hitshaketime) > 0 && target, time <= 0)
fvar(5) = 5
;0
[State -3, Corner Push]
type = VarSet
trigger1 = NumTarget
trigger1 = Target, GetHitVar(HitShakeTime) <= 0
fvar(5) = fvar(5) * 0.85

[State -3, Corner Push]
type = varset
triggerAll = MoveType != H
trigger1 = movecontact = 1 && numtarget
fvar(5) = target, gethitvar(xvel)
ignorehitpause = 1

[State -3, Corner Push]
type = posadd
triggerall = fvar(5)
triggerall = (statetype = S || statetype = C) && numtarget
triggerall = !hitpausetime && target, gethitvar(hitshaketime) <= 0
triggerall = (target, statetype = S || target, statetype = C) && !(target, gethitvar(yvel)) && !(target, hitfall)
trigger1 = target, frontedgebodydist <= abs(target, vel x)
trigger1 = (target, gethitvar(xvel) * target, facing) > 0
trigger2 = target, backedgebodydist <= abs(target, vel x)
trigger2 = (target, gethitvar(xvel) * target, facing) < 0
x = ifelse(target, frontedgebodydist <= 0, -1, 1) * (target, facing) * fvar(5)

[State -3, Corner Push]
type = varset
trigger1 = fvar(5)
trigger1 = abs(fvar(5)) < 1.0
fvar(5) = 0
;0

[State -3, Corner Push]
type = varset
trigger1 = numtarget
trigger1 = target, gethitvar(hitshaketime) <= 0
fvar(5) = fvar(5) * 0.85

[State -3, ExFX]
type = varadd
trigger1 = var(25) > 0
var(25) = -1

[State -3, ExFX]
type = varset
trigger1 = movetype != a || movetype = H
var(25) = 0



[State -3, Ex Flash]
type = palfx
trigger1 =!(gametime % 5) && var(25) 
time = 1
color = 0
mul = 256, 224, 0
add = 128, 128, 128
ignorehitpause = 1

[State -3, Movement Afterimage]
type = afterimage
triggerall = time = 1 && !var(20)
trigger1 = stateno = 50 && (var(3) = 2 || var(3) = 3)
trigger2 = (stateno = [700, 715])
time = 2
timegap = 1
framegap = 4
length = 9
palbright = 0, 0, 0
palcontrast = 128, 128, 128
palpostbright = 0, 0, 0
paladd = 0, 0, 0
palmul = 0.9, 0.9, 0.9
trans = add1

[State -3, Lv1 Super Afterimage]
type = afterimage
trigger1 = stateno = 3000 && time = 43
time = 2
timegap = 1
framegap = 10
length = 21
palbright = 0, 0, 0
palcontrast = 128, 128, 128
palpostbright = 0, 0, 0
paladd = 0, 0, 0
palmul = 0.75, 0.75, 0.75
trans = add1

[State -3, Lv2 Super Afterimage]
type = afterimage
trigger1 = stateno = 3050 && time = 43
time = 2
timegap = 1
framegap = 10
length = 21
palbright = 0, 0, 0
palcontrast = 32, 32, 160
palpostbright = 0, 0, 0
paladd = 0, 0, 0
palmul = 0.75, 0.75, 0.75
trans = add1

[State -3, Lv3 Super Afterimage]
type = afterimage
trigger1 = stateno = 3500 && time = 43
time = 2
timegap = 1
framegap = 10
length = 21
palbright = 0, 0, 0
palcontrast = 160, 32, 32
palpostbright = 0, 0, 0
paladd = 0, 0, 0
palmul = 0.75, 0.75, 0.75
trans = add1

[State -3, Afterimage Persist]
type = afterimagetime
trigger1 = stateno = 50 || (stateno = [600, 699])
trigger1 = (var(3) = 2 || var(3) = 3) && vel y < -1
trigger2 = var(20)
trigger3 = stateno = [700, 715]
trigger4 = (StateNo = [3000,4999])
time = 2

[State -3, Underground Juggle Prevention]
type = targetbind
trigger1 = movecontact = 1
trigger1 = numtarget && numenemy
trigger1 = (target, time = 0) && (target, ID = enemynear, ID)
trigger1 = !(target, hitshakeover) && (target, pos y > 0)
pos = ceil(p2dist x), ceil(-pos y)
ignorehitpause = 1

[State -3, Prevent Crossup]
type = width
trigger1 = movetype != H
edge = 8, 0
ignorehitpause = 1

[State -3, Variable Height]
type = playerpush
triggerall = statetype = A && movetype != H && numenemy
triggerall = p2bodydist x = [ -(enemynear, const(size.ground.back) + enemynear, const(size.ground.front)), 0]
trigger1 = p2statetype = S
trigger1 = P2Dist y >= (EnemyNear, const(size.height) - 12)
trigger2 = P2StateType = C
trigger2 = P2Dist y >= (EnemyNear, const(size.height) - 28)
trigger3 = P2StateType = L
trigger3 = P2Dist y >= 12
value = 0
ignorehitpause = 1

[State -3, GetHit Snd]
type = playsnd
triggerall = alive && time = 1
triggerall = stateno = 5000 || stateno = 5010
trigger1 = gethitvar(animtype) >= 2 && random < 500
trigger2 = gethitvar(animtype) = 1 && random < 375
trigger3 = gethitvar(animtype) = 0 && random < (250 * (AIlevel ** 2 / 64.0))
value = 5000, (random % 3)
channel = 0
ignorehitpause = 1

[State -3, GetHit Snd]
type = playsnd
triggerall = alive && time = 1
trigger1 = (stateno = 5000 || stateno = 5010) && numenemy
trigger1 = gethitvar(fall) || (enemynear, hitdefattr = SCA, SA, HA)
trigger2 = (stateno = 5020 || stateno = 5070 || stateno = 5080)
trigger3 = (stateno = 5050 || stateno = 5100) && (prevstateno != [5000, 5199])
value = 5000, (random % 3)
channel = 0
ignorehitpause = 1

[State -3, Cheap KO]
type = changestate
trigger1 = !alive && (stateno = [5000, 5010])
trigger1 = (prevstateno = [130, 131]) || (prevstateno = [140, 141]) || (prevstateno = [150, 153])
value = 5950
ignorehitpause = 1

[State -3, Cheap KO]
type = assertspecial
trigger1 = (stateno = [5000, 5010])
trigger1 = (prevstateno = [130, 131]) || (prevstateno = [140, 141]) || (prevstateno = [150, 153])
flag = nokosnd
ignorehitpause = 1

[State -3, Stop Guarding Voice]
type = StopSnd
trigger1 = StateNo = [120,155]
channel = 0

[State -3, CC Finish]
type = null
helper
triggerall = winKO && var(20)
triggerall = roundstate = 3 && !numhelper(8600)
trigger1 = movehit = [1, 4]
trigger2 = StateNo = 810 && (AnimElemTime(6) = [0, 1])
trigger3 = StateNo = 820 && (AnimElemTime(6) = [0, 1])
trigger4 = numhelper(1005)
trigger4 = (helper(1005), stateno = [1005, 1007]) && (helper(1005), var(18))
trigger5 = numhelper(1055)
trigger5 = (helper(1055), stateno = [1055, 1057]) && (helper(1055), var(18))
stateno = 8600
ID = 8600 + 0 * (var(23) := 900)
name = "Super Finish"
postype = left
pos = 160, -120
ownpal = 1
pausemovetime = 255
supermovetime = 255
ignorehitpause = 1

[State -3, Super Finish]
type = null;helper
triggerall = winKO
triggerall = roundstate = 3 && !numhelper(8600)
trigger1 = MoveHit = 1 && (StateNo = [3000,4999])
trigger1 = var(23) := stateno
trigger2 = (StateNo = [4250,4263]) ;nightshade
trigger2 = var(23) := 4250
trigger3 = StateNo = 4000          ;thorn garden
trigger3 = var(23) := 4000
trigger4 = (StateNo = [4500,4506])  ;Angel's Trumpet
trigger4 = var(23) := 4500
trigger5 = StateNo = 3150 || numhelper(13100)  ;CDPB
trigger5 = var(23) := 3150

trigger6 = StateNo = 775   ;ShadowFury
trigger6 = var(23) := 775
stateno = 8600
ID = 8600
name = "Super Finish"
postype = left
pos = 160, -120
ownpal = 1
pausemovetime = 255
supermovetime = 255
ignorehitpause = 1



;This controller plays a sound everytime KFM lands from a jump, or
;from his back-dash.
[State -3, Landing Sound]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 52 ;Jump land
trigger2 = stateno = 106 ;Run-back land
value = 40, 0





