;================================
; CNS File for SHIN SATAN by Balthazar and Jango and Cybaster
; State -2 & State -3 file
;================================


;==========================================================
[Statedef -2]
;==========================================================
;VARS USED
;Var(5) - Multikick track
;Var(6) - Multikick stuff
;Var(20) - Focus Attack
;Var(50) - Shield Randomizer
;===============================================================================
;------------              FUN VALUES        -----------------------------------
;If you received a code from Jango for contributing, paste it here! Who knows
;what'll happen?!
;===============================================================================

;================================================================================

;remove clone/ghost removal indicater
[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = P2MoveType != H
id = 991901

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

;air basic juggle limiter
[State 0, VarSet]
type = VarSet
trigger1 = P2MoveType != H
var(1) = 0

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

[State 0, PlaySnd]
type = PlaySnd
trigger1 = enemynear, stateno = 3421 && stateno = 3400
trigger1 = enemynear, anim = 5170 && enemynear,animelemtime(1) = 1
value = 15000,1
volumescale = 255
channel = -1
freqmul = 1.0
loop = 0
pan = 0
ignorehitpause = 1
persistent = 0


[State 0, Explod]
type = Explod
triggerall = numexplod(15010) = 0
trigger1 = numhelper(15010) = 1
anim = 1
ID = 15010
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = 0,0
accel = 0,0
random = 0,0
removetime = -1
pausemovetime = 0
scale = 1,1
sprpriority = 3
ontop = 0
shadow = 0,0,0
ownpal = 0
removeongethit = 0

[State 0, Helper]
type = Helper
triggerall = enemynear, alive = 0
trigger1 = numhelper(60000) = 0
helpertype = normal ;player
name = "Speshul Sauce"
ID = 60000
stateno = 60000
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 0
supermovetime = 0
pausemovetime = 0
ignorehitpause = 1
persistent = 0

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = numexplod(818) = 1
flag = invisible

[State 0, VelSet]
type = VelSet
trigger1 = numexplod(818) = 1
x = 0
y = 0
;ignorehitpause = 
;persistent = 

[State 0, VictoryQuote]
type = VictoryQuote
trigger1 = numhelper(60000) = 0
value = 0+floor(51*random/1000.0)
ignorehitpause =1
persistent =1

[State 0, VictoryQuote]
type = VictoryQuote
triggerall = numhelper(60000) = 1
trigger1 = helper(60000),var(1) != 0
value = 51+(helper(60000),var(1)) ; 1~99
ignorehitpause =1
persistent =1


[State 0, RemapPal]
type = RemapPal
triggerall = numhelper(777719) = 0
trigger1 = !time
source = 3038,1
dest = 3038,0
ignorehitpause =1
persistent = 1

[State 0, RemapPal]
type = RemapPal
triggerall = numhelper(777719) = 0
trigger1 = !time
source = 3038,0
dest = 3038,0
ignorehitpause =1
persistent = 1

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = movetype = H 
id = 3010

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = !time 
trigger1 = movetype = H 
id = 3020

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = movetype = H 
trigger1 = !time 
id = 3030

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = movetype = H 
trigger1 = !time 
id = 3040

[State -2, Helper]
type = Helper
triggerall = enemynear, name!="Shin Satan Z2"
triggerall = roundstate <= 2
trigger1 = var(58) >= 1 && alive = 1
trigger1 = numhelper(2850) = 0
id = 2850
name = "Crowd"
pos = 200,160
postype = left    ;p2,front,back,left,right
stateno = ifelse(var(58)=234,2853,2851)
helpertype = normal
keyctrl = 0
ownpal = 1
pausemovetime = 999999

[State -2, Helper]
type = Helper
triggerall = p2name="Shin Satan Z2"
triggerall = roundstate <= 2
trigger1 = var(58) >= 1 && alive = 1
trigger1 = numhelper(2850) = 0
trigger1 = teamside = 1
id = 2850
name = "Crowd (P1 VS Mr. Satan)"
pos = -80,160
postype = left    ;p2,front,back,left,right
stateno = ifelse(var(58)=234,2853,2851)
helpertype = normal
keyctrl = 0
ownpal = 1
pausemovetime = 999999
supermovetime = 999999

[State -2, Helper]
type = Helper
triggerall = p2name="Shin Satan Z2"
triggerall = roundstate = 1
trigger1 = var(58) >= 1 && alive = 1
trigger1 = numhelper(2850) = 0
trigger1 = teamside = 2
id = 2850
name = "Crowd (P2 VS Mr. Satan)"
pos = -80,160
postype = left    ;p2,front,back,left,right
stateno = ifelse(var(58)=234,2853,2851)
helpertype = normal
keyctrl = 0
ownpal = 1
pausemovetime = 999999
supermovetime = 999999
;===============================================================================
;-------- Explod Fix by JNP-------
;===============================================================================
; FIX Reverse commands
; revised version by JNP and XG
[State -2, Explod]
type = Explod
triggerall = !NumExplod(21)
triggerall = Pos Y >=-50 && Vel Y >0
trigger1 = facing = enemy,facing
trigger2 = P2MoveType = H
trigger2 = P2BodyDist X <0
anim = 15999
removetime = -1
ID = 21

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

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

[State -2, Explod]
type = RemoveExplod
trigger1 = time = 6
trigger1 = StateType != A
trigger2 = StateNo != 52    
trigger2 = facing != enemy,facing  
trigger3 = StateNo = [1000,1130]; for air to ground states
trigger3 = facing != enemy,facing  
ID = 21

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

[State -2]
type = ScreenBound
trigger1 = enemynear,stateno = 15300
value = 1
movecamera = 0,0
ignorehitpause = 1
persistent = 1

[State -2, shield randomizer]
type = varset
triggerall = time >= 20
trigger1 = stateno != [120,155]
trigger1 = stateno != 51
trigger1 = stateno != 52
var(50) = floor(8*random/1000.0)*10
ignorehitpause = 1

[State -2, don't go too cocky star fox]
type = varset
trigger1 = var(8) >= 4
v = 8
value = 3

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

[State 0, ChangeState]
type = Null
trigger1 = command = "hype" && power >= 2000 && var(2) <= 2
value = 2800
ctrl = 0
ignorehitpause = 1
persistent = 0


[State 0, StopSnd]
type = StopSnd
trigger1 = numhelper(701) = 0
channel = 5
persistent = 1

[State 0, StopSnd]
type = StopSnd
triggerall = stateno = 0 && !time
trigger1 = prevstateno = 191
trigger2 = prevstateno = 192
trigger3 = prevstateno = 193
trigger4 = prevstateno = 194
trigger5 = prevstateno = 714
trigger6 = prevstateno = 715
trigger7 = prevstateno = 716
trigger8 = prevstateno = 717
channel = -1
persistent = 0

[State 0, StopSnd]
type = StopSnd
trigger1 = stateno = 3010
trigger1 = stateno = 3020
trigger1 = stateno = 3030
trigger1 = stateno = 3040
channel = 4
;ignorehitpause = 
;persistent = 

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = ctrl = 1
id = 3201

[State 0, Helper]
type = Helper
triggerall = !numhelper(15052)
trigger1 = enemynear,stateno=15300
helpertype = normal ;player
name = "boss plz"
ID = 15052
stateno = 15052
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 0
supermovetime = 9999999
pausemovetime = 9999999
persistent = 0

[State 0, Helper]
type = Helper
triggerall = !numhelper(12000)
trigger1 = stateno = [120,155]
helpertype = normal ;player
name = "guarding"
ID = 12000
stateno = 12000
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 0
supermovetime = 0
pausemovetime = 0
ignorehitpause = 1

[State 0, Helper]
type = Helper
triggerall = !numhelper(12400)
trigger1 = stateno = [120,155]
helpertype = normal ;player
name = "guarding item"
ID = 12400
stateno = 12400
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 0
supermovetime = 0
pausemovetime = 0
ignorehitpause = 1

[State 0, PlaySnd]
type = PlaySnd
triggerall = !time
trigger1 = var(50) = 20 && stateno = [150,155];stateno = [120,155]
;trigger1 = enemynear, movecontact
;trigger1 = !time
;trigger2 = helper, movecontact
;trigger2 = !time
value = 150,0
volumescale = 255
channel = -1
freqmul = 1.0
loop = 0
pan = 0
ignorehitpause = 1 
persistent = 0

[State 0, PlaySnd]
type = PlaySnd
triggerall = !time
trigger1 = var(50) = 30 && stateno = [150,155];stateno = [120,155]
value = 150,4
volumescale = 255
channel = -1
freqmul = 1.0
loop = 0
pan = 0
ignorehitpause =1 
persistent = 0

[State 0, PlaySnd]
type = PlaySnd
triggerall = !time
trigger1 = var(50) = 0 && stateno = [150,155];stateno = [120,155]
value = 150,7
volumescale = 255
channel = -1
freqmul = 1.0
loop = 0
pan = 0
ignorehitpause =1 
persistent = 0

[State 0, PlaySnd]
type = PlaySnd
triggerall = !time
trigger1 = var(50) = 40 && stateno = [150,155];stateno = [120,155]
value = 150,1
volumescale = 255
channel = -1
freqmul = 1.0
loop = 0
pan = 0
ignorehitpause =1 
persistent = 0

[State 0, PlaySnd]
type = PlaySnd
triggerall = time = 2
triggerall = random <= 300
trigger1 = var(50) = 40 && stateno = [150,155];stateno = [120,155]
value = 150,80+floor(2*random/1000)
volumescale = 255
channel = -1
freqmul = 1.0
loop = 0
pan = 0
ignorehitpause =1 
persistent = 0

[State 0, PlaySnd]
type = PlaySnd
triggerall = !time
trigger1 = var(50) = 50 && stateno = [150,155];stateno = [120,155]
value = 150,2
volumescale = 255
channel = -1
freqmul = 1.0
loop = 0
pan = 0
ignorehitpause =1 
persistent = 0

[State 25, PlaySnd]
type = PlaySnd
triggerall = !time
trigger1 = var(50) = 60 && stateno = [150,155]
value = 150,5
volumescale = 255
channel = -1
freqmul = 1.0
loop = 0
pan = 0
ignorehitpause =1 
persistent = 0

[State 25, PlaySnd]
type = PlaySnd
triggerall = !time
trigger1 = var(50) = 10 && stateno = [150,155];stateno = [120,155]
value = 150,8
volumescale = 255
channel = -1
freqmul = 1.0
loop = 0
pan = 0
ignorehitpause =1 
persistent = 0

[State 0, PlaySnd]
type = PlaySnd
triggerall = !time
trigger1 = var(50) = 70 && stateno = [150,155];stateno = [120,155]
value = 150,6
volumescale = 255
channel = -1
freqmul = 1.0
loop = 0
pan = 0
ignorehitpause =1 
persistent = 0

[State -3, stopsnd if skip intro]
type = stopsnd
triggerall = roundstate=2 ;stateno=0
trigger1 = prevstateno=191
channel = 8

[State 0, StopSnd]
type = StopSnd
trigger1 = !alive && !time
channel = 3

[State -2, Hype formula]
type = null
trigger1 = 1
fv = 34
value = 1+(var(8)*.22)

;[State 0, CtrlSet]
;type = Changestate
;triggerall = statetype != A
;trigger1 = enemynear, stateno = 15300
;value = 0

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

[State -2, Explod];State 5052 Twist FX
type = playsnd
trigger1 = anim=5052 && !(gametime%10)
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

;These controllers play the "hit ground" sound effect everytime the enemy hits the ground, 
;during different custom states.
[State -2, Hitting ground sound effect];Strong sound effect, first bounce.
type		= PlaySnd
triggerall	= Enemy, Time = 1
triggerall          = Enemy, MoveType = H
trigger1		= Enemy, StateNo = 652	;custom state: a.SP
trigger2		= Enemy, StateNo = 807	;custom state: bwd throw
trigger3		= Enemy, StateNo = 1557	;custom state: EX Hurricane Kick
trigger4		= Enemy, StateNo = 3632	;custom state: Lvl 0 Finisher Gekiretsu Ranbu
value		= 15000, 2
ignorehitpause	= 1
[State -2, Hitting ground sound effect];Medium sound effect, first bounce
type		= PlaySnd
triggerall	= Enemy, Time = 1
triggerall          = Enemy, MoveType = H
trigger1		= Enemy, StateNo = 1115100	;custom state: Dizzy/Stun, falling
trigger2		= Enemy, StateNo = 3765
value		= 15000, 1
ignorehitpause	= 1
[State -2, Hitting ground sound effect];Weak sound effect, second bounce
type		= PlaySnd
triggerall	= Enemy, Time = 1
triggerall          = Enemy, MoveType = H
trigger1		= Enemy, StateNo = 1115110	;custom state: Dizzy/Stun, falling
trigger2		= Enemy, StateNo = 2785	;custom state: Lvl 0 Finisher Gekiretsu Ranbu (second bounce)
trigger3		= Enemy, StateNo = 3767
value		= 15000, 0
ignorehitpause	= 1

[State 810, 2] ;P2 Hit Ground Spark (front)
type = Explod
triggerall = numtarget
trigger1 = target,StateNo=718 && !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 = numtarget
trigger1 = target,StateNo=718 && !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 -2, P2 Hit Wall Spark (front)]
type		= Explod
triggerall	= NumTarget
trigger1		= Target, StateNo = 1052
trigger1		= !NumExplod(8402)
ID		= 8402
anim		= 8402
pos		= -20, -50
postype		= p2
velocity		= 0, 0
accel		= 0, 0
removetime	=-2
sprpriority	= 3
ignorehitpause	= 1
persistent	= 0
facing		=-1
[State -2, P2 Hit Wall Spark (back)]
type		= Explod
triggerall	= NumTarget
trigger1		= Target, StateNo = 1052
trigger1		= !NumExplod(8403)
ID		= 8403
anim		= 8403
pos		= -20, -50
postype		= p2
velocity		= 0, 0
accel		= 0, 0
removetime	=-2
sprpriority	=-3
ignorehitpause	= 1
persistent	= 0
facing		=-1
 
[State -2, Hitting wall sound effect]
type		= PlaySnd
triggerall          = NumTarget
triggerall	= target, StateNo = 1052
trigger1		= target, Time = 1
value		= 15000, 2



;===========================================================================
; ---------------- Stuff I stole from Pupa ---------------------------------
;============================================================================
[State -2, Tap Punch Reset]
type = VarSet
triggerall = !NumHelper(1600)
trigger1 = var(10) <= 0
trigger2 = Time = 1
trigger2 = StateNo = 0
var(10) = 0

[State -2, Shut up Pupa]
type = StopSnd
triggerall = prevstateno = 1305 && stateno != [1310,1320]
trigger1 = time = 0
channel = 0

[State -2, Tap Punch Decrement]
type = VarAdd
trigger1 = var(46) > 0
var(46) = -1

[State -2, Tap Punch Reset]
type = VarSet
trigger1 = var(46) <= 0
trigger2 = Time = 1
trigger2 = StateNo = 1000
var(46) = 0

[State -2, Tap Punch]
type=varset
trigger1= var(46)<=0
trigger2= time=1
trigger2= stateno= 1400
trigger3 = stateno = [1000,1220]
var(45)= 0

[State -2, Tap Punch]
type=varadd
triggerall= var(59)<=0
;triggerall= statetype = S
trigger1= command="b"
trigger1= var(46):=12
var(45)= 1

[State -2, Tap Punch Reset]
type = VarSet
triggerall = !NumHelper(1600)
trigger1 = var(10) <= 0
trigger2 = Time = 1
trigger2 = StateNo = 0
var(11) = 0

[State -2, Shut up Pupa]
type = StopSnd
triggerall = prevstateno = 1305 && stateno != [1310,1320]
trigger1 = time = 0
channel = 0

[State -2, Tap Punch Decrement]
type = VarAdd
trigger1 = var(48) > 0
var(48) = -1

[State -2, Tap Punch Reset]
type = VarSet
trigger1 = var(48) <= 0
trigger2 = Time = 1
trigger2 = StateNo = 1000
var(47) = 0

[State -2, Tap Punch]
type=varset
trigger1= var(48)<=0
trigger2= time=1
trigger2= stateno= 1400
trigger3 = stateno = [1000,1220]
var(47)= 0

[State -2, Tap Punch]
type=varadd
triggerall= var(59)<=0
;triggerall= statetype = S
trigger1= command="x"
trigger1= var(48):=12
var(47)= 1

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

;===============================================================================
; ------- 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 = stateno=3201 && animelemtime(1)=1
trigger2 = stateno=3200 && movecontact
trigger3 = stateno=3203 && movecontact
trigger4 = numhelper(3350)
trigger5 = stateno = 3500
trigger6 = stateno = 3400
trigger7 = numhelper(3550) = 1	
trigger8 = stateno = 3010 || stateno = 3020 || stateno = 3030
trigger9 = numhelper(3465) = 1	
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=3201 && animelemtime(1)=1
trigger2 = stateno=3200 && movecontact
trigger3 = stateno=3203 && movecontact
trigger4 = numhelper(3350)
trigger5 = stateno = 3500
trigger6 = stateno = 3400
trigger7 = numhelper(3550) = 1	
trigger8 = stateno = 3010 || stateno = 3020 || stateno = 3030
trigger9 = numhelper(3465) = 1
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

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

[State -2, DisplayToClipboard]
type = DisplayToClipboard
trigger1 = (authorname="Team Z2")
text = "Mr. Satan "
ignorehitpause = 1

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

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

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

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

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

[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

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

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

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

[State -2, VarSet];Counter Hit Succesful
type = VarSet
trigger1 = var(56) = 1 && movehit ;Counter Check Ok, Move Hit Succesfully.
trigger1 = StateNo != [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 = enemy, movetype = h ;Enemy was indeed HIT, otherwise this'd be retarded.
trigger1 = var(56) = 1 && movehit  ;Move hit, Ok
trigger2 = var(56) = 1 && projhit = 1 ;Projectile hit, Ok
value = 255,255,255
time = 1
under = 1
ignorehitpause = 1
persistent = 0

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

[State -2, Explod];Counter Explod for P2 Side.
type = Explod
triggerall = NumEnemy
triggerall = var(56) = 1 && numexplod(13000) = 0 && teamside = 2 ;Counter Ok, Explod has not played, P2 Side
triggerall = enemy, movetype = h ;Enemy was indeed HIT, otherwise this'd be retarded.
triggerall = StateNo != [800,820] ;Does not activate during throws.
triggerall = StateNo != [950,951] ;Don't activate during throws.
trigger1 = movehit ;Move hits
trigger2 = projhit = 1 ;Projectile Hits
anim = 13001
pos = -82,100 ;-10-69-3
postype = right  ;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]
trigger1 = p2movetype = H
v = 27
value = 1
ignorehitpause = 1

[State -2, First Attack - if F1 is pressed]
type = VarSet
triggerall = Var(27) = 0
triggerall = RoundState = [0,1]
trigger1 = p2StateNo = [5000,5199]
trigger1 = p2movetype = H
v = 27
value = 2
ignorehitpause = 1

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

[State -2, Explod];P2 Side.
type = Explod
trigger1 = var(27)= 1 && numexplod(13100)=0 && teamside = 2
anim = 13101
pos = -117,IfElse(numexplod(13000),80,100)
postype = right  ;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

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

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

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

[State -2, Explod];P2 Side.
type = Explod
trigger1 = var(27)= 1 && numexplod(13100)=0 && teamside = 2
anim = 13101
pos = -117,ifelse(numexplod(13000),80,100)
postype = right  ;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


[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

;===============================================================================
; ------- Damage Dampener --------
;===============================================================================
 
[State -2, Counter Flag] 
type = VarSet
trigger1 = NumEnemy
fvar(8) = (EnemyNear, MoveType = A)
ignoreHitPause = 1
 
;Damage Dampener Variable (by POTS)
[State -2, Hit Count] 
type = VarAdd 
trigger1 = !IsHelper
trigger1 = MoveHit = 1 
trigger1 = !HitPauseTime 
trigger1 = !(HitDefAttr = SCA, AT) 
fvar(13) = 1 
 
[State -2, Hit Count Reset] 
type = VarSet 
trigger1 = NumEnemy && fvar(13) 
trigger1 = (EnemyNear, MoveType != H) && (EnemyNear, StateNo != 5300) 
fvar(13) = 0 
ignoreHitPause = 1
 
[State -2, Dampener] 
type = VarSet 
trigger1 = 1 
fvar(10) = ifElse(fvar(13) < 3, 24, ifElse(fvar(13) >= 23, 1, 24 - fvar(13))) / 24.0 
ignoreHitPause = 1 
 
[State -2, Dampener Limit] 
type = VarSet 
trigger1 = fvar(10) < 0 
fvar(10) = 0 
ignoreHitPause = 1 
 
[State -2, Root Dampener] 
type = VarSet 
trigger1 = 1 
fvar(11) = fvar(10) * ifElse(fvar(8), 1.2, 1) 
ignoreHitPause = 1

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

[State 0, VarSet]
type = VarSet
trigger1 = statetype != A
var(25) = 0

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = var(58) >= 234 
id = 2850

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = alive = 0
trigger2 = enemy, alive = 0
id = 2890

[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = alive = 0
trigger2 = enemy, alive = 0
id = 2893


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

[State -3, Prevent Undergound Juggles]
type= targetbind
trigger1= movehit=1
trigger1= numtarget=1 && numenemy
trigger1= (target,time<=1) && (target,ID=enemynear,ID); this is just to prevent Simul issues as usual
trigger1= !(target,hitshakeover) && (target, hitfall) && (target, pos y>0)
pos= ceil(p2dist x), ceil(-pos y); keeps P2 at the same horizontal distance, but resets his Y position
ignorehitpause= 1

[State -3, Change to second state]
type = HitOverride
trigger1 = stateno = 1600
attr = SCA,NA,SA,HA,NP,SP,HP
slot = 0
stateno = 1601
time = 1
forceair = 0
ignorehitpause = 1
persistent = 1

[state -3, varset for first state]
type = varset
trigger1 = stateno = 1600
var(20) = 1

[state -3, varset for second state]
type = varset
trigger1 = stateno = 1601
var(20) = 0

[State -3]
type = varset
trigger1 = var(58) >= 234
var(58) = 234

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

;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 -3, Landing Sound]
type = PlaySnd
triggerall = stateno = 20
trigger1 = animelemtime(3) = 1
trigger2 = animelemtime(9) = 1
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]
type = playsnd
triggerall = !numhelper(2504) && !numhelper(2505)
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
trigger3 = gethitvar(animtype)=1 ;&& random<375
trigger4 = gethitvar(animtype)=0 ;&& random<250
value = s5000,random%10
channel = 0
ignorehitpause = 1
persistent = 0

[state -3, remove afterimage]
type = afterimagetime
trigger1 = Movetype = H
trigger2 = Anim != 2000
time = 0

[State -3, Prevent Crossup]
type = width
trigger1 = 1
edge = 4,0
ignorehitpause = 1

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