;=====================
;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(1)
; Var(2) - 6C charge check

; Var(5) - Superjump Check

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

; Var(15) - Is flagged as 1 in situations where the AI cannot land hits.
; 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: Medium Attacks
	; 3: Heavy Attacks
	; 4: Command Attacks, Drive Attacks
	; 5: A/B Special Attacks
	; 6: C Special Attacks, Command Drive Attacks
	; 7: Lv. 1 Supers
	; 8: Lv. 2-3 Supers

; Counter and counter-hit vars
; 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(23) - Wallbounce trigger for State 3000

; Var(25) - D Attack Enabled/Disabled
; Var(26) - D Attack Stocks

; Hitstun and Untechable Proration Vars
; Var(30) - Hitstun Scaling (for aerial enemies). Increases by 1 for every six hits landed.
; Var(31) - Hitstun Scaling (for grounded enemies). Increases by 1 for every six hits landed.
; Var(32) - When set to 1 (going from ground combos to air combos), reduces the scaling slightly.

; Var(56) - Special KO Variable
; Var(57) - Burst Mode cooldown FX control (controls the G and B values of PalFX in State -3)
; Var(58) - Burst Mode cooldown timer (always shares the same value as var(0) of helper 10700)
; Var(59) - Burst Mode state (0 = inactive, 1 = active, 2 = cooldown)

;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 = 400			;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 = 15		;Player width (back, ground)
ground.front = 15		;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 = -6.5,-2.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 = "Death isn't something to take lightly. It changes you when you've seen it up close."
victory1 = "I'm sorry about all of this. You should be able to get to a hospital from here."
victory2 = "I really wasn't looking for a fight, but I have to admit that you're tough."
victory3 = "That was really close...I think I could've lost that time."
victory4 = "I hope this taught you a lesson about picking fights for no reason."
victory5 = "I don't take life so lightly that I'd kill people carelessly. Let's not do this again."
victory6 = "There's nothing really fun about betting your life on a fight."
victory7 = "Whew...that was exhausting."
victory8 = "I'm gonna need a nap...my heart's racing."
victory9 = "Well, I guess that's over...."

;==
; Special quotes
victory10 = "I guess you really couldn't keep up, huh? You didn't even hit me once." ;Perfect

victory20 = "Is this...another illusion...?" ; Mirror match
victory21 = "Oh, Sensei. How do you think I did? I've been trying to live like you told me to all those years ago." ; Aoko
victory22 = "I'll beat you back as many times as I have to. I'm not a slave to my bloodlust." ; Nanaya
victory23 = "Ghh...! Those eyes...why do they seem so familiar?" ;Kouma
victory24 = "Akiha, I can take care of myself. You don't have to keep worrying about me." ;Akiha

;---------------------------------------------------------------------------
; 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 % 4

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

[State 181, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 8
value = S181,0
volumescale = 200

[State 181, AssertSpecial]
type = AssertSpecial
trigger1 = Time < 225
flag = roundnotover

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

[State 182, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 8
value = S181,1
volumescale = 200

[State 182, AssertSpecial]
type = AssertSpecial
trigger1 = Time < 225
flag = roundnotover


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

[State 183, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 8
value = S181,2
volumescale = 200

[State 183, AssertSpecial]
type = AssertSpecial
trigger1 = Time < 225
flag = roundnotover

;---------------------------------------------------------------------------
; Win pose 4
[Statedef 184]
type = S
ctrl = 0
anim = 184
velset = 0,0

[State 184, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 11
value = S181,3
volumescale = 200

[State 184, AssertSpecial]
type = AssertSpecial
trigger1 = Time < 225
flag = roundnotover


;---------------------------------------------------------------------------
; Win pose 5
[Statedef 185]
type = S
ctrl = 0
anim = 185
velset = 0,0

[State 185, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 11
value = S181,4
volumescale = 200

[State 185, AssertSpecial]
type = AssertSpecial
trigger1 = Time < 225
flag = roundnotover

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

[State 190, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 191

[State 191, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 2
value = S191, 0
volumescale = 200

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

[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 192, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 192

[State 192, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 3
value = S191, 1
volumescale = 200

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

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

;---------------------------------------------------------------------------
; Introduction 3
[Statedef 193]
type = S
ctrl = 0
anim = 193
velset = 0,0

[State 193, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 193

[State 193, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 3
value = S191, 2
volumescale = 200

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

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

;---------------------------------------------------------------------------
; Introduction 4 (vs. Aoko)
[Statedef 194]
type = S
ctrl = 0
anim = 194
velset = 0,0

[State 194, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 194

[State 194, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 2
value = S194, 0
volumescale = 200

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

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

;---------------------------------------------------------------------------
; 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 = "var(15) = %d, var(17) = %d"
params = var(15), var(17)

[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 = P2BodyDist X > 40
var(0) = 1

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

[State -2, Throws Disallowed]
type = VarSet
triggerall = NumEnemy
triggerall = RoundState = 2
trigger1 = (enemynear,stateno = [150,155])
trigger2 = EnemyNear, StateType != A 
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 = P2BodyDist X > 40
var(1) = 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 = StateNo < 3000 && var(22) >= 30 && var(16) = 1;Reset if 22 ticks passed and move hit
trigger2 = (StateNo = [3000,3999]) && var(22) >= 60 && var(16) = 1;Reset if 22 ticks passed and move hit
trigger3 = p2movetype != h ;Reset if P2 is no longer in gethit state
trigger4 = 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

[State -2, Air Jump Install Var Reset]
type = VarSet
trigger1 = Anim = 47
trigger2 = MoveType = H
var(6) = 0

[State -2, Air Dash Install Var Reset]
type = VarSet
trigger1 = Anim = 47
trigger2 = MoveType = H
var(7) = 0

;== Hitstun/Untech Scaling

[State -2, Hitstun Scaling - Air]
type = VarAdd
triggerall = NumEnemy
triggerall = MoveHit = 1
triggerall = Var(30) < 15
trigger1 = P2StateType = A && (enemy,gethitvar(hitcount)%6)
var(30) = 1
persistent = 0

[State -2, Hitstun Scaling - Ground]
type = VarAdd
triggerall = NumEnemy
triggerall = MoveHit = 1
triggerall = Var(30) < 15
trigger1 = P2StateType != A  && (enemy,gethitvar(hitcount)%6)
var(31) = 1
persistent = 0

[State -2, VarSet]
type = VarSet
trigger1 = P2StateType != A && var(31) != 0
var(32) = 1

[State -2, VarSet]
type = VarSet
trigger1 = Var(32) = 1 && GameTime % 1 = 0
var(32) = 2

[State -2, Apply Half of Ground Hitstun Scaling to Air Hitstun Scaling]
type = VarSet
trigger1 = P2StateType = A && Var(32) = 1
var(30) = var(30) - floor((var(31)/2))

[State -2, Hitstun Scaling Var Reset]
type = VarSet
triggerall = NumEnemy
trigger1 = P2MoveType != H
var(30) = 0
ignorehitpause = 1
;==

[State -2, Untech Proration (Normal Moves)]
type = VarAdd
triggerall = Var(18) = [1,4]
triggerall = MoveHit = 1
triggerall = NumEnemy
triggerall = Enemy, HitFall = 1
trigger1 = Enemy, GetHitVar(HitCount) > 1
var(35) = 2
persistent = 0

[State -2, Untech Proration Reset]
type = VarSet
triggerall = Var(35)
triggerall = NumEnemy
trigger1 = Enemy, MoveType != H
var(35) = 0
ignorehitpause = 1

[State -3, var(15) = 0 (Enemy Recovers)]
type = VarSet
trigger1 = NumEnemy
trigger1 = EnemyNear, MoveType != H
trigger2 = NumEnemy
trigger2 = (EnemyNear, StateNo != [5110,5210])
trigger3 = NumEnemy
trigger3 = (EnemyNear, PrevStateNo != [5110,5210])
trigger4 = MoveType = H
trigger5 = StateType = L
trigger6 = EnemyNear, MoveType = A
trigger7 = EnemyNear, StateType = L
var(15) = 0
ignorehitpause = 1
persistent = 0

[State -3, var(15) = 1 (Full Reset)]
type = VarSet
trigger1 = HitDefAttr = SCA, AT
;==
trigger2 = NumEnemy
trigger2 = (EnemyNear, StateNo = [5110,5120]) || (EnemyNear, StateNo = [5200,5210])
;==
trigger3 = NumEnemy
trigger3 = (EnemyNear, PrevStateNo = [5110,5120]) || (EnemyNear, PrevStateNo = [5200,5210])
trigger3 = StateNo != 0
;==
trigger4 = RoundState != 2
;==
trigger5 = NumEnemy
trigger5 = EnemyNear, StateNo = [15000,59999]
;==
trigger6 = NumEnemy
trigger6 = EnemyNear, HitFall = 1 && EnemyNear, Vel Y > 0 && EnemyNear, Pos Y >= -5
;==
trigger7 = PrevStateNo = [800,899]
;==
trigger8 = P2StateType = L
var(15) = 1
ignorehitpause = 1

[State -2, Custom State]
type = TargetState
triggerall = StateNo != [3020,3025]
triggerall = MoveType = A && NumTarget(StateNo)
trigger1 = P2StateType = A && movehit = 1 && (P2StateNo!=[55020,55035])
value = 55020
ID = StateNo
ignorehitpause = 1 

[State -2, Custom State 2]
type = TargetState
triggerall = MoveType = A && NumTarget(55050)
triggerall = Target, HitShakeOver = 1
trigger1 = P2StateType = A && movehit = 1 && (P2StateNo!=[55020,55035])
value = 55050
id = 55050
ignorehitpause = 1 

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

[Statedef -3]

[State -3, PowerSet]
type = PowerSet
trigger1 = PalNo = 12 && var(59) = 0
value = 3000
ignorehitpause = 1
persistent = 1

[State -3, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noairguard

[State -3, AssertSpecial]
type = AssertSpecial
triggerall = RoundState > 2
trigger1 = var(56)
flag = nomusic 

[State -3, ScreenBound]
type = ScreenBound
triggerall = RoundState > 2
trigger1 = var(56)
value = 1
movecamera = 0,0

[State -3, Var(16) Reset]
type = VarSet
triggerall = var(56)
trigger1 = PrevStateNo = 3021 && RoundState < 3
var(56) = 0
ignorehitpause = 1

[State -3, Superjump VarSet]
type = VarSet
triggerall = StateNo != 45
triggerall = PrevStateNo != 45
triggerall = StateType != A
trigger1 = command = "highjump"
var(5) = 1
ignorehitpause = 1
persistent = 1

[State -3, Dust]
type = Helper
triggerall = NumHelper(10040) = 0
trigger1 = StateNo = 50 && Time = 1 && PrevStateNo != 45
trigger2 = StateNo = 52 && Time = 1
trigger3 = (StateNo = [100,106]) && Time = 1
trigger4 = Anim = [1005,1007]
trigger4 = Time = 1
trigger5 = Anim = 3002 && 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 -3, CH Helper]
type = Helper
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.
triggerall = NumHelper(10010) = 0
trigger1 = var(21) = 1 && Var(16) = 1 ;Move hit, Ok
name = "Counter FX"
ID = 10010
stateno = 10010
pos = 0,0
postype = p1  
facing = 1
keyctrl = 0
ownpal = 1
ignorehitpause = 1

[State -3, Burst Mode Helper]
type = Helper
triggerall = StateNo = [700,701]
trigger1 = NumHelper(10012) = 0
name = "Burst Mode FX"
ID = 10012
stateno = 10010
pos = 0,0
postype = p1  
facing = 1
keyctrl = 0
ownpal = 1
ignorehitpause = 1

[State -3, Helper]
type = Helper
triggerall = NumHelper(10700) = 0
trigger1 = StateNo = 700 && var(59) = 1
name = "Power Drain" 
ID = 10700
stateno = 10700
pos = 0,0
postype = p1    ;p2,front,back,left,right
pausemovetime = 999
ownpal = 1
scale = 1,1
persistent = 0

[State -3, Helper]
type = Helper
trigger1 = NumHelper(10230) = 0
name = "Teleport Tracker" 
ID = 10230
stateno = 10230
pos = 0,0
postype = p1    ;p2,front,back,left,right
pausemovetime = 999
ownpal = 1
scale = 1,1
persistent = 0

[State -3, Superjump Var Reset]
type = VarSet
trigger1 = stateno = 52
trigger2 = MoveType = H
trigger3 = StateNo != [40,50] 
trigger3 = Time = 1
var(5) = 0
ignorehitpause = 1
persistent = 1

[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%10)

[State -3, Perfect Victory Quote]
type = VictoryQuote
triggerall = NumEnemy
trigger1 = WinPerfect
trigger1 = EnemyNear, Name != "ZSShiki"
trigger1 = EnemyNear, Name != "ZSAoko"
trigger1 = EnemyNear, Name != "ZSKouma"
trigger1 = EnemyNear, Name != "ZSNanaya"
value = 10

[State -3, Mirror]
type = VictoryQuote
triggerall = NumEnemy
trigger1 = EnemyNear, Name = "ZSShiki"
value = 20

[State -3, Vs. Aoko]
type = VictoryQuote
triggerall = NumEnemy
trigger1 = EnemyNear, Name = "ZSAoko"
value = 21

[State -3, Vs. Nanaya]
type = VictoryQuote
triggerall = NumEnemy
trigger1 = EnemyNear, Name = "ZSNanaya"
value = 22

[State -3, Vs. Kouma]
type = VictoryQuote
triggerall = NumEnemy
trigger1 = EnemyNear, Name = "ZSKouma"
value = 23

;= Invul State Check

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

;== Special/Super Cancel Detection ==

[State -3, Special Cancel Variable Set]
type = VarSet
triggerall = MoveType = A
triggerall = StateNo = [200,620] 
triggerall = Var(18) < 5 ; Applies to normals and command moves only
triggerall = Var(16) = [1,2] ; Move must make contact
trigger1 = StateNo != 420
var(17) = 1
ignorehitpause = 1

[State -3, Super Cancel Variable Set (Specials and EX Specials]
type = VarSet
triggerall = MoveType = A
triggerall = Var(18) = [5,6] ;Applies to Specials and EX Specials only
triggerall = StateNo != [2000,2005]
trigger1 = Var(16) = [1,2]
var(17) = 2
ignorehitpause = 1

[State -3, Super Cancel Variable Set (Lv. 1 Supers)]
type = VarSet
triggerall = MoveType = A
triggerall = Var(18) = 7 && StateNo < 3010 ;Applies to Specials and EX Specials only
trigger1 = Var(16) = [1,2]
var(17) = 3
ignorehitpause = 1

[State -3, Cancel Variable Reset]
type = VarSet
trigger1 = Var(16) = 0
trigger2 = StateNo = [800,899]
var(17) = 0
ignorehitpause = 1
persistent = 0

;== Attack Strength Detection (Self) ==

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

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

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

[State -3, Command Attack VarSet]
type = VarSet
trigger1 = StateNo = [221,232]
trigger2 = StateNo = 421
trigger3 = StateNo = 430
trigger4 = StateNo = 630
var(18) = 4
ignorehitpause = 1

[State -3, Special Attack VarSet]
type = VarSet
trigger1 = StateNo = [1000,1999]
var(18) = 5
ignorehitpause = 1

[State -3, EX Special Attack VarSet]
type = VarSet
trigger1 = StateNo = 1002
trigger2 = StateNo = 1007
trigger3 = StateNo = 1012
trigger4 = StateNo = 1017
trigger5 = StateNo = [2000,2999]
var(18) = 6
ignorehitpause = 1

[State -3, Super Attack VarSet]
type = VarSet
trigger1 = StateNo = [3000,3005]
var(18) = 7
ignorehitpause = 1

[State -3, EX Super Attack VarSet]
type = VarSet
trigger1 = StateNo > 3005
var(18) = 8
ignorehitpause = 1

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

;==

[State -3, Jump Buffer Command Var Reset]
type = VarSet
trigger1 = MoveType = A
trigger2 = MoveType = H
var(19) = 0
ignorehitpause = 1

;== 
;Damage Dampening System

[State -3, Hit Count Add]
type = VarAdd
triggerall = NumEnemy
triggerall = HitDefAttr != SCA, AT
trigger1 = MoveHit = 1
trigger1 = StateNo != [1000,1002]
trigger1 = StateNo != 3000
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,3020)
triggerall = Enemy,GetHitVar(HitCount) > 0
triggerall = fvar(20) <=  0.4
trigger1 = 1
fvar(20) = 0.4
ignorehitpause = 1

[State -3, Minimum Multiplier Calculation (NEOMAX)]
type = VarSet
triggerall = NumEnemy
triggerall = StateNo = [3020,3025] 
triggerall = Enemy,GetHitVar(HitCount) > 0
triggerall = fvar(20) <= 0.5
trigger1 = 1
fvar(20) = 0.5
ignorehitpause = 1

;==

[State -3, Jumping Sound]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = 50 && PrevStateNo = 40
trigger2 = StateNo = 100
trigger3 = StateNo = 105
value = S40, var(5)

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


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

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

[State -3, Punch Swing 3]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = 410
value = S5,8

;[State -3, Kick Swing 1]
;type = PlaySnd
;triggerall = Time = 1
;trigger1 = stateno = 0
;value = S5,9

[State -3, Kick Swing 2]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = 210
trigger2 = stateno = 610
value = S5,10

[State -3, Kick Swing 3]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = 220
trigger2 = stateno = [225,226]
trigger3 = stateno = 420
trigger4 = stateno = 620
trigger5 = stateno = [1010,1012]
value = S5,11

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

[State -3, Grab Miss]
type = PlaySnd
trigger1 = Anim = 810
trigger1 = AnimElem = 3
value = S810, Random % 2
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 1] ;Attack Voice 1
type = PlaySnd
triggerall = Time = 1
triggerall = Random % 2 = 0
triggerall = var(18) < 4
trigger1 = StateNo = 200
trigger2 = StateNo = 400
trigger3 = StateNo = 600
value = S200, Random % 2
volumescale = 200
channel = 0

[State -3, Randomized Voice 2] ;Attack Voice 2
type = PlaySnd
triggerall = Time = 1
triggerall = Random % 2 = 0
triggerall = var(18) < 4
trigger1 = StateNo = 210
trigger2 = StateNo = 410
trigger3 = StateNo = 610
value = S210, Random % 2
volumescale = 200
channel = 0

[State -3, Randomized Voice 3] ;Attack Voice 3
type = PlaySnd
triggerall = Time = 1
triggerall = Random % 2 = 0
triggerall = var(18) < 4
trigger1 = StateNo = 220
trigger2 = StateNo = 420
trigger3 = StateNo = 620
value = S220, Random % 2
volumescale = 200
channel = 0

[State -3, Randomized Voice 3] ;Attack Voice 4
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = [230,232]
trigger2 = StateNo = 430
trigger3 = StateNo = 630
trigger4 = StateNo = [2000,2005]
value = S230, 0
volumescale = 200
channel = 0

[State -3, Command Attack Voices]
type = PlaySnd
triggerall = var(18) = 4
trigger1 = Time = 1	
trigger1 = StateNo != 226
value = S(StateNo), 0
volumescale = 200
channel = 0
ignorehitpause = 1

[State -3, Magic Draw Voices]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = [1000,1002]
value = S1000, 0
volumescale = 200
channel = 0
ignorehitpause = 1

[State -3, Magic Draw Voices]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = [1005,1007]
value = S1005, 0
volumescale = 200
channel = 0
ignorehitpause = 1

[State -3, Magic Draw Voices]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = [1010,1012]
value = S1010, 0
volumescale = 200
channel = 0
ignorehitpause = 1

[State -3, Magic Draw Voices]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = [1015,1017]
value = S1015, 0
volumescale = 200
channel = 0
ignorehitpause = 1

[State -3, Super Voices]
type = PlaySnd
triggerall = var(18) = 7
trigger1 = Time = 1
value = S(StateNo), 0
volumescale = 200
channel = 0
ignorehitpause = 1

[State -3, Randomized Voice 5] ;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, Random % 3
volumescale = 200
channel = 0

[State -3, Randomized Voice 6] ;Hurt Voice
type = PlaySnd
triggerall = Time = 1
triggerall = Alive
trigger1 = stateno = [5200,5210]
value = S5200, Random%2
volumescale = 200
channel = 0

;== Burst Mode Effects

[State -3, Burst Mode FX]
type = PalFX
triggerall = Var(59) = 1
trigger1 = GameTime % 20 = 0
time = 20
add = 0,0,0
mul = 256,256,256
sinadd = 43,43,43,20
invertall = 0
color = 256
persistent = 1
ignorehitpause = 1

[State -3, AfterImage]
type = AfterImage
triggerall = Var(59) = 1
trigger1 = GameTime % 20 = 0
time = 20
length = 20
palcolor = 256
palinvertall = 0
palbright = 30,30,30
palcontrast = 120,120,220
palpostbright = 0,0,0
paladd = 10,10,25
palmul = .65,.65,.75
timegap = 1
framegap = 4
trans = none

[State -3, Burst Cooldown FX]
type = PalFX
trigger1 = Var(59) = 2
time = 20
add = 0,0,0
mul = 256, var(57), var(57)
sinadd = 0,0,0,0
invertall = 0
color = 256
persistent = 1
ignorehitpause = 1

[State -3, Cooldown Control Var Reset]
type = VarSet
trigger1 = Var(59) = 0 ; Set to 0 when Burst Mode is off
var(57) = 0
persistent = 1

[State -3, Cooldown Control Var Set]
type = VarSet
trigger1 = Var(59) = 1 ; Set to 112 when Burst Mode is on
var(57) = 160

[State -3, Cooldown Control Var Add]
type = VarAdd
triggerall = Var(59) = 2
triggerall = NumHelper(10700) = 1
triggerall = var(58) % 100 = 0
trigger1 = var(57) < 256
var(57) = 16 ; Slowly decrease the amount of red in the PalFX as the mode timer decreases

[State -3, Burst Mode End]
type = VarSet
triggerall = var(59) = 1 
trigger1 = StateNo < 200
trigger1 = Power = 0
trigger2 = StateNo = 3011 || StateNo = 3016
trigger2 = AnimTime = 0
trigger3 = StateNo = 3021
trigger3 = AnimTime = 0
var(59) = 2