;---------------------------------------------------------------------------
; Override common states (use same number to override) :
;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; States that are always executed (use statedef -2)
;---------------------------------------------------------------------------
[Statedef -2]

[State -2, Variables]
type = DisplayToClipboard
trigger1 = 1
text = "Charge X: %d     Charge Y: %d     2nd Shot: %d     Blade: %d \nSuper Mode: %d"
params = Var(30), Var(31), Var(32), Var(35), Var(55)
ignorehitpause = 1

;=========================
;-------------------------
; RAPID FIRE OPTION. DO
; NOT ABUSE THIS FEATURE.
;-------------------------
; 0 Disables rapid fire. 
; 1 Enables rapid fire.
;-------------------------
[State -2, VarSet]
type = VarSet
trigger1 = 1
ignorehitpause = 1
var(3) = 0
;-------------------------
;=========================

;=========================
;-------------------------
; CPU AI can go off screen
; during arcade mode matches.
;-------------------------
[State -2, ScreenBound]
type = ScreenBound
triggerall = Var(20) < 0
trigger1 = IsHomeTeam = 1
trigger1 = TeamSide = 2
trigger2 = IsHomeTeam = 1
trigger2 = MatchNo > 1
ignorehitpause = 1
movecamera = 0,0
value = 0
;-------------------------
;=========================

;----- Stand Upright -----
[State -2, VarSet]
type = VarSet
trigger1 = StateNo = 194
trigger2 = StateNo = 196
trigger2 = Time > 100
trigger3 = Var(20) < 0
trigger4 = Var(55) > 0
ignorehitpause = 1
var(59) = 0

[State -2, VarSet]
type = VarSet
triggerall = Var(20) >= 0
triggerall = Var(55) <= 0
trigger1 = StateNo = 195
ignorehitpause = 1
var(59) = 1
;-------------------------

;----- Stop Charge -----
[State -2, RemoveExplod]
type = RemoveExplod
trigger1 = PrevStateNo = 196
ignorehitpause = 1

[State -2, Sound]
type = StopSnd
trigger1 = PrevStateNo = 196
channel = 1

[State -2, Sound]
type = StopSnd
trigger1 = PrevStateNo = 196
channel = 3
;-------------------------

;----- No KO Slow -----
[State -2, 1]
type = AssertSpecial
trigger1 = 1
ignorehitpause = 1
flag = NoKOSlow
;--------------------

;----- AfterImage -----
[State -2, AfterImage]
type = AfterImageTime
trigger1 = Vel X >= const(velocity.runjump.fwd.x)
ignorehitpause = 1
time = 2
;--------------------

;--------------------
; Remove Explods
[State -2, RemoveExplod]
type = RemoveExplod
triggerall = NumExplod(110) > 0
trigger1 = MoveType != A
trigger1 = StateNo != 196
ignorehitpause = 1
id = 112

[State -2, RemoveExplod]
type = RemoveExplod
triggerall = NumExplod(111) > 0
trigger1 = MoveType != A
trigger1 = StateNo != 196
ignorehitpause = 1
id = 113

[State -2, RemoveExplod]
type = RemoveExplod
triggerall = NumExplod(266) > 0
trigger1 = MoveType != A
trigger1 = StateNo != 192
trigger1 = StateNo != 196
ignorehitpause = 1
id = 266
;--------------------

;--------------------
; Super Mode
[State -2, VarSet]
type = VarSet
triggerall = Var(55) > 0
trigger1 = AnimElemNo(0) < Var(10) 
var(10) = AnimElemNo(0) - 1

[State -2, VarAdd]
type = VarAdd
triggerall = Var(55) > 0
trigger1 = AnimElemTime(AnimElemNo(0) + 1) < 0
var(10) = 1

[State -2, Speed]
type = ChangeAnim
triggerall = Var(55) > 0
triggerall = MoveType != H
triggerall = SelfAnimExist(Anim)
trigger1 = AnimElemTime(AnimElemNo(0) + 1) < 0
value = Anim
elem = Var(10)

[State -2, PosAdd]
type = PosAdd
trigger1 = Var(55) > 0
trigger1 = MoveType != H
trigger1 = StateNo < 2100
x = Vel X
y = Vel Y

[State -2, VelAdd]
type = VelAdd
triggerall = Var(55) > 0
triggerall = MoveType != H
triggerall = StateNo < 2100
trigger1 = Vel Y != 0
y = .2

[State -2, AttackMulSet]
type = AttackMulSet
trigger1 = Var(55) > 0
ignorehitpause = 1
value = 0.5

[State -2, DefenceMulSet]
type = DefenceMulSet
trigger1 = Var(55) > 0
ignorehitpause = 1
value = 0.5

[State -2, VarAdd]
type = VarAdd
trigger1 = Var(55) > 0
ignorehitpause = 1
var(55) = -1

[State -2, VarSet]
type = VarSet
trigger1 = Var(55) <= 0
trigger1 = NumHelper(995) <= 0
trigger2 = RoundState > 2
trigger2 = PalNo <= 7
ignorehitpause = 1
var(55) = 0
;--------------------

;--------------------
; Shadow Omega
[State -2, VarSet]
type = VarSet
trigger1 = Name = "Shadow Omega Zero"
trigger1 = AuthorName = "N-Mario"
ignorehitpause = 1
var(55) = 1000

[State -2, VarSet]
type = VarSet
trigger1 = Name = "Shadow Omega Zero"
trigger1 = AuthorName = "N-Mario"
ignorehitpause = 1
var(56) = 1
;--------------------

;--------------------
; Player Hit
[State -2, VarSet]
type = VarSet
trigger1 = Var(20) < 0
trigger2 = Var(46) <= 0
trigger3 = Var(46) > 100
ignorehitpause = 1
v = 46
value = 0

[State -2, VarSet]
type = VarSet
triggerall = Var(20) >= 0
trigger1 = MoveType = H
trigger1 = Time > 0
ignorehitpause = 1
v = 46
value = 100

[State -2, VarAdd]
type = VarAdd
triggerall = Var(20) >= 0
trigger1 = StateType != L
trigger1 = MoveType != H
trigger1 = Var(46) > 0
ignorehitpause = 1
v = 46
value = -1

[State -2, NotHitBy]
type = NotHitBy
triggerall = Var(20) >= 0
trigger1 = StateType != L
trigger1 = MoveType != H
trigger1 = Var(46) > 0
ignorehitpause = 1
value = SCA
time = 1

[State -2, PalFX]
type = PalFX
triggerall = Alive
triggerall = Var(20) >= 0
trigger1 = HitShakeOver = 0
trigger1 = MoveType = H
trigger1 = Time <= 0
trigger2 = StateType != L
trigger2 = MoveType != H
trigger2 = GameTime % 4 = 0
trigger2 = Var(46) > 0
ignorehitpause = 1
time = 2
add = 250,250,250
;--------------------

;--------------------
; Armor Code
[State -2, AssertSpecial]
type = AssertSpecial
trigger1 = 1
ignorehitpause = 1
flag = NoStandguard
flag2 = NoCrouchguard
flag3 = NoAirguard

[State -2, Vel X]
type = VarSet
trigger1 = MoveType != H
trigger1 = Time > 0
ignorehitpause = 1
fv = 30
value = Vel X

[State -2, Vel Y]
type = VarSet
trigger1 = MoveType != H
trigger1 = Time > 0
ignorehitpause = 1
fv = 31
value = Vel Y

[State -2, StateNo]
type = VarSet
trigger1 = MoveType != H
trigger1 = Time > 0
ignorehitpause = 1
v = 40
value = StateNo

[State -2, Anim]
type = VarSet
trigger1 = MoveType != H
trigger1 = Time > 0
ignorehitpause = 1
v = 41
value = Anim

[State -2, AnimElemNo]
type = VarSet
trigger1 = MoveType != H
trigger1 = Time > 0
ignorehitpause = 1
v = 42
value = AnimElemNo(0)

[State -2, Ctrl]
type = VarSet
trigger1 = MoveType != H
trigger1 = Time > 0
ignorehitpause = 1
v = 43
value = Ctrl

[State -2, VarSet]
type = VarSet
triggerall = RoundState >= 2
triggerall = MoveType != H
trigger1 = StateTime <= 1
ignorehitpause = 1
var(44) = -1

[State -2, VarAdd]
type = VarAdd
trigger1 = RoundState >= 2
trigger1 = MoveType != H
ignorehitpause = 1
var(44) = 1

[State -2, VarSet]
type = VarSet
trigger1 = Var(20) >= 0
trigger2 = Var(45) <= 0
trigger3 = Var(45) > 100
ignorehitpause = 1
v = 45
value = 0

[State -2, VarSet]
type = VarSet
triggerall = Var(20) < 0
triggerall = Var(45) <= 0
trigger1 = MoveType = H
trigger1 = Time > 0
ignorehitpause = 1
v = 45
value = 100

[State -2, VarAdd]
type = VarAdd
triggerall = Var(20) < 0
trigger1 = StateType != L
trigger1 = MoveType != H
trigger1 = Var(45) > 0
ignorehitpause = 1
v = 45
value = -1

[State -2, NotHitBy]
type = NotHitBy
triggerall = Var(20) < 0
trigger1 = Var(45) > 0
trigger1 = Var(45) <= 80
trigger1 = MoveType != H
ignorehitpause = 1
value = SCA
time = 1

[State -2, HitOverride]
type = HitOverride
triggerall = Var(20) < 0
trigger1 = MoveType = I
trigger2 = StateNo = 2000
attr = SCA, AA, AT, AP
ignorehitpause = 1
stateno = 5000	; Idle Hit
time = 1

[State -2, HitOverride]
type = HitOverride
triggerall = Var(20) < 0
trigger1 = MoveType = A
trigger1 = StateNo != 2000
attr = SCA, AA, AT, AP
ignorehitpause = 1
stateno = 5005	; Attack Hit
time = 1

[State -2, HitOverride]
type = HitOverride
triggerall = Var(20) < 0
trigger1 = MoveType = H
trigger1 = Anim >= 5000
attr = SCA, AA, AT, AP
ignorehitpause = 1
stateno = 5006	; Hit
time = 1

[State -2, PalFX]
type = PalFX
triggerall = Alive
triggerall = Var(20) < 0
trigger1 = HitShakeOver = 0
trigger1 = MoveType = H
trigger1 = Time <= 0
trigger2 = Var(45) > 0
trigger2 = StateType != L
trigger2 = GameTime % 4 = 0
ignorehitpause = 1
time = 2
add = 250,250,250
;--------------------

;--------------------
; Attack identifier
[State -2, VarSet]
type = VarSet
trigger1 = MoveType != A
ignorehitpause = 1
var(1) = 0
;--------------------

;--------------------
; Can't KO CPU from F1
[State -2, VarSet]
type = VarSet
trigger1 = Var(20) < 0
trigger1 = Life > Var(50)
ignorehitpause = 1
var(50) = Life

[State -2, LifeSet]
type = LifeSet
trigger1 = Var(20) < 0
ignorehitpause = 1
value = Var(50)

[State -2, VarAdd]
type = VarAdd
trigger1 = Var(20) < 0
trigger1 = Life <= Var(50)
ignorehitpause = 1
var(50) = (-GetHitVar(Damage))
;--------------------

;--------------------
; Aura Shadow
[State -2, Helper]
type = Helper
triggerall = Alive
triggerall = Life > 0
triggerall = NumHelper(9999) = 0
trigger1 = RoundState > 0
trigger1 = RoundState < 3
trigger1 = StateNo != 180
trigger1 = StateNo != 190
trigger2 = StateNo = 190
trigger2 = Anim = 191
trigger2 = AnimElem = 9
helpertype = normal
name = "Aura Shadow"
pausemovetime = 1000000000
supermovetime = 1000000000
id = 9999
pos = 0,0
postype = p1
stateno = 9999
keyctrl = 0
ownpal = 1
;--------------------

;--------------------
; AI System
[State -2, AI]
type = Helper
trigger1 = Alive
trigger1 = Life > 0
trigger1 = Var(20) >= 0
trigger1 = NumHelper(6666) = 0
trigger1 = RoundState = 2
trigger1 = PalNo < 7
helpertype = normal
name = "AI Trigger"
pausemovetime = 1000000000
supermovetime = 1000000000
id = 6666
pos = 1000, 1000
stateno = 6666
keyctrl = 1
ownpal = 1
;--------------------

[State -2, State]
type = SelfState
triggerall = Var(20) >= 0
triggerall = StateNo < 5150 || StateNo >= 5160
trigger1 = !Alive
value = 5151

[State -2, State]
type = SelfState
triggerall = Var(20) < 0
triggerall = StateNo < 5150 || StateNo >= 5160
trigger1 = !Alive
value = 5155

;---------------------------------------------------------------------------
; States that are executed when in self's state file (use statedef -3)
;---------------------------------------------------------------------------
[Statedef -3]

;-------------------------
; No Music Until The Match.
;-------------------------
[State -3, AssertSpecial]
type = AssertSpecial
trigger1 = RoundNo <= 1
trigger1 = RoundState < 2
trigger2 = RoundsExisted = 0
trigger2 = TeamMode = Turns
trigger2 = RoundState < 2
trigger3 = MatchOver
trigger4 = RoundState > 2
trigger4 = Alive = 0
trigger4 = Lose
flag = NoMusic
;-------------------------

;--------------------
; Auto Turn Off
[State -3, 0]
type = AssertSpecial
trigger1 = Var(20) >= 0
flag = NoAutoTurn
ignorehitpause = 1

[State -3, VelSet]
type = VelSet
triggerall = Anim < 5000
triggerall = Var(20) >= 0
triggerall = MoveType != H
triggerall = Command = "holdback"
triggerall = PrevStateNo != 2502
triggerall = StateNo < 1000
triggerall = Anim != 250
triggerall = Anim != 251
triggerall = Anim != 620
triggerall = Anim != 640
trigger1 = Ctrl
trigger1 = StateType != A
trigger1 = Command != "holddown"
trigger1 = Command != "holdfwd"
trigger2 = StateType = A
trigger2 = Command != "holdfwd"
x = -Vel X

[State -3, Turn]
type = Turn
triggerall = Anim < 5000
triggerall = Var(20) >= 0
triggerall = MoveType != H
triggerall = Command = "holdback"
triggerall = PrevStateNo != 2502
triggerall = StateNo < 1000
triggerall = Anim != 250
triggerall = Anim != 251
triggerall = Anim != 620
triggerall = Anim != 640
trigger1 = Ctrl
trigger1 = StateType != A
trigger1 = Command != "holddown"
trigger1 = Command != "holdfwd"
trigger2 = StateType = A
trigger2 = Command != "holdfwd"
;--------------------

;--------------------
; Air Jump Variable
[State -3, VarSet]
type = VarSet
trigger1 = Var(5) > 0
trigger1 = StateType != A
ignorehitpause = 1
var(5) = 0

[State -3, VarSet]
type = VarSet
trigger1 = StateNo = 45
ignorehitpause = 1
var(5) = 1
;--------------------

;--------------------
; AirJump Move
[State -3, 0]
type = VelSet
triggerall = Vel Y < 0
triggerall = Var(20) >= 0
triggerall = StateType = A
triggerall = MoveType != H
triggerall = StateNo >= 40 && StateNo < 100 || StateNo >= 300 && StateNo < 1000
trigger1 = Command != "hold_a"
y = Vel Y / 2

[State -3, VelAdd]
type = VelAdd
triggerall = Vel X < const(velocity.walk.fwd.x)
triggerall = Anim != 640
triggerall = Var(20) >= 0
triggerall = StateType = A
triggerall = MoveType != H
triggerall = Command = "holdfwd"
triggerall = StateNo >= 40 && StateNo < 100 || StateNo >= 300 && StateNo < 1000
trigger1 = MoveType = A
trigger2 = Ctrl
x = .5

[State -3, VelAdd]
type = VelAdd
triggerall = Vel X > 0
triggerall = Anim != 640
triggerall = Var(20) >= 0
triggerall = StateType = A
triggerall = MoveType != H
triggerall = Command != "holdfwd"
triggerall = Command != "holdback"
triggerall = StateNo >= 40 && StateNo < 100 || StateNo >= 300 && StateNo < 1000
trigger1 = MoveType = A
trigger2 = Ctrl
x = -.05

[State -3, VelSet]
type = VelSet
triggerall = Var(20) >= 0
triggerall = StateType = A
triggerall = MoveType != H
trigger1 = Vel Y >= 10
y = 10
;--------------------
