;www.infinitymugenteam.com
; =======================================================================================
; Capcom VS System Common State File.
; The following is a copy, with modifications in the common1.cns
; M.U.G.E.N. System File, to emulate Capcom VS. System Behavior.
; It uses almost the same layout as the original file.
;
; --------- Credits ---------------------------------------------------------------------
; Thanks to the following people that made this possible:
; - Elecbyte: For the main common template system.
; - Capcom: For making the vs series and allowing using the features.
; - Chankast: For letting me analyze Marvel vs Capcom 2 carefully.
; - REDHOT: For all his help and his MvC2 sparks.
; - Kung Fu Man: For pointing out how many system vars does mugen uses.
; - Messastsu: For teaching how to use common files for your chars.
; - MGBenz: For letting me use this template for Felicia and testing.
; - Mauteck: For some MvC2 sparks used.
;
; =======================================================================================
;                                  Version revision: 4.0
; =======================================================================================
;
; System variables usage
; ----------------------
; Var name    Type   Purpose
; --------    ----   -------
; sysvar(0)   Temp   Set by state 5071-81 (HITL_SLIDE & HIT_TRIP) to 1
;                    to prevent showing ground hit frame in state 5110
;                    (HIT_LIEDOWN).
;                    Used by guarding states.
; sysvar(1)   Temp   Used by state 40 (Jump Start) amd 45 (Air Jump Start)
;                    to keep track of which way to jump.
; sysvar(2)   Temp   Free Var.
; sysvar(3)   Temp   Skips animation secuences for certain type of hits.
; sysvar(4)   Temp   Recovery Roll var, used for generic recovery roll.
;
; System float variables usage
; ----------------------------
; Var name    Type   Purpose
; --------    ----   -------
; SysFVar(0)  Temp   Used by state 5100 and 5110 to remember downward
;                    velocity of player just before hitting the ground.
; SysFVar(1)  Temp   Used to detect if enemy is on the ground when hitting
;                    you, so some animations can be set correctly and in
;                    time, used in state 5020 (Air GetHit State).
;
; The following states have special handling within MUGEN, and should be
; overridden with caution:
; Jump Start (40): airjumping bookkeeping at time = 0
; All guard states (120-155): guard handling throughout state
; Hit_trip, shaking (5070): defence increases at time = 0
; Hit_bounce (5100): defence increases at time = 0, player becomes
;                    invincible if within 10 ticks of getting up
; Hit_liedown (5110): player changes to state 5111 inmediately to avoid
;                     the button mashing getup (M.U.G.E.N. old behavior)
; Hit_liedown2 (5111): lie down state, after 15 ticks player changes into
;                      get up state (5120).
; Hit_getup (5120): player's defence is restored to normal at time = 0
;
; --- The folowing are present just to maintain compatibility with other
;     chars.
; Hit_up_t (5035): hit up transition (redirects to 5050 now)
; Hitfall_recover (5200): player's defence is restored at time = 0
; Hitfall_airrecover (5210): player's defence is restored at time = 0
;
; =======================================================================================
;
; Changelog:
; - Updated Hyper BG Helper to make it compatible with Delayed Hyper
;   Combo System (comes from vs-tagsys.st, contained on every char)
; - Corrected some constant velocities in HIT_L states, they aren't
;   dependant of the hitdefs anymore. (as they are meant to be)
; - Changed behavior in Ground, Crouch and Air GetHit states to match
;   Capcom VS System behavior (not 100% accurate though).
; - Removed original recovery controls for falling states, since this
;   feature is not used in the VS system, now in situations in which
;   you can recover, you will be able to do it automaticaly.
; - Fixed some issues in aerial gethit animations (animation not timed
;   correctly).
; - State 5035 is no longer used, now it redirects to the new VS system
;   states, maintained just for compatibility.
; - Changed behavior in HITL_SHAKE (5080) to emulate VS System behavior
;   when hitting a foe that is lying down (OTG hits). For the sake of
;   emulation, a new state and animation had been added (5082) if 5082
;   is not found, 5110 anim will be displayed instead.
; - Changed behavior in state 5100 to emulate VS system features in
;   ground hits, like bounce and auto recover from ground.
; - Modified state 5110 to avoid button mashing when lying down, now
;   it redirects to a new state (5111) which changes to either 5120
;   when alive or 5150 when you aren't when 15 tick have passed.
; - Added a new common state for Vs series: Recovery Roll, a new
;   animation is required for this one (5190), if not found 5110 anim
;   is displayed. Also is required a new set of commands for this feature,
;   which needs to be present in your char in order to get this working,
;   read the readme file to see how.
; - Coded an animation skipper for certain velocities, so the animations
;   show properly like in VS system.
;
; Animation setup
; This new system requires the following animations, most of them are
; M.U.G.E.N. default, but with minor changes to emulate Marvel System.
; Only changed anims will be listed here, others should be set like if
; you were using standard common1.cns file.
; * 5030 - Hit Diagonal Up anim (used when DiagUp anim is defined or when
;          you die. (2 frames - 1st 1 tick, 2nd infinite looptime)
; * 5035 - Hit Up transition for either DiagUp or Up anims (2 frames -
;          1st 4 ticks, 2nd 3 ticks.
; * 5050 - Hit Up: going down anim (1 frame, 3 ticks)
; * 5060 - Hit Up going down: (ending falling frames, frames will vary,
;          they should be a total of 5 or 6 tiks for the whole animation
;          a loop should be placed for the last frame(s).
; * 5082 - Roll after HITL_SLIDE (just like MvC recovery roll, but it is
;          executed after HITL_SLIDE automaticaly.
; * 5140 - This animation will be shown now when you die before your
;          partner, the clasic VS vanish animation.
; * 5150 - No changes, except that this one will be shown at the end of
;          the match.
; * 5160 - MUST have infinite looptime.
; * 5190 - Finite looptime, can be rolling or a modification for the
;          get up animation (like Magneto).
; The rest can be set like in M.U.G.E.N.'s common1.cns
; *For better results, you must use animations separated, for instance
; 5030, 5035, 5050, 5060 and so on, because the system skips some anims
; depending of the hit received and velocity.
;
; =======================================================================================



;---------------------------------------------------------------------------
;
; Normal generic states
; This can be overriden depending of the features you want for your char
;
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; Stand
[Statedef 0]
type = S
physics = S
sprpriority = 0

[State 0, 1]
type = ChangeAnim
trigger1 = Anim != 0 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0 ;Turn anim over
value = 0

[State 0, 2]
type = VelSet
trigger1 = Time = 0
y = 0

[State 0, 3] ;Stop moving if low velocity or 4 ticks pass
type = VelSet
trigger1 = abs(vel x) < 2
trigger2 = Time = 4
x = 0

[State 0, 4] ;Are you dead?
type = ChangeState
trigger1 = !alive
value = 5050

;---------------------------------------------------------------------------
; Stand to Crouch
[Statedef 10]
type    = C
physics = N
anim = 10

[State 10, 1]
type = VelSet
trigger1 = (PrevStateNo = [105, 106]) && (time = 0)
x = -6

[State 10, 2]
type = ChangeState
trigger1 = AnimTime = 0
value = 11

;---------------------------------------------------------------------------
; Crouching
[Statedef 11]
type    = C
physics = C
anim = 11
sprpriority = 0

[State 11, 1] ;Change from turning animation
type = ChangeAnim
trigger1 = Anim = 6 && AnimTime = 0
value = 11

;---------------------------------------------------------------------------
; Crouch to Stand
[Statedef 12]
type    = S
physics = S
anim = 12

[State 12, 1]
type = ChangeState
trigger1 = AnimTime = 0
value = 0

;---------------------------------------------------------------------------
; Walk
[Statedef 20]
type    = S
physics = S
sprpriority = 0

[State 20, 1]
type = VelSet
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)

[State 20, 2]
type = VelSet
trigger1 = command = "holdback"
x = const(velocity.walk.back.x)

[State 20, 3]
type = ChangeAnim
triggerall = vel x > 0
trigger1 = Anim != 20 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 20

[State 20, 4]
type = ChangeAnim
triggerall = vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 21

;---------------------------------------------------------------------------
; Jump Start
[Statedef 40]
type    = S
physics = S
anim = 40
ctrl = 0
sprpriority = 1

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

[State 40, 2]
type = VarSet
trigger1 = command = "holdfwd"
sysvar(1) = 1

[State 40, 3]
type = VarSet
trigger1 = command = "holdback"
sysvar(1) = -1

[State 40, 4]
type = VelSet
trigger1 = AnimTime = 0
x = ifelse(sysvar(1)=0, const(velocity.jump.neu.x), ifelse(sysvar(1)=1, const(velocity.jump.fwd.x), const(velocity.jump.back.x)))
y = const(velocity.jump.y)

[State 40, 5]
type = VelSet
trigger1 = AnimTime = 0
trigger1 = prevstateno = 100 ;RUN_FWD
trigger1 = sysvar(1) = 1
x = const(velocity.runjump.fwd.x)

[State 40, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 50
ctrl = 1

;---------------------------------------------------------------------------
; AirJump Start
[Statedef 45]
type    = A
physics = N
anim = 40
ctrl = 0
velset = 0,0

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

[State 45, 2]
type = VarSet
trigger1 = command = "holdfwd"
sysvar(1) = 1

[State 45, 3]
type = VarSet
trigger1 = command = "holdback"
sysvar(1) = -1

[State 45, 4]
type = VelSet
trigger1 = Time = 2
x = ifelse(sysvar(1)=0, const(velocity.airjump.neu.x), ifelse(sysvar(1)=1, const(velocity.airjump.fwd.x), const(velocity.airjump.back.x)))
y = const(velocity.airjump.y)

[State 45, 5]
type = ChangeState
trigger1 = Time = 2
value = 50
ctrl = 1

;---------------------------------------------------------------------------
; Jump Up
[Statedef 50]
type    = A
physics = A

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

[State 50, 2]
type = ChangeAnim
trigger1 = Time = 0
value = ifelse((vel x)=0, 41, ifelse((vel x)>0, 42, 43))

[State 50, 3]
type = ChangeAnim
trigger1 = Vel y > -2
trigger1 = SelfAnimExist(anim + 3)
persistent = 0
value = Anim + 3

;---------------------------------------------------------------------------
; Jump Down (empty state for compatibility)
[Statedef 51]
type    = A
physics = A

[State 51, 1]
type = Null
trigger1 = 1

;---------------------------------------------------------------------------
; Jump Land
[Statedef 52]
type    = S
physics = S
ctrl = 0
anim = 47

[State 52, 1]
type = VelSet
trigger1 = Time = 0
y = 0

[State 52, 2]
type = PosSet
trigger1 = Time = 0
y = 0

[State 52, 3]
type = CtrlSet
trigger1 = Time = 3
value = 1

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

;-------------------------------------------------------------------
; Dash Foward
[Statedef 100]
type = S
movetype = I
physics = N
anim = 100
ctrl = 0
sprpriority = 1

[State 100, 1]
type = PlayerPush
trigger1 = 1
value  = 1

[State 100, 2]
type = VelMul
trigger1 = 1
x = 0.96

[State 100, 3]
type = VelSet
trigger1 = Time = 0
x = const(velocity.run.fwd.x)

[State 100, 4]
type = AssertSpecial
trigger1 = 1
flag = nowalk
flag2 = noautoturn

[State 100, 5]
type = CtrlSet
trigger1 = Time = 0
value = 1

[State 100, 6]
type = ChangeState
trigger1 = AnimTime = 0
value = 101

;-------------------------------------------------------------------
; Dash Foward (land)
[Statedef 101]
type = S
movetype = I
physics = S
ctrl = 0
anim = 12

[State 101, 1]
type = PlayerPush
trigger1 = 1
value  = 1

[State 101, 2]
type = VelSet
trigger1 = Time = 0
y = 0

[State 101, 3]
type = PosSet
trigger1 = Time = 0
y = 0

[State 101, 4]
type = MakeDust
trigger1 = Time = 2
pos = 50,-1
spacing = 1

[State 100, 5]
type = CtrlSet
trigger1 = Time = 0
value = 1

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

;---------------------------------------------------------------------------
; Dash Back
[Statedef 105]
type    = S
movetype = I
physics = N
ctrl = 0
anim = 105
sprpriority = 1

[State 105, 1]
type = VelMul
trigger1 = time >= 0
x = 0.97

[State 105, 2]
type = VelSet
trigger1 = Time = 0
x = const(velocity.run.back.x)

[State 105, 3]
type = AssertSpecial
trigger1 = 1
flag = nowalk
flag2 = noautoturn

[State 105, 4]
type = CtrlSet
trigger1 = Time = 0
value = 1

[State 105, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 106

;---------------------------------------------------------------------------
; Dash Back (land)
[Statedef 106]
type    = S
movetype = I
physics = S
ctrl = 0
anim = 12

[State 106, 1]
type = VelSet
trigger1 = Time = 0
y = 0

[State 106, 2]
type = PosSet
trigger1 = Time = 0
y = 0

[State 106, 3]
type = MakeDust
trigger1 = Time = 2
pos = -50,-2
spacing = 1

[State 106, 4]
type = CtrlSet
trigger1 = Time = 0
value = 1

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

;---------------------------------------------------------------------------
; RUN_UP
[Statedef 110]
type    = S
physics = N

[State 110, 0]
type = CtrlSet
trigger1 = Time = 0
value = 0

[State 110, 1]
type = ChangeAnim
trigger1 = Time = 0
value = 110

[State 110, 2]
type = HitBy
trigger1 = Time = 0
value = SCA, NT, ST, HT
time = 30

[State 110, 3]
type = VelSet
trigger1 = Time = 0
x = 0
z = -7

[State 110, 4]
type = VelMul
trigger1 = 1
z = 0.8

[State 110, 5]
type = VelSet
trigger1 = AnimTime = -8
z = 0

[State 110, 7]
type = CtrlSet
trigger1 = AnimTime = 0
value = 1

[State 110, 8]
type = ChangeState
trigger1 = AnimTime = 0
value = 0

;---------------------------------------------------------------------------
; RUN_DOWN
[Statedef 115]
type    = S
physics = N

[State 115, 0]
type = CtrlSet
trigger1 = Time = 0
value = 0

[State 115, 1]
type = ChangeAnim
trigger1 = Time = 0
value = 110

[State 115, 2]
type = HitBy
trigger1 = Time = 0
value = SCA, NT, ST, HT
time = 30

[State 115, 3]
type = VelSet
trigger1 = Time = 0
x = 0
z = 7

[State 115, 4]
type = VelMul
trigger1 = 1
z = 0.8

[State 115, 5]
type = VelSet
trigger1 = AnimTime = -8
z = 0

[State 115, 7]
type = CtrlSet
trigger1 = AnimTime = 0
value = 1

[State 115, 8]
type = ChangeState
trigger1 = AnimTime = 0
value = 0


;---------------------------------------------------------------------------
;
; Guard generic states
; This can be overriden depending of the features you want for your char
;
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; GUARD (start)
[Statedef 120]
type = U    ;Leave state type unchanged
physics = U ;Leave physics unchanged

[State 120, 1]
type = ChangeAnim
trigger1 = Time = 0
value = 120 + (statetype = C) + (statetype = A)*2

[State 120, 2]
type = StateTypeSet
trigger1 = Time = 0 && statetype = S
physics = S

[State 120, 3]
type = StateTypeSet
trigger1 = Time = 0 && statetype = C
physics = C

[State 120, 4]
type = StateTypeSet
trigger1 = Time = 0 && statetype = A
physics = A

[State 120, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown"
statetype = C
physics = C

[State 120, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C && command != "holddown"
statetype = S
physics = S

[State 120, 5]
type = ChangeState
trigger1 = AnimTime = 0
value = 130 + (statetype = C) + (statetype = A)*2

[State 120, Stop Guarding]
type = ChangeState
trigger1 = command != "holdback"
trigger2 = !inguarddist
value = 140

;---------------------------------------------------------------------------
; STAND GUARD (guarding)
[Statedef 130]
type    = S
physics = S

[State 130, 1]
type = ChangeAnim
trigger1 = Anim != 130
value = 130

[State 130, Hi to Lo]
type = ChangeState
trigger1 = command = "holddown"
value = 131

[State 130, Stop Guarding]
type = ChangeState
trigger1 = command != "holdback"
trigger2 = !inguarddist
value = 140

;---------------------------------------------------------------------------
; CROUCH GUARD (guarding)
[Statedef 131]
type    = C
physics = C

[State 131, 1]
type = ChangeAnim
trigger1 = Anim != 131
value = 131

[State 131, Lo to Hi]
type = ChangeState
trigger1 = command != "holddown"
value = 130

[State 131, Stop Guarding]
type = ChangeState
trigger1 = command != "holdback"
trigger2 = !inguarddist
value = 140

;---------------------------------------------------------------------------
; AIR GUARD (guarding)
[Statedef 132]
type    = A
physics = N

[State 132, 1]
type = ChangeAnim
trigger1 = Anim != 132
value = 132

[State 132, 2]
type = VelAdd
trigger1 = 1
y = Const(movement.yaccel)

[State 132, 3]
type = VarSet
trigger1 = 1
sysvar(0) = (pos y >= 0) && (vel y > 0)

[State 132, 4]
type = VelSet
trigger1 = sysvar(0)
y = 0

[State 132, 5]
type = PosSet
trigger1 = sysvar(0)
y = 0

[State 132, 6]
type = ChangeState
trigger1 = sysvar(0)
trigger1 = command = "holdback"
trigger1 = inguarddist
value = 130

[State 132, 7]
type = ChangeState
trigger1 = sysvar(0)
value = 52

[State 132, Stop Guarding]
type = ChangeState
trigger1 = command != "holdback"
trigger2 = !inguarddist
value = 140

;---------------------------------------------------------------------------
; GUARD (end)
[Statedef 140]
type = U    ;Leave state type unchanged
physics = U ;Leave physics unchanged
ctrl = 1

[State 140, 1]
type = ChangeAnim
trigger1 = Time = 0
value = 140 + (statetype = C) + (statetype = A)*2

[State 140, 2]
type = StateTypeSet
trigger1 = Time = 0 && statetype = S
physics = S

[State 140, 3]
type = StateTypeSet
trigger1 = Time = 0 && statetype = C
physics = C

[State 140, 4]
type = StateTypeSet
trigger1 = Time = 0 && statetype = A
physics = A

[State 140, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown"
statetype = C
physics = C

[State 140, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C && command != "holddown"
statetype = S
physics = S

;[State 140, 5] ;Implemented within engine
;type = ChangeState
;trigger1 = AnimTime = 0
;value = (statetype = C)*11 + (statetype = A)*51

;---------------------------------------------------------------------------
; SGUARDHIT (shaking)
[Statedef 150]
type    = S
movetype= H
physics = N
velset = 0,0

[State 150, 1]
type = ChangeAnim
trigger1 = 1
value = 150

[State 150, 2]
type = ChangeState
trigger1 = HitShakeOver
value = 151 + 2*(command = "holddown")

[State 150, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown"
statetype = C
physics = C

[State 150, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C && command != "holddown"
statetype = S
physics = S

[State 150, 3]
type = ForceFeedback
trigger1 = time = 0
waveform = square
time = 3

;---------------------------------------------------------------------------
; SGUARDHIT2 (knocked back)
[Statedef 151]
type    = S
movetype= H
physics = S
anim = 150

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

[State 151, 2]
type = VelSet
trigger1 = Time = GetHitVar(slidetime)
trigger2 = HitOver
x = 0

[State 151, 3]
type = CtrlSet
trigger1 = Time = GetHitVar(ctrltime)
value = 1

[State 151, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown"
statetype = C
physics = C

[State 151, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C && command != "holddown"
statetype = S
physics = S

[State 151, 4]
type = ChangeState
trigger1 = HitOver
value = 130
ctrl = 1

;---------------------------------------------------------------------------
; CGUARDHIT (shaking)
[Statedef 152]
type    = C
movetype= H
physics = N
velset = 0,0

[State 152, 1]
type = ChangeAnim
trigger1 = 1
value = 151

[State 152, 3]
type = ChangeState
trigger1 = HitShakeOver
value = 151 + 2*(command = "holddown")

[State 152, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown"
statetype = C
physics = C

[State 152, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C && command != "holddown"
statetype = S
physics = S

[State 152, 4]
type = ForceFeedback
trigger1 = time = 0
waveform = square
time = 4

;---------------------------------------------------------------------------
; CGUARDHIT2 (knocked back)
[Statedef 153]
type    = C
movetype= H
physics = C
anim = 151

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

[State 153, 2]
type = VelSet
trigger1 = Time = GetHitVar(slidetime)
trigger2 = HitOver
x = 0

[State 153, 3]
type = CtrlSet
trigger1 = Time = GetHitVar(ctrltime)
value = 1

[State 153, Hi to Lo]
type = StateTypeSet
trigger1 = statetype = S && command = "holddown"
statetype = C
physics = C

[State 153, Lo to Hi]
type = StateTypeSet
trigger1 = statetype = C && command != "holddown"
statetype = S
physics = S

[State 153, 4]
type = ChangeState
trigger1 = HitOver
value = 131
ctrl = 1

;---------------------------------------------------------------------------
; AGUARDHIT (shaking)
[Statedef 154]
type    = A
movetype= H
physics = N
velset = 0,0

[State 154, 1]
type = ChangeAnim
trigger1 = 1
value = 152

[State 154, 2]
type = ChangeState
trigger1 = HitShakeOver
value = 155 ;AGUARDHIT2

[State 154, 3]
type = ForceFeedback
trigger1 = time = 0
waveform = square
time = 4

;---------------------------------------------------------------------------
; AGUARDHIT2 (knocked away)
[Statedef 155]
type    = A
movetype= H
physics = N
anim = 152

[State 155, 1]
type = HitVelSet
trigger1 = Time = 0
x = 1
y = 1

[State 155, 2]
type = VelAdd
trigger1 = 1
y = Const(movement.yaccel)

[State 155, 3]
type = CtrlSet
trigger1 = Time = GetHitVar(ctrltime)
value = 1

[State 155, 4]
type = VarSet
trigger1 = 1
sysvar(0) = (pos y >= 0) && (vel y > 0)

[State 155, 5]
type = VelSet
trigger1 = sysvar(0)
y = 0

[State 155, 6]
type = PosSet
trigger1 = sysvar(0)
y = 0

[State 155, 6]
type = ChangeState
trigger1 = sysvar(0)
trigger1 = command = "holdback"
trigger1 = inguarddist
value = 130

[State 155, 7]
type = ChangeState
trigger1 = sysvar(0)
value = 52


;---------------------------------------------------------------------------
;
; Generic Lose, Intros and Win states
; This can be overriden depending of the features you want for your char
;
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; LOSE (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, 2]
type = PlaySnd
trigger1= AnimElem = 3
value = 3, 21

;---------------------------------------------------------------------------
; DRAWGAME (Time over)
[Statedef 175]
type = S
ctrl = 0
velset = 0,0

[State 175, 1] ; If no anim, use go to lose state.
type = ChangeState
trigger1 = Time = 0
trigger1 = !SelfAnimExist(175)
value = 170

[State 175, 2]
type = ChangeAnim
trigger1 = Time = 0
value = 175

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

;---------------------------------------------------------------------------
; PREINTRO
[Statedef 190]
type = S
ctrl = 0
velset = 0,0

[State 190, 1]
type = ChangeAnim
trigger1 = SelfAnimExist(190)
value = 190

[State 190, 2] ;Go straight to intro.
type = ChangeState
trigger1 = Time = 0
value = 191

;---------------------------------------------------------------------------
; INTRO (override this state to give character an intro)
[Statedef 191]
type = S
ctrl = 0

[State 191, 1]
type = ChangeState
trigger1 = Time = 0
value = 0


;---------------------------------------------------------------------------
;
; Vs System GetHit States
;
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
; HITG_SHAKE
[Statedef 5000]
type    = S
movetype= H
physics = N
velset = 0,0

[State 5000, 1x]
type = ChangeState
triggerall = (RoundState > 2) && (!Alive)
trigger1 = HitShakeOver
value = 5090

[State 5000, 1vr]
type = VarSet
trigger1 = time = 0
sysvar(3) = 0
ignorehitpause = 1

[State 5000, 1vs]
type = VarSet
triggerall = HitVel Y > 0
triggerall = GetHitVar(yaccel) > 0
triggerall = HitFall
trigger1 = Pos Y = [-100, 0]
sysvar(3) = 1
ignorehitpause = 1

[State 5000, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
value = ifelse((GetHitVar(groundtype) = 1),5000,5010) + (GetHitVar(animtype) - (ifelse((GetHitVar(animtype) = [3,5]), 3, 0)))

[State 5000, 2] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5000, 3a]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0 && !GetHitVar(fall)
value = 5001 ;HITG_SLIDE

[State 5000, 3b]
type = ChangeState
trigger1 = HitShakeOver
value = 5030

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

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

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

;---------------------------------------------------------------------------
; HITG_SLIDE
[Statedef 5001]
type    = S
movetype= H
physics = S

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

[State 5001, 2]
type = ChangeAnim
trigger1 = AnimTime = 0
value = 5005 + (GetHitVar(animtype) - (ifelse((GetHitVar(animtype) = [3,5]), 3, 0))) + (GetHitVar(groundtype)=2)*10

[State 5001, 3] ;Stop sliding back
type = VelMul
trigger1 = Time >= GetHitVar(slidetime)
x = .6

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

[State 5001, 5]
type = DefenceMulSet
trigger1 = HitOver
value = 1

[State 5001, 6]
type = SelfState
trigger1 = HitOver
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; HITC_SHAKE
[Statedef 5010]
type    = C
movetype= H
physics = N
velset = 0,0

[State 5010, 1x]
type = ChangeState
triggerall = (RoundState > 2) && (!Alive)
trigger1 = HitShakeOver
value = 5090

[State 5010, 1rv]
type = VarSet
trigger1 = time = 0
sysvar(3) = 0
ignorehitpause = 1

[State 5010, 1vs]
type = VarSet
triggerall = HitVel Y > 0
triggerall = GetHitVar(yaccel) > 0
triggerall = HitFall
trigger1 = Pos Y = [-100, 0]
sysvar(3) = 1
ignorehitpause = 1

[State 5010, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
value = 5020 + (GetHitVar(animtype) - (ifelse((GetHitVar(animtype) = [3,5]), 3, 0)))

[State 5010, 2] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5010, 3a]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0 && !GetHitVar(fall)
value = 5011 ;HITC_SLIDE

[State 5010, 3b]
type = ChangeState
trigger1 = HitShakeOver
value = 5030

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

[State 5010, FFB Medium]
type = ForceFeedback
trigger1 = anim = 5021
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 5010, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5022
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

;---------------------------------------------------------------------------
; HITC_SLIDE
[Statedef 5011]
type    = C
movetype= H
physics = C

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

[State 5011, 2]
type = ChangeAnim
trigger1 = AnimTime = 0
value = 5025 + (GetHitVar(animtype) - (ifelse((GetHitVar(animtype) = [3,5]), 3, 0)))

[State 5011, 3] ;Stop sliding back
type = VelMul
trigger1 = Time >= GetHitVar(slidetime)
x = .6

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

[State 5011, 5]
type = DefenceMulSet
trigger1 = HitOver
value = 1

[State 5011, 6]
type = SelfState
trigger1 = HitOver
value = 11
ctrl = 1


;---------------------------------------------------------------------------
; HITA_SHAKE
[Statedef 5020]
type    = A
movetype= H
physics = N
velset = 0,0

[State 5020, 1x]
type = ChangeState
triggerall = (RoundState > 2) && (!Alive)
trigger1 = HitShakeOver
value = 5090

[State 5020, 1vs-f] ;Check if enemy is on ground (Marvel system FIX)
type = VarSet
trigger1 = time = 0
SysFVar(1) = enemynear, Pos Y
ignorehitpause = 1

[State 5020, 1rs]
type = VarSet
trigger1 = time = 0
sysvar(3) = 0
ignorehitpause = 1

[State 5020, 1vs]
type = VarSet
triggerall = HitVel Y > 0
triggerall = GetHitVar(yaccel) > 0
triggerall = HitFall
trigger1 = Pos Y < 0
sysvar(3) = 1
ignorehitpause = 1

[State 5020, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
value = ifelse((GetHitVar(airtype) = 1),5000,5010) + (GetHitVar(animtype) - (ifelse((GetHitVar(animtype) = [3,5]), 3, 0)))

[State 5020, 2] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5020, 3]
type = ChangeState
trigger1 = HitShakeOver
value = 5030

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

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

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

;---------------------------------------------------------------------------
; HITA_UP (initial going up) Marvel System Type
[Statedef 5030]
type    = A
movetype= H
physics = N
ctrl = 0

[State 5030, 1]
type = VelAdd;Gravity
trigger1 = 1
y = GetHitVar(yaccel)

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

[State 5030, 3a] ;Anim for HIT_BACK/HIT_DIAG_UP
type = ChangeAnim
triggerall = !sysvar(3)
triggerall = (GetHitVar(animtype) = 3) || (GetHitVar(animtype) = 5)
trigger1 = (Pos Y >= 0) && (Time = 0)
trigger2 = (Pos Y < 0) && (Time = (ifelse((SysFVar(1) >= 0), 0, 7)))
value = 5030
persistent = 0

[State 5030, 3b] ;Anim for HIT_UP (it HAS to exist)
type = ChangeAnim
triggerall = !sysvar(3)
triggerall = anim != 5030
triggerall = GetHitVar(animtype) = 4
trigger1 = (Pos Y >= 0) && (Time = 0)
trigger2 = (Pos Y < 0) && (Time = (ifelse((SysFVar(1) >= 0), 0, 7)))
value = ifelse(SelfAnimExist(5051), 5051, ifelse(SelfAnimExist(5035), 5035, 5030))
persistent = 0

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

[State 5030, 5]
type = ChangeState
trigger1 = (Anim = 5030) && (ifelse((HitVel Y > 0), (Vel Y > 0), (Time >= (ifelse((Pos Y = [-60, 50]), 2, 10)))))
trigger2 = (Anim = 5051) && (Vel Y > 0) && (Time >= 15)
trigger3 = ((Anim != 5030) && (Anim != 5051)) && (Time >= 8)
trigger4 = Pos Y >= 10
trigger5 = sysvar(3)
trigger6 = (!Alive) && (Vel Y > 0)
value = 5050

;---------------------------------------------------------------------------
; HITA_UP_T (Transintion, not used, maintained just for compatibility)
[Statedef 5035]
type    = A
movetype= H
physics = N
ctrl = 0

[State 5035, x1] ;Inmediately change into the correct state
type = ChangeState
trigger1 = 1
value = 5050

;---------------------------------------------------------------------------
; HITA_RECOV (recovering in air, not falling)
[Statedef 5040]
type    = A
movetype= H
physics = N

[State 5040, 1]
type = ChangeState
trigger1 = !Alive
value = 5050

[State 5040, 2]
type = ChangeAnim
trigger1 = AnimTime = 0
trigger1 = Anim != 5040
trigger2 = Time = 0
trigger2 = Anim != 5035
value = 5040

[State 5040, 3]
type = CtrlSet
trigger1 = HitOver
value = 1

[State 5040, 4]
type = StateTypeSet
trigger1 = HitOver
movetype = I

[State 5040, 5]
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5040, 6]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 52 ;JUMPLAND

;---------------------------------------------------------------------------
; HITA_FALL (knocked up, falling)
[Statedef 5050]
type    = A
movetype= H
physics = N

[State 5050, 2] ;Hit transition
type = ChangeAnim
triggerall = !sysvar(3)
triggerall = time = 0
triggerall = (anim != 5060) && (anim != 5061)
trigger1 = SelfAnimExist(5035)
value = 5035
persistent = 0

[State 5050, 3] ;Change anim when done with transition
type = ChangeAnim
triggerall = (anim != 5060) && (anim != 5061)
trigger1 = Anim = 5035
trigger1 = AnimTime = 0
trigger2 = Anim != 5035
trigger2 = Vel Y > 0
trigger3 = (sysvar(3)) && (!SelfAnimExist(5060))
value = 5050
persistent = 0

[State 5050, 4] ;Coming down anim
type = ChangeAnim
triggerall = SelfAnimExist(5060)
trigger1 = (Anim = 5050) && (AnimTime = 0)
trigger2 = ((Anim = 5051) || (Anim = 5052)) && (Vel Y > 0)
trigger3 = sysvar(3)
value = 5060
persistent = 0

[State 5050, 5] ;Gravity
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5050, 1rs]
type = VarSet
trigger1 = anim = 5060
sysvar(3) = 0

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

[State 5050, 6a]
type = SelfState
triggerall = Alive
trigger1 = (!HitFall) && (Vel Y > 0)
trigger2 = (CanRecover) && (ifelse(GetHitVar(fall.recovertime) = 0, (Vel Y > 0), time = GetHitVar(fall.recovertime)))
value = 5040

[State 5050, 6b]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 20
value = 5100 ;HIT_BOUNCE

;---------------------------------------------------------------------------
; HIT_TRIP (shaking)
[Statedef 5070]
type    = A
movetype= H
physics = N
velset = 0,0

[State 5070, 1]
type = ChangeAnim 
trigger1 = 1
value = 5070

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

[State 5070, 2]
type = ChangeState
trigger1 = HitShakeOver
value = 5071

[State 5070, 3]
type = ForceFeedback
trigger1 = time = 0
time = 12
waveform = sinesquare
ampl = 140

;---------------------------------------------------------------------------
; HIT_TRIP2 (fall through air)
[Statedef 5071]
type    = A
movetype= H
physics = N

[State 5071, 1] ;Set HIT_TRIP var
type = VarSet
trigger1 = time = 0
sysvar(0) = 1

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

[State 5071, 3] ;Acceleration
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

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

[State 5071, 4] ;Hit ground
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 15
value = 5110

;---------------------------------------------------------------------------
; HITL_SHAKE
[Statedef 5080]
type    = L
movetype= H
physics = N
velset = 0,0

[State 5080, 1]
type = ChangeAnim
trigger1 = time = 0
value = 5080

[State 5080, 2] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5080, 3]
type = ChangeState
trigger1 = HitShakeOver
value = 5081 ;HITL_SLIDE

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

;---------------------------------------------------------------------------
; HITL_SLIDE
[Statedef 5081]
type    = L
movetype= H
physics = N

[State 5081, 1]
type = ChangeAnim
trigger1 = time = 0
value = ifelse(selfanimexist(5090), 5090, 5030)

[State 5081, 2]
type = StateTypeSet
trigger1 = Pos Y != 0
statetype = A

;Constant aceleration, not dependant from hitdef parameters
[State 5080, 3]
type = VelAdd
trigger1 = 1
y = 0.69

;Custom Velocity statement, not dependant from hitdef parameters
[State 5080, 4]
type = VelSet
trigger1 = Time = 0
x = -4
y = -8.5

[State 5080, 5a]
type = ChangeState
triggerall = Alive
trigger1 = Pos Y >= 0
trigger1 = Vel Y >= 0
value = 5082

[State 5080, 5b]
type = ChangeState
triggerall = !Alive
trigger1 = Pos Y >= 0
trigger1 = Vel Y >= 0
value = 5110

;---------------------------------------------------------------------------
; HITL_RECOVERY
[Statedef 5082]
type    = S
movetype= I
physics = N

[State 5082, 1]
type = NotHitBy
trigger1 = 1
value = SCA, NA, SA, HA, NP, SP, HP, NT, ST, HT
time = 20

[State 5082, 2]
type = PosSet
trigger1 = time = 0
y = 0

[State 5082, 3]
type = ChangeAnim
trigger1 = time = 0
value = ifelse(SelfAnimExist(5082), 5082, 5110)

[State 5082, 4]
type = VelSet
trigger1 = Time = 0
x = -7
y = 0

[State 5082, 5]
type = VelSet
trigger1 = Time >= 19
x = 0
y = 0

[State 5082, 6]
type = SelfState
trigger1 = Time >= 20
value = 5120

;---------------------------------------------------------------------------
; HITA_UP_DEAD (initial going up, used when dead) Marvel System Type
[Statedef 5090]
type    = U
movetype= H
physics = N
ctrl = 0

[State 5090, 1]
type = VelAdd;Gravity
trigger1 = 1
y = GetHitVar(yaccel)

[State 5090, 2]
type = HitVelSet
trigger1 = time = 0
x = 1
y = 1

[State 5090, 3]
type = VelAdd
trigger1 = time = 0
x = ifelse((GetHitVar(xvel) >= 0), (-4.5), (ifelse(GetHitVar(xvel) < -8, GetHitVar(xvel)/2, GetHitVar(xvel) * 1.2)))
y = ifelse((GetHitVar(yvel) >= 0), ifelse(GetHitVar(yvel) > 7, -30, -15.5), (ifelse(GetHitVar(yvel) < -10, GetHitVar(yvel)/3, GetHitVar(yvel)) * 1.2))

[State 5090, 4] ;Anim for HIT_BACK/HIT_DIAG_UP
type = ChangeAnim
trigger1 = time = 0
value = ifelse(SelfAnimExist(5030), 5030, ifelse(SelfAnimExist(5035), 5035, 5050))

[State 5090, 5]
type = ChangeState
trigger1 = Vel Y > 0
value = 5050

;---------------------------------------------------------------------------
; HIT_BOUNCE (hit ground)
[Statedef 5100]
type    = L
movetype= H
physics = N

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

[State 5100, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
value2 = S,NA
time = 1

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

[State 5100, Var] ;Save fall velocity
type = VarSet
trigger1 = Time = 0
SysFVar(0) = 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]
type = ChangeState
trigger1 = Time = 0
trigger1 = GetHitVar(fall.yvel) = 0
trigger2 = !Alive
value = 5110 ;HIT_LIEDOWN

[State 5100, 7]
type = HitFallDamage
trigger1 = Time = 3

[State 5100, 8]
type = PosFreeze
trigger1 = 1

[State 5100, 9]
type = ChangeState
trigger1 = Time >= 3
value = 5101

[State 5100, 10]
type = ForceFeedback
trigger1 = Time = 0
waveform = sinesquare
ampl = 128,-3,-.2,.005
time = 20

;---------------------------------------------------------------------------
; HIT_BOUNCE (bounce from ground into air)
[Statedef 5101]
type    = L
movetype= H
physics = N
anim = 5040

[State 5101, 1] ;Turn if not facing opponent
type = Turn
trigger1 = Time = 0
trigger1 = p2dist X < -5

[State 5101, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
value2 = S,NA
time = 1

[State 5101, 2]
type = HitFallVel
trigger1 = Time = 0

[State 5101, 3]
type = VelMul
trigger1 = 1
x = const(movement.stand.friction)

[State 5101, 4] ;Acceleration
type = VelAdd
trigger1 = 1
y = const(movement.yaccel)

[State 5101, 5] ;Instant recover near ground
type = ChangeState
trigger1 = Vel Y > 0
value = 5102

;---------------------------------------------------------------------------
; HIT_BOUNCE2 (vs style hitbounce on ground)
[Statedef 5102]
type    = A
movetype= I
physics = N

[State 5102, 1] ;Acceleration
type = VelAdd
trigger1 = 1
y = const(movement.yaccel)

[State 5102, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
value2 = S,NA
time = 1

[State 5102, 2]
type = ChangeState
trigger1 = Pos Y >= 0
value = 5103

;---------------------------------------------------------------------------
; HIT_BOUNCERECOVER (vs style hitbounce recovery on ground)
[Statedef 5103]
type    = S
movetype= I
physics = S
anim = 47
velset = 0, 0

[State 5103, 1]
type = PosSet
trigger1 = Time = 0
y = 0

[State 5103, 2]
type = SelfState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

;---------------------------------------------------------------------------
; HIT_LIEDOWN
[Statedef 5110]
type    = L
movetype= H
physics = N

[State 5110, 1]
type = ChangeState
trigger1 = 1
value = 5111

;---------------------------------------------------------------------------
; HIT_LIEDOWN2 (Vs series style)
[Statedef 5111]
type    = L
movetype= H
physics = N

[State 5110, 1]
type = PosSet
trigger1 = Time = 0
y = 0

[State 5110, 2]
type = VelSet
trigger1 = Time = 0
x = 0
y = 0

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

[State 5110, 3]
type = ChangeAnim
trigger1 = time = 0
value = ifelse(sysvar(0), 5170, 5100)

[State 5110, 4]
type = ChangeAnim
trigger1 = (Anim = 5100) && (AnimTime = 0)
value = 5160

[State 5110, 5]
type = ChangeAnim
trigger1 = (Anim = 5160) && (Time = 9)
value = 5170

[State 5110, 6]
type = ChangeAnim
trigger1 = (Anim = 5170) && (AnimTime = 0)
value = 5110

[State 5110, 7]
type = HitFallDamage
trigger1 = Time = 0

[State 5110, 8]
type = VarSet
trigger1 = sysvar(0)
trigger1 = Time = 0
sysvar(0) = 0

[State 5110, 9]
type = VarSet
trigger1 = Time = 0
SysFVar(0) = 0

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

[State 5110, 9a]
type = SelfState
triggerall = Alive
trigger1 = Time >= 15
value = 5120

[State 5110, 9b]
type = SelfState
triggerall = !Alive
trigger1 = Anim = 5110
trigger2 = Time >= 15
value = 5150

[State 5110, 10]
type = ForceFeedback
trigger1 = alive
trigger1 = Time = 0
time = 8
ampl = 240
waveform = sine

[State 5110, 11]
type = ForceFeedback
trigger1 = !alive
trigger1 = Time = 0
ampl = 200, 7, -.467
time = 30
waveform = sine

;---------------------------------------------------------------------------
; HIT_GETUP
[Statedef 5120]
type    = S
movetype= I
physics = N

[State 5120, 1a] ;Get up anim (normal)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim != [5111,5119]
trigger2 = !SelfAnimExist(5120 + (anim % 10))
value = 5120

[State 5120, 1b] ;Get up anim (for hit up/diag-up)
type = ChangeAnim
triggerall = time = 0
trigger1 = anim = [5111,5119]
trigger1 = SelfAnimExist(5120 + (anim % 10))
value = 5120 + (anim % 10)

[State 5120, 2]
type = VarSet
trigger1 = 1
sysvar(4) = 0

[State 5120, 3]
type = VelSet
trigger1 = Time = 0
x = 0

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

[State 5120, 5]
type = HitFallSet
trigger1 = AnimTime = 0
value = 1

[State 5120, 6] ;Can't be thrown right after getting up
type = NotHitBy
trigger1 = AnimTime = 0
value = , NT,ST,HT
time = 12

[State 5120, 7] ;Can't be hit right after getting up (short time)
type = NotHitBy
trigger1 = AnimTime = 0
value2 = SCA
time = 3

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

;---------------------------------------------------------------------------
; HIT_LIEDEAD
[Statedef 5150]
type    = L
movetype= H
physics = N
sprpriority = -3

[State 5150, 1] ;Normal anim
type = ChangeAnim
triggerall = Time = 0
triggerall = SelfAnimExist(5140)
triggerall = RoundState != 3
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 = Time = 0
trigger1 = Roundstate = 3
trigger1 = (anim != [5111,5119]) && (anim != [5171,5179])
trigger1 = SelfAnimExist(5150)
value = 5150

[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, 6] ;Friction
type = VelMul
trigger1 = 1
x = 0.85

[State 5150, 7] ;Friction
type = VelSet
trigger1 = Vel x < .05
persistent = 0
x = 0

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

;----------------------------------------------------------------------
;Recovery Roll (From Nobuyuki's Magneto MvC2 Ver, Vs series feature)
[Statedef 5190]
type = S
movetype = I
physics = N
ctrl = 0
facep2 = 1

[State 5190, 1]
type = ChangeAnim
trigger1 = time = 0
value = ifelse(SelfAnimExist(5190), 5190, 5110)

[State 5190, 2]
type = VarSet
trigger1 = 1
sysvar(4) = 0

[State 5190, 3]
type = VelSet
trigger1 = time >= 0
x = 8

[State 5190, 4]
type = PosSet
trigger1 = 1
y = 0

[State 5190, 5]
type = NotHitby
trigger1 = 1
value = SCA

[State 5190, 6]
type = PlayerPush
trigger1 = 1
value = 0

[State 5190, 7]
type = velset
trigger1 = time = 29
x = 0

[State 5190, 8]
type = SelfState
trigger1 = time = 30
value = 5120
ctrl = 1

;---------------------------------------------------------------------------
; HIT_FALLRECOVER (still falling)
[Statedef 5200]
type    = A
movetype= H
physics = N

[State 5200, 1] ;Change anim if done with transition
type = ChangeAnim
trigger1 = Anim = 5035
trigger1 = AnimTime = 0
value = 5050

[State 5200, 2]
type = VelAdd
trigger1 = 1
y = GetHitVar(yaccel)

[State 5200, 3]
type = SelfState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 10
value = 5201

;---------------------------------------------------------------------------
; HIT_FALLRECOVER (on the ground)
[Statedef 5201]
type    = A
movetype= H
physics = A
anim = 5200

[State 5201, 1] ;Turn if not facing opponent
type = Turn
trigger1 = Time = 0
trigger1 = p2dist X < -5

[State 5201, 2]
type = VelSet
trigger1 = Time = 0
x = -.15
y = -3.5

[State 5201, 3]
type = PosSet
trigger1 = Time = 0
y = 0

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

[State 5201, 5] ;Blink white
type = PalFX
trigger1 = Time = 0
time = 3
add = 128,128,128 ;256,256,256

[State 5201, 6]
type = GameMakeAnim
trigger1 = Time = 1
value = 60
pos = 0, 0
under = 1

;---------------------------------------------------------------------------
; HIT_AIRFALLRECOVER
[Statedef 5210]
type    = A
movetype= I
physics = N
anim = 5210
ctrl = 0

[State 5210, 1] ;Blink white
type = PalFX
trigger1 = Time = 0
time = 3
add = 128,128,128 ;256,256,256

[State 5210, 1]
type = PosFreeze
trigger1 = Time = 0
value = 4

[State 5210, 2] ;Turn if not facing opponent
type = Turn
trigger1 = Time = 0
trigger1 = p2dist X < -20

[State 5210, 1] 
type = VelMul
trigger1 = Time = 4
x = .8
y = .8

[State 5210, 1]
type = VelAdd
trigger1 = Time = 4
y = -4.5

[State 5210, 1] 
type = VelMul
trigger1 = Time = 4
trigger1 = Vel Y > 0
y = .5

[State 5210, 1]
type = VelAdd
trigger1 = Time = 4
trigger1 = Vel Y > -3
y = -2

[State 5210, 1]
type = VelAdd
trigger1 = Time = 4
trigger1 = Vel Y > -2
y = -1

[State 5210, 2] ;Go up
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holdup"
y = -2

[State 5210, 2] ;Go down
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holddown"
y = 1.5

[State 5210, 2] ;Go fwd
type = VelMul
trigger1 = Time = 4
trigger1 = Command = "holdfwd"
x = 1

[State 5210, 2] ;Go back
type = VelAdd
trigger1 = Time = 4
trigger1 = Command = "holdback"
x = -1

[State 5210, 3]
type = NotHitBy
trigger1 = Time = 0
value = SCA
time = 15

[State 5210, 4]
type = CtrlSet
trigger1 = Time = 20
value = 1

[State 5210, 5]
type = VelAdd;Gravity
trigger1 = Time >= 4
y = .35

[State 5210, 5] ;Land on ground
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 52 ;JUMP_LAND
ctrl = 1

;---------------------------------------------------------------------------
; Continue?
[Statedef 5500]
type = S
ctrl = 0
anim = 5300
velset = 0,0

[State 5500, 1] ;Use continue animation if available
type = ChangeAnim
trigger1 = time = 0
trigger1 = SelfAnimExist(5500)
value = 5500

;---------------------------------------------------------------------------
; Initialize (at the start of the round)
[Statedef 5900]
type = S

[State 5900, 1]  ;Clear all int variables
type = VarRangeSet
trigger1 = !RoundsExisted
first = 0
last = 58
value = 0

[State 5900, 2]  ;Clear all float variables
type = VarRangeSet
trigger1 = !RoundsExisted
fvalue = 0

[State 5900, 3a] ;Intro for round 1
type = ChangeState
trigger1 = roundno = 1
value = 190

[State 5900, 3b] ;No intro for further rounds
type = ChangeState
trigger1 = roundno > 1
value = 0

; =================================================================================== ;
;            Full Game Features Section (DO NOT OVERRIDE unless you know              ;
;            what are you doing. This will add extra features to your                 ;
;            chars. THANKS TO: Messatsu for discovering this.                         ;
; =================================================================================== ;

; ========================================================================
;Main System Helper (Controls many aspects for a full game)
[StateDef 1337000000]
anim = 1337000000
ctrl = 0

[State MS - X, IX]
type = AssertSpecial
trigger1 = 1
flag = noshadow
flag2 = invisible

[State MS - X, NM]
type = AssertSpecial
triggerall = root, var(17) = [20, 21]
trigger1 = (roundstate < 2) && (roundno < 2)
flag = nomusic

[State MS - Pos, 01]
type = BindToRoot
trigger1 = 1
time = 1
facing = root, facing
pos = 0, 0

;;;;;;;;;;;;;;; Feature 1: Combo Messages ;;;;;;;;;;;;;;;;
; --------------------------------------------------------
; Original by Ryou Win - Used vars for this feature: 5
; - var(1) *** Special var for First Attack (avoids var reset if intro skipped)
; - var(2) *** Ground Hit Count
; - var(3) *** Aerial Hit Count (buggy)
; - var(4) *** Danger Var
; - var(5) *** PlaceHolder for Counter and Danger vars
[State -4, FA - Initial Value]
type = VarSet
trigger1 = (var(1) != 1) && (roundstate <= 2)
trigger2 = (var(1) = 1) && (roundstate < 2)
var(1) = -1

[State -4, FA - Active]
type = VarSet
trigger1 = (NumExplod(9500)) && (var(1) = -1)
var(1) = 0

[State -4, FA - Done]
type = VarSet
trigger1 = (var(1) = 0) && (roundstate >= 2)
trigger2 = (var(2) = -1) && ifelse((root, NumPartner), (root, MoveType = H || partner, MoveType = H) && ((root, StateNo != [150, 155]) && (partner, StateNo != [150, 155])), (root, MoveType = H) && (root, Stateno != [150, 155]))
var(1) = 1
;----------------------------

[State -4, HitCount PlaceHolder]
type = VarSet
trigger1 = var(2) >= 3
trigger2 = (var(2) = -1) && (enemynear, MoveType = H) && (enemynear, Stateno != [150, 155])
var(5) = 1 + (var(2) > 4) + (var(2) > 5) + (var(2) > 7) + (var(2) > 9) + (var(2) > 29) + (var(2) > 49) + (var(2) > 69) - (var(2) = -1)

[State -4, Aerial HitCount PlaceHolder]
type = VarSet
triggerall = root, var(17) >= 20
trigger1 = var(3) > 1
var(5) = 10

[State -4, Danger On]
type = VarSet
trigger1 = (var(4) != 1) && (roundstate = 2) && (root, life = [1, 250])
var(5) = 9
;----------------------------

[State -4, FA - Danger Sound]
type = PlaySnd
triggerall = (var(2) = -1) && (!NumExplod(9500))
trigger1 = (var(5) = 9) && (var(4) = 0) && (root, life > 0)
trigger2 = (var(2) = -1) && (enemynear, MoveType = H) && (enemynear, Stateno != [150, 155])
value = f(ifelse((root, var(17) = [10, 11]), 230, 9500)), 0
volume = 255

[State -4, Combo Sounds]
type = PlaySnd
trigger1 = (!NumExplod(9500)) && (var(2) = 0 && var(3) = 0 && var(5) != 0)
value = f(ifelse((root, var(17) = [10, 11]), 230, 9500)), ifelse(var(5) > 9, 11, var(5))
volume = 255

[State -4, Combo Message (left)]
type = Explod
triggerall = TeamSide = 1 && !NumExplod(9500)
trigger1 = var(2) = 0 && var(3) = 0 && var(5) != 0
trigger2 = (var(2) = -1) && (enemynear, MoveType = H) && (enemynear, Stateno != [150, 155])
trigger3 = (var(5) = 9) && (var(4) = 0) && (root, life > 0)
anim = f((ifelse((root, var(17) = [10, 11]), 230, 9500)) + ifelse(var(5) > 9, 30, var(5)))
ID = 9500
postype = left
pos = 0, 80
ontop = 1
ownpal = 1
bindtime = -1
removetime = 60
supermovetime = 60
pausemovetime = 60
scale = 0.5,0.5

[State -4, Combo Message (right)]
type = explod
triggerall = TeamSide = 2 && !NumExplod(9500)
trigger1 = var(2) = 0 && var(3) = 0 && var(5) != 0
trigger2 = (var(2) = -1) && (enemynear, MoveType = H) && (enemynear, Stateno != [150, 155])
trigger3 = (var(5) = 9) && (var(4) = 0) && (root, life > 0)
anim = f((ifelse((root, var(17) = [10, 11]), 240, 9510)) + ifelse(var(5) > 9, 21, var(5)))
ID = 9500
postype = right
pos = -1, 80
ontop = 1
ownpal = 1
bindtime = -1
removetime = 60
supermovetime = 60
pausemovetime = 60
scale = 0.5,0.5
;----------------------------

[State -4, Main HitCount]
type = VarAdd
trigger1 = (enemynear, time = 1) && (enemynear, HitShakeOver = 0) && (enemynear, MoveType = H) && (enemynear, Stateno != [150, 155])
var(2) = 1 + (var(2) = -1)

[State -4, Main HitCount (Aerial Rave)]
type = VarAdd
triggerall = ifelse((root, NumPartner), ((Root, HitDefAttr = A, NA, SA, HA) || (Partner, HitDefAttr = A, NA, SA, HA)), (Root, HitDefAttr = A, NA, SA, HA))
trigger1 = (enemynear, time = 1) && (enemynear, HitShakeOver = 0) && (enemynear, MoveType = H) && (enemynear, Stateno != [150, 155]) && (enemynear, statetype = A)
var(3) = 1

[State -4, Reset HitCount]
type = VarSet
trigger1 = var(2) != -1 && (p2movetype != H || enemynear, ctrl)
trigger2 = (var(2) = -1) && ifelse((root, NumPartner), (root, MoveType = H || partner, MoveType = H) && ((root, StateNo != [150, 155]) && (partner, StateNo != [150, 155])), (root, MoveType = H) && (root, Stateno != [150, 155]))
trigger3 = (var(2) = -1) && (enemynear, MoveType = H) && (enemynear, Stateno != [150, 155])
var(2) = 0 - (var(1) = -1)

[State -4, Reset HitCount (Aerial Rave)]
type = VarSet
trigger1 = var(2) != -1 && (p2movetype != H || enemynear, ctrl)
trigger2 = ifelse((root, NumPartner), ((Root, HitDefAttr = SC, NA, SA, HA) || (Partner, HitDefAttr = SC, NA, SA, HA)), (Root, HitDefAttr = SC, NA, SA, HA))
trigger2 = (enemynear, MoveType = H) && (enemynear, Stateno != [150, 155])
var(3) = 0

[State -4, Reset PlaceHolder Var]
type = VarSet
triggerall = NumExplod(9500)
trigger1 = (var(2) = 0) || (var(3) = 0) || (roundstate > 2)
var(5) = 0

[State -4, Danger Indicator]
type = VarSet
trigger1 = var(4) = 1 && roundstate != 2
trigger2 = var(4) = 0 && root, life <= 250
var(4) = (roundstate > 1)
; -------------------------------------------------------- 

;;;;;;;;;;;;; Feature 2: K.O. for Simul Mode ;;;;;;;;;;;;;;
; --------------------------------------------------------
; Used vars for this feature: 1
; - var(6) *** Detects whenever root or partner had been defeated in roundstate 2 when in simul mode.
[State -4, VarSet]
type = VarSet
trigger1 = (var(6) = 0) && !(root, Alive)
var(6) = 1

[State -4, Special K.O. Effect if defeated in simul mode (roundstate = 2)]
type = Helper
triggerall = !NumHelper(1338000000)
trigger1 = var(6) = 1
name = "Finish!"
ID = 1338000000
stateno = 1338000000
ownpal = 1
persistent = 0

[State -4, VarSet]
type = VarSet
trigger1 = var(6) > 0
trigger2 = (var(6) = 0) && ifelse((root, NumPartner), !(partner, Alive), (var(6) > 0))
trigger3 = !NumPartner
var(6) = -1
; --------------------------------------------------------

;;;;;;;;;;;;;; Feature 3: Hyper Background ;;;;;;;;;;;;;;;
; --------------------------------------------------------
; Used vars for this feature: 2
; - var(7) *** Detects Hyper Combo Finish
; - var(8) *** Detects Normal Finish
[State -4, Hyper Combo Finish Varset]
type = VarSet
triggerall = root, var(17) >= 10
triggerall = var(7) = 0
triggerall = root, WinKO
triggerall = !(Helper(1338000001), NumExplod(9400))
triggerall = !(Helper(1338000002), NumExplod(9400))
trigger1 = root, stateno = [3000, 3999]
trigger2 = root, stateno = [4601, 4609]
var(7) = 1

[State -4, Normal Finish Varset]
type = VarSet
triggerall = var(8) = 0
triggerall = var(7) = 0
trigger1 = root, WinKO
var(8) = 1

[State -4, Hyper Background Helper]
type = Helper
triggerall = root, var(17) >= 10
triggerall = !NumHelper(1338000001)
trigger1 = root, stateno = [3000, 3999]
name = "Hyper Background"
ID = 1338000001
stateno = 1338000001
pos = 0,0
postype = back
ownpal = 1
supermovetime = 9999999999
pausemovetime = 9999999999

[State -4, Dual Hyper Background Helper]
type = Helper
triggerall = root, var(17) >= 10
triggerall = !NumHelper(1338000002)
trigger1 = root, stateno = [4601, 4609]
name = "Dual Hyper Background"
ID = 1338000002
stateno = 1338000002
pos = 0,0
postype = back
ownpal = 1
supermovetime = 9999999999
pausemovetime = 9999999999

[State -4, HCF Varset]
type = VarSet
triggerall = root, var(17) >= 10
triggerall = var(7) = 1
trigger1 = Helper(1338000001), NumExplod(9400)
trigger2 = Helper(1338000002), NumExplod(9400)
var(7) = -1

[State -4, Reset Vars]
type = VarSet
trigger1 = Roundstate = [0, 2]
var(7) := var(8) := 0
; --------------------------------------------------------

;;;;;;;;;;;; Feature 4: Stage Number Display ;;;;;;;;;;;;;
; --------------------------------------------------------
; Used vars for this feature: 2
; - var(9) *** Dozens for counting Number of matches
; - var(10) ** Units for counting Number of matches
[State -4, Set Dozens]
type = varset
trigger1 = 1
var(9) = (MatchNo / 10)

[State -4, Set Units]
type = varset
trigger1 = 1
var(10) = (MatchNo - (var(9) * 10))

[State -4, ST - Explod]
type = Explod
triggerall = !NumExplod(9610) && ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = root, var(17) = [20, 21]
anim = f9610
ID = 9610
pos = 145, 228
postype = left
scale = 0.5, 0.5
facing = 1
sprpriority = 2
ownpal = 1
bindtime = -1

[State -4, ST - Dozens]
type = Explod
triggerall = !NumExplod(9611) && ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = root, var(17) = [20, 21]
anim = f(9600 + var(9))
ID = 9611
pos = 164, 228
postype = left
scale = 0.5, 0.5
facing = 1
sprpriority = 2
ownpal = 1
bindtime = -1

[State -4, ST - Units]
type = Explod
triggerall = !NumExplod(9612) && ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = root, var(17) = [20, 21]
anim = f(9600 + var(10))
ID = 9612
pos = 170, 228
postype = left
scale = 0.5, 0.5
facing = 1
sprpriority = 2
ownpal = 1
bindtime = -1
; --------------------------------------------------------

;;;;;;;;;;;;;;;; Feature 5: Score Control ;;;;;;;;;;;;;;;;
; --------------------------------------------------------
; Used Vars for this feature: 4
; - var(11) ** Score counter
; - root, var(59) ** Score Bookeeping... This var is very important
; to avoid the score to be reset between rounds, also for this is
; important to override state 5900, so var(59) is not reseted after
; matches.
; - var(12) ** Time bonus tracker.
; - var(13) ** Max combo bonus tacker.
; Note that, if you skip the intro, the score counter will reset again
; into zero, but not the root var.
[State -4, Score Var]
type = VarAdd
triggerall = (root, var(17) >= 10) && (root, var(58) = -1 || root, var(58) = 0)
trigger1 = (enemynear, time = 1) && (enemynear, HitShakeOver = 0) && (enemynear, MoveType = H) && (enemynear, Stateno != [150, 155])
trigger2 = (var(2) = -1) && (enemynear, MoveType = H) && (enemynear, Stateno != [150, 155])
var(11) = (ceil((root, stateno) || (partner, stateno) / 5) * var(2) * (roundstate != 4)) + ((var(1) = -1) * 500)

[State -4, Set Score for Next Rounds]
type = ParentVarSet
trigger1 = roundstate > 2
var(59) = var(11) + ((Helper(1338000005), var(0)) * (roundstate > 2 && MatchOver))

[State -4, Set Score for Next Rounds]
type = VarSet
trigger1 = roundstate < 2
var(11) = root, var(59)

[State -4, Time Bonus Var]
type = VarAdd
trigger1 = roundstate = 2
var(12) = 1

[State -4, Max Combo Bonus Var]
type = VarSet
trigger1 = var(2) > var(13)
var(13) = var(2)

[State -4, Score Helper]
type = Helper
triggerall = !NumHelper(1338000003) && (root, var(17) >= 10) && (GameTime % 10) = 0 && ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = root, var(58) = -1
trigger2 = root, var(58) = 0
name = "Score Helper"
stateno = 1338000003
ID = 1338000003
pos = 0,0
postype = left
bindtime = -1
ownpal = 1
pausemovetime = 999999999
supermovetime = 999999999

[State -4, Press Start Label]
type = Explod
triggerall = !NumExplod(9800) && (root, var(17) >= 10) && (GameTime % 60) = (root, ID)
trigger1 = root, var(58) = -2 && (root, Alive)
trigger2 = root, var(58) = 1
anim = f(ifelse((root, var(17) = [10, 11]), 220, 9800))
ID = 9800
pos = (ifelse((TeamSide = 1), 35, 190)) - (ifelse((root, var(17) = [10, 11]), 25, ifelse((root, var(17) = [30, 31]), (10 - 5 * (teamside = 2)), 0))), ifelse((root, var(17) = [10, 11]), 4, ifelse((root, var(17) = [30, 31]), 5, 2))
postype = Left
removetime = 30
bindtime = -1
ownpal = 1
ontop = 1
scale = 0.50, 0.50
supermovetime = 999999999
pausemovetime = 999999999
; --------------------------------------------------------

;;;;;;;;;;;;;;;; Feature 6: Player Simbols ;;;;;;;;;;;;;;;
; --------------------------------------------------------
; Used vars for this feature: 0
; Shows a simbol P1 (O) when foe is offscreen
[State -4, Simbol 1]
type = Explod
triggerall = root, var(17) >= 10
triggerall = (enemynear, Alive) && (roundstate = 2)
trigger1 = enemynear, ScreenPos Y < 0
trigger2 = enemynear, ScreenPos Y > 220 - (const(size.head.pos.y))
trigger3 = P2BodyDist Y > 200
anim = f(ifelse((root, var(17) = [10, 11]), 300, 9700) + (ifelse((root, var(17) = [10, 11]), 1, 2))*(enemy, ID > root, ID))
id = 9700
pos = ceil(enemynear, screenpos x), 15 + (enemynear, screenpos y > 0) * 200
postype = left
ontop = 1
bindtime = -1
removetime = 1
scale = ifelse((root, var(17) = [10, 11]), 1, 0.5), ifelse((root, var(17) = [10, 11]), 1, 0.5)

; Shows a simbol P1 (>) when foe is offscreen
[State -4, Simbol 2]
type = Explod
triggerall = root, var(17) >= 10
triggerall = (enemynear, Alive) && (roundstate = 2)
trigger1 = enemynear, ScreenPos Y < 0
trigger2 = enemynear, ScreenPos Y > 220 - (const(size.head.pos.y))
trigger3 = P2BodyDist Y > 200
anim = f(ifelse((root, var(17) = [10, 11]), 302, 9701) + (ifelse((root, var(17) = [10, 11]), 1, 2))*(enemy, ID > root, ID))
id = 9701
pos = ceil(enemynear, screenpos x), 15 + (enemynear, screenpos y > 0) * 200
postype = left
ontop = 1
bindtime = -1
facing = (enemynear, facing)
removetime = 1
scale = ifelse((root, var(17) = [10, 11]), 1, 0.30), ifelse((root, var(17) = [10, 11]), 1, 0.30)
; --------------------------------------------------------

;;;;;;;;;;;;;;;; Feature 7: Winning Quotes ;;;;;;;;;;;;;;;
; --------------------------------------------------------
; Used vars for this feature: 0
[State -4, Win Quotes]
type = Helper
triggerall = (ifelse((root, ID > partner, ID), (partner, SelfAnimExist(1337000000)), 1)) || (!NumPartner)
triggerall = (root, var(17) >= 20) && !NumHelper(1338000004)
trigger1 = ((root, stateno = [180, 189]) || (partner, stateno = [180, 189])) && MatchOver
name = "Win Quotes"
ID = 1338000004
stateno = 1338000004
pos = 0, 0
postype = back
ownpal = 1
supermovetime = 999999999
pausemovetime = 999999999

[State -4, Final Score Helper]
type = Helper
triggerall = ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = NumHelper(1338000004) && !NumHelper(1338000005)
name = "Final Score Helper"
ID = 1338000005
stateno = 1338000005
ownpal = 1
bindtime = -1
; --------------------------------------------------------

;;;;;;;;;;; Feature 9: Detect Metal-Like People ;;;;;;;;;;
; --------------------------------------------------------
; Used Vars for this feature: 1
; - var(14) ** Detect Metal-Like enemyes.
; This also includes Non-Marvel/Capcom Characters as well.
[State -2, Who is made of metal here?]
type = VarSet
triggerall = root, var(17) >= 20
triggerall = enemynear, stateno != 5150
trigger1  = enemynear, name = "Sentinel"
trigger2  = enemynear, name = "Sentinel by ER"
trigger3  = enemynear, name = "Iron Man"
trigger4  = enemynear, name = "Iron-Man"
trigger5  = enemynear, name = "War Machine"
trigger6  = enemynear, name = "Marvel vs. Capcom's WarMachine"
trigger7  = enemynear, name = "Dr. Doom"
trigger8  = enemynear, name = "Doctor Doom"
trigger9  = enemynear, name = "Dr. Doom by WhiteMagic2002"
trigger10 = enemynear, name = "Dr.Doom"
trigger11 = enemynear, name = "Dr. Doom By {_Carnificina_}"
trigger12 = enemynear, name = "Tron Bonne"
trigger13 = enemynear, name = "Tron"
trigger14 = enemynear, name = "Abyss Form 1"
trigger15 = enemynear, name = "Chotto-Ko Mech-Gouki"
trigger16 = enemynear, name = "Mech Gouki"
trigger17 = enemynear, name = "Mazinger Z"
trigger18 = enemynear, name = "karakuri"
trigger19 = enemynear, name = "phobos"
trigger20 = enemynear, name = "Abyss-First type"
trigger21 = enemynear, name = "God Gundam"
trigger22 = enemynear, name = "ShinGetter1"
var(14) = 1 - (1*(enemynear, stateno = 5150))

[State -2, Who isn't?]
type = VarSet
triggerall = root, var(17) >= 20
trigger1  = enemynear, name != "Sentinel"
trigger2  = enemynear, name != "Sentinel by ER"
trigger3  = enemynear, name != "Iron Man"
trigger4  = enemynear, name != "Iron-Man"
trigger5  = enemynear, name != "War Machine"
trigger6  = enemynear, name != "Marvel vs. Capcom's WarMachine"
trigger7  = enemynear, name != "Dr. Doom"
trigger8  = enemynear, name != "Doctor Doom"
trigger9  = enemynear, name != "Dr. Doom by WhiteMagic2002"
trigger10 = enemynear, name != "Dr.Doom"
trigger11 = enemynear, name != "Dr. Doom By {_Carnificina_}"
trigger12 = enemynear, name != "Tron Bonne"
trigger13 = enemynear, name != "Tron"
trigger14 = enemynear, name != "Abyss Form 1"
trigger15 = enemynear, name != "Chotto-Ko Mech-Gouki"
trigger16 = enemynear, name != "Mech Gouki"
trigger17 = enemynear, name != "Mazinger Z"
trigger18 = enemynear, name != "karakuri"
trigger19 = enemynear, name != "phobos"
trigger20 = enemynear, name != "Abyss-First type"
trigger21 = enemynear, name != "God Gundam"
trigger22 = enemynear, name != "ShinGetter1"
var(14) = 0
; --------------------------------------------------------

;;;;;;;;;;;;; Feature 9: Aerial Rave Prev Fix ;;;;;;;;;;;;
; --------------------------------------------------------
; Used Vars for this feature: 1
; - var(15) ** Detect Very big chars or Bosses that don't
;              allow aerial rave finishers.
[State -4, Special Cases for AR]
type = VarSet
trigger1  = p2name != "Apocalypse"
trigger2  = p4name != "Apocalypse"
trigger3  = p2name != "Onslaught"
trigger4  = p4name != "Onslaught"
trigger5  = P2name != "Abyss Form 1"
trigger6  = P4name != "Abyss Form 1"
trigger7  = P2name != "Abyss Form 2"
trigger8  = P4name != "Abyss Form 2"
trigger9  = P2name != "Abyss Form 3"
trigger10 = P4name != "Abyss Form 3"
trigger11 = P2name != "Abyss"
trigger12 = P4name != "Abyss"
var(15) = 1

[State -4, Special Cases for AR]
type = VarSet
trigger1  = p2name = "Apocalypse"
trigger2  = p4name = "Apocalypse"
trigger3  = p2name = "Onslaught"
trigger4  = p4name = "Onslaught"
trigger5  = P2name = "Abyss Form 1"
trigger6  = P4name = "Abyss Form 1"
trigger7  = P2name = "Abyss Form 2"
trigger8  = P4name = "Abyss Form 2"
trigger9  = P2name = "Abyss Form 3"
trigger10 = P4name = "Abyss Form 3"
trigger11 = P2name = "Abyss"
trigger12 = P4name = "Abyss"
var(15) = 0
; --------------------------------------------------------

[State MS - M, DisplayToClipboard]
type = DisplayToClipboard
trigger1 = 1
text = "F.Attack: %d, H.Count: %d, A.Rave: %d, Danger: %d, D.Holder: %d\n"
params = var(1), var(2), var(3), var(4), var(5)

[State MS - M, AppendToClipboard]
type = AppendToClipboard
trigger1 = 1
text = "Root: %d, Partner: %d, R.StateNo: %d, P.StateNo: %d"
;text = "E.Helper(1338000001): %d, P.Helper(1338000001): %d, var(7): %d"
;text = "R.MoveHit: %d, R.Time: %d, E.StateNo: %d, E.HSO: %d, E.Time: %d"
;text = "MatchNo: %d, var(9): %d, var(10): %d, NumEnemy: %d, NumPartner: %d"
params = (Root, ID), (Partner, ID), (Root, StateNo), (Partner, StateNo)
;params = (enemynear, NumHelper(1338000001)), (partner, NumHelper(1338000001)), var(7)
;params = (root, movehit), (root, time), (enemynear, stateno), (enemynear, hitshakeover), (enemynear, time)
;params = MatchNo, var(9), var(10), NumEnemy, NumPartner

[State MS - END] ;ctrl a tick ago
type = Null
trigger1 = var(0) := root, ctrl

; ========================================================================
; Feature Helpers:
; This sections contains the helpers that are called back in the main
; system helper, most are self-explanatory
; ========================================================================

; ========================================================================
;K.O. Helper (for simul mode)
;This one is called in roundstate 2 when one of the two chars in the team
;die. Override to fit your needs.
[StateDef 1338000000]
anim = 1337000000
ctrl = 0

[State FX, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow
flag2 = invisible

[State FX-1, PlaySnd]
type = PlaySnd
triggerall = root, var(17) >= 20
trigger1 = time = 0
value = f20000, 0
volume = 200

; ------------------------------
[State FX-2, Explod]
type = Explod
triggerall = root, var(17) = [20, 21]
trigger1 = time = 0
anim = f9900
pos = 160, 120
postype = back
removetime = -2
supermovetime = 999999
pausemovetime = 999999
scale = 0.5, 0.5
ownpal = 1
ontop = 1

[State FX-4a, Pause]
type = SuperPause
triggerall = root, var(17) = [20, 21]
trigger1 = time = 0
anim = -1
time = 60
; ------------------------------

; ------------------------------
[State FX-4b, Pause]
type = Pause
triggerall = (root, var(17) = [10, 11]) || (root, var(17) = [30, 31])
triggerall = (time % 1) = 0
trigger1 = root, stateno = [5000, 5050]
trigger2 = root, stateno = [6000, 6999]
time = 1
; ------------------------------

[State FX-4, Exit]
type = DestroySelf
trigger1 = ifelse((root, var(17) = [20, 21]), time >= 0, (root, Stateno = [5100, 5150]))


; ========================================================================
; Hyper Background Effects (includes DHC Bg Changers)
; This is a very basic version, if you need to fit some custom needs, you
; must override this helper.
[Statedef 1338000001]
anim = 1337000000
ctrl = 0

; Here you must stablish the Hyper Cancel Var for each char, is strongly
;recomended that the var is var(31) because this var is related to any
;tag system features (mainly Delayed Hyper Combo System).
[State HBG, Hyper Cancel VarSet]
type = VarSet
trigger1 = 1
var(0) = root, var(31)

[State HBG, VarSet]
type = VarSet
trigger1 = 1
var(1) = partner, var(30)

[State HBG, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow
flag2 = invisible

; Thanks to _nabeshin_ for the Hyper BG Sprites.
[State HBG, DHC]
type = AssertSpecial
triggerall = root, var(17) >= 10
trigger1 = root, stateno = [3000, 3999]
flag = noBG
flag2 = noFG

;Hyper BG Changer (for HC)
;------------------------------
; Level 2
[State HBG, Hyper BG Right]
type = Explod
triggerall = root, var(17) >= 20
triggerall = root, time = 1
triggerall = var(0) = 2
trigger1 = root, stateno = [3000, 3999]
removetime = 52
anim = f9203
ID = 9203
pos = -161, 0
postype = right
sprpriority = -5
facing = -1
bindtime = -1
supermovetime = 51
removeongethit = 1

[State HBG, Hyper BG Left]
type = Explod
triggerall = root, var(17) >= 20
triggerall = root, time = 1
triggerall = var(0) = 2
trigger1 = root, stateno = [3000, 3999]
removetime = 52
anim = f9203
ID = 9213
pos = 160, 0
postype = left
sprpriority = -5
facing = 1
bindtime = -1
supermovetime = 51
removeongethit = 1

; Level 3
[State HBG, Hyper BG Right]
type = Explod
triggerall = root, var(17) >= 20
triggerall = root, time = 1
triggerall = var(0) = 3
trigger1 = root, stateno = [3000, 3999]
removetime = 52
anim = f9204
ID = 9204
pos = -161, 0
postype = right
sprpriority = -5
facing = -1
bindtime = -1
supermovetime = 51
removeongethit = 1

[State HBG, Hyper BG Left]
type = Explod
triggerall = root, var(17) >= 20
triggerall = root, time = 1
triggerall = var(0) = 3
trigger1 = root, stateno = [3000, 3999]
removetime = 52
anim = f9204
ID = 9214
pos = 160, 0
postype = left
sprpriority = -5
facing = 1
bindtime = -1
supermovetime = 51
removeongethit = 1

;Hyper BG (Color may change if HC var is active)
;-----------------------------------------------
[State HBG, HBG R]
type = Explod
triggerall = root, var(17) >= 10
triggerall = !NumExplod(9200)
trigger1 = root, stateno = [3000, 3999]
trigger1 = root, time >= 52
anim = f(ifelse((root, var(17) = [10, 11]), 400, 9200) + (ifelse((root, var(17) >= 20), (var(0) - 1), 0)))
postype = right
ID = 9200
sprpriority = -5
supermovetime = 500
removetime = -1
pos = ifelse((root, var(17) = [10, 11]), 0, -161), 0
bindtime = -1
facing = -1

[State HBG, HBG L]
type = Explod
triggerall = root, var(17) >= 20
triggerall = !NumExplod(9210)
trigger1 = root, stateno = [3000, 3999]
trigger1 = root, time >= 52
anim = f(9200 + (var(0) - 1))
postype = left
ID = 9210
sprpriority = -5
supermovetime = 500
removetime = -1
pos = 160,0
bindtime = -1

; Remove Effects
; --------------------------------------
[State HBG, Delayed Hyper Combo Change]
type = RemoveExplod
trigger1 = var(1) = 6

[State HBG, Remove Hyper BG (right)]
type = RemoveExplod
trigger1 = root, stateno != [3000, 3999]
trigger2 = root, stateno = [3000, 3999]
trigger2 = root, time = [0, 52]
trigger3 = NumExplod(9400) != 0    ; Hyper Combo Finish is active
id = 9200

[State HBG, Remove Hyper BG (left)]
type = RemoveExplod
trigger1 = root, stateno != [3000, 3999]
trigger2 = root, stateno = [3000, 3999]
trigger2 = root, time = [0, 52]
trigger3 = NumExplod(9400) != 0    ; Hyper Combo Finish is active
id = 9210

[State HBG, Remove Hyper BG Changer (level 1, right)]
type = RemoveExplod
trigger1 = root, stateno != [3000, 3999]         ; If player isn't in H.States
trigger2 = NumExplod(9400) != 0    ; Hyper Combo Finish is active
id = 9203

[State HBG, Remove Hyper BG Changer (level 1, left)]
type = RemoveExplod
trigger1 = root, stateno != [3000, 3999]         ; If player isn't in H.States
trigger2 = NumExplod(9400) != 0    ; Hyper Combo Finish is active
id = 9213

[State HBG, Remove Hyper BG Changer (level 2, right)]
type = RemoveExplod
trigger1 = root, stateno != [3000, 3999]         ; If player isn't in H.States
trigger2 = NumExplod(9400) != 0    ; Hyper Combo Finish is active
id = 9204

[State HBG, Remove Hyper BG Changer (level 2, left)]
type = RemoveExplod
trigger1 = root, stateno != [3000, 3999]         ; If player isn't in H.States
trigger2 = NumExplod(9400) != 0    ; Hyper Combo Finish is active
id = 9214

;-------------------------------------------------------
; Hyper Combo Finish
; Thanks to Erradicator for the Hyper Combo Finish BG!!!
[State HCF, HCF Varset]
type = VarSet
trigger1 = 1
var(7) = Helper(1337000000), var(7)

[State HCF, HCF Varset]
type = VarSet
trigger1 = 1
var(8) = Helper(1337000000), var(8)

[State HCF, 1 as_EX]
type = AssertSpecial
triggerall = root, var(17) >= 10
triggerall = (var(7)) && (!var(8))
trigger1 = NumExplod(9400)
flag = NoBG
flag2 = NoBarDisplay
flag3 = NoFG

[State HCF, 2 as_EX]
type = PlaySnd
triggerall = root, var(17) >= 10
trigger1 = (var(7) = 1) && (!var(8))
value = f(ifelse((root, var(17) = [10, 11]), 8550, 20000)), (ifelse((root, var(17) = [10, 11]), 0, 1))
volume = 200
persistent = 0

; Hyper Combo Finish BG (thanks to Erradicator)
[State HCF, 3 as_EX]
type = Explod
triggerall = root, var(17) >= 10
trigger1 = (var(7) = 1) && (!var(8))
ID = 9400
anim = f(ifelse((root, var(17) = [10, 11]), 500, 9400))
postype = back
pos = 0, 0
bindtime = -1
removetime = -2
sprpriority = -5
persistent = 0

[State HCF, DestroySelf]
type = DestroySelf
triggerall = !NumExplod(9400)
trigger1 = root, stateno != [3000, 3999]


; ========================================================================
; Hyper Background Effects (Dual Hyper)
[Statedef 1338000002]
ctrl = 0
anim = 1337000000

[State DHBG, AS - 1]
type = AssertSpecial
trigger1 = 1
flag = noshadow
flag2 = invisible

[State DHBG, AS - 2]
type = AssertSpecial
triggerall = root, var(17) >= 10
trigger1 = 1
flag = noBG
flag2 = noFG

[State DHBG, Dual Hyper Explod]
type = Explod
trigger1 = time = 0
pos = (floor(partner, pos X) * facing) + 190, -55
anim = f(ifelse(root, var(17) >= 20, 9100, 102))
supermovetime = 500
sprpriority = 5
scale = ifelse(root, var(17) >= 10, 0.5, 1), ifelse(root, var(17) >= 10, 0.5, 1)
bindtime = 1

; Thanks to _nabeshin_ for the Hyper BG Sprites.
;Hyper BG (Dual Hyper)
;------------------------------
[State DHBG, Hyper BG Right]
type = Explod
triggerall = root, var(17) >= 10
trigger1 = time = 0
removetime = -1
anim = f(ifelse(root, var(17) >= 20, 9300, 400))
ID = 9300
pos = -161, 0
postype = right
sprpriority = -5
facing = -1
bindtime = -1
supermovetime = 500

[State DHBG, Hyper BG Left]
type = Explod
triggerall = root, var(17) >= 10
trigger1 = time = 0
removetime = -1
anim = f(ifelse(root, var(17) >= 20, 9300, 400))
ID = 9300
pos = 160, 0
postype = left
sprpriority = -5
facing = 1
bindtime = -1
supermovetime = 500

[State DHBG, HBG Hyper Sound]
type = PlaySnd
trigger1 = Time = 0
value =  f20, ifelse(root, var(17) >= 20, 1, 0)
volume = 255
channel = 2

[State DHBG, HBG Sound]
type = PlaySnd
triggerall = root, var(17) >= 20
trigger1 = Time = 4
value =  f21, 0
volume = 255
channel = 3

[State DHBG, x1]
type = RemoveExplod
trigger1 = root, stateno != [4601, 4609] ; Not in Dual Hyper states
trigger2 = NumExplod(9400) != 0          ; Hyper Combo Finish is active
ID = 9300

;-------------------------------------------------------
; Hyper Combo Finish
; Thanks to Erradicator for the Hyper Combo Finish BG!!!
[State HCF, HCF Varset]
type = VarSet
trigger1 = 1
var(7) = Helper(1337000000), var(7)

[State HCF, HCF Varset]
type = VarSet
trigger1 = 1
var(8) = Helper(1337000000), var(8)

[State HCF, 1 as_EX]
type = AssertSpecial
triggerall = root, var(17) >= 10
triggerall = (var(7)) && (!var(8))
trigger1 = NumExplod(9400)
flag = NoBG
flag2 = NoBarDisplay
flag3 = NoFG

[State HCF, 2 as_EX]
type = PlaySnd
triggerall = root, var(17) >= 10
trigger1 = (var(7) = 1) && (!var(8))
value = f(ifelse((root, var(17) = [10, 11]), 8550, 20000)), (ifelse((root, var(17) = [10, 11]), 0, 1))
volume = 200
persistent = 0

; Hyper Combo Finish BG (thanks to Erradicator)
[State HCF, 3 as_EX]
type = Explod
triggerall = root, var(17) >= 10
trigger1 = (var(7) = 1) && (!var(8))
ID = 9400
anim = f(ifelse((root, var(17) = [10, 11]), 500, 9400))
postype = back
pos = 0, 0
bindtime = -1
removetime = -2
sprpriority = -5
persistent = 0

[State DHBG, x2]
type = DestroySelf
triggerall = !NumExplod(9400)
trigger1 = root, stateno != [4601, 4609]

; ========================================================================
; Score Helper
[Statedef 1338000003]
anim = 1337000000
ctrl = 0

[State S, 0]
type = Varset
trigger1 = 1
var(0) = parent, var(11)

[State S, Units]
type = Explod
trigger1 = !NumExplod(9600)
anim = f(ifelse((root, var(17) >= 20), 9600, 250)) + (var(0) - var(0) / 10 * 10)
ID = 9600
postype = left
pos = 114 + 160 * (teamside = 2), ifelse(((root, var(17) = [10, 11]) || (root, var(17) = [30, 31])), 5, 2)
bindtime = -1
removetime = 10
sprpriority = 2
ownpal = 1
facing = facing
scale = ifelse((root, var(17) >= 20), 0.5, 1), ifelse((root, var(17) >= 20), 0.5, 1)

[State S, Dozens]
type = Explod
trigger1 = !NumExplod(9601) && var(0) > 9
anim = f(var(0) / 10 - var(0) / 100 * 10) + (ifelse((root, var(17) >= 20), 9600, 250))
ID = 9601
postype = left
pos = 114 + 160 * (teamside = 2) - 8, ifelse(((root, var(17) = [10, 11]) || (root, var(17) = [30, 31])), 5, 2)
bindtime = -1
removetime = 10
sprpriority = 2
ownpal = 1
facing = facing
scale = ifelse((root, var(17) >= 20), 0.5, 1), ifelse((root, var(17) >= 20), 0.5, 1)

[State S, Hundreds]
type = Explod
trigger1 = !NumExplod(9602) && var(0) > 99
anim = f(var(0) / 100 - var(0) / 1000 * 10) + (ifelse((root, var(17) >= 20), 9600, 250))
ID = 9602
postype = left
pos = 114 + 160 * (teamside = 2) - 16, ifelse(((root, var(17) = [10, 11]) || (root, var(17) = [30, 31])), 5, 2)
bindtime = -1
removetime = 10
sprpriority = 2
ownpal = 1
facing = facing
scale = ifelse((root, var(17) >= 20), 0.5, 1), ifelse((root, var(17) >= 20), 0.5, 1)

[State S, Thousands]
trigger1 = !NumExplod(9603) && var(0) > 999
type = Explod
anim = f(var(0) / 1000 - var(0) / 10000 * 10) + (ifelse((root, var(17) >= 20), 9600, 250))
ID = 9603
postype = left
pos = 114 + 160 * (teamside = 2) - 24, ifelse(((root, var(17) = [10, 11]) || (root, var(17) = [30, 31])), 5, 2)
bindtime = -1
removetime = 10
sprpriority = 2
ownpal = 1
facing = facing
scale = ifelse((root, var(17) >= 20), 0.5, 1), ifelse((root, var(17) >= 20), 0.5, 1)

[State S, Ten Thousand]
trigger1 = !NumExplod(9604) && var(0) > 9999
type = Explod
anim = f(var(0) / 10000 - var(0) / 100000 * 10) + (ifelse((root, var(17) >= 20), 9600, 250))
ID = 9604
postype = left
pos = 114 + 160 * (teamside = 2) - 32, ifelse(((root, var(17) = [10, 11]) || (root, var(17) = [30, 31])), 5, 2)
bindtime = -1
removetime = 10
sprpriority = 2
ownpal = 1
facing = facing
scale = ifelse((root, var(17) >= 20), 0.5, 1), ifelse((root, var(17) >= 20), 0.5, 1)

[State S, Hundred Thousand]
trigger1 = !NumExplod(9605) && var(0) > 99999
type = Explod
anim = f(var(0) / 100000 - var(0) / 1000000 * 10) + (ifelse((root, var(17) >= 20), 9600, 250))
ID = 9605
postype = left
pos = 114 + 160 * (teamside = 2) - 40, ifelse(((root, var(17) = [10, 11]) || (root, var(17) = [30, 31])), 5, 2)
bindtime = -1
removetime = 10
sprpriority = 2
ownpal = 1
facing = facing
scale = ifelse((root, var(17) >= 20), 0.5, 1), ifelse((root, var(17) >= 20), 0.5, 1)

[State S, Millions]
trigger1 = !NumExplod(9606) && var(0) > 999999
type = Explod
anim = f(var(0) / 1000000 - var(0) / 10000000 * 10) + (ifelse((root, var(17) >= 20), 9600, 250))
ID = 9606
postype = left
pos = 114 + 160 * (teamside = 2) - 48, ifelse(((root, var(17) = [10, 11]) || (root, var(17) = [30, 31])), 5, 2)
bindtime = -1
removetime = 10
sprpriority = 2
ownpal = 1
facing = facing
scale = ifelse((root, var(17) >= 20), 0.5, 1), ifelse((root, var(17) >= 20), 0.5, 1)

[State S, Ten Million]
trigger1 = !NumExplod(9607) && var(0) > 9999999
type = Explod
anim = f(var(0) / 10000000 - var(0) / 100000000 * 10) + (ifelse((root, var(17) >= 20), 9600, 250))
ID = 9607
postype = left
pos = 114 + 160 * (teamside = 2) - 56, ifelse(((root, var(17) = [10, 11]) || (root, var(17) = [30, 31])), 5, 2)
bindtime = -1
removetime = 10
sprpriority = 2
ownpal = 1
facing = facing
scale = ifelse((root, var(17) >= 20), 0.5, 1), ifelse((root, var(17) >= 20), 0.5, 1)

[State S, Hundred Million]
trigger1 = !NumExplod(9608) && var(0) > 99999999
type = Explod
anim = f(var(0) / 100000000 - var(0) / 1000000000 * 10) + (ifelse((root, var(17) >= 20), 9600, 250))
ID = 9608
postype = left
pos = 114 + 160 * (teamside = 2) - 64, ifelse(((root, var(17) = [10, 11]) || (root, var(17) = [30, 31])), 5, 2)
bindtime = -1
removetime = 10
sprpriority = 2
ownpal = 1
facing = facing
scale = ifelse((root, var(17) >= 20), 0.5, 1), ifelse((root, var(17) >= 20), 0.5, 1)

[State S, Billions]
trigger1 = !NumExplod(9609) && var(0) > 999999999
type = Explod
anim = f(var(0) / 1000000000 - var(0) / 10000000000 * 10) + (ifelse((root, var(17) >= 20), 9600, 250))
ID = 9609
postype = left
pos = 114 + 160 * (teamside = 2) - 72, ifelse(((root, var(17) = [10, 11]) || (root, var(17) = [30, 31])), 5, 2)
bindtime = -1
removetime = 10
sprpriority = 2
ownpal = 1
facing = facing
scale = ifelse((root, var(17) >= 20), 0.5, 1), ifelse((root, var(17) >= 20), 0.5, 1)

[State S, DestoySelf]
type = DestroySelf
trigger1 = time = 0

; ========================================================================
; Win Quotes Helper (Override this to fit your needs)
[Statedef 1338000004]
anim = 1337000000
ctrl = 0

[State WQ, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow
flag2 = invisible

[State WQ, AssertSpecial]
type = AssertSpecial
triggerall = ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = time = [0, 800]
flag = roundnotover

[State WQ, AssertSpecial]
type = AssertSpecial
triggerall = ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = time >= 200
flag = nobardisplay
flag2 = nomusic
flag3 = nofg

[State WQ, BGM]
type = StopSnd
trigger1 = time = 0
channel = -1

[State WQ, BGM]
type = PlaySnd
triggerall = ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = time = 190
value = f21000, 0
channel = 4
volume = 255

[State WQ, FX - Varset]
type = VarAdd
triggerall = ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = time >= 200
var(0) = 10

[State WQ, VarAdd]
type = VarSet
triggerall = ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = var(0) > 255
var(0) = 255

[State WQ, EnvColor]
type = EnvColor
triggerall = ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = time >= 200
value = 255 - var(0), 255 - var(0), 255 - var(0)
time = 1
under = 1

[State WQ, Win BG]
type = Explod
triggerall = ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = !NumExplod(10000) && time >= 230
anim = f10000
ID = 10000
pos = 160,120
postype = back
bindtime = -1
scale = 0.5, 0.5
sprpriority = 2
ontop = 1
ownpal = 1

[State WQ, Portraits]
type = Explod
triggerall = root, NumPartner
trigger1 = !NumExplod(9105) && time >= 230
anim = 9105
ID = 9105
pos = 65 + (250 * (root, ID > partner, ID)), 0 + (51 * (root, ID > partner, ID))
postype = back
bindtime = -1
scale = 0.5 - (0.15 * (root, ID > partner, ID)), 0.5 - (0.15 * (root, ID > partner, ID))
sprpriority = 2 - (1 * (root, ID > partner, ID))
ontop = 1
ownpal = 1
facing = ifelse((root, ID > partner, ID), -1, 1)

[State WQ, Portrait]
type = Explod
triggerall = !(root, NumPartner)
trigger1 = !NumExplod(9105) && time >= 230
anim = 9105
ID = 9105
pos = 60, 0
postype = back
bindtime = -1
scale = 0.5, 0.5
sprpriority = 2
ontop = 1
ownpal = 1

[State WQ, Text BG]
type = Explod
triggerall = ifelse((root, NumPartner), (root, ID < partner, ID), 1)
trigger1 = !NumExplod(10001) && time >= 230
anim = f10001
ID = 10001
pos = 160,120
postype = back
bindtime = -1
scale = 0.5, 0.5
sprpriority = 3
ontop = 1
ownpal = 1

[State WQ, Win Text]
type = Explod
triggerall = ifelse((root, NumPartner), (root, ID < partner, ID), 1) && !var(1)
trigger1 = !NumExplod(10020) && time >= 230
anim = 10020 + (random % 9) ;Change 9 to the number of win texts you have
ID = 10020
pos = 25, 182
postype = back
bindtime = -1
scale = 0.5, 0.5
sprpriority = 4
ontop = 1
ownpal = 1

; -----------------------------------------------------------------------
; Final Score Helper
[Statedef 1338000005]
anim = 1337000000
ctrl = 0

[State FSH, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = noshadow
flag2 = invisible

[State FSH - T, Data]
type = Explod
trigger1 = !NumExplod(10002) && (time = 230)
anim = f10002
ID = 10002
pos = 7, 2
postype = back
ownpal = 1
removetime = -1
bindtime = -1
sprpriority = 5
ontop = 1
scale = 0.5, 0.5

[State FSH, Life]
type = Varset
trigger1 = time = 0
var(1) = root, life * 10

[State FSH, Life + Partner's life]
type = Varset
trigger1 = time = 0 && NumPartner
var(1) = var(1) + partner, life * 10

[State FSH, Perfect Bonus]
type = Varset
trigger1 = time = 0 && !NumPartner
var(2) = 1000 * ((root, const(Data.life)) = (root,life)) * 10

[State FSH, Perfect Bonus if Partner != 0]
type = Varset
trigger1 = time = 0 && NumPartner
trigger1 = ((root,const(Data.life)) = (root,life))
trigger1 = ((partner,const(Data.life)) = (partner,life))
var(2) = ((partner,life) + (root,life)) * 10

[State FSH, Time Bonus]
type = Varset
trigger1 = time = 0
var(3) = (100 - ceil((Helper(1337000000), var(12)) / 60)) * 10

[State FSH, Max Combo Bonus]
type = Varset
trigger1 = time = 0
var(4) = Helper(1337000000), var(13) * 100

[State FSH -V, VarSet Final]
type = Varset
trigger1 = time = 0
var(0) = (var(1) + var(2) + var(3) + var(4))

;------------------------
[State FSH, Set Values]
type = Varset
trigger1 = time = [230, 233]
var(5) = var((time + 1) - 230)

[State FSH, Units]
type = Explod
trigger1 = time = [230, 233]
anim = f(var(5) - var(5) / 10 * 10) + 10010
postype = left
pos = 80, (((time + 1) - 230) * 28) - 13
bindtime = -1
removetime = -1
ontop = 1
ownpal = 1
scale = 0.5, 0.5

[State FSH, Dozens]
type = Explod
trigger1 = time = [230, 233]
trigger1 = var(5) > 9
anim = f(var(5) / 10 - var(5) / 100 * 10) + 10010
postype = left
pos = 80 - 10, (((time + 1) - 230) * 28) - 13
bindtime = -1
removetime = -1
ontop = 1
ownpal = 1
scale = 0.5, 0.5

[State FSH, Hundreds]
type = Explod
trigger1 = time = [230, 233]
trigger1 = var(5) > 99
anim = f(var(5) / 100 - var(5) / 1000 * 10) + 10010
postype = left
pos = 80 - 20, (((time + 1) - 230) * 28) - 13
bindtime = -1
removetime = -1
ontop = 1
ownpal = 1
scale = 0.5, 0.5

[State FSH, Thousands]
type = Explod
trigger1 = time = [230, 233]
trigger1 = var(5) > 999
anim = f(var(5) / 1000 - var(5) / 10000 * 10) + 10010
postype = left
pos = 80 - 30, (((time + 1) - 230) * 28) - 13
bindtime = -1
removetime = -1
ontop = 1
ownpal = 1
scale = 0.5, 0.5

[State FSH, Ten Thousands]
type = Explod
trigger1 = time = [230, 233]
trigger1 = var(5) > 9999
anim = f(var(5) / 10000 - var(5) / 100000 * 10) + 10010
postype = left
pos = 80 - 40, (((time + 1) - 230) * 28) - 13
bindtime = -1
removetime = -1
ontop = 1
ownpal = 1
scale = 0.5, 0.5

