;-| Button Remapping |-----------------------------------------------------
; If the following lines are NOT preceded by semicolons, please
; add them or remove the remap entirely since Ricepigeon is a
; lazy bastard who forgets to remove it before releasing stuff
; *facepalms*
;[Remap]
;x = a
;y = b
;z = c
;a = x
;b = y
;c = z
;s = s

;-| Default Values |-------------------------------------------------------
[Defaults]
; Default value for the "time" parameter of a Command. Minimum 1.
command.time = 15
; Default value for the "buffer.time" parameter of a Command. Minimum 1,
; maximum 30.
command.buffer.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 = "start"
command = s
time = 1

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

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

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

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

;-| Hold Button |----------------------------------------------------------
; Please define Anim 74140108 in your AIR file if AND ONLY IF you place these
; 7 Hold Button commands immediately after the 11 Single Button and Hold Dir
; commands at the very top of your CMD list, as demonstrated here.
; In this version of the AI code, these commands are only used by the XOR
; method, and thus are optional.  But there remains a possibility that a
; future version of the helper method might be helped by having these
; commands placed here, and Anim 74140108 would then be used to indicate
; that a partner character has a compatible CMD.

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

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

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

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

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

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

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

;-| CPU |--------------------------------------------------------------
; Note that if you make any changes to the basic one-button or recovery
; commands, you'll need to make the same changes to their matching commands here
; and/or in the XOR VarSet controller.  That includes things like, for example:
;  * changing the recovery command to use a different combination of buttons.
;  * renaming the b button command as "d", or the start button command as "s".
;  * switching the button names around, e.g. so button y triggers "a" and button a triggers "y".
;  * having more than one way to trigger the same command name.
; If you understand how the XOR method works, the proper changes should be obvious.
; If you don't understand it, then simply disable the lines in the XOR VarSet
; controller that correspond to the commands you've altered.

[Command]
name = "a2"
command = a
time = 1

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

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

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

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

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

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

[Command]
name = "holdfwd2"
command = /$F
time = 1

[Command]
name = "holdback2"
command = /$B
time = 1

[Command]
name = "holdup2"
command = /$U
time = 1

[Command]
name = "holddown2"
command = /$D
time = 1

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

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

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

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

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

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

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

[Command]
name = "recovery2"
command = x+y
time = 1

[Command]
name = "recovery2"
command = x+z
time = 1

[Command]
name = "recovery2"
command = y+z
time = 1


[Command]
name = "SelectRight"
command = F
time = 1
[Command]
name = "SelectLeft"
command = B
time = 1
[Command]
name = "SelectUp"
command = U
time = 1
[Command]
name = "SelectDown"
command = D
time = 1

;-| Spellcards - Level 3 |--------------------------------------------------

[Command]
name = "Imperishable"
command = ~D,DF,F,D,DF,F,z
time = 30
[Command]
name = "Imperishable"
command = ~D,F,D,F,z
time = 30

[Command]
name = "MtFuji"
command = B,DB,D,DF,F,z
time = 30
[Command]
name = "MtFuji"
command = B,$D,F,z
time = 30

;[Command]
;name = "XuFu"
;command = ~F,D,$F,D,$F,z
;time = 30
;[Command]
;name = "XuFu"
;command = ~F,D,F,D,$F,z
;time = 30

;-| Spellcards - Level 2 |--------------------------------------------------

[Command]
name = "Possess"
command = ~D,DB,B,D,DB,B,y
time = 25
[Command]
name = "Possess"
command = ~D,B,D,B,y
time = 25

[Command]
name = "Woo"
command = ~D,DF,F,D,DF,F,y
time = 25
[Command]
name = "Woo"
command = ~D,F,D,F,y
time = 25

[Command]
name = "Tail"
command = F,DF,D,DB,B,y
time = 25
[Command]
name = "Tail"
command = F,$D,B,y
time = 25

;-| Spellcards - Level 1 |--------------------------------------------------

[Command]
name = "FlyingF"
command = ~D,DB,B,D,DB,B,x
time = 25
[Command]
name = "FlyingF"
command = ~D,B,D,B,x
time = 25

[Command]
name = "Spire"
command = ~F,D,$F,D,$F,x
time = 25
[Command]
name = "Spire"
command = ~F,D,F,D,$F,~x
time = 25

[Command]
name = "Advice"
command = ~D,DF,F,D,DF,F,x
time = 25
[Command]
name = "Advice"
command = ~D,F,D,F,x
time = 25

;-| Special Motions |------------------------------------------------------
[Command]
name = "Press_X"
command = ~D, DB, B, x
time = 10
[Command]
name = "Press_X"
command = ~D, B, x
time = 10

[Command]
name = "Press_Y"
command = ~D, DB, B, y
time = 10
[Command]
name = "Press_Y"
command = ~D, B, y
time = 10

[Command]
name = "Press_Z"
command = ~D, DB, B, z
time = 10
[Command]
name = "Press_Z"
command = ~D, B, z
time = 10

;-------------------------------------------
[Command]
name = "FP_X"
command = ~B,F,x
time = 10
[Command]
name = "FP_X"
command = ~B,F,x
time = 10

[Command]
name = "FP_Y"
command = ~B,F,y
time = 10
[Command]
name = "FP_Y"
command = ~B,F,y
time = 10

[Command]
name = "FP_Z"
command = ~B,F,z
time = 10
[Command]
name = "FP_Z"
command = ~B,F,z
time = 10

;-------------------------------------------
[Command]
name = "Kick13_X"
command = ~F,D,$F, x
time = 15
[Command]
name = "Kick13_X"
command = ~DF,DF, x
time = 15

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

[Command]
name = "Kick13_Z"
command = ~F,D,$F, z
time = 15
[Command]
name = "Kick13_Z"
command = ~DF,DF, z
time = 15

;-------------------------------------------
[Command]
name = "Meteor_X"
command = ~D,F,x
time = 10
[Command]
name = "Meteor_X"
command = ~D,DF,F, x
time = 10

[Command]
name = "Meteor_Y"
command = ~D,F,y
time = 10
[Command]
name = "Meteor_Y"
command = ~D,DF,F, y
time = 10

[Command]
name = "Meteor_Z"
command = ~D,F,z
time = 10
[Command]
name = "Meteor_Z"
command = ~D,DF,F,z
time = 10

;-------------------------------------------
;[Command]
;name = "RideWave_X"
;command = ~D,D,x
;time = 10

;[Command]
;name = "RideWave_Y"
;command = ~D,D,y
;time = 10

;[Command]
;name = "RideWave_Z"
;command = ~D,D,z
;time = 10

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

;-| 2/3 Button Combination |-----------------------------------------------
[Command]
name = "recovery";Required (do not remove)
command = x+y
time = 1
[Command]
name = "recovery";Required (do not remove)
command = x+z
time = 1
[Command]
name = "recovery";Required (do not remove)
command = y+z
time = 1

;-| Dir + Button |---------------------------------------------------------
[Command]
name = "down_a"
command = /$D,a
time = 1

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

;---------------------------------------------------------------------------
; 2. State entry
; --------------
; Don't remove the following line. It's required by the CMD standard.
[Statedef -1]
[State -1, AI Helper Check]
type = ChangeState
trigger1 = IsHelper(9741)
value = 9741

[State -1, AI Helper Check 2]
type = ChangeState
trigger1 = IsHelper(9742)
value = 9742

;===========================================================================
[State -1, Combo condition Reset]
type = VarSet
trigger1 = 1
var(1) = 0
ignorehitpause = 1

[State -1, Combo condition Check]
type = VarSet
trigger1 = statetype != A
trigger1 = ctrl
trigger2 = (stateno = [200,299]) || (stateno = [400,499]) || (stateno = [600,699])
trigger2 = movehit;movecontact
trigger3 = (stateno = 1000) && (movehit)
trigger3 = (var(10)!=1);||((animelem=2)&&(var(10)=1))
var(1) = 1
ignorehitpause = 1

;===========================================================================
;===========================================================================
; CPU CONTROLS
;===========================================================================
;===========================================================================

;[State -1, StandGuard AI]
;type = ChangeState
;triggerall = stateno != 130
;triggerall = (var(58) > 0) && (StateType = S) && (Pos Y >= 0) && (P2BodyDist Y <= 0)
;triggerall = (P2BodyDist Y >= -120) && (P2StateType != C) && (P2MoveType = A)
;trigger1 = (P2BodyDist X <= 120) && (Random <= 799) && (Ctrl)
;trigger2 = (StateNo = [140, 155]) || (StateNo = [100, 105])
;value = 130

[State -1, Guard]
type=changestate
value=120
trigger1 = var(58) > 0
trigger1 = roundstate=2
trigger1 = inguarddist
trigger1 = ctrl || (stateno = [100,106])
trigger1 = (stateno!=[120,155])
trigger1 = !(enemynear,hitdefattr=SCA,AT) && (enemynear,time<120)
trigger1 = (random%100)<ifelse((p2stateno=[200,699]), 49, ifelse((p2stateno=[1000,2999]), 49, 100))

[State -1, Recover AI] ; Recover near ground (use ChangeState)
type = SelfState
triggerall = stateno = 5050;movetype = H
triggerall = time >= 10
triggerall = Vel Y > 0
triggerall = Pos Y >= -20
triggerall = alive
triggerall = CanRecover
triggerall = var(58) > 0
trigger1 = (random%100) <= 24
;trigger1 = !((power>=3000)&&(var(2)=0)&&(life<=1)&&(var(37)=1))
value = 5200 ;HITFALL_RECOVER

[State -1, Recover AI] ; Recover in mid air (use SelfState)
type = SelfState
triggerall = stateno = 5050;movetype = H
triggerall = time >= 10
triggerall = Vel Y > 0
triggerall = alive
triggerall = CanRecover
triggerall = var(58) > 0
trigger1 = (random%100) <= 24
;trigger1 = !((power>=3000)&&(var(2)=0)&&(life<=1)&&(var(37)=1))
value = 5210 ;HITFALL_AIRRECOVER

;===========================================================================
; Mokou's Basics
;---------------------------------------------------------------------------
;Run Fwd
[State -1, Run Fwd AI]
type = ChangeState
value = 100+10*(statetype = A)
triggerall = var(58) > 0 ;AI On
trigger1 = stateno != [100,116]
trigger1 = enemynear,movetype != A
trigger1 = var(8) = 0
trigger1 = var(8) := 1
trigger1 = ctrl
trigger1 = p2dist x >= 120;200
trigger1 = (random%100) <= 6

;Run Fwd
[State -1, Run Back AI]
type = ChangeState
value = 105+10*(statetype = A)
triggerall = var(58) > 0 ;AI On
triggerall = stateno != [100,116]
triggerall = var(8) = 0
triggerall = var(8) := 1
trigger1 = ctrl
trigger1 = (enemynear,stateno=[200,699]) || (enemynear,hitdefattr = SCA,AT)
trigger1 = (p2bodydist x >= -5) && (p2bodydist x <= 90)
trigger1 = enemynear,vel x <= 3
trigger1 = enemynear,movetype = A
trigger1 = (random%100) <= 49
trigger1 = (prevstateno = [5000,5220]) || (prevstateno = [120,159])
trigger2 = animtime = 0
trigger2 = stateno = 1101
trigger3 = (enemynear,statetype = L) || (enemynear,stateno = 5150)
trigger3 = p2bodydist x <= 160

;---------------------------------------------------------------------------
;Powercharge
[State -1, Powercharge]
type = ChangeState
value = 195
triggerall = var(58) > 0 ;AI On
triggerall = (random%100) <= 8
triggerall = power < powermax
trigger1 = statetype = S
trigger1 = ctrl && (stateno != 100) && (stateno != 195)
trigger1 = p2dist x >= 100
trigger1 = enemynear,statetype != A
trigger1 = !inguarddist

;---------------------------------------------------------------------------
;Grab
[State -1, Grab AI]
type = ChangeState
value = 800
triggerall = var(58) > 0 ;AI On
triggerall = p2bodydist x = [0,40]
triggerall = (random%100) <= 6
triggerall = statetype != A
triggerall = ctrl && stateno != [100,106]
triggerall = enemynear,statetype != A
triggerall = enemynear,movetype != H
trigger1 = enemynear,movetype != A
trigger2 = enemynear,stateno = [120,150]

;---------------------------------------------------------------------------
;Stand Light Attack
[State -1, Stand Light Attack AI]
type = ChangeState
value = 200
triggerall = var(58) > 0 ;AI On
trigger1 = (random%100) <= 7
trigger1 = statetype = S
trigger1 = ctrl ;&& stateno != 100
trigger1 = p2bodydist x <= 30
trigger1 = enemynear,statetype != A
trigger1 = enemynear,statetype != L
trigger2 = statetype = S
trigger2 = stateno = 100
trigger2 = time > 4
trigger2 = p2bodydist x <= 30
trigger2 = (random%100) <= 3
trigger2 = enemynear,statetype != A
trigger2 = enemynear,statetype != L

;---------------------------------------------------------------------------
;Stand Medium Attack
[State -1, Stand Medium Attack AI]
type = ChangeState
value = 210
triggerall = var(58) > 0 ;AI On
trigger1 = ((enemynear,statetype = C) && (enemynear,movetype != H)) || ((enemynear,statetype != C) && (enemynear,movetype = H))
trigger1 = movecontact;(var(1))
trigger1 = stateno = [200,205]
trigger2 = movecontact;(var(1))
trigger2 = stateno = 400
trigger2 = (random%100) <= 9

;---------------------------------------------------------------------------
;Stand Medium Attack - Dash
[State -1, Stand Medium Attack Dash AI]
type = ChangeState
value = 210;215
triggerall = var(58) > 0 ;AI On
triggerall = statetype != A
triggerall = stateno = 100
triggerall = time > 4
triggerall = p2bodydist x = [10,60]
triggerall = (random%100) <= 9
trigger1 = enemynear,statetype = A
trigger1 = enemynear,movetype = H
;trigger1 = enemynear,movetype != A
;trigger2 = enemynear,statetype = L

;---------------------------------------------------------------------------
;Stand Strong Attack
[State -1, Stand Strong Attack AI]
type = ChangeState
value = 220
triggerall = var(58) > 0 ;AI On
triggerall = statetype != A
trigger1 = movecontact;(var(1))
trigger1 = stateno = 210;[210,215]
trigger2 = (stateno=100 && time>4) || (stateno = 101 && time <= 3)
trigger2 = p2bodydist x <= 80
trigger2 = (random%100) <= 6
trigger2 = enemynear,statetype != L

;---------------------------------------------------------------------------
;Crouching Light Attack
[State -1, Crouching Light AI]
type = ChangeState
value = 400
triggerall = var(58) > 0 ;AI On
triggerall = (random%100) <= 6
triggerall = (statetype != L) && (statetype != A)
triggerall = ctrl
triggerall = p2bodydist x <= 45
trigger1 = enemynear,statetype != L
trigger1 = enemynear,statetype != A
trigger2 = enemynear,statetype != A
trigger2 = enemynear,statetype = S

;---------------------------------------------------------------------------
;Crouching Medium Attack
[State -1, Crouching Medium AI]
type = ChangeState
value = 410
triggerall = var(58) > 0 ;AI On
triggerall = statetype != A
trigger1 = movecontact;(var(1))
trigger1 = stateno = 400
trigger2 = ctrl
trigger2 = var(6) > 0
trigger2 = (enemynear,statetype = L) || (enemynear,statetype = S)
trigger2 = p2dist x <= 60
trigger2 = (random%100) <= 7

;---------------------------------------------------------------------------
;Crouching Strong Attack
[State -1, Crouching Strong AI]
type = ChangeState
value = 420
triggerall = var(58) > 0 ;AI On
triggerall = statetype != A
trigger1 = movecontact;(var(1))
trigger1 = stateno = 410
trigger2 = ctrl
trigger2 = p2bodydist x = [0,55]
trigger2 = random%100 <= 6
trigger2 = p2statetype != C
trigger2 = !inguarddist

;---------------------------------------------------------------------------
;Jump Light Attack
[State -1, Jump Light AI]
type = ChangeState
value = 600
triggerall = var(58) > 0 ;AI On
triggerall = statetype = A
trigger1 = inguarddist = 0
trigger1 = ctrl || stateno = 100 || stateno = 105
trigger1 = enemynear,statetype != L
trigger1 = p2bodydist x >= 25
trigger1 = p2bodydist x <= 50
trigger1 = abs(p2bodydist y) <= 30
trigger1 = stateno != 430
trigger2 = stateno = 430
trigger2 = ctrl
trigger2 = enemynear,statetype = A
trigger2 = p2bodydist x <= 50
trigger2 = abs(p2bodydist y) <= 30
trigger2 = (random%100) < 9


;---------------------------------------------------------------------------
;Jump Medium Attack
[State -1, Jump Medium AI]
type = ChangeState
value = 610
triggerall = var(58) > 0 ;AI On
trigger1 = statetype = A
trigger1 = stateno = 600
trigger1 = movecontact;var(1)
trigger2 = ctrl
trigger2 = p2dist x < 60
trigger2 = p2dist y = [-50,20]
trigger2 = (random%100) <= 6

;---------------------------------------------------------------------------
;Jump Strong Attack
[State -1, Jump Strong AI]
type = ChangeState
value = 620
triggerall = var(58) > 0 ;AI On
triggerall = statetype = A
trigger1 = stateno = 610
trigger1 = movecontact;var(1)
trigger2 = ctrl
trigger2 = p2dist x = [0,60]
trigger2 = enemynear,movetype != H
trigger2 = (random%100) <= 6

;===========================================================================
; Mokou's Specials AI
;---------------------------------------------------------------------------
; Kick 13
[State -1, Kick 13 AI]
type = ChangeState
value = 1000
triggerall = var(58) > 0 ;AI On
triggerall = statetype != A
triggerall = (ctrl) || ((stateno = [200,420]) && (var(1)))
trigger1 = ctrl
trigger1 = !inguarddist
trigger1 = (random%100) <= 5
trigger1 = enemynear,statetype=A
trigger1 = enemynear,movetype!=H
trigger1 = p2bodydist x = [0,60]
trigger1 = var(10) := 1
trigger2 = ((stateno = [200,420]) && (var(1)))
trigger2 = (random%100) <= 5
trigger2 = var(10) := 2
trigger3 = ((stateno = [200,420]) && (var(1)))
trigger3 = (random%100) <= 5
trigger3 = power >= 500
trigger3 = var(10) := 3


; Flame Press
[State -1, Flame Press AI]
type = ChangeState
value = 1300
triggerall = var(58) > 0 ;AI On
triggerall = (statetype != A)
triggerall = ctrl || ((stateno = [200,420]) && (var(1)))
triggerall = p2movetype != A
triggerall = p2statetype != L
triggerall = p2stateno != 5120
triggerall = p2stateno != 5201
triggerall = p2dist x = [0,90]
triggerall = enemynear,vel y >= 0
trigger1 = random%100 <= 4
trigger1 = var(10) := 1
trigger2 = random%100 <= 4
trigger2 = var(10) := 2
trigger3 = random%100 <= 2
trigger3 = var(10) := 3
trigger3 = power >= 500

; FP AI
[State -1, Fujiyama Punch AI]
type = ChangeState
value = 1100
triggerall = var(58) > 0 ;AI On
triggerall = (ctrl) || ((stateno = 420) && var(1)) || ((stateno = [600,620]) && var(1)) || (stateno = [100,116])
trigger1 = statetype = A
trigger1 = random%100 <= 5
trigger1 = enemynear,statetype != A
trigger1 = enemynear,movetype != A
trigger1 = p2bodydist x = [0,60]
trigger1 = var(10) := 1
;trigger2 = (command = "FP_Y")
;trigger2 = var(10) := 2
trigger2 = statetype != A
trigger2 = enemynear,vel x > 3
trigger2 = enemynear,statetype != A
trigger2 = random%100 <= 4
trigger2 = p2bodydist x = [80,160]
trigger2 = power >= 500
trigger2 = var(10) := 3

; Volcanic Meteor
[State -1, Volcanic Meteor AI]
type = ChangeState
value = 1200
triggerall = var(58) > 0 ;AI On
triggerall = numprojid(1205) = 0
triggerall = (statetype = S) || (statetype = C)
triggerall = ctrl
trigger1 = random%100 <= 5
trigger1 = p2bodydist x > 120
trigger1 = var(10) := 1

;===========================================================================
; Mokou's Supers AI (Level 3)
;---------------------------------------------------------------------------

[State -1, Mt Fuji Volcano AI]
type = ChangeState
value = 4100
triggerall = var(58) > 0 ;AI On
triggerall = var(38)=1
triggerall = (ctrl)
triggerall = (statetype = S) || (statetype = C)
trigger1 = life > 300
trigger1 = random%100 <= 4
trigger1 = enemynear,statetype = A
trigger1 = enemynear,vel x > 0
trigger1 = p2bodydist x = [-90,90]
trigger1 = power >= 3000

[State -1, Imperishable]
type = ChangeState
value = 4200
triggerall = var(58) > 0 ;AI On
triggerall = var(39)=1
triggerall = (ctrl) || ((stateno = [600,620])&&(var(1))) || ((stateno = 1000)&&(var(1)))
triggerall = numhelper(4201) = 0
triggerall = (statetype = A)
triggerall = random%100 <= 4
triggerall = power >= 3000
triggerall = p2bodydist x = [0,90]
trigger1 = frontedgedist = [60,100]
trigger1 = enemynear,statetype = L
trigger2 = stateno = 620
trigger2 = var(1)

;===========================================================================
; Mokou's Supers AI (Level 2)
;---------------------------------------------------------------------------

[State -1, Possessed by Phoenix AI]
type = ChangeState
value = 3000
triggerall = var(58) > 0 ;AI On
triggerall = var(34)=1
triggerall = (ctrl) || ((stateno = [200,420]) && (var(1)))
triggerall = numhelper(3060) = 0
triggerall = (statetype = S) || (statetype = C)
trigger1 = p2bodydist x = [0,60]
trigger1 = random%100 <= (3+3*(enemynear,statetype=A))
trigger1 = power >= 2000

[State -1, Woo]
type = ChangeState
value = 3100
triggerall = var(58) > 0 ;AI On
triggerall = var(35)=1
triggerall = (ctrl) || ((stateno = [200,420]) && (var(1)))
triggerall = numhelper(3102) = 0
triggerall = (statetype = S) || (statetype = C)
triggerall = random%100 <= 3
triggerall = power >= 2000
trigger1 = numtarget
trigger1 = target,movetype = H
trigger1 = target,statetype = A
trigger1 = target,vel y < 0

[State -1, Phoenix Tail]
type = ChangeState
value = 3200
triggerall = var(58) > 0 ;AI On
triggerall = var(36)=1
triggerall = (ctrl)
triggerall = statetype != A
triggerall = power >= 2000
triggerall = random%100 <= 2+2*(life<=floor(lifemax/2))
triggerall = life < (lifemax - 300)
trigger1 = enemynear,statetype = L
trigger1 = p2bodydist x > 120
trigger2 = enemynear,movetype = H
trigger2 = enemynear,hitfall = 1
trigger2 = p2bodydist x > 70

;===========================================================================
; Mokou's Supers AI (Level 1)
;---------------------------------------------------------------------------

[State -1, Flying Phoenix AI]
type = ChangeState
value = 2000
triggerall = var(58) > 0 ;AI On
triggerall = var(31)=1
triggerall = random%100 <= 2
triggerall = power >= 1000
triggerall = frontedgedist >= 90
trigger1 = (stateno = 620) && var(1)
trigger2 = (stateno = 1000) && var(1)
trigger2 = statetype = A

[State -1, Fire Spire AI]
type = ChangeState
value = 2100
triggerall = var(58) > 0 ;AI On
triggerall = var(32)=1
triggerall = statetype != A
triggerall = random%100 <= 2
triggerall = power >= 1000
trigger1 = ctrl
trigger1 = enemynear,statetype != A
trigger1 = enemynear,movetype = A
trigger1 = enemynear,movehit = 0
trigger1 = enemynear,movecontact = 1
trigger2 = ctrl
trigger2 = enemynear,statetype = A
trigger2 = p2bodydist x = [0,80]
trigger3 = (stateno = 1000) && (var(1))
trigger3 = statetype != A


[State -1, Heat Wave AI]
type = ChangeState
value = 2200
triggerall = var(58) > 0 ;AI On
triggerall = var(33)=1
triggerall = (ctrl)
triggerall = random%100 <= 2
triggerall = power >= 1000
trigger1 = statetype != A
trigger1 = enemynear,statetype != A
trigger1 = p2bodydist x >= 70
trigger1 = enemynear,movetype = A

;===========================================================================
;===========================================================================
; HUMAN CONTROLS
;===========================================================================
;===========================================================================

;===========================================================================
; Mokou's Supers (Level 3)
;---------------------------------------------------------------------------

;[State -1, Phoenix Rebirth]
;type = ChangeState
;value = 4000
;triggerall = var(58) <= 0 ;AI Off
;;triggerall = var(37)=1
;trigger1 = var(2) = 0 ;Had not rebirthed yet
;trigger1 = life <= 1
;trigger1 = stateno =
;;triggerall = (statetype = S) || (statetype = C)
;;trigger1 = command = "Express"
;trigger1 = power >= 3000

[State -1, Mt Fuji Volcano]
type = ChangeState
value = 4100
triggerall = var(58) <= 0 ;AI Off
triggerall = var(38)=1
triggerall = (ctrl) ;|| ((stateno = [1002,1005])&&(var(1)))
;triggerall = numhelper(4120) = 0
;triggerall = numhelper(4121) = 0
triggerall = (statetype = S) || (statetype = C)
trigger1 = command = "MtFuji"
trigger1 = power >= 3000

[State -1, Imperishable]
type = ChangeState
value = 4200
triggerall = var(58) <= 0 ;AI Off
triggerall = var(39)=1
triggerall = (ctrl) || ((stateno = [600,620])&&(var(1))) || ((stateno = 1000)&&(var(1)))
triggerall = numhelper(4201) = 0
triggerall = (statetype = A)
trigger1 = command = "Imperishable"
trigger1 = power >= 3000

;===========================================================================
; Mokou's Supers (Level 2)
;---------------------------------------------------------------------------

[State -1, Possessed by Phoenix]
type = ChangeState
value = 3000
triggerall = var(58) <= 0 ;AI Off
triggerall = var(34)=1
triggerall = (ctrl) || ((stateno = [200,420]) && (var(1)))
triggerall = numhelper(3060) = 0
;triggerall = numhelper(3002) = 0
;triggerall = numhelper(3003) = 0
triggerall = (statetype = S) || (statetype = C)
trigger1 = command = "Possess"
trigger1 = power >= 2000

[State -1, Woo]
type = ChangeState
value = 3100
triggerall = var(58) <= 0 ;AI Off
triggerall = var(35)=1
triggerall = (ctrl) || ((stateno = [200,420]) && (var(1)))
triggerall = numhelper(3102) = 0
triggerall = (statetype = S) || (statetype = C)
trigger1 = command = "Woo"
trigger1 = power >= 2000

[State -1, Phoenix Tail]
type = ChangeState
value = 3200
triggerall = var(58) <= 0 ;AI Off
triggerall = var(36)=1
triggerall = (ctrl)
triggerall = statetype != A
trigger1 = command = "Tail"
trigger1 = power >= 2000

;===========================================================================
; Mokou's Supers (Level 1)
;---------------------------------------------------------------------------

[State -1, Flying Phoenix]
type = ChangeState
value = 2000
triggerall = var(58) <= 0 ;AI Off
triggerall = var(31)=1
triggerall = (ctrl) || (((stateno = [200,620])||(stateno=1000)) && (var(1)))
;triggerall = numhelper(2002) = 0
;triggerall = (statetype = S) || (statetype = C)
trigger1 = command = "FlyingF"
trigger1 = power >= 1000

[State -1, Fire Spire]
type = ChangeState
value = 2100
triggerall = var(58) <= 0 ;AI Off
triggerall = var(32)=1
triggerall = (ctrl) || ((stateno = [200,420]) && (var(1))) || ((stateno = 1000) && (var(1))) || ((stateno = [1002,1005])&&(var(1)))
triggerall = statetype != A
trigger1 = command = "Spire"
trigger1 = power >= 1000

[State -1, Heat Wave]
type = ChangeState
value = 2200
triggerall = var(58) <= 0 ;AI Off
triggerall = var(33)=1
triggerall = (ctrl) ;|| ((stateno = [200,620]) && (var(1)))
triggerall = statetype != A
trigger1 = command = "Advice"
trigger1 = power >= 1000

;===========================================================================
; Mokou's Specials
;---------------------------------------------------------------------------

; Illusion Rift
[State -1, Fujiyama Punch]
type = ChangeState
value = 1100
triggerall = var(58) <= 0 ;AI Off
;triggerall = (statetype = S) || (statetype = C)
triggerall = (ctrl) || ((stateno = 420) && var(1)) || ((stateno = [600,620]) && var(1)) || (stateno = [100,116])
trigger1 = (command = "FP_X")
trigger1 = var(10) := 1
trigger2 = (command = "FP_Y")
trigger2 = var(10) := 2
trigger3 = (command = "FP_Z")
trigger3 = power >= 500
trigger3 = var(10) := 3

; Kick 13
[State -1, Kick 13]
type = ChangeState
value = 1000
triggerall = var(58) <= 0 ;AI Off
;triggerall = (numhelper(1102) = 0) && (numhelper(1104)=0)
triggerall = (statetype = S) || (statetype = C)
triggerall = (ctrl) || ((stateno = [200,420]) && (var(1))); || ((stateno = 1400) && (movehit))
trigger1 = command = "Kick13_X"
trigger1 = var(10) := 1
trigger2 = command = "Kick13_Y"
trigger2 = var(10) := 2
trigger3 = command = "Kick13_Z"
trigger3 = var(10) := 3
trigger3 = power >= 500

; Volcanic Meteor
[State -1, Volcanic Meteor]
type = ChangeState
value = 1200
triggerall = var(58) <= 0 ;AI Off
triggerall = numprojid(1205) = 0
triggerall = (statetype = S) || (statetype = C)
triggerall = ctrl
trigger1 = command = "Meteor_X"
trigger1 = var(10) := 1
trigger2 = command = "Meteor_Y"
trigger2 = var(10) := 2
trigger3 = command = "Meteor_Z"
trigger3 = var(10) := 3
;trigger3 = power >= 500

; Flame Press
[State -1, Flame Press]
type = ChangeState
value = 1300
triggerall = var(58) <= 0 ;AI Off
triggerall = (statetype != A)
triggerall = ctrl || ((stateno = [200,420]) && (var(1)))
trigger1 = command = "Press_X"
trigger1 = var(10) := 1
trigger2 = command = "Press_Y"
trigger2 = var(10) := 2
trigger3 = command = "Press_Z"
trigger3 = var(10) := 3
trigger3 = power >= 500

; Bound to the Grave
;[State -1, Bound to Grave]
;type = ChangeState
;value = 1400
;triggerall = var(58) <= 0 ;AI Off
;triggerall = (statetype = S) || (statetype = C)
;triggerall = (ctrl) || (((stateno = [200,420])||(stateno = 1002)) && (var(1)))
;trigger1 = (command = "Grave_X")
;trigger1 = var(10) := 1
;trigger2 = (command = "Grave_Y")
;trigger2 = var(10) := 2
;trigger3 = (command = "Grave_Z")
;trigger3 = power >= 500
;trigger3 = var(10) := 3

;===========================================================================
; Mokou's Basics
;---------------------------------------------------------------------------
;Run Fwd
[State -1, Run Fwd]
type = ChangeState
value = 100+10*(statetype=A)
triggerall = var(58) <= 0 ;AI Off
triggerall = stateno != [100,116]
trigger1 = command = "FF"
trigger1 = var(8) = 0
trigger1 = var(8) := 1
trigger1 = ctrl

;---------------------------------------------------------------------------
;Run Back
[State -1, Run Back]
type = ChangeState
value = 105+10*(statetype=A)
triggerall = var(58) <= 0 ;AI Off
trigger1 = command = "BB"
trigger1 = var(8) = 0
trigger1 = var(8) := 1
trigger1 = ctrl

;---------------------------------------------------------------------------
;Powercharge
[State -1, Powercharge]
type = ChangeState
value = 195
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "holdstart"
triggerall = power < powermax
trigger1 = statetype = S
trigger1 = ctrl && (stateno != 100) && (stateno != 195)

;---------------------------------------------------------------------------
;Stand Light Attack
[State -1, Stand Light Attack]
type = ChangeState
value = 200
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "x"
triggerall = command != "holddown"
trigger1 = statetype != A
trigger1 = ctrl && stateno != 100

;---------------------------------------------------------------------------
;Stand Light Attack - Dash
[State -1, Stand Light Attack Dash]
type = ChangeState
value = 200;205
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "x"
triggerall = command != "holddown"
trigger1 = statetype != A
trigger1 = stateno = 100
trigger1 = time > 4

;---------------------------------------------------------------------------
;Stand Medium Attack
[State -1, Stand Medium Attack]
type = ChangeState
value = 210
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "y"
triggerall = command != "holddown"
triggerall = stateno != 100
trigger1 = statetype != A
trigger1 = ctrl
trigger2 = movecontact;(var(1));movehit = [1,5]
trigger2 = stateno = [200,205]
trigger3 = movecontact;(var(1));movehit = [1,5]
trigger3 = stateno = 400

;---------------------------------------------------------------------------
;Stand Medium Attack - Dash
[State -1, Dash Medium Attack]
type = ChangeState
value = 210;215
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "y"
triggerall = command != "holddown"
trigger1 = statetype != A
trigger1 = stateno = 100 && time > 4
;trigger2 = (var(1));movehit = [1,5]
;trigger2 = stateno = [200,205]
;trigger3 = (var(1));movehit = [1,5]
;trigger3 = stateno = 400

;---------------------------------------------------------------------------
;Grab
[State -1, Grab]
type = ChangeState
value = 800
triggerall = var(58) <= 0 ;AI Off
triggerall = p2bodydist x < 40
triggerall = command = "z"
triggerall = command = "holdfwd"
triggerall = command != "holddown"
trigger1 = statetype != A
trigger1 = ctrl && stateno != [100,106]

;---------------------------------------------------------------------------
;Stand Strong Attack
[State -1, Stand Strong Attack]
type = ChangeState
value = 220
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "z"
triggerall = command != "holddown"
trigger1 = statetype != A
trigger1 = ctrl && stateno != [100,101]
trigger2 = movecontact;(var(1));movehit = [1,5]
trigger2 = stateno = [200,215]
trigger3 = movecontact;(var(1));movehit = [1,5]
trigger3 = stateno = [400,410]

;---------------------------------------------------------------------------
;Dash Strong Attack
[State -1, Dash Strong Attack]
type = ChangeState
value = 220;225
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "z"
triggerall = statetype != A
trigger1 = stateno = 100 && time > 4
trigger2 = stateno = 101 && time <= 3

;---------------------------------------------------------------------------
;Crouching Light Attack
[State -1, Crouching Light]
type = ChangeState
value = 400
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "x"
triggerall = command = "holddown"
trigger1 = statetype != A
trigger1 = ctrl

;---------------------------------------------------------------------------
;Crouching Medium Attack
[State -1, Crouching Medium]
type = ChangeState
value = 410
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "y"
triggerall = command = "holddown"
trigger1 = statetype != A
trigger1 = ctrl
trigger2 = movecontact;(var(1));movehit = [1,5]
trigger2 = stateno = 400

;---------------------------------------------------------------------------
;Crouching Strong Attack
[State -1, Crouching Strong]
type = ChangeState
value = 420
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "z"
triggerall = command = "holddown"
trigger1 = statetype != A
trigger1 = ctrl
trigger2 = movecontact;(var(1));movehit = [1,5]
trigger2 = stateno = 410

;---------------------------------------------------------------------------
;Crouching Jump cancel
[State -1, Jump Cancel]
type = null;ChangeState
value = 430
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "holdup"
trigger1 = statetype = C
trigger1 = (var(1));movehit = [1,5]
trigger1 = stateno = 420

;---------------------------------------------------------------------------
;Jump Light Attack
[State -1, Jump Light]
type = ChangeState
value = 600
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "x"
triggerall = statetype = A
trigger1 = ctrl
trigger2 = (stateno = [100,116]);) || (stateno = 105)
trigger2 = statetime >= 4

;---------------------------------------------------------------------------
;Jump Medium Attack
[State -1, Jump Medium]
type = ChangeState
value = 610
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "y"
trigger1 = statetype = A
trigger1 = ctrl
trigger2 = (stateno = [100,116]);trigger2 = (stateno = 100) || (stateno = 105)
trigger2 = statetime >= 4
trigger3 = stateno = 600
trigger3 = movecontact;var(1);movehit = [1,5]

;---------------------------------------------------------------------------
;Jump Strong Attack
[State -1, Jump Strong]
type = ChangeState
value = 620
triggerall = var(58) <= 0 ;AI Off
triggerall = command = "z"
trigger1 = statetype = A
trigger1 = ctrl
trigger2 = (stateno = [100,116]);trigger2 = (stateno = 100) || (stateno = 105)
trigger2 = statetime >= 8
trigger3 = stateno = [600,610]
trigger3 = movecontact;var(1);movehit = [1,5]


