;================================
; CNS File for Vegeta Z2 by Balthazar & Cybaster
; Majin Vegeta Z2 by 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

[State -2, Prevent starting with decreased lifebar after Babidi intro]
type = LifeSet
triggerall = RoundNo = 1
trigger1 = roundstate=2
trigger1 = prevstateno = 735 ;[700,750] ;735
trigger2 = roundstate<2
trigger2 = stateno!=735
value = LifeMax
;ignorehitpause =
persistent = 0

[State -2, Disable Ctrl after Royal Edict]
type = CtrlSet
trigger1 = stateno =  50
trigger1 = prevstateno=3557
value = 0


;===============================================================================
; ------- Kill AI --------
;===============================================================================
[State -2, Kill AI]
type=varset
trigger1= var(59)!=0
trigger1= roundstate!=2 || !alive
var(59)=0
ignorehitpause=1

;===============================================================================
; ------- AI Selection Cap --------
;===============================================================================
[State -2, Max AI]
type=varset
trigger1= var(53)>8
trigger1= roundstate=0
var(53)=8
ignorehitpause=1

[State -2, Min AI]
type=varset
trigger1= var(53)<1
trigger1= roundstate=0
var(53)=1
ignorehitpause=1

;===============================================================================
; ------- Majin Bakuhatsu Winpose Controllers --------
;===============================================================================

[State 0, Baku Initialize]
type = VarSet
triggerall = var(1)=2 ;Majin only
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
triggerall = var(1)=2 ;Majin only
trigger1 = roundstate = 0
trigger1 = Time = 1
fvar(5) = 0

[State 0, Vel Y Initialize]
type = VarSet
triggerall = var(1)=2 ;Majin only
trigger1 = roundstate = 0
trigger1 = Time = 1
fvar(6) = 0

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

[State -2, Save Y]
type = VarSet
triggerall = var(1)=2 ;Majin only
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 = var(1)=2 ;Majin only
triggerall = var(54) = 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, Baku Winpose Enabled]
type = VarSet
trigger1 = NumProjID(3900)
var(54) = 1



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

;Damage Dampener Variable (by POTS)
[State -2, Damage based on hits]
type=varset
trigger1 = numenemy
fvar(12) = ifelse(enemynear,gethitvar(hitcount)<2, 20, ifelse(enemynear,gethitvar(hitcount)>=20, 2, 21-enemynear,gethitvar(hitcount))) / 20.0  ;CFJ
ignorehitpause=1

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

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


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

[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
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, Charge GG startup]
type = varset
trigger1 = stateno!=2600 && stateno!=2595 && stateno!=2596 && stateno!=2603
fvar(10) = 0
ignorehitpause = 1

[State -2, Alternate Dashing Elbow anim]
type=varset
trigger1= stateno != 1101		;Wolvie FWD
trigger1= stateno != 1201		;Wolvie BWD
trigger1= stateno != [105,106]	;Dash Back
var(12) = 0

[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)

;Dash Elbow variable
[State -2, Dash Elbow reset]
type = VarSet
trigger1 = PrevStateno=3110&&Stateno!=3110
var(3) = 0

;===============================================================================
; ------- Rage Mode --------
;===============================================================================

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

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

[State -2, RAGE MODE VARS - Flame]
type = varadd
triggerall = var(1)=1 ; Draining only affects Normal Vegeta
triggerall = var(32)>0 && var(33)>0 && var(33)<2100
triggerall = stateno != [2800,2899]		;Not in Rage GG state
;triggerall = stateno != [3700,3703]             ;Not in SPB state
;triggerall = stateno != [37021,37032]           ;Not in SPB state
;triggerall = stateno != 3800                    ;Not in Aura Burst
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, RAGE MODE VARS - Zero]
type = varset
trigger1 = var(33)<0
var(33) = 0
ignorehitpause = 1

[State -2, RAGE MODE VARS - Flame]
type = varset
trigger1 = var(33)>2100
var(33) = 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)
triggerall = var(55)=0		;Voice=English
trigger1 = !alive && var(8) = 1
trigger1 = var(8) := 2
value = 11, 1 + (1+random%4)*(stateno = 5950)
ignorehitpause = 1
volume = 300


[State -2, KO snd Japan]
type = 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
volume = 300

[State -2, KO snd Sabbat]
type = 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
volume = 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
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,-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
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)
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

[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

;[MAJIN]
;Salt Statue
[State -2, AssertSpecial]
type = AssertSpecial
trigger1 = NumExplod(3840)
flag = invisible
flag2 = nobardisplay
flag3 = nomusic



;===============================================================================
; ------- 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(2001)								;Galick Ho
trigger1 = helper(2001),movecontact
trigger2 = NumHelper(2301)								;Bakuhatsuha
trigger2 = helper(2301),movecontact
trigger3 = NumHelper(2321)								;Bakuhatsuha LV2
trigger3 = helper(2321),movecontact
trigger4 = NumHelper(2401)								;Chou Galick Ho
trigger4 = helper(2401),movecontact
trigger5 = NumHelper(2341)								;Bakuhatsuha LV3-1
trigger5 = helper(2341),movecontact
trigger6 = NumHelper(2342)								;Bakuhatsuha LV3-2
trigger6 = helper(2342),movecontact
trigger7 = NumHelper(2343)								;Bakuhatsuha LV3-3
trigger7 = helper(2343),movecontact
trigger8 = stateno = 2625								;Galactic Gunfire
trigger9 = NumHelper(2102)								;Air Galick Ho
trigger9 = helper(2102),movecontact
trigger10 = NumHelper(2452)								;Air Chou Galick Ho (not last)
trigger10 = helper(2452),movecontact
trigger11 = NumHelper(2453)								;Air Chou Galick Ho (last)
trigger11 = helper(2453),movecontact
trigger12 = stateno = 2835								;Rage Galactic Gunfire - Charged Blast
trigger13 = stateno = 2865 && !MatchOver				;Rage Galactic Gunfire - Final Galick Ho (no fatality)
trigger14 = NumHelper(33210)							;Majin Big Bang Attack (Shield)
trigger14 = helper(33210),movecontact
trigger15 = NumHelper(3331)								;Majin Big Bang Attack (Ball)
trigger15 = helper(3331),movecontact
trigger16 = ProjContact3335=1,<20						;Majin Big Bang Attack (Explosion)
trigger17 = NumHelper(3410)								;Majin Machine Gun Tantrum
trigger17 = helper(3410),movecontact
trigger18 = NumHelper(3431)								;Majin Air Machine Gun Tantrum
trigger18 = helper(3431),movecontact
trigger19 = stateno = [3550,3554]                                                       ; Royal Edict
trigger20 = NumHelper(3302)								;Photon Bomber
trigger20 = helper(3302),movecontact
trigger21 = ProjContact3307=1,<20						;Photon Bomber (Explosion)
trigger22 = ProjContact3003=1,<20						;Atomic Blast (Explosion)
trigger23 = ProjContact3714=1,<20						;SPB (Explosion)
trigger24 = stateno = 4104                              ;SPB#1 - Galactic Juggler
trigger25 = NumHelper(4004)                                                     ;SPB#2 - Final Flash
trigger25 = helper(4004),movecontact
trigger26 = stateno = 3802 && movecontact                                       ;Aura Burst
trigger26 = !NumHelper(38000)
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,3557]                       ; 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(2001)								;Galick Ho
trigger1 = helper(2001),movecontact
trigger2 = NumHelper(2301)								;Bakuhatsuha
trigger2 = helper(2301),movecontact
trigger3 = NumHelper(2321)								;Bakuhatsuha LV2
trigger3 = helper(2321),movecontact
trigger4 = NumHelper(2401)								;Chou Galick Ho
trigger4 = helper(2401),movecontact
trigger5 = NumHelper(2341)								;Bakuhatsuha LV3-1
trigger5 = helper(2341),movecontact
trigger6 = NumHelper(2342)								;Bakuhatsuha LV3-2
trigger6 = helper(2342),movecontact
trigger7 = NumHelper(2343)								;Bakuhatsuha LV3-3
trigger7 = helper(2343),movecontact
trigger8 = stateno = 2625								;Galactic Gunfire
trigger9 = NumHelper(2102)								;Air Galick Ho
trigger9 = helper(2102),movecontact
trigger10 = NumHelper(2452)								;Air Chou Galick Ho (not last)
trigger10 = helper(2452),movecontact
trigger11 = NumHelper(2453)								;Air Chou Galick Ho (last)
trigger11 = helper(2453),movecontact
trigger12 = stateno = 2835								;Rage Galactic Gunfire - Charged Blast
trigger13 = stateno = 2865 && !MatchOver				;Rage Galactic Gunfire - Final Galick Ho (no fatality)
trigger14 = NumHelper(33210)							;Majin Big Bang Attack (Shield)
trigger14 = helper(33210),movecontact
trigger15 = NumHelper(3331)								;Majin Big Bang Attack (Ball)
trigger15 = helper(3331),movecontact
trigger16 = ProjContact3335=1,<20						;Majin Big Bang Attack (Explosion)
trigger17 = NumHelper(3410)								;Majin Machine Gun Tantrum
trigger17 = helper(3410),movecontact
trigger18 = NumHelper(3431)								;Majin Air Machine Gun Tantrum
trigger18 = helper(3431),movecontact
trigger19 = NumHelper(3302)								;Photon Bomber
trigger19 = helper(3302),movecontact
trigger20 = ProjContact3307=1,<20						;Photon Bomber (Explosion)
trigger21 = ProjContact3003=1,<20						;Atomic Blast (Explosion)
trigger22 = ProjContact3714=1,<20						;SPB (Explosion)
trigger23 = NumHelper(4004)                                                     ;SPB#2 - Final Flash
trigger23 = helper(4004),movecontact
trigger24 = stateno = 3802 && movecontact                                       ;Aura Burst
trigger24 = !NumHelper(38000)
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="Balthazar & Cybaster") || (authorname="Balthazar, Cybaster & XGargoyle")
text = "PrevState=%d, Vel Y=%f, PosX=%d, v1=%d, target=%d\n"
params = PrevStateno, vel y, Pos X, var(1), 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
triggerall = var(1) = 1
trigger1 = (authorname="Balthazar & Cybaster") || (authorname="Balthazar, Cybaster & XGargoyle")
text = "by Balthazar & Cybaster - http://network.mugenguild.com/balthazar/"
ignorehitpause = 1

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

[State -2, Debug]
type = appendtoclipboard
triggerall = var(1) = 2
trigger1 = (authorname="Balthazar & Cybaster") || (authorname="Balthazar, Cybaster & XGargoyle")
text = "by Balthazar & Cybaster & XGargoyle - http://network.mugenguild.com/balthazar/"
ignorehitpause = 1

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


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

; Dummy controls and ChangeStates

[State no control]
type = VarSet
triggerall = NumEnemy
triggerall = enemy,name = "Goku Z2" && enemy,authorname = "Balthazar & Cybaster"
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 = "Balthazar & Cybaster"
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 = "Balthazar & Cybaster"
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 = "Balthazar & Cybaster"
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 = "Balthazar & Cybaster"
triggerall = teamside = 2
trigger1 = enemy,NumHelper(20000)
trigger1 = enemy,var(51)=3
trigger1 = (stateno!=650) && ctrl && (statetype=A)
value = 650

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

;===============================================================================
; ------- Rage Mode Gauge --------
;===============================================================================

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

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

;===============================================================================
; ------- Sanity Mode Gauge --------
;===============================================================================

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

; SANITY MODE GAUGE P2
[State -2, Sanity Gauge]
type = helper
triggerall = !NumHelper(4760) && teamside = 2
triggerall = var(1) = 2 ;Majin only
trigger1 = var(32) > 0
ID = 4760
stateno = 4760
pos = 20, 0
postype = left
helpertype = normal
name = "sanity"
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
id = 908

[state -2, remove rising knee/Double Slash Kick FX]
type = removeexplod
trigger1 = stateno != 1501 && stateno != 3601 && stateno != 3603 && stateno != 3651 && stateno != 3653 && stateno != 3655 && stateno != 3657
id = 1503

[state -2, remove EX rising knee FX]
type = removeexplod
trigger1 = stateno!=1551 || anim!=1501
id = 1553

[state -2, remove goomba]
type = removeexplod
;trigger1 = stateno != 725 && stateno != 726
trigger1 = stateno != 714 && stateno != 7141
trigger1 = stateno != 52
id = 72501

;[MAJIN]
[state -2, remove Elbow dash]
type = removeexplod
trigger1 = stateno != 3101
id = 3105

;[MAJIN]
[state -2, remove Majin face]
type = removeexplod
trigger1 = stateno != 0
trigger2 = Anim!=0 && Anim!=3
trigger3 = Anim=0 && var(1)=2 ;remove if Majin in Vanilla stance (Satan FIX)
trigger4 = Anim=3 && var(1)=1 ;remove if Vanilla in Majin stance (Satan FIX)
trigger5 = stateno=0  ;remove explod if player skips intro
trigger5 = prevstateno=[191,194]
;trigger5 = prevstateno=[700,735]
trigger5 = prevstateno=[700,749]
trigger6 = prevstateno = 0 && RoundState =2 ;prevent misalignment if skipped Roundstate=0,1
id = 4

[state -2, remove Crouch face]
type = removeexplod
trigger1 = Anim!=11    ;remove if not crouched
trigger2 = Anim=11 && command != "holddown"
id = 11

[state -2, remove Double Slash kick effect]
type = removeexplod
trigger1 = Anim!=3601
trigger1 = Anim!=3603
trigger1 = Anim!=3651
trigger1 = Anim!=3653
id = 1503

[State -2, Remove Aura ZERO] ;Babidi leeching
type = RemoveExplod
trigger1 = RoundState!=0
trigger2 = Stateno!=735
id = 19739

;[MAJIN]
;Big Bang
[State -2, stopsnd BB sound]
type = StopSnd
trigger1 = movetype = H
trigger1 = prevstateno=[3320,3326]
trigger2 = (enemy,name="Vegeta Z2" || enemy,name="Normal Vegeta Z2" || enemy,name="Majin Vegeta Z2") && enemy,NumHelper(2504);destroy under Vegeta Final Flash
trigger3 = !SelfAnimExist(Anim) ; destroy under custom state
channel = 5


;[MAJIN]
;===============================================================================
; Atomic Blast ball controls
;===============================================================================
[State 3201, AB ball P2]
type = Explod
triggerall = numtarget
;triggerall = prevstateno = 3200
triggerall = !NumExplod(3210)
;;triggerall = enemy,prevstateno = 3206
;triggerall = enemy,Anim=3204  ;Non Z2
triggerall = target,stateno=3206
triggerall = target,stateno != 3207
;;triggerall = enemy,BackEdgeDist >= 30
;;trigger1 = time = 8 ;AnimElemtime(5)= 0
trigger1 = FrontEdgeBodyDist >= 90 ;avoid bug in corner
trigger1 = target,Anim=120 || target,Anim=3204  ;Non Z2
anim = 3210
ID = 3210
;pos = IfElse((enemy,Anim=3204),15,65), -60
pos = 15, -60
postype = p2  ;p2,front,back,left,right
facing = -1
vfacing = 1
bindtime = 1
vel = -3,0
accel = 0,0
random = 0,0
removetime = -1
pausemovetime = 0
scale = 1,1
sprpriority = 5
ontop = 0
shadow = 0,0,0
ownpal = 1
ignorehitpause = 1

[State 3201, AB ball P2]
type = Explod
triggerall = numtarget
;triggerall = prevstateno = 3200
triggerall = !NumExplod(3210)
;triggerall = enemy,prevstateno = 3206
triggerall = target,Anim=3206  ;Z2
triggerall = target,stateno != 3207
;triggerall = enemy,BackEdgeDist >= 30
;trigger1 = time = 8 ;AnimElemtime(5)= 0
trigger1 = FrontEdgeBodyDist >= 90 ;avoid bug in corner
anim = 3210
ID = 3210
;pos = IfElse((enemy,Anim=3204),15,65), -60
pos = 65-50*(enemy,name="Babidi Z2"), -60+55*(enemy,name="Babidi Z2")
postype = p2  ;p2,front,back,left,right
facing = -1
vfacing = 1
bindtime = 1
vel = -3,0
accel = 0,0
random = 0,0
removetime = -1
pausemovetime = 0
scale = 1,1
sprpriority = 5
ontop = 0
shadow = 0,0,0
ownpal = 1
ignorehitpause = 1


[State -2, dash Sound]
type = PlaySnd
triggerall = NumExplod(3210)
trigger1 = numtarget
trigger1 = target,Stateno=3206
trigger1 = target,time=8 ;AnimElemTime(2)=0
trigger2 = !numtarget
trigger2 = enemy,Stateno=3206
trigger2 = enemy,time=8
value = 3200, 0
channel = 5


[State -2, dash Sound loop]
type = PlaySnd
triggerall = NumExplod(3210)
trigger1 = numtarget
trigger1 = target,Stateno=3206
trigger1 = target,time=23 ;AnimElemTime(2)=15
trigger2 = !numtarget
trigger2 = enemy,Stateno=3206
trigger2 = enemy,time=23
value = 3200, 1
loop = 1
channel = 5

[State -2, Dash StopSnd]
type = StopSnd
trigger1 = numtarget
trigger1 = target,Stateno=3207
trigger1 = BackEdgeDist < 15
trigger2 = numtarget
trigger2 = NumExplod(3210)
trigger2 = target,Stateno!=3206
trigger3 = !numtarget
trigger3 = enemy,Stateno=3207
trigger3 = BackEdgeDist < 15
trigger4 = !numtarget
trigger5 = NumExplod(3210)
trigger5 = enemy,Stateno!=3206
channel = 5

[State -2, AB ExplodBindTime]
type = ExplodBindTime
triggerall = NumExplod(3210)
trigger1 = numtarget
trigger1 = target,BackEdgeDist < 15
trigger2 = !numtarget
trigger2 = enemy,BackEdgeDist < 15
ID = 3210
time = 0
;ignorehitpause =
;persistent =


[State -2, AB Explosion] ;NEW
type = Explod
triggerall = roundstate=2
triggerall = var(26)=1
triggerall = !NumExplod(3208)
triggerall = enemy,stateno != 32077
trigger1 = numtarget
trigger1 = target,stateno = 3207
trigger1 = NumExplod(3210) ;big AB    ;!NumExplod(3209) &&
trigger1 = target,time = 10
trigger2 = numtarget
trigger2 = NumExplod(3209) && !NumExplod(3210) ;small AB
;trigger2 = !NumExplod(3210) ;small AB
trigger2 = target,time >= 7
trigger3 = numtarget
trigger3 = !NumExplod(3209) && !NumExplod(3210) ;corner case
trigger3 = target,time >= 7
trigger4 = !numtarget
trigger4 = NumExplod(3210) ;big AB
trigger4 = enemy,stateno = 3207
trigger4 = enemy,time = 10
trigger5 = !numtarget
trigger5 = NumExplod(3209) && !NumExplod(3210) ;small AB
trigger5 = enemy,time = 7
;trigger6 = !numtarget
;trigger6 = !NumExplod(3209) && !NumExplod(3210) ;corner case
;trigger6 = enemy,time >= 7
anim = 3208
ID = 3208
pos = 10,-60+55*(enemy,name="Babidi Z2")
postype = p2  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = -1
vel = 0,0
accel = 0,0
random = 0,0
removetime = -2
supermovetime = 9999
pausemovetime = 9999 ;0
scale = 1,1
sprpriority = 0
ontop = 1
shadow = 0,0,0
ownpal = 0
removeongethit = 0
ignorehitpause = 1
;trans =
;persistent = 0
;supermove = 0
;pausemove = 0


[State -2, Explosion Sound]
type = PlaySnd
triggerall = roundstate=2
triggerall = var(26)=1
trigger1 = numtarget
trigger1 = target,stateno = 3207
trigger1 = target,time = 10
trigger2 = !numtarget
trigger2 = enemy,stateno = 3207
trigger2 = enemy,time = 10
value = 3330,1
channel = 6

[State -2, Remove Atomic Blast ball]
type = RemoveExplod
triggerall = roundstate=2
triggerall = var(26)=1
triggerall = NumExplod(3210)
trigger1 = numtarget
trigger1 = target,stateno = 3207
trigger1 = target,time = 10
trigger2 = numtarget
trigger2 = target,stateno != [3206,3207]
trigger3 = !numtarget
trigger3 = enemy,stateno != [3206,3207]
id = 3210
;ignorehitpause =
;persistent =

[State -2, Projectile]
type = Projectile
triggerall = roundstate=2
triggerall = var(26)=1
triggerall = !NumProjID(3003)
trigger1 = numtarget
trigger1 = target,stateno = 3207 ;Target,stateno = 3207
trigger1 = target,time = 10 ;Target,time = 10
trigger2 = !numtarget
trigger2 = enemy,stateno = 3207
trigger2 = enemy,time = 10
ProjID =  3003
projanim = 3003
projhitanim =-1 ; 3003
projremove = 1
;projremovetime = 36 ;-1
velocity = 0,0
remvelocity = 0,0
accel = 0,0
velmul = 1
projhits = 1
projpriority = 1
projsprpriority = 4
projedgebound = 40
projstagebound = 40
projheightbound = -240
offset = 0,0
postype = p2
projshadow = 0,0,0
supermovetime = 0
pausemovetime = 0
; HitDef
attr = S,NP        ;SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
hitflag = MAF        ;HLAFD+-
guardflag = MA         ;HLA
getpower = 0,0
givepower = 0,0
affectteam = E          ;B,E,F
animtype = medium ;light          ;light,medium,hard,back,up,diagup
;air.animtype = light
;fall.animtype = Back
priority = 4,Hit   ;Hit,Miss,Dodge
damage = 100,10
pausetime = 0,0 ;0,50 ;50
guard.pausetime = 0,0 ;50
sparkno = -1
guard.sparkno = -1
sparkxy = 0,0
;hitsound = 0,0
;guardsound = 0,0
ground.type = High      ;Low,Trip,None
;air.type = High
ground.slidetime = 15
;guard.slidetime = 0
ground.hittime = 0 ;50
;guard.hittime = 0
;air.hittime = 20
;guard.ctrltime  = 0
;guard.dist = 320
;yaccel = 0.5
ground.velocity = 0,0
guard.velocity = 0
air.velocity = 0,0
airguard.velocity = 0,0
p2stateno = 32077
ignorehitpause = 1
;persistent =

[State 3201, AB Flag]
type = VarSet
trigger1 = NumProjID(3003)
trigger2 = !numtarget
var(26)=0
ignorehitpause = 1
;persistent =




;===============================================================================
; 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
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.
triggerall = stateno != [3320,3330]  ;Don't activate during Big Bang
trigger1 = movehit ;Move hits
trigger2 = projhit = 1 ;Projectile Hits
anim = 13001
pos = -1,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

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


;===============================================================================
; BEAM COUNTER - Vegeta gets freezed during "superpause"
;===============================================================================

;RIP LOL



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

[State -3, Wrong StateType]
type= null ;superpause
triggerall = var(1) = 2
triggerall = roundstate=2
triggerall = stateno!=3553
triggerall = stateno!=[4100,4120]
trigger1= pos y!=0 && statetype!=A && statetype!=L
time= 99999
ignorehitpause= 1


[State -3, AI Helper]
type=helper
trigger1= !var(59)&& !numhelper(9741)
trigger1= alive && roundstate=2
helpertype=normal
name="Vegeta's AI"
ID=9741
pos=99999,99999
stateno=9741
keyctrl=1
pausemovetime=65535
supermovetime=65535

[State -3, Gametime Var]
type=varset
trigger1= 1
var(58)=gametime
ignorehitpause=1

[State -3, Super Jump AI get closer to you]
type = veladd
x = 0.2
triggerall = var(59)>=1 && 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 = var(55)=0		;Voice=English
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%6
channel = 0
ignorehitpause = 1
persistent = 0
volume = 200

[State -3, GetHitSnd Medium]
type = playsnd
triggerall = var(55)=0		;Voice=English
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
volume = 200

[State -3, GetHitSnd Hard]
type = playsnd
triggerall = var(55)=0		;Voice=English
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%7
channel = 0
ignorehitpause = 1
persistent = 0
volume = 200
;--------------------------------------
[State -3, GetHitSnd Light]
type = 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
volume = 200

[State -3, GetHitSnd Medium]
type = 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
volume = 200

[State -3, GetHitSnd Hard]
type = 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
volume = 200
;--------------------------------------
[State -3, GetHitSnd Light]
type = 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
volume = 200

[State -3, GetHitSnd Medium]
type = 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
volume = 200

[State -3, GetHitSnd Hard]
type = 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
volume = 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 != [1550,1551]	;EX Rising Knee
trigger2 = stateno != 1450			;EX Machine Gun Temper
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
triggerall = stateno=0
trigger1 = prevstateno=[191,194]
;trigger2 = prevstateno=[700,745]
trigger2 = prevstateno=[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=[700,749]
channel = 0

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



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


