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

		; 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
			; 3: Command Attacks
			; 4: Special Attacks
			; 5: Super 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(30) - Technical Bar Value (0-100)
		; Var(31) - Cancel Timer
		; Var(32) - T. Bar Overflow Buffer
		
		; Vars(40), (41), (42), (43) - Charge Buffer

	; Tatsuki's Personal Variables
	;--------
		; Var(1) - Special Throw Check (0 = Allowed, 1 = Disallowed)
		; Var(3) - Controls Jupiter Hold followups
			; 0 - None
			; 1 - Mars Palm
			; 2 - Mercury Lift
			; 3 - Uranus Swing ~Low Cluster~
			; 4 - Uranus Swing ~High Cluster~

;Floats
;--------
	; System Variables
	;--------
		; 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 = 14		;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 = 10, -70	;Approximate position of head
mid.pos = 0, -50		;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 = 3.4		;Walk forward
walk.back = -3.2		;Walk backward
run.fwd = 5.6, -4	;Run forward (x, y)
run.back = -5.5,-3.8	;Hop backward (x, y)
jump.neu = 0,-7.8		;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 = "Who am I? Just Seija Academy's strongest fighter, is all...hehehe!"
victory1 = "Hey, what was that? Don't mess with me! Fight me for real!"
victory2 = "That was great! Can you share some training tips with me?"
victory3 = "Wow, you're a tough one! That was a good fight!"
victory4 = "I'm not the type to quit...my sister, though, she'll say 'I quit' in the first five seconds."
victory5 = "Took your eyes off of me, huh? Not a smart idea. *smile*"
victory6 = "I'm pretty tough, aren't I?"
victory7 = "Training by yourself is really hard, but boy does it pay off."
victory8 = "Yeah! How'd you like that?!"
victory9 = "All right, I've gotta run! See ya!"
;==
; Special quotes
victory10 = "Awesome! I didn't even get hurt!" ; Perfect

victory20 = "Mr. Kurosawa, it was an honor! Your techniques are really something!" ; Vs. Kaneda
victory21 =  "I actually won a fight against Xia Chen! I can't believe it!" ;Vs. Xia
victory22 = "That was pretty good, Ai! I told you you were better than you thought you were!" ;Vs. Ai
victory23 = "...I'm flattered and all, but don't you think you'd do better if you were fighting as yourself?" ;Mirror match
;---------------------------------------------------------------------------
; 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 = IfElse(Enemy, Name != "Xia", 181 + Random % 2, 183)

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

[State 181, PlaySnd]
type = PlaySnd
trigger1 = AnimElemTime(4) = 0
trigger2 = AnimElemTime(7) = 0
value = F5, IfElse(AnimElemTime(4) = 0, 7, 8)
volumescale = 100
channel = 1

[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 = AnimElemTime(3) = 0
trigger2 = AnimElemTime(12) = 0
value = F5, IfElse(AnimElemTime(3) = 0, 10, 11)
volumescale = 100
channel = 1

[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 183, PlaySnd]
type = PlaySnd
trigger1 = AnimElemTime(2) = 0
value = F5, 8

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

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

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

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

[State 191, PlaySnd]
type = PlaySnd
trigger1 = AnimElem = 9
value = F5, 8
volumescale = 100

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

;---------------------------------------------------------------------------
; Introduction 2 (vs. Kaneda, Xia)
[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, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 192, PlaySnd]
type = PlaySnd
trigger1 = AnimElemTime(2) = 0
trigger2 = AnimElemTime(5) = 0
value = F5, IfElse(AnimElemTime(2) = 0, 7, 8)
volumescale = 100
channel = 1

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

;---------------------------------------------------------------------------
; Intro 3 (vs. Ai)
[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, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 193, PlaySnd]
type = PlaySnd
trigger1 = AnimElemTime(9) = 0
value = F5,8
volumescale = 100
channel = 1

[State 193, 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 195, 2]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; Initialize (at the start of the round)
[Statedef 5900]
type = S

[State 5900, 1] ;Clear all int variables
type = VarRangeSet
trigger1 = roundsexisted = 0
value = 0

[State 5900, 2] ;Clear all float variables
type = VarRangeSet
trigger1 = roundsexisted = 0
fvalue = 0

[State 5900, 3] ;Change palette
type = RemapPal
trigger1 = 1
source = 1,1
dest = 1,palno

[State 5900, 4] ;Intro for round 1
type = ChangeState
triggerall = roundno = 1
trigger1 = Enemy, Name = "Ai"
value = 193

[State 5900, 5] ;Intro for round 1
type = ChangeState
triggerall = roundno = 1
trigger1 = Enemy, Name = "Kaneda"
trigger2 = Enemy, Name = "Xia"
value = 192

[State 5900, 6] ;Intro for round 1
type = ChangeState
trigger1 = roundno = 1
value = 191

[State 5900, 7] ;All other rounds
type = ChangeState
trigger1 = 1
value = 0
;---------------------------------------------------------------------------
; Override common states (use same number to override) :
;---------------------------------------------------------------------------

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

[Statedef -3]

[State -3, Debug]
type = DisplayToClipboard
trigger1 = 1
text = "var(1) = %d, Juggle = %d, Cancels = %f"
params = var(1), var(15), fvar(20) 

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

[State -3, Special Throws Disallowed]
type = VarSet
triggerall = NumEnemy
trigger1 = (enemynear,stateno = [150,155])
trigger2 = ((enemynear,stateno = 0) || (enemynear,stateno = 52)) && (enemynear,prevstateno = [5000,5040]) && ((enemynear,time <= 0) || !(enemynear,ctrl))
trigger3 = (enemynear,stateno = 0) && (enemynear,prevstateno = 52) && ((enemynear,time <= 0) || !(enemynear,ctrl))
trigger4 = (enemynear,stateno = 40) && (enemynear,time>= 1 || enemynear,prevstateno = 0 || enemynear,prevstateno = 52)
trigger5 = MoveType = H
trigger6 = StateType = L
trigger7 = EnemyNear,StateType = L
trigger8 = P2BodyDist X > cond(StateNo < 3000, 50, 65)
var(1) = 1

[State -3, Forward Jump Dust]
type = Helper
triggerall = NumHelper(10042) = 0
trigger1 = Anim = 1001 && AnimElem = 3
trigger2 = StateNo = [1005,1006]
trigger2 = AnimElem = 8
name = "Dust"
ID = 10042
stateno = 10040
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
persistent = 0

[State -3, Landing Dust]
type = Helper
triggerall = NumHelper(10052) = 0
trigger1 = Anim = 1004 && Time = 1
name = "Dust"
ID = 10052
stateno = 10040
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
persistent = 0

[State -3, CornerPush Disabled (Cancels)]
type = VarSet
triggerall = 1
triggerall = Vel X = 0
trigger1 = StateNo = 700
trigger2 = StateNo = 701
trigger3 = PrevStateNo = [700,701]
var(10) = 2

[State -3, Counterhit Disabled]; Resets condition every tick to check again
type = VarRangeSet
trigger1 = StateNo = [1010,1016]
trigger2 = StateNo = [3010,3012]
first = 21
last = 22
value = 0
ignorehitpause = 1
persistent = 1

[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 != "Kaneda"
trigger1 = EnemyNear, Name != "Xia"
trigger1 = EnemyNear, Name != "Ai"
trigger1 = EnemyNear, Name != "Tatsuki"
value = 10

[State -3, Vs. Kaneda]
type = VictoryQuote
triggerall = NumEnemy
trigger1 = EnemyNear, Name = "Kaneda"
value = 20

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

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

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

;== Hit Detection ==

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

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

[State -3, Cancel Variable Reset]
type = VarSet
trigger1 = Var(16) = 0
trigger2 = MoveType = H
trigger3 = Anim = [1005,1006] 
trigger3 = MoveHit && var(15) 
var(17) = 0
ignorehitpause = 1

;== Attack Strength Detection (Self) ==

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

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

[State -3, Command Attack VarSet]
type = VarSet
trigger1 = StateNo = 202
var(18) = 3
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, 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 = 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 = StateNo = [3000,3999]
triggerall = Enemy,GetHitVar(HitCount) > 0
triggerall = fvar(20) <=  0.4
trigger1 = 1
fvar(20) = 0.4
ignorehitpause = 1

;== T. Bar System ==

[State -3, T. Shift Bar]
type = Helper
trigger1 = NumHelper(6000) = 0
name = "Meter Display"
ID = 6000
stateno = 6000
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
persistent = 0

[State -3, T. Bar Max Value]
type = VarSet
triggerall = RoundState < 2
trigger1 = Life = 1000 && Power = 3000
var(30) = 100
ignorehitpause = 1 
persistent = 0

[State -3, T. Bar Max Value]
type = VarSet
trigger1 = var(30) > 100
var(30) = 100
ignorehitpause = 1 
persistent = 1

[State -3, T. Bar Min Value]
type = VarSet
trigger1 = var(30) < 0 
var(30) = 0
ignorehitpause = 1 
persistent = 1

[State -3, T. Bar Overflow Value]
type = VarSet
trigger1 = 1
var(32) = 100-var(30)
ignorehitpause = 1

[State -3, T. Bar Increase (Normals)]
type = VarAdd
triggerall = var(31) = 0
triggerall = StateNo != [700,703]
triggerall = (StateNo = [200,650])
triggerall = var(30) < 100
trigger1 = movecontact = 1 
var(30) = IfElse(MoveHit = 1, IfElse(var(30) + 5 < 100, 5, var(32)), IfElse(var(30) + 2 < 100, 2, var(32)))
ignorehitpause = 0
persistent = 0

[State -3, T. Bar Increase (Special)]
type = VarAdd
triggerall = var(31) = 0
triggerall = StateNo != [700,703]
triggerall = StateNo = [1000,1999]
triggerall = var(30) < 100
trigger1 = movecontact = 1 
var(30) = IfElse(MoveHit = 1, IfElse(var(30) + 10 < 100, 10, var(32)), IfElse(var(30) + 5 < 100, 5, var(32)))
ignorehitpause = 0
persistent = 0

;==

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

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

[State -3, Punch Swing 3]
type = PlaySnd
triggerall = Time = 1
trigger1 = StateNo = [1005,1006]
value = F5,8

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

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

[State -3, Kick Swing 3]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 1012
trigger2 = stateno = [1020,1021]
value = F5,11

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

[State -3, Grab Whiff]
type = PlaySnd
triggerall = AnimElem = 3
trigger1 = Anim = 800
trigger2 = Anim = 1013
value = F5,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 = F5000,0+(Random%2)
volumescale = 100
channel = 0
