
;------------------------------------------------------------------
[Statedef -2]

;------------------------------------------------------------------
[State life]
type = TargetLifeAdd
triggerall = numhelper(1140) >= 1
trigger1 = helper(1140),p2dist x = [-70,70]
trigger1 = helper(1140),p2dist y = [-40,40]
trigger2 = var(10) = 1 && p2dist x < 90
trigger2 =(stateno = 0 || stateno = 20)&& timemod = 4,0
value = -1
kill = 0

[State life]
type = lifeadd
triggerall = var(10) = 1 && roundstate = 2
trigger1 = projhit1040 = 1 || projhit1042 = 1
value = 5
ignorehitpause = 1

;------------------------------------------------------------------
[State var]
type = varadd
trigger1 =!alive
var(1) = 1
ignorehitpause = 1

[State -2]
type = PlaySnd
trigger1 = var(1) = 2
value = 5150,ifelse(var(10)=1||fvar(10)>=2,10,random%2)
ignorehitpause = 1

;------------------------------------------------------------------
[State cancel]
type = ReversalDef
triggerall = movecontact = 0
trigger1 = stateno = [200,799]
trigger2 = stateno = [1000,1999]
trigger3 = stateno = [2050,2099]
reversal.attr = SCA,NA,SA
pausetime = 10,10
sparkno = -1;s4490
hitsound = s900,random%2
hitonce = 1
numhits = 0
ignorehitpause = 1

;------------------------------------------------------------------
[State Vital source]
type = Helper
trigger1 = numhelper(9090) = 0
trigger1 = roundstate = 2
name = "vital_source"
stateno = 9090
ID = 9090
ownpal = 1
supermovetime = 9999
persistent = 0
ignorehitpause = 1

[State var]
type = varset
trigger1 = numhelper(9090) = 1
var(0) = helper(9090),var(0)
ignorehitpause = 1
[State var]
type = varset
trigger1 = numhelper(9090) = 1
fvar(0) = helper(9090),fvar(0)
ignorehitpause = 1

[State var]
type = varadd
triggerall = fvar(0) < 64 && time = [0,4]
trigger1 = var(10) = 1 || fvar(10) >= 2
trigger1 = stateno = 42 || stateno = 100 || stateno = 102 || prevstateno = 951
fvar(0) = -1.6

[State var]
type = varset
triggerall = fvar(0) >= 1
trigger1 = var(10) = 1 || fvar(10) >= 2
trigger1 = stateno = 42 || stateno = 100 || stateno = 102 || prevstateno = 951
var(0) = 0

;---------------------------------------------------------------------
[State var]
type = varadd
trigger1 = command = "holdback"
fvar(4) = 1
[State var]
type = varset
trigger1 = command!= "holdback"
fvar(4) = 0
[State 120]
type = ChangeState
triggerall = var(0) < 32
triggerall =(fvar(4) = [1,2])&& p2bodydist x < 80
triggerall = enemynear,statetype = S
trigger1 = stateno = 120 && statetype = S
trigger2 = stateno = 130
value = 160
[State 120]
type = ChangeState
triggerall = var(0) < 32
triggerall =(fvar(4) = [1,2])&& p2bodydist x < 80
triggerall = enemynear,statetype = C
trigger1 = stateno = 120 && statetype = C
trigger2 = stateno = 131
value = 161

[State 160]
type = PlaySnd
trigger1 =(stateno = [160,161])&& time = 1
value = 160,ifelse(var(10)=1||fvar(10)>=2,10+random%2,random%3)
channel = 0

;---------------------------------------------------------------------
[State -2]
type = varset
trigger1 = stateno = 200
var(20) = 1
[State -2]
type = varset
trigger1 = stateno = 210
var(21) = 1
[State -2]
type = varset
trigger1 = stateno = [220,225]
var(22) = 1
[State -2]
type = varset
trigger1 = stateno = 320
var(23) = 1
[State -2]
type = varset
trigger1 = stateno = 400
var(24) = 1
[State -2]
type = varset
trigger1 = stateno = [410,415]
var(25) = 1
[State -2]
type = varset
trigger1 = stateno = 420
var(26) = 1
[State -2]
type = varset
trigger1 = stateno = 600
var(27) = 1
[State -2]
type = varset
trigger1 = stateno = 610
var(28) = 1
[State -2]
type = varset
trigger1 = stateno = 620
var(29) = 1

[State var]
type = VarRangeSet
trigger1 = stateno = [0,20]
trigger2 = stateno = 102 || stateno = [950,952]
value = 0
first = 20
last = 29


;------------------------------------------------------------------
[State target]
type = varset
trigger1 = numenemy >= 1 && numhelper(9090) = 1
fvar(31) = enemy(0),screenpos x
ignorehitpause = 1
[State target]
type = varset
trigger1 = numenemy >= 1 && numhelper(9090) = 1
fvar(32) = helper(9090),screenpos y-enemy(0),screenpos y-floor(enemy(0),const(size.mid.pos.y))
ignorehitpause = 1

[State target]
type = varset
trigger1 = numenemy >= 2 && numhelper(9090) = 1
fvar(33) = enemy(1),screenpos x
ignorehitpause = 1
[State target]
type = varset
trigger1 = numenemy >= 2 && numhelper(9090) = 1
fvar(34) = helper(9090),screenpos y-enemy(1),screenpos y-floor(enemy(1),const(size.mid.pos.y))
ignorehitpause = 1

;------------------------------------------------------------------
; Extra hit spark
[State var]
type = varset
trigger1 = numhelper(4100) >= 1
var(31) = helper(4100),ID
ignorehitpause = 1
[State var]
type = varset
trigger1 = numhelper(4102) >= 1
var(33) = helper(4102),ID
ignorehitpause = 1

[State target]
type = varset
trigger1 = numenemy >= 1
trigger1 = enemy(0),movetype!= H || enemy(0),gethitvar(guarded) || enemy(0),stateno = [5100,5120]
var(32) = 0
ignorehitpause = 1
[State target]
type = varset
triggerall = numenemy >= 1
triggerall = enemy(0),statetype!= L && enemy(0),gethitvar(guarded) = 0
triggerall = enemy(0),gethitvar(chainID) = [4200,4210]
trigger1 = projhit1040 = 1 || projhit1042 = 1 || projhit1290 = 1
trigger2 = numhelper(1140) >= 1
trigger2 = helper(1140),stateno = 1141 && helper(1140),movehit
trigger3 =(stateno = [2000,2002])&& movehit
trigger4 =(stateno = [12100,12102])&& movehit
var(32) = 2
ignorehitpause = 1
[State target]
type = varadd
trigger1 = var(32) >= 1
var(32) = -1
ignorehitpause = 1

[State target]
type = varset
trigger1 = numenemy >= 2
trigger1 = enemy(1),movetype!= H || enemy(1),gethitvar(guarded) || enemy(1),stateno = [5100,5120]
var(34) = 0
ignorehitpause = 1
[State target]
type = varset
triggerall = numenemy >= 2
triggerall = enemy(1),statetype!= L && enemy(1),gethitvar(guarded) = 0
triggerall = enemy(1),gethitvar(chainID) = [4200,4210]
trigger1 = projhit1040 = 1 || projhit1042 = 1 || projhit1290 = 1
trigger2 = numhelper(1140) >= 1
trigger2 = helper(1140),stateno = 1141 && helper(1140),movehit
trigger3 =(stateno = [2000,2002])&& movehit
trigger4 =(stateno = [12100,12102])&& movehit
var(34) = 2
ignorehitpause = 1
[State target]
type = varadd
trigger1 = var(34) >= 1
var(34) = -1
ignorehitpause = 1

[State Extra hit spark p2]
type = Helper
trigger1 = numenemy >= 1 && numhelper(4100) = 0 && ctrl
name = "extra_p2"
stateno = 4100
ID = 4100
ownpal = 1
ignorehitpause = 1
[State Extra hit spark p4]
type = Helper
trigger1 = numenemy >= 2 && numhelper(4102) = 0 && ctrl
name = "extra_p4"
stateno = 4100
ID = 4102
ownpal = 1
ignorehitpause = 1

;------------------------------------------------------------------
[State var]
type = null;varset
trigger1 = teammode = turns
trigger2 = enemy,teammode = turns
var(50) = -1

[State var]
type = null;varset
trigger1 = var(50) >= 0
trigger1 = roundsexisted = 0
var(50) = 0
[State var]
type = varadd
trigger1 = var(50) = 0 && win = 1
trigger1 = roundstate = 4
trigger2 = var(50) >= 1 && win = 1
trigger2 = roundstate = 3
var(50) = 1
persistent = 0
ignorehitpause = 1

[State -2]
type = ChangeState
triggerall = numpartner = 0 && matchover = 1
triggerall =(ishometeam = 0 && teamside = 1)|| ishometeam = 1 && teamside = 2
trigger1 = stateno = 180 && time = 115
trigger2 = stateno = 10181 && var(2) = 0 && time = 255
trigger3 = stateno = 10181 &&(var(2) = [1,2])&& time = 155
value = 189

;------------------------------------------------------------------
; Armor mode
[State helper]
type = Helper
trigger1 = var(10) = 1 && life >= 249
trigger1 = numhelper(10000) = 0
name = "armor"
stateno = 10000
ID = 10000
pausemovetime = 9999
supermovetime = 9999
ignorehitpause = 1

[State helper]
type = Helper
trigger1 = var(10) = 1 && life >= 249
trigger1 = numhelper(2940) = 0
name = "mirage"
stateno = 2940
ID = 2940
supermovetime = 9999
ownpal = 1
ignorehitpause = 1

[State -2]
type = AssertSpecial 
trigger1 = numhelper(10000)>= 1
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard

[State life]
type = lifeadd
trigger1 = numhelper(10000)>= 1
trigger1 = helper(10000),gethitvar(damage)!= 0
value = -helper(10000),gethitvar(damage)
absolute = 1

[State hit]
type = NotHitBy
trigger1 = numhelper(10000)>= 1
trigger1 = movetype!= H
value = ,AA,AP
ignorehitpause = 1

[State var]
type = varset
trigger1 = life < 249 || alive = 0
var(10) = 0
ignorehitpause = 1

;------------------------------------------------------------------
[State Turning]
type = ChangeAnim
trigger1 = var(10) = 1
trigger1 = anim = 5 && statetype = S
value = 10005
[State Crouch Turning]
type = ChangeAnim
trigger1 = var(10) = 1
trigger1 = anim = 6 && statetype = C
value = 10006

;------------------------------------------------------------------
[State snd]
type = StopSnd
trigger1 = movetype = H && stateno!= [120,155]
channel = 0

[State snd]
type = PlaySnd
trigger1 = stateno = 52 && time = 1
value = 52,0

[State snd]
type = PlaySnd
trigger1 = stateno = 101 && time = 1
value = 101,0

[State 150]
type = PlaySnd
trigger1 = stateno = 151 || stateno = 153 || stateno = 155
trigger1 = time = 5 && random < 100
value = 150,ifelse(var(10)=1||fvar(10)>=2,10+random%2,random%3)
channel = 0

[State 901]
type = PlaySnd
trigger1 = stateno = 901 || stateno = 911 || stateno = 921
trigger1 = time = 1
value = 901,ifelse(var(10)=1||fvar(10)>=2,10+random%3,random%2)
channel = 0

[State snd]
type = PlaySnd
trigger1 = enemy,stateno = 5062 && enemy,time = 1
value = 4350,0
persistent = 0

[State 5120]
type = PlaySnd
trigger1 = stateno = 5120 && time = 1
value = 5120,ifelse(var(10)=1||fvar(10)>=2,10+random%2,random%4)
channel = 0
[State 5200]
type = PlaySnd
trigger1 =(stateno = [5201,5210])&& time = 1
value = 5200,ifelse(var(10)=1||fvar(10)>=2,10+random%3,random%4)
[State 5300]
type = PlaySnd
trigger1 = stateno = 5300 && time = 5
value = 5300,ifelse(var(10)=1||fvar(10)>=2,10+random%2,random%4)

[State var]
type = varset
trigger1 = stateno = 0 || stateno = 52
trigger2 = movetype = H
var(11) = 0
ignorehitpause = 1
[State var]
type = varset
trigger1 =(stateno = [0,20])|| stateno = 52
trigger2 = movetype = H
trigger3 = pos y >= 0 && vel y > 0
fvar(11) = 0
ignorehitpause = 1
[State -2]
type = AssertSpecial
trigger1 = fvar(11) = 1
flag = nojugglecheck

;------------------------------------------------------------------
[State pause]
type = Pause
triggerall = numtarget >= 1 && roundstate = 2
trigger1 = projhittime(1040) = [0,9]
trigger2 = projhittime(1042) = [0,9]
trigger3 = projhittime(1290) = [0,4]
time = 2
movetime = 0
[State pause]
type = Pause
triggerall = numtarget >= 1 && roundstate = 2
trigger1 = projhittime(1041) = [0,9]
trigger2 = projhittime(1291) = [0,9]
time = 2
movetime = 1

[State pause]
type = Pause
triggerall = numtarget >= 1 && roundstate = 2
trigger1 = projguardedtime(1040) = [0,9]
trigger2 = projguardedtime(1041) = [0,9]
trigger3 = projguardedtime(1042) = [0,9]
trigger4 = projguardedtime(1290) = [0,4]
trigger5 = projguardedtime(1291) = [0,9]
time = 1
movetime = 0

[State pause]
type = Pause
triggerall = roundstate = 2
triggerall = movecontact; && HitPauseTime = 0
trigger1 = stateno = 2000
trigger1 = animelem = 30,>= 0 && animelem = 38,< 0
trigger2 = stateno = 2002 && animelem = 5,< 0
time = 4
movetime = 0

;------------------------------------------------------------------
[State power]
type = poweradd
triggerall = var(3) < 2 && time = 1
trigger1 = stateno = 1000 || stateno = 1050
trigger2 = stateno = 1100 || stateno = 1150
trigger3 = stateno = 1200 || stateno = 1250
value = 100

[State power]
type = poweradd
trigger1 = gametime%2 && ctrl
value = 1+var(10)

;------------------------------------------------------------------
[State 200]
type = PlaySnd
triggerall = time = 1 && random < 250
trigger1 = stateno = 200
trigger2 = stateno = 400
trigger3 = stateno = 600
value = 200,ifelse(var(10)=1||fvar(10)>=2,10,0)
channel = 0

[State 200]
type = PlaySnd
triggerall = time = 1 && random < 250
trigger1 = stateno = 210
trigger2 = stateno = 410
trigger3 = stateno = 610
value = 200,ifelse(var(10)=1||fvar(10)>=2,11,1)
channel = 0

[State 200]
type = PlaySnd
triggerall = time = 1 && random < 250
trigger1 = stateno = 220 || stateno = 225
trigger2 = stateno = 420
trigger3 = stateno = 620
value = 200,ifelse(var(10)=1||fvar(10)>=2,12,1)
channel = 0

[State 200]
type = PlaySnd
trigger1 = stateno = 320 && animelem = 4
value = 200,ifelse(var(10)=1||fvar(10)>=2,13,3)
channel = 0

[State 200]
type = PlaySnd
trigger1 = stateno = 720 && animelem = 7
value = 200,ifelse(var(10)=1||fvar(10)>=2,14,3)
channel = 0

;------------------------------------------------------------------
[State 5000]
type = PlaySnd
triggerall = time = 1 && random < 50
triggerall = stateno = 5000
triggerall = alive = 1
trigger1 = anim = 5000+var(10)*10000 || anim = 5010+var(10)*10000
value = 5000,0

[State 5000]
type = PlaySnd
triggerall = time = 1 && random < 50
triggerall = stateno = 5000
triggerall = alive = 1
trigger1 = anim = 5001+var(10)*10000 || anim = 5011+var(10)*10000
value = 5000,1

[State 5000]
type = PlaySnd
triggerall = time = 1 && random < 50
triggerall = stateno = 5010
triggerall = alive = 1
trigger1 = anim = 5020+var(10)*10000 || anim = 5021+var(10)*10000
value = 5000,2

[State 5000]
type = PlaySnd
triggerall = time = 1 && random < 50
triggerall = stateno = 5000
triggerall = alive = 1
trigger1 = anim = 5002+var(10)*10000 || anim = 5012+var(10)*10000
value = 5000,3

[State 5000]
type = PlaySnd
triggerall = time = 1 && random < 50
triggerall = stateno = 5010
triggerall = alive = 1
trigger1 = anim = 5022+var(10)*10000
value = 5000,4

[State 5000]
type = PlaySnd
triggerall = time = 1 && random < 50
triggerall = alive = 1
trigger1 = stateno = 5030
trigger2 = stateno = 5070
value = 5000,random%2

;------------------------------------------------------------------
; AI implementation
[State jump]
type = ChangeState
triggerall = var(59) = 1 && roundstate = 2 && random < 250
triggerall = enemy,statetype!= A
triggerall = p2bodydist x = [30,149]
triggerall = statetype!= A && ctrl
trigger1 = enemy,movetype!= A && random < 50
trigger2 = enemy,numproj >= 1
value = 40
[State jump]
type = varset
trigger1 = var(59) = 1
sysvar(1) = 1

[State 赤主・檻髪]
type = ChangeState
triggerall = var(59) = 1 && roundstate = 2 && random < 100
triggerall = power >= 3000
triggerall = p2bodydist x < 20 && p2statetype!= A
trigger1 =(statetype!= A && ctrl || stateno = 101)&& random < 100
trigger2 = stateno = 220 && movecontact
value = 2000

[State 空中投げ技]
type = ChangeState
triggerall = var(59) = 1 && roundstate = 2 && random < 250
triggerall = p2bodydist x < 20 && p2bodydist y = [-40,40]
triggerall = p2statetype = A
trigger1 = statetype = A && ctrl && random < 100
trigger2 = stateno = 620 && movehit
value = 820

[State Recover]
type = ChangeState
triggerall = fvar(0) < 64 && var(59) = 1 && roundstate = 2 && random < 50
triggerall = stateno = 5050
triggerall = vel y > -1
triggerall = alive && canrecover
trigger1 = random < 250
value = 5200

[State Air Dash]
type = ChangeState
triggerall = var(11) < 2 && var(59) = 1 && roundstate = 2 && random < 100
triggerall = enemy,movetype = I
triggerall = stateno!= 45 && stateno!= [102,103]
trigger1 = prevstateno!= 45
trigger1 = statetype = A && ctrl
trigger2 = prevstateno = 45 && stateno = 50 && time >= 10
trigger3 = stateno = 161 && time >= 5
value = 102

[State guard]
type = ChangeState
triggerall = var(59) = 1 && roundstate = 2
triggerall = numhelper(2940) = 0
trigger1 = enemynear,movetype = A
trigger1 = p2bodydist x < const(size.attack.dist)/2
trigger1 = statetype!= A && ctrl
value = ifelse((enemynear,statetype=C),131,130)

[State power]
type = powerset
trigger1 = fvar(10)>= 2 && var(59) = 1 && roundstate = 2
trigger1 = enemy,name!= "Akiha_Tohno"
value = 3000
