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

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

; **IMPORTANT NOTE**
; YOU WON'T HAVE TO WORRY FOR THE AI ACTIVATION OR VARIABLE.
; IT IS ALREADY CODED HERE, ALL YOU HAVE TO DO, IS MAKE AI CODES
; IN THE COMMAND FILE

[State -2, PlaySnd]
type = PlaySnd
triggerall = prevstateno = 194
triggerall = life < lifemax
trigger1 = ishometeam
trigger1 = TeamSide = 2
trigger1 = time = 1
value = S5,11
channel = 10

[State -2, LifeBar]
type = LifeAdd
triggerall = prevstateno = 194
triggerall = life < lifemax
trigger1 = ishometeam
trigger1 = TeamSide = 2
value = 10*(lifemax/1000)

[State -2, Stop Lifebar sound]
type = StopSnd
triggerall = prevstateno = 194 ;|| stateno = 194
;triggerall = roundstate = 2
trigger1 = life >= lifemax
channel = 10

[State -2, Starting Lifebar]
type = LifeAdd
triggerall = stateno = 0
trigger1 = prevstateno = 194
Value = 1001*(lifemax/1000)

;==================================================================================
;======| RELACIONADO À AI - AI RELATED |===========================================
;==================================================================================

; Within StateDef -2, none of your own AI-related code should be placed
; above these next two controllers.

[State -2, StopAI]
type = VarSet
triggerall = (var(59) > 0)
trigger1 = (RoundState != 2)
trigger2 = !Alive
var(59) = -2
IgnoreHitPause = 1

; This controller is optional.  It allows you treat the AI flag as a boolean
; value rather than an integer value, letting you trigger your AI directives
; with "var(0)" instead of "var(59)>0", and letting you make moves usable only
; by humans by using "!var(0)" instead of "var(59)<1", thus slightly improving
; the size and efficiency of your code.
; Another benefit is that it makes it much easier for users to disable your AI,
; if they so choose.
[State -2, Simplifier]
type = VarSet
trigger1 = (var(59) = 1)
trigger2 = (var(0):=0)
var(0) = 1	; Another option is to replace 1 with something like MatchNo, if
		; you want to design your AI to have varying levels of difficulty.
IgnoreHitPause = 1

[State -2, varKOsnd]
type=varset
trigger1=alive&&var(18)>0
trigger2=!alive&&var(18)<2
var(18)=ifelse(alive,0,var(18)+1)
ignorehitpause=1

[State -3, GetHit Snd]
type=playsnd
triggerall=alive&&time=1
triggerall=stateno=5000||stateno=5010
trigger1=gethitvar(animtype)>=2&&random<500
trigger2=gethitvar(animtype)=1&&random<375
trigger3=gethitvar(animtype)=0&&random<250
value=s5000,(0+(random%4));*10,ceil(random/200)
channel=5
ignorehitpause=1

[State -3, GetHit Snd]
type=playsnd
triggerall=alive&&time=1
trigger1=(stateno=5000||stateno=5010)&&numenemy
trigger1=gethitvar(fall)||(enemynear,hitdefattr=SCA,SA,HA)
trigger2=(stateno=5020||stateno=5070||stateno=5080)
trigger3=(stateno=5050||stateno=5100)&&(prevstateno!=[5000,5199])
value=s5000,(0+(random%4));*10,ceil(random/200)
channel=5
ignorehitpause=1

[State -2, KOsnd]
type=playsnd
trigger1=!alive&&var(18)=1
trigger1=var(18):=2
value=5500,0;ifelse((var(1)=2),2,1)+2*(stateno=5130)
ignorehitpause=1
persistent=0

;---------------------------------------------------
[State -2, Hyper Combo Finish!!]
type = Helper
triggerall = NumHelper(9999) <= 0
triggerall = NumHelper(7610) <= 0
triggerall = (stateno = [3000,3499]) ;|| (stateno = [3700,3799]) || (stateno = [3900,3949])
triggerall = roundstate = 3
trigger1 = Winko
helpertype = normal
name = "HyperFinish"
ID = 9999
stateno = 9999
ownpal = 1
supermovetime = 9999
pausemovetime = 9999
ignorehitpause = 1

[State -2, Fffffinish!!]
type = Helper
triggerall = NumHelper(9998) <= 0
triggerall = NumHelper(9999) <= 0
triggerall = NumHelper(7610) <= 0
triggerall = stateno != [3000,3999]
triggerall = roundstate = 3
trigger1 = Winko
helpertype = normal
name = "Finish"
ID = 9998
stateno = 9998
ownpal = 1
supermovetime = 9999
pausemovetime = 9999
ignorehitpause = 1

[State -2, Plane Destroyed]
type = Helper
triggerall = prevstateno = 3201
triggerall = numhelper(3290) = 0
trigger1 = movetype = H
helpertype = normal
name = "Plane Destroyed"
ID = 3290
stateno = 3290
ownpal = 1

;------------------------------------------------------
;signs

[State -2, VS_Combo]
type = VarSet
trigger1 = var(28) >= 3
trigger2 = var(28)=-1 && (movehit || p2movetype = H && p2stateno != [120,159]);p2stateno = [5000,5899])
var(29) = 1+(var(28)>4)+(var(28)>5)+(var(28)>7)+(var(28)>9)+(var(28)>14)+(var(28)>19)+(var(28)>25)-(var(28)=-1)
ignorehitpause = 1

[State -2, Danger]
type = VarSet
trigger1 = var(30) !=1 && roundstate=2 && life = [1,250]
var(29) = 9
ignorehitpause = 1

; sound First attack
;[State -2, First Attack]
;type = PlaySnd
;triggerall = var(28)=-1
;triggerall = NumExplod(8701) = 0
;trigger1 = var(28)=-1 && (movehit || p2movetype = H && p2stateno != [120,159]);p2stateno = 6300 || p2movetype = H);p2stateno = [5000,5899])
;persistent = 0
;value = 7050,0
;volume=255
;ignorehitpause = 1

; Telop sound
;[State -2, Combo Sound]
;type = PlaySnd
;trigger1 = NumExplod(8701) = 0
;trigger1 = var(28)=0 && var(29)!=0
;persistent = 0;1
;value = 7050,var(29)
;volume=255
;ignorehitpause = 1

[State -2, Left]
type = explod
trigger1 = var(28)=0 && var(29)!=0
trigger2 = var(28)=-1 && (movehit || p2movetype = H && p2stateno != [120,159]);p2stateno = 6300 ||p2movetype = H);p2stateno = [5000,5899])
triggerall = TeamSide = 1 && NumExplod(8701) = 0
anim = (7050 + var(29))
ID = 8701
postype = left
pos = 3,90
ontop = 1
bindtime = -1
removetime = 60
ownpal = 1
supermovetime = 60
pausemovetime = 60
scale = 0.5,0.5
persistent = 0
ignorehitpause = 1

[State -2, Right]
type = explod
trigger1 = var(28)=0 && var(29)!=0
trigger2 = var(28)=-1 && (movehit || p2movetype = H && p2stateno != [120,159]);p2stateno = 6300 ||p2movetype = H);p2stateno = [5000,5899])
triggerall = TeamSide = 2 && NumExplod(8701) = 0
anim = (7150+ var(29));8011;8720;
ID = 8701
postype = right
pos = -10,90;130;82
ontop = 1
bindtime = -1
removetime = 60;90
ownpal = 1
supermovetime = 60;90
pausemovetime = 60;90
scale = 0.5,0.5
persistent = 0;1
ignorehitpause = 1

[State -2, VS_Combo]
type = VarAdd
trigger1 = enemynear, time = 0
trigger1 = enemynear, Hitshakeover = 0
trigger1 = (p2movetype = H && p2stateno != [120,159]);p2stateno = 6300 || p2movetype = H;p2stateno = [5000,5899]
trigger2 = var(28)=-1 && (movehit || p2movetype = H && p2stateno != [120,159]);p2stateno = 6300 || p2movetype = H);p2stateno = [5000,5899])
var(28) = 1 + (var(28)=-1)
ignorehitpause = 1

[State -2, VS_Combo]
type = VarSet
trigger1 = var(28)!=-1 && (p2movetype!=H || enemynear, ctrl)
trigger2 = var(28)=-1 && movetype = H;p2stateno = [5000,5899])
var(28) = 0 - (roundstate<2)
ignorehitpause = 1

[State -2, VS_Combo]
type = VarSet
triggerall = numexplod(8701)!=0
trigger1 = var(28)=0
var(29) = 0
ignorehitpause = 1

[State -2, Score]
type = Varadd
trigger1 = enemynear, time=0
trigger1 = enemynear, Hitshakeover=0
trigger1 = moveguarded || p2stateno = 6300 || p2movetype = H;p2stateno = [5000,5899])
trigger2 = var(28)=-1 && (movehit || p2stateno = 6300 || p2movetype = H);p2stateno = [5000,5899])
trigger3 = roundstate=4 && time=0 && stateno = [180,189]
var(21) = ceil(stateno/50)*var(28) + (life)*(roundstate=4) + (moveguarded)
ignorehitpause = 1

[State -2, Normalize Score]
type = Varset
triggerall = numpartner=1
trigger1 = var(21)< partner, var(21)
var(21) = partner, var(21)

[State -2, Is Danger]
type = VarSet
trigger2 = var(30) = 0 && life <= 250
trigger1 = var(30) = 1 && roundstate!=2
var(30) = (roundstate>1)
ignorehitpause = 1

[State -2, Is First Attack p3]
type = VarSet
triggerall = numpartner=1
trigger1 = partner, movehit
trigger1 = partner, var(28) != -1
var(28) = 0
ignorehitpause = 1

[State -2, AssertSpecial]
type = AssertSpecial
triggerall = roundno = 1
trigger1 = roundstate < 2
flag = nomusic

[State -2, Charge Helper]
type = Helper
triggerall = var(20) = 2
trigger1 = numhelper(1590) = 0 && var(31) >= 20
type = normal
name = "Charge FX"
ID = 1590
postype = p1
stateno = 1590
ownpal = 1

[State -2, Charge]
type = VarAdd
triggerall = var(20) = 2
triggerall = command = "holdz" && var(31) < 900;2700 ;9000
trigger1 = stateno != 225 && stateno != 625
v = 31
value = 1
ignorehitpause = 1

[State -2, VarSet Charge Used]
type = VarSet
triggerall = var(20) = 2
triggerall = stateno != 225 && stateno != 625
trigger1 = command = "endz" && stateno != [200,1299]
trigger1 = ctrl = 0
trigger2 = stateno = [180,194]
trigger3 = stateno = [3000,3500]
v = 31
value = 0
ignorehitpause = 1

[State -2, VarSet Charge End]
type = Varset
triggerall = var(20) = 2
triggerall = stateno != 225 && stateno != 625
trigger1 = command = "z" || roundstate!=2
v = 31
value = 0
ignorehitpause = 1

[State -2, VarSet Charge End]
type = Varset
triggerall = var(20) = 2
triggerall = stateno = 225 && animelemtime(9) = 0|| stateno = 625 && animelemtime(9) = 0
triggerall = stateno != 225 || stateno != 625
trigger1 = command != "holdz" || command = "endz" || command = "z"
v = 31
value = 0
ignorehitpause = 1

[State -2, VarSet]
type = VarSet
triggerall = var(20) = 2
triggerall = (stateno = [200,220]) || (stateno = [230,620]) || (stateno = [630,1999])
triggerall = !movecontact
trigger1 = command != "holdz" || command = "endz" || command = "z"
v = 31
value = 0
ignorehitpause = 1

[State -2, VarSet]
type = VarSet
trigger1 = var(20) != 2
trigger2 = prevstateno=225 || prevstateno=625
trigger2 = movetype=H
v = 31
value = 0
ignorehitpause = 1

[State 0, ChangeState]
type = null;ChangeState
triggerall = var(20) = 2
triggerall = var(31) >= 90
;triggerall = (stateno = [200,220]) || (stateno = [230,450]) ||(stateno = [1000,1999])
triggerall = animtime = 0
triggerall = statetype != A
trigger1 = command != "holdz" || command = "endz" || command = "z"
value = 225
ctrl = 0

[State 0, ChangeState]
type = null;ChangeState
triggerall = var(20) = 2
triggerall = var(31) >= 90
;triggerall = (stateno = [200,220]) || (stateno = [230,450]) ||(stateno = [1000,1999])
triggerall = animtime = 0
triggerall = statetype = A
trigger1 = command != "holdz" || command = "endz" || command = "z"
value = 625
ctrl = 0

[state -2, Charge Sound]
type = playsnd
triggerall = var(20) = 2
trigger1 = var(31) = 90
value = S5,8
channel = 6

[state -2,Charge Sound End]
type = stopsnd
triggerall = var(20) = 2
trigger1 = var(31) = 0
channel = 6

[state -2, Start Charge FX1]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [20, 89]
trigger1 = time % 56 = [12,15]
add = 160,160,160
time = 1

[state -2, Start Charge FX2]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [20, 89]
trigger1 = time % 56 = [8,11]
trigger2 = time % 56 = [16,19]
add = 120,120,120
time = 1

[state -2, Start Charge FX3]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [20, 89]
trigger1 = time % 56 = [4,7]
trigger2 = time % 56 = [20,23]
add = 80,80,80
time = 1

[state -2, Start Charge FX4]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [20, 89]
trigger1 = time % 56 = [0,3]
trigger2 = time % 56 = [24,27]
add = 40,40,40
time = 1

[state -2, Start Charge FX5]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [20, 89]
trigger1 = time % 56 = [32,35]
trigger2 = time % 56 = [48,51]
add = -40,-40,-40
time = 1

[state -2, Start Charge FX6]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [20, 89]
trigger1 = time % 56 = [36,39]
trigger2 = time % 56 = [44,47]
add = -80,-80,-80
time = 1

[state -2, Start Charge FX7]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [20, 89]
trigger1 = time % 56 = [40,43]
add = -120,-120,-120
time = 1

[state -2, Level 1 Charge FX1]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [90, 179]
trigger1 = time % 42 = [12,15]
add = 160,160,160
time = 1

[state -2, Level 1 Charge FX2]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [90, 179]
trigger1 = time % 42 = [8,11]
trigger2 = time % 42 = [16,19]
add = 120,120,120
time = 1

[state -2, Level 1 Charge FX3]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [90, 179]
trigger1 = time % 42 = [4,7]
trigger2 = time % 42 = [20,23]
add = 80,80,80
time = 1

[state -2, Level 1 Charge FX4]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [90, 179]
trigger1 = time % 42 = [0,3]
trigger2 = time % 42 = [24,27]
add = 40,40,40
time = 1

[state -2, Level 1 Charge FX5]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [90, 179]
trigger1 = time % 42 = [32,35]
trigger2 = time % 42 = [48,51]
add = -40,-40,-40
time = 1

[state -2, Level 1 Charge FX6]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [90, 179]
trigger1 = time % 42 = [36,39]
trigger2 = time % 42 = [44,47]
add = -80,-80,-80
time = 1

[state -2, Level 1 Charge FX7]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [90, 179]
trigger1 = time % 42 = [40,43]
add = -120,-120,-120
time = 1

[state -2, Level 2 Charge FX1]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [180,359]
trigger1 = time % 28 = [0,1]
add = 70,-8,-74
time = 1
color = 0
ignorehitpause = 1

[state -2, Level 2 Charge FX2]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [180,359]
trigger1 = time % 28 = [2,3]
trigger2 = time % 28 = [26,27]
add = 102,24,-74
time = 1
color = 0
ignorehitpause = 1

[state -2, Level 2 Charge FX3]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [180,359]
trigger1 = time % 28 = [4,5]
trigger2 = time % 28 = [24,25]
add = 134,56,-74
time = 1
color = 0
ignorehitpause = 1

[state -2, Level 2 Charge FX4]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [180,359]
trigger1 = time % 28 = [6,7]
trigger2 = time % 28 = [22,23]
add = 166,88,-74
time = 1
color = 0
ignorehitpause = 1

[state -2, Level 2 Charge FX5]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [180,359]
trigger1 = time % 28 = [8,9]
trigger2 = time % 28 = [20,21]
add = 166,104,-58
time = 1
color = 0
ignorehitpause = 1

[state -2, Level 2 Charge FX6]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [180,359]
trigger1 = time % 28 = [10,11]
trigger2 = time % 28 = [18,19]
add = 166,120,-42
time = 1
ignorehitpause = 1
color = 0

[state -2, Level 2 Charge FX7]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [180,359]
trigger1 = time % 28 = [12,13]
trigger2 = time % 28 = [16,17]
add = 166,136,-26
time = 1
ignorehitpause = 1
color = 0

[state -2, Level 2 Charge FX8]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) = [180,359]
trigger1 = time % 28 = [14,15]
add = 166,152,-10
ignorehitpause = 1
color = 0
time = 1

[state -2, Level 3 Charge FX1]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) >= 360
trigger1 = time % 14 = [0,1]
add = 70,-8,74
time = 1
color = 0
ignorehitpause = 1

[state -2, Level 3 Charge FX2]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) >= 360
trigger1 = time % 14 = [2,3]
trigger2 = time % 14 = [26,27]
add = 102,24,126
time = 1
color = 0
ignorehitpause = 1

[state -2, Level 3 Charge FX3]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) >= 360
trigger1 = time % 14 = [4,5]
trigger2 = time % 14 = [24,25]
add = 134,56,128
time = 1
color = 0
ignorehitpause = 1

[state -2, Level 3 Charge FX4]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) >= 360
trigger1 = time % 14 = [6,7]
trigger2 = time % 14 = [22,23]
add = 166,88,170
time = 1
color = 0
ignorehitpause = 1

[state -2, Level 3 Charge FX5]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) >= 360
trigger1 = time % 14 = [8,9]
trigger2 = time % 14 = [20,21]
add = 166,104,170
time = 1
color = 0
ignorehitpause = 1

[state -2, Level 3 Charge FX6]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) >= 360
trigger1 = time % 14 = [10,11]
trigger2 = time % 14 = [18,19]
add = 166,120,170
time = 1
ignorehitpause = 1
color = 0

[state -2, Level 3 Charge FX7]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) >= 360
trigger1 = time % 14 = [12,13]
trigger2 = time % 14 = [16,17]
add = 166,136,170
time = 1
ignorehitpause = 1
color = 0

[state -2, Level 3 Charge FX8]
type = PalFx
triggerall = var(20) = 2
triggerall = var(31) >= 360
trigger1 = time % 14 = [14,15]
add = 166,152,170
ignorehitpause = 1
color = 0
time = 1
;------------------------------
[state -2, Glow Evil FX1]
type = PalFx
triggerall = var(35) = 1
trigger1 = time % 14 = [0,1]
add = 0,-200,-200
time = 1
color = 0
ignorehitpause = 1

[state -2, Glow Evil FX2]
type = PalFx
triggerall = var(35) = 1
trigger1 = time % 14 = [2,3]
trigger2 = time % 14 = [26,27]
add = 30,-170,-170
time = 1
color = 0
ignorehitpause = 1

[state -2, Glow Evil FX3]
type = PalFx
triggerall = var(35) = 1
trigger1 = time % 14 = [4,5]
trigger2 = time % 14 = [24,25]
add = 60,-140,-140
time = 1
color = 0
ignorehitpause = 1

[state -2, Glow Evil FX4]
type = PalFx
triggerall = var(35) = 1
trigger1 = time % 14 = [6,7]
trigger2 = time % 14 = [22,23]
add = 90,-110,-110
time = 1
color = 0
ignorehitpause = 1

[state -2, Glow Evil FX5]
type = PalFx
triggerall = var(35) = 1
trigger1 = time % 14 = [8,9]
trigger2 = time % 14 = [20,21]
add = 120,-80,-80
time = 1
color = 0
ignorehitpause = 1

[state -2, Glow Evil FX6]
type = PalFx
triggerall = var(35) = 1
trigger1 = time % 14 = [10,11]
trigger2 = time % 14 = [18,19]
add = 150,-50,-50
time = 1
ignorehitpause = 1
color = 0

[state -2, Glow Evil FX7]
type = PalFx
triggerall = var(35) = 1
trigger1 = time % 14 = [12,13]
trigger2 = time % 14 = [16,17]
add = 180,-20,-20
time = 1
ignorehitpause = 1
color = 0

[state -2, Glow Evil FX8]
type = PalFx
triggerall = var(35) = 1
trigger1 = time % 14 = [14,15]
add = 220,10,10
ignorehitpause = 1
color = 0
time = 1

[State -2, Clipboard]
type = DisplayToClipboard
trigger1 = 1
text = "damage=%f||AI?=%d||Weapon=%d||ChargeLv.=%d||Combo=%d"
params = fVar(10), Var(59), var(20), var(31), Var(28);p2bodydist X

[State -2, Damage based on hits]
type=varset
trigger1= numenemy
fvar(12)=enemynear,gethitvar(hitcount)
ignorehitpause=1

[State -2, Reset var when the opponent recovers]
type=varset
trigger1= numenemy
trigger1= (enemynear,movetype!=H)
trigger2= !numenemy
fvar(12)=1

[State -2, Dampener]
type=varset
trigger1=stateno!= [3000,3999]
fvar(10)= ifelse(fvar(12)=0, 1, ifelse(fvar(12)=1, 1, .85**fvar(12)))
ignorehitpause=1

[State -2, Dampener]
type=varset
trigger1=stateno = [3000,3999]
fvar(10)= ifelse(fvar(12)=0, 1, ifelse(fvar(12)=1, 1, .95**fvar(12)))
ignorehitpause=1

[State -2, Dampener itself]
type=attackmulset
trigger1= 1
value=fvar(10)
ignorehitpause=1
;==================================================================================
;==================================================================================
;==================================================================================


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

[Statedef -3]

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [1100,1155]
id = 1100
;ignorehitpause =
;persistent =

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [1100,1155]
id = 1192
;ignorehitpause =
;persistent =

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [3100,3199]
id = 3190
;ignorehitpause =
;persistent =

[State -3, RemoveExplod]
type = RemoveExplod
trigger1 = stateno != [3100,3199]
id = 3191
;ignorehitpause =
;persistent =


;==================================================================================
;======| RELACIONADO À AI - AI RELATED |===========================================
;==================================================================================


; Kamek and Luchini appear to have been the first ones to use the IsHomeTeam AI activation concept.
; Feel free to move this controller to your character's intro state for slightly better efficiency.
[State -3, SetAI]
type = VarSet
triggerall = !RoundState
triggerall = IsHomeTeam
trigger1 = (TeamSide = 2)
trigger2 = (MatchNo > 1)
var(59) = 1

; Feel free to move this controller to your character's intro state for slightly better efficiency.
; Note that it may give P2 a slight unfair advantage in simul team vs mode, so you
; may want to disable it.  But then, since when has Mugen been about fairness? =P
[State -3, Unfair]; Is this reliable?
type = VarSet
trigger1 = !RoundState
trigger1 = (var(59) != 1)
trigger1 = NumPartner
trigger1 = (ID > Partner,ID)
trigger1 = (TeamSide = 2)
var(59) = 1

[State -3, AI Helper (Compatibly Partnered Version)]
type = Helper
trigger1 = !var(59)
trigger1 = !NumHelper(9742)
trigger1 = (RoundState = 2)
trigger1 = Alive
trigger1 = NumPartner
trigger1 = Partner,SelfAnimExist(9741)
HelperType = normal
name = "AI Helper (Simul Version)"
ID = 9742
pos = 9999999,99999
StateNo = 9742
KeyCtrl = 1
PauseMoveTime = 999999999
SuperMoveTime = 999999999

; If you want to use the Guard mode, Dummy mode, Distance, or Button jam dummy control
; options in Training mode without activating the dummy's AI while working on your
; character, then all you need to do is temporarily disable this controller.
; Or, if you want to permanently disable this controller in Training mode,
; then you could use the Training mode detection code available on my site
; ( http://www.shinmugen.net/winane/ ), and then just add a "(var(59)&63)>30"
; triggerall to this controller.
[State -3, AI Helper]
type = Helper
triggerall = !var(59)
triggerall = !NumHelper(9741)
triggerall = (RoundState = 2)
triggerall = Alive
trigger1 = !NumPartner
trigger2 = !(Partner,SelfAnimExist(9741))
HelperType = normal
name = "AI Helper"
ID = 9741
pos = 9999999,99999
StateNo = 9741
KeyCtrl = 1
PauseMoveTime = 999999999
SuperMoveTime = 999999999

[State -3, TurnBackOnAI]
type = VarSet
trigger1 = (var(59) = -2)
trigger1 = (RoundState = 2)
trigger1 = Alive
var(59) = 1

[State -3, HitPauseTime Helper]
type = Helper
triggerall = var(59)!=1
triggerall = !NumHelper(9743)
triggerall = (RoundState = 2)
triggerall = Alive
trigger1 = (MatchNo = 1)
trigger2 = NumPartner
trigger2 = (ID > Partner,ID)
HelperType = normal
name = "HitPauseTime"
ID = 9743
pos = 9999999,99999
StateNo = 9743
PauseMoveTime = 999999999
SuperMoveTime = 999999999

; According to Roque, this method works in Linux Mugen version 2002.04.14,
; whereas the old humanly-impossible commands method does not.
; It is very important that this controller NOT be moved to State -2.
; Note that this part won't work if AI.Cheat is turned off in mugen.cfg.
;[State -3, XOR]
;type = VarSet
;triggerall = var(59)!=1
;triggerall = (var(57) = GameTime-1)
;triggerall = NumHelper(9743)
;triggerall = !(Helper(9743),var(1))
;trigger1 = (command = "a") ^^ (command = "a2")
;trigger2 = (command = "b") ^^ (command = "b2")
;trigger3 = (command = "c") ^^ (command = "c2")
;trigger4 = (command = "x") ^^ (command = "x2")
;trigger5 = (command = "y") ^^ (command = "y2")
;trigger6 = (command = "z") ^^ (command = "z2")
;trigger7 = (command = "start") ^^ (command = "start2")
;trigger8 = (command = "holda") ^^ (command = "holda2")
;trigger9 = (command = "holdb") ^^ (command = "holdb2")
;trigger10 = (command = "holdc") ^^ (command = "holdc2")
;trigger11 = (command = "holdx") ^^ (command = "holdx2")
;trigger12 = (command = "holdy") ^^ (command = "holdy2")
;trigger13 = (command = "holdz") ^^ (command = "holdz2")
;trigger14 = (command = "holdstart") ^^ (command = "holdstart2")
;trigger15 = (command = "holdfwd") ^^ (command = "holdfwd2")
;trigger16 = (command = "holdback") ^^ (command = "holdback2")
;trigger17 = (command = "holdup") ^^ (command = "holdup2")
;trigger18 = (command = "holddown") ^^ (command = "holddown2")
;trigger19 = (command = "recovery") ^^ (command = "recovery2")
;Add more as desired. (See my notes in the CMD.)
;var(59) = 1

; It is very important that this controller NOT be moved to State -2, as putting
; it there would defeat the entire purpose of the controller, allowing the
; helper method or the XOR method to erroneously set the AI variable.
; And within State -3, don't put any ChangeState controllers before this
; controller, lest you unnecessarily delay your character's AI activation.
[State -3, GameTimeVar]
type = VarSet
trigger1 = 1
var(57) = GameTime
IgnoreHitPause = 1

; Within StateDef -3, none of your own AI-related code should come after the code
; provided here (and putting it before the code is also generally a bad idea).
; It's better to use State -1 (or, in special circumstances, State -2) instead.

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

;Ths controller plays a sound everytime the player lands from a jump, or
;from a back-dash.
[State -3, Landing Sound]
type = PlaySnd
triggerall = Time = 1
trigger1 = stateno = 52 ;Jump land
trigger2 = stateno = 106 ;Run-back land
trigger3 = stateno = 101
trigger4 = stateno = [900,901]
value = s100,0

[State -3, Landing Anim]
type = Explod
triggerall = Time = 1
trigger1 = stateno = 52 ;Jump land
trigger2 = stateno = 106
trigger3 = stateno = 101
anim = 7503
ID = 8030
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = -2
supermove = 9999
pausemove = 9999
scale = .6,.6
sprpriority = -1
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause =1
persistent =0

[State -3, AfterImagePersist]
type=afterimagetime
;trigger1=stateno=[1600,1602]
;trigger2=stateno=[1900,1903] ;&& time <= 80
trigger1=stateno=[3000,3005]
trigger2=stateno=[3400,3404]
time=2

[State -3, StopSnd]
type = StopSnd
trigger1 = movetype = H
trigger2 = stateno != [3000,3999]
channel = 15
ignorehitpause = 1

[State -3, AfterImageTime]
type = AfterImageTime
trigger1 = numhelper(7005)=1
time = 0
ignorehitpause = 1
;persistent =  0

;------------------------------------------------------------------------------------------------------
;wall hit
[state 5100,2]
type = explod
triggerall = numtarget
triggerall = stateno!=0
triggerall = stateno!=3005
triggerall = stateno!=3000
triggerall = stateno!=1000
triggerall = stateno!=1005
triggerall = stateno!=1010
triggerall = stateno!=50
;triggerall = stateno!=[5000,5999]
;triggerall = movetype ! =H
triggerall = var(42)
triggerall = enemynear,stateno != [120,159]
trigger1 = enemynear,movetype = h
trigger1 = enemynear,backedgedist <= 15
trigger1 = enemynear,statetype = a
trigger1 = enemynear,vel x < 0
anim = 7024
pos = (enemy,const(size.mid.pos.x))-20,(target,const(size.mid.pos.y))
postype = p2
scale = 0.6,0.52
sprpriority = 3
bindtime = 1
facing = -1
removetime = -2
id = 7024
shadow = 0,0,0
ownpal = 1
;removeongethit = 1
;ignorehitpause = 1
;vel = -2,0
;accel = -0.1,0

[state 5100,2]
type = explod
triggerall = numtarget
triggerall = stateno!=0
triggerall = stateno!=3005
triggerall = stateno!=3000
triggerall = stateno!=1000
triggerall = stateno!=1005
triggerall = stateno!=1010
triggerall = stateno!=50
;triggerall = stateno!=[5000,5999]
;triggerall = movetype ! =H
triggerall = var(42)
triggerall = enemynear,stateno != [120,159]
trigger1 = enemynear,movetype = h
trigger1 = enemynear,backedgedist <= 15
trigger1 = enemynear,statetype = a
trigger1 = enemynear,vel x < 0
anim = 7024
pos = (enemy,const(size.mid.pos.x))-20,(target,const(size.mid.pos.y))
postype = p2
sprpriority = -3
bindtime = 1
facing = -1
scale = 0.6,0.52
removetime = -2
id = 7024
shadow = -1
ownpal = 1
;removeongethit = 1
;ignorehitpause = 1
;vel = -2,0
;accel = -0.1,0

[state 5100,2]
type = playsnd
triggerall = numtarget
triggerall = stateno!=0
triggerall = stateno!=3005
triggerall = stateno!=3000
triggerall = stateno!=1000
triggerall = stateno!=1005
triggerall = stateno!=1010
triggerall = stateno!=50
;triggerall = stateno!=[5000,5999]
;triggerall = movetype ! =H
triggerall = var(42)
triggerall = numenemy
triggerall = enemynear,stateno != [120,159]
trigger1 = stateno != 4003
trigger1 = enemynear,movetype = h
trigger1 = enemynear,backedgedist < 15
trigger1 = enemynear,statetype = a
trigger1 = enemynear,vel x < 0
persistent = 0
value = 7000,2
channel = 4
volume = 255

[state 200, 3]
type = varset
;triggerall = stateno!=[5000,5999]
;triggerall = movetype ! =H
triggerall = var(42)
triggerall = numenemy
trigger1 = enemynear,movetype = h
trigger1 = enemynear,backedgedist < 15
trigger1 = enemynear,statetype = a
trigger1 = enemynear,vel x < 0
v = 42
value = 0

[state -3, 2];combo hosei
type = varset
trigger1 = 1
v = 24
value = var(22)

[state -3, 2];combo hosei
type = varset
trigger1 = 1
v = 22
value = var(25)+hitcount

[state -3, 2];combo hosei
type = varset
trigger1 = enemynear,movetype != H
v = 25
value = 0

;***************
[state -3, 2];combo
type = varset
trigger1 = var(22)>var(24)
v = 42
value = 1

[State -3, VarSet]
type = VarSet
trigger1 = stateno != [3000,3999]
;trigger1 = animtime = 0
v = 45   ;fv = 10
value = 0
