;----------------------------------------------------------------------
;----------------------------------------------------------------------
;GRAB HOLD [CUSTOM STATE]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[Statedef 2416]
type    = A
movetype= H
physics = N
velset = 0,0
sprpriority = 1

[state 2416]
type = destroyself
trigger1 = ishelper

[State 2416]
type = NotHitBy
trigger1 = 1
value = SCA

[State 2416]
type = ChangeAnim2
Trigger1 = Time = 0
value = 2416

[State 2416]
type = screenbound
trigger1 = 1
value = 1
movecamera = 1

[state 2416]
type = velset
trigger1 = animelem = 1
x = -.5
y = -12

[State 2416]
type = VelAdd
Trigger1 = 1;animelem = 3,>= 0
y = .4

[State 2416]
type = lifeadd
triggerall = Vel Y > 0
trigger1 = Pos Y >= 0
value = Ceil(-0.04 * Const(data.life))
absolute = 1

[State 2416]
type = powerset
triggerall = enemynear,name="Gold Orochi"&&enemynear,palno=12
trigger1 = life <= (Ceil(0.3 * Const(data.life)))
ignorehitpause = 1
value = 0

[State 2416]
type = lifeSet
triggerall = enemynear,name="Gold Orochi"&&enemynear,palno=12
triggerall = Vel Y > 0
trigger1 = Pos Y >= 0
trigger1 = life <= (Ceil(0.3 * Const(data.life)))
value = 0

[State 2416]
type = lifeadd
triggerall = enemynear,name="Gold Orochi"&&enemynear,palno=12
triggerall = Vel Y > 0
trigger1 = Pos Y >= 0
trigger1 = life <= (Ceil(0.3 * Const(data.life)))
value = -9999999
absolute = 1

[State 2416] 
type = SelfState
triggerall = Vel Y > 0
trigger1 = Pos Y >= 0
value = 5100

;----------------------------------------------------------------------
;----------------------------------------------------------------------
;DASH ATTACK [CUSTOM REVERSAL STATE]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[statedef 2030]
type=a
movetype=h
physics=n
velset=0,0
facep2=1

[state 2030]
type=removeexplod
trigger1=name!="Gold Orochi"
trigger1=ishelper
id=-1

[state 2030]
type=destroyself
trigger1=name!="Gold Orochi"

[state 2030]
type=lifeset
trigger1=time=1
value=life-(ceil((0.005+((enemynear,name="Gold Orochi"&&(enemynear,palno=6))*0.003))*const(data.life)))
ignorehitpause=1

[state 2030]
type=lifeset
trigger1=time=1
trigger1=(numpartner=1||enemynear,name="Gold Orochi"&&enemynear,palno>10)
value=life-(ceil((0.005+((enemynear,name="Gold Orochi"&&(enemynear,palno=6))*0.003))*const(data.life)))
ignorehitpause=1

[state 2030]
type=nothitby
trigger1=1
value=sca
ignorehitpause=1

[state 2030]
type=screenbound
trigger1=1
value=1
movecamera=1
ignorehitpause=1

[state 2030]
type=changeanim2
trigger1=!time
value=2030
ignorehitpause=1

[state 2030]
type=trans
trigger1=1
trans=add1
alpha=250,70+(animelemtime(2)>=0)*110
ignorehitpause=1

[state 2030]
type=velset
trigger1=!time
x=ifelse((p2dist x<0),0.3,-0.3)
y=-0.25
ignorehitpause=1

[state 2030]
type=veladd
trigger1=1
y=0.002
ignorehitpause=1

[state 2030] 
type=changestate
trigger1=time>=11
value=2040

;----------------------------------------------------------------------
;----------------------------------------------------------------------
;DASH ATTACK [CUSTOM REVERSAL STATE 2]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[statedef 2040]
type=a
movetype=h
physics=n
sprpriority=4

[state 2040]
type=removeexplod
trigger1=name!="Gold Orochi"
trigger1=ishelper
id=-1

[state 2040]
type=destroyself
trigger1=name!="Gold Orochi"

[state 2040]
type=lifeset
trigger1=life<=(ceil(0.01*const(data.life)))
value=0
ignorehitpause=1

[state 2040]
type=playerpush
trigger1=1
value=0
ignorehitpause=1

[state 2040]
type=nothitby
trigger1=1
value=sca
ignorehitpause=1

[state 2040]
type=screenbound
trigger1=1
value=1
movecamera=1
ignorehitpause=1

[state 2040]
type=changeanim
trigger1=!time
trigger1=selfanimexist(5050)
value=5050
ignorehitpause=1

[state 2040]
type=velset
trigger1=!time
x=ifelse((p2dist x<0),3.32,-3.32)
y=-2.8
ignorehitpause=1

[state 2040]
type=veladd
trigger1=time
y=.39
ignorehitpause=1

[state 2040]
type=changestate
trigger1=vel y>0&&pos y>=0
value=2050

;----------------------------------------------------------------------
;----------------------------------------------------------------------
;DASH ATTACK [CUSTOM STATE 3]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[statedef 2050]
type=l
movetype=h
physics=n

[state 2050]
type=removeexplod
trigger1=1
id=-1

[state 2050]
type=destroyself
trigger1=name!="Gold Orochi"

[state 2050]
type=velset
trigger1=!time
trigger1=gethitvar(fall.yvel)=0&&vel x>1
x=1

[state 2050]
type=posset
trigger1=!time
y=0

[state 2050]
type=velset
trigger1=!time
y=0

[state 2050]
type=velmul
trigger1=!time
x=0.75

[state 2050]
type=fallenvshake
trigger1=!time

[state 2050]
type=varset
trigger1=!time
sysvar(1)=floor(vel y)

[state 2050]
type=changeanim
triggerall=!time
trigger1=(anim!=[5051,5059])&&(anim!=[5061,5069])
trigger2=!selfanimexist(5100+(anim%10))
value= 5100

[state 2050]
type=changeanim
trigger1=!time
trigger1=(anim=[5051,5059])||(anim=[5061,5069])
trigger1=selfanimexist(5100+(anim%10))
value=5100+(anim%10)

[state 2050]
type=screenbound
trigger1=1
value= 1
movecamera=1

[state 2050]
type=gamemakeanim
trigger1=time=1
value= 60+(sysvar(1)>5)+(sysvar(1)>14)
pos=0,0
under=sysvar(1)<=14

[state 2050]
type=playsnd
trigger1=time=1
value= F7,(sysvar(1)>5)+(sysvar(1)>14)

[state 2050]
type=posfreeze
trigger1=1

[state 2050]
type=changestate
trigger1=!time&&gethitvar(fall.yvel)=0
trigger2=!animtime
value=2060+(!time&&gethitvar(fall.yvel)=0)*10

;----------------------------------------------------------------------
;----------------------------------------------------------------------
;DASH ATTACK [CUSTOM STATE 4]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[statedef 2060]
type=l
movetype=h
physics=n

[state 2060]
type=removeexplod
trigger1=1
id=-1

[state 2060]
type=destroyself
trigger1=name!="Gold Orochi"

[state 2060]
type=posset
trigger1=!time
y=20

[state 2060]
type=veladd
trigger1=1
y=.4

[state 2060]
type=screenbound
trigger1=1
value=1
movecamera=1

[state 2060]
type=changeanim
triggerall=!time
trigger1=anim!=[5101,5109]
trigger2=!selfanimexist(5160+(anim%10))
value=5160

[state 2060]
type=changeanim
triggerall=!time
trigger1=anim=[5101,5109]
trigger1=selfanimexist(5160+(anim%10))
value=5160+(anim%10)

[state 2060]
type=hitfallvel
trigger1=!time

[state 2060]
type=changestate
trigger1=vel y>0&&pos y>=12
value=2070

;----------------------------------------------------------------------
;----------------------------------------------------------------------
;DASH ATTACK [CUSTOM STATE 5]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[statedef 2070]
type=l
movetype=h
physics=n

[state 2070]
type=removeexplod
trigger1=1
id=-1

[state 2070]
type=destroyself
trigger1=name!="Gold Orochi"

[state 2070]
type=screenbound
trigger1=1
value=1
movecamera=1

[state 2070]
type=playerpush
trigger1=1
value=0

[state 2070]
type=fallenvshake
trigger1=!time

[state 2070]
type=changeanim
trigger1=selfanimexist(5110+(anim%10))
trigger1=anim=[5081,5089]
value=5110+(anim%10)
persistent=0

[state 2070]
type=changeanim
triggerall=!time
triggerall=anim!=[5110,5119]
trigger1=anim!=[5161,5169]
trigger2=!selfanimexist(5170+(anim%10))
value=5170

[state 2070]
type=changeanim
triggerall=!time
triggerall=anim!=[5110,5119]
trigger1=anim=[5161,5169]
trigger1=selfanimexist(5170+(anim % 10))
value=5170+(anim%10)

[state 2070]
type=posset
trigger1=!time
y=0

[state 2070]
type=velset
trigger1=!time
y=0

[state 2070]
type=velmul
trigger1= 1
x=0.85

[state 2070]
type=varset
trigger1=!time
trigger1=sysvar(0)
sysvar(0)=0

[state 2070]
type= varset
trigger1=!time
trigger1=gethitvar(fall.yvel)!=0
sysvar(1)=floor(vel y)

[state 2070]
type=playsnd
trigger1=!time
trigger1=!sysvar(0)
value= F7,(sysvar(1)>5)+(sysvar(1)>14)

[state 2070]
type=gamemakeanim
trigger1=!time
trigger1=!sysvar(0)
value=60+(sysvar(1)>5)+(sysvar(1)>14)
pos=0,0
under=sysvar(1)<=14

[state 2070]
type=changeanim
triggerall=anim=[5171,5179]
triggerall=selfanimexist(5110+(anim%10))
trigger1=!animtime
trigger2=sysvar(0)
value=5110+(anim%10)
persistent=0

[state 2070]
type=changeanim
triggerall=anim!=[5111,5119]
trigger1=!animtime
trigger2=sysvar(0)
value=5110
persistent=0

[state 2070]
type=changestate
triggerall=!alive
trigger1=!animtime
trigger2=sysvar(0)
trigger3=anim=[5110,5119]
value=5150

[state 2070]
type=changestate
triggerall=alive
trigger1=time>=100
value=2080

;----------------------------------------------------------------------
;----------------------------------------------------------------------
;DASH ATTACK [CUSTOM STATE 6]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[statedef 2080]
type=l
movetype=i
physics=n

[state 2080]
type=removeexplod
trigger1=1
id=-1

[state 2080]
type=destroyself
trigger1=name!="Gold Orochi"

[state 2080]
type=screenbound
trigger1=1
value=1
movecamera=1

[state 2080] 
type=changeanim
triggerall=!time
trigger1=anim!=[5111,5119]
trigger2=!selfanimexist(5120+(anim%10))
value=5120

[state 2080]
type=changeanim
triggerall=!time
trigger1=anim=[5111,5119]
trigger1=selfanimexist(5120+(anim%10))
value=5120+(anim%10)

[state 2080]
type=velset
trigger1=!time
x=0

[state 2080]
type=nothitby
trigger1=1
value=sca
time=1

[state 2080]
type=nothitby
trigger1= !animtime
value=,nt,st,ht
time=12

[state 2080]
type=nothitby
trigger1=!animtime
value2=sca
time=3

[state 2080]
type=hitfallset
trigger1=!animtime
value=1

[state 2080]
type=selfstate
trigger1=!animtime
value=0
ctrl=1

;----------------------------------------------------------------------
;----------------------------------------------------------------------
;DASH ATTACK [CUSTOM STATE]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[statedef 2903]
type=a
movetype=h
physics=n
velset=0,0
facep2=1

[state 2903]
type=removeexplod
trigger1=1
id=-1
ignorehitpause=1

[state 2903]
type=destroyself
trigger1=name!="Gold Orochi"

[state 2903]
type=lifeset
trigger1=!time
value=life-(ceil(0.0015*const(data.life)))
ignorehitpause=1

[state 2903]
type=screenbound
trigger1=1
value=1
movecamera=1

[state 2903]
type=playerpush
trigger1=1
value=0

[state 2903]
type=changeanim
trigger1=!time
value=5070

[state 2903]
type=trans
trigger1=1
trans=add1
alpha=250,70

[state 2903]
type=changestate
trigger1=time>=12
value=2904

;----------------------------------------------------------------------
;----------------------------------------------------------------------
;DASH ATTACK [CUSTOM STATE 2]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[statedef 2904]
type=a
movetype=h
physics=n
sprpriority=4

[state 2904]
type=destroyself
trigger1=name!="Gold Orochi"

[state 2904]
type=lifeset
trigger1=!time
value=life-(ceil(0.035*const(data.life)))
ignorehitpause=1

[state 2904]
type=lifeset
trigger1=life<=(ceil(0.01*const(data.life)))
value=0
ignorehitpause=1

[state 2904]
type=playerpush
trigger1=1
value=0

[state 2904]
type=nothitby
trigger1=1
value=sca

[state 2904]
type=screenbound
trigger1=1
value=1
movecamera=1

[state 2904]
type=changeanim
trigger1=!time
value=5050

[state 2904]
type=velset
trigger1=!time
x=ifelse((p2dist x<0),3.32,-3.32)
y=-2.8

[state 2904]
type=veladd
trigger1=time
y=0.39

[state 2904]
type=changestate
trigger1=vel y>0&&pos y>=0
value=2050

;----------------------------------------------------------------------
;----------------------------------------------------------------------
;DASH ATTACK [CUSTOM STATE 3]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[statedef 2905]
type=a
movetype=h
physics=n
velset=0,0
facep2=1

[state 2905]
type=removeexplod
trigger1=1
id=-1
ignorehitpause=1

[state 2905]
type=powerset
trigger1=!time
value=0
ignorehitpause=1

[state 2905]
type=destroyself
trigger1=name!="Gold Orochi"

[state 2905]
type=lifeset
trigger1=!time
value=life-(ceil(0.25*const(data.life)))
ignorehitpause=1

[state 2905]
type=screenbound
trigger1=1
value=1
movecamera=1

[state 2905]
type=playerpush
trigger1=1
value=0

[state 2905]
type=changeanim
trigger1=!time
value=5070

[state 2905]
type=trans
trigger1=1
trans=add1
alpha=250,70

[state 2905]
type=changestate
trigger1=time>=8
value=2904

;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
;BARRAGE ATTACK [CUSTOM STATE]
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
[Statedef 9000]
type    = S
movetype= H
physics = N
velset = 0,0

[State 9000]
type = lifeadd
trigger1 = time = 0
ignorehitpause = 1
value = -(Ceil(0.01 * Const(data.life)))
absolute = 1

[State 9000]
type = lifeset
triggerall = enemynear,name="Gold Orochi"&&enemynear,palno=12
trigger1 = life <= (Ceil(0.3 * Const(data.life)))
ignorehitpause = 1
value = 0

[State 9000]
type = powerset
triggerall = enemynear,name="Gold Orochi"&&enemynear,palno=12
trigger1 = life <= (Ceil(0.3 * Const(data.life)))
ignorehitpause = 1
value = 0

[State 9000]
type = lifeadd
trigger1 = life <= (Ceil(0.05 * Const(data.life)))
value = -9999999
absolute = 1

[State 9000]
type = VarRangeSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
value = 0

[State 9000]
type = VarRangeSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
fvalue = 0
IgnoreHitPause = 1

[State 9000]
type = VarSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
sysvar(1) = 0
IgnoreHitPause = 1

[State 9000]
type = VarSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
sysvar(2) = 0
IgnoreHitPause = 1

[State 9000]
type = VarSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
sysvar(3) = 0
IgnoreHitPause = 1

[State 9000]
type = VarSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
sysvar(4) = 0
IgnoreHitPause = 1

[state 9000]
type = destroyself
trigger1 = ishelper

[State 9000]
type = ScreenBound
trigger1 = stateno = 2999
trigger1 = 1
movecamera = 0,0

[State 9000]
type = PalFX
trigger1 = GameTime % 2
time = 1
add = 0,15,75
color = 0
invertall = 1

[State 9000]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) != [3,5]
value = ifelse((GetHitVar(groundtype) = 1),5000,5010) + GetHitVar(animtype)

[State 9000]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5030

[State 9000]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5047 + GetHitVar(animtype) ;5051 - 4 + type

[State 9000]
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 9000]
type = StateTypeSet
trigger1 = Time = 0
trigger1 = GetHitVar(yvel) != 0 && GetHitVar(fall)
trigger2 = Pos Y != 0
value = a

[State 9000]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0
value = 9001

[State 9000]
type = ChangeState
trigger1 = HitShakeOver
value = 9030

[State 9000, FFB Light]
type = ForceFeedback
trigger1 = anim = 5000
trigger2 = anim = 5010
persistent = 0
time = 6
waveform = square

[State 9000, FFB Medium]
type = ForceFeedback
trigger1 = anim = 5001
trigger2 = anim = 5011
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 9000, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5012
trigger2 = anim = 5002
trigger3 = anim = 5030
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

;----------------------------------------------------------------------
;----------------------------------------------------------------------
;BARRAGE ATTACK [CUSTOM STATE END]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[Statedef 9001]
type    = S
movetype= H
physics = S

[State 9000]
type = ScreenBound
trigger1 = stateno = 2999
trigger1 = 1
movecamera = 0,0

[State 9001]
type = PalFX
trigger1 = GameTime % 2
time = 1
add = 0,15,75
color = 0
invertall = 1

[State 9001]
type = HitVelSet
trigger1 = Time = 0
x = 1

[State 9001]
type = ChangeAnim
trigger1 = AnimTime = 0
value = 5005 + GetHitVar(animtype) + (GetHitVar(groundtype)=2)*10

[State 9001]
type = VelMul
trigger1 = Time >= GetHitVar(slidetime)
x = .6

[State 9001]
type = VelSet
trigger1 = HitOver
x = 0

[State 9001]
type = DefenceMulSet
trigger1 = HitOver
value = 1

[State 9001]
type = SelfState
trigger1 = HitOver
value = 0
ctrl = 1

;----------------------------------------------------------------------
;----------------------------------------------------------------------
;PILLAR ATTACK [CUSTOM STATE]
;----------------------------------------------------------------------
;----------------------------------------------------------------------
[Statedef 14200]
type    = A
movetype= H
physics = N
velset = 0,0
sprpriority = 1

[State 14200]
type = VarRangeSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
value = 0

[State 14200]
type = VarRangeSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
fvalue = 0
IgnoreHitPause = 1

[State 14200]
type = VarSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
sysvar(1) = 0
IgnoreHitPause = 1

[State 14200]
type = VarSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
sysvar(2) = 0
IgnoreHitPause = 1

[State 14200]
type = VarSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
sysvar(3) = 0
IgnoreHitPause = 1

[State 14200]
type = VarSet
trigger1 = enemynear,name="Gold Orochi"&&enemynear,fvar(37)=1&&!ishelper&&name!="Gold Orochi"
sysvar(4) = 0
IgnoreHitPause = 1

[State 14200]
type = AssertSpecial
trigger1 = time <= 25
flag = invisible

[State 14200]
type = screenbound
trigger1 = 1
value = 1
movecamera = 1

[State 14200]
type = ChangeAnim
Trigger1 = Time = 0
value = 5050

[State 14200]
type = NotHitBy
trigger1 = 1
value = SCA

[state 14200]
type = velset
trigger1 = time = 0
x = 0
y = -60

[state 14200]
type = veladd
trigger1 = 1
y = 1.4

[State 14200] 
type = lifeadd
triggerall = Vel Y > 0
trigger1 = Pos Y >= 0
value = -(Ceil(0.06 * Const(data.life)))
absolute = 1

[State 14200]
type = lifeset
triggerall = enemynear,name="Gold Orochi"&&enemynear,palno=12
triggerall = Vel Y > 0
trigger1 = Pos Y >= 0
trigger1 = life <= (Ceil(0.3 * Const(data.life)))
ignorehitpause = 1
value = 0

[State 14200]
type = powerset
triggerall = enemynear,name="Gold Orochi"&&enemynear,palno=12
trigger1 = life <= (Ceil(0.3 * Const(data.life)))
ignorehitpause = 1
value = 0

[State 14200]
type = EnvShake
triggerall = Vel Y > 0
trigger1 = Pos Y >= 0
time = 10
ampl = -5
freq = 95
phase = 95

[State 14200] 
type = SelfState
triggerall = Vel Y > 0
trigger1 = Pos Y >= 0
value = 5100 