;================================
; CNS File for Buu Z2 by Barker & XGargoyle
; State -2 & State -3 files
;================================
;==========================================================
[Statedef -2]
;==========================================================

;MegaCandy Blast BG Hack
[State -2, SprPriority]
type = SprPriority
triggerall = stateno!=2900 ;!NumExplod(2906)
trigger1 = var(43)>0 ;=2900
value = 2
ignorehitpause = 1
;persistent =

[State -2, RemoveExplod]
type = RemoveExplod
trigger1 = var(43)<=0 ;!=2900
id = 1650
ignorehitpause = 1
;persistent =

[State -2, RemoveExplod]
type = RemoveExplod
trigger1 = var(43)<=0 ;!=2900
id = 1651
ignorehitpause = 1
;persistent =

[state -2, speedlines]
type = explod
triggerall = stateno!=2900 ;!NumExplod(2906)
triggerall = var(43)>0 ;=2900
trigger1 = !NumExplod(1651)
anim = 2923
ID = 1651
postype = back
pos = 0,0
supermovetime = 9999
pausemovetime = 9999
facing = 1
vfacing = 1
bindtime = -1
removetime = -1
scale = 1,1
sprpriority = 1;-10
ownpal = 1
removeongethit = 1
ignorehitpause = 1

[state -2, black BG]
type = explod
triggerall = stateno!=2900 ;!NumExplod(2906)
triggerall = var(43)>0 ;=2900
trigger1 = !NumExplod(1650)
anim = 2906
ID = 1650
postype = back
pos = 0,0 ;-160,-120
supermovetime = 9999
pausemovetime = 9999
facing = 1
vfacing = 1
bindtime = -1
removetime = -1
scale = 1,1
sprpriority = 1;-10
ownpal = 1
removeongethit = 1
ignorehitpause = 1
;End MCB BG hack

;can throw tech in these states
[State 0, Explod]
type = Explod
triggerall = !NumExplod(98000000)
trigger1 = StateNo = [0,20]
trigger2 = StateNo = [120,152]
anim = 15999
ID = 98000000
removetime = -1
removeongethit = 1
[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = StateNo != [0,20]
trigger1 = StateNo != [120,152]
id = 98000000




; FIX Reverse commands
; revised version by JNP and XG
[State -2, Explod]
type = Explod
triggerall = !NumExplod(21)
triggerall = Pos Y >=-50 && Vel Y >0
trigger1 = facing = enemy,facing
trigger2 = P2MoveType = H
trigger2 = P2BodyDist X <0
anim = 9999
removetime = -1
ID = 21

[State -2, Explod]
type = Explod
triggerall = !NumExplod(20)
triggerall = Pos Y >-80 && Vel Y >0
trigger1 = StateType = A
trigger1 = !NumExplod(21)
trigger1 = facing = enemy,facing
trigger2 = NumExplod(21)
trigger2 = facing = enemy,facing
trigger2 = StateType = S
trigger3 = P2MoveType = H
trigger3 = P2BodyDist X <0
trigger4 = StateNo = 52  ;<-- NEW
trigger4 = facing = enemy,facing ;<-- NEW
anim = 9999
removetime = -1
ID = 20

[State -2, Explod]
type = RemoveExplod
triggerall = StateType = S
trigger1 = facing != enemy,facing
trigger2 = MoveType = H
trigger3 = !NumExplod(21) ;<-- CHANGED
trigger4 = Vel X != 0;JNP
ID = 20

[State -2, Explod]
type = RemoveExplod
trigger1 = time = 6
trigger1 = StateType != A
trigger2 = StateNo != 52    ;<-- NEW
trigger2 = facing != enemy,facing  ;<-- NEW
ID = 21

;Head Recall home base
[State 0, Explod]
type = Explod
triggerall = NumHelper(1150)
triggerall = !NumExplod(1160)
trigger1 = facing=1
trigger1 = (Helper(1150),Pos X - (Const(size.head.pos.x)+Pos X))=[-15,15]
trigger1 = (Helper(1150),Pos Y - (Const(size.head.pos.y)+Pos Y+25*(statetype=C || Stateno=52)))=[-15,15]
anim = 1160
ID = 1160
pos = 7*(Helper(1150),facing)+Const(size.head.pos.x),-6+Const(size.head.pos.y)+25*(statetype=C || Stateno=52)
facing = Helper(1150),facing
postype = p1  ;p2,front,back,left,right
bindtime = -1
removetime = -2
sprpriority = 10
removeongethit = 0
;ignorehitpause =
[State 0, Explod]
type = Explod
triggerall = NumHelper(1150)
triggerall = !NumExplod(1160)
trigger1 = facing=-1
trigger1 = (Helper(1150),Pos X - (Const(size.head.pos.x)+Pos X))=[-15,15]
trigger1 = (Helper(1150),Pos Y - (Const(size.head.pos.y)+Pos Y+25*(statetype=C || Stateno=52)))=[-15,15]
anim = 1160
ID = 1160
pos = -7*(Helper(1150),facing)+Const(size.head.pos.x),-6+Const(size.head.pos.y)+25*(statetype=C || Stateno=52)
facing = -(Helper(1150),facing)
postype = p1  ;p2,front,back,left,right
bindtime = -1
removetime = -2
sprpriority = 10
removeongethit = 0
;ignorehitpause =

[State -2, PlaySnd] ;Head merges into Buu
type = PlaySnd
trigger1 = NumExplod(1160)
value = 1150,3
channel = 4
lowpriority = 1

;Special winpose
[State -2, AssertSpecial]
type = AssertSpecial
trigger1 = NumHelper(28800)
flag = invisible
;flag2 = nobardisplay
;flag3 = nomusic

;TEMP EMO CODE

[State 0, VarSet]
type = null;VarSet
trigger1 = 1
var(32)=1
[State 0, VarSet]
type = null;VarSet
trigger1 = 1
var(33)=100

[State -2, EMO SHIELD]
type = helper
triggerall = stateno!=910
triggerall = !NumHelper(916)
triggerall = stateno!=[2500,2501] ;Pain Train
triggerall = stateno!=[1300,1301] ;Focus Attack
triggerall = stateno!=[300,330] ;Puddle Mode
triggerall = movetype!=H
triggerall = roundstate=2 ;do not play in winposes
trigger1 = var(32)>0
trigger1 = var(33)>0 ;var(33)>=23
ID = 916
stateno = 916
pos = 0, 0
postype = p1
helpertype = normal
name = "EMO Shield"
pausemovetime = 999999
supermovetime = 999999
sprpriority = 7
ownpal = 1
keyctrl = 0
ignorehitpause = 1


[State -2, EMO NotHitBy NEW]
type = NotHitBy
triggerall = NumHelper(916)
triggerall = var(33)>0
triggerall = stateno!=[2500,2501] ;Pain Train
triggerall = stateno!=[1300,1301] ;Focus Attack
triggerall = stateno!=[300,330] ;Puddle Mode
triggerall = stateno!=[120,155] ;Guarding
trigger1 = Helper(916),stateno=[916,919]
trigger2 = Helper(916),stateno=920
;trigger2 = Helper(916),time<15   ;test
;trigger2 = Helper(916),GetHitVar(hittime)=-1 && (enemynear,movehit)>=3 ;new test
trigger2 = Helper(916),Var(1)>0 ;&& (enemynear,movehit)>5 ;<=6 ;new test
;trigger3 = Helper(916),stateno=920
;trigger3 = Helper(916),GetHitVar(hitshaketime)=-1 && (enemynear,movehit)=[1,7] ;<7<7
;trigger2 = Helper(916),HitOver = 0 ;HitShakeOver = 0 ;time<10
;trigger2 = Helper(916),HitShakeOver = 1
;trigger2 = Helper(916),GetHitVar(HitShakeTime) = 0
;trigger2 = enemynear,HitPauseTime != 0
value = SCA,NA,SA,HA,NP,SP,HP;,NT,ST,HT
time = 1
ignorehitpause = 1
;persistent =

[State -2, EMO HitBy NEW]
type = HitBy
triggerall = NumHelper(916)
triggerall = var(33)>0
triggerall = stateno!=[2500,2501] ;Pain Train
triggerall = stateno!=[1300,1301] ;Focus Attack
triggerall = stateno!=[120,155] ;Guarding
trigger1 = Helper(916),stateno=[916,919]
trigger2 = Helper(916),stateno=920
trigger2 = Helper(916),Var(1)>0 ;&& (enemynear,movehit)>5 ;<=6 ;new test
value = SCA,NT,ST,HT
;value2 = S,NA
time = 1
ignorehitpause = 1

[State -2, VelAdd] ;Recoil from hit
type = VelAdd
triggerall = stateno!=[2500,2501]
trigger1 = NumHelper(916)
trigger1= Helper(916),gethitvar(hitshaketime)>0
x = facing*(Helper(916),gethitvar(xvel))
ignorehitpause = 1
;persistent =



;-------------------------------------------------------------------------------

;jump link infinite prevention on tall chars--see state 50 in override
[State 0, RemoveExplod] ;Knockdown effect for air basics
type = RemoveExplod
trigger1 = P2MoveType != H
trigger2 = P2StateType = A
trigger3 = StateNo >=1000
id = 52					   

[State -2,Lifeset]
type = null ;lifeset
trigger1 = life >= 100
value = 100
ignorehitpause = 1

[State -2, Kirby LifeAdd]
type = LifeAdd
trigger1 = NumHelper(415) ;Kirby
trigger1 = Helper(415),stateno=416
trigger1 = Helper(415),time=1
trigger2 = NumHelper(1210)  ;Pop Kick
trigger2 = Helper(1210),stateno=1213
trigger2 = Helper(1210),time=1
trigger3 = NumHelper(915)  ;PAIN Shield
trigger3 = Helper(915),stateno=915
trigger3 = movetype!=H ;root is not hit
;trigger3 = Helper(915),time=1
trigger4 = NumHelper(916)  ;EMO Shield
trigger4 = Helper(916),stateno=[916,920]
;trigger4 = movetype!=H ;root is not hit
value = IfElse(NumHelper(415),var(9),-ceil(var(53)/2))
kill = 0
absolute = 0
ignorehitpause = 1
;persistent =

[State -2, AirGuard];Don't airguard if you've dashed or moving forward
type = AssertSpecial
triggerall = var(10) = 1 || vel x >= 0.1
trigger1 = 1
flag = NoAirGuard
IgnoreHitPause = 1

;DeffenceMulSet fix ; Thanks to Jesuszilla
[State -2, DefenseMulSet] ;Not crouching
type = LifeAdd
triggerall = Alive && MoveType = H && Statetype != C
trigger1 = (FVar(8) - life)>0
value = floor((1.0 + fvar(7) - 1.0) * ifElse((FVar(8)-life) < life, -(FVar(8) - life),0))

[State -2, DefenseMulSet] ;Crouching  ;25% more defense
type = LifeAdd
triggerall = Alive && MoveType = H && Statetype = C
trigger1 = (FVar(8) - life)>0
value = floor((0.75 + fvar(7) - 1.0) * ifElse((FVar(8)-life) < life, -(FVar(8) - life),0))

[State -2, Combo]
type = VarSet
trigger1 = 1
fvar(8) = life
ignorehitpause = 1
;DeffenceMulSet fix END

;this resets the var so he will go to state 5170 correctly in all instances
[State -2, System Variable Set]
type = VarSet
trigger1 = StateType = S || Statetype = C
sysvar(0) = 0
ignorehitpause = 1


;===============================================================================
; ------- Damage Dampener --------
;===============================================================================

;----------- NEW CODE
[State -2, Counter Flag]
type = VarSet
trigger1 = NumEnemy
fvar(12) = (EnemyNear, MoveType = A)
ignoreHitPause = 1

;Damage Dampener Variable (by POTS)
[State -2, Hit Count]
type = VarAdd
trigger1 = !IsHelper
trigger1 = MoveHit = 1
trigger1 = !HitPauseTime
trigger1 = !(HitDefAttr = SCA, AT)
fvar(13) = 1

[State -2, Hit Count Reset]
type = VarSet
trigger1 = NumEnemy && fvar(13)
trigger1 = (EnemyNear, MoveType != H) && (EnemyNear, StateNo != 5300)
fvar(13) = 0
ignoreHitPause = 1

[State -2, TEST MIN DAMAGE]
type = null;VarSet
trigger1 = 1
fvar(13) = 50
ignoreHitPause = 1

[State -2, Dampener]
type = VarSet
trigger1 = 1
fvar(10) = ifElse(fvar(13) < 3, 24, ifElse(fvar(13) >= 23, 1, 24 - fvar(13))) / 24.0
ignoreHitPause = 1

[State -2, Dampener Limit]
type = VarSet
trigger1 = fvar(10) < 0
fvar(10) = 0
ignoreHitPause = 1

[State -2, Root Dampener]
type = VarSet
trigger1 = 1
fvar(11) = fvar(10) * ifElse(fvar(12), 1.2, 1) ;1.2
ignoreHitPause = 1


;===============================================================================
; ------- Toilet Winpose Controllers --------
;===============================================================================

[State 0, Toilet Initialize]
type = VarSet
trigger1 = roundstate = 0
trigger1 = Time = 1
var(54) = IfElse(random<=(125*RoundNo),0,69)  ;probability on playing the special winpose increases with rounds

[State 0, Vel X Initialize]
type = VarSet
trigger1 = roundstate = 0
trigger1 = Time = 1
fvar(5) = 0

[State 0, Vel Y Initialize]
type = VarSet
trigger1 = roundstate = 0
trigger1 = Time = 1
fvar(6) = 0

[State -2, Save X]
type = VarSet
triggerall = var(54) = 0
trigger1 = WinKO
fv = 5
value = EnemyNear, Facing * (EnemyNear, GetHitVar(xvel))

[State -2, Save Y]
type = VarSet
triggerall = var(54) = 0
trigger1 = WinKO
fv = 6
value = EnemyNear, GetHitVar(yvel)

;Check KO ;Thanks to Splode for coming up with the original concept
[State -2, Special Projectile]
type = Projectile
triggerall = TeamMode != Simul
triggerall = enemyNear,TeamMode != Simul
triggerall = (enemy,Name != "Saibamen Z2")
trigger1 = var(54) = 0
trigger1 = EnemyNear,stateno!=652 ;CC Sleepy Punch
trigger1 = movecontact
trigger1 = WinKO
ProjID = 3900
projanim = 3900
projremovetime = 1
postype = p2
offset = 0, -30
attr = A, NP
hitflag = MAF
guardflag =
pausetime = 0, 0
sparkno = -1
hitsound = -1
numhits = 0
air.velocity = fvar(5)/2.0, fvar(6)/2.0
p2stateno = EnemyNear, StateNo


[State 0, Toilet Winpose Enabled]
type = VarSet
trigger1 = NumProjID(3900)
var(54) = 1



;===============================================================================
; ------- VarSets --------
;===============================================================================
[State -2, Air Taunt reset]
type=varset
trigger1= statetype!=A
var(4) = 0

[State -2, Super Jump reset var when Vegeta lands]
type=varset
trigger1= statetype!=A
var(22) = 0

[State -2, Air dash reset var when Vegeta lands]
type=varset
trigger1= statetype!=A
var(10) = 0

[State -2, 2OS Helper to detect life removal]
type = helper
trigger1 = !numhelper(2)
helpertype = normal
id = 2
name = "Life removal"
keyctrl = 0
size.xscale = const(size.xscale)
size.yscale = const(size.yscale)
stateno = 2
ignorehitpause = 1
persistent = 1
pausemovetime = 9999999
supermovetime = 9999999

[State -2, 2OS Damage detection]
type = varset
trigger1 = 1
fvar(2) = life - helper(2),var(2)
ignorehitpause = 1
persistent = 1

;Slashing Chop
[State -2, Focus Attack meter reset when no longer charging]
type = VarSet
trigger1 = (stateno !=[1300,1301]) && ((stateno=[5000,5099]) && prevstateno != 1300)
trigger2 = stateno = [100,105]
trigger3 = stateno = 301
fv = 9
value = 0

[State varset];a.HK juggle limiter
type = VarSet
trigger1= numenemy
trigger1= (enemynear,movetype=H) && var(6)>0
var(7) = 1
[State -2, Reset var when the opponent recovers]
type=varset
trigger1= numenemy
trigger1= (enemynear,movetype!=H)
trigger2= !numenemy
var(7)=0

[State -2, OTG]
type= varset
trigger1= numenemy
trigger1= (enemynear,movetype!=H)
trigger2= movecontact=1 && p2statetype!=L
var(6) = 0
ignorehitpause = 1
[State -2, Free Juggling]
type = assertspecial
trigger1 = var(6)=1
flag = nojugglecheck
ignorehitpause = 1

[State -2, Throws Allowed]
type = VarSet
triggerall = numenemy
trigger1 = EnemyNear, MoveType != H
trigger1 = EnemyNear, StateNo != 140
trigger1 = (EnemyNear, ctrl && EnemyNear, Time >= 1) || (EnemyNear, Time >= 8)
trigger2 = EnemyNear, MoveType = A
trigger3 = (EnemyNear, StateNo != [0,52]) && (EnemyNear, StateNo != [120,155]) && (EnemyNear, StateNo != [5000,5120])
trigger4 = var(20) || var(21) || var(22)
var(38) = 0

[State -2, Throws Disallowed]
type = VarSet
triggerAll = NumEnemy
trigger1 = EnemyNear, StateNo = [150,155]
trigger2 = (EnemyNear, StateNo = 51 || EnemyNear, StateNo = 140) && (EnemyNear, PrevStateNo = [150, 155])
trigger3 = EnemyNear, MoveType = H && EnemyNear, StateType != A && !var(20) && !var(21) && !var(22)
trigger4 = (EnemyNear, StateNo = [5020,5040]) && EnemyNear, HitFall = 0
trigger5 = EnemyNear, StateNo = 40 && EnemyNear, PrevStateNo != 52 && (EnemyNear, Anim != [0, 29])
var(38) = 1
ignorehitpause = 1

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


[State -2, s.SK to s.SK limiter]
type=varset
trigger1 = numenemy
trigger1 = (enemynear,movetype!=H)
trigger2 = !numenemy
var(37) = 0

[State -2, OTG]
type= varset
trigger1= movecontact=1 && p2statetype!=L
var(40) = 0
ignorehitpause = 1
[State -2, Free Juggling]
type = assertspecial
trigger1 = var(40)=1
flag = nojugglecheck
ignorehitpause = 1

[state -2, P2 ID Single Mode]
type = varset
trigger1 = numenemy = 1
var(28) = (enemy,ID)
 
[state -2, P2 ID Simul Mode]
type = varset
trigger1 = numenemy > 1
var(28) = (enemy(0),ID)
 
[state -2, P4 ID Simul Mode]
type = varset
trigger1 = numenemy > 1
var(29) = (enemy(1),ID)

;Maniac Ball variable
[State -2, Maniac Ball reset]
type = VarSet
trigger1 = Movetype=H
var(3) = 0

;===============================================================================
; ------- EMO Mode --------
;===============================================================================

[State -2, EMO MODE VARS - Buffer]
type = varset
trigger1 = var(32) < 0
var(32) = 0
ignorehitpause = 1

[State -2, EMO MODE VARS - Timer]
type = varadd
trigger1 = var(34)>0
var(34) = -1
ignorehitpause = 1

[State -2, EMO MODE VARS - Flame]
type = null;varadd
triggerall = var(32)>0 && var(33)>0 && (var(33)<69);var(33)<2100
triggerall = stateno != [4000,4004]		;Not in EMO startup
triggerall = stateno != [4100,4102]             ;Not in Finisher 1
triggerall = stateno != [4200,4212]             ;Not in Finisher 2
triggerall = stateno != [4300,4303]             ;Not in Finisher 3
triggerall = movetype != H	    	        ;Not in HitState
triggerall = stateno != [5000,5110]	        ;Not in HitState
trigger1 = var(34) <= 0  			;Timer empty
var(33) = -1 ;-2
ignorehitpause = 1


[State -2, EMO MODE VARS - Flame]
type = varadd
triggerall = var(32)>0 && var(33)>0 && (var(33)<=69);var(33)<2100
triggerall = stateno != 2900		;Not in EMO Ender (MCB)
triggerall = NumHelper(9996) ;MCB Limiter
triggerall = movetype != H	    	        ;Not in HitState
triggerall = stateno != [5000,5110]	        ;Not in HitState
triggerall = gametime%10=0  ;Trigger every 10 ticks
trigger1 = var(34) <= 0  			;Timer empty
var(33) = -1
ignorehitpause = 1

[State -2, EMO MODE VARS - Zero]
type = varset
trigger1 = var(33)<0
var(33) = 0
ignorehitpause = 1

[State -2, EMO MODE VARS - Flame]
type = varset
trigger1 = (var(33)>69);var(33)>2100
var(33) = 69 ;2100
ignorehitpause = 1


;===============================================================================
; ------- Miscelaneous Stuff --------
;===============================================================================

[State -2, KO snd English]
type = playsnd
;triggerall = (enemy,name="Vegeta Z2" || enemy,name="Normal Vegeta Z2" || enemy,name="Majin Vegeta Z2") && (stateno != 3556) && (stateno != 3860)
trigger1 = !alive && var(8) = 1
trigger1 = var(8) := 2
value = 11, 1 + (stateno = 5950); + (1+random%4)*(stateno = 5950)
ignorehitpause = 1
volumescale = 300


[State -2, KO snd Japan]
type = null;playsnd
;triggerall = (enemy,name="Vegeta Z2" || enemy,name="Normal Vegeta Z2" || enemy,name="Majin Vegeta Z2") && (stateno != 3556) && (stateno != 3860)
triggerall = var(55)=1		;Voice=Japan
trigger1 = !alive && var(8) = 1
trigger1 = var(8) := 2
value = 11, 10 + (stateno = 5950)
ignorehitpause = 1
volumescale = 300

[State -2, KO snd Sabbat]
type = null;playsnd
;triggerall = (enemy,name="Vegeta Z2" || enemy,name="Normal Vegeta Z2" || enemy,name="Majin Vegeta Z2") && (stateno != 3556) && (stateno != 3860)
triggerall = var(55)=2		;Voice=Eng Sabbat
trigger1 = !alive && var(8) = 1
trigger1 = var(8) := 2
value = 11, 20 + (stateno = 5950)
ignorehitpause = 1
volumescale = 300

[State -2, ctrlset]
type = CtrlSet
trigger1 = roundstate=0 || roundstate=1
value = 0

[State 1001, stop power charging sound]
type = stopsnd
trigger1 = stateno != 900
channel = 3
persistent = 0

[State 1001, stop taunt sound]
type = stopsnd
trigger1 = (prevstateno = 195) && (movetype = H)
channel = 4
persistent = 0

[State -2, Explod];State 5052 Twist FX
type = playsnd
trigger1 = anim=5052 && !(gametime%10) && animelemtime(4)>=0
value = 5052,0

[State -2, Explod];State 5052 Twist FX
type = Explod
triggerall = NumExplod(20152) = 0
trigger1 = anim=5052 && animelemtime(4)=0
anim = 20152
pos = 0,-50
postype = P1
removetime = -1
;supermovetime = 99999
sprpriority = 3
id = 20152
bindtime = -1
ownpal = 1
ignorehitpause = 1
pausemovetime = -1

[state 17100, Flip KO FX]
type=explod
triggerall = !IsHelper
trigger1 = Anim=5937 && !numexplod(59370) && animelemtime(3)=0
anim = 5938
id = 5938
pos = 0,-50
postype = P1
sprpriority = 3
ownpal = 1
;supermovetime = -1
removetime = -1
persistent = 0
bindtime = -1
ignorehitpause = 1

[State 810, 2] ;P2 Hit Ground Spark (front)
type = Explod
triggerall = numenemy
trigger1 = enemy,StateNo=652 && !NumExplod(8400)
trigger1 = enemy,time=1
trigger2 = enemy,StateNo=4122 && !NumExplod(8400)
trigger2 = enemy,time=1
persistent = 0
ID = 8400
anim = 8400
postype = p2
pos = -4, -3
velocity = 0, 0
accel = 0, 0
removetime = -2
sprpriority = 3
ignorehitpause = 1
[State 810, 3] ;P2 Hit Ground Spark (back)
type = Explod
triggerall = numenemy
trigger1 = enemy,StateNo=652 && !NumExplod(8401)
trigger1 = enemy,time=1
trigger2 = enemy,StateNo=4122 && !NumExplod(8400)
trigger2 = enemy,time=1
persistent = 0
ID = 8401
anim = 8401
postype = p2
pos = -4, -3
velocity = 0, 0
accel = 0, 0
removetime = -2
sprpriority = -3
ignorehitpause = 1

[State -2, Hitting wall/ground sound effect]
type = PlaySnd
triggerall = Numenemy
triggerall = enemy, Time = 1
trigger1 = enemy, StateNo = 4122
trigger2 = enemy, StateNo = 652   ;custom state: a.SP
value = 15000, 2
channel	= 23

[state 17100, Shocked FX]
type=explod
trigger1 = (Anim=7696 || anim=9010) && !numexplod(9011)
anim = 9011
id = 9011
pos = 0,0
postype = P1
sprpriority = -5
ownpal = 1
removetime = -1
persistent = 0
bindtime = -1
ignorehitpause = 1

[state 17100, Shocked FX]
type = removeexplod
trigger1 = (Anim != 7696 && anim != 9010) && numexplod(9011)
ID = 9011

[State 3000, smoke]
type = helper
triggerall = playeridexist(var(28))
trigger1 = !numhelper(5945) && playerid(var(28)),stateno=5944
helpertype = normal
stateno = 5945
ID = 5945
name = "FF dead smoke"
postype = p1
pos = 0,0
ownpal = 1

[State 3000, smoke]
type = helper
triggerall = playeridexist(var(29))
trigger1 = !numhelper(59450) && playerid(var(29)),stateno=5944
helpertype = normal
stateno = 5945
ID = 59450
name = "FF dead smoke"
postype = p1
pos = 0,0
ownpal = 1

; Rage GG Aura FX Position Fix
[State 1000]
type = modifyexplod
trigger1 = numexplod(2776)
ID = 2776
pos = 0,0
postype = p1

;-----------------------------------
; Rage GG Finishers Fatality - WTF

[State 10000, Explod]; White BG
type = Explod
triggerall = numenemy
triggerall = WinKO && MatchOver
trigger1 = enemy,stateno=5943 && NumExplod(5943)=0
trigger2 = enemy,stateno=2875 && NumExplod(5943)=0   ;Final Galick Ho
anim = 2763
id = 5943
pos =  160,120
postype = left
sprpriority = 6
bindtime = -1
ownpal = 1
removetime = -2
pausemovetime = 999999
supermovetime = 999999
supermove = 1
scale = 1.50,1.50
ignorehitpause = 1
persistent = 0

[State 10000, Explod]; White BG front holes
type = Explod
triggerall = numenemy
triggerall = WinKO && MatchOver
trigger1 = enemy,stateno=5943 && NumExplod(5944)=0
anim = 5944
id = 5944
postype = p2
pos =  0, ceil(((enemy,const(size.head.pos.Y))+(enemy,const(size.mid.pos.Y)))/2)
sprpriority = 8
bindtime = -1
ownpal = 1
removetime = -2
pausemovetime = 999999
supermovetime = 999999
supermove = 1
scale = 1,1
ignorehitpause = 1
persistent = 0
facing = -1

[State 10000, Explod]; White BG front holes tall chars
type = Explod
triggerall = numenemy
triggerall = WinKO && MatchOver
trigger1 = enemy,stateno=5943 && NumExplod(59440)=0
anim = 5944
id = 59440
postype = p2
pos =  0, ceil(((enemy,const(size.head.pos.Y))+(enemy,const(size.mid.pos.Y)))/2)-170
sprpriority = 8
bindtime = -1
ownpal = 1
removetime = -2
pausemovetime = 999999
supermovetime = 999999
supermove = 1
scale = 1,1
ignorehitpause = 1
persistent = 0
facing = -1

[State 10000, Explod]; White BG front holes VERY tall chars
type = Explod
triggerall = WinKO && MatchOver
triggerall = numenemy
trigger1 = enemy,stateno=5943 && NumExplod(59441)=0
anim = 5944
id = 59441
postype = p2
pos =  0, ceil(((enemy,const(size.head.pos.Y))+(enemy,const(size.mid.pos.Y)))/2)+170
sprpriority = 8
bindtime = -1
ownpal = 1
removetime = -2
pausemovetime = 999999
supermovetime = 999999
supermove = 1
scale = 1,1
ignorehitpause = 1
persistent = 0
facing = -1

; White BG front holes - VERTICAL (FINAL GALICK HO)
[State -2, Explod Helper]
type = helper
triggerall = numenemy
trigger1 = enemy,stateno=2875 && NumHelper(2876)=0
trigger1 = stateno=2869
ID = 2876
postype = p2
pos =  0, 0 ;ceil(((enemy,const(size.head.pos.Y))+(enemy,const(size.mid.pos.Y)))/2)
stateno = 2876
helpertype = normal
name = "white_fg"
pausemovetime = 999999
supermovetime = 999999
sprpriority = 8
ownpal = 1
keyctrl = 0
ignorehitpause = 1
persistent = 0
facing = 1

; White BG front holes - VERTICAL (FINAL GALICK HO)
[State -2, Explod Helper]
type = helper
triggerall = numenemy
trigger1 = enemy,stateno=2875 && NumHelper(2877)=0
trigger1 = stateno=2869
ID = 2877
postype = p2
pos =  120, 0;ceil(((enemy,const(size.head.pos.Y))+(enemy,const(size.mid.pos.Y)))/2)
stateno = 2876
helpertype = normal
name = "white_fg"
pausemovetime = 999999
supermovetime = 999999
sprpriority = 8
ownpal = 1
keyctrl = 0
ignorehitpause = 1
persistent = 0
facing = 1

; White BG front holes - VERTICAL (FINAL GALICK HO)
[State -2, Explod Helper]
type = helper
triggerall = numenemy
trigger1 = enemy,stateno=2875 && NumHelper(2878)=0
trigger1 = stateno=2869
ID = 2878
postype = p2
pos =  -120, 0;ceil(((enemy,const(size.head.pos.Y))+(enemy,const(size.mid.pos.Y)))/2)
stateno = 2876
helpertype = normal
name = "white_fg"
pausemovetime = 999999
supermovetime = 999999
sprpriority = 8
ownpal = 1
keyctrl = 0
ignorehitpause = 1
persistent = 0
facing = 1

[State 3000, debris]
type = helper
triggerall = numenemy
trigger1 = enemy,stateno=2847 && NumHelper(2848)=0
helpertype = normal
stateno = 2848
ID = 2848
name = "debris"
postype = p2
pos = 0,0
ownpal = 1


;===============================================================================
; ------- Compatibility with V.Akiha by Kohaku --------
;===============================================================================

[State -2, LifeAdd]
type = LifeAdd
triggerall = NumEnemy
triggerall = Enemy,AuthorName = "Kohaku" && Enemy,Name = "VAkiha_K"
trigger1 = Enemy,Var(30) = 1
value = -5
kill = 0

[State -2, PowerAdd]
type = PowerAdd
triggerall = NumEnemy
triggerall = Enemy,AuthorName = "Kohaku" && Enemy,Name = "VAkiha_K"
trigger1 = Enemy,Var(30) = 1
value = -26

;===============================================================================
; ------- Compatibility with Warachia by Rajaaboy --------
;===============================================================================

[state -2,RajaaBoy:_Warachia]
type = lifeadd
trigger1 = numenemy
trigger1 = enemy,authorname="RajaaBoy"
trigger1 = enemy,name="RajaaWarachia"
trigger1 = enemy,var(32)=1||enemy,var(33)=1||enemy,var(34)=1
value = (-14*enemy,var(32))+(-21*enemy,var(33))+(-28*enemy,var(34))
kill = 0
ignorehitpause = 1

[state -2,RajaaBoy:_Warachia]
type = poweradd
trigger1 = numenemy
trigger1 = enemy,authorname="RajaaBoy"
trigger1 = enemy,name="RajaaWarachia"
trigger1 = enemy,var(32)=1||enemy,var(33)=1||enemy,var(34)=1
value = 10
ignorehitpause = 1

;===============================================================================
; ------- Super Background Helper Triggers --------
;===============================================================================

; SUPER BG HELPER
[State -2, Hyper Kill bg]
type = helper
triggerall = winKO && !NumHelper(19875)
triggerall = var(13) < 2
trigger1 = NumHelper(2010)								;Heavy Rain Lv1
trigger1 = helper(2010),movecontact
trigger2 = NumHelper(2011)								;Heavy Rain Lv1
trigger2 = helper(2011),movecontact
trigger3 = NumHelper(2150)								;Vice Shot Lv1
trigger3 = helper(2150),movecontact
;trigger4 = NumHelper(2311)								;Gackt Lv1
trigger4 = NumProjID(3410)>0
;trigger4 = helper(2311),movecontact
trigger5 = NumHelper(2450)								;Vice Shot Lv2
trigger6 = helper(2450),movecontact
trigger7 = stateno = [2500,2501]                       ; Pain Train Lv1
trigger8 = stateno = 2600                             ; Madman's Ball Lv1
trigger9 = stateno = 2801                              ; Flesh Prison Lv2
ID = 19875
pos = 20-20*(var(13)=0),-250+250*(var(13)=0)
postype = left
stateno = 19875 + 25*var(13)
helpertype = normal
name = "superbackground"
pausemovetime = 999999
supermovetime = 999999
sprpriority = -5
ownpal = 1
keyctrl = 0
ignorehitpause = 1

; SUPER BG HELPER - Super DBZ Physic
[State -2, Hyper Kill bg]
type = helper
triggerall = winKO && !NumHelper(19875)
triggerall = var(13) = 2
trigger1 = stateno = [2500,2501]                       ; Pain Train Lv1
trigger2 = stateno = 2600                             ; Madman's Ball Lv1
trigger3 = stateno = 2801                              ; Flesh Prison Lv2
ID = 19875
pos = 0,0
postype = left
stateno = 19885
helpertype = normal
name = "superbackground"
pausemovetime = 999999
supermovetime = 999999
sprpriority = -5
ownpal = 1
keyctrl = 0
ignorehitpause = 1
persistent = 0

; SUPER BG HELPER - Super DBZ Ki
[State -2, Hyper Kill bg]
type = helper
triggerall = winKO && !NumHelper(19875)
triggerall = var(13) = 2
trigger1 = NumHelper(2010)								;Heavy Rain Lv1
trigger1 = helper(2010),movecontact
trigger2 = NumHelper(2011)								;Heavy Rain Lv1
trigger2 = helper(2011),movecontact
trigger3 = NumHelper(2150)								;Ground Vice Shot Lv1
trigger3 = helper(2150),movecontact
;trigger4 = NumHelper(2311)								;Gackt Lv1
trigger4 = NumProjID(3410)>0
;trigger4 = helper(2311),movecontact
trigger5 = NumHelper(2450)								;Vice Shot Lv2
trigger5 = helper(2450),movecontact
ID = 19875
pos =  0,0
postype = left
stateno = 19892
helpertype = normal
name = "superbackground"
pausemovetime = 999999
supermovetime = 999999
sprpriority = -5
ownpal = 1
keyctrl = 0
ignorehitpause = 1
persistent = 0

;===============================================================================
; ------- Display To Clipboard --------
;===============================================================================

[State -2, DisplayToClipboard]
type = DisplayToClipboard
trigger1 = (authorname="Team Z2")
text = "PrevState=%d, P2X=%d, Life=%d, v33=%d, Anim=%d, Elem=%d\n"
params = PrevStateno, p2bodydist x, life, var(33), (2751+floor(var(33)/24.0)), (1+(var(33)%24)) ;(0+(var(33)=[700,1399])+2*(var(33)=[1400,2099])+3*(var(33)>=2100)) ;(Helper(19730),rootdist X) ;19725 ;1000-P2Life ;var(34) ;helper(3331),vel X ;var(4) ;IfElse(WinKO=1,1,0) ; random*(var(53)/4.0)
ignorehitpause = 1

[State -2, Debug]
type = appendtoclipboard
trigger1 = (authorname="Team Z2")
text = "by Barker & XGargoyle - http://network.mugenguild.com/balthazar/"
ignorehitpause = 1

[State -2, VS Thieves]
type = DisplayToClipboard
trigger1 = (authorname="Team Z2") = 0
text = "This character was created by Barker & XGargoyle. Don't even try to deny\it thief! Original version available at http://network.mugenguild.com/balthazar/\n"
ignorehitpause = 1


;=======================================================================
; External coding for Hyper Pause Fixes (Fighting SyN'S Characters only)
;=======================================================================
[State -2, Camera focus on player for Hyper Pause]
type = ScreenBound
triggerall = NumEnemy
triggerall = enemynear,authorname = "ImmortaL -SyN-"
trigger1 = enemynear,numhelper(4999)
value = 1

;[State -2] ;DEAD CAMERA IGNORE
;type = ScreenBound
;trigger1 = (life <= 0) && (roundstate >= 3)
;value = 0
;movecamera = 0,0
;ignorehitpause = 1

;===============================================================================
; ------- EMO Mode Gauge --------
;===============================================================================

; EMO MODE GAUGE P1
[State -2, Sanity Gauge]
type = helper
triggerall = !NumHelper(2750) && teamside = 1
trigger1 = var(32) > 0
ID = 2750
stateno = 2750
pos = 20, 0
postype = left
helpertype = normal
name = "EMO"
pausemovetime = 999999
supermovetime = 999999
sprpriority = 7
ownpal = 1
keyctrl = 0
ignorehitpause = 1
;size.xscale = 0.5
;size.yscale = 0.5

; EMO MODE GAUGE P2
[State -2, Sanity Gauge]
type = helper
triggerall = !NumHelper(2760) && teamside = 2
trigger1 = var(32) > 0
ID = 2760
stateno = 2760
pos = 20, 0
postype = left
helpertype = normal
name = "EMO"
pausemovetime = 999999
supermovetime = 999999
sprpriority = 7
ownpal = 1
keyctrl = 0
ignorehitpause = 1
size.xscale = 0.5
size.yscale = 0.5


;===============================================================================
; ------- Remove various explods --------
;===============================================================================

[state -2, remove Flip KO FX]
type = removeexplod
trigger1 = anim!=5937
id = 5938
[state -2, remove Twist KO FX]
type = removeexplod
trigger1 = anim!=5052
id = 20152

[state -2, remove charge dust]
type = removeexplod
trigger1 = stateno != 900
trigger1 = stateno != 901
trigger1 = stateno != [2000,2002]
trigger1 = stateno != [2300,2301]
id = 908

[State 0, RemoveExplod] ;Vice Shot
type = RemoveExplod
trigger1 = !NumHelper(2150) ; No Vice shot
id = 2150


;===============================================================================
; COUNTER HIT (Taken from Vans, who based his on Sander's Method)
;===============================================================================

[State -2, VarSet];Checks if opponent is in attack state
type = VarSet
triggerall = numenemy
trigger1 = enemy, movetype = A
var(56) = 1
ignorehitpause = 1

[State -2, VarSet];This resets the condition if counter not succesful and succesful
type = VarSet
triggerall = numenemy
trigger1 = enemy, movetype = I || var(57) >= 1  ;Enemy is Idle | Counter was Succesful
trigger2 = var(57) > 10 && enemy, movetype = H  ;10 ticks passed & enemy is on gethit state
var(56) = 0
ignorehitpause = 1

[State -2, VarSet];Counter Hit Succesful
type = VarSet
trigger1 = var(56) = 1 && movehit ;Counter Check Ok, Move Hit Succesfully.
trigger1 = stateno != [701,709] ;Does not activate during intros.
trigger1 = stateno != [800,820] ;Does not activate during throws.
trigger1 = stateno != [950,951] ;Don't activate during throws.
trigger2 = var(56) = 1 && projhit = 1  ;Counter Check Ok, Projectile Hit Succesfully.
var(57) = 1
ignorehitpause = 1

[State -2, VarAdd];Counter Hit Timer
type = VarAdd
trigger1 = var(57) >= 1 ;Counter was succesful
var(57) = 1
ignorehitpause = 1

[State -2, VarSet];Counter Hit Reset
type = VarSet
trigger1 = var(57) >= 22 && movehit ;Reset if 22 ticks passed and move hit
trigger2 = p2movetype != H ;Reset if P2 is no longer in gethit state
trigger3 = movetype = H ;Reset if P1 is getting hit
trigger4 = var(57) >= 22 && projhit = 1 ;Reset if 22 ticks passed and projectile hit
var(57) = 0
ignorehitpause = 1

[State -2, AssertSpecial];This will award free juggles for Counter Hit.
type = AssertSpecial
trigger1 = var(57) > 0
flag = nojugglecheck

[State -2, EnvColor];This will produce a flash a la KOF2K2
type = EnvColor
triggerall = numenemy
triggerall = stateno != [701,709] ;Does not activate during intros.
triggerall = stateno != [800,820] ;Does not activate during throws.
triggerall = stateno != [950,951] ;Don't activate during throws.
triggerall = enemy, movetype = h ;Enemy was indeed HIT, otherwise this'd be retarded.
trigger1 = var(56) = 1 && movehit  ;Move hit, Ok
trigger2 = var(56) = 1 && projhit = 1 ;Projectile hit, Ok
value = 255,255,255
time = 1
under = 1
ignorehitpause = 1
persistent = 0

[State -2, Explod];Counter Explod for P1 Side.
type = Explod
triggerall = numenemy
triggerall = var(56) = 1 && numexplod(13000) = 0 && teamside = 1 ;Counter Ok, Explod has not played, P1 Side
triggerall = enemy, movetype = h ;Enemy was indeed HIT, otherwise this'd be retarded.
triggerall = stateno != [800,820] ;Does not activate during throws.
triggerall = stateno != [950,951] ;Don't activate during throws.
trigger1 = movehit ;Move hits
trigger2 = projhit = 1 ;Projectile Hits
anim = 13000
pos = 10,100
postype = left  ;p2,front,back,left,right
removetime = -2
supermove = 1
;scale = 0.5,0.5
sprpriority = 0
id = 13000
bindtime = -1
ontop = 1
ownpal = 1
ignorehitpause = 1
pausemovetime = -1

[State -2, Explod];Counter Explod for P2 Side.
type = Explod
triggerall = numenemy
triggerall = var(56) = 1 && numexplod(13000) = 0 && teamside = 2 ;Counter Ok, Explod has not played, P2 Side
triggerall = enemy, movetype = h ;Enemy was indeed HIT, otherwise this'd be retarded.
triggerall = stateno != [800,820] ;Does not activate during throws.
triggerall = stateno != [950,951] ;Don't activate during throws.
trigger1 = movehit ;Move hits
trigger2 = projhit = 1 ;Projectile Hits
anim = 13001
pos = -82,100 ;-1,100
postype = right ;left  ;p2,front,back,left,right
removetime = -2
supermove = 1
;scale = 0.5,0.5
sprpriority = 0
id = 13000
bindtime = -1
ontop = 1
ownpal = 1
ignorehitpause = 1
pausemovetime = -1

;===============================================================================
; FIRST ATTACK NOTIFICATION
;===============================================================================

[State -2, First Attack]
type = VarSet
triggerall = Var(27) = 0
triggerall = RoundState = 2
trigger1 = p2stateno = [5000,5199]
v = 27
value = 1
ignorehitpause = 1

[State -2, Explod];P1 Side.
type = Explod
trigger1 = var(27)= 1 && numexplod(13100)=0 && teamside = 1
anim = 13100
pos = 10,ifelse(numexplod(13000),80,100)
postype = left  ;p2,front,back,left,right
removetime = -2
supermove = 1
;scale = 0.5,0.5
sprpriority = 0
id = 13100
bindtime = -1
ontop = 1
ownpal = 1
ignorehitpause = 1
pausemovetime = -1
persistent = 0

[State -2, Explod];P2 Side.
type = Explod
trigger1 = var(27)= 1 && numexplod(13100)=0 && teamside = 2
anim = 13101
pos = -117,ifelse(numexplod(13000),80,100);-48,ifelse(numexplod(13000),80,100)
postype = right ;left  ;p2,front,back,left,right
removetime = -2
supermove = 1
;scale = 0.5,0.5
sprpriority = 0
id = 13100
bindtime = -1
ontop = 1
ownpal = 1
ignorehitpause = 1
pausemovetime = -1
persistent = 0

[State -2, Powaa !!!]
type = PowerAdd
trigger1 = Var(27) = 1
value = 200
persistent = 0

[State -2, First Attack]
type = VarSet
trigger1 = Var(27) = 1
trigger2 = movetype = H && Var(27) = 0 && stateno != [150,159]
v = 27
value = 2


; ------- Custom State Check --------
[State -2, VarAdd] ;this increases every tick even while in custom state
type = VarAdd
trigger1 = 1
var(58) = 1

;==========================================================
[Statedef -3]
;==========================================================

[State -3, VarSet] ;custom state check reset
type = VarSet
trigger1 =  var(58)-var(59)!=0
var(59) = var(58)
ignorehitpause = 1
;persistent =

[State -3, VarSet] ;this won't increase during custom states
type = VarAdd
trigger1 = 1
var(59) = 1
;------------------------------------------

[State -3, Wrong StateType] ;DEBUG
type= null;superpause
triggerall = roundstate=2
trigger1= pos y!=0 && statetype!=A && statetype!=L
time= 99999
ignorehitpause= 1

;AI EX Chaos Burst
[State -3, AI EX Chaos Burst]
type = ChangeState
triggerall = AILevel>0 && numenemy && roundstate=2 && StateType != A && StateType != L
triggerall =(p2bodydist x=[-30,80]) && P2Movetype=A
triggerall = (power >= 1000 && !NumHelper(9996))
triggerall = ctrl=0 && stateno!=1750
triggerall = var(32)=0 ;No EMO mode
triggerall = !NumHelper(9993) ;AI CB Limiter
triggerall = gethitvar(hitcount)>=4
triggerall = random<(50*gethitvar(hitcount)*((AILevel)**2/64.0))
trigger1 = movetype=H && stateno!=[120,155]
trigger2 = stateno=[5000,5999]
value = 1750
ignorehitpause= 1


[State -3, Super Jump AI get closer to you]
type = veladd
x = 0.2
triggerall = AILevel>0 && numenemy && statetype = A && roundstate = 2 && enemy,vel y < -1
triggerall = (p2bodydist y = [-320,-30]) && enemynear,Statetype=A 
trigger1 = (prevstateno=[10230,10232])

;This 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 && prevstateno != 107 ;back dash land and no flik flak
trigger3 = stateno=0 && prevstateno=5120
trigger4 = stateno = 5201
value = 40, 0

[state 52, Land FX]
type = helper
triggerall = Time = 1
trigger1 = stateno = 52
trigger2 = stateno = 106 && prevstateno != 107
trigger3 = stateno = 5201
name = "LandFX"
helpertype = normal
stateno = 17100
id = 17100
postype = P1
ownpal = 1
keyctrl = 0
supermovetime = 99999
pausemovetime = 99999

[State 0, ]
type = Helper
triggerall = !numhelper(52100)
trigger1 = stateno = 5201
helpertype = normal
name = "recoverpulser"
ID = 52100
stateno = 52100
ownpal = 1
supermovetime = 99999
pausemovetime = 99999
;--------------------------------------

[State -3, GetHitSnd Light]
type = playsnd
triggerall = alive && (time = 1)
triggerall = stateno=5000||stateno=5010||stateno=5020||stateno=5070||stateno=5080
trigger1 = numenemy > 0
trigger1 = enemynear,hitdefattr = SCA,SA,HA
trigger2 = gethitvar(animtype)=0 && random<250
value = s5000,random%5
channel = 0
ignorehitpause = 1
persistent = 0
volumescale = 200

[State -3, GetHitSnd Medium]
type = playsnd
triggerall = alive && (time = 1)
triggerall = stateno=5000||stateno=5010||stateno=5020||stateno=5070||stateno=5080
trigger1 = numenemy > 0
trigger1 = enemynear,hitdefattr = SCA,SA,HA
trigger2 = gethitvar(animtype)=1 && random<375
value = s5000,10+random%5
channel = 0
ignorehitpause = 1
persistent = 0
volumescale = 200

[State -3, GetHitSnd Hard]
type = playsnd
triggerall = alive && (time = 1)
triggerall = stateno=5000||stateno=5010||stateno=5020||stateno=5070||stateno=5080
trigger1 = numenemy > 0
trigger1 = enemynear,hitdefattr = SCA,SA,HA
trigger2 = gethitvar(animtype)>=2 && random<500
value = s5000,20+random%5
channel = 0
ignorehitpause = 1
persistent = 0
volumescale = 200
;--------------------------------------
[State -3, GetHitSnd Light]
type = null;playsnd
triggerall = var(55)=1		;Voice=Japan
triggerall = alive && (time = 1)
triggerall = stateno=5000||stateno=5010||stateno=5020||stateno=5070||stateno=5080
trigger1 = numenemy > 0
trigger1 = enemynear,hitdefattr = SCA,SA,HA
trigger2 = gethitvar(animtype)=0 && random<250
value = s5001,random%6
channel = 0
ignorehitpause = 1
persistent = 0
volumescale = 200

[State -3, GetHitSnd Medium]
type = null;playsnd
triggerall = var(55)=1		;Voice=Japan
triggerall = alive && (time = 1)
triggerall = stateno=5000||stateno=5010||stateno=5020||stateno=5070||stateno=5080
trigger1 = numenemy > 0
trigger1 = enemynear,hitdefattr = SCA,SA,HA
trigger2 = gethitvar(animtype)=1 && random<375
value = s5001,10+random%3
channel = 0
ignorehitpause = 1
persistent = 0
volumescale = 200

[State -3, GetHitSnd Hard]
type = null;playsnd
triggerall = var(55)=1		;Voice=Japan
triggerall = alive && (time = 1)
triggerall = stateno=5000||stateno=5010||stateno=5020||stateno=5070||stateno=5080
trigger1 = numenemy > 0
trigger1 = enemynear,hitdefattr = SCA,SA,HA
trigger2 = gethitvar(animtype)>=2 && random<500
value = s5001,20+random%7
channel = 0
ignorehitpause = 1
persistent = 0
volumescale = 200
;--------------------------------------
[State -3, GetHitSnd Light]
type = null;playsnd
triggerall = var(55)=2		;Voice=Eng Sabbat
triggerall = alive && (time = 1)
triggerall = stateno=5000||stateno=5010||stateno=5020||stateno=5070||stateno=5080
trigger1 = numenemy > 0
trigger1 = enemynear,hitdefattr = SCA,SA,HA
trigger2 = gethitvar(animtype)=0 && random<250
value = s5002,random%6
channel = 0
ignorehitpause = 1
persistent = 0
volumescale = 200

[State -3, GetHitSnd Medium]
type = null;playsnd
triggerall = var(55)=2		;Voice=Eng Sabbat
triggerall = alive && (time = 1)
triggerall = stateno=5000||stateno=5010||stateno=5020||stateno=5070||stateno=5080
trigger1 = numenemy > 0
trigger1 = enemynear,hitdefattr = SCA,SA,HA
trigger2 = gethitvar(animtype)=1 && random<375
value = s5002,10+random%5
channel = 0
ignorehitpause = 1
persistent = 0
volumescale = 200

[State -3, GetHitSnd Hard]
type = null;playsnd
triggerall = var(55)=2		;Voice=Eng Sabbat
triggerall = alive && (time = 1)
triggerall = stateno=5000||stateno=5010||stateno=5020||stateno=5070||stateno=5080
trigger1 = numenemy > 0
trigger1 = enemynear,hitdefattr = SCA,SA,HA
trigger2 = gethitvar(animtype)>=2 && random<500
value = s5002,20+random%7
channel = 0
ignorehitpause = 1
persistent = 0
volumescale = 200

;--------------------------------------

[state -3, remove afterimage]
type = afterimagetime
trigger1 = Movetype = H
trigger2 = stateno != [10230,10233]  ;Super Jump
trigger2 = stateno != [110,115]  ;air dash
trigger2 = stateno != 50
trigger2 = stateno != [1450,1470]			;EX Maniac Ball
trigger2 = stateno != 2600			;Madman's Ball
;trigger2 = stateno != [1550,1551]	;EX Rising Knee
;trigger2 = stateno != 1730			;EX Aerial Machine Gun Temper
;trigger2 = stateno != [3120,3122]               ;EX Elbow Surprise
;trigger2 = stateno != [3650,3658]               ;EX Double Slash Kick
;trigger2 = stateno != [3050,3051]               ;EX Majin Bakuhatsuha
;trigger2 = stateno != 3557                      ;Royal Edict Jump Backwards
time = 0

[State -3, Prevent Crossup]
type = width
triggerall = numenemy
trigger1 = movetype != H
trigger1 = facing != enemynear, facing
edge = 4, 0
ignorehitpause = 1

[State -3, No walk during turning animation]
type = VelSet
trigger1 = anim=5
x = 0

[State -3, stopsnd if skip intro]
type = stopsnd
trigger1 = stateno=0
trigger1 = prevstateno=[701,730]
channel = 8

[State -3, stopsnd if skip intro]
type = stopsnd
triggerall = stateno=0
trigger1 = prevstateno=[701,730]
channel = 9

[State -3, StopSnd] ;Pain Train Walk
type = StopSnd
trigger1 = movetype=H ;stateno=5000
channel = 1
ignorehitpause = 1
[State -3, StopSnd] ;Pain Train Walk
type = StopSnd
trigger1 = movetype=H ;stateno=5000
channel = 2
ignorehitpause = 1
[State -3, StopSnd] ;Pain Train Walk
type = StopSnd
trigger1 =movetype=H ; stateno=5000
channel = 3
ignorehitpause = 1
[State 0, StopSnd] ;Pain Train Slide land
type = StopSnd
trigger1 = movetype=H ;stateno=5000
channel = 5
ignorehitpause = 1
[State 0, RemoveExplod] ;Pain Train Slide dust
type = RemoveExplod
trigger1 = movetype=H ;stateno=5000
id = 2512
ignorehitpause = 1


;===============================================================================
; Slashing Chop / Saving Strike code (Part B)
;===============================================================================
[state -3, animelem set frame 1]
type = varset
trigger1 = stateno = 1300 && time = 1
var(23) = 1
 
[state -3, animelem set frame 2]
type = varset
trigger1 = stateno = 1300 && animelem = 2
var(23) = 2

[state -3, animelem set frame 3]
type = varset
trigger1 = stateno = 1300 && animelem = 3
var(23) = 3
 
[State -3, Change to second state]
type = HitOverride
trigger1 = stateno = 1300
attr = SCA,NA,SA,HA,NP,SP,HP
slot = 0
stateno = 1301
time = 1
forceair = 0
ignorehitpause = 1
persistent = 1
 
[state -3, varset for first state]
type = varset
trigger1 = stateno = 1300
var(20) = 1
 
[state -3, varset for second state]
type = varset
trigger1 = stateno = 1301
var(20) = 0

[State -3, health removal in second state]
type = LifeAdd
trigger1 = stateno = 1301
value = -(gethitvar(damage))
kill = 1



;================================================================================
; ------- Cheap K.O. system By Warusaki3 & POTS --------
;===============================================================================
;[State -2, 3]
;type = ChangeState
;trigger1 = !Alive
;trigger1 = PrevStateNo = 130 || PrevStateNo = 131 || PrevStateNo = [150,153]
;trigger1 = Stateno = [5000,5050]
;value = 5950

[State -3, Cheap KO]
type = changestate
trigger1 = !alive && (stateno = [5000, 5010])
trigger1 = (prevstateno = [130, 131]) || (prevstateno = [140, 141]) || (prevstateno = [150, 153])
value = 5950
ignorehitpause = 1

[State -2,KO]
type = Varset
triggerall = StateNo = [120,159]
trigger1 = StateType = S
ignorehitpause = 1
fvar(1) = 0

[State -2,KO]
type = Varset
triggerall = StateNo = [120,159]
trigger1 = StateType = C
ignorehitpause = 1
fvar(1) = 1

[State -2,KO]
type = Varset
triggerall = StateNo = [120,159]
trigger1 = StateType = A
ignorehitpause = 1
fvar(1) = 2


