; 1. Command definition
; ---------------------

;-| Button Remapping |-----------------------------------------------------
; This section lets you remap the player's buttons (to easily change the
; button configuration). The format is:
;   old_button = new_button
; If new_button is left blank, the button cannot be pressed.
[Remap]
x = x
y = y
z = z
a = a
b = b
c = c
s = s

;-| Default Values |-------------------------------------------------------
[Defaults]
; Default value for the "time" parameter of a Command. Minimum 1.
command.time = 30

; Default value for the "buffer.time" parameter of a Command. Minimum 1,
; maximum 30.
command.buffer.time = 1

;-| Super Motions |--------------------------------------------------------

	[Command]
	name = "2QCF_p"
	command = ~D, DF, F, D, DF, F, x
	time = 30

	[Command]
	name = "2QCF_p"
	command = ~D, DF, F, D, DF, F, y
	time = 30

	[Command]
	name = "2QCF_k"
	command = ~D, DF, F, D, DF, F, a
	time = 30

	[Command]
	name = "2QCF_k"
	command = ~D, DF, F, D, DF, F, b
	time = 30

	[Command]
	name = "2B_F_bd"
	command = ~D, DF, F, D, DF, F, y+b
	time = 30

	;Reversed

	[Command]
	name = "2QCB_p"
	command = ~D, DB, B, D, DB, B, x
	time = 30

	[Command]
	name = "2QCB_p"
	command = ~D, DB, B, D, DB, B, y
	time = 30

	[Command]
	name = "2QCB_k"
	command = ~D, DB, B, D, DB, B, a
	time = 30

	[Command]
	name = "2QCB_k"
	command = ~D, DB, B, D, DB, B, b
	time = 30

	[Command]
	name = "2F_B_bd"
	command = ~D, DB, B, D, DB, B, y+b
	time = 30

;-| Special Motions |------------------------------------------------------

	[Command]
	name = "B_F_x"
	command = ~30$B, F, x
	time = 15

	[Command]
	name = "B_F_y"
	command = ~30$B, F, y
	time = 15

	[Command]
	name = "B_F_a"
	command = ~30$B, F, a
	time = 15

	[Command]
	name = "B_F_b"
	command = ~30$B, F, b
	time = 15

	[Command]
	name = "QCB_x"
	command = ~D, DB, B, x
	time = 15

	[Command]
	name = "QCB_y"
	command = ~D, DB, B, y
	time = 15


	;= Reversed commands ==

	[Command]
	name = "F_B_x"
	command = ~30$F, B, x
	time = 15

	[Command]
	name = "F_B_y"
	command = ~30$F, B, y
	time = 15

	[Command]
	name = "F_B_a"
	command = ~30$F, B, a
	time = 15

	[Command]
	name = "F_B_b"
	command = ~30$F, B, b
	time = 15

	[Command]
	name = "QCF_x"
	command = ~D, DF, F, x
	time = 15

	[Command]
	name = "QCF_y"
	command = ~D, DF, F, y
	time = 15


;-| Double Tap |-----------------------------------------------------------
[Command]
name = "FF"     ;Required (do not remove)
command = F, F
time = 10

[Command]
name = "BB"     ;Required (do not remove)
command = B, B
time = 10

[Command]
name = "highjump"
command = $D, $U
time = 20

;-| 2/3 Button Combination |-----------------------------------------------

	[Command]
	name = "recovery" ;Required (do not remove)
	command = x+y
	time = 3

	[Command]
	name = "recovery"
	command = a+b
	time = 3

	[Command]
	name = "throw"
	command = x+y
	time = 3

;-| Dir + Button |---------------------------------------------------------
[Command]
name = "back_x"
command = /$B,x
time = 1

[Command]
name = "back_y"
command = /$B,y
time = 1

[Command]
name = "back_z"
command = /$B,z
time = 1

[Command]
name = "down_x"
command = /$D,x
time = 1

[Command]
name = "down_y"
command = /$D,y
time = 1

[Command]
name = "down_z"
command = /$D,z
time = 1

[Command]
name = "fwd_x"
command = /$F,x
time = 1

[Command]
name = "fwd_y"
command = /$F,y
time = 1

[Command]
name = "fwd_z"
command = /$F,z
time = 1

[Command]
name = "up_x"
command = /$U,x
time = 1

[Command]
name = "up_y"
command = /$U,y
time = 1

[Command]
name = "up_z"
command = /$U,z
time = 1

[Command]
name = "back_a"
command = /$B,a
time = 1

[Command]
name = "back_b"
command = /$B,b
time = 1

[Command]
name = "back_c"
command = /$B,c
time = 1

[Command]
name = "down_a"
command = /$D,a
time = 1

[Command]
name = "down_b"
command = /$D,b
time = 1

[Command]
name = "down_c"
command = /$D,c
time = 1

[Command]
name = "fwd_a"
command = /$F,a
time = 1

[Command]
name = "fwd_b"
command = /$F,b
time = 1

[Command]
name = "fwd_c"
command = /$F,c
time = 1

[Command]
name = "up_a"
command = /$U,a
time = 1

[Command]
name = "up_b"
command = /$U,b
time = 1

[Command]
name = "up_c"
command = /$U,c
time = 1

;-| Single Button |---------------------------------------------------------
[Command]
name = "a"
command = a
time = 1

[Command]
name = "b"
command = b
time = 1

[Command]
name = "c"
command = c
time = 1

[Command]
name = "x"
command = x
time = 1

[Command]
name = "y"
command = y
time = 1

[Command]
name = "z"
command = z
time = 1

[Command]
name = "s"
command = s
time = 1

;-| Single Dir |------------------------------------------------------------
[Command]
name = "fwd" ;Required (do not remove)
command = $F
time = 1

[Command]
name = "downfwd"
command = $DF
time = 1

[Command]
name = "down" ;Required (do not remove)
command = $D
time = 1

[Command]
name = "downback"
command = $DB
time = 1

[Command]
name = "back" ;Required (do not remove)
command = $B
time = 1

[Command]
name = "upback"
command = $UB
time = 1

[Command]
name = "up" ;Required (do not remove)
command = $U
time = 1

[Command]
name = "upfwd"
command = $UF
time = 1

;-| Hold Button |--------------------------------------------------------------
[Command]
name = "hold_x"
command = /x
time = 1

[Command]
name = "hold_y"
command = /y
time = 1

[Command]
name = "hold_z"
command = /z
time = 1

[Command]
name = "hold_a"
command = /a
time = 1

[Command]
name = "hold_b"
command = /b
time = 1

[Command]
name = "hold_c"
command = /c
time = 1

[Command]
name = "hold_s"
command = /s
time = 1

;-| Hold Dir |--------------------------------------------------------------
[Command]
name = "holdfwd" ;Required (do not remove)
command = /$F
time = 1

[Command]
name = "holddownfwd"
command = /$DF
time = 1

[Command]
name = "holddown" ;Required (do not remove)
command = /$D
time = 1

[Command]
name = "holddownback"
command = /$DB
time = 1

[Command]
name = "holdback" ;Required (do not remove)
command = /$B
time = 1

[Command]
name = "holdupback"
command = /$UB
time = 1

[Command]
name = "holdup" ;Required (do not remove)
command = /$U
time = 1

[Command]
name = "holdupfwd"
command = /$UF
time = 1

;---------------------------------------------------------------------------
; 2. State entry
; --------------

[Statedef -1]

;===========================================================================
; AI Behavior
;===========================================================================

;---------------------------------------------------------------------------
[State -1, AI Defense]
type = ChangeState
triggerall = stateno!= [120,160] 
triggerall = roundstate = 2
triggerall = AILevel != 0
triggerall = ctrl
triggerall = StateType != A
trigger1 = InGuardDist 
trigger1 = (random<100*(AILevel**2/64.0))
value = 120

;---------------------------------------------------------------------------
[State -1, AI EX MILL]
type = ChangeState
value = 3000
triggerall = Power >= 1000
triggerall = random < 40 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 100
triggerall = abs(P2BodyDist X) <= 200
triggerall = StateType != A
triggerall = Var(15) < 4 && EnemyNear, StateType != L
trigger1 = ctrl
trigger2 = (var(17) = 1) 
trigger3 = StateNo = 5120 && Time > 3

;---------------------------------------------------------------------------
[State -1, AI EX PRESS]
type = ChangeState
value = 3005
triggerall = Power >= 1000
triggerall = random < 40 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 50
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 40, abs(P2BodyDist Y) = [10,50])
triggerall = StateType != A
triggerall = Var(15) < 4 && EnemyNear, StateType != L
trigger1 = ctrl
trigger2 = ((var(17) = 1) || EnemyNear, MoveType = A && ctrl)
trigger3 = StateNo = 5120 && Time > 3

;---------------------------------------------------------------------------
[State -1, AI GATLING]
type = ChangeState
value = 3010
triggerall = Power = 3000
triggerall = AILevel = 0
triggerall = random < 40 * (AILevel**2/64.0)
triggerall = abs(P2BodyDist X) <= 50
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 40, abs(P2BodyDist Y) = [10,50])
triggerall = StateType != A
triggerall = var(0) = 0
trigger1 = var(17) = 1
trigger2 = StateNo = 5120 && Time > 3

;---------------------------------------------------------------------------
[State -1, AI MILL]
type = ChangeState
value = 1000
triggerall = random < 80 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 70
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 100, abs(P2BodyDist Y) = [20,100])
triggerall = StateType != A
triggerall = Var(15) < 3 
trigger1 = ctrl
trigger2 = var(16) = 1 && var(17) = 1 
trigger3 = ctrl && EnemyNear, MoveType = A 

;---------------------------------------------------------------------------
[State -1, AI A SHOOT]
type = ChangeState
value = 1005
triggerall = random < 80 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 150
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 40, abs(P2BodyDist Y) = [20,50])
triggerall = StateType != A
triggerall = EnemyNear, MoveType != A
triggerall = Var(15) < 3 
trigger1 = ctrl
trigger2 = var(16) = 1 && var(17) = 1 
trigger3 = ctrl && EnemyNear, StateType = A 

;---------------------------------------------------------------------------
[State -1, AI B SHOOT]
type = ChangeState
value = 1006
triggerall = random < 80 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 75
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 100, abs(P2BodyDist Y) = [20,120])
triggerall = StateType != A
triggerall = EnemyNear, MoveType != A
triggerall = Var(15) < 3 
trigger1 = ctrl
trigger2 = var(16) = 1 && var(17) = 1 
trigger3 = ctrl && EnemyNear, StateType = A 

;---------------------------------------------------------------------------
[State -1, AI A PRESS]
type = ChangeState
value = 1010
triggerall = random < 70 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 60
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 40, abs(P2BodyDist Y) = [10,50])
triggerall = StateType != A
triggerall = EnemyNear, MoveType != A
triggerall = Var(15) < 3 
trigger1 = ctrl
trigger2 = var(16) = 1 && var(17) = 1 

;---------------------------------------------------------------------------
[State -1, AI B PRESS]
type = ChangeState
value = 1011
triggerall = var(25) = 0 
triggerall = random < 50 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 60
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 40, abs(P2BodyDist Y) = [10,50])
triggerall = StateType != A
triggerall = EnemyNear, MoveType != A
trigger1 = ctrl
trigger2 = ctrl && EnemyNear, StateType = L 

;---------------------------------------------------------------------------
[State -1, AI SHOOTING]
type = ChangeState
value = 800
triggerall = AILevel != 0 && RoundState = 2
triggerall = IfElse(EnemyNear, Name != "Kai", EnemyNear, MoveType != A, EnemyNear, MoveType != A || (EnemyNear, StateNo = 1005 || EnemyNear, PrevStateNo = 1005))
triggerall = StateType != A
triggerall = P2StateType != A
triggerall = Var(0) = 0
trigger1 = ctrl
trigger2 = ctrl && EnemyNear, Name = "Kai" && StateNo = 1005
trigger3 = ctrl && EnemyNear, Name = "Kai" && PrevStateNo = 1005

;---------------------------------------------------------------------------
[State -1, AI st.A]
type = ChangeState
value = 200 
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 40
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 40, abs(P2BodyDist Y) = [10,50])
triggerall = Var(15) = 0
triggerall = StateType != A
trigger1 = ctrl
trigger2 = (var(17) = 1 || Time > 6) && (stateno != [200,230]) && (var(18) = 1)

;---------------------------------------------------------------------------
[State -1, AI st.B]
type = ChangeState
value = 210 + IfElse(P2BodyDist X > 20, 0, 1)
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 50
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 40, abs(P2BodyDist Y) = [10,50])
triggerall = Var(15) = 0
triggerall = StateType != A
trigger1 = ctrl
trigger2 = var(17) = 1 && var(18) < 2

;---------------------------------------------------------------------------
[State -1, AI st.C]
type = ChangeState
value = 230 + IfElse(P2BodyDist X > 20, 0, 1)
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 50
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 40, abs(P2BodyDist Y) = [10,50])
triggerall = Var(15) = 0
triggerall = StateType != A
trigger1 = ctrl
trigger2 = StateNo = 231 && (var(17) = 1 || Time > 6) && (var(18) = 1)

;---------------------------------------------------------------------------
[State -1, AI st.D]
type = ChangeState
value = 240 + IfElse(P2BodyDist X > 20, 0, 1)
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 40
triggerall = abs(P2BodyDist Y) <= 60
triggerall = Var(15) = 0
triggerall = StateType != A
trigger1 = ctrl && random<40*(AILevel**2/64.0)
trigger2 = var(17) = 1 && var(18) < 2

;---------------------------------------------------------------------------
[State -1, AI cr.A]
type = ChangeState
value = 400
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 25
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 40, abs(P2BodyDist Y) = [10,50])
triggerall = Var(15) = 0
triggerall = StateType != A
trigger1 = ctrl
trigger2 = (var(17) = 1 || Time > 6) && (var(18) = 1) 

;---------------------------------------------------------------------------
[State -1, AI cr.B]
type = ChangeState
value = 410
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 20
triggerall = IfElse(P2StateType != A, abs(P2BodyDist Y) <= 70, abs(P2BodyDist Y) = [20,80])
triggerall = Var(15) = 0
triggerall = StateType != A
trigger1 = ctrl
trigger2 = var(17) = 1 && var(18) < 2

;---------------------------------------------------------------------------
[State -1, AI cr.C]
type = ChangeState
value = 430
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 20
triggerall = P2StateType != A
triggerall = Var(15) = 0
triggerall = StateType != A
trigger1 = ctrl
trigger2 = (var(17) = 1 || Time > 6) && (var(18) = 1)

;---------------------------------------------------------------------------
[State -1, AI cr.D]
type = ChangeState
value = 440
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = abs(P2BodyDist X) <= 80
triggerall = P2StateType != A
triggerall = Var(15) = 0
triggerall = StateType != A
trigger1 = ctrl && random<40*(AILevel**2/64.0)
trigger2 = (ctrl || var(17) = 1 && var(18) < 2) 

;---------------------------------------------------------------------------
[State -1, AI j.A]
type = ChangeState
value = 600
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = P2BodyDist X = [0,40]
triggerall = (EnemyNear, Pos Y) - Pos Y = [-20,20]
triggerall = Var(15) < 2
triggerall = StateType = A
trigger1 = ctrl

;---------------------------------------------------------------------------
[State -1, AI j.B]
type = ChangeState
value = 610
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = P2BodyDist X = [0,40]
triggerall = (EnemyNear, Pos Y) - Pos Y = [0,40]
triggerall = Var(15) < 2
triggerall = StateType = A
trigger1 = ctrl

;---------------------------------------------------------------------------
[State -1, AI j.C]
type = ChangeState
value = 630
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = P2BodyDist X = [-20,40]
triggerall = (EnemyNear, Pos Y) - Pos Y = [-20,20]
triggerall = Var(15) < 2
triggerall = StateType = A
trigger1 = ctrl 

;---------------------------------------------------------------------------
[State -1, AI j.D]
type = ChangeState
value = 640
triggerall = random < 100 * (AILevel**2/64.0)
triggerall = AILevel != 0 && RoundState = 2
triggerall = P2BodyDist X = [0,40]
triggerall = (EnemyNear, Pos Y) - Pos Y = [0,-40]
triggerall = Var(15) < 2
triggerall = StateType = A
trigger1 = ctrl 

;---------------------------------------------------------------------------
[State -1, AI S. Cancel]
type = ChangeState
value = 700
triggerall = AILevel != 0 && RoundState = 2
triggerall = StateType != A && MoveType = A
triggerall = (StateNo = [200,1999]) && StateNo != 440 && (StateNo != [700,799])
triggerall = var(30) >= IfElse(StateNo < 1000, 25, 50)
triggerall = Var(16) = 1
triggerall = P2BodyDist X = [0,20]
trigger1 = stateno = 210
trigger2 = stateno = 230
trigger3 = stateno = [240,242]
ignorehitpause = 1

;---------------------------------------------------------------------------
[State -1, AI Fwd. S. Cancel]
type = ChangeState
value = 701
triggerall = AILevel != 0 && RoundState = 2
triggerall = StateType != A && MoveType = A
triggerall = (StateNo = [200,1999]) && StateNo != 440 && (StateNo != [700,799])
triggerall = var(30) >= IfElse(StateNo < 1000, 25, 50)
triggerall = Var(16) = 1
triggerall = P2BodyDist X = (20,50]
trigger1 = stateno = 210
trigger2 = stateno = 230
trigger3 = stateno = [240,242]
ignorehitpause = 1

