;==========================================
; CNS File for Babidi Z2 by Balthazar, Daeron & XGargoyle
; System code: winpose, intro, system, etc.
;==========================================


;-------------------------------------------------------------------------------
;GUARD
[Statedef 120]
type=U
physics=U
anim=120+(statetype=C)+(statetype=A)*2

[State 1900, Shield helper]
type = Helper
trigger1 = !time
id = 6120
name = "Shield"
pos = 0,0
postype = P1
stateno = 6120
helpertype = normal
keyctrl = 0
ownpal = 1
ignorehitpause = 1

[State 120]
Type=CtrlSet
Trigger1=AILevel>0
value=0

[State 120, Type]
type=statetypeset
trigger1= !time && statetype=S
physics=S
[State 120, Type]
type=statetypeset
trigger1= !time && statetype=C
physics=C
[State 120, Type]
type=statetypeset
trigger1= !time && statetype=A
physics=A
[State 120, Vel]
type=velset
trigger1= !time && statetype!=A
x=0
y=0
[State 120, High to Low]
type=statetypeset
triggerall = statetype!=A
trigger1= AILevel<=0 && statetype=S && command="holddown"
trigger2= AILevel>0 && statetype=S && (enemynear,movetype=A) && (enemynear,statetype=C)
statetype=C
physics=C
[State 120, Low to High]
type=statetypeset
triggerall = statetype!=A
trigger1= AILevel<=0 && statetype=C && command!="holddown"
trigger2= AILevel>0 && statetype=C && (enemynear,movetype=A) && (enemynear,statetype!=C)
statetype=S
physics=S
[State 120, AI fix]
type=ctrlset
trigger1= AILevel>0 && numenemy
value= (enemynear,time>=120 || time>=180)
[State 120, End]
type=changestate
trigger1= !animtime || AILevel>0
value=130+(statetype=C)+(statetype=A)*2
[State 120, Stop]
type=changestate
trigger1= (AILevel<=0 && command!="holdback")
trigger2= !inguarddist
trigger3= AILevel>0 && numenemy
trigger3= enemynear,hitdefattr=SCA,AT
value=140


;-------------------------------------------------------------------------------
;STAND GUARD (guarding)
[Statedef 130]
type=S
physics=S
[State 120]
Type=CtrlSet
Trigger1=AILevel>0
value=0
[State 130, Anim]
type=changeanim
trigger1= anim!=130
value=130
[State 130, AI fix]
type=ctrlset
trigger1= AILevel>0 && numenemy
value= (enemynear,time>=120 || time>=180)
[State 130, High to Low]
type=changestate
trigger1= AILevel<=0 && command="holddown"
trigger2= AILevel>0 && random<250
trigger2= (enemynear,movetype=A) && (enemynear,statetype=C)
value=131
[State 130, Stop Guarding]
type=changestate
trigger1= (AILevel<=0 && command!="holdback")
trigger2= !inguarddist
trigger3= AILevel>0 && numenemy
trigger3= enemynear,hitdefattr=SCA,AT
value=140


;-------------------------------------------------------------------------------
;CROUCH GUARD (guarding)
[Statedef 131]
type=C
physics=C
[State 120]
Type=CtrlSet
Trigger1=AILevel>0
value=0
[State 131, Anim]
type=changeanim
trigger1= anim!=131
value=131
[State 131, Low to High]
type=changestate
trigger1= AILevel<=0 && command!="holddown"
trigger2= AILevel>0 && random<125
trigger2= (enemynear,movetype=A) && (enemynear,statetype!=C)
value=130
[State 131, AI fix]
type=ctrlset
trigger1= AILevel>0 && numenemy
value= (enemynear,time>=120 || time>=180)
[State 131, Stop Guarding]
type=changestate
trigger1= (AILevel<=0 && command!="holdback")
trigger2= !inguarddist
trigger3= AILevel>0 && numenemy
trigger3= enemynear,hitdefattr=SCA,AT
value=140

;-------------------------------------------------------------------------------
;AIR GUARD (guarding)
[Statedef 132]
type=A
physics=N
[State 120]
Type=CtrlSet
Trigger1=AILevel>0
value=0
[State 132, Anim]
type=changeanim
trigger1= anim!=132
value=132
[State 132, Grav]
type=veladd
trigger1= 1
y=const(movement.yaccel)
[State 132, Var]
type=varset
trigger1= 1
sysvar(0)=(pos y>=0 && vel y>0)
[State 132, Vel]
type=velset
trigger1= sysvar(0)
y=0
[State 132, Pos]
type=posset
trigger1= sysvar(0)
y=0
[State 132, AI fix]
type=ctrlset
trigger1= AILevel>0 && numenemy
value= (enemynear,time>=120 || time>=180)
[State 132, End]
type=changestate
trigger1= sysvar(0) && inguarddist
trigger1= (AILevel<=0 && command="holdback") || AILevel>0
value=130
[State 132, End]
type=changestate
trigger1= sysvar(0)
value=52
[State 132, stop guarding]
type=changestate
trigger1= (AILevel<=0 && command!="holdback")
trigger2= !inguarddist
trigger3= AILevel>0 && numenemy
trigger3= enemynear,hitdefattr=SCA,AT
value=140

;-------------------------------------------------------------------------------
;GUARD (end)
[Statedef 140]
type=U
physics=U
ctrl=1
[State 140, Anim]
type=changeanim
trigger1= !time
value=140+(statetype=C)+(statetype=A)*2
[State 140, Type]
type=statetypeset
trigger1= !time && statetype=S
physics=S
[State 140, Type]
type=statetypeset
trigger1= !time && statetype=C
physics=C
[State 140, Type]
type=statetypeset
trigger1= !time && statetype=A
physics=A
[State 140, High to Low]
type=statetypeset
trigger1= AILevel<=0 && statetype=S && command="holddown"
trigger2= AILevel>0 && random<250
trigger2= statetype=S && (enemynear,movetype=A) && (enemynear,statetype=C)
statetype=C
physics=C
[State 140, Low to High]
type=statetypeset
trigger1= AILevel<=0 && statetype=C && command!="holddown"
trigger2= AILevel>0 && random<125
trigger2= statetype=C && (enemynear,movetype=A) && (enemynear,statetype!=C)
statetype=S
physics=S
[State 140, End]
type=changestate
trigger1= !animtime
value=(statetype=C)*11+(statetype=A)*51

;-------------------------------------------------------------------------------
;SGUARDHIT (shaking)
[Statedef 150]
type=S
movetype=H
physics=N
velset=0,0
[State 150, Anim]
type=changeanim
trigger1= 1
value=150
[State 150, End]
type=changestate
trigger1= hitshakeover
value=151+2*((AILevel<=0 && command="holddown") || (AILevel>0 && (enemynear,movetype=A) && (enemynear,statetype=C)))
[State 150, High to Low]
type=statetypeset
trigger1= AILevel<=0 && statetype=S && command="holddown"
trigger2= AILevel>0 && random<250
trigger2= statetype=S && (enemynear,movetype=A) && (enemynear,statetype=C)
statetype=C
physics=C
[State 150, Low to High]
type=statetypeset
trigger1= AILevel<=0 && statetype=C && command!="holddown"
trigger2= AILevel>0 && random<125
trigger2= statetype=C && (enemynear,movetype=A) && (enemynear,statetype!=C)
statetype=S
physics=S

;-------------------------------------------------------------------------------
;SGUARDHIT2 (knocked back)
[Statedef 151]
type=S
movetype=H
physics=S
anim=150
[State 151, Vel]
type=hitvelset
trigger1= !time
x=1
[State 151, Vel]
type=velset
trigger1= time=gethitvar(slidetime)
trigger2= hitover
x=0
[State 151, Ctrl]
type=ctrlset
trigger1= time=gethitvar(ctrltime)
value=1
[State 151, High to Low]
type=statetypeset
trigger1= AILevel<=0 && statetype=S && command="holddown"
trigger2= AILevel>0 && random<250
trigger2= statetype=S && (enemynear,movetype=A) && (enemynear,statetype=C)
statetype=C
physics=C
[State 151, Low to High]
type=statetypeset
trigger1= AILevel<=0 && statetype=C && command!="holddown"
trigger2= AILevel>0 && random<125
trigger2= statetype=C && (enemynear,movetype=A) && (enemynear,statetype!=C)
statetype=S
physics=S
[State 151, End]
type=changestate
trigger1= hitover
value=130
ctrl=1

;-------------------------------------------------------------------------------
;CGUARDHIT (shaking)
[Statedef 152]
type=C
movetype=H
physics=N
velset=0,0
[State 152, Anim]
type=changeanim
trigger1= 1
value=151
[State 152, End]
type=changestate
trigger1= hitshakeover
value=151+2*((AILevel<=0 && command="holddown") || (AILevel>0 && (enemynear,movetype=A) && (enemynear,statetype=C)))
[State 152, High to Low]
type=statetypeset
trigger1= AILevel<=0 && statetype=S && command="holddown"
trigger2= AILevel>0 && random<250
trigger2= statetype=S && (enemynear,movetype=A) && (enemynear,statetype=C)
statetype=C
physics=C
[State 152, Low to High]
type=statetypeset
trigger1= AILevel<=0 && statetype=C && command!="holddown"
trigger2= AILevel>0 && random<125
trigger2= statetype=C && (enemynear,movetype=A) && (enemynear,statetype!=C)
statetype=S
physics=S

;-------------------------------------------------------------------------------
;CGUARDHIT2 (knocked back)
[Statedef 153]
type=C
movetype=H
physics=C
anim=151
[State 153, Vel]
type=hitvelset
trigger1= !time
x=1
[State 153, Vel]
type=velset
trigger1= time=gethitvar(slidetime)
trigger2= hitover
x=0
[State 153, Ctrl]
type=ctrlset
trigger1= time=gethitvar(ctrltime)
value=1
[State 153, High to Low]
type=statetypeset
trigger1= AILevel<=0 && statetype=S && command="holddown"
trigger2= AILevel>0 && random<250
trigger2= statetype=S && (enemynear,movetype=A) && (enemynear,statetype=C)
statetype=C
physics=C
[State 153, Low to High]
type=statetypeset
trigger1= AILevel<=0 && statetype=C && command!="holddown"
trigger2= AILevel>0 && random<125
trigger2= statetype=C && (enemynear,movetype=A) && (enemynear,statetype!=C)
statetype=S
physics=S
[State 153, End]
type=changestate
trigger1= hitover
value=131
ctrl=1

;-------------------------------------------------------------------------------
;AGUARDHIT (shaking)
[Statedef 154]
type=A
movetype=H
physics=N
velset=0,0
[State 154, Anim]
type=changeanim
trigger1= 1
value=152
[State 154, End]
type=changestate
trigger1= hitshakeover
value=155

;-------------------------------------------------------------------------------
;AGUARDHIT2
[Statedef 155]
type=A
movetype=H
physics=N
anim=152
[State 155, Vel]
type=hitvelset
trigger1= !time
x=1
y=1
[State 155, Vel]
type=veladd
trigger1= 1
y=const(movement.yaccel)
[State 155, Ctrl]
type=ctrlset
trigger1= time=gethitvar(ctrltime)
value=1
[State 155, Var]
type=varset
trigger1= 1
sysvar(0)=(pos y>=0 && vel y>0)
[State 155, Vel]
type=velset
trigger1= sysvar(0)
y=0
[State 155, Pos]
type=posset
trigger1= sysvar(0)
y=0
[State 155, End]
type=changestate
trigger1= sysvar(0) && inguarddist
trigger1= (AILevel<=0 && command="holdback") || AILevel>0
value=130
[State 155, End]
type=changestate
trigger1= sysvar(0)
value=52

;-------------------------------------------------------------------------------
; Lose by Time Over

[Statedef 170]
type = S
ctrl = 0
anim = 170
velset = 0,0

[State 170, 1]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 170, voice]
type = PlaySnd
trigger1 = !time
value = 9100,10+random%2
channel = 0

;WINPOSE
[Statedef 180]
type = S
ctrl = 0

[State 180, Debug];Debug winpose
type = null;changestate
trigger1 = !time
value = 184

[State 180, Perfect Winpose]
type = changestate
trigger1 = !time
trigger1 = WinPerfect
value = 184

[State 180, Time Winpose]
type = changestate
trigger1 = !time
trigger1 = WinTime
value = 183

[State 180, Hyper KO]
type = changestate
trigger1 = !time
trigger1 = NumHelper(19875)>0 ; Hyper KO
value = 182+random%4

[State 180, Special Winpose]
type = changestate
trigger1 = !time
trigger1 = var(51)=1 ; Special winpose enabled
value = 181+random%2

[State 180, Normal win]
type = ChangeState
trigger1 = var(51)!=1 ; Special winpose disabled
trigger1 = Time = 0
value =  183+random%3


;Winpose 1 - Crystal Ball
[Statedef 181]
type = S
ctrl = 0
;anim = 788
velset = 0,0
movetype = I
physics = S
sprpriority = 1

[State 784, AssertSpecial]
type = AssertSpecial
trigger1 = time>0
flag = nobardisplay
flag2 = noFG
flag3 = invisible

[State 784, bgpalfx1]
type = palfx
trigger1 = time = [0,128]
time = 256
color=256
mul=256,256,256
add = -256+2*time,-256+2*time,-256+2*time

[State 784, PosSet]
type = PosSet
trigger1 = time=1
x = 0
y = 0

[state 784, Back]
type = explod
trigger1 = time=1
anim = 786
pos = 0,60
postype=P1
sprpriority=7
ownpal = 1
removetime = -1
bindtime = -1
trans = addalpha
alpha = 64,128 ;64,256

[state 784, Majin]
type = null ;explod
trigger1 = time=1
anim = 788
pos = 0,0
postype=P1
sprpriority=2
ownpal = 1
removetime = -1
bindtime = -1

[state 784, Babidi]
type = explod
trigger1 = time=1
anim = 784
pos = 0,60
postype=P1
sprpriority=8
ownpal = 0
removetime = -1
bindtime = -1

[state 784, Front]
type = explod
trigger1 = time=1
anim = 787
pos = 0,60
postype=P1
sprpriority=9
ownpal = 1
removetime = -1
bindtime = -1
trans = addalpha
alpha = 64,128 ;64,256


[state 784, Reflection]
type = explod
trigger1 = time=1
anim = 785
pos = 0,60
postype=P1
sprpriority=10
ownpal = 1
removetime = -1
bindtime = -1

[State 784, Babidi voice]
type = PlaySnd
trigger1 = Time = 1
value = 9100,2+random%4
volume = 0
channel = 8
;abspan =
;ignorehitpause =
;persistent =

[state 784, 1]
type = assertspecial
trigger1 = time < 500
flag = roundnotover

;Winpose 1b - Enemy in Crystal ball
[Statedef 3181]
type = L
movetype = H
physics = N
sprpriority = 2

[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = !time
value = 5110

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = nobardisplay
flag2 = noBG
flag3 = noFG


[State 0, PosSet]
type = PosSet
trigger1 = 1
x = 0
y = -10 ;0
;ignorehitpause =
;persistent =

; Winpose 2 - Necromancer
[Statedef 182]
type    = S
movetype= A
physics = S
juggle  = 7
velset = 0,0
anim = 1800
ctrl = 0
sprpriority = 2
poweradd = 0

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = time>=9
flag = invisible


;BABIDI NECROMANCER
[State 9110, Babidi]
type = Helper
trigger1 = time=9 ;!time ;time=5
helpertype = normal
name = "Babidi Necromancer"
ID =   9110
stateno = 9110
pos = 160-35*facing+ceil((enemy,Pos X)), -5 ;55
postype = left
facing = facing
keyctrl = 0
ownpal = 1
supermovetime = 0
pausemovetime = 0

[State 3901, Babidi voice]  ;speech
type = PlaySnd
trigger1 = time=5
value = 9100,20+random%4
volume = 0
channel = 8

[State 3901, Babidi voice] ;hehehehe
type = PlaySnd
trigger1 = time=275
value = 9100,0
volume = 0
channel = 8
lowpriority = 1

[state 189, 1]
type = assertspecial
trigger1 = time < 500 ;300 ;180  ;May require rework
flag = roundnotover

; Winpose 2b - Raised by Babidi
[Statedef 3182]
type = L
movetype = H
physics = N
sprpriority = 2

[State 5150, 1] ;Normal anim
type = ChangeAnim
triggerall = Time = 0
triggerall = SelfAnimExist(5140)
trigger1 = (anim != [5111,5119]) && (anim != [5171,5179])
trigger2 = !SelfAnimExist(5140 + (anim % 10))
value = 5140

[State 5150, 3] ;Hit up type anim
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (anim = [5111,5119]) || (anim = [5171,5179])
trigger1 = SelfAnimExist(5140 + (anim % 10))
value = 5140 + (anim % 10)

[State 5150, 4] ;Match over anim
type = ChangeAnim
persistent = 0
trigger1 = MatchOver = 1
trigger1 = Anim = [5140,5149]
trigger1 = SelfAnimExist(anim+10)
value = anim+10

[State 5150, 5] ;Switch to 5110 if liedead anim does not exist
type = ChangeAnim
trigger1 = Time = 0
trigger1 = Anim != [5140,5159]
trigger1 = Anim != [5110,5119]
value = 5110

[State 0, ChangeState]
type = ChangeState
trigger1 = enemy,NumHelper(9110)=1
trigger1 = !animtime
value =  3183
ctrl = 0
anim = anim
;ignorehitpause =
;persistent =

; Winpose 2b - Raised by Babidi 2
[Statedef 3183]
type = L
movetype = H
physics = N
sprpriority = 2

[State 0, ChangeAnim]
type = null ;ChangeAnim
trigger1 = !time
value = 5110


[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = time = 128 ;10
value = 5120


[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = Anim=5120
trigger1 = !AnimTime
value = 0
;elem = 1
;ignorehitpause =
;persistent =

[State 0, PalFX]
type = PalFX
trigger1 = time<128
time = 1
add = 0-ceil(time/5.5),0-ceil(time/1.28),0+ceil(time/2.7)
mul = 256-ceil(time/21.3),256-ceil(time/4.0),256-ceil(time/1.21)
sinadd = -10,-10,-10,1
invertall = 0
color = 256-2*time
;ignorehitpause = 0
;persistent = 1



[State 0, PalFX]
type = PalFX
trigger1 = time=128
time = -1
add = -23,-100,47
mul = 250,224,150
sinadd = -10,-10,-10,1
invertall = 0
color = 0
;ignorehitpause = 0
;persistent = 1


;Winpose 3 - Laughing
[Statedef 183]
type = S
ctrl = 0
anim = 0
velset = 0,0
movetype = I
physics = S
sprpriority = 1


[State 200, laugh]
type = PlaySnd
trigger1 = !time
value = 9100,0
channel = 4
volume = 300

[State 0, Face]
type = Explod
trigger1 = !time && !NumExplod(195)
anim = 195
ID = 195
pos = 0,0
postype = p1
supermovetime = 0
pausemovetime = 0
removetime = -2
sprpriority = 2
ownpal = 1
bindtime = -1
scale = 1,1
removeongethit = 1
ignorehitpause = 0


[state 784, 1]
type = assertspecial
trigger1 = time < 500
flag = roundnotover

;Winpose 4 - Minions
[Statedef 184]
type = S
ctrl = 0
anim = 0
velset = 0,0
movetype = I
physics = S
sprpriority = 1


[State 200, laugh]
type = PlaySnd
trigger1 = !time
value = 184,random%2
channel = 4
volume = 300

[State 0, Face]
type = Explod
trigger1 = !time && !NumExplod(195)
anim = 195
ID = 195
pos = 0,0
postype = p1
supermovetime = 0
pausemovetime = 0
removetime = -2
sprpriority = 2
ownpal = 1
bindtime = -1
scale = 1,1
removeongethit = 1
ignorehitpause = 0

[State 3121, PlaySnd]  ;teleport SFX
type = PlaySnd
trigger1 = time=150
value = 2302,0

[State 0, Darbura]
type = Explod
trigger1 = time=150 && !NumExplod(3184)
anim = 3184
ID = 3184
pos = IfElse(FrontEdgeDist>100,floor(screenpos X)+30*facing,floor(screenpos X)-30*facing),var(54)
postype = left
facing = facing ;1
supermovetime = 0
pausemovetime = 0
removetime = -2
sprpriority = -10
shadow = -1,-1,-1 ;0,0,0
ownpal = 1
bindtime = -1
scale = 1,1
removeongethit = 1
ignorehitpause = 0


[State 0, Pui-Pui]
type = Explod
trigger1 = time=150 && !NumExplod(3185)
anim = 3185
ID = 3185
pos = IfElse(FrontEdgeDist>100,floor(screenpos X)+90*facing,floor(screenpos X)-90*facing),var(54)
postype = left
facing = facing ;1
supermovetime = 0
pausemovetime = 0
removetime = -2
sprpriority = -8
shadow = -1,-1,-1 ;0,0,0
ownpal = 1
bindtime = -1
scale = 1,1
removeongethit = 1
ignorehitpause = 0

[state 784, 1]
type = assertspecial
trigger1 = time < 300
flag = roundnotover

;Winpose 5 - Teleport out
[Statedef 185]
type = S
ctrl = 0
anim = 0
velset = 0,0
movetype = I
physics = S
sprpriority = 1


[State 200, laugh]
type = PlaySnd
trigger1 = time=60
value = 185,random%3
channel = 4
volume = 300

[State 0, Face]
type = Explod
trigger1 = time=60
anim = 195
ID = 195
pos = 0,0
postype = p1
supermovetime = 0
pausemovetime = 0
removetime = -2
sprpriority = 2
ownpal = 1
bindtime = -1
scale = 1,1
removeongethit = 1
ignorehitpause = 0

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = time = 150
id = 195
;ignorehitpause =
;persistent =

[State 0, Warp sound]
type = PlaySnd
trigger1 = time=150
value = 1800,0 ;2000,10
volume = 300
channel = 0

[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = time=170
value = 1800
;elem = 1
;ignorehitpause =
;persistent =

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = time>=180
flag = invisible


[state 784, 1]
type = assertspecial
trigger1 = time < 250
flag = roundnotover


;INTRO
[Statedef 190]
type = S
ctrl = 0

[State 190, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 0, Capture floor level]
type = VarSet
trigger1 = Time=0
var(54) = floor(ScreenPos Y)
;ignorehitpause =
;persistent =

[State 0, Capture X position start]
type = VarSet
trigger1 = Time=0
var(55) = floor(ScreenPos X)
;ignorehitpause =
;persistent =

[State 180, vs Majin]
type = ChangeState
triggerall = numenemy
triggerall = Time = 0
triggerall = (enemy,authorname="Team Z2")
trigger1 = (enemy,Name = "Vegeta Z2") && (enemy,palno = [7,12])
trigger2 = (enemy,Name = "Majin Vegeta Z2")
value = 199


[State 180, 1]
type = ChangeState
trigger1 = Time = 0
value = 191+random%4


;Intro 1 - Levitating
[Statedef 191]
type = S
ctrl = 0
anim = 191
velset = 0,0

[State 182, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 190, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 191

[State 190, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 0, PosAdd]
type = PosAdd
triggerall = Pos Y > var(52)
trigger1 = time>0
y = -1
;ignorehitpause =
;persistent =

[State 0, PosSet]
type = PosSet
trigger1 = Pos Y <= var(52)
y = var(52)
;ignorehitpause =
;persistent =


[State 190, 4] ;Change to stand state
type = ChangeState
trigger1 = Pos Y <= var(52)
value = 0

;Intro 2 - B&W Hovering
[Statedef 192]
type = S
ctrl = 0
anim = 191
velset = 0,0

[State 0, ScreenBound]
type = ScreenBound
trigger1 =  1
value = 0
movecamera = 0,0
;ignorehitpause =
;persistent =

[State 182, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 190, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 191

[State 190, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = facing = 1
trigger1 = floor(ScreenPos X) < var(55)
trigger2 = facing = -1
trigger2 = floor(ScreenPos X) > var(55)
flag = nomusic
flag2 = nobardisplay

[State 731, BGPalFX]
type = BGPalFX
trigger1 = !time
time = -1 ;101
;add = 0,0,0
;mul = 256,256,256
;sinadd = 0,0,0,10
invertall = 0
color = 0 ;256
;ignorehitpause =
;persistent =

[State 3901, Babidi voice]  ;speech
type = PlaySnd
trigger1 = time = 50 ;!time
value = 191,random%2
volume = 200
channel = 8

[State 0, Pause]
type = null;Pause
trigger1 = time=1
time = 999
movetime = 999
pausebg = 1


[State 0, PosSet]
type = PosSet
trigger1 = !time
x = -500*facing
y = var(52)-100
;ignorehitpause =
;persistent =


;Formula to find the components of a given vector AB
;V(x) = B(x) - A(x)
;V(y) = B(y) - A(y)
[State 1640, X]
Type = VarSet
Trigger1 = !time ;1
fvar(1) = 500
;Finds the Y component of the vector Player, EnemyNear
[State 1640, Y]
Type = VarSet
Trigger1 = !time
fvar(2) = 100

;Finds the vector length
;Formula of the length of a given vector AB
;|AB| = (AB(x)^2  + AB(y)^2)^1/2
[State 1640, Vector Length]
Type = VarSet
Trigger1 = !time
fvar(3) = Exp(0.5*ln((fvar(1) * fvar(1))+(fvar(2) * fvar(2))))
[State 37001, Velocity 0]
type = VelSet
trigger1 = Time = 0
x = 1.7*(Fvar(1)/fvar(3))
y = 1.7*(FVar(2)/fvar(3))

[State 0, Stop Pause]
type = null;Pause
trigger1 = facing=1
trigger1 = floor(ScreenPos X) >= var(55)
trigger2 = facing=-1
trigger2 = floor(ScreenPos X) <= var(55)
time = 0
movetime = 0
pausebg = 0

[State 731, Stop BGPalFX]
type = BGPalFX
trigger1 = facing=1
trigger1 = floor(ScreenPos X) >= var(55)
trigger2 = facing=-1
trigger2 = floor(ScreenPos X) <= var(55)
time = 0
;add = 0,0,0
;mul = 256,256,256
;sinadd = 0,0,0,10
invertall = 0
color = 256
;ignorehitpause =
;persistent =

[State 0, VelSet]
type = VelSet
trigger1 = facing=1
trigger1 = floor(ScreenPos X) >= var(55)
trigger2 = facing=-1
trigger2 = floor(ScreenPos X) <= var(55)
x = 0
;ignorehitpause =
;persistent =


[State 0, Correct position at end]
type = PosAdd
triggerall = Pos Y < var(52)
trigger1 = facing=1
trigger1 = floor(ScreenPos X) >= var(55)-35
trigger2 = facing=-1
trigger2 = floor(ScreenPos X) <= var(55)+35
y = 0.5

[State 0, Stop Y vel]
type = VelSet
trigger1 = Pos Y >= var(52)
y = 0
;ignorehitpause =
;persistent =

[State 0, Correct position at end]
type = PosSet
trigger1 = vel Y = 0
trigger1 = Pos Y >= var(52)
y = var(52)

[State 190, 4] ;Change to stand state
type = ChangeState
trigger1 = vel x = 0
trigger1 = Pos Y = var(52)
value = 0

;Intro 3 - Babidi & Friends
[Statedef 193]
type = S
ctrl = 0
anim = 191
velset = 0,0

[State 0, PosSet]
type = PosSet
trigger1 = !time
y = var(52)

[State 182, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 190, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 191

[State 190, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 200, speech]
type = PlaySnd
trigger1 = !time
value = 193,random%2
channel = 8
volume = 300

[State 0, Face]
type = Explod
trigger1 = !time && !NumExplod(195)
anim = 195
ID = 195
pos = 0,0
postype = p1
supermovetime = 0
pausemovetime = 0
removetime = -1 ;-2
sprpriority = 2
ownpal = 1
bindtime = -1
scale = 1,1
removeongethit = 1
ignorehitpause = 0

[State 3121, PlaySnd]  ;teleport SFX
type = PlaySnd
trigger1 = time=450
value = 2302,0

[State 0, Slave]
type = Explod
trigger1 = !time
anim = 3194+random%2
ID = 3194
pos = -50,-var(52)
postype = p1
facing = 1
supermovetime = 0
pausemovetime = 0
removetime = -2
sprpriority = -10
shadow = -1,-1,-1 ;0,0,0
ownpal = 1
bindtime = -1
scale = 1,1
removeongethit = 1
ignorehitpause = 0


[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = time = 430
id = 195
;ignorehitpause =
;persistent =


[State 190, 4] ;Change to stand state
type = ChangeState
trigger1 = time = 500
value = 0

;Intro 4 - Top Hat
[Statedef 194]
type = S
ctrl = 0
anim = 186
velset = 0,0

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = time<200
flag = noshadow
flag2 = invisible


[State 0, PosSet]
type = PosSet
trigger1 = !time
y = var(52)

[State 194, Top Hat]
type = Helper
trigger1 = !time
helpertype = normal
name = "Hat"
ID =   3186
stateno = 3186
pos = floor(Screenpos X),-var(52)+12 ;50 ;floor(enemynear,ScreenPos Y) ;var(54);0,0 ;160-35*facing+ceil((enemy,Pos X)), -5 ;55
postype = left
facing = facing
keyctrl = 0
ownpal = 1
supermovetime = 0
pausemovetime = 0

[State 182, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 190, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 186

[State 190, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro

[State 1001, Alakazam]
type = playsnd
trigger1 = time=190
value = 7777,10+random%7
channel = 0


[State 0, Warp sound]
type = PlaySnd
trigger1 = time=200
value = 1800,0 ;2000,10
volume = 300
channel = -1

[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = time=200
value = 1801
;elem = 1
;ignorehitpause =
;persistent =


[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = Anim=1801
trigger1 = !animtime
value = 186
;elem = 1
;ignorehitpause =
;persistent =



[State 190, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = NumHelper(3186)=1
trigger1 = Helper(3186),AnimElemTime(2)=0
value = 0

[State 190, 4] ;Change to stand state
type = ChangeState
trigger1 = !NumHelper(3186)
value = 0



;Intro X1 - Vs. Majin
[Statedef 199]
type = S
ctrl = 0
anim = 191
velset = 0,0

[State 0, PosSet]
type = PosSet
trigger1 = !time
y = var(52)

[State 182, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 190, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 191

[State 190, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = 1
flag = Intro
flag2 = nomusic

[State 200, speech]
type = PlaySnd
trigger1 = !time
value = 199,0
channel = 8
volume = 300

[State 0, Face]
type = Explod
triggerall = !NumExplod(195)
trigger1 = !time
trigger2 = time=430
;trigger3 = time=600
anim = 195
ID = 195
pos = 0,0
postype = p1
supermovetime = 0
pausemovetime = 0
removetime = -1 ;-2
sprpriority = 2
ownpal = 1
bindtime = -1
scale = 1,1
removeongethit = 1
ignorehitpause = 0

[State 1900, Power Lamp explod]
type = explod
triggerall = !NumExplod(910)
trigger1 = time = 300
anim = 910
id = 910
pos = 0,0
sprpriority = 6
bindtime = -1
ownpal = 0
removeongethit = 1
ignorehitpause = 1
facing = 1
removetime = -1 ;-2

[State 0, PlaySnd] ;power sink
type = PlaySnd
trigger1 = Time = 320
value = 2400,10
volume = 0
channel = 8

[State 0, Remove Face Explod]
type = RemoveExplod
trigger1 = time = 380
trigger2 = time = 950
id = 195
;ignorehitpause =
;persistent =

[State 0, Remove Lamp Explod]
type = RemoveExplod
trigger1 = time = 430
id = 910
;ignorehitpause =
;persistent =

[State 0, PlaySnd]  ;laugh
type = PlaySnd
trigger1 = Time = 430
value = 9100,0
volume = 0
channel = 8

[State 0, voice] ;"My majin"
type = PlaySnd
trigger1 = time=600
value = 199,1
channel = 0
volume = 300

[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = time=950
value = 199
;elem = 1
;ignorehitpause =
;persistent =


[State 170, voice] ;What???
type = PlaySnd
trigger1 = time=970
value = 9100,10+random%2
channel = 0

[State 0, Face scared]
type = Explod
trigger1 = time=1050
anim = 3199
ID = 3199
pos = 0,0
postype = p1
supermovetime = 0
pausemovetime = 0
removetime = 50
sprpriority = 3
ownpal = 1
bindtime = -1
scale = 1,1
removeongethit = 1
ignorehitpause = 0

[State 190, 4] ;Change to stand state
type = ChangeState
trigger1 = time = 1100
value = 0
;===========================================================================
;POWER CHARGE
[StateDef 900]
type = S
movetype = I
physics = S
anim = 900
velset = 0,0
ctrl = 0

[State 1000, Power]
type = PowerAdd
triggerall = (Anim=900) && (power < 3000)
trigger1 = (AILevel<=0) && (command = "hold_b") && (command = "hold_y")
trigger2 = AILevel>0
value = 5 + (time/20)

[State 4500, 1];Small sound
type = null ;PlaySnd
trigger1 = animelemtime(4)=0
value = 8,1
volume = 255
channel = 1

[State 4500, 2];long sound
type = PlaySnd
trigger1 = animelemtime(5)=0
value = 8,5 ;8,0
loop = 1
pan = 1
volume = 25
channel = 3

[State 4500, 2];long sound
type = null ;PlaySnd
trigger1 = time=130
value = 8,0
loop = 1
pan = 1
volume = 25
channel = 3

[State 4500, 1];Scream
type = PlaySnd
trigger1 = animelemtime(5)=0
value = 9100,0
volume = 500
channel = 0


[State 1000, shake]
type = EnvShake
triggerall = (anim=900) && animelemtime(5)>=0
trigger1 = !(time%4)
time=4
freq=80
ampl=1+0.02*time


[State 1000, SSJ flash]
type = PalFX
trigger1 = (anim=900) && !(time%10) && animelemtime(5)>=0
add = 40, 40, -10
sinadd = 40,40,-10,10
time = 10


[State 1900, Aura helper]
type = Helper
triggerall = !NumHelper(905)
trigger1 = animelemtime(5)=0
id = 905
name = "Charge"
pos = 0,0 ;-24,-2
postype = P1
stateno = 905
helpertype = normal
keyctrl = 0
ownpal = 1
ignorehitpause = 1

[State 1900, dust]
type = explod
trigger1 = animelemtime(5)=0
anim = 908+(var(2)=0)
id = 908
;pos = 17,5
pos = floor(screenpos X)-10*facing, var(54)
postype = left  ;p2,front,back,left,right
sprpriority = 4
bindtime = -1
ownpal = 1
removeongethit = 1
ignorehitpause = 1
facing = facing
removetime = -1

[State 1900, Power Lamp explod]
type = null ;explod
triggerall = !NumExplod(910)
trigger1 = animelemtime(5)=0
anim = 910
id = 910
pos = 0,0
sprpriority = 6
bindtime = -1
ownpal = 0
removeongethit = 1
ignorehitpause = 1
facing = 1
removetime = -1 ;-2


[State 1001, stopsnd]
type = stopsnd
trigger1 = (command != "hold_b") || (command != "hold_y") || (power >= 3000)
trigger2 = anim != 900
channel = 3
persistent = 0

[State 1000, PC-End]
type = ChangeState
triggerall = anim=900
trigger1 = (command != "hold_b") || (command != "hold_y") || (power >= 3000)
trigger2 = (AILevel>0) && (inguarddist || p2movetype=A || p2dist x<160 )
trigger3 = Power >= const(data.power) || Power >= PowerMax || RoundState != 2
value = 901
Ctrl = 0

;-------------------------------------
; End of Power Charge
[StateDef 901]
type = S
movetype = I
physics = S
ctrl = 0
anim = 901

[State 0, Remove Power Lamp]
type = RemoveExplod
trigger1 = !time
id = 910
;ignorehitpause =
;persistent =

[State 1001, full power]
type = playsnd
trigger1 = power >= 3000
value = 8,3
channel = 1
persistent = 0

[State 1001, full power voice]
type = playsnd
trigger1 = power >= 3000
value = 7777,10+random%7
channel = 0
persistent = 0


[State 1001, EndByPowMax]
type = PalFX
trigger1 = Power = 3000
time = 1
add = 255-(20*Time), 255-(20*Time), 255-(20*Time)

[State 1001, End]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;===========================================================================
; DASH COLLISION
;===========================================================================

[Statedef 950]
type = S
physics = S ;N ;AlexSin fix
movetype = A
anim = 950
ctrl = 0
velset = 0,0
sprpriority = 1

[State 0, PosSet] ;Babidi Y position fix
type = PosSet
trigger1 = 1
y = -20
;ignorehitpause =
;persistent =


[State -2, Explod]; Smoke FX
type = Explod
trigger1 = time=5 && numexplod(956)=0 && teamside = 1
anim = 956
pos = 45,0
postype = p1
removetime = -2
supermove = 1
scale = 1,1
sprpriority = 0
id = 956
bindtime = -1
ownpal = 1
ignorehitpause = 1
pausemovetime = -1

[State -2, Explod]; Collision FX
type = null;Explod
triggerall = var(2) = 0 ;solid
trigger1 = time=5 && numexplod(955)=0 && teamside = 1
anim = 955
pos = 45,-56
postype = p1
removetime = 80
supermove = 1
sprpriority = 0
id = 955
bindtime = -1
ontop = 1
ownpal = 1
ignorehitpause = 1
pausemovetime = -1

[State -2, Explod]; Collision FX
type = null ;Explod
triggerall = var(2) = 1 ;transparent
trigger1 = time=5 && numexplod(955)=0 && teamside = 1
anim = 958
pos = 45,-56
postype = p1
removetime = 80
supermove = 1
sprpriority = 0
id = 955
bindtime = -1
ontop = 1
ownpal = 1
ignorehitpause = 1
pausemovetime = -1

[state 17100,scale FX]
type = null;modifyexplod
trigger1 = numexplod(955)
scale = 0.9+0.1*sin(0.1*time),0.9+0.1*sin(0.1*time)
id = 955

[State -2, Explod]; White FG
type = Explod
trigger1 = time=5 && numexplod(957)=0 && teamside = 1
anim = 957
pos = 0,0
postype = left
removetime = 3
supermove = 1
scale = 1,1
sprpriority = 7
id = 957
bindtime = -1
ontop = 1
ownpal = 1
ignorehitpause = 1
pausemovetime = -1

[State -2, notification]
type = helper
trigger1 = time=5 && numhelper(13200)=0 && teamside = 1
helpertype=normal
stateno=13200
ID=13200
name="notif-col"
postype=p1
pos= 45,-57
ownpal=1
pausemovetime=65535
supermovetime=65535
ignorehitpause=1
facing = -1

[State 800, ABORT]
type = Changestate
trigger1 = p2stateno != 950 && p2stateno != 951 && time>=4 && time<50
value = 952
ctrl = 1

[State 1000]
type = PosAdd
trigger1 = P2bodydist X < 10
X = -8
[State 1000]
type = PosAdd
trigger1 = P2bodydist X < 25
X = -5
[State 1000]
type = PosAdd
trigger1 = P2bodydist X < 35
X = -2
[State 1000]
type = PosAdd
trigger1 = P2bodydist X < 40
X = -1

[State 1000]
type = width
trigger1 = 1
edge = 50,40

[State 800, Grab SND]
type = PlaySnd
trigger1 = time=5
value = 800,1

[State 800, Explosion SND]
type = PlaySnd
trigger1 = time=5 && teamside = 1
value = 950,0

[State 4500, 1];Scream
type = PlaySnd
trigger1 = time=5
value = 3,11
volume = 500

[State 1000, shake]
type = EnvShake
trigger1 = !(time%4)
time = 8
freq = 20
ampl = 1+0.1*time

[State 800, count]
type = VarSet
trigger1 = !time
var(30) = 0
[State 800, count]
type = VarAdd
triggerall = time<75
trigger1 = command="x" || command="y" || command="z" || command="a" || command="b" || command="c" || command="s"
trigger2 = command = "up" || command = "down" || command = "back" || command = "fwd"
var(30) = 1

[State 800, count]
type = Changestate
triggerall = time = 80
trigger1 = var(30) > enemy,var(30)
value = 951

[State 800, count]
type = Changestate
triggerall = time = 80
trigger1 = var(30) < enemy,var(30)
value = 0
ctrl = 0

[State 800, count]
type = Changestate
triggerall = time = 80
trigger1 = var(30) = enemy,var(30)
value = 105
ctrl = 0

;-----------------------------------------
;Grabbing

[Statedef 951]
type = S
movetype = A
physics = S
juggle = 15
velset = 0,0
ctrl = 0
anim = 951
sprpriority = 1
facep2 = 1
poweradd = 20

[State 800, Don't Guard]
type = attackdist
trigger1 = 1
value = 0

[State 800, hit]
type = hitdef
trigger1 = animelem=1
attr = S,NT
hitflag = M-
priority = 1,Miss
sparkno = -1
p1facing = 1
p2facing = 1
p1stateno = 801
guard.dist = 0
fall = 1
fall.recover = 0

[State 951, Abort]
type = ChangeState
trigger1 = time=5;2
value =  952
ctrl = 0
ignorehitpause = 1

;-------------------------
;Abort Dash Collision to avoid bugs
[Statedef 952]
type = S
physics = N
movetype = A
ctrl = 1
velset = 0,0
sprpriority = 2

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = 1
id = 955

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = 1
id = 956

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = 1
id = 957

[State 0, ChangeState]
type = ChangeState
trigger1 = 1
value = 0
ctrl = 1

;========================< DIZZY >=============================
[Statedef 5300]
type = S
movetype = H
physics = S
velset = 0, 0
anim = 5300

[State 5300, Timer]
type = varadd
trigger1 = time
sysfvar(4) = -1
[State 5300, Timer]
type = varadd
trigger1 = sysfvar(4) > 0
trigger1 = command = "up" || command = "down" || command = "back" || command = "fwd"
sysfvar(4) = -2
[State 5300, Timer]
type = varadd
trigger1 = sysfvar(4) > 0
trigger1 = command = "x" || command = "y" || command = "z" || command = "a" || command = "b" || command = "c"
sysfvar(4) = -1

[State 5300, Skip]
type = varset
trigger1 = !time
sysfvar(3) = 0
[State 5300, Skip]
type = varadd
trigger1 = command = "up" || command = "down" || command = "back" || command = "fwd"
trigger2 = command = "a" || command = "b" || command = "c" || command = "x" || command = "y" || command = "z"
sysfvar(3) = 1

[State 5300, Skip]
type = changeanim
trigger1 = animelemtime(animelemno(0)) > 0 && animelemtime(animelemno(0) + 1) < 0
trigger1 = animelemtime(animelemno(0) + 1) >= -sysfvar(3)
value = 5300
elem = animelemno(0) + 1
[State 5300, Skip]
type = varset
trigger1 = animelemtime(1) >= 0 && !animelemtime(animelemno(0))
sysfvar(3) = 0

[State 5300, End]
type = varset
trigger1 = sysfvar(4) < 0
sysfvar(4) = 0
[State 5300, End]
type = selfstate
trigger1 = sysfvar(4) <= 0 || time >= 300 || roundstate != 2
value = 0
ctrl = 1

;===========================================================================
;AIR DASH
;===========================================================================

[Statedef 110]
type = A
physics = N
anim = 110
velset = 0,0
ctrl = 0

[State 110, var]
type = VarSet
trigger1 = time=0
var(10)=1

[State 110, end]
type = ChangeState
trigger1 = AnimTime = 0
value = 111
ctrl = 0

;------------------------------------------
; DASH FORWARD

[Statedef 111]
type = A
physics = N
anim = 102
ctrl = 0
velset = 0,0

[State 0, CtrlSet]
type = CtrlSet
trigger1 = !NumExplod(110)
value = 1

[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "x"
anim = 15999
ID = 90000200
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "y"
anim = 15999
ID = 90000210
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "z"
anim = 15999
ID = 90000220
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "a"
anim = 15999
ID = 90000230
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "b"
anim = 15999
ID = 90000240
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "c"
anim = 15999
ID = 90000250
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "s"
anim = 15999
ID = 90000195
removetime = 3
pausemovetime = 3
supermovetime = 3

[State 41, Train]
type = AfterImage
trigger1 = Time = 0
time= 30
timegap= 1
framegap= 3
length= 12
palbright= 0,0,0
paladd= 0,0,0
palmul= .9,.9,.9
palcontrast= 120,120,120
palpostbright= 0,0,0
trans= add1

[State 100, 7]
type = Explod
trigger1 = Time = 0
Anim = 8050
postype = P1
pos = -10,-20
scale = 0.5,0.5 ;1,.8
bindtime = 15
sprpriority = 2
ownpal = 1
removetime = -2
removeongethit = 1

[State 111, 1]
type = VelSet
trigger1 = time=0
x = 9

[State 115, dash Sound]
type = PlaySnd
trigger1 = time=0
value = 100,0

[State 111, 1]
type = VelAdd
trigger1 = time>=5 && vel X>=0
x = -0.3

[State 111, 1]
type = StateTypeSet
trigger1 = time >= 5
physics = A

[State 111, 1]
type = ChangeState
triggerall = time > 7
trigger1 = command != "holdfwd" || time = 15
value = 50

[State 111, end]
type = ChangeState
trigger1 = Vel Y > 0 && Pos Y >= 0
value = 112

;------------------------------------------
;LAND FROM AERIAL DASH FORWARD
[Statedef 112]
type    = S
movetype= I
physics = S
ctrl = 0
anim = 103

[State 115, 1]
type = VelSet
trigger1 = Time = 0
x = 15
y = 0

[State 115, 3]
type = VelAdd
trigger1 = Time > 0
x = .15

[state 115, 2]
type = posset
trigger1 = time = 0
y = 0

[State 115, Landing Sound]
type = PlaySnd
trigger1 = animelem = 2
value = 52,0

[State 115, e]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;-----------------------------------------
;AIR DASH BACK
[Statedef 115]
type = A
movetype = I
physics = N
anim = 115
ctrl = 0
velset = 0,0

[State 0, CtrlSet]
type = CtrlSet
trigger1 = !NumExplod(110)
value = 1

[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "x"
anim = 15999
ID = 90000200
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "y"
anim = 15999
ID = 90000210
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "z"
anim = 15999
ID = 90000220
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "a"
anim = 15999
ID = 90000230
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "b"
anim = 15999
ID = 90000240
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "c"
anim = 15999
ID = 90000250
removetime = 3
pausemovetime = 3
supermovetime = 3
[State 0, Explod]
type = Explod
trigger1 = NumExplod(110)
trigger1 = command = "s"
anim = 15999
ID = 90000195
removetime = 3
pausemovetime = 3
supermovetime = 3

[State 110, var]
type = VarSet
trigger1 = time=0
var(10)=1

[State 41, Train]
type = AfterImage
trigger1 = Time = 0
time= 30
timegap= 1
framegap= 3
length= 12
palbright= 0,0,0
paladd= 0,0,0
palmul= .9,.9,.9
palcontrast= 120,120,120
palpostbright= 0,0,0
trans= add1

[State 100, 7]
type = Explod
trigger1 = Time = 0
Anim = 8050
postype = P1
pos = 0,-20
scale = 0.5,0.5 ;1,.8
bindtime = 15
sprpriority = 2
ownpal = 1
removetime = -2
removeongethit = 1
facing = -1

[State 111, 1]
type = VelSet
trigger1 = time=0
x = -7

[State 115, dash Sound]
type = PlaySnd
trigger1 = time=0
value = 100,0

[State 111, 1]
type = VelAdd
trigger1 = time>=5 && vel X<=0
x = 0.2

[State 111, 1]
type = StateTypeSet
trigger1 = time >= 5
physics = A

[State 111, 1]
type = ChangeState
triggerall = time > 7
trigger1 = command != "holdback" || time = 10 ;15
value = 116

[State 112, end]
type = null ;ChangeState
trigger1 = Vel Y > 0 && Pos Y >= 0
value = 52

[State 0, ChangeState]
type = ChangeState
trigger1 = pos Y > (var(52)+5) ;-40 ;-25 ;-40
value = 52
ctrl = 0

;---------------------------------------------------------------------------
; Back Dash in air - modified state 50
[Statedef 116]
type    = A
physics = N ;A

[State 50, 1]
type = VarSet
trigger1 = Time = 0
sysvar(1) = 0

[State 50, 2]
type = ChangeAnim
trigger1 = Time = 0
value = 103 ;104

[State 0, ChangeState]
type = ChangeState
trigger1 = pos Y > (var(52)+5) ;-40 ;-25 ;-40
value = 52
ctrl = 0






;===========================================================================
; <<<<< SUPER JUMP >>>>>
; SJ after c.SP : 10230
; SJ Straight : 10231
; SJ Forward : 10232
; SJ Backward : 10233
; LJ West : 10240
;===========================================================================

;SUPER JUMP AFTER C.SP
[Statedef 10230]
type    = S
physics = S
anim = 40
ctrl = 0
velset = 0,0
facep2 = 1

[State 10230, Superjump Sound]
type = playsnd
trigger1 = Time = 0
value = 0,24

[State 10230, Superjump Var]
type = varset
trigger1 = Time = 0
var(22) = 1

[State 890, 2];FX
type = Explod
trigger1 = !time
Anim = 8051
postype = P1
pos = 0,-20
bindtime = 15
sprpriority = 2
ownpal = 1
removetime = -2
removeongethit = 1

[State 41, Train]
type = AfterImage
trigger1 = Time = 0
time= 30
timegap= 1
framegap= 3
length= 12
palbright= 0,0,0
paladd= 0,0,0
palmul= .9,.9,.9
palcontrast= 120,120,120
palpostbright= 0,0,0
trans= add1

[State 10230, 11]
type = VelSet
trigger1 = AnimTime = 0
x = 0.85 * Const(velocity.jump.fwd.x)
y = Const(velocity.jump.y) - 2

[State 10230, 13]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
; SUPER JUMP STRAIGHT UP

[Statedef 10231]
type    = S
physics = S
anim = 40
ctrl = 0
velset = 0,0
facep2 = 1

[State 10230, Superjump Var]
type = varset
trigger1 = Time = 0
var(22) = 1

[State 890, 2]
type = Explod
trigger1 = !time
Anim = 8051
postype = P1
pos = 0,-20
bindtime = 15
sprpriority = 2
ownpal = 1
removetime = -2
removeongethit = 1

[State 10231, Superjump Sound]
type = playsnd
trigger1 = Time = 0
value = 0,24

[State 10231, Give Player control]
type = ctrlset
trigger1 = Time = 20
value = 1

[State 41, Train]
type = AfterImage
trigger1 = Time = 0
time= 30
timegap= 1
framegap= 3
length= 12
palbright= 0,0,0
paladd= 0,0,0
palmul= .9,.9,.9
palcontrast= 120,120,120
palpostbright= 0,0,0
trans= add1

[State 10231, 11]
type = VelSet
trigger1 = AnimTime = 0
x = Const(velocity.jump.neu.x)
y = Const(velocity.jump.y) - 2.5

[State 10231, 13]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
; SUPER JUMP FORWARD

[Statedef 10232]
type    = S
physics = S
anim = 40
ctrl = 0
velset = 0,0
facep2 = 1

[State 890, 2]
type = Explod
trigger1 = !time
Anim = 8051
postype = P1
pos = 0,-20
bindtime = 15
sprpriority = 2
ownpal = 1
removetime = -2
removeongethit = 1

[State 10230, Superjump Var]
type = varset
trigger1 = Time = 0
var(22) = 1

[State 10232, Superjump Sound]
type = playsnd
trigger1 = Time = 0
value = 0,24

[State 10232, Give Player control]
type = ctrlset
trigger1 = Time = 20
value = 1

[State 41, Train]
type = AfterImage
trigger1 = Time = 0
time= 30
timegap= 1
framegap= 3
length= 12
palbright= 0,0,0
paladd= 0,0,0
palmul= .9,.9,.9
palcontrast= 120,120,120
palpostbright= 0,0,0
trans= add1

[State 10232, 11]
type = VelSet
trigger1 = AnimTime = 0
x = Const(velocity.jump.fwd.x)
y = Const(velocity.jump.y) - 2.2

[State 10232, 13]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
; SUPER JUMP BACKWARD

[Statedef 10233]
type    = S
physics = S
anim = 40
ctrl = 0
velset = 0,0
facep2 = 1

[State 890, 2]
type = Explod
trigger1 = !time
Anim = 8051
postype = P1
pos = 0,-20
bindtime = 15
sprpriority = 2
ownpal = 1
removetime = -2
removeongethit = 1

[State 10230, Superjump Var]
type = varset
trigger1 = Time = 0
var(22) = 1

[State 10233, Superjump Sound]
type = playsnd
trigger1 = Time = 0
value = 0,24

[State 10233, Give Player control]
type = ctrlset
trigger1 = Time = 20
value = 1

[State 41, Train]
type = AfterImage
trigger1 = Time = 0
time= 30
timegap= 1
framegap= 3
length= 12
palbright= 0,0,0
paladd= 0,0,0
palmul= .9,.9,.9
palcontrast= 120,120,120
palpostbright= 0,0,0
trans= add1

[State 10233, 11]
type = VelSet
trigger1 = AnimTime = 0
x = Const(velocity.jump.back.x)
y = Const(velocity.jump.y) - 2.2

[State 10233, 13]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1


;---------------------------------------------------------------------------
;P2 going to the ground from a.SK

[Statedef 651]
type = A
movetype = H
physics = N
ctrl = 0
sprpriority = -1
velset = 0,0

[State 3020, 2]
type = changeanim2
trigger1 = !time && anim !=651
value = 651

[State 4005, vel Y]
type = velset
trigger1 = time=15 ;animelemtime(2)=0
y = 8
x = -4
ignorehitpause = 1

[State 3052, Land]
type = changestate
trigger1 = Pos Y >= 0
trigger1 = Vel Y > 0
value = 652

;---------------------------------------------------------------------------
;P2 bouncing on the ground from a.SK

[Statedef 652]
type    = L
movetype= H
physics = N
velset = 0,0

[State 5100, 1]
type = VelSet
trigger1 = Time = 0
trigger1 = GetHitVar(fall.yvel) = 0
trigger1 = vel x > 1
x = 1

[State 5100, EnvShake]
type = FallEnvShake
trigger1 = Time = 0

[State 5100, Var] ;Save fall velocity
type = VarSet
trigger1 = Time = 0
sysvar(1) = floor(vel y)

[State 5100, 2] ;Hit ground anim (normal)
type = ChangeAnim
triggerall = time = 0
trigger1 = (anim != [5051,5059]) && (anim != [5061,5069])
trigger2 = !SelfAnimExist(5100 + (anim % 10))
value = 5100

[State 5100, 3] ;Hit ground anim (for hit up)
type = ChangeAnim
trigger1 = time = 0
trigger1 = (anim = [5051,5059]) || (anim = [5061,5069])
trigger1 = SelfAnimExist(5100 + (anim % 10))
value = 5100 + (anim % 10)

[State 5100, 4]
type = PosSet
trigger1 = Time = 0
y = 0

[State 5100, 5]
type = VelSet
trigger1 = Time = 0
y = 0

[State 5100, 6] ;Reduce speed
type = VelMul
trigger1 = Time = 0
x = 0.5

[State 5100, 10]
type = PlaySnd
trigger1 = Time = 1
value = f7,2

[State 5100, 5]
type = VelSet
trigger1 = AnimTime = 0
y = -7
x = -2

[State 111, 1]
type = StateTypeSet
trigger1 = AnimTime = 0
physics = A

[State 5100, 12]
type = SelfState
trigger1 = AnimTime = 0
value = 5050


;========================< THROW ESCAPE >=============================
;Throw Escape
[Statedef 5940]
type = S
movetype = H
physics = S
velset = 0, 0

[State 0, SelfState]
type = SelfState
trigger1 = !Time
value = Cond(Var(0)=1,950,5949)
ignorehitpause = 1

[Statedef 5949]
type = S
movetype = H
physics = S
velset = 0, 0
anim = 5940

[State 950, PosAdd 1]
type = PosAdd
trigger1 = Time <=10
trigger1 = P2bodydist X < 10
X = -8
[State 950, PosAdd 2]
type = PosAdd
trigger1 = Time <=10
trigger1 = P2bodydist X < 25
X = -5
[State 950, PosAdd 3]
type = PosAdd
trigger1 = Time <=10
trigger1 = P2bodydist X < 35
X = -2
[State 950, PosAdd 4]
type = PosAdd
trigger1 = Time <=10
trigger1 = P2bodydist X < 40
X = -1

[State 950, Width]
type = Width
trigger1 = Time <=10
edge = 50,40

[State 41, Train]
type = AfterImage
trigger1 = Time = 10
time= 30
timegap= 1
framegap= 3
length= 12
palbright= 0,0,0
paladd= 0,0,0
palmul= .9,.9,.9
palcontrast= 120,120,120
palpostbright= 0,0,0
trans= add1

[State 115, dash Sound]
type = PlaySnd
trigger1 = time=0
value = 100,0

[State 111, 1]
type = VelSet
trigger1 = time>=11
x = -7

[State 111, 1]
type = StateTypeSet
trigger1 = time > 20
movetype = I

[State 111, 1]
type = SelfState
trigger1 = time =20
value = 0
ctrl = 1
;===========================================================================
; CHEAP KO
;===========================================================================

[Statedef 5950]
physics = S
movetype = H
ctrl = 0
velset = 0,0

[State 5950, 1]
type = HitVelSet
trigger1 = Time = 0
x = 2

[State 5950, 4]
type = VelSet
trigger1 = HitOver
x = 0

[State 5950, 4]
type = NotHitBy
trigger1 = 1
value = SCA

[State 5950, 4]
type = ChangeAnim
trigger1 = !HitOver
value = ifElse(FVar(1)=0,5000,5020)

[State 190, 4]
type = ChangeAnim
trigger1 = HitOver
value = 5950
persistent = 0

[State 5950, 4]
type = PosAdd
trigger1 = AnimElemTime(5) = 0 && anim=5950
X = -30

[State 1100, ChangeState]
type = ChangeState
trigger1 = !Animtime
value = 5150

;================================================
;Killed by Chou Kamehameha (Fatality)

[Statedef 5941]
type    = S
movetype= I
physics = N
ctrl = 0
sprpriority = 7
facep2 = 1

[State 2260, bg]
type = assertspecial
trigger1 = 1
flag = noFG
flag2 = noBG
flag3 = nobardisplay
ignorehitpause = 1

[State 4005, vel Y]
type = posset
trigger1 = !time
x = ifelse(facing=1, -80, 80)
y = -20

[State 10000, Explod]; White BG
type = Explod
trigger1 = time = 0
anim = 2763
id = 19875
pos =  160,120
postype = left
sprpriority = 7
bindtime = -1
ownpal = 1
removetime = -2
pausemovetime = 999999
supermovetime = 999999
supermove = 1
scale = 1.50,1.50
ignorehitpause = 1
persistent = 0

[State 182, 1]
type = screenbound
trigger1 = 1
movecamera = 0,0
value = 1

[State 3000, invisibleanim]
type = ChangeAnim
trigger1 = !time
Value = 15999
ignorehitpause = 1

[State 3000, shaking]
type = PosAdd
trigger1 = time<30
X = ifelse(time%4=0,-2,ifelse(time%4=2,2,0))
ignorehitpause = 1

;[State 3000, Killed sound]
;type = PlaySnd
;trigger1 = !time
;value = 11,0

[State 1315, Vegeta]
type = explod
trigger1 = !time
anim = 5941
ID = 5941
sprpriority=7
postype = p1
pos = 0,-15
removetime=-2
ownpal=0
ignorehitpause=1
bindtime = -1
ontop = 1

[State 13300, Fadeout no selfanim]
type = PalFX
triggerall = !SelfAnimExist(5942)
trigger1 = Time = [0,30]
time = 1
add = -4*(Time),-4*(Time),-4*(Time)

[State 1315, fadeout selfanim]
type = explod
triggerall = SelfAnimExist(5942)
trigger1 = !time
anim = 5942
ID = 5942
sprpriority=7
postype = p1
pos = 0,-15
removetime=-2
ownpal=0
ignorehitpause=1
bindtime = -1
ontop = 1

[State 3000, nhb]
type = nothitby
trigger1 = 1
time = 1
value = SCA
ignorehitpause = 1

;This prevent freeze game
[State 49999, 5]
type = ChangeState
trigger1 = time >130
value = 5942

;---------------------------------------------------------------------------------------
;Prevent Freezing from Chou Kmh Kill
[Statedef 5942]
type = S
movetype= H
physics = N
velset = 0,0

[State 182, 1]
type = screenbound
trigger1 = 1
movecamera = 0,0
value = 1

[State 49999, 1]
type = LifeSet
trigger1 = 1
value = 0

[State 49999, 1]
type = PosSet
trigger1 = 1
y = 9000

[State 49999, 5]
type = ChangeAnim2
trigger1 = !time
value = 15999

[State 444, 0]
type = Changestate
trigger1 = time >=60
value = 5150

;================================================
;Killed by Chou Kamehameha (Fatality) - FULL SCREEN WALT VERSION

[Statedef 5943]
type    = S
movetype= I
physics = N
ctrl = 0
sprpriority = 7
facep2 = 1

[State 2260, bg]
type = null ;assertspecial
trigger1 = 1
flag = noFG
flag2 = noBG
flag3 = nobardisplay
ignorehitpause = 1

[State 182, 1]
type = screenbound
trigger1 = 1
movecamera = 0,0
value = 1

[State 4005, vel Y]
type = posset
trigger1 = !time
x = ifelse(facing=1, -70, 70)
y = -20

[State 3000, hit anim]
type = ChangeAnim2
trigger1 = Anim!=5943
value = 5943
ignorehitpause = 1

[State 13300, Fadeout]
type = PalFX
trigger1 = Time = [0,30]
time = 1
add = -8*(Time),-8*(Time),-8*(Time)

[State 13300, Fadeout]
type = PalFX
trigger1 = Time >= 30
time = 1
add = -256,-256,-256

[State 3000, shaking]
type = PosAdd
trigger1 = time<30
X = ifelse(time%4=0,-2,ifelse(time%4=2,2,0))
ignorehitpause = 1

[State 3000, nhb]
type = nothitby
trigger1 = 1
time = 1
value = SCA
ignorehitpause = 1

;This prevent freeze game
[State 49999, 5]
type = ChangeState
trigger1 = time >99
value = 5942

;---------------------------------------------------------------------------
; Hit Lie Dead, killed and burned
[Statedef 5944]
type  = L
movetype= H
physics = N
sprpriority = -10

[State 3010, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 0
movecamera = 0,0

[State 49999, 1]
type = PosSet
trigger1 = !time
y = 1000
[State 49999, 1]
type = PosSet
triggerall = numenemy
trigger1 = enemy,stateno=2506
y = 0

[State 8000, flash]
type = PalFX
trigger1 = !time
add = -30,-30,-30
color = 120
time = 100000

[State 5150, 1] ;Normal anim
type = ChangeAnim
triggerall = Time = 0
triggerall = SelfAnimExist(5140)
trigger1 = (anim != [5111,5119]) && (anim != [5171,5179])
trigger2 = !SelfAnimExist(5140 + (anim % 10))
value = 5140

[State 5150, 5] ;Switch to 5110 if liedead anim does not exist
type = ChangeAnim
trigger1 = Time = 0
trigger1 = Anim != [5140,5159]
trigger1 = Anim != [5110,5119]
value = 5110

[State 5150, 8]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1

[State 444, 0]
type = Changestate
trigger1 = time >=60
value = 5150
