;===============================================================
; AI Activation
;---------------------------------------------------------------------------
[StateDef 9741]
type = S
movetype = I
physics = N
anim = 9741
ctrl = 0

[State 9741, Safety]; Just in case your opponent is very poorly coded.
type = SelfState
trigger1 = !IsHelper
value = 0

[State 9741, UglyHack]
type = VarSet
trigger1 = !var(1)
var(2) = 2

[State 9741, PauseCheck]
type = VarSet
trigger1 = GameTime > Parent,var(57)
trigger2 = !(Parent,Alive)
trigger3 = RoundState != 2
trigger4 = Parent,var(55)
trigger5 = var(3):=0
var(2) = (var(3):=1)+(var(4):=0)

[State 9741, Facing]
type = Turn
trigger1 = var(9):=(Facing != Parent,Facing)
trigger1 = !(var(4):=0)

[State 9741, DirTurnOnAI]
type = ParentVarSet
triggerall = !(var(3) || var(9))
trigger1 = Parent,command = "holdfwd"
trigger2 = Parent,command = "holdback"
trigger3 = Parent,command = "holdup"
trigger4 = Parent,command = "holddown"
trigger5 = !(var(4):=1)
var(55) = var(4)

[State 9741, DirTurnOffAI]
type = ParentVarSet
triggerall = !var(3)
triggerall = Parent,var(55)
trigger1 = command = "holdfwd"
trigger1 = Parent,command = "holdfwd"
trigger2 = command = "holdback"
trigger2 = Parent,command = "holdback"
trigger3 = command = "holdup"
trigger3 = Parent,command = "holdup"
trigger4 = command = "holddown"
trigger4 = Parent,command = "holddown"
var(55) = var(4):=0

[State 9741, ButtonTurnOnAI]
type = ParentVarSet
triggerall = !var(2)
trigger1 = Parent,command = "a"
trigger2 = Parent,command = "b"
trigger3 = Parent,command = "c"
trigger4 = Parent,command = "x"
trigger5 = Parent,command = "y"
trigger6 = Parent,command = "z"
trigger7 = Parent,command = "start"
var(55) = 1

[State 9741, ButtonTurnOffAI]
type = ParentVarSet
triggerall = !var(2)
trigger1 = command = "a"
trigger1 = Parent,command = "a"
trigger2 = command = "b"
trigger2 = Parent,command = "b"
trigger3 = command = "c"
trigger3 = Parent,command = "c"
trigger4 = command = "x"
trigger4 = Parent,command = "x"
trigger5 = command = "y"
trigger5 = Parent,command = "y"
trigger6 = command = "z"
trigger6 = Parent,command = "z"
trigger7 = command = "start"
trigger7 = Parent,command = "start"
var(55) = -1

[State 9741, UnPauseCheck]
type = VarSet
triggerall = var(2)
trigger1 = Parent,command = "a"
trigger2 = Parent,command = "b"
trigger3 = Parent,command = "c"
trigger4 = Parent,command = "x"
trigger5 = Parent,command = "y"
trigger6 = Parent,command = "z"
trigger7 = Parent,command = "start"
trigger8 = var(2) = 2
trigger8 = var(2):=0
var(2) = 2

[State 9741, Goodbye]
type = DestroySelf
triggerall = var(1):=1
trigger1 = Parent,var(55)
trigger2 = !(Parent,Alive)
trigger3 = RoundState != 2

[StateDef 9742]
type = S
movetype = I
physics = N
anim = 9741
ctrl = 0

[State 9742, Safety]; Just in case your opponent is very poorly coded.
type = SelfState
trigger1 = !IsHelper
value = 0

[State 9742, UglyHack]
type = VarSet
trigger1 = !var(1)
var(2) = var(3):=2

[State 9742, PauseCheck]
type = VarSet
trigger1 = GameTime > Parent,var(57)
trigger2 = !(Parent,Alive)
trigger3 = RoundState != 2
trigger4 = Parent,var(55)
trigger5 = var(3):=0
var(2) = var(3):=1

[State 9742, Facing]
type = Turn
trigger1 = var(9):=(Facing != Parent,Facing)

[State 9742, ParentDirCheck]
type = VarSet
trigger1 = Parent,command = "holdfwd"
trigger2 = Parent,command = "holdback"
trigger3 = Parent,command = "holdup"
trigger4 = Parent,command = "holddown"
trigger5 = var(6):=0
var(6) = 1

[State 9742, BufferCheck]
type = VarSet
trigger1 = var(3) || var(4) || var(10)
var(10) = var(6)

[State 9742, ParentButtonCheck]
type = VarSet
trigger1 = Parent,command = "a"
trigger2 = Parent,command = "b"
trigger3 = Parent,command = "c"
trigger4 = Parent,command = "x"
trigger5 = Parent,command = "y"
trigger6 = Parent,command = "z"
trigger7 = Parent,command = "start"
trigger8 = var(7):=0
var(7) = 1

[State 9742, SameButtonCheck]
type = VarSet
triggerall = var(7)
triggerall = !var(2)
triggerall = NumPartner
trigger1 = Parent,command = "a"
trigger1 = Partner,command = "a"
trigger2 = Parent,command = "b"
trigger2 = Partner,command = "b"
trigger3 = Parent,command = "c"
trigger3 = Partner,command = "c"
trigger4 = Parent,command = "x"
trigger4 = Partner,command = "x"
trigger5 = Parent,command = "y"
trigger5 = Partner,command = "y"
trigger6 = Parent,command = "z"
trigger6 = Partner,command = "z"
trigger7 = Parent,command = "start"
trigger7 = Partner,command = "start"
trigger8 = var(8):=0
var(8) = 1

[State 9742, DirTurnOnAI]
type = ParentVarSet
trigger1 = var(6)
trigger1 = !(var(9) || var(10))
var(55) = 1

[State 9742, DirTurnOffAI]
type = ParentVarSet
triggerall = var(6)
triggerall = !var(3)
triggerall = Parent,var(55)
trigger1 = command = "holdfwd"
trigger1 = Parent,command = "holdfwd"
trigger2 = command = "holdback"
trigger2 = Parent,command = "holdback"
trigger3 = command = "holdup"
trigger3 = Parent,command = "holdup"
trigger4 = command = "holddown"
trigger4 = Parent,command = "holddown"
var(55) = 0

[State 9742, ButtonTurnOnAI]
type = ParentVarSet
trigger1 = var(5) && var(7)
trigger1 = !(var(2) || var(8))
var(55) = 1

[State 9742, ButtonTurnOffAI]
type = ParentVarSet
triggerall = var(7)
triggerall = !(var(2) || var(8))
trigger1 = command = "a"
trigger1 = Parent,command = "a"
trigger2 = command = "b"
trigger2 = Parent,command = "b"
trigger3 = command = "c"
trigger3 = Parent,command = "c"
trigger4 = command = "x"
trigger4 = Parent,command = "x"
trigger5 = command = "y"
trigger5 = Parent,command = "y"
trigger6 = command = "z"
trigger6 = Parent,command = "z"
trigger7 = command = "start"
trigger7 = Parent,command = "start"
var(55) = -1

[State 9742, UnPauseCheck]
type = VarSet
triggerall = var(2)
triggerall = !var(4)
trigger1 = var(7)
trigger2 = var(2) = 2
trigger2 = var(2):=0
var(2) = 2

[State 9742, Goodbye]
type = DestroySelf
trigger1 = Parent,var(55)
trigger2 = !(Parent,Alive)
trigger3 = RoundState != 2

[State 9742, HitPauseCheck]
type = VarSet
trigger1 = var(6) || var(7)
trigger2 = !(Parent,HitPauseTime)
var(4) = Parent,HitPauseTime

[State 9742, Delay]
type = VarSet
trigger1 = var(1):=1
var(5) = !var(7)

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

; Camera control
[Statedef 7650]
physics=N
velset=0,0
anim=9741
[State 7650, bound]
type=screenbound
trigger1=1
value=0
movecamera=1,1
[State 7650, end]
type=destroyself
trigger1=roundstate=2
;---------------------------------------------------------------------------
; Manchester Gold energy glow & dust
[Statedef 2150]
type     = S
movetype = I
physics  = N
ctrl     = 0
anim     = 2150
sprpriority = 4

[State 1040, BTP]
type = BindToParent
trigger1 = Root,Anim = 2100
pos = 0,0

[State 2015, ScrBound]
type = ScreenBound
trigger1 = 1
value = 0

[State 2015, Push]
type = PlayerPush
trigger1 = 1
value = 0

[state 2150, Shad]
type = AssertSpecial
trigger1 = 1
flag = NoShadow

[state 2150, AnimFix]
type = ChangeAnim
trigger1 = Root,Anim = 2100
trigger1 = AnimElemNo(0) != Root,AnimElemNo(0) - 5
value = Anim
elem = Root,AnimElemNo(0) - 5
ignorehitpause = 1

[state 2150, Spr]
type = SprPriority
trigger1 = 1
value = 4
[State 2100, dust]
type = Explod
trigger1 = !Time
anim = 2155
ID = 2150
bindtime = -1
sprpriority = 4
ownpal = 1
pos = 0, -14
removeongethit = 1
removetime = -1
persistent = 0

[State 2100, Remove]
type = RemoveExplod
trigger1 = Root,Anim != 2100
ID = 2150
ignorehitpause = 1

[State 2100, dust2]
type = Explod
trigger1 = Root,Anim != 2100
anim = 2156
ID = 2156
bindtime = -1
sprpriority = 4
ownpal = 1
pos = 0, -14
persistent = 0

[State 2015, End]
type = DestroySelf
trigger1 = Root, Anim != 2100
;trigger1 = !NumExplod(2150)
ignorehitpause = 1
;---------------------------------------------------------------------------
; Cyclone vacuum
[Statedef 2160]
type     = S
movetype = A
physics  = N
poweradd = 0
ctrl     = 0
anim     = 2160

[State 1040, Dust1]
type = Explod
trigger1 = P2BodyDist X < 3
trigger1 = !(Time%5)
anim = 7103
ownpal = 1
sprpriority = 5
pos = -6, 0

[State 2015, PSetOnGround]
type = PosSet
trigger1 = Pos Y != 0
y = 0

[State 1150, HitBy]
type = NotHitBy
trigger1 = 1
value = SCA
[State 2015, ScrBound]
type = ScreenBound
trigger1 = 1
value = 0
[State 2015, TowardJoe]
type = Turn
trigger1 = (Facing = Parent, Facing)

[State 2015, Push]
type = PlayerPush
trigger1 = P2bodyDist X = [-5,5]
value = 1

[State 2015, VSet]
type = VelSet
trigger1 = ParentDist X >= 0
x = IfElse((Parentdist X = [0,100]), 6, IfElse((ParentDist X = [100,200]), 4.5, 3))

[State 2015, PosFix]
type = PosAdd
trigger1 = P2BodyDist X != [-5,5]
x = ceil(P2Dist X) - EnemyNear, Const(size.ground.back) - 5

[State 2015, End]
type = DestroySelf
trigger1 = Parent, Anim != 2100
trigger2 = Parent, MoveContact

;-------------------------------------------------------------------------------
;Super Combo KO effect

;Union Jack Platinum KO
[Statedef 3000]
type = S
movetype = I
physics = N
anim = 9741 ;Invisible anim

[State 3000, Explod]
type = Explod
trigger1 = !time
anim = 7018
id = 7018
pos = 0, 0
postype = left
sprpriority = -10
facing = 1
bindtime = -1
ownpal = 1
removetime = 60
supermove = 1
supermovetime = 99999999999999
pausemovetime = 99999999999999
scale = .85, 1.10
ignorehitpause = 1
persistent = 0

[State 3000, SCKO Sound]
type = Playsnd
trigger1 = !Time
value = s2000,5
channel = 5
volume = 255
ignorehitpause = 1

[State 3000, AssertSpecial]
type = AssertSpecial
trigger1 = NumExplod(7018) = 1
flag = Nobardisplay
flag2 = Noshadow
flag3 = NoFG
ignorehitpause = 1
persistent = 1

[State 3000, DestroySelf]
type = DestroySelf
trigger1 = Roundstate = 4
ignorehitpause = 1
persistent = 1

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

;Manchester Gold KO
[Statedef 3001]
type = S
movetype = I
physics = N
anim = 9741 ;Invisible anim

[State 3001, Explod]
type = Explod
trigger1 = !time
anim = 7019
id = 7019
pos = 0, 0
postype = left
sprpriority = -10
facing = 1
bindtime = -1
ownpal = 1
removetime = 60
supermove = 1
supermovetime = 99999999999999
pausemovetime = 99999999999999
scale = .85, 1.10
ignorehitpause = 1
persistent = 0

[State 3001, SCKO Sound]
type = Playsnd
trigger1 = !Time
value = s2000,5
channel = 5
volume = 255
ignorehitpause = 1

[State 3001, AssertSpecial]
type = AssertSpecial
trigger1 = NumExplod(7019) = 1
flag = Nobardisplay
flag2 = Noshadow
flag3 = NoFG
ignorehitpause = 1
persistent = 1

[State 3001, DestroySelf]
type = DestroySelf
trigger1 = Roundstate = 4
ignorehitpause = 1
persistent = 1



