;===========================================<AI Helper>==============================================

;===========================================<StageEdge>==============================================
[Statedef 22222, StageEdgeRight]
type = A
ctrl = 0
anim = 0
velset = -10,0
movetype = I
physics = N
sprpriority = 1

[State 22222]
type = assertspecial
trigger1 = 1
flag = invisible
[State 22222]
type = NotHitBy
value = SCA
trigger1 = 1
[State 22222]
type=selfstate
trigger1=!ishelper
value=0

[State 22222]
type = Projectile
Trigger1 = time = 0
velocity = 10,0
projID = 2222
projhits = 9999
projpriority = 9999
projanim = 0
offset = 0,0
projstagebound = 0
Projedgebound = 100000
projremove = 0
Projremovetime = -1
supermovetime = 9999
pausemovetime = 9999

[State 22222]
type = velset
Trigger1 = Root,NumProjID(2222) = 0
Trigger1 = time > 0
x = 0
y = 0

;var(0)   - enemy,power
;var(1)   - stateno
;var(2)   - used power
;
;var(9)   - begining statetype
;var(10)  - hitdefattr
;
;var(12)  - Ryu prev-attack-stateno
;
;var(15)  - enemy muteki-attack flag
;var(16)
;var(17)
;var(18)
;
;var(20)  - tsubushi
;var(29)
;
;var(37)  - reversal state
;var(39)  - non throw flag
;
;fvar(19) - p2bodydist x
;fvar(29) - p2bodydist x

;=====<attack property>=====
[State 22222, enemy SuperCombo flug]
type=varset
triggerall=playeridexist(root,var(54))
trigger1= playerid(root,var(54)),power<var(0)
trigger2= var(1)!=playerid(root,var(54)),stateno;playerid(root,var(54)),power>=var(0)
var(1)=ifelse(playerid(root,var(54)),power<var(0),playerid(root,var(54)),stateno,0)
ignorehitpause=1
pausemovetime=1
supermovetime=1
[State 22222, enemy SuperCombo flug]
type=varset
triggerall=playeridexist(root,var(54))
trigger1= var(1) && var(0)>playerid(root,var(54)),power
trigger2= var(1)!=playerid(root,var(54)),stateno
var(2)=ifelse(var(1)=playerid(root,var(54)),stateno,var(0)-playerid(root,var(54)),power,0)
ignorehitpause=1
pausemovetime=1
supermovetime=1

[State 22222, reset]
type=varset
trigger1=1
var(5)=0
[State 22222, enemy charging]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= playerid(root,var(54)),stateno>=200
trigger1= playerid(root,var(54)),movetype=I && root,var(29)=0 && playerid(root,var(54)),power>var(0)
var(5)=1
[State 22222, enemy powercheck]
type=varset
trigger1=playeridexist(root,var(54))
var(0)=playerid(root,var(54)),power
ignorehitpause=1
pausemovetime=1
supermovetime=1

[State 22222, enemy attacking statetype]
type=varset
triggerall=playeridexist(root,var(54))
trigger1= playerid(root,var(54)),movetype=A && playerid(root,var(54)),time<=2
trigger2= root,var(29)=0 && var(9)
trigger2= var(9):=0
var(9)= (playerid(root,var(54)),statetype=A)*3+(playerid(root,var(54)),statetype=C)*2+(playerid(root,var(54)),statetype=S)*1
ignorehitpause=1
pausemovetime=1
supermovetime=1
[State 22222, enemy hitdefattr]
type=varset
triggerall=playeridexist(root,var(54))
trigger1= playerid(root,var(54)),movetype=A
trigger2= root,var(29)=0 && var(10)
trigger2= var(10):=0
var(10)=(playerid(root,var(54)),hitdefattr=SCA,NA,NP,NT)*1+(playerid(root,var(54)),hitdefattr=SCA,SA,SP,ST)*2+(playerid(root,var(54)),hitdefattr=SCA,HA,HP,HT)*3
ignorehitpause=1
pausemovetime=1
supermovetime=1

[State 22222, prev attack stateno]
type=varset
trigger1= root,movetype=A && root,time=1
var(12)= root,stateno

[State -2, enemy muteki attack flag]
type=varset
trigger1= playeridexist(root,var(54))
trigger1= playerid(root,var(54)),movetype!=A
var(15)=0
[State -2, enemy muteki attack flag]
type=varset
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),movetype=A
trigger1= root,anim=210 && root,time=8 && root,movecontact=0 && root,movereversed=0
trigger1= root,fvar(37)<=64 && root,fvar(35)>=0 && (root,fvar(36)=[-84-root,fvar(0),0])
trigger1= playerid(root,var(54)),statetype=S && playerid(root,var(54)),const(size.head.pos.y)<=-59
trigger2= root,stateno=214 && root,time=4 && root,movecontact=0 && root,movereversed=0
trigger2= root,fvar(37)<=24 && root,fvar(35)>=0 && (root,fvar(36)=[-88-root,fvar(0),0])
trigger2= playerid(root,var(54)),statetype=S && playerid(root,var(54)),const(size.head.pos.y)<=-34
var(15)=playerid(root,var(54)),stateno
[State -2, enemy muteki attack mem]
type=null
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),hitdefattr=SCA,AA
trigger1= !var(16)
trigger1= var(16):=var(15)
trigger2= var(16) && !var(17)
trigger2= var(16)!=var(15)
trigger2= var(17):=var(15)
trigger3= var(16) && var(17) && !var(18)
trigger3= var(16)!=var(15) && var(17)!=var(15)
trigger3= var(18)!=var(15)

;=====<Tsubushi>=====
[State -2, prepare]
type=null
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),time=1
triggerall= playerid(root,var(54)),movetype=A && !(playerid(root,var(54)),hitdefattr=SC,NA)
trigger1= !var(20) || var(20)=-2
trigger1= var(20):=-1
trigger2= !var(21) || var(21)=-2
trigger2= var(21):=-1
trigger3= !var(22) || var(22)=-2
trigger3= var(22):=-1
trigger4= !var(23) || var(23)=-2
trigger4= var(23):=-1
trigger5= !var(24) || var(24)=-2
trigger5= var(24):=-1
trigger6= !var(25) || var(25)=-2
trigger6= var(25):=-1
[State -2, learn]
type=null
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),time>=1+3+1+1
triggerall= playerid(root,var(54)),hitdefattr=SC,NA
trigger1= var(20)=-1 || var(20)=playerid(root,var(54)),stateno
trigger1= var(20):=playerid(root,var(54)),stateno
trigger2= var(21)=-1  || var(21)=playerid(root,var(54)),stateno
trigger2= var(21):=playerid(root,var(54)),stateno
trigger3= var(22)=-1  || var(22)=playerid(root,var(54)),stateno
trigger3= var(22):=playerid(root,var(54)),stateno
trigger4= var(23)=-1  || var(23)=playerid(root,var(54)),stateno
trigger4= var(23):=playerid(root,var(54)),stateno
trigger5= var(24)=-1  || var(24)=playerid(root,var(54)),stateno
trigger5= var(24):=playerid(root,var(54)),stateno
trigger6= var(25)=-1  || var(25)=playerid(root,var(54)),stateno
trigger6= var(25):=playerid(root,var(54)),stateno
ignorehitpause=1
[State -2, end]
type=null
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),hitdefattr=SCA,AA,AT,AP
trigger1= var(20)=-1
trigger1= var(20):=-2
trigger2= var(21)=-1
trigger2= var(21):=-2
trigger3= var(22)=-1
trigger3= var(22):=-2
trigger4= var(23)=-1
trigger4= var(23):=-2
trigger5= var(24)=-1
trigger5= var(24):=-2
trigger6= var(25)=-1
trigger6= var(25):=-2
ignorehitpause=1

[State -2, Tsubushi fail]
type=varset
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),movetype=A
trigger1= var(55)=1 && stateno=200 && enemynear,time<time
var(54)=1

[State -2, Tsubushi flag]
type=varset
trigger1=1
var(55)=0

[State -2, Tsubushi flag]
type=varset
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),movetype=A
trigger1= playerid(root,var(54)),stateno=var(20)
trigger2= playerid(root,var(54)),stateno=var(21)
trigger3= playerid(root,var(54)),stateno=var(22)
trigger4= playerid(root,var(54)),stateno=var(23)
trigger5= playerid(root,var(54)),stateno=var(24)
trigger6= playerid(root,var(54)),stateno=var(25)
var(55)=1

;=====<range>=====
[State -2, bodydist x]
type=varset
triggerall=playeridexist(root,var(54))
trigger1= (root,ctrl || (root,stateno=[21,30]) || root,stateno=12345 || root,stateno=23456 || root,stateno=34567)
trigger1= playerid(root,var(54)),ctrl || (playerid(root,var(54)),stateno=[0,119])
fvar(19)= root,fvar(37)
ignorehitpause=1
pausemovetime=1
supermovetime=1

[State -2, enemy attack range SC vs S];for parry
type=parentvarset
triggerall=playeridexist(root,var(54))
trigger1= (root,prevstateno=[0,29]) || root,prevstateno=52 || root,prevstateno=12345 || root,prevstateno=23456 || root,prevstateno=34567
trigger1= !(root,statetype=A) && playerid(root,var(54)),hitdefattr=S,NA,SA && (playerid(root,var(54)),movecontact || playerid(root,var(54)),movereversed)
trigger1= root,fvar(20)<fvar(19)
fvar(20)= fvar(19)+1*(fvar(19)=0)
ignorehitpause=1
[State -2, enemy attack range SC vs C];for parry
type=parentvarset
triggerall=playeridexist(root,var(54))
trigger1= (root,prevstateno=[0,119]) || root,prevstateno=12345 || root,prevstateno=23456 || root,prevstateno=34567
trigger1= !(root,statetype=A) && playerid(root,var(54)),hitdefattr=C,NA,SA && (playerid(root,var(54)),movecontact || playerid(root,var(54)),movereversed)
trigger1= root,fvar(21)<fvar(19)
fvar(21)= fvar(19)+1*(fvar(19)=0)
ignorehitpause=1
[State -2, enemy attack range SC vs A];for parry
type=parentvarset
triggerall=playeridexist(root,var(54))
trigger1= (root,prevstateno=[0,119]) || root,prevstateno=12345 || root,prevstateno=23456 || root,prevstateno=34567
trigger1= !(root,statetype=A) && playerid(root,var(54)),hitdefattr=A,NA,SA && (playerid(root,var(54)),movecontact || playerid(root,var(54)),movereversed)
trigger1= root,fvar(22)<fvar(19)
fvar(22)= fvar(19)+1*(fvar(19)=0)
ignorehitpause=1
[State -2, enemy attack range A sv SC];for parry
type=parentvarset
triggerall=playeridexist(root,var(54))
trigger1= (root,prevstateno=[40,51]) || (root,prevstateno=[260,289]) || (root,prevstateno=[1100,1299]) || (root,prevstateno=[1500,1599]) || (root,prevstateno=[2100,2112])
trigger1= root,statetype=A && playerid(root,var(54)),hitdefattr=SC,NA,SA && (playerid(root,var(54)),movecontact || playerid(root,var(54)),movereversed)
trigger1= root,fvar(23)<fvar(19)
fvar(23)= fvar(19)+1*(fvar(19)=0)
ignorehitpause=1

[State -2, enemy attack range SC vs SC];
type=varset
triggerall=playeridexist(root,var(54))
trigger1= playerid(root,var(54)),movetype=I; && playerid(root,var(54)),time<=1
fvar(29)= root,fvar(37)
ignorehitpause=1
[State -2, enemy attack range SC vs SC];
type=parentvarset
triggerall=playeridexist(root,var(54))
triggerall= root,fvar(30)<fvar(29)
trigger1= playerid(root,var(54)),hitdefattr=SC,NA,SA,NP,SP,NT,ST && (playerid(root,var(54)),movecontact=1 || playerid(root,var(54)),movereversed=1)
trigger2= playerid(root,var(54)),movecontact=0 && playerid(root,var(54)),statetype!=A && gametime-root,var(58)=1
fvar(30)= fvar(29);+1*(fvar(29)=0)
ignorehitpause=1

;=====<throw/atemi/chu-dan>=====
[State -2, nonthrow flag]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= playerid(root,var(54)),hitdefattr=SCA,AA,AP,AT || playerid(root,var(54)),ctrl=1 || playerid(root,var(54)),movetype=H || playerid(root,var(54)),animtime=0
var(37)= 0
[State -2, nonthrow flag];reversal start state
type=varset
triggerall= playeridexist(root,var(54))
trigger1= !(playerid(root,var(54)),movetype=H) && playerid(root,var(54)),ctrl=0 && !var(37) && playerid(root,var(54)),time<=1
var(37)= playerid(root,var(54)),stateno
[State -2, Throw flag]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= var(39)
trigger1= !(playerid(root,var(54)),movetype=A) || playerid(root,var(54)),ctrl || root,movereversed;!(playerid(root,var(54)),hitdefattr=SCA,AT);
var(39)=0
[State -2, Throw]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= !var(39)
trigger1= playerid(root,var(54)),hitdefattr=SCA,AT
var(39)=1
[State -2, revmem]
type=null
triggerall= playeridexist(root,var(54))
triggerall= var(37) && !var(39)
triggerall= (root,movereversed=1 && var(37)>=200) || (root,gametime-root,var(58)=1); || (root,var(58)!=root,gametime)
trigger1= !var(40) || var(37)=var(40)
trigger1= var(40):=var(37)
trigger2= !var(41) || var(37)=var(41)
trigger2= var(41):=var(37)
trigger3= !var(42) || var(37)=var(42)
trigger3= var(42):=var(37)
trigger4= !var(43) || var(37)=var(43)
trigger4= var(43):=var(37)
trigger5= !var(44) || var(37)=var(44)
trigger5= var(44):=var(37)
ignorehitpause=1
pausemovetime=1
supermovetime=1
[State -2, parentvarset]
type=parentvarset
trigger1= var(41) && var(41)!=root,var(41)
trigger1= var(57):=41
trigger2= var(42) && var(42)!=root,var(42)
trigger2= var(57):=42
trigger3= var(43) && var(43)!=root,var(43)
trigger3= var(57):=43
trigger4= var(44) && var(44)!=root,var(44)
trigger4= var(57):=44
v=var(57)
value=var(var(57))
[State -2, parentvarset]
type=varset
trigger1= root,var(41) && var(41)!=root,var(41)
trigger1= var(57):=41
trigger2= root,var(42) && var(42)!=root,var(42)
trigger2= var(57):=42
trigger3= root,var(43) && var(43)!=root,var(43)
trigger3= var(57):=43
trigger4= root,var(44) && var(44)!=root,var(44)
trigger4= var(57):=44
v=var(57)
value=root,var(var(57))

[State -2, air throw]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= playerid(root,var(54)),hitdefattr=A,NT,ST
var(56)=1

[State -2, middle attack mem]
type=parentvarset
triggerall= playeridexist(root,var(54))
trigger1= root,var(48)=0
trigger1= root,prevstateno=131 && root,movetype=H && playerid(root,var(54)),movehit && playerid(root,var(54)),hitdefattr=S,NA,SA
var(48)= playerid(root,var(54)),stateno
[State -2, middle attack mem2]
type=parentvarset
triggerall= playeridexist(root,var(54))
trigger1= root,var(48) && root,var(49)=0
trigger1= root,var(48)!=playerid(root,var(54)),stateno
trigger1= root,prevstateno=131 && root,movetype=H && playerid(root,var(54)),movehit && playerid(root,var(54)),hitdefattr=S,NA,SA
var(49)= playerid(root,var(54)),stateno

[State -2, reversaldef]
type=varset
trigger1=1
var(58)=0
[State -2, reversaldef]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= playerid(root,var(54)),stateno=root,var(41) && root,var(41)
trigger2= playerid(root,var(54)),stateno=root,var(42) && root,var(42)
trigger3= playerid(root,var(54)),stateno=root,var(43) && root,var(43)
trigger4= playerid(root,var(54)),stateno=root,var(44) && root,var(44)
;trigger6= playerid(root,var(54)),stateno=root,var(45) && root,var(45)
var(58)=1
[State -2, middle]
type=varset
trigger1=1
var(59)=0
[State -2, middle]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= playerid(root,var(54)),stateno=root,var(48) && root,var(48)
trigger2= playerid(root,var(54)),stateno=root,var(49) && root,var(49)
var(59)=1

[State 22222, Debug gase/muteki]
type=displaytoclipboard
;trigger1= 0
trigger1= 1
text= "1%d 2%d 3%d 4%d attr%d"
params= var(20), var(21), var(22), var(16), var(10)
ignorehitpause=1
[State 22222, Debug dist]
type=displaytoclipboard
trigger1= 0
trigger1= 1
text= "dist%f S-dist%f C-dist%f A-dist%f U-dist%f"
params= abs(root,pos x-pos x), root,fvar(37), root,fvar(20), root,fvar(22), root,fvar(30)
ignorehitpause=1

;var(0)-var(2);super flag
;var(10);enemy statetype

;---

[Statedef 33333, StageEdgeLeft]
type = A
ctrl = 0
anim = 0
velset = -10,0
movetype = I
physics = N
sprpriority = 1

[State 33333]
type = assertspecial
trigger1 = 1
flag = invisible

[State 33333]
type = NotHitBy
value = SCA
trigger1 = 1

[State 33333]
type=selfstate
trigger1=!ishelper
value=0

[State 33333]
type = Projectile
Trigger1 = time = 0
velocity = -10,0
projID = 3333
projhits = 9999
projpriority = 9999
projanim = 0
offset = 0,0
projstagebound = 0
Projedgebound = 100000
projremove = 0
Projremovetime = -1
supermovetime = 9999
pausemovetime = 9999

[State 33333]
type = velset
Trigger1 = Root,NumProjID(3333) = 0
Trigger1 = time > 0
x = 0
y = 0

[State -2, Null]
type=null
triggerall= playeridexist(root,var(54))
trigger1=playerid(root,var(54)),ctrl || playerid(root,var(54)),statetype=L
trigger1=fvar(20):=0 || fvar(21):=0 || fvar(22):=0 || fvar(23):=0

[State -2, xvel]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= root,movecontact=1
fvar(0)= playerid(root,var(54)),gethitvar(xvel)*playerid(root,var(54)),facing*-1
ignorehitpause=1
[State -2, friction]
type=varset
trigger1= playeridexist(root,var(54))
fvar(1)=ifelse(playerid(root,var(54)),statetype=S,playerid(root,var(54)),const(movement.stand.friction),ifelse(playerid(root,var(54)),statetype=C,playerid(root,var(54)),const(movement.crouch.friction),1))
ignorehitpause=1
[State -2, yvel]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= root,movecontact=1
fvar(22)= playerid(root,var(54)),gethitvar(yvel)
ignorehitpause=1
[State -2, yaccel]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= root,movecontact=1
fvar(23)= playerid(root,var(54)),gethitvar(yaccel)
ignorehitpause=1

[state -2, hitvack friction]
type=varset
trigger1= fvar(1) || fvar(2)!=fvar(1)+fvar(1)**2
fvar(2)= fvar(1)+fvar(1)**2
ignorehitpause=1
[state -2, hitvack friction]
type=varset
trigger1= fvar(2) || fvar(3)!=fvar(2)+fvar(1)**3
fvar(3)= fvar(2)+fvar(1)**3
ignorehitpause=1
[state -2, hitvack friction]
type=varset
trigger1= fvar(3) || fvar(4)!=fvar(3)+fvar(1)**4
fvar(4)= fvar(3)+fvar(1)**4
ignorehitpause=1
[state -2, hitvack friction]
type=varset
trigger1= fvar(4) || fvar(5)!=fvar(4)+fvar(1)**5
fvar(5)= fvar(4)+fvar(1)**5
ignorehitpause=1
[state -2, hitvack friction]
type=varset
trigger1= fvar(5) || fvar(6)!=fvar(5)+fvar(1)**6
fvar(6)= fvar(5)+fvar(1)**6
ignorehitpause=1
[state -2, hitback friction]
type=varset
trigger1= fvar(6) || fvar(7)!=fvar(6)+fvar(1)**7
fvar(7)=fvar(6)+fvar(1)**7
ignorehitpause=1
[state -2, hitback friction]
type=varset
trigger1= fvar(7) || fvar(8)!=fvar(7)+fvar(1)**8
fvar(8)=fvar(7)+fvar(1)**8
ignorehitpause=1
[state -2, hitback friction9]
type=varset
trigger1= fvar(8) || fvar(9)!=fvar(8)+fvar(1)**9
fvar(9)=fvar(8)+fvar(1)**9
ignorehitpause=1
[state -2, hitback friction9]
type=varset
trigger1= fvar(9) || fvar(10)!=fvar(9)+fvar(1)**10
fvar(10)=fvar(9)+fvar(1)**10
ignorehitpause=1
[state -2, hitback friction9]
type=varset
trigger1= fvar(10) || fvar(11)!=fvar(10)+fvar(1)**11
fvar(11)=fvar(10)+fvar(1)**11
[state -2, hitback friction]
type=varset
trigger1= fvar(11)
fvar(12)=fvar(11)+fvar(1)**12
[state -2, hitback friction]
type=varset
trigger1= fvar(12)
fvar(13)=fvar(12)+fvar(1)**13
[state -2, hitback friction9]
type=varset
trigger1= fvar(13)
fvar(14)=fvar(13)+fvar(1)**14
[state -2, hitback friction9]
type=varset
trigger1= fvar(14)
fvar(15)=fvar(14)+fvar(1)**15
[state -2, hitback friction9]
type=varset
trigger1= fvar(15)
fvar(16)=fvar(15)+fvar(1)**16
[state -2, hitback friction9]
type=varset
trigger1= fvar(16)
fvar(17)=fvar(16)+fvar(1)**17
ignorehitpause=1
[state -2, hitback friction9]
type=varset
trigger1= fvar(17)
fvar(18)=fvar(17)+fvar(1)**18
ignorehitpause=1

;sukashi support

[State -2, didnt attack in air]
type=varset
trigger1= root,stateno=[40,41]
var(50)=0
[State -2,]
type=varset
triggerall= var(50)!=1
trigger1= root,movetype=A && root,statetype=A
var(50)=1
[State -2, didnt attack in air]
type=varset
triggerall= var(50)!=-1
trigger1= root,statetype!=A && (root,stateno!=[40,41]) && root,stateno!=52 && root,time>1
var(50)=-1

;zero counter support

[State -2, guard count]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= root,movetype=A
var(55)=0
[State -2, guard count]
type=varadd
triggerall= playeridexist(root,var(54))
trigger1= playerid(root,var(54)),moveguarded
trigger1= (root,stateno=150 || root,stateno=152) && root,time=1
var(55)=1

;okizeme support

[State -2, time counter]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= playerid(root,var(54)),stateno!=[5110,5120]
var(56)=0
[State -2, time counter]
type=varadd
triggerall= playeridexist(root,var(54))
trigger1= playerid(root,var(54)),stateno=[5110,5120]
var(56)=1

[State -2, enemy rising]
type=varset
triggerall= playeridexist(root,var(54)) && var(57)=-1
trigger1= playerid(root,var(54)),stateno!=[5110,5120]
var(58)=0
[State -2, enemy rising check flag];1:checking,-1:finish
type=varset
triggerall= playeridexist(root,var(54))
trigger1= !var(57) || var(57)=-1
trigger1= playerid(root,var(54)),stateno=[5110,5120]
trigger2= var(57)=1
trigger2= (playerid(root,var(54)),stateno!=[5110,5120])
var(57)=ifelse(!var(57),1,-1)
[State -2, enemy rising]
type=varadd
triggerall= playeridexist(root,var(54))
trigger1= playerid(root,var(54)),stateno=[5110,5120]
var(58)=1
[State -2]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= var(57)=-1 && var(59)<var(58)
var(59)=var(58)-1

[state -2, Debug]
type=displaytoclipboard
trigger1= 1
text= "dist%f vel x%f friction%f enemy%d count%d"
params= abs(root,pos x-pos x), fvar(0), fvar(1), var(59), var(50)
ignorehitpause=1


;===========================================<Hadou Checker>==============================================
[Statedef 44444, Hadou Checker]
anim = 9741
movetype=I
type=A
physics=N
ctrl=0

[state 44444, destroy]
type=DestroySelf
trigger1= var(59)
trigger2= var(58)>60
ignorehitpause=1
pausemovetime=1
supermovetime=1

[State 44444, PlayerIDSet0]
type=parentvarset
trigger1= playeridexist(id-1-var(58))
trigger1= playerid(id-1-var(58)),ishelper && teamside!=playerid(id-1-var(58)),teamside
trigger1= playerid(id-1-var(58)),movetype=A || playerid(id-1-var(58)),vel x || playerid(id-1-var(58)),vel y
trigger1= var(59):=1 || 1
var(55)=ID-var(58)
ignorehitpause=1
pausemovetime=255
supermovetime=255

[state 44444, destroy]
type=DestroySelf
trigger1= var(59)
trigger2= var(58)>60
ignorehitpause=1
pausemovetime=1
supermovetime=1

[State 44444, nhb]
type=nothitby
trigger1=1
value=SCA

[State 44444, roop]
type=varadd
trigger1= !var(59)
var(58)=1
ignorehitpause=1
pausemovetime=1
supermovetime=1

[State 44444, roop]
type=changestate
trigger1= !var(59) && var(58)<=60
value=44444
ignorehitpause=1
pausemovetime=1
supermovetime=1
persistent=0

[state 44444, Safety]
type=DestroySelf
trigger1=1
ignorehitpause=1
pausemovetime=1
supermovetime=1

[State 44444, Debug]
type=displaytoclipboard
trigger1= 1
text= "destroy%d roop%d id%d"
params= var(59), var(58), id
ignorehitpause=1

;===========================================<Projectile Checker>==============================================
[Statedef 44445, Projectile Checker]
anim = 9741
movetype=I
type=A
physics=N
ctrl=0

[State -2, inguarddist checker reset]
type=varset
triggerall= !fvar(37)
trigger1= var(0)=0
var(2)=0

[State -2, inguarddist checker]
type=varset
triggerall= !fvar(37)
trigger1= !var(2) && inguarddist
var(2)=1

[State -2, pos]
type=posadd
trigger1= !fvar(37)
x=-1
ignorehitpause=1
pausemove=1
supermove=1

[State -2, roop]
type=changestate
triggerall= !fvar(37)
triggerall= (!var(2) || inguarddist)
trigger1= var(0)<254
trigger1= var(0):=var(0)+1 || 1
value=44445
ignorehitpause=1
pausemove=1
supermove=1

;roop end

[State 44445, noturn]
type=assertspecial
trigger1=1
flag=noautoturn
[State 44445, nhb]
type=nothitby
trigger1=1
value=SCA

[State 44445, time]
type=varadd
trigger1=1
var(1)=1

[State 44445, velocity]
type=velset
trigger1= fvar(37)
x=-fvar(37)

[State 44445, vel calc]
type=varset
triggerall= !fvar(37) && fvar(36)
trigger1= var(1)=11
fvar(37)= (-1*(pos x-fvar(36))*facing)/(var(1)-1)

[State 44445, pos memory1]
type=varset
trigger1= !fvar(36)
fvar(36)= pos x
ignorehitpause=1
pausemovetime=1
supermovetime=1

[State 44445, dist x]
type=varset
trigger1=1
fvar(39)= ((pos x+playerid(root,var(54)),const(size.proj.attack.dist)*facing)-root,pos x)*root,facing
ignorehitpause=1
pausemovetime=1
supermovetime=1

[State 44445, roll flag reset]
type= varset
trigger1=1
var(58)=0
[State 44445, roll flag]
type= varset
trigger1= fvar(39)>0
trigger1= fvar(39)-fvar(37)*19-85<-22-44
var(58)=1
[State 44445, alert reset]
type= varset
trigger1=1
var(59)=0
[State 44445, alert]
type= varset
trigger1=(fvar(39)-fvar(37)*7=[-22-44,22])
trigger2= !fvar(37) && (fvar(39)=[-22-44,22])
var(59)=1+(var(1)>9 || root,inguarddist=0)
[State 44445, alert]
type= parentvarset
trigger1= parent,var(58)=0
var(58)=var(58)
[State 44445, alert]
type= parentvarset
trigger1= parent,var(59)=0
var(49)=var(59)

[state 44445, End]
type=DestroySelf
trigger1= playerid(root,var(54)),numproj=0
trigger2= var(0)>=254 && inguarddist
ignorehitpause=1
pausemove=1
supermove=1

[State 44445, Debug]
type=displaytoclipboard
trigger1= 1
text= "guard%d roll%d vel x%f dist2%f dist%f"
params= var(59), var(58), fvar(37), fvar(38), fvar(39)


;===========================================<Hadou Defence>==============================================
[Statedef 55555, Hadou Defence]
type=A
movetype=I
physics=N
anim=9741
ctrl=0

;v0     roop
;v1-v29 time
;v30    memo
;v40~   helperstateno
;v50    numhadou
;v51    numhelper
;v57    jump
;v58    roll
;v59    guard,parry
;f1-f29 dist
;f39    dist learn

[state -2, hadou-dist]
type=varset
triggerall= root,var(55)
trigger1= playeridexist(root,var(55)-1-var(0))
trigger1= playerid(root,var(55)-1-var(0)),HitDefAttr=SCA,AP,AA || PlayerID(root,var(55)-1-var(0)),movetype=A || PlayerID(root,var(55)-1-var(0)),vel x
fvar(1+var(0))=(playerID(root,var(55)-1-var(0)),pos x-root,pos x)*root,facing
ignorehitpause=1
pausemove=1
supermove=1

[State -3, hit learn]
type=varset
triggerall= (root,prevstateno=[0,29])
triggerall= root,movetype=H && (root,stateno!=[150,155]) && root,gethitvar(hittime)>0 && root,gethitvar(hitcount)=1
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),movecontact=0 && playerid(root,var(54)),movereversed=0; && root,var(58)=gametime
trigger1= playeridexist(root,var(55)-1-var(0))
trigger1= fvar(1+var(0))
trigger1= (playerid(root,var(55)-1-var(0)),movetype=I && playerid(root,var(55)-1-var(0)),time<=1) || playerid(root,var(55)-1-var(0)),movecontact
trigger1= abs(fvar(1+var(0)))>fvar(39) && abs(fvar(1+var(0)))>22
fvar(39)=abs(fvar(1+var(0)))-22
ignorehitpause=65535
pausemove=1
supermove=1

[state -2, dist reset]
type=varset
triggerall= root,var(55)
trigger1= fvar(1+var(0))
trigger1= PlayerIDExist(root,var(55)-1-var(0))=0
fvar(1+var(0))=0
ignorehitpause=1
pausemove=1
supermove=1
[state -2, exist var]
type=varset;varadd
triggerall= root,var(55)
trigger1= playeridexist(root,var(55)-1-var(0))
trigger1= playerid(root,var(55)-1-var(0)),movetype=A || playerid(root,var(55)-1-var(0)),vel x || playerid(root,var(55)-1-var(0)),vel y
var(1+var(0))=playerid(root,var(55)-1-var(0)),time;1
ignorehitpause=1
pausemove=1
supermove=1
[state -2, exist var]
type=varset
triggerall= root,var(55)
trigger1= playeridexist(root,var(55)-1-var(0))=0 && var(1+var(0))
var(1+var(0))=0
ignorehitpause=1
pausemove=1
supermove=1

[state -2, jump flag]
type=varset
trigger1= var(0)=0
var(56)=0
ignorehitpause=1
pausemove=1
supermove=1
[State -2, zutsuki flag]
type=varset
triggerall= var(56)>=0
triggerall= playeridexist(root,var(55)-1-var(0))
triggerall= playerid(root,var(55)-1-var(0)),ishelper
triggerall= playerid(root,var(55)-1-var(0)),movetype=A || playerid(root,var(55)-1-var(0)),vel x>=0 || playerid(root,var(55)-1-var(0)),vel y
triggerall= playerid(root,var(55)-1-var(0)),hitdefattr=SCA,NP,SP
trigger1= fvar(1+var(0))>playerid(root,var(55)-1-var(0)),vel x*7+22+fvar(39)
var(56)=1+(playerid(root,var(55)-1-var(0)),pos y=0 && playerid(root,var(55)-1-var(0)),vel y=0)*1
ignorehitpause=1
pausemovetime=255
supermovetime=255
[State -2, zutsuki disallow]
type=varset
triggerall= var(56)>=0
triggerall= playeridexist(root,var(55)-1-var(0))
triggerall= playerid(root,var(55)-1-var(0)),ishelper
triggerall= playerid(root,var(55)-1-var(0)),movetype=A || playerid(root,var(55)-1-var(0)),vel x || playerid(root,var(55)-1-var(0)),vel y
trigger1= playerid(root,var(55)-1-var(0)),hitdefattr=SCA,AA,HP,AT
trigger2= fvar(1+var(0))<=playerid(root,var(55)-1-var(0)),vel x*7+22+fvar(39)
var(56)=-1
ignorehitpause=1
pausemovetime=255
supermovetime=255

[state -2, jump flag]
type=varset
trigger1= var(0)=0
var(57)=0
ignorehitpause=1
pausemove=1
supermove=1
[State -2, jump flag]
type=varset
triggerall= var(57)>=0
triggerall= playeridexist(root,var(55)-1-var(0))
triggerall= playerid(root,var(55)-1-var(0)),ishelper
triggerall= playerid(root,var(55)-1-var(0)),movetype=A || playerid(root,var(55)-1-var(0)),vel x || playerid(root,var(55)-1-var(0)),vel y
triggerall= playerid(root,var(55)-1-var(0)),movetype=A && playerid(root,var(55)-1-var(0)),vel x>=0 && playerid(root,var(55)-1-var(0)),vel y=0
trigger1= fvar(1+var(0))>playerid(root,var(55)-1-var(0)),vel x*3+22+fvar(39)
trigger1= var(52):=ceil((fvar(1+var(0))-playerid(root,var(55)-1-var(0)),vel x*3-22-fvar(39))/(root,const(velocity.jump.fwd.x)+playerid(root,var(55)-1-var(0)),vel x)) || 1
trigger1= root,const(velocity.jump.y)*var(52)+root,const(movement.yaccel)*var(52)<playerid(root,var(55)-1-var(0)),pos y+root,fvar(39)
trigger1= var(52):=ceil((fvar(1+var(0))-playerid(root,var(55)-1-var(0)),vel x*3+22+44-fvar(39))/(root,const(velocity.jump.fwd.x)+playerid(root,var(55)-1),vel x)) || 1
trigger1= root,const(velocity.jump.y)*var(52)+root,const(movement.yaccel)*var(52)<playerid(root,var(55)-1-var(0)),pos y+root,fvar(39)
var(57)=1
ignorehitpause=1
pausemovetime=255
supermovetime=255
[State -2, jump disallow]
type=varset
triggerall= var(57)>=0
triggerall= playeridexist(root,var(55)-1-var(0))
triggerall= playerid(root,var(55)-1-var(0)),ishelper
triggerall= playerid(root,var(55)-1-var(0)),movetype=A || playerid(root,var(55)-1-var(0)),vel x || playerid(root,var(55)-1-var(0)),vel y
trigger1= playerid(root,var(55)-1-var(0)),movetype!=A || playerid(root,var(55)-1-var(0)),vel x<0 || playerid(root,var(55)-1-var(0)),vel y
trigger2= fvar(1+var(0))<=playerid(root,var(55)-1-var(0)),vel x*3+22+fvar(39)
trigger3= var(52):=ceil((fvar(1+var(0))-playerid(root,var(55)-1-var(0)),vel x*3-22-fvar(39))/(root,const(velocity.jump.fwd.x)+playerid(root,var(55)-1),vel x)) || 1
trigger3=  root,const(velocity.jump.y)*var(52)+root,const(movement.yaccel)*var(52)>=playerid(root,var(55)-1-var(0)),pos y+root,fvar(39)
trigger4= var(52):=ceil((fvar(1+var(0))-playerid(root,var(55)-1-var(0)),vel x*3+22+44-fvar(39))/(root,const(velocity.jump.fwd.x)+playerid(root,var(55)-1),vel x)) || 1
trigger4= root,const(velocity.jump.y)*var(52)+root,const(movement.yaccel)*var(52)>=playerid(root,var(55)-1-var(0)),pos y+root,fvar(39)
var(57)=-1
ignorehitpause=1
pausemovetime=255
supermovetime=255

[state -2, guard flag]
type=varset
trigger1= var(0)=0
var(58)=0
ignorehitpause=1
pausemove=1
supermove=1
[State -2, rolling flag]
type=varset
trigger1= var(58)>=0
trigger1= playeridexist(root,var(55)-1-var(0))
trigger1= playerid(root,var(55)-1-var(0)),ishelper
trigger1= playerid(root,var(55)-1-var(0)),movetype=A || playerid(root,var(55)-1-var(0)),vel x || playerid(root,var(55)-1-var(0)),vel y
trigger1= fvar(1+var(0))-playerid(root,var(55)-1),vel x*19-85<-22-44-fvar(39)
var(58)=1
ignorehitpause=1
pausemovetime=255
supermovetime=255
[State -2, rolling disallow]
type=varset
trigger1= var(58)>=0
trigger1= playeridexist(root,var(55)-1-var(0))
trigger1= playerid(root,var(55)-1-var(0)),ishelper
trigger1= playerid(root,var(55)-1-var(0)),movetype=A || playerid(root,var(55)-1-var(0)),vel x || playerid(root,var(55)-1-var(0)),vel y
trigger1= fvar(1+var(0))-playerid(root,var(55)-1),vel x*19-85>=-22-44-fvar(39)
var(58)=-1
ignorehitpause=1
pausemovetime=255
supermovetime=255

[state -2, guard flag]
type=varset
trigger1= var(0)=0
var(59)=0
ignorehitpause=1
pausemove=1
supermove=1
[state -2, guard flag]
type=varset
trigger1= playeridexist(root,var(55)-1-var(0))
trigger1= fvar(1+var(0))>=0 && playerid(root,var(55)-1-var(0)),ishelper
trigger1= playerid(root,var(55)-1-var(0)),movetype=A || playerid(root,var(55)-1-var(0)),vel x || playerid(root,var(55)-1-var(0)),vel y
trigger1= (fvar(1+var(0))-playerid(root,var(55)-1-var(0)),vel x*7=[-22-44-fvar(39),22+fvar(39)])
var(59)=1
ignorehitpause=1
pausemove=1
supermove=1
[state -2, parry flag]
type=varset
triggerall= playeridexist(root,var(55)-1-var(0))
triggerall= playerid(root,var(55)-1-var(0)),ishelper
triggerall= playerid(root,var(55)-1-var(0)),movetype=A || playerid(root,var(55)-1-var(0)),vel x || playerid(root,var(55)-1-var(0)),vel y
trigger1= fvar(1+var(0))-playerid(root,var(55)-1-var(0)),vel x*5=[-22-44-fvar(39),22+fvar(39)]
trigger1= playerid(root,var(55)-1-var(0)),time>9 || fvar(1+var(0))<=0 || (playerid(root,var(55)-1-var(0)),vel x=0 && playerid(root,var(55)-1-var(0)),vel y=0)
trigger2= playerid(root,var(55)-1-var(0)),hitdefattr=SCA,HA,HP
trigger3= (fvar(1+var(0))-playerid(root,var(55)-1-var(0)),vel x*5=[-playerid(root,var(54)),const(size.proj.attack.dist),fvar(39)])
var(59)=2
ignorehitpause=1
pausemove=1
supermove=1

[State -2, numhadou]
type=varset
trigger1=var(0)=0
var(50)=0
ignorehitpause=1
pausemove=1
supermove=1
[State -2, numhadou]
type=varadd
trigger1= playeridexist(root,var(55)-1-var(0))
trigger1= playerid(root,var(55)-1-var(0)),ishelper
trigger1= playerid(root,var(55)-1-var(0)),movetype=A || playerid(root,var(55)-1-var(0)),vel x || playerid(root,var(55)-1-var(0)),vel y
var(50)=1
ignorehitpause=1
pausemove=1
supermove=1
persistent=0

[State -2, roop]
type=changestate
trigger1= var(0)<28
trigger1= var(0):=var(0)+1 || 1
value=55555
ctrl=0

;after roop
[State 55555, nhb]
type=nothitby
trigger1=1
value=SCA
[State 55555, assertspecial]
type=null;;assertspecial
trigger1=1
flag=invisible
[State 55555, push]
type=playerpush
trigger1=1
value=0

[State -2, parry disable]
type=varset
triggerall= var(59)=2 && root,numhelper(10700)=0 && root,numhelper(10701)=0 && root,inguarddist
trigger1= var(50)>2
trigger1= random>250
var(59)=1

[State 55555]
type=varset
trigger1= roundstate=2 && root,var(54)>0
trigger1= playeridexist(root,var(54))
var(51)= playerid(root,var(54)),numhelper
pausemovetime=255
supermovetime=255

[State -2]
type=parentvarset
trigger1= fvar(39)>root,fvar(33)
trigger2= root,fvar(33)>fvar(39)
trigger2= fvar(39):=root,fvar(33)
trigger2= 0
fvar(33)=fvar(39)

[State -2, projectile defence]
type=helper
triggerall= root,var(57)>40
triggerall= playeridexist(root,var(54))
trigger1= numenemy=1
trigger1= enemy,numproj=1
trigger1= numhelper(44445)<=0
postype=p1
pos=floor(root,fvar(35))+1,0
name="projectile defence"
facing=1
type=normal
id=44445
stateno=44445
supermovetime=65535
pausemovetime=65535

[State -2, parry flag special]
type=varset
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),name="Nakoruru"
trigger1= !(playerid(root,var(54)),hitdefattr=SCA,AA,AP) && root,inguarddist && playerid(root,var(54)),time>1
trigger2= root,inguarddist=0
var(59)=root,inguarddist
[State -2, parry flag special]
type=null;varset
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),name="justice"
trigger1= playerid(root,var(54)),numhelper(1350)
var(59)=root,inguarddist*2

[State -2]
type=varset
trigger1= roundstate=2 && numenemy
trigger1= playeridexist(root,var(54))
var(54)= playerid(root,var(54)),numproj

[State -2, launch state]
type=null
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),ctrl=0
triggerall= (var(1)=1) || (var(2)=1) || (var(3)=1) || (var(4)=1) || (var(5)=1) || (var(6)=1) || (var(7)=1) || var(8)=1 || var(9)=1 || var(10)=1
trigger1= !var(30) || var(30)=playerid(root,var(54)),stateno
trigger1= var(30):=playerid(root,var(54)),stateno
trigger2= !var(31) || var(31)=playerid(root,var(54)),stateno
trigger2= var(31):=playerid(root,var(54)),stateno
trigger3= !var(32) || var(32)=playerid(root,var(54)),stateno
trigger3= var(32):=playerid(root,var(54)),stateno
trigger4= !var(33) || var(33)=playerid(root,var(54)),stateno
trigger4= var(33):=playerid(root,var(54)),stateno

[State -2, launch state]
type=varset
trigger1=1
var(55)=0

[State -2, launch state]
type=varset
triggerall= playeridexist(root,var(54))
trigger1= var(30) && playerid(root,var(54)),stateno=var(30)
trigger2= var(31) && playerid(root,var(54)),stateno=var(31)
trigger3= var(32) && playerid(root,var(54)),stateno=var(32)
trigger4= var(33) && playerid(root,var(54)),stateno=var(33)
var(55)=1

[State -2, launch state]
type=null
triggerall= playeridexist(root,var(54))
triggerall= playerid(root,var(54)),numproj>var(55)
trigger1= !var(16)
trigger1= var(16):=playerid(root,var(54)),stateno
trigger2= var(16) && !var(17) && !(playerid(root,var(54)),stateno=var(16))
trigger2= var(17):=playerid(root,var(54)),stateno
trigger3= var(16) && var(17) && !var(18) && !(playerid(root,var(54)),stateno=var(16)) && !(playerid(root,var(54)),stateno=var(17))
trigger3= var(18):=playerid(root,var(54)),stateno
trigger4= var(16) && var(17) && var(18) && !var(19) && !(playerid(root,var(54)),stateno=var(16)) && !(playerid(root,var(54)),stateno=var(17)) && !(playerid(root,var(54)),stateno=var(18))
trigger4= var(19):=playerid(root,var(54)),stateno

[State -2, varset]
type=varset
trigger1=playeridexist(root,var(54))
var(42)= floor(playerid(root,var(54)),const(size.proj.attack.dist)*0.75)

[State -2, PosSet]
type=bindtoroot
trigger1= 1;root,facing!=playerid(root,var(54)),facing
pos=-var(42)+22,0
ignorehitpause=1
pausemove=1
supermove=1
[State -2, PosSet]
type=bindtoroot
trigger1= playeridexist(root,var(54))
trigger1= root,facing=playerid(root,var(54)),facing && root,fvar(35)>0
pos=var(42)-22,0
ignorehitpause=1
pausemove=1
supermove=1
[State -2, turn]
type = turn
trigger1= playeridexist(root,var(54))
trigger1= facing!=root,facing
trigger1= !inguarddist || root,facing!=playerid(root,var(54)),facing
ignorehitpause=1
pausemovetime=65535
supermovetime=65535

[State 55555, roop reset]
type=varset
trigger1=1
var(0)=0
ignorehitpause=1
pausemove=1
supermove=1

[state 55555,debug]
type=displaytoclipboard
;trigger1=0
trigger1= 1
text= "1%d 2%d learn%f alert%d num%d"
params= var(1), var(2), root,fvar(33), var(59), var(50);+playerid(root,var(55)),numproj;helper(44445),fvar(39)
ignorehitpause=1
[state 55555,debug]
type=displaytoclipboard
trigger1=0
trigger1= 1
text= "store%d store%d learn%f numhadou%d alert%d"
params= var(30), var(31), fvar(39), var(50), var(59);+playerid(root,var(55)),numproj;helper(44445),fvar(39)
ignorehitpause=1
[state 55555,debug]
type=displaytoclipboard
trigger1= 0
trigger1= 1
text= "dist%f dist3%f exist%f alert%f dist%f"
params= fvar(1), fvar(3), fvar(5), fvar(7), fvar(9)
ignorehitpause=1

[State -2, avoiding 1F throw]
type=helper
triggerall= root,var(59)>=1 && root,teamside=1
triggerall= roundstate=2 && !numhelper(66666) && (root,statetype=S || root,statetype=C)
trigger1= enemynear,hitdefattr=SC,AT && (root,ctrl || (root,anim=[0,101]))
trigger1= enemynear,time<=3
;trigger2= root,command="start";test
ID=66666
stateno=66666
postype=left
pos=160,0
name="reflex"


;===========================================<Reflex>==============================================
[Statedef 66666, Reflex]
type=A
movetype=I
physics=N
anim=66666
ctrl=0
velset=0,0;,1

[State 66666, hitby]
type=hitby
trigger1=1
value=C,NP

[State 66666, proj]
type=projectile
trigger1=1
ProjID=6666
projanim=66666
projremove=1
projremovetime=1
projhits=1
postype=p1
offset=0,0
supermove=1
pausemove=1
ignorehitpause=1
attr=C,NP
hitflag=A
guardflag=
getpower=0,0
givepower=0,0
affectteam=F;B,E,F
damage = 0,0
pausetime = 0,0
sparkno=-1
ground.hittime = 0
air.hittime=0
guard.dist=0
air.velocity = 0,0
p1stateno=1200;ifelse(root,fvar(37)<60,1200,150)
p2stateno=66667

[State 66666, safety]
type=destroyself
trigger1= ishelper && time>1
;
[Statedef 66667, Reflex]
type=A
movetype=H
physics=N
anim=9741
ctrl=0

[State 66667, end]
type=destroyself
trigger1=ishelper || ID!=root,ID
