; Common state file for M.U.G.E.N 1.0
;
; System variables usage
; ----------------------
; Var name    Type   Purpose
; --------    ----   -------
; sysvar(0)   Temp   Set by state 5081 (HITL_SLIDE) 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.
;                    Used by state 5100 and 5110 to remember downward
;                    velocity of player just before hitting the ground.
;                    Used in state 5080 for storing the anim # to display.
; sysvar(4)   Perm   Current round state
;                    -1: Next round
;                    -2: Versus screen
;                    -3: Ready...FIGHT!
;                    -4: Match in progress
;                    -5: DOWN...FIGHT!
;                    -6: KO
;                    -7: Winscreen
;                    -8: Round is over
;                    -9: Demo Mode
; Var(50)     Perm   Round timer. Starts at 99 and decreases
; Var(51)     Perm   Timer rate: decreases every tick.
; var(52)     Perm   Am I P1 or P2?
; var(53)     Perm   UVVWXYZZ -U: Max life stocks
;                             -VV: Max time (00 = Infinite)
;                             -W: Timer Speed
;                             -X: Life stocks
;                             -Y: Max Power Stocks (0 = 99)
;                             -ZZ: Number of Power stocks
; var(54)     Perm   ---VWXYZ -V: Number of times finished w/right super?
;                             -W: Have continued/lost a life?
;                             -X: Is training data menu on? 
;                             -Y: Is training mode menu active?
;                             -Z: Is training mode?
; var(55)     Temp   Type of hit for cornerpush purposes
; var(56)     Temp   Countdown till cornerpush ends
; var(57)     Temp   Apply cornerpush if need be?
; var(58)     Temp   Recoverable life
; var(59)     Temp   Recoverable life timer
;
; slidetime          --VVVXYZ -VVV: Recoverable life damage
;                             -X: 0 - Ground attack, 1 - Aerial attack
;                             -Y: 0 - Facing left, 1 - Facing right
;                             -Z: Hit strength

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

[Statedef -2]

[State -2, No hits after KO]
type = NotHitBy
trigger1 = Sysvar(4) = 6
value = SCA

[State -2, Balance the bar]
type = VarSet
trigger1 = var(58) < Life
var(58) = Life
ignorehitpause = 1

;----------
;Regenerate
[State -2, LifeTimer]
type = VarAdd
trigger1 = MoveType != H
trigger1 = var(50) > 0
trigger1 = (sysvar(4) = 4) || (sysvar(4) = 10)
var(59) = -1
ignorehitpause = 1

[State -2, 0]
type = Explod
triggerall = var(52) = Facing
trigger1 = sysvar(4) = [4,6]
trigger2 = sysvar(4) = 10
trigger3 = StateNo = 190
trigger3 = Time > 129
anim = F6701
postype = back
pos = 159.5,16
facing = -1
scale = (Life - 1),1
bindtime = -1
sprpriority = -98
ignorehitpause = 1

[State -2, 0]
type = Explod
triggerall = var(52) != Facing
trigger1 = sysvar(4) = [4,6]
trigger2 = sysvar(4) = 10
trigger3 = StateNo = 190
trigger3 = Time > 129
anim = F6701
postype = back
pos = 224,16
scale = (Life - 1),1
bindtime = -1
sprpriority = -98
ignorehitpause = 1

[State -2, 0]
type = Explod
triggerall = var(50) > 0
triggerall = var(52) = Facing
trigger1 = sysvar(4) = 4
trigger2 = sysvar(4) = 10
trigger3 = StateNo = 190
trigger3 = Time > 129
anim = F6700
facing = -1
postype = back
pos = 159.5,16
scale = (var(58) - 1),1
bindtime = -1
sprpriority = -99
ignorehitpause = 1

[State -2, 0]
type = Explod
triggerall = var(50) > 0
triggerall = var(52) != Facing
trigger1 = sysvar(4) = 4
trigger2 = sysvar(4) = 10
trigger3 = StateNo = 190
trigger3 = Time > 129
anim = F6700
postype = back
pos = 224,16
scale = (var(58) - 1),1
bindtime = -1
sprpriority = -99
ignorehitpause = 1

[State -2, Life Regain]
type = LifeAdd
triggerall = var(50) > 0
trigger1 = var(58) > Life
trigger1 = var(59) = 0
trigger1 = MoveType != H
trigger1 = (sysvar(4) = 4) || (sysvar(4) = 10)
value = 1
ignorehitpause = 1

[State -2, LifeTimer]
type = VarSet
triggerall = var(50) > 0
trigger1 = var(59) < 1
trigger1 = MoveType != H
trigger1 = (sysvar(4) = 4) || (sysvar(4) = 10)
var(59) = 9
ignorehitpause = 1
;----------

;----------
;Cornerpush
[State -2, Is cornerpush applicable?]
type = VarSet
trigger1 = Enemy, BackEdgeBodyDist = 0
trigger1 = StateType != A
trigger1 = Enemy, StateType != A
trigger1 = Enemy, StateNo != [5020,5070]
var(57) = 1
ignorehitpause = 1

[State -2, Turn cornerpush off?]
type = VarSet
trigger1 = Enemy, BackEdgeBodyDist > 0
trigger2 = StateType = A
trigger3 = Enemy, StateType = A
trigger4 = Enemy, StateNo = [5020,5070]
var(57) = 0
ignorehitpause = 1

[State -2, If opponent dead, clear timer]
type = VarSet
trigger1 = var(56)
trigger1 = Enemy, StateNo = [5020,5070]
var(56) = 0

;Light Gethit
[State 5001, 1]
type = PosAdd
trigger1 = var(56) = [8,11]
trigger1 = var(55) = 1
trigger1 = var(57)
X = -4

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = [5,7]
trigger1 = var(55) = 1
trigger1 = var(57)
X = -3

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 4
trigger1 = var(55) = 1
trigger1 = var(57)
X = -2

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = [1,3]
trigger1 = var(55) = 1
trigger1 = var(57)
X = -1

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 11
trigger1 = var(55) = 2
trigger1 = var(57)
X = -3

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = [8,10]
trigger1 = var(55) = 2
trigger1 = var(57)
X = -4

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 7
trigger1 = var(55) = 2
trigger1 = var(57)
X = -5

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = [5,6]
trigger1 = var(55) = 2
trigger1 = var(57)
X = -6

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 4
trigger1 = var(55) = 2
trigger1 = var(57)
X = -5

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 3
trigger1 = var(55) = 2
trigger1 = var(57)
X = -4

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 2
trigger1 = var(55) = 2
trigger1 = var(57)
X = -3

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 1
trigger1 = var(55) = 2
trigger1 = var(57)
X = -2

;Heavy Gethit
[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 20
trigger1 = var(55) = 3
trigger1 = var(57)
X = -4

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 19
trigger1 = var(55) = 3
trigger1 = var(57)
X = -5

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 18
trigger1 = var(55) = 3
trigger1 = var(57)
X = -6

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 17
trigger1 = var(55) = 3
trigger1 = var(57)
X = -7

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = [15,16]
trigger1 = var(55) = 3
trigger1 = var(57)
X = -8

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 14
trigger1 = var(55) = 3
trigger1 = var(57)
X = -7

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 13
trigger1 = var(55) = 3
trigger1 = var(57)
X = -6

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 12
trigger1 = var(55) = 3
trigger1 = var(57)
X = -5

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 11
trigger1 = var(55) = 3
trigger1 = var(57)
X = -4

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 10
trigger1 = var(55) = 3
trigger1 = var(57)
X = -3

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = 9
trigger1 = var(55) = 3
trigger1 = var(57)
X = -2

[State 5001, 1]
type = PosAdd
trigger1 = var(56) = [1,8]
trigger1 = var(55) = 3
trigger1 = var(57)
X = -1

[State -2, Start decreasing]
type = VarAdd
trigger1 = var(56)
var(56) = -1
;----------

[State -2]
type = VarSet
trigger1 = Enemy, sysvar(4) = 6
sysvar(4) = 6
ignorehitpause = 1

[State -2]
type = VarSet
trigger1 = Enemy, sysvar(4) = 7
sysvar(4) = 7
ignorehitpause = 1

[State -2]
type = RemoveExplod
trigger1 = NumExplod(6020)
trigger1 = Enemy, StateNo = 6200
trigger2 = StateNo = [5700,5900]
trigger3 = stateno = 6200
ID = 6020

[State -2]
type = LifeSet
triggerall = Enemy, StateNo = 6200
triggerall = StateNo = 5150
triggerall = Enemy, Time > 100
trigger1 = Enemy, Time = 434
trigger2 = Enemy, command = "x"
trigger3 = Enemy, command = "y"
trigger4 = Enemy, command = "z"
trigger5 = Enemy, command = "a"
trigger6 = Enemy, command = "b"
trigger7 = Enemy, command = "c"
value = 0

[State -2]
type = LifeSet
trigger1 = enemy, sysvar(4) = 8
value = 0

[State -2]
type = VarAdd
triggerall = SysVar(4) = 4
trigger1 = var(50) != 0
trigger2 = var(50) = 0
trigger2 = var(51) > 0
v = 51
value = -1
ignorehitpause = 1

[State -2]
type = VarAdd
trigger1 = SysVar(4) = 4
trigger1 = Var(51) = 0
trigger1 = Var(50) > 0
trigger1 = Var(50) != 101
trigger1 = Life > 1
v = 50
value = -1
ignorehitpause = 1

[State -2]
type = VarSet
trigger1 = SysVar(4) = 4
trigger1 = Var(51) = 0
trigger1 = var(50) > 0
v = 51
value = 2;109
ignorehitpause = 1

[State -2, 0]
type = ChangeState
trigger1 = Sysvar(4) = 4
trigger1 = (ctrl = 1) || (stateno = 0)
trigger1 = var(51) = 0
trigger1 = var(50) = 0
trigger1 = Enemy, var(50) = 0
trigger1 = Enemy, var(51) = 0
trigger1 = Pos Y = 0
value = 170
ctrl = 0
ignorehitpause = 1

[State -2, Timer1]
type = Explod
triggerall = TeamSide = 1
triggerall = Var(50) != 101
trigger1 = SysVar(4) = [4,6]
trigger2 = Time > 170
trigger2 = StateNo = 190
removetime = 1
postype = left
pos = 178,22
bindtime = -1
anim = F6000 + (Floor(Var(50)/10) % 10)
sprpriority = -90
ownpal = 1
ignorehitpause = 1

[State -2, Timer1]
type = Explod
triggerall = TeamSide = 1
triggerall = Var(50) = 101
trigger1 = SysVar(4) = [4,6]
trigger2 = Time > 170
trigger2 = StateNo = 190
trigger3 = sysvar(4) = 10
removetime = 1
postype = left
pos = 178,22
bindtime = -1
anim = F6010
sprpriority = -90
ownpal = 1
ignorehitpause = 1

[State -2, Timer1]
type = Explod
triggerall = TeamSide = 1
triggerall = Var(50) != 101
trigger1 = SysVar(4) = [4,6]
trigger2 = Time > 170
trigger2 = StateNo = 190
removetime = 1
postype = left
pos = 194,22
bindtime = -1
anim = F6000 + (Var(50) % 10)
sprpriority = -90
ownpal = 1
ignorehitpause = 1

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

[Statedef -3]

[State -3]
type = DisplaytoClipboard
trigger1 = 1
text = "%f, %i, %i"
params = Floor(P2BodyDist X), movehit, -1*abs(((Floor(gethitvar(xvel)/1))))
ignorehitpause = 1

[State -3, Temp Power Boost to avoid bug]
type = PowerSet
trigger1 = Power = 0
value = 1