;================================
; CNS File for Babidi Z2 by Balthazar, Daeron & XGargoyle
; State -2 & State -3 files
;================================
;==========================================================
[Statedef -2]
;==========================================================

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

[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

;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


;===============================================================================
; ------- Floating Babidi --------
;===============================================================================

[State -2, AngleDraw]
type = null ;AngleDraw
trigger1 = movetype!=H ;1
value = -3*(vel x)
;scale =
;ignorehitpause =
;persistent =

[State -2, VelAdd]  ;prevent sinking
type = PosAdd
triggerall = Roundstate = 2
triggerall = Pos Y >= (var(52)+20) ;-25
trigger1 = stateno=[10,20]
;trigger2 = stateno=[52,53]
y = -1

[State -2, PosAdd] ;floating
type = PosAdd
triggerall = Roundstate = 2
triggerall = stateno!=[52,53]  ;landing
triggerall = stateno!=[800,811] ; throw
triggerall = stateno!=[950,952] ; dash collision
triggerall = statetype!=A ;Air moves
trigger1 = Pos Y < 0 ;1
;x = 0
y = 0.5*sin(gametime/10)

[State -2, crouching dust]
type=explod
trigger1= statetype=C
trigger1= !NumExplod(15)
anim=15
ID = 15
sprpriority=-7
postype=left
pos= floor(Screenpos X),var(54)
removetime=-2
ownpal=1
facing=-1
scale = 0.5,0.5
ignorehitpause=1
pausemovetime=100
supermovetime=100


[State -2, Camera fix]
type = ScreenBound
trigger1 = statetype != A
trigger2 = statetype = A && p2dist Y>0
value = 1
movecamera = 1,0
ignorehitpause = 1

[State -2, change direction sound]
type = null;playsnd
trigger1 = (prevstateno=0 || prevstateno=20)  && stateno=40 && !time
trigger2 = stateno=20 && vel x<0 && command = "holdfwd"
trigger3 = stateno=20 && vel x>0 && command = "holdback"
value = 50,0
channel = -1
volume = 300

[State -2, AutoTurn]
type = null ;Turn
triggerall = roundstate = 2
triggerall = Anim != [5,6]
triggerall = stateno != [1800,1805]
triggerall = P2Dist X>50
trigger1 = facing = enemy,facing
trigger1 = time>=5
;ignorehitpause =
;persistent =

; 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,53] ;<-- 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,53]   ;<-- NEW
trigger2 = facing != enemy,facing  ;<-- NEW
ID = 21

; Piccolo Clones compatibility
[State -2, Explod]
type = Explod
trigger1 = !NumExplod(991901)
trigger1= NumHelper(6800)
trigger1 = Helper(6800),stateno=6910
anim = 5939
ID = 991901
pos = 0,0
postype = p1  ;p2,front,back,left,right
bindtime = -1
removetime = -1
removeongethit = 1

;Piccolo Clones Compatibility
[State 0, RemoveExplod]
type = RemoveExplod
trigger1= !NumHelper(6800)
trigger2 = P2MoveType != H
id = 991901

; Yakon lower layer
[State -2, SprPriority]
type = SprPriority
trigger1 = NumHelper(2110)
value = -9
ignorehitpause = 1
;persistent =

; Floating Bomb fail
[State -2, ChangeState]
type = ChangeState
triggerall = movetype=I || stateno=1900
trigger1 = NumHelper(2950)
trigger1 = Helper(2950),stateno=2956
trigger1 = helper(2950),time=5
value = 1910
ctrl = 0
;anim =
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

;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

;===============================================================================
; ------- Guard priority --------
;===============================================================================
[State -2, Guard SprPriority]
type = SprPriority
trigger1 = stateno = [120,155]
value = -5
ignorehitpause = 1
;persistent =

[State -2, Remove Focus spiral]
type = RemoveExplod
trigger1 = stateno != 1300 ; [1300,1302]
id = 7300
;ignorehitpause =
;persistent =



;===============================================================================
; ------- Remove Various Explods --------
;===============================================================================
[state -2, remove charge dust]
type = removeexplod
trigger1 = stateno != 900
;trigger1 = stateno != 901
id = 908

[State -2, Remove Sticky Bomb]
type = RemoveExplod
trigger1 = NumHelper(2400)=0
trigger2 = enemy,stateno=[6920,6927] ; remove when Curse Lv.3
id = 6303
;ignorehitpause =
;persistent =

[State -2, RemoveExplod Pong]
type = RemoveExplod
trigger1 = stateno!=6910
trigger2 = NumHelper(6800)=0
id = 784
[State -2, RemoveExplod Pong]
type = RemoveExplod
trigger1 = stateno!=6910
trigger2 = NumHelper(6800)=0
id = 785
[State -2, RemoveExplod Pong]
type = RemoveExplod
trigger1 = stateno!=6910
trigger2 = NumHelper(6800)=0
id = 786
[State -2, RemoveExplod Pong]
type = RemoveExplod
trigger1 = stateno!=6910
trigger2 = NumHelper(6800)=0
id = 787


[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

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

[State -2, Counter Flag]
type = VarSet
trigger1 = NumEnemy
fvar(8) = (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, 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(8), 1.2, 1)
ignoreHitPause = 1

;===============================================================================
; ------- Special Winpose Controllers --------
;===============================================================================

[State 0, Winpose Initialize]
type = VarSet
trigger1 = roundstate = 0
trigger1 = Time = 1
var(51) = IfElse(random<=300,0,69) ;0 ;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(51) = 0
trigger1 = WinKO
fv = 5
value = EnemyNear, Facing * (EnemyNear, GetHitVar(xvel))

[State -2, Save Y]
type = VarSet
triggerall = var(51) = 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 = var(51) = 0
trigger1 = WinKO
ProjID = 3900
projanim = 3900
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, Special Winpose Enabled]
type = VarSet
trigger1 = NumProjID(3900)
var(51) = 1

;===============================================================================
; ------- PONG --------
;===============================================================================

[State -2, Pong special]
type = AssertSpecial
trigger1 = NumHelper(6800)=1
trigger1 = Helper(6800),stateno=6910
flag = invisible
ignorehitpause = 1

[State -2, Pong special]
type = NotHitBy
trigger1 = NumHelper(6800)=1
trigger1 = Helper(6800),stateno=6910
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
;value2 = S,NA
time = 1
ignorehitpause = 1
;persistent =

[State 0, Pong special] ; prevent pushing enemy
type = PlayerPush
trigger1 = NumHelper(6800)=1
trigger1 = Helper(6800),stateno=6910
value = 1
ignorehitpause = 1
;persistent =


[State -2, Pong special]
type = CtrlSet
trigger1 = NumHelper(6800)=1
trigger1 = Helper(6800),stateno=6910
value = 0
ignorehitpause = 1
;persistent =

[State -2, PosSet]
type = PosSet
trigger1 = NumHelper(6800)=1
trigger1 = Helper(6800),stateno=6910
x = IfElse(facing=1,-80,80)
y = var(52)
;ignorehitpause =
;persistent =

[State -2, Pong special]
type = ChangeState
trigger1 = enemy,stateno=6927 ;time=240
value = 6911
ctrl = 0
;anim =
ignorehitpause = 1
;persistent =

[State -2, Pong special]
type = CtrlSet
trigger1 = stateno!=6911
trigger1 = NumTarget
trigger1 = target,stateno=6927
trigger2 = stateno!=2900      ;if CB hits but loses target
trigger2 = NumHelper(6800)=1
trigger2 = Helper(6800),stateno=6910
trigger2 = !NumTarget
value = 1
ignorehitpause = 1
;persistent =



;===============================================================================
; ------- Timer counter --------
;===============================================================================
[State 1501, Decrement Time Left]
type = VarAdd
triggerall = !NumHelper(2100) ;no Yakon
trigger1 = NumHelper(8888)
var(35) = -1
;ignorehitpause =
;persistent =

[State 0, VarSet] ;interrupt frozen
type = VarSet
trigger1 = enemy,prevstateno=6876
;trigger1 = enemy,stateno=[5000,5100] ;!= 5071
trigger1 = enemy,movetype=H
trigger2 = enemy,stateno=6920
var(35) = 0
ignorehitpause = 1
;persistent =


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

[State -2, laugh when Frozen]
type = playsnd
trigger1 = enemy,stateno=6876
trigger1 = enemy,time=0
value = 3,11
channel = 0
volume = 300
lowpriority = 1

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

[State -2, Explod];State 5052 Twist FX
type = Explod
triggerall = NumExplod(20152) = 0
trigger1 = anim=5052 && animelemtime(4)=0
anim = 20152
pos = 0,-20 ;-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=null ;explod
trigger1 = Anim=5937 && !numexplod(59370) && animelemtime(3)=0
anim = 5938
id = 5938
pos = 0,-20 ;-50
postype = P1
sprpriority = 3
ownpal = 1
;supermovetime = -1
removetime = -1
persistent = 0
bindtime = -1
ignorehitpause = 1

[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

;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 -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, 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, KO snd Babidi]
type = playsnd
trigger1 = !alive && var(8) = 1
trigger1 = var(8) := 2
value = 11, 1 + (stateno = 5950)
ignorehitpause = 1
volume = 300


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


;===============================================================================
; ------- VarSets --------
;===============================================================================

[State -2, Air dash reset var when Babidi 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
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

[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

;===============================================================================
; ------- 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(2604)                                                              ;2604 Pui-Pui LV1
trigger1 = helper(2604),movecontact
trigger2 = NumHelper(2100)								;2100 Yakon LV1
trigger2 = helper(2100),movecontact
trigger3 = NumHelper(2305)								;2305 Darbura LV2
trigger3 = helper(2305),movecontact
trigger4 = NumHelper(2353)								;2353 Darbura LV3
trigger4 = helper(2353),movecontact
trigger5 = stateno=6911                                                                 ;6911 Pong LV3
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 = [3550,3554]                       ; Royal Edict
trigger2 = stateno = 4104                              ;SPB#1 - Galactic Juggler
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(2604)                                                              ;2604 Pui-Pui LV1
trigger1 = helper(2604),movecontact
trigger2 = NumHelper(2100)								;2100 Yakon LV1
trigger2 = helper(2100),movecontact
trigger3 = NumHelper(2305)								;2305 Darbura LV2
trigger3 = helper(2305),movecontact
trigger4 = NumHelper(2353)								;2353 Darbura LV3
trigger4 = helper(2353),movecontact
trigger5 = stateno=6911                                                                 ;6911 Pong LV3
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

;===============================================================================
; 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
triggerall = stateno != [3320,3330]  ;Don't activate during Big Bang
trigger1 = var(56) = 1 && movehit ;Counter Check Ok, Move Hit Succesfully.
trigger1 = stateno != [190,199] ;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 != [190,199] ;Does not activate during intros.
triggerall = stateno != [800,820] ;Does not activate during throws.
triggerall = stateno != [950,951] ;Don't activate during throws.
triggerall = stateno != [3320,3330]  ;Don't activate during Big Bang
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.
triggerall = stateno != [3320,3330]  ;Don't activate during Big Bang
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
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.
triggerall = stateno != [3320,3330]  ;Don't activate during Big Bang
trigger1 = movehit ;Move hits
trigger2 = projhit = 1 ;Projectile Hits
anim = 13001
pos = -82,100 ;-1,100
postype = right  ;p2,front,back,left,right
removetime = -2
supermove = 1
sprpriority = 0
id = 13000
bindtime = -1
ontop = 1
ownpal = 1
ignorehitpause = 1
pausemovetime = -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

;===============================================================================
; 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
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  ;p2,front,back,left,right
removetime = -2
supermove = 1
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

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

[State -2, DisplayToClipboard]
type = DisplayToClipboard
trigger1 = (authorname="Team Z2")
text = "PrevState=%d, Posx=%d, VelY=%f, Pos Y=%d, NumTarget=%d\n"       ;2604 ;2305
params = PrevStateno, floor(pos X), vel y, floor(pos Y), numtarget;(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 Balthazar, Daeron & 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 Balthazar, Daeron & XGargoyle. Don't even try to deny\it thief! Original version available at http://network.mugenguild.com/balthazar/\n"
ignorehitpause = 1




;===============================================================================
; ------- END BABIDI --------
;===============================================================================




;===============================================================================
; ------- Challenge/Trial Mode Stuff --------
;===============================================================================

; Dummy controls and ChangeStates

[State no control]
type = VarSet
triggerall = NumEnemy
triggerall = enemy,name = "Goku Z2" && enemy,authorname = "Team Z2"
triggerall = teamside = 2
trigger1 = enemy,NumHelper(20000) && roundstate=2
var(52) = 1

[State recover]
type = ChangeState
triggerall = NumEnemy
triggerall = enemy,name = "Goku Z2" && enemy,authorname = "Team Z2"
triggerall = teamside = 2
trigger1 = enemy,NumHelper(20000)
trigger1 = Vel Y > -1
trigger1 = CanRecover && stateno=5050
value = ifelse((pos Y>=-20), 5200, 5210)

[State kicking]
type = ChangeState
triggerall = NumEnemy
triggerall = enemy,name = "Goku Z2" && enemy,authorname = "Team Z2"
triggerall = teamside = 2
trigger1 = enemy,NumHelper(20000)
trigger1 = enemy,var(51)=1
trigger1 = (stateno!=250) && ctrl && (statetype=S)
value = 250

[State jumping]
type = ChangeState
triggerall = NumEnemy
triggerall = enemy,name = "Goku Z2" && enemy,authorname = "Team Z2"
triggerall = teamside = 2
trigger1 = enemy,NumHelper(20000)
trigger1 = enemy,var(51)>=2
trigger1 = (stateno!=40) && ctrl && (statetype != A)
value = 40

[State kicking in air]
type = ChangeState
triggerall = NumEnemy
triggerall = enemy,name = "Goku Z2" && enemy,authorname = "Team Z2"
triggerall = teamside = 2
trigger1 = enemy,NumHelper(20000)
trigger1 = enemy,var(51)=3
trigger1 = (stateno!=650) && ctrl && (statetype=A)
value = 650



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


;--------------------------------------
[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,0
channel = 0
ignorehitpause = 1
persistent = 0
volume = 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%4
channel = 0
ignorehitpause = 1
persistent = 0
volume = 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%3
channel = 0
ignorehitpause = 1
persistent = 0
volume = 200

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

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

[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 = null ;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, remove afterimage]
type = afterimagetime
trigger1 = Movetype = H
trigger2 = stateno != [10230,10233]  ;Super Jump
trigger2 = stateno != [110,115]  ;air dash
trigger2 = stateno != 50
trigger2 = stateno != 1950	;EX Floating Bomb
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
triggerall = stateno=0
trigger1 = prevstateno=[191,194]
;trigger2 = prevstateno=[700,745]
trigger2 = prevstateno= 199 ;[700,749]
channel = 8

[State -3, stopsnd if skip intro]
type = stopsnd
triggerall = stateno=0
trigger1 = prevstateno=[191,194]
;trigger2 = prevstateno=[700,745]
trigger2 = prevstateno= 199 ;[700,749]
channel = 0

[State -3, stopsnd Ki Blast charging]
type = stopsnd
trigger1 = Anim!=1000 && Anim!=1003
channel = 7

[State 0, Stop Pause]
type = Pause
triggerall = stateno=0
trigger1 = prevstateno=[191,194]
time = 0
movetime = 0
pausebg = 0

[State -3, Stop BGPalFX if skip intro]
type = BGPalFX
triggerall = stateno=0
trigger1 = prevstateno=[191,194]
time = 0
;add = 0,0,0
;mul = 256,256,256
;sinadd = 0,0,0,10
invertall = 0
color = 256
;ignorehitpause =
;persistent =



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

;===============================================================================
; Galactic Gunfire / Saving Strike code (Part B)
;===============================================================================

[state -3, animelem set frame 2]
type = varset
trigger1 = stateno = 2600 && animelem = 5
var(23) = 5

[state -3, animelem set frame 3]
type = varset
trigger1 = stateno = 2600 && animelem = 6
var(23) = 6

[State -3, Change to second state]
type = HitOverride
trigger1 = stateno = 2600
attr = SCA,NA,SA,HA,NP,SP,HP
slot = 0
stateno = 2595
time = 1
forceair = 0
ignorehitpause = 1
persistent = 1
 
[state -3, varset for first state]
type = varset
trigger1 = stateno = 2600
var(25) = 1
 
[state -3, varset for second state]
type = varset
trigger1 = stateno = 2595
var(25) = 0

[State -3, health removal in second state]
type = LifeAdd
trigger1 = stateno = 2596
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

