;=====================
;Variable list
; This list does not account for variables used by helpers (states 10000-50000).
; Unless stated otherwise here or in the code, the helper variables don't correspond at all to the main ones.

; Var(0) - Throw Check (0 = Allowed, 1 = Disallowed)

; Var(2) - Psi-Blade Hit Counter, Psi-Thrust Repeat Checker
; Var(3) - Psi-Blade Cancel Variable
; Var(4) - Ninjutsu Drill/Psi-Thrust Direction Control

; Var(10) - Statedef -2, Superpause Check Variable
	; 2: Cornerpush disabled
; Var(11) - Statedef -2, Cornerpush Variable

; Var(15) - Juggle: determines what kind of fall state the opponent is in.
	; 0: None.
	; 1: Air reset (Only air basics/special moves/super moves can juggle.)
	; 2: Special air juggle (only special moves/super moves may juggle).
	; 3: Super air juggle (only super moves may juggle).
	; 4: Universal reset (no juggles allowed.)
; Var(16) - MoveHit/Contact Detection (1 = Hit, 2 = Guarded, 3 = Whiffed, 4 = Reversed)
; Var(17) - Cancel Detection - Determines when normal and special moves are allowed to be canceled.
	; 1: Chain cancels (normal to normal, special, super)
	; 2: Super cancels (special to super)
; Var(18) - Attack Type 
	; 1: Light Attacks
	; 2: Heavy Attacks

; Var(20) - Hit counter: keeps track of the number of hits that have landed for the damage dampener.
; Var(21) - Counterhit variable 1 (0: opponent is idle, 1: opponent is attacking)
; Var(22) - Counterhit variable 2 (counterhit timer)

; Var(25) - Projectiles Active
; Var(26) - Psi-Blade Repeat Checker
; Var(27) - Psi-Thrust Timer

;Floats
;--------
; FVar(10) - Statedef -2, Cornerpush Variable
; FVar(20) - Damage Dampening System (keeps count of the % to decay the damage by)

;=====================

[Data]
life = 1000			;Amount of life to start with
power = 3000		;Amount of maximum power
attack = 100		;attack power (more is stronger)
defence = 100		;defensive power (more is stronger)
fall.defence_up = 50	;Percentage to increase defense everytime player is knocked down
liedown.time = 60		;Time which player lies down for, before getting up
airjuggle = 15		;Number of points for juggling
sparkno = 2			;Default hit spark number for HitDefs
guard.sparkno = 40	;Default guard spark number
KO.echo = 0			;1 to enable echo on KO
volumescale = 100			;Volume offset (negative for softer)
IntPersistIndex = 60	;Variables with this index and above will not have their values
FloatPersistIndex = 40 ;reset to 0 between rounds or matches. There are 60 int variables,
 				;indexed from 0 to 59, and 40 float variables, indexed from 0 to 39.
 				;If omitted, then it defaults to 60 and 40 for integer and float
 				;variables repectively, meaning that none are persistent, i.e. all
 				;are reset. If you want your variables to persist between matches,
 				;you need to override state 5900 from common1.cns.


[Size]
xscale = 1			;Horizontal scaling factor.
yscale = 1			;Vertical scaling factor.
ground.back = 20		;Player width (back, ground)
ground.front = 19		;Player width (front, ground)
air.back = 12		;Player width (back, air)
air.front = 12		;Player width (front, air)
height = 60			;Height of player (for opponent to j.over)
attack.dist = 160		;Default attack distance
proj.attack.dist = 90	;Default attack distance for projectiles
proj.doscale = 0		;Set to 1 to scale projectiles too  
head.pos = -5, -90	;Approximate position of head
mid.pos = -5, -60		;Approximate position of midsection
shadowoffset = 0		;Number of pixels to vertically offset the shadow
draw.offset = 0,0		;Player drawing offset in pixels (x, y)

[Velocity]
walk.fwd = 2.6		;Walk forward
walk.back = -2.4		;Walk backward
run.fwd = 5.6, -4	;Run forward (x, y)
run.back = -5.5,-3.8	;Hop backward (x, y)
jump.neu = 0,-9.4		;Neutral jump velocity (x, y)
jump.back = -2.55		;Jump back Speed (x, y)
jump.fwd = 2.5		;Jump forward Speed (x, y)

[Movement]
airjump.num = 0		;Number of air jumps allowed (opt)
airjump.height = 35	;Minimum distance from ground before you can air j.(opt)
yaccel = .5		;Vertical acceleration
stand.friction = .85	;Friction coefficient when standing
crouch.friction = .82	;Friction coefficient when crouching
;air.gethit.groundrecover = -.15,-3.5 ;Velocity for ground recovery state (x, y) **MUGEN 1.0**
;air.gethit.airrecover.mul = .5,.2   ;Multiplier for air recovery velocity (x, y) **MUGEN 1.0**
;air.gethit.airrecover.add = 0,-4.5  ;Velocity offset for air recovery (x, y) **MUGEN 1.0**
;air.gethit.airrecover.back = -1    ;Extra x-velocity for holding back during air recovery **MUGEN 1.0**
;air.gethit.airrecover.fwd = 0     ;Extra x-velocity for holding forward during air recovery **MUGEN 1.0**
;air.gethit.airrecover.up = -2     ;Extra y-velocity for holding up during air recovery **MUGEN 1.0**
;air.gethit.airrecover.down = 1.5   ;Extra y-velocity for holding down during air recovery **MUGEN 1.0**
stand.friction.threshold = 2     ;If player's speed drops below this threshold while standing, stop his movement **MUGEN 1.0**
crouch.friction.threshold = .05    ;If player's speed drops below this threshold while crouching, stop his movement **MUGEN 1.0**
air.gethit.groundlevel = 25      ;Y-position at which a falling player is considered to hit the ground **MUGEN 1.0**
air.gethit.groundrecover.ground.threshold = -20 ;Y-position below which falling player can use the recovery command **MUGEN 1.0**
air.gethit.groundrecover.groundlevel = 10  ;Y-position at which player in the ground recovery state touches the ground **MUGEN 1.0**
air.gethit.airrecover.threshold = -1 ;Y-velocity above which player may use the air recovery command **MUGEN 1.0**
air.gethit.airrecover.yaccel = .35  ;Vertical acceleration for player in the air recovery state **MUGEN 1.0**
air.gethit.trip.groundlevel = 15   ;Y-position at which player in the tripped state touches the ground **MUGEN 1.0**
down.bounce.offset = 0,0      ;Offset for player bouncing off the ground (x, y) **MUGEN 1.0**
down.bounce.yaccel = .5        ;Vertical acceleration for player bouncing off the ground **MUGEN 1.0**
down.bounce.groundlevel = 12     ;Y-position at which player bouncing off the ground touches the ground again **MUGEN 1.0**
down.friction.threshold = .05     ;If the player's speed drops below this threshold while lying down, stop his movement **MUGEN 1.0**

[Quotes]
victory0 = "You fought well, but you are still outclassed!"
victory1 = "Your skills don't compare to mine!"
victory2 = "You've lost, but you've proven yourself."
victory3 = "Your skills grow with experience... but not enough for me!"
victory4 =  "Call me again when you're serious!"
victory5 = "How considerate of you to stand still while I defeat you."
victory6 = "Next time, I suggest you try fighting back."
victory7 = "I have danced with the devil himself. You are no threat to me."
victory8 = "Arrogance will always be your downfall!"
victory9 = "Pain is an excellent teacher. Learn well."
victory10 = "We will meet again."

victory20 = "Perhaps you should consider an easier opponent."
victory21 = "I won't embarrass you by continuing this fight any further."

victory30 = "Another Psylocke?! Spiral and I must have a little chat..."
victory31 = "Perhaps you regret doing your little 'Body Shoppe' work on me now!"

;---------------------------------------------------------------------------
; Lose by Time Over
[Statedef 170]
type = S
ctrl = 0
anim = 170
velset = 0,0

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

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

[State 180, 1]
type = ChangeState
trigger1 = Time = 0
value = 181 + Random % 3

;---------------------------------------------------------------------------
; Win pose 1
[Statedef 181]
type = S
ctrl = 0
anim = 181
velset = 0,0

[State 181, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 7
value = S5,8
volumescale = 100
channel = 1

[State 181, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 9
value = S181,0
volumescale = 100
channel = 0

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

;---------------------------------------------------------------------------
; Win pose 2
[Statedef 182]
type = S
ctrl = 0
anim = 182
velset = 0,0

[State 182, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 8
value = S5,8
volumescale = 100
channel = 1

[State 220, Helper]
type = Helper
trigger1 = !Time
name = "Psi FX"
ID = 10182
stateno = 10200
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 0
pausemovetime = 0

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


;---------------------------------------------------------------------------
; Win pose 3
[Statedef 183]
type = S
ctrl = 0
anim = 183
velset = 0,0

[State 181, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 2
value = S5,11
volumescale = 100
channel = 1

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

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

[State 0, PosAdd]
type = PosAdd
trigger1 = !Time
x = -150
y = -75

[State 0, PosAdd]
type = PosAdd
trigger1 = Time = [1,25]
x = 6
y = 3

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

[State 191, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 191, Landing Dust 1]
type = Explod
trigger1 = Pos Y = 0
anim = 10052
ID = 10052
pos = 0,0
scale = 0.5, 0.5
postype = p1
removetime = -2
sprpriority = 1
ownpal = 1
persistent = 0

[State 191, Landing Dust 2]
type = Explod
trigger1 = Pos Y = 0
anim = 10053
ID = 10053
pos = 0,0
scale = 0.5, 0.5
postype = p1
removetime = -2
sprpriority = 0
ownpal = 1
persistent = 0

[State 191, PlaySnd]
type = PlaySnd
trigger1 = Pos Y = 0
value = S52,0
volumescale = 100
persistent = 0

[State 191, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 18
value = S191,0
volumescale = 100
channel = 0

[State 191, Helper]
type = Helper
trigger1 = AnimElem = 18
name = "Psi FX"
ID = 10191
stateno = 10200
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 0
pausemovetime = 0

[State 191, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 20
value = S5,8
volumescale = 100
persistent = 0

[State 191, 3] ;Change to stand state
type = ChangeState
trigger1 = AnimTime = 0
value = 0

;---------------------------------------------------------------------------
; Introduction 2
[Statedef 192]
type = S
ctrl = 0
anim = 192
velset = 0,0

[State 0, PosAdd]
type = PosAdd
trigger1 = !Time
x = -80
y = -80

[State 0, PosAdd]
type = PosAdd
trigger1 = Time = [1,20]
x = 4
y = 3

[State 10200, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 9
value = S1010,1
volumescale = 100
channel = 0

[State 1000, Explod]
type = Explod
trigger1 = AnimElem = 9
anim = StateNo + 10000
ID = StateNo + 10000
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 = 1,1
sprpriority = 3
shadow = 0,0,0
ownpal = 1
removeongethit = 1

[State 0, PosAdd]
type = PosAdd
trigger1 = AnimElemTime(20) >= 0 && AnimElemTime(21) < 0
trigger1 = Pos Y < 0
y = 4

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

[State 191, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

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

[State 191, Landing Dust 1]
type = Explod
trigger1 = Pos Y = 0
anim = 10052
ID = 10052
pos = 0,0
scale = 0.5, 0.5
postype = p1
removetime = -2
sprpriority = 1
ownpal = 1
persistent = 0

[State 191, Landing Dust 2]
type = Explod
trigger1 = Pos Y = 0
anim = 10053
ID = 10053
pos = 0,0
scale = 0.5, 0.5
postype = p1
removetime = -2
sprpriority = 0
ownpal = 1
persistent = 0

[State 191, PlaySnd]
type = PlaySnd
trigger1 = Pos Y = 0
value = S52,0
volumescale = 100
persistent = 0

[State 191, 3] ;Change to stand state
type = ChangeState
trigger1 = AnimTime = 0
value = 0
;---------------------------------------------------------------------------
; Taunt
[Statedef 195]
type = S
ctrl = 0
anim = 195
velset = 0,0
movetype = I
physics = S
sprpriority = 2

[State 3000, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 10
trigger2 = AnimElem = 17
value = S5,6
volumescale = 50
channel = 0

[State 3000, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 7
value = S191,0
volumescale = 100
channel = 0

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

;---------------------------------------------------------------------------
; Override common states (use same number to override) :
;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; States that are always executed (use statedef -2)
;---------------------------------------------------------------------------

[Statedef -2]

[State -2, Debug]
type = DisplayToClipboard
trigger1 = 1
text = "Reversal = %d, Juggle = %d, Cancels = %d, Psi Direction = %d"
params = var(44), var(15), var(17), var(4)

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

[State -2, Throws Disallowed]; Resets condition every tick to check again
type = VarSet
trigger1 = 1
var(0) = 0

[State -2, Throws Disallowed]
type = VarSet
triggerall = NumEnemy
triggerall = RoundState = 2
trigger1 = (enemynear,stateno = [150,155])
trigger2 = enemynear,movetype = H 
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 = MoveType = H
trigger8 = StateType = L
trigger9 = EnemyNear,StateType = L
trigger10 = var(15) > 0
trigger11 = P2BodyDist X > 30
var(0) = 1

[State -2, Prevent Underground Juggles]
type = targetbind
trigger1 = movehit = 1
trigger1 = numtarget = 1 && numenemy
trigger1 = (target,time <= 1) && (target,ID = enemynear,ID); this is just to prevent Simul issues as usual
trigger1 = !(target,hitshakeover) && (target, hitfall) && (target, pos y>0)
pos = ceil(p2dist x), ceil(-pos y); keeps P2 at the same horizontal distance, but resets his Y position
ignorehitpause = 1


;================================================================================
; ------- KOF Cornerpush System by Vans --------
;===============================================================================
[State -2, Superpause Check]
type = VarAdd
trigger1 = var(10)
var(10) = -1

[State -2, Reset Time counter]
type = VarSet
trigger1 = movecontact = 1
var(11) = 0

[State -2, Accel]
type = VarSet
triggerall = roundstate = 2
triggerall = var(10) <=  0
triggerall = numtarget >= 1
trigger1 = target, hitshakeover
fvar(10) = (target, gethitvar(xvel)*exp((-0.25)*((var(11)))));exp((-0.1886)*((var(11)))))

[State -2, Push]
type = PosAdd
triggerall = roundstate = 2
triggerall = !var(10)
triggerall = numtarget >= 1
triggerall = (target, BackEdgeBodyDist <=  0) || (target, FrontEdgeBodyDist <=  0)
triggerall = target,statetype != L
triggerall = target,statetype != A
trigger1 = Statetype != A
x = ifelse(facing = -1,fvar(10),-fvar(10))

[State -2, Increase]
type = VarSet
triggerall = numtarget >= 1
triggerall = target, hitshakeover
trigger1 = var(10) <=  0
trigger1 = var(11)
var(11) = var(11)+1

[State -2, Time counter]
type = VarSet
trigger1 = !var(11)
trigger1 = fvar(10)
var(11) = 1

[State -2, Freeze Pos During Superpause]
type = PosFreeze
trigger1 = var(10)
value = 1

[State -2, Drop]
type = VarSet
triggerall = fvar(10)
trigger1 = !numtarget
trigger2 = projcontact = 1
trigger3 = movecontact = 1
fvar(10) = 0
ignorehitpause = 1

;================================================================================
; ------- COUNTER HIT by Vans (Based on Sander's Method) --------
;===============================================================================
[State -2, VarSet];Checks if opponent is in attack state
type = VarSet
triggerall = numenemy
trigger1 = enemy, movetype = a
var(21) = 1
ignorehitpause = 1

[State -2, VarSet];This resets the condition if counter not succesful and succesful
type = VarSet
triggerall = numenemy
trigger1 = enemy, movetype = i || var(22) >= 1 ;Enemy is Idle | Counter was Succesful
trigger2 = var(22) > 10 && enemy, movetype = h ;10 ticks passed & enemy is on gethit state
trigger3 = MoveType = I
var(21) = 0
ignorehitpause = 1

[State -2, VarSet];Counter Hit Succesful
type = VarSet
trigger1 = var(21) = 1 && var(16) = 1 ;Counter Check Ok, Move Hit Succesfully.
trigger1 = StateNo != [190,199] ;Does not activate during intros.
trigger1 = StateNo != [800,899]
var(22) = 1
ignorehitpause = 1

[State -2, VarAdd];Counter Hit Timer
type = VarAdd
trigger1 = var(22) >= 1 ;Counter was succesful
var(22) = 1
ignorehitpause = 1

[State -2, VarSet];Counter Hit Reset
type = VarSet
trigger1 = var(22) >= 22 && var(16) = 1;Reset if 22 ticks passed and move hit
trigger2 = p2movetype != h ;Reset if P2 is no longer in gethit state
trigger3 = movetype = h ;Reset if P1 is getting hit
var(22) = 0
ignorehitpause = 1

[State -2, EnvColor];This will produce a flash a la KOF2K2
type = EnvColor
triggerall = MoveType != H
triggerall = numenemy
triggerall = var(21)
triggerall = StateNo != [190,199] ;Does not activate during intros.
triggerall = StateNo != [800,899] ;Does not activate during throws.
trigger1 = var(21) = 1 && Var(16) = 1 ;Move hit, Ok
value = 255,255,255
time = 1
under = 1
ignorehitpause = 1
persistent = 0
;---------------------------------------------------------------------------
; States that are executed when in self's state file (use statedef -3)
;---------------------------------------------------------------------------

[Statedef -3]

[State -3, Dust]
type = Helper
triggerall = NumHelper(10040) = 0
trigger1 = (Anim = [41,63]) && Time = 1 && PrevStateNo = 40
trigger2 = (Anim = 100 || Anim = 105) && Time = 1
trigger3 = StateNo = 106 && Time = 1
trigger4 = StateNo = 1003 && Time = 1
trigger5 = (StateNo = [1005,1007]) && StateType != A && Time = 1
name = "Dust"
ID = 10040
stateno = 10040
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
persistent = 0

;==

[State 1010, VarSet]
type = VarSet
triggerall = (StateNo = [1010,1015]) || (StateNo = [3000,3002])
triggerall = var(4) = 0 && Time > 0
trigger1 = AILevel = 0 && command = "holddownback"
trigger1 = command = "a" || command = "b" || command = "c" || command = "x" || command = "y" || command = "z"
trigger2 = AILevel != 0
trigger2 = P2BodyDist X = [0,-150] 
trigger2 = P2BodyDist Y > 0
trigger2 = StateType = A || P2StateType = L 
trigger2 = var(15) < 5
trigger2 = IfElse(StateNo < 3000, AnimElemTime(13) >= 0, StateNo = 3002 && Time >= 0)
var(4) = 1
persistent = 0

[State 1010, VarSet]
type = VarSet
triggerall = (StateNo = [1010,1015]) || (StateNo = [3000,3002])
triggerall = var(4) = 0 && Time > 0
trigger1 = AILevel = 0 && command = "holddownfwd"
trigger1 = command = "a" || command = "b" || command = "c" || command = "x" || command = "y" || command = "z"
trigger2 = AILevel != 0
trigger2 = P2BodyDist X = [0,150]
trigger2 = P2BodyDist Y > 0
trigger2 = StateType = A || P2StateType = L
trigger2 = var(15) < 5
trigger2 = IfElse(StateNo < 3000, AnimElemTime(13) >= 0, StateNo = 3002 && Time >= 0)
var(4) = 3
persistent = 0

[State 1010, VarSet]
type = VarSet
triggerall = (StateNo = [1010,1015]) || (StateNo = [3000,3002])
triggerall = var(4) = 0 && Time > 0
trigger1 = AILevel = 0 && command = "holdupback"
trigger1 = command = "a" || command = "b" || command = "c" || command = "x" || command = "y" || command = "z"
trigger2 = AILevel != 0
trigger2 = P2BodyDist X = [0,-150]
trigger2 = P2BodyDist Y < -35
trigger2 = var(15) < 5
trigger2 = IfElse(StateNo < 3000, AnimElemTime(13) >= 0, StateNo = 3002 && Time >= 0)
var(4) = 7
persistent = 0

[State 1010, VarSet]
type = VarSet
triggerall = (StateNo = [1010,1015]) || (StateNo = [3000,3002])
triggerall = var(4) = 0 && Time > 0
trigger1 = AILevel = 0 && command = "holdupfwd"
trigger1 = command = "a" || command = "b" || command = "c" || command = "x" || command = "y" || command = "z"
trigger2 = AILevel != 0
trigger2 = P2BodyDist X = [0,150]
trigger2 = P2BodyDist Y < -35
trigger2 = var(15) < 5
trigger2 = IfElse(StateNo < 3000, AnimElemTime(13) >= 0, StateNo = 3002 && Time >= 0)
var(4) = 9
persistent = 0

[State 1010, VarSet]
type = VarSet
triggerall = (StateNo = [1010,1015]) || (StateNo = [3000,3002])
triggerall = var(4) = 0 && Time > 0
trigger1 = AILevel = 0 && command = "holdup"
trigger1 = command = "a" || command = "b" || command = "c" || command = "x" || command = "y" || command = "z"
trigger2 = AILevel != 0
trigger2 = P2BodyDist X = [-20,20] 
trigger2 = P2BodyDist Y < -35
trigger2 = var(15) < 5
trigger2 = IfElse(StateNo < 3000, AnimElemTime(13) >= 0, StateNo = 3002 && Time >= 0)
var(4) = 8
persistent = 0

[State 1010, VarSet]
type = VarSet
triggerall = (StateNo = [1010,1015]) || (StateNo = [3000,3002])
triggerall = var(4) = 0 && Time > 0
trigger1 = AILevel = 0 && command = "holddown"
trigger1 = command = "a" || command = "b" || command = "c" || command = "x" || command = "y" || command = "z"
trigger2 = P2BodyDist X = [-20,20] 
trigger2 = P2BodyDist Y > 0
trigger2 = StateType = A || P2StateType = L
trigger2 = var(15) < 5
trigger2 = IfElse(StateNo < 3000, AnimElemTime(13) >= 0, StateNo = 3002 && Time >= 0)
var(4) = 2
persistent = 0

[State 1010, VarSet]
type = VarSet
triggerall = (StateNo = [1010,1015]) || (StateNo = [3000,3002])
triggerall = var(4) = 0 && Time > 0
trigger1 = AILevel = 0 && command = "holdfwd"
trigger1 = command = "a" || command = "b" || command = "c" || command = "x" || command = "y" || command = "z"
trigger2 = AILevel != 0
trigger2 = P2BodyDist X >= 0 
trigger2 = P2BodyDist Y = [-35,35]
trigger2 = var(15) < 5
trigger2 = P2StateType != L
trigger2 = IfElse(StateNo < 3000, AnimElemTime(13) >= 0, StateNo = 3002 && Time >= 0)
var(4) = 6
persistent = 0

[State 1010, VarSet]
type = VarSet
triggerall = (StateNo = [1010,1015]) || (StateNo = [3000,3002])
triggerall = var(4) = 0 && Time > 0
trigger1 = AILevel = 0 && command = "holdback"
trigger1 = command = "a" || command = "b" || command = "c" || command = "x" || command = "y" || command = "z"
trigger2 = AILevel != 0
trigger2 = P2BodyDist X < 0 
trigger2 = P2BodyDist Y = [-35,35]
trigger2 = var(15) < 5
trigger2 = P2StateType != L
trigger2 = IfElse(StateNo < 3000, AnimElemTime(13) >= 0, StateNo = 3002 && Time >= 0)
var(4) = 4
persistent = 0

;==

[State -3, Superjump VarSet]
type = VarSet
trigger1 = command = "highjump"
v = 5  
value = 1

[State -3, Superjump Var Reset]
type = VarSet
trigger1 = stateno = 52
trigger2 = MoveType = H
var(5) = 0

;==

[State -3, CornerPush Disabled]
type = VarSet
triggerall = Vel X = 0
triggerall = Vel Y = 0
trigger1 = NumHelper(30000) = 1
trigger2 = NumHelper(30001) = 1
trigger3 = NumHelper(30002) = 1
trigger4 = StateNo = [3000,3050]
var(10) = 2

[State -3, Standard Victory Quote]
type = VictoryQuote
triggerall = NumEnemy
trigger1 = !WinPerfect
value = (Random%11)

[State -3, Perfect Victory Quote]
type = VictoryQuote
triggerall = NumEnemy
trigger1 = WinPerfect
value = 20 + random % 2

;== Juggle System by Zero-Sennin ==

[State -3, var(15) = 1 (Air Reset)]
type = VarSet
triggerall = var(22) <= 0
triggerall = var(15) = 0
triggerall = stateno = [200,650]
triggerall = MoveHit
triggerall = NumTarget
trigger1 = Target, StateNo = [5030,5040]
var(15) = 1
ignorehitpause = 1
persistent = 0

[State -3, var(15) = 4 (Full Reset)]
type = VarSet
trigger1 = StateNo = [3000,3050]
trigger1 = MoveType = I
trigger2 = HitDefAttr = SCA, AT
trigger3 = NumEnemy
trigger3 = EnemyNear,StateType = L || EnemyNear, StateNo = [5100,5210]
trigger4 = RoundState != 2
var(15) = 4
ignorehitpause = 1

[State -3, var(15) = 0 (Enemy Recovers)]
type = VarSet
trigger1 = NumEnemy
trigger1 = EnemyNear,MoveType != H
trigger1 = EnemyNear, StateNo != [5030,5040]
trigger1 = EnemyNear, StateNo != [5100,5210]
trigger2 = MoveType = H
trigger3 = StateType = L
trigger4 = var(22) && StateNo != 450
var(15) = 0
ignorehitpause = 1
persistent = 0

;== Hit Detection ==

[State -3, Var(16) MoveHit]
type = VarSet
trigger1 = MoveHit
var(16) = ifElse(MoveHit, 1, 3)
ignorehitpause = 1

[State -3, Var(16) Move/Projectile Guarded/Reversed]
type = VarSet
trigger1 = MoveGuarded
trigger2 = ProjGuarded = 1
trigger3 = MoveReversed
var(16) = ifElse((MoveGuarded||MoveReversed),2,4)
ignorehitpause = 1

[State -3, Var(16) Reset]
type = VarSet
trigger1 = Time = 1
trigger2 = MoveType = I
trigger3 = MoveType = H
var(16) = 0
ignorehitpause = 1

;== Hit Detection ==

[State -3, Special Cancel Variable Set]
type = VarSet
triggerall = MoveType = A
triggerall = StateNo = [200,651]
triggerall = Var(18) < 5
trigger1 = Var(16) = [1,2]
trigger1 = StateNo != 230
trigger1 = StateNo != 240
trigger1 = StateNo != 250
trigger1 = StateNo != 450
trigger1 = StateNo != 650
var(17) = 1
ignorehitpause = 1

[State -3, Super Cancel Variable Set]
type = VarSet
triggerall = MoveType = A
triggerall = StateNo = [1000,1999]
trigger1 = Var(16) = [1,2]
var(17) = 2
ignorehitpause = 1

[State -3, Cancel Variable Reset]
type = VarSet
trigger1 = Var(16) = 0
trigger2 = MoveType = H
var(17) = 0
ignorehitpause = 1

;== Attack Strength Detection (Self) ==

[State -3, Light Attack VarSet]
type = VarSet
trigger1 = StateNo = 200
trigger2 = StateNo = 400
trigger3 = StateNo = 600
trigger4 = StateNo = 230
trigger5 = StateNo = 430
trigger6 = StateNo = 630
var(18) = 1
ignorehitpause = 1

[State -3, Medium Attack VarSet]
type = VarSet
trigger1 = StateNo = 210
trigger2 = StateNo = 410
trigger3 = StateNo = 610
trigger4 = StateNo = 240
trigger5 = StateNo = 440
trigger6 = StateNo = 640
var(18) = 2
ignorehitpause = 1

[State -3, Heavy Attack VarSet]
type = VarSet
trigger1 = StateNo = 220
trigger2 = StateNo = 420
trigger3 = StateNo = 620
trigger4 = StateNo = 250
trigger5 = StateNo = 450
trigger6 = StateNo = 650
var(18) = 3
ignorehitpause = 1

[State -3, Command Attack VarSet]
type = VarSet
trigger1 = StateNo = 241
trigger2 = StateNo = 252
trigger3 = StateNo = 651
var(18) = 4
ignorehitpause = 1

[State -3, Attack Type Var Reset]
type = VarSet
trigger1 = Var(16) = 0
trigger2 = MoveType = H
var(18) = 0
ignorehitpause = 1

;== 
;Damage Dampening System

[State -3, Hit Count Add]
type = VarAdd
triggerall = NumEnemy
triggerall = HitDefAttr != SCA, AT
trigger1 = MoveHit = 1
var(20) = 1
persistent = 0

[State -3, Hit Counter Reset]
type = VarSet
triggerall = NumEnemy
trigger1 = EnemyNear, MoveType != H
var(20) = 0
ignorehitpause = 0
persistent = 0

[State -3, Decay Set]
type = VarSet
triggerall = NumEnemy
trigger1 = 1
fvar(20) = 1 - .05 * var(20)
ignorehitpause = 1
persistent = 1

[State -3, Minimum Multiplier Calculation (Normals/Specials)]
type = VarSet
triggerall = NumEnemy
triggerall = StateNo = [200, 3000)
triggerall = Enemy,GetHitVar(HitCount) > 0
triggerall = fvar(20) <=  0.2
trigger1 = 1
fvar(20) = 0.2
ignorehitpause = 1

[State -3, Minimum Multiplier Calculation (Supers)]
type = VarSet
triggerall = NumEnemy
triggerall = StateNo = [3000,3999]
triggerall = Enemy,GetHitVar(HitCount) > 0
triggerall = fvar(20) <=  0.4
trigger1 = 1
fvar(20) = 0.4
ignorehitpause = 1

;==

[State -3, Projectile Variable Set]
type = VarSet
triggerall = 1
trigger1 = NumHelper(11000) = 0
trigger1 = NumHelper(11001) = 0
trigger1 = NumHelper(11002) = 0
trigger1 = NumHelper(11010) = 0
trigger1 = NumHelper(11011) = 0
trigger1 = NumHelper(11012) = 0
trigger1 = NumHelper(13020) = 0
trigger1 = NumHelper(13021) = 0
var(25) = 0
ignorehitpause = 1

;==

[State -3, Psi-Blade Cancel Set]
type = VarSet
trigger1 = StateNo = [1005,1007]
trigger1 = MoveType = I
var(3) = 0
ignorehitpause = 1

[State -3, Psi-Blade Counter Set]
type = VarSet
trigger1 = StateNo = 1003
trigger2 = MoveType = H
var(26) = 0
ignorehitpause = 1

[State -3, Bound Check]
type = VarSet
triggerall = NumEnemy
trigger1 = Enemy, MoveType != H
var(28) = 0
ignorehitpause = 1
persistent = 0

;== Reversals

[State -2, Reversals Allowed]
type = VarSet
;trigger1 = StateNo = 15110 && Time >= 15; Can reversal after the first 15 frames of liedown
trigger1 = StateNo = 5120 && Time >= 9 ; Can reversal during the last 5 frames of wakeup
trigger2 = StateNo = 5201 && AnimTime >= -10 ; Can reversal during the last 10 frames of recovery roll
var(44) = 1
ignorehitpause = 1
persistent = 0

[State -2, Reversals Disallowed]
type = VarSet
trigger1 = (StateNo = [150,155]) && !Time ; Cannot reversal immediately after entering blockstun
trigger2 = StateNo < 120 && var(44) = 1 && Time > 10 ; Cannot reversal after 10 frames have passed in an idle state
trigger3 = StateNo = 5120 && Time < 9 ; Cannot reversal after the first 10 frames of wakeup
trigger4 = StateNo = 5201 && AnimTime < -10 ; Cannot reversal before 10 frames of recovery roll
var(44) = 0
ignorehitpause = 1
persistent = 0

[State -2, Reversals Reset]
type = VarSet 
triggerall = var(44) = 1
trigger1 = StateNo = [200,3999]
trigger2 = StateNo = 5000 || StateNo = 5010 || (StateNo = [5030,5090])
trigger3 = StateNo = 0
var(44) = 0

;== 


[State -3, Jumping Sound]
type = PlaySnd
trigger1 = Time = 1
trigger1 = stateno = 50 && PrevStateNo = 40
value = S40, var(5)

[State -3, Jumping Sound 2]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 241
trigger2 = stateno = 252
value = S40, 0

[State -3, Landing Sound]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = 52
trigger2 = StateNo = 106
trigger3 = StateNo = 1003
value = S52,0

[State -3, Punch Swing 1]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = [200,201]
trigger2 = stateno = 400
trigger3 = stateno = 600
value = S5,6

[State -3, Punch Swing 2]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = [210,211]
trigger2 = stateno = 410
trigger3 = stateno = 610
value = S5,7

[State -3, Punch Swing 3]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = 220
trigger2 = StateNo = 420
trigger3 = StateNo = 620
value = S5,8

[State -3, Kick Swing 1]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = [230,231]
trigger2 = stateno = 430
trigger3 = stateno = 630
value = S5,9

[State -3, Kick Swing 2]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 240
trigger2 = stateno = 440
trigger3 = stateno = 640
trigger4 = stateno = 1010
trigger5 = stateno = 1011
value = S5,10

[State -3, Kick Swing 3]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = [250,251]
trigger2 = StateNo = 450
trigger3 = StateNo = [650,651]
value = S5,11

[State 10200, PlaySnd]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = 210
trigger2 = StateNo = 410
trigger3 = StateNo = 610
value = S210,0
volumescale = 100
channel = 0

[State 10200, PlaySnd]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = 220
trigger2 = StateNo = 420
trigger3 = StateNo = 620
value = S220,0
volumescale = 100
channel = 0

[State 10200, PlaySnd]
type = PlaySnd
triggerall = Time = 1
trigger1 = Anim = [1000,1002]
value = S1000,0
volumescale = 100
channel = 0

[State 10200, PlaySnd]
type = PlaySnd
triggerall = Time = 1
trigger1 = Anim = [1005,1007]
value = S1005,0
volumescale = 100
channel = 0

[State 10200, PlaySnd]
type = PlaySnd
triggerall = Time = 1
trigger1 = Anim = 1010
value = S1010,1
volumescale = 100
channel = 0

[State -3, Grab Miss]
type = PlaySnd
trigger1 = Anim = 800 
trigger1 = AnimElem = 3
value = S800,0
channel = 0

[State -3, Grab Whiff]
type = PlaySnd
trigger1 = Anim = 800
trigger1 = AnimElem = 3
trigger2 = Anim = 810
trigger2 = AnimElem = 3
value = S5,8
channel = 1

[State -3, Randomized Voice] ;Attack Voice
type = PlaySnd
triggerall = Time = 1
triggerall = Random % 2 = 0
trigger1 = stateno = [200,650]
value = S200,0+(Random%2)
volumescale = 100
channel = 0

[State -3, Randomized Voice 2] ;Hurt Voice
type = PlaySnd
triggerall = Time = 1
triggerall = Random < 499
triggerall = Alive
trigger1 = stateno = 5001
trigger2 = stateno = 5011
trigger3 = stateno = 5021
trigger4 = stateno = 5030
value = S5000,0+(Random%2)
volumescale = 100
channel = 0
