;XTSM Data
;var(0) = Keep track of in round time.
;var(1) = P1 Score
;var(2) = P2 Score
;var(3) = P1 Lives
;var(4) = P2 Lives
;var(5) = P1 Bullets
;var(6) = P2 Bullets
;var(7) = P1 Gun
;var(8) = P2 Gun
;var(9) = P1 Shots Fired
;var(10) = P2 Shots Fired
;var(11) = P1 Shots Hit
;var(12) = P2 Shots Hit
;var(13) = P1 Victims
;var(14) = P2 Victims
;var(15) = P1 Rings
;var(16) = P2 Rings
;var(17) = P1 Accuracy
;var(18) = P2 Accuracy
;var(20) = Konami Code
;var(21) = Enemy AI (disable P2)
;var(22) = P1 Bonus
;var(23) = P2 Bonus
;var(24) = Match Editor
;var(25) = Stage Editor
;var(26) = Duck Shot Count
;var(27) = Total Ducks/Discs
;var(28) = Fire the Torpedos!
;var(29) = P1 Amount of Sonic Chars
;var(30) = P2 Amount of Sonic Chars 
;var(31) = P1 Sonic Shield
;var(32) = P2 Sonic Shield
;var(33) = P1 Sonic Invincibility Timer
;var(34) = P2 Sonic Invincibility Timer

;GUNS
;0 = Handgun
;1 = Gatling Gun
;2 = Grenade Launcher
;3 = M16
;4 = Machine Gun
;5 = Flame Thrower
;6 = Shotgun

;Enemy Vars

;LETHAL ENFORCERS II ROUND
;var(0) = Enemy type.
;var(1) = Time till they fire gun.
;var(2) = Amount of points to add when shot.
;var(3) = Which player to kill?
;var(4) = Enemy classification
;var(5) = Boss Max HP
;var(6) = Boss HP
;var(7) = Invincible time between hits.

;DUCK HUNT ROUND
;var(0) = Ducks hit this round.
;fvar(0) = Scaling Var

;MARIO ROUND
;var(0) = Enemy type.
;var(1) = Rotation time.
;(ITEM BLOCK) var(0) = Coin or 1UP?
;var(3) = Which player to kill?
;var(5) = Boss/BossHelper Max HP
;var(6) = Boss/BossHelper HP
;var(7) = Invincible time between hits.

;STAR WARS ROUND
;var(1) = Time till they fire gun.
;var(2) = Used for explosion.
;var(3) = Which player to kill?

;SONIC ROUND
;var(0) = Sonic stop moving up
;var(1) = Compare Player ScreenY
;var(2) = Which character jumps out?
;ITEM BOX
;var(0) = Which item?
;var(1) = Disappear Timer.
;var(2) = Which player to give item to?

;GAME TIMER VARS
;var(0) = State Time
;var(1) = Used with Sonic Rings to determine extra lives (P1)
;var(2) = Used with Sonic Rings to determine extra lives (P2)

[Data]
;Amount of life to start with
;体力ゲージの初期値
life = 1000
;attack power (more is stronger)
;攻撃ダメージ
attack = 100
;defensive power (more is stronger)
;体力パワー
defence = 100
;Percentage to increase defense everytime player is knocked down
fall.defence_up = 50
;Time which player lies down for, before getting up
liedown.time = 60
;Number of points for juggling
airjuggle = 15
;Default hit spark number for HitDefs
sparkno = 2
;Default guard spark number
guard.sparkno = 40
;1 to enable echo on KO
KO.echo = 0
;Volume offset (negative for softer)
volume = 0

;Variables with this index and above will not have their values
;reset to 0 between rounds or matches. There are 60 int variables,
;indexed from 0 to 59, and 40 float variables, indexed from 0 to 39.
;If omitted, then it defaults to 60 and 40 for integer and float
;variables repectively, meaning that none are persistent, i.e. all
;are reset. If you want your variables to persist between matches,
;you need to override state 5900 from common1.cns.
IntPersistIndex = 1
FloatPersistIndex = 40

[Size]
xscale = 1       ;Horizontal scaling factor.
yscale = 1        ;Vertical scaling factor.
ground.back = 2     ;Player width (back, ground)
ground.front = 2    ;Player width (front, ground)
air.back = 2       ;Player width (back, air)
air.front = 2       ;Player width (front, air)
height = 20      ;Height of player (for opponent to jump over)
attack.dist = 160    ;Default attack distance
proj.attack.dist = 90 ;Default attack distance for projectiles
proj.doscale = 0     ;Set to 1 to scale projectiles too
head.pos = -5, -90   ;Approximate position of head
mid.pos = -5, -60    ;Approximate position of midsection
shadowoffset = 0     ;Number of pixels to vertically offset the shadow
draw.offset = 0,0    ;Player drawing offset in pixels (x, y)

[Velocity]
walk.fwd  = 5      ;Walk forward
walk.back = -5    ;Walk backward
run.fwd  = 4.6, 0    ;Run forward (x, y)
run.back = -4.5,-3.8 ;Hop backward (x, y)
jump.neu = 0,-11    ;Neutral jumping velocity (x, y)
jump.back = -2.5    ;Jump back Speed (x, y)
jump.fwd = 2.5       ;Jump forward Speed (x, y)
runjump.back = -2.55,-8.1 ;Running jump speeds (opt)
runjump.fwd = 4,-8.1      ;.
airjump.neu = 0,-8.1      ;.
airjump.back = -2.55      ;Air jump speeds (opt)
airjump.fwd = 2.5         ;.

[Movement]
airjump.num = 0      ;Number of air jumps allowed (opt)
airjump.height = 35  ;Minimum distance from ground before you can air jump (opt)
yaccel = .44         ;Vertical acceleration
stand.friction = .85  ;Friction coefficient when standing
crouch.friction = .82 ;Friction coefficient when crouching

;---------------------------------------------------------------------------
; Format:
; [Statedef STATENO]
; type = ?      S/C/A/L  stand/crouch/air/liedown
; movetype = ?  I/A/H    idle/attack/gethit
; physics = ?   S/C/A/N  stand/crouch/air/none
; juggle = ?             air juggle points move requires
;
; [State STATENO, ?]     ? - any number you choose
; type = ?
; ...

;State 180 is win round.  Calculate bonuses here.

;---------------------------------------------------------------------------
; Victory.  Display bonuses
[Statedef 180]
type = S
ctrl = 0
anim = 0
velset = 0,0

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

;Stop BGMusic
[State 180, StopBGMusic]
type = StopSnd
trigger1 = Time = 0
channel = 5

;Victory Music
[State 180, VictoryMusic]
type = PlaySnd
triggerall = !IsHelper
trigger1 = Time = 0
value = 181,MatchNo+var(24)-1
volume = 1
channel = 5
lowpriority = 5

;Set Accuracy
[State 180, P1Accuracy]
type = VarSet
trigger1 = Time = 0
trigger1 = var(9) != 0
v = 17
value = IfElse(ceil(100*var(11)/var(9))>100,100,ceil(100*var(11)/var(9)))

[State 180, P2Accuracy]
type = VarSet
trigger1 = Time = 0
trigger1 = var(10) != 0
v = 18
value = IfElse(ceil(100*var(12)/var(10))>100,100,ceil(100*var(12)/var(10)))

;Set Bonus
[State 180, P1Bonus]
type = VarSet
trigger1 = Time = 0
v = 22
value = IfElse(MatchNo+var(24)!=5,(30*var(11))+(80*var(17))-(70*var(13)),(30*var(11))+(50*var(15)))

[State 180, P2Bonus]
type = VarSet
trigger1 = Time = 0
v = 23
value = IfElse(MatchNo+var(24)!=5,(30*var(12))+(80*var(18))-(70*var(14)),(30*var(12))+(50*var(16)))

;Add to Score
[State 180, AddBonusP1]
type = VarAdd
trigger1 = Time = 200
v = 1
value = var(22)

[State 180, AddBonusP1]
type = VarAdd
trigger1 = Time = 200
v = 2
value = var(23)

;Display RINGS
[State 180,SHOTS]
type = Explod
triggerall = MatchNo+var(24) = 5
triggerall = !IsHelper
triggerall = Time = 0
trigger1 = NumExplod(16018) = 0
anim = 15016
ID = 16018
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 146,76

;Display #00 P1 Rings
[State 180,P1Rings]
type = Explod
triggerall = MatchNo+var(24) = 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(15) >= 100
trigger1 = NumExplod(141) = 0
anim = 15000+(var(15)/100%10)
ID = 141
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,88,232),76

;Display 0#0 P1 Rings
[State 180,P1Rings]
type = Explod
triggerall = MatchNo+var(24) = 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(15) >= 10
trigger1 = NumExplod(142) = 0
anim = 15000+(var(15)/10%10)
ID = 142
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,96,240),76

;Display 00# P1 Rings
[State 180,P1Rings]
type = Explod
triggerall = MatchNo+var(24) = 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(143) = 0
anim = 15000+(var(15)%10)
ID = 143
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,104,248),76

;Display #00 P2 Shots
[State 180,P1Shots]
type = Explod
triggerall = MatchNo+var(24) = 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(16) >= 100
trigger1 = NumExplod(145) = 0
anim = 15000+(var(16)/100%10)
ID = 145
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,88,232),76

;Display 0#0 P2 Shots
[State 180,P2Shots]
type = Explod
triggerall = MatchNo+var(24) = 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(16) >= 10
trigger1 = NumExplod(146) = 0
anim = 15000+(var(16)/10%10)
ID = 146
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,96,240),76

;Display 00# P2 Shots
[State 180,P2Shots]
type = Explod
triggerall = MatchNo+var(24) = 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(147) = 0
anim = 15000+(var(16)%10)
ID = 147
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,104,248),76

;Display SHOTS
[State 180,SHOTS]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = !IsHelper
triggerall = Time = 0
trigger1 = NumExplod(16018) = 0
anim = 15018
ID = 16018
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 144,76

;Display #000 P1 Shots
[State 180,P1Shots]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(9) >= 1000
trigger1 = NumExplod(140) = 0
anim = 15000+(var(9)/1000%10)
ID = 140
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,80,224),76

;Display 0#00 P1 Shots
[State 180,P1Shots]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(9) >= 100
trigger1 = NumExplod(141) = 0
anim = 15000+(var(9)/100%10)
ID = 141
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,88,232),76

;Display 00#0 P1 Shots
[State 180,P1Shots]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(9) >= 10
trigger1 = NumExplod(142) = 0
anim = 15000+(var(9)/10%10)
ID = 142
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,96,240),76

;Display 000# P1 Shots
[State 180,P1Shots]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(143) = 0
anim = 15000+(var(9)%10)
ID = 143
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,104,248),76

;Display #000 P2 Shots
[State 180,P2Shots]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(10) >= 1000
trigger1 = NumExplod(144) = 0
anim = 15000+(var(10)/1000%10)
ID = 144
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,80,224),76

;Display 0#00 P2 Shots
[State 180,P1Shots]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(10) >= 100
trigger1 = NumExplod(145) = 0
anim = 15000+(var(10)/100%10)
ID = 145
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,88,232),76

;Display 00#0 P2 Shots
[State 180,P2Shots]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(10) >= 10
trigger1 = NumExplod(146) = 0
anim = 15000+(var(10)/10%10)
ID = 146
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,96,240),76

;Display 000# P2 Shots
[State 180,P2Shots]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(147) = 0
anim = 15000+(var(10)%10)
ID = 147
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,104,248),76

;Display HITs
[State 180,HITS]
type = Explod
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(16017) = 0
anim = 15017
ID = 16017
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 150,92

;Display #000 P1 Hits
[State 180,P1Hits]
type = Explod
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(11) >= 1000
trigger1 = NumExplod(150) = 0
anim = 15000+(var(11)/1000%10)
ID = 150
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,80,224),92

;Display 0#00 P1 Hits
[State 180,P1Hits]
type = Explod
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(11) >= 100
trigger1 = NumExplod(151) = 0
anim = 15000+(var(11)/100%10)
ID = 151
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,88,232),92

;Display 00#0 P1 Hits
[State 180,P1Hits]
type = Explod
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(11) >= 10
trigger1 = NumExplod(152) = 0
anim = 15000+(var(11)/10%10)
ID = 152
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,96,240),92

;Display 000# P1 Hits
[State 180,P1Hits]
type = Explod
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(153) = 0
anim = 15000+(var(11)%10)
ID = 153
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,104,248),92

;Display #000 P2 Hits
[State 180,P2Hits]
type = Explod
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(12) >= 1000
trigger1 = NumExplod(154) = 0
anim = 15000+(var(12)/1000%10)
ID = 154
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,80,224),92

;Display 0#00 P2 Hits
[State 180,P2Hits]
type = Explod
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(12) >= 100
trigger1 = NumExplod(155) = 0
anim = 15000+(var(12)/100%10)
ID = 155
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,88,232),92

;Display 00#0 P2 Hits
[State 180,P2Hits]
type = Explod
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(12) >= 10
trigger1 = NumExplod(156) = 0
anim = 15000+(var(12)/10%10)
ID = 156
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,96,240),92

;Display 000# P2 Hits
[State 180,P2Hits]
type = Explod
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(157) = 0
anim = 15000+(var(12)%10)
ID = 157
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,104,248),92

;Display ACCURACY
[State 180,ACCURACY]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(16014) = 0
anim = 15014
ID = 16014
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 133,108

;Display #00% P1 Accuracy
[State 180,P1Accuracy]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(17) >= 100
trigger1 = NumExplod(160) = 0
anim = 15000+(var(17)/100%10)
ID = 160
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,80,224),108

;Display 0#0% P1 Accuracy
[State 180,P1Accuracy]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(17) >= 10
trigger1 = NumExplod(161) = 0
anim = 15000+(var(17)/10%10)
ID = 161
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,88,232),108

;Display 00#% P1 Accuracy
[State 180,P1Accuracy]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(162) = 0
anim = 15000+(var(17)%10)
ID = 162
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,96,240),108

;Display 000% P1 Accuracy
[State 180,P1Accuracy]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(163) = 0
anim = 15021
ID = 163
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,104,248),108

;Display #00% P2 Accuracy
[State 180,P2Accuracy]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(18) >= 100
trigger1 = NumExplod(164) = 0
anim = 15000+(var(18)/100%10)
ID = 164
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,80,224),108

;Display 0#0% P2 Accuracy
[State 180,P2Accuracy]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(18) >= 10
trigger1 = NumExplod(165) = 0
anim = 15000+(var(18)/10%10)
ID = 165
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,88,232),108

;Display 00#% P2 Accuracy
[State 180,P2Accuracy]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(166) = 0
anim = 15000+(var(18)%10)
ID = 166
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,96,240),108

;Display 000% P2 Accuracy
[State 180,P2Accuracy]
type = Explod
triggerall = MatchNo+var(24) != 5
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(167) = 0
anim = 15021
ID = 167
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,104,248),108

;Display VICTIMS
[State 180,VICTIMS]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(16020) = 0
anim = 15020
ID = 16020
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 139,124

;Display #000 P1 Victims
[State 180,P1Victims]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(13) >= 1000
trigger1 = NumExplod(170) = 0
anim = 15000+(var(13)/1000%10)
ID = 170
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,80,224),124

;Display 0#00 P1 Victims
[State 180,P1Victims]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(13) >= 100
trigger1 = NumExplod(171) = 0
anim = 15000+(var(13)/100%10)
ID = 171
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,88,232),124

;Display 00#0 P1 Victims
[State 180,P1Victims]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(13) >= 10
trigger1 = NumExplod(172) = 0
anim = 15000+(var(13)/10%10)
ID = 172
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,96,240),124

;Display 000# P1 Victims
[State 180,P1Victims]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(173) = 0
anim = 15000+(var(13)%10)
ID = 173
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,104,248),124

;Display #000 P2 Victims
[State 180,P2Victims]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(14) >= 1000
trigger1 = NumExplod(174) = 0
anim = 15000+(var(14)/1000%10)
ID = 174
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,80,224),124

;Display 0#00 P2 Victims
[State 180,P2Victims]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(14) >= 100
trigger1 = NumExplod(175) = 0
anim = 15000+(var(14)/100%10)
ID = 175
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,88,232),124

;Display 00#0 P2 Victims
[State 180,P2Victims]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = var(14) >= 10
trigger1 = NumExplod(176) = 0
anim = 15000+(var(14)/10%10)
ID = 176
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,96,240),124

;Display 000# P2 Victims
[State 180,P2Victims]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = Time = 0
triggerall = !IsHelper
trigger1 = NumExplod(177) = 0
anim = 15000+(var(14)%10)
ID = 177
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,104,248),124

;Display BONUS
[State 180,BONUS]
type = Explod
triggerall = Time = 200
triggerall = !IsHelper
trigger1 = NumExplod(16015) = 0
anim = 15015
ID = 16015
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 145,188

;Display #0000 P1 Bonus
[State 180,P1Bonus]
type = Explod
triggerall = Time = 200
triggerall = !IsHelper
trigger1 = var(22) >= 10000
trigger1 = NumExplod(190) = 0
anim = 15000+(var(22)/10000%10)
ID = 190
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,72,216),188

;Display 0#000 P1 Bonus
[State 180,P1Bonus]
type = Explod
triggerall = Time = 200
triggerall = !IsHelper
trigger1 = var(22) >= 1000
trigger1 = NumExplod(191) = 0
anim = 15000+(var(22)/1000%10)
ID = 191
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,80,224),188

;Display 00#00 P1 Bonus
[State 180,P1Bonus]
type = Explod
triggerall = Time = 200
triggerall = !IsHelper
trigger1 = var(22) >= 100
trigger1 = NumExplod(192) = 0
anim = 15000+(var(22)/100%10)
ID = 192
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,88,232),188

;Display 000#0 P1 Bonus
[State 180,P1Bonus]
type = Explod
triggerall = Time = 200
triggerall = !IsHelper
trigger1 = var(22) >= 10
trigger1 = NumExplod(193) = 0
anim = 15000+(var(22)/10%10)
ID = 193
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,96,240),188

;Display 0000# P1 Bonus
[State 180,P1Bonus]
type = Explod
triggerall = Time = 200
triggerall = !IsHelper
trigger1 = NumExplod(194) = 0
anim = 15000+(var(22)%10)
ID = 194
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,104,248),188

;Display #0000 P2 Bonus
[State 180,P2Bonus]
type = Explod
triggerall = Time = 200
triggerall = !IsHelper
trigger1 = var(23) >= 10000
trigger1 = NumExplod(195) = 0
anim = 15000+(var(23)/10000%10)
ID = 195
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,72,216),188

;Display 0#000 P2 Bonus
[State 180,P2Bonus]
type = Explod
triggerall = Time = 200
triggerall = !IsHelper
trigger1 = var(23) >= 1000
trigger1 = NumExplod(196) = 0
anim = 15000+(var(23)/1000%10)
ID = 196
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,80,224),188

;Display 00#00 P2 Bonus
[State 180,P2Bonus]
type = Explod
triggerall = Time = 200
triggerall = !IsHelper
trigger1 = var(23) >= 100
trigger1 = NumExplod(197) = 0
anim = 15000+(var(23)/100%10)
ID = 197
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,88,232),188

;Display 000#0 P2 Bonus
[State 180,P2Bonus]
type = Explod
triggerall = Time = 200
triggerall = !IsHelper
trigger1 = NumExplod(198) = 0
trigger1 = var(23) >= 10
anim = 15000+(var(23)/10%10)
ID = 198
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,96,240),188

;Display 0000# P2 Bonus
[State 180,P2Bonus]
type = Explod
triggerall = Time = 200
triggerall = !IsHelper
trigger1 = NumExplod(199) = 0
anim = 15000+(var(23)%10)
ID = 199
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,104,248),188

;Play Bonus sound
[State 180, Bonus]
type = PlaySnd
trigger1 = Time = 200
value = 180,MatchNo+var(24)-1

;Reset Rings
[State 180,RingReset]
type = VarRangeSet
trigger1 = Time = 1
first = 15
last = 16
value = 0

;Keep round from ending
[State 180, 2]
type = AssertSpecial
trigger1 = Time < 500
flag = roundnotover

;---------------------------------------------------------------------------
; Introduction
; CNS difficulty: basic
; CNS レベル: 基本
[Statedef 191]
type = S
ctrl = 0
anim = 0
velset = 0,0

;Match Fixer
[State -2, MatchEdit]
type = VarSet
trigger1 = Time = 0
trigger1 = MatchNo+var(24) >= 5
v = 24
value = -MatchNo+1

;STAGE 1-1

;Display Company Logo
[State 191, Company]
type = Explod
trigger1 = Time = 0
anim = 20000+(2*(MatchNo+var(24)-1))
ID = 20000
postype = left
scale = 0.5,0.5
pos = 160,150
bindtime = -1
ontop = 1
ownpal = 1

;Display Game Logo
[State 191, GameLogo]
type = Explod
trigger1 = Time = 0
anim = 20001+(2*(MatchNo+var(24)-1))
ID = 20001
postype = left
scale = 0.5,0.5
pos = 160,60
bindtime = -1
ontop = 1
ownpal = 1

;Play Company Sound/Title Music
[State 191, KonamiSound]
type = PlaySnd
triggerall = Time = 0
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
value = 20000+(2*(MatchNo+var(24)-1)),0

;Konami Code

[State 191, KonamiSecretSound]
type = PlaySnd
triggerall = MatchNo+var(24) = 1
triggerall = NumExplod(20000) = 1
triggerall = var(20) = 0
trigger1 = Facing = 1
trigger1 = Command = "konamicoderight"
trigger2 = Facing = -1
trigger2 = Command = "konamicodeleft"
trigger3 = enemy,Facing = 1 && enemy,Command = "konamicoderight"
trigger4 = enemy,Facing = -1 && enemy,Command = "konamicodeleft"
value = 20000,1

[State 191, KonamiSecret]
type = VarSet
triggerall = MatchNo+var(24) = 1
triggerall = NumExplod(20000) = 1
triggerall = var(20) = 0
trigger1 = Facing = 1
trigger1 = Command = "konamicoderight"
trigger2 = Facing = -1
trigger2 = Command = "konamicodeleft"
trigger3 = enemy,Facing = 1 && enemy,Command = "konamicoderight"
trigger4 = enemy,Facing = -1 && enemy,Command = "konamicodeleft"
v = 20
value = 1

[State 191, AddLivesBonusP1]
type = Varset
triggerall = MatchNo+var(24) = 1
triggerall = !IsHelper
trigger1 = RoundNo = 1
trigger1 = var(20) = 1
trigger1 = var(3) < 10
v = 3
value = 10

[State 191, AddLivesBonusP2]
type = Varset
triggerall = MatchNo+var(24) = 1
triggerall = !IsHelper
trigger1 = RoundNo = 1
trigger1 = var(20) = 1
trigger1 = var(4) < 10
v = 4
value = 10

[State 191, 1] ;Freeze animation until PreIntro is over
type = ChangeAnim
trigger1 = RoundState = 0
value = 0

;Hide Company Logo
[State 191, HideLogo]
type = RemoveExplod
trigger1 = Time = 400
ID = 20000

;Hide Game Title Logo
[State 191, HideLogo]
type = RemoveExplod
trigger1 = Time = 400
ID = 20001

[State 191, 2] ;Assert this until you want "round 1, fight" to begin
type = AssertSpecial
trigger1 = Time < 400
flag = Intro

[State 191, 3] ;Change to stand state when done
type = ChangeState
trigger1 = AnimTime = 0
value = 0

;---------------------------------------------------------------------------
; P2 Target
[Statedef 90000]
type = S

;Kill P3/P4
[State 90000, Kill my self if I'm p3/p4]
Type = LifeSet
trigger1 = Life > 0
trigger1 = numpartner > 0
trigger1 = partner, id < id
trigger2 = enemy,var(0) = 7199
value = 0

;Kill if Life = 0
[State 90000, 1]
type = ChangeState
trigger1 = Life = 0
trigger1 = StateNo != 5150
value = 5150

[State 90000, VelSet]
type = VelSet
trigger1 = 1
X = 0
Y = 0

;Jump out of state if you are the XTSM
[State 90000, OutofState]
type = SelfState
trigger1 = Name = "XTSM"
trigger2 = RoundState = 3
value = 0

;Move Left-Right
[State 90000, MoveLR]
type = PosAdd
triggerall = var(21) = 0
triggerall = enemy,var(4) > 0
triggerall = RoundState = 2
trigger1 = Command = "holdfwd" || Command = "holdback"
X = IfElse(command = "holdfwd",5,-5)
Y = 0

;Move Up-Down
[State 90000, MoveUD]
type = PosAdd
triggerall = var(21) = 0
triggerall = enemy,var(4) > 0
triggerall = RoundState = 2
trigger1 = Command = "holddown" || Command = "holdup"
X = 0
Y = IfElse(command = "holddown",5,-5)

;Do not hurt crosshair
[State 90000, NoHit]
type = NotHitBy
trigger1 = 1
value = SCA

;Unset backgrounds, autoturning
[State 90000, PreSet1]
type = AssertSpecial
trigger1 = 1
flag = noBG
flag2 = noFG
flag3 = noautoturn

;No Guard
[State 90000, PreSet2]
type = AssertSpecial
trigger1 = 1
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard

;No Shadow, No Timer
[State 90000, PreSet2]
type = AssertSpecial
trigger1 = 1
flag = noshadow
flag2 = timerfreeze

;No Push
[State 90000, NoPush]
type = PlayerPush
trigger1 = 1
value = 0

;Stay in Screen
[State 90000, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 1

[State 90000, FixLowY]
type = PosSet
triggerall = Pos Y > 20
triggerall = MoveType != A
trigger1 = RoundState = 2
trigger2 = RoundsExisted >= 1
Y = 20

[State 90000, FixHighY]
type = PosSet
triggerall = MoveType != A
trigger1 = RoundState = 2
trigger1 = Pos Y < -210
Y = -210

;Invisible and no walking
[State 90000, Invisible]
type = AssertSpecial
trigger1 = 1
flag = invisible
flag2 = nowalk

;---------------------------------------------------------------------------
; ScreenBind
[Statedef 20000]
type = S
anim = 30000

[State 20000, ScreenBind]
type = NotHitBy
trigger1 = IsHelper(20000)
value = SCA

[State 20000, NoAutoTurn]
type = AssertSpecial
trigger1 = 1
flag = noautoturn

[State 20000, Hide]
type = PosSet
trigger1 = 1
X = IfElse(TeamSide = 1,-400,400)
Y = 0

[State 20000, Width]
type = Width
trigger1 = 1
edge = FrontEdgeBodyDist, BackEdgeBodyDist

;--------------------------------------------------------------------------
; Game Timer
[Statedef 20100]
type = S
anim = 30000

[State 20100, ScreenBind]
type = NotHitBy
trigger1 = IsHelper(20100)
value = SCA

[State 20100, NoAutoTurn]
type = AssertSpecial
trigger1 = 1
flag = noautoturn

[State 20100, Hide]
type = PosSet
trigger1 = 1
X = IfElse(TeamSide = 1,-400,400)
Y = 0

[State 20100, TimeVar]
type = VarAdd
triggerall = RoundState = 2
triggerall = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = MatchNo+root,var(24) = 1 && RoundNo+root,var(25) = 1
trigger2 = MatchNo+root,var(24) = 2 && RoundNo+root,var(25) = 2 && var(0) < 300
trigger3 = MatchNo+root,var(24) = 3 && RoundNo+root,var(25) = 1
trigger4 = MatchNo+root,var(24) = 3 && RoundNo+root,var(25) = 2 && var(0) < 400
trigger5 = MatchNo+root,var(24) = 4 && RoundNo+root,var(25) = 1
trigger6 = MatchNo+root,var(24) = 4 && RoundNo+root,var(25) = 2 && var(0) < 7201
v = 0
value = 1

;Trigger end of round
[State 20100, EndRound]
type = ParentVarSet
trigger1 = MatchNo+root,var(24) = 1 && RoundNo+root,var(25) = 1
trigger1 = var(0) = 7200
trigger2 = MatchNo+root,var(24) = 3 && RoundNo+root,var(25) = 1
trigger2 = var(0) = 10600
trigger3 = MatchNo+root,var(24) = 4 && RoundNo+root,var(25) = 1
trigger3 = var(0) = 7200
v = 0
value = 7199

;Sonic extra lives counter.
[State 20100, GiveExtraLifeSound]
type = PlaySnd
triggerall = MatchNo+parent,var(24) = 5
trigger1 = parent,var(15) >= (var(1)+1)*100
trigger2 = parent,var(16) >= (var(2)+1)*100
value = 25430,1
volume = 20
abspan = 1

[State 20100, GiveLife]
type = ParentVarAdd
triggerall = MatchNo+parent,var(24) = 5
trigger1 = parent,var(15) >= (var(1)+1)*100
trigger2 = parent,var(16) >= (var(2)+1)*100
v = IfElse(parent,var(15) >= (var(1)+1)*100,3,4)
value = 1

[State 20100, IncreaseRingLifeValue]
type = VarAdd
triggerall = MatchNo+parent,var(24) = 5
trigger1 = parent,var(15) >= (var(1)+1)*100
trigger2 = parent,var(16) >= (var(2)+1)*100
v = IfElse(parent,var(15) >= (var(1)+1)*100,1,2)
value = 1

;---------------------------------------------------------------------------
; Crosshair
[Statedef 90005]
type = S
anim = 30005

;;;;;;;;;;;;
;; AI SET ;;
;;;;;;;;;;;;
[State 90005, AI]
type = VarSet
triggerall = roundstate = 2
trigger1 = enemy,command = "CPU0"
trigger2 = enemy,command = "CPU1"
trigger3 = enemy,command = "CPU2"
trigger4 = enemy,command = "CPU3"
trigger5 = enemy,command = "CPU4"
trigger6 = enemy,command = "CPU5"
trigger7 = enemy,command = "CPU6"
trigger8 = enemy,command = "CPU7"
v = 21
value = 1

[State 90005, AI]
type = VarSet
triggerall = roundstate = 2
trigger1 = enemy,command = "CPU8"
trigger2 = enemy,command = "CPU9"
trigger3 = enemy,command = "CPU10"
trigger4 = enemy,command = "CPU11"
trigger5 = enemy,command = "CPU12"
trigger6 = enemy,command = "CPU13"
trigger7 = enemy,command = "CPU14"
trigger8 = enemy,command = "CPU15"
v = 21
value = 1

[State 90005, AI]
type = VarSet
triggerall = roundstate = 2
trigger1 = enemy,command = "CPU16"
trigger2 = enemy,command = "CPU17"
trigger3 = enemy,command = "CPU18"
trigger4 = enemy,command = "CPU19"
trigger5 = enemy,command = "CPU20"
trigger6 = enemy,command = "CPU21"
trigger7 = enemy,command = "CPU22"
trigger8 = enemy,command = "CPU23"
v = 21
value = 1

[State 90005, AI]
type = VarSet
triggerall = roundstate = 2
trigger1 = enemy,command = "CPU24"
trigger2 = enemy,command = "CPU25"
trigger3 = enemy,command = "CPU26"
trigger4 = enemy,command = "CPU27"
trigger5 = enemy,command = "CPU28"
trigger6 = enemy,command = "CPU29"
trigger7 = enemy,command = "CPU30"
trigger8 = enemy,command = "CPU31"
v = 21
value = 1

;Stay with enemy
[State 90005, PosChange]
type = PosSet
trigger1 = 1
X = enemy,Pos X
Y = enemy,Pos Y

;--------------------------------------------------------------------------
;Sonic Round
[State -1, JumpSound]
type = PlaySnd
triggerall = MatchNo+parent,var(24) = 5
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
trigger1 = enemy,Command="a" && NumHelper(25484) = 0
trigger2 = enemy,Command="b" && NumHelper(25485) = 0 && parent,var(30) >= 1
trigger3 = enemy,Command="c" && NumHelper(25486) = 0 && parent,var(30) >= 2
value = 0,12

[State -2, CreateSonic]
type = Helper
triggerall = MatchNo+parent,var(24) = 5
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = enemy,Command = "a"
trigger1 = NumHelper(25484) = 0
helpertype = normal
name = "Sonic"
ID = 25484
postype = p1
ownpal = 1
stateno = 25481
pos = 0,floor(240-Pos Y)

[State -2, CreateTails]
type = Helper
triggerall = MatchNo+parent,var(24) = 5
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = enemy,Command = "b"
trigger1 = NumHelper(25485) = 0
trigger1 = parent,var(30) >= 1
helpertype = normal
name = "Tails"
ID = 25485
postype = p1
ownpal = 1
stateno = 25481
pos = 0,floor(240-Pos Y)

[State -2, CreateKnuckles]
type = Helper
triggerall = MatchNo+parent,var(24) = 5
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = enemy,Command = "c"
trigger1 = NumHelper(25486) = 0
trigger1 = var(30) >= 2
helpertype = normal
name = "Knuckles"
ID = 25486
postype = p1
ownpal = 1
stateno = 25481
pos = 0,floor(240-Pos Y)

;Sonic Round Modifiers
[State 9000, LoseLives]
type = ParentVarAdd
triggerall = MatchNo+root,var(24) = 5
triggerall = RoundState = 2
trigger1 = var(4) != 0
v = 4
value = -1

[State 9000, LoseRings]
type = ParentVarAdd
triggerall = MatchNo+root,var(24) = 5
triggerall = RoundState = 2
trigger1 = var(16) != 0
v = 16
value = var(16)

;Debug
[State 9000, Debug]
type = DisplayToClipboard
trigger1 = 1
text = "var(16) = %d"
params = var(16)

[State 9000, LoseShield]
type = ParentVarSet
triggerall = MatchNo+root,var(24) = 5
triggerall = RoundState = 2
trigger1 = var(32) = -1
v = 32
value = 0

;Reset vars
[State 9000, ResetLiveModifier]
type = VarSet
triggerall = MatchNo+root,var(24) = 5
trigger1 = var(4) != 0
v = 4
value = 0

[State 9000, ResetRingModifier]
type = VarSet
triggerall = MatchNo+root,var(24) = 5
trigger1 = var(16) != 0
v = 16
value = 0

[State 9000, ResetShieldModifier]
type = VarSet
triggerall = MatchNo+root,var(24) = 5
trigger1 = var(32) != 0
v = 32
value = 0

;--------------------------------------------------------------------------
;Star Wars Round

;Blaster Sound
[State -1, BlasterSound]
type = PlaySnd
triggerall = MatchNo+parent,var(24) = 4
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,var(28) = 0
trigger1 = enemy,Command = "a"
value = 0,9+RoundNo+parent,var(25)

;Blaster Spark
[State -1, Attack]
type = Projectile
triggerall = MatchNo+parent,var(24) = 4
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,var(28) = 0
trigger1 = enemy,Command = "a"
damage = 2,2
attr = S,N
sparkno = -1
projanim = IfElse(RoundNo+parent,var(25)=1,10009,10012)
affectteam = B
projremovetime = IfElse(RoundNo+parent,var(25)=1,12,6)
projsprpriority = -1
projremove = 0

;X-Wing Laser (Upper Left)
[State -1, LaserUL]
type = Explod
triggerall = MatchNo+parent,var(24) = 4
triggerall = RoundNo+parent,var(25) = 2
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,var(28) = 0
trigger1 = enemy,Command = "a"
anim = 10010
ID = 10010
postype = left
bindtime = 1
removetime = 6
ownpal = 1
sprpriority = -2
pos = floor(ScreenPos X-50),floor(ScreenPos Y-50)
vel = 7,7

;X-Wing Laser (Upper Right)
[State -1, LaserUR]
type = Explod
triggerall = MatchNo+parent,var(24) = 4
triggerall = RoundNo+parent,var(25) = 2
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,var(28) = 0
trigger1 = enemy,Command = "a"
anim = 10011
ID = 10010
postype = left
bindtime = 1
removetime = 6
ownpal = 1
sprpriority = -2
pos = floor(ScreenPos X+50),floor(ScreenPos Y-50)
vel = -7,7

;X-Wing Laser (Lower Left)
[State -1, LaserLL]
type = Explod
triggerall = MatchNo+parent,var(24) = 4
triggerall = RoundNo+parent,var(25) = 2
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,var(28) = 0
trigger1 = enemy,Command = "a"
anim = 10011
ID = 10010
postype = left
bindtime = 1
removetime = 6
ownpal = 1
sprpriority = -2
pos = floor(ScreenPos X-50),floor(ScreenPos Y+50)
vel = 7,-7

;X-Wing Laser (Lower Right)
[State -1, LaserUR]
type = Explod
triggerall = MatchNo+parent,var(24) = 4
triggerall = RoundNo+parent,var(25) = 2
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,var(28) = 0
trigger1 = enemy,Command = "a"
anim = 10010
ID = 10010
postype = left
bindtime = 1
removetime = 6
ownpal = 1
sprpriority = -2
pos = floor(ScreenPos X+50),floor(ScreenPos Y+50)
vel = -7,-7

;Increase Shot Count
[State 90005, IncreaseShot]
type = ParentVarAdd
triggerall = MatchNo+parent,var(24) = 4
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,var(28) = 0
trigger1 = enemy,Command = "a"
v = 10
value = 1

;---------------------------------------------------------------------------
;Mario Round
[State -1, Fireball]
type = PlaySnd
triggerall = MatchNo+parent,var(24) = 3
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
trigger1 = enemy,Command = "a"
value = 0,9

;Fireball Spark
[State -1, Attack]
type = Projectile
triggerall = MatchNo+parent,var(24) = 3
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
trigger1 = enemy,Command = "a"
damage = 2,2
attr = S,N
sparkno = -1
projanim = 10008
affectteam = B
projremovetime = 9
projsprpriority = -1
projremove = 0

;Increase Shot Count
[State 90005, IncreaseShot]
type = ParentVarAdd
triggerall = MatchNo+parent,var(24) = 3
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
trigger1 = enemy,Command = "a"
v = 10
value = 1

;---------------------------------------------------------------------------
;Duck Hunt Round
;Zapper
[State -1, Zapper]
type = PlaySnd
triggerall = MatchNo+parent,var(24) = 2
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,NumHelper(25403) > 0
trigger1 = enemy,Command = "a"
value = 0,8

;Make screen flash
[State -1, ScreenFlash]
type = AllPalFX
triggerall = MatchNo+parent,var(24) = 2
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,NumHelper(25403) > 0
trigger1 = enemy,Command = "a"
time = 1
add = 256,256,256
mul = 256,256,256

;Zapper Fire
[State -1, Attack]
type = Projectile
triggerall = MatchNo+parent,var(24) = 2
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,NumHelper(25403) > 0
trigger1 = enemy,Command = "a"
damage = 2,2
attr = S,N
sparkno = -1
projanim = 10007
affectteam = B
projremovetime = 2
projsprpriority = -1
projremove = 0

;Increase Shot Count
[State 90005, IncreaseShot]
type = ParentVarAdd
triggerall = MatchNo+parent,var(24) = 2
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,NumHelper(25403) > 0
trigger1 = enemy,Command = "a"
v = 10
value = 1

;Take Away Bullets
[State 90005, Attack]
type = ParentVarAdd
triggerall = MatchNo+parent,var(24) = 2
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = parent,NumHelper(25403) > 0
trigger1 = enemy,Command = "a"
v = 6
value = -1

;---------------------------------------------------------------------------
;Lethal Enforcers II Round
;Out of Bullets
[State 90005, GunSound]
type = PlaySnd
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) <= 0
triggerall = !(Pos Y = [18,20])
trigger1 = enemy,command = "a"
value = 1,1

;Gun Sound
[State 90005, GunSound]
type = PlaySnd
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = !(Pos Y = [18,20])
trigger1 = enemy,command = "a"
trigger2 = enemy,command = "holda" && parent,var(8) = 1 && GameTime%6 = 0
trigger3 = enemy,command = "holda" && parent,var(8) = 3 && GameTime%5 = 0
trigger4 = enemy,command = "holda" && parent,var(8) = 4 && GameTime%4 = 0
trigger5 = enemy,command = "holda" && parent,var(8) = 5 && GameTime%4 = 0
value = 0,parent,var(8)
volume = IfElse(parent,var(8)=5,-80,0)

;Gun Fire
[State 90005, Attack]
type = Projectile
damage = 2,2
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = !(Pos Y = [18,20])
trigger1 = enemy,command = "a"
trigger2 = enemy,command = "holda" && parent,var(8) = 1 && GameTime%6 = 0
trigger3 = enemy,command = "holda" && parent,var(8) = 3 && GameTime%5 = 0
trigger4 = enemy,command = "holda" && parent,var(8) = 4 && GameTime%4 = 0
trigger5 = enemy,command = "holda" && parent,var(8) = 5 && GameTime%4 = 0
attr = S,N
sparkno = -1
projanim = 10000+parent,var(8)
affectteam = B
projremovetime = IfElse(parent,var(8)=6,8,IfElse(parent,var(8)=1,6,IfElse(parent,var(8)=2,32,IfElse(parent,var(8)=5,16,8))))
offset = IfElse(parent,var(8)=5,facing*-Pos X,0),IfElse(parent,var(8)=5,-Pos Y+20,0)
velocity = IfElse(parent,var(8)=5,facing*(Pos X+Pos X)/32,0),IfElse(parent,var(8)=5,(Pos Y+Pos Y-20)/32,0)
projsprpriority = -1
projremove = 0

;Extra Gatling Gun Bullets
[State 90005, GGBullets]
type = Projectile
damage = 2,2
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = !(Pos Y = [18,20])
trigger1 = enemy,command = "holda" && parent,var(8) = 1 && GameTime%6 = 0
attr = S,N
sparkno = -1
projanim = 10000+parent,var(8)
affectteam = B
projremovetime = 6
offset = 0,-20
projsprpriority = -1
projremove = 0

[State 90005, GGBullets]
type = Projectile
damage = 2,2
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = !(Pos Y = [18,20])
trigger1 = enemy,command = "holda" && parent,var(8) = 1 && GameTime%6 = 0
attr = S,N
sparkno = -1
projanim = 10000+parent,var(8)
affectteam = B
projremovetime = 6
offset = 20,0
projsprpriority = -1
projremove = 0

[State 90005, GGBullets]
type = Projectile
damage = 2,2
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = !(Pos Y = [18,20])
trigger1 = enemy,command = "holda" && parent,var(8) = 1 && GameTime%6 = 0
attr = S,N
sparkno = -1
projanim = 10000+parent,var(8)
affectteam = B
projremovetime = 6
offset = 0,20
projsprpriority = -1
projremove = 0

[State 90005, GGBullets]
type = Projectile
damage = 2,2
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = !(Pos Y = [18,20])
trigger1 = enemy,command = "holda" && parent,var(8) = 1 && GameTime%6 = 0
attr = S,N
sparkno = -1
projanim = 10000+parent,var(8)
affectteam = B
projremovetime = 6
offset = -20,0
projsprpriority = -1
projremove = 0

;Reload Vocal
[State 90005, ReloadVocal]
type = PlaySnd
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) = 1
triggerall = !(Pos Y = [18,20])
trigger1 = enemy,command = "a"
trigger2 = enemy,command = "holda" && parent,var(8) = 1 && GameTime%6 = 0
trigger3 = enemy,command = "holda" && parent,var(8) = 3 && GameTime%5 = 0
trigger4 = enemy,command = "holda" && parent,var(8) = 4 && GameTime%4 = 0
trigger5 = enemy,command = "holda" && parent,var(8) = 5 && GameTime%4 = 0
value = 1,2

;Take Away Bullets
[State 90005, Attack]
type = ParentVarAdd
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = !(Pos Y = [18,20])
trigger1 = enemy,command = "a"
trigger2 = enemy,command = "holda" && parent,var(8) = 1 && GameTime%6 = 0
trigger3 = enemy,command = "holda" && parent,var(8) = 3 && GameTime%5 = 0
trigger4 = enemy,command = "holda" && parent,var(8) = 4 && GameTime%4 = 0
trigger5 = enemy,command = "holda" && parent,var(8) = 5 && GameTime%4 = 0
v = 6
value = -1

;Increase Shot Count
[State 90005, IncreaseShot]
type = ParentVarAdd
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
triggerall = parent,var(6) > 0
triggerall = !(Pos Y = [18,20])
trigger1 = enemy,command = "a"
trigger2 = enemy,command = "holda" && parent,var(8) = 1 && GameTime%6 = 0
trigger3 = enemy,command = "holda" && parent,var(8) = 3 && GameTime%5 = 0
trigger4 = enemy,command = "holda" && parent,var(8) = 4 && GameTime%4 = 0
trigger5 = enemy,command = "holda" && parent,var(8) = 5 && GameTime%4 = 0
v = 10
value = 1

;Reload Sound
[State -1, ReloadSound]
type = PlaySnd
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
trigger1 = Pos Y = [18,20]
trigger1 = enemy,command = "a"
value = 1,0

;Reload
[State -1, Reload]
type = ParentVarSet
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = parent,var(4) > 0
triggerall = RoundState = 2
trigger1 = Pos Y = [18,20]
trigger1 = enemy,command = "a"
v = 6
value = IfElse(parent,var(8)=0,8,IfElse(parent,var(8)=1,30,IfElse(parent,var(8)=2,15,IfElse(parent,var(8)=3,60,IfElse(parent,var(8)=4,45,IfElse(parent,var(8)=5,50,20))))))

;Konami Code

[State 90005, KonamiSecretSound]
type = PlaySnd
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = RoundState < 2
triggerall = parent,var(20) = 0
trigger1 = enemy,Facing = 1
trigger1 = enemy,Command = "konamicoderight"
trigger2 = enemy,Facing = -1
trigger2 = enemy,Command = "konamicodeleft"
value = 20000,1

[State 90005, KonamiSecret]
type = ParentVarSet
triggerall = MatchNo+parent,var(24) = 1
triggerall = var(21) = 0
triggerall = RoundState < 2
triggerall = parent,var(20) = 0
trigger1 = enemy,Facing = 1
trigger1 = enemy,Command = "konamicoderight"
trigger2 = enemy,Facing = -1
trigger2 = enemy,Command = "konamicodeleft"
v = 20
value = 1

[State 90005, AddLivesBonusP1]
type = ParentVarSet
triggerall = MatchNo+parent,var(24) = 1
triggerall = RoundNo = 1
triggerall = RoundState < 2
triggerall = parent,var(20) = 1
trigger1 = parent,var(3) < 10
v = 3
value = 10

[State 90005, AddLivesBonusP2]
type = ParentVarSet
triggerall = MatchNo+parent,var(24) = 1
triggerall = RoundNo = 1
triggerall = RoundState < 2
triggerall = parent,var(20) = 1
trigger1 = parent,var(4) < 10
v = 4
value = 10

;Remove Explods for modification

[State 90005, RemoveStars]
type = RemoveExplod
trigger1 = NumExplod(15077) > 0
trigger1 = parent,var(34) <= 0
trigger2 = RoundState = 4
ID = 15077

[State 90005, RemoveShield]
type = RemoveExplod
trigger1 = NumExplod(15075) > 0
trigger1 = parent,var(32) != 1
trigger2 = RoundState = 4
trigger3 = parent,var(34) > 0
ID = 15075

[State 90005, RemoveTails]
type = RemoveExplod
trigger1 = NumExplod(15072) > 0
trigger1 = NumHelper(25485) > 0
trigger2 = RoundState = 4
ID = 15072

[State 90005, RemoveKnuckles]
type = RemoveExplod
trigger1 = NumExplod(15073) > 0
ID = 15073

[State 90005, RemoveRINGS]
type = RemoveExplod
trigger1 = NumExplod(15016) > 0
ID = 15016

[State 90005, RemoveRINGSDig1]
type = RemoveExplod
trigger1 = NumExplod(15060) > 0
ID = 15060

[State 90005, RemoveRINGSDig2]
type = RemoveExplod
trigger1 = NumExplod(15061) > 0
ID = 15061

[State 90005, RemoveRINGSDig3]
type = RemoveExplod
trigger1 = NumExplod(15062) > 0
ID = 15062

[State 90005, RemoveGun]
type = RemoveExplod
trigger1 = NumExplod(15011) > 0
ID = 15011

[State 90005, RemoveGun]
type = RemoveExplod
trigger1 = NumExplod(15013) > 0
ID = 15013

[State 90005, RemoveGun]
type = RemoveExplod
trigger1 = NumExplod(15014) > 0
ID = 15014

[State 90005, RemoveGun]
type = RemoveExplod
triggerall = NumExplod(15050) = 1
trigger1 = MatchNo+parent,var(24) = 1
trigger2 = MatchNo+parent,var(24) = 5
trigger3 = RoundState = 4
ID = 15050

[State 90005, RemoveBulletDigit]
type = RemoveExplod
;trigger1 = RoundState = 2
trigger1 = NumExplod(15051) = 1
ID = 15051

[State 90005, RemoveBulletDigit2]
type = RemoveExplod
;trigger1 = RoundState = 2
trigger1 = NumExplod(15052) = 1
ID = 15052

[State 90005, RemoveDigit1Rest]
type = RemoveExplod
;trigger1 = RoundState = 2
trigger1 = NumExplod(15030) = 1
ID = 15030

[State 90005, RemoveDigit2Rest]
type = RemoveExplod
;trigger1 = RoundState = 2
trigger1 = NumExplod(15031) = 1
ID = 15031

[State 90005, RemoveDigit1Score]
type = RemoveExplod
;trigger1 = RoundState = 2
trigger1 = NumExplod(15032) = 1
ID = 15032

[State 90005, RemoveDigit2Score]
type = RemoveExplod
;trigger1 = RoundState = 2
trigger1 = NumExplod(15033) = 1
ID = 15033

[State 90005, RemoveDigit3Score]
type = RemoveExplod
;trigger1 = RoundState = 2
trigger1 = NumExplod(15034) = 1
ID = 15034

[State 90005, RemoveDigit4Score]
type = RemoveExplod
;trigger1 = RoundState = 2
trigger1 = NumExplod(15035) = 1
ID = 15035

[State 90005, RemoveDigit5Score]
type = RemoveExplod
;trigger1 = RoundState = 2
trigger1 = NumExplod(15036) = 1
ID = 15036

[State 90005, RemoveDigit6Score]
type = RemoveExplod
;trigger1 = RoundState = 2
trigger1 = NumExplod(15037) = 1
ID = 15037

[State -2, RemoveDigit7Score]
type = RemoveExplod
;trigger1 = RoundState = 2
trigger1 = NumExplod(15038) = 1
ID = 15038

;Display 1P/2P
[State 90005,1P2P]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15011) = 0
trigger1 = enemy,Name != "XTSM"
anim = IfElse(enemy,TeamSide = 1,15010,15011)
ID = 15011
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,4,190+42),4

;Display REST
[State 90005,REST]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15013) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15012
ID = 15013
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,4,190+42),12

;Display RINGS
[State 90005,RINGS]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15016) = 0
trigger1 = enemy,Name != "XTSM"
trigger1 = MatchNo+parent,var(24) = 5
anim = 15016
ID = 15016
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,4,190+42),28

;Display Rings #00
[State 90005,Digit1 Rings]
type = Explod
triggerall = parent,var(16)>=100
triggerall = RoundState <= 3
trigger1 = NumExplod(15060) = 0
trigger1 = enemy,Name != "XTSM"
trigger1 = MatchNo+parent,var(24) = 5
anim = 15000+(parent,var(16)/100%10)
ID = 15060
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,50,236+42),28

;Display Rings 0#0
[State -2,Digit2 Rings]
type = Explod
triggerall = parent,var(16) >= 10
triggerall = RoundState <= 3
trigger1 = NumExplod(15061) = 0
trigger1 = enemy,Name != "XTSM"
trigger1 = MatchNo+parent,var(24) = 5
anim = 15000+(parent,var(16)/10%10)
ID = 15061
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,58,244+42),28

;Display Rings 00#
[State 90005,Digit3 Rings]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15062) = 0
trigger1 = enemy,Name != "XTSM"
trigger1 = MatchNo+parent,var(24) = 5
anim = 15000+(parent,var(16)%10)
ID = 15062
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,66,252+42),28

;Display Game Over
[State 90005,Game Over]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15014) = 0
trigger1 = enemy,Name != "XTSM"
trigger1 = parent,var(4) <= 0
anim = 15013
ID = 15014
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,4,190+42),20

;Display Digit1 of Rest
[State 90005,Digit1 Rest]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15030) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15000+((parent,var(4))/10)
ID = 15030
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,42,228+42),12


;Display Digit2 of Rest
[State 90005,Digit2 Rest]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15031) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15000+((parent,var(4))%10)
ID = 15031
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,50,236+42),12

;Display Digit 1 of Score
[State 90005,Digit1 Score]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15032) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15000+(parent,var(2)/1000000%10)
ID = 15032
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,34,220+42),4

;Display Digit 2 of Score
[State 90005,Digit2 Score]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15033) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15000+(parent,var(2)/100000%10)
ID = 15033
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,42,228+42),4

;Display Digit 3 of Score
[State 90005,Digit3 Score]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15034) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15000+(parent,var(2)/10000%10)
ID = 15034
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,50,236+42),4

;Display Digit 4 of Score
[State -2,Digit4 Score]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15035) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15000+(parent,var(2)/1000%10)
ID = 15035
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,58,244+42),4

;Display Digit 5 of Score
[State 90005,Digit5 Score]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15036) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15000+(parent,var(2)/100%10)
ID = 15036
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,66,252+42),4

;Display Digit 6 of Score
[State 90005,Digit6 Score]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15037) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15000+(parent,var(2)/10%10)
ID = 15037
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,74,260+42),4

;Display Digit 7 of Score
[State 90005,Digit7 Score]
type = Explod
triggerall = RoundState <= 3
trigger1 = NumExplod(15038) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15000+(parent,var(2)%10)
ID = 15038
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,82,268+42),4

;Display Gun
[State 90005,GunDisplay]
type = Explod
triggerall = RoundState <= 3
triggerall = enemy,Name != "XTSM"
triggerall = NumExplod(15050) = 0
trigger1 = MatchNo+var(24) != 5
trigger2 = MatchNo+var(24) = 5 && NumHelper(25484) = 0
anim = IfElse(MatchNo+var(24)=1,10100+(parent,var(8)),IfElse(MatchNo+var(24)=2,10108,IfElse(MatchNo+var(24)=3,10109,IfElse(MatchNo+var(24)=4,10109+RoundNo+var(25),10112))))
ID = 15050
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,24,210+42),222
scale = IfElse(MatchNo+var(24)=3,1,IfElse(MatchNo+var(24)=4&&RoundNo+var(25)=2,0.3,IfElse(MatchNo+var(24)=5,0.5,0.15))),IfElse(MatchNo+var(24)=3,1,IfElse(MatchNo+var(24)=4&&RoundNo+var(25)=2,0.3,IfElse(MatchNo+var(24)=5,0.5,0.15)))

;Display Digit1 of BulletCount
[State 90005,Digit1 Bullet]
type = Explod
triggerall = MatchNo+parent,var(24) < 3
triggerall = RoundState <= 3
trigger1 = NumExplod(15051) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15000+(parent,var(6)/10)
ID = 15051
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,58,244+42),222

;Display Digit2 of BulletCount
[State 90005,Digit2 Bullet]
type = Explod
triggerall = MatchNo+parent,var(24) < 3
triggerall = RoundState <= 3
trigger1 = NumExplod(15052) = 0
trigger1 = enemy,Name != "XTSM"
anim = 15000+(parent,var(6)%10)
ID = 15052
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,66,252+42),222

;Display Tails (Sonic Round)
[State 90005,TailsDisplay]
type = Explod
triggerall = RoundState <= 3
triggerall = enemy,Name != "XTSM"
triggerall = NumExplod(15072) = 0
trigger1 = MatchNo+var(24) = 5 && NumHelper(25485) = 0 && parent,var(30) >= 1
anim = 10113
ID = 15072
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,24,210+42),222
scale = 0.5,0.5

;Display Knuckles (Sonic Round)
[State 90005,KnucklesDisplay]
type = Explod
triggerall = RoundState <= 3
triggerall = enemy,Name != "XTSM"
triggerall = NumExplod(15073) = 0
trigger1 = MatchNo+var(24) = 5 && NumHelper(25486) = 0 && parent,var(30) >= 2
anim = 10114
ID = 15073
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(enemy,TeamSide=1,24,210+42),222
scale = 0.5,0.5

;Display Stars on Crosshair (Sonic Round)
[State -2,DisplayStars]
type = Explod
triggerall = RoundState <= 3
triggerall = enemy,Name != "XTSM"
triggerall = NumExplod(15077) = 0
trigger1 = MatchNo+var(24) = 5
trigger1 = parent,var(34) > 0
anim = 25525
ID = 15077
postype = p1
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2

;Display Shield on Crosshair (Sonic Round)
[State -2,DisplayKnux]
type = Explod
triggerall = RoundState <= 3
triggerall = enemy,Name != "XTSM"
triggerall = NumExplod(15075) = 0
trigger1 = MatchNo+var(24) = 5
trigger1 = parent,var(32) = 1
trigger1 = parent,var(34) <= 0
anim = 25524
ID = 15075
postype = p1
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2

;Game Over.  Press Start to Resume Play
[State 90005, CoinSound]
type = PlaySnd
triggerall = var(21) = 0
triggerall = RoundState = 2
triggerall = parent,var(4) <= 0
trigger1 = enemy,command = "start"
value = 1,3

[State 90005, HideGameOver]
type = RemoveExplod
triggerall = var(21) = 0
triggerall = RoundState = 2
triggerall = parent,var(4) > 0
trigger1 = NumExplod(15014) > 0
ID = 15014

[State 90005, Take Away Points]
type = ParentVarAdd
triggerall = var(21) = 0
triggerall = RoundState = 2
triggerall = parent,var(4) <= 0
trigger1 = enemy,command = "start"
v = 2
value = -1000

[State 90005, Reset Lives]
type = ParentVarSet
triggerall = var(21) = 0
triggerall = RoundState = 2
triggerall = parent,var(4) <= 0
trigger1 = enemy,command = "start"
v = 4
value = IfElse(parent,var(20)=1,10,5)

;Destroy Self it Round is over
[State 90005, DestroySelf]
type = DestroySelf
trigger1 = RoundState = 4

;---------------------------------------------------------------------------
; Select Enemy
[Statedef 24999]
type = S
sprpriority = -4

;Which enemy?  Pop up, jump in, or innocent?
[State 24999, SelectEnemy]
type = ChangeState
trigger1 = Time = 0
value = IfElse(Random > 0 && Random <= 199,25002,IfElse(Random >= 200 && Random < 699,25000,25001))

;---------------------------------------------------------------------------
; Enemies (Pop Up)
[Statedef 25000]
type = S
anim = 0
sprpriority = -4

;Enemy Quote
[State 25000, EnemyTalk]
type = PlaySnd
trigger1 = Time = 0
trigger1 = Random <= 499
value = 25001,floor(Random/80)

;Set enemy type
[State 25000, EnemyType]
type = VarSet
trigger1 = Time = 0
v = 0
value = Floor(Random/180)

;Set enemy graphic if close up enemy
[State 25000, GraphicVar]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = var(0) = 5
value = 25000+(10*var(0))

;Put enemy under ground if they are close up shooter
[State 25000, CloseShooterPos]
type = PosSet
trigger1 = Time = 0
trigger1 = var(0) = 5
Y = 80

;Change sprpriority if enemy is close up shooter
[State 25000, CloseUpPrior]
type = SprPriority
trigger1 = Time = 0
trigger1 = var(0) = 5
value = -2

;Set time till they shoot
[State 25000, FireTime]
type = VarSet
trigger1 = Time = 0
v = 1
value = Ceil(Random/8)+50

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
trigger1 = Time = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = Time = 0
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Anim = 25002+(10*var(0))
trigger1 = AnimElem = 2
v = IfElse(var(3)=0,3,4)
value = -1

;Reset Gun and Bullets
[State 25000, ResetGun]
type = ParentVarSet
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Anim = 25002+(10*var(0))
trigger1 = AnimElem = 2
v = IfElse(var(3)=0,7,8)
value = 0

[State 25000, ResetBullets]
type = ParentVarSet
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Anim = 25002+(10*var(0))
trigger1 = AnimElem = 2
v = IfElse(var(3)=0,5,6)
value = 8

;Random X Set
[State 25000, RandomX]
type = PosSet
trigger1 = Time = 0
X = (Random/5)-120

;Fix Initial Position
[State 25000, PosChange]
type = PosAdd
trigger1 = var(0) < 5 && ScreenPos Y != [118,122]
trigger2 = var(0) = 5 && ScreenPos Y != [150,154]
trigger2 = Anim = 25050
;Y = -3
Y = IfElse(var(0)=5,-4,IfElse(ScreenPos Y < 120,2,-2))

[State 25000, Invis]
type = AssertSpecial
trigger1 = var(0) < 5 && Anim != 25000+(10*var(0)) && ScreenPos Y != [118,122]
flag = Invisible

;Change Animation to pop up animation
[State 25000, AnimSet]
type = ChangeAnim
triggerall = Anim != [25000+(10*var(0)),25004+(10*var(0))]
trigger1 = var(0) < 5 && ScreenPos Y = [118,122]
trigger2 = var(0) = 5 && ScreenPos Y = [150,154]
value = 25000+(10*var(0))

;Shoot!
[State 25000, Shoot]
type = ChangeAnim
trigger1 = Time >= var(1)
trigger1 = Anim = 25001+(10*var(0))
value = 25002+(10*var(0))

[State 25000, ShootSound]
type = PlaySnd
trigger1 = Anim = 25002+(10*var(0))
trigger1 = AnimElem = 1
value = 26000,0

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Anim = 25002+(10*var(0))
trigger1 = AnimElem = 2
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Go to idle position after shoot
[State 25000, Shoot]
type = ChangeAnim
trigger1 = Anim = 25002+(10*var(0))
trigger1 = AnimTime = 0
value = 25003+(10*var(0))

;Increase Pos if enemy is close up.
[State 25000, GoDown]
type = VelSet
trigger1 = Anim = 25003+(10*var(0))
trigger1 = var(0) = 5 && AnimTime = 0
Y = 3

;Duck back down
[State 25000, DuckBackDown]
type = ChangeAnim
trigger1 = Anim = 25003+(10*var(0))
trigger1 = AnimTime = 0
value = 25004+(10*var(0))

;Disappear
[State 25000, Shoot]
type = DestroySelf
trigger1 = Anim = 25004+(10*var(0))
trigger1 = var(0) < 5 && AnimTime = 0
trigger2 = Anim = 25004+(10*var(0))
trigger2 = var(0) = 5 && ScreenPos Y > 250
trigger3 = RoundState > 2

;Enemies aims at you
[State 25000, EnemyAim]
type = ChangeAnim
triggerall = Anim = 25000+(10*var(0))
trigger1 = var(0) < 5 && AnimTime = 0
trigger2 = var(0) = 5 && ScreenPos Y = [150,154]
value = 25001+(10*var(0))

;---------------------------------------------------------------------------
; Enemies (Enter from side)
[Statedef 25001]
type = S
anim = 0
sprpriority = -3

;Animations:  25100 - Enter, 25101 - Aim, 25102 - Fire, 25103 - Die

;Set enemy classification
[State 25001, SetSideEnemy]
type = VarSet
trigger1 = Time = 0
v = 4
value = 1

;Enemy Quote
[State 25001, EnemyTalk]
type = PlaySnd
trigger1 = Time = 0
trigger1 = Random <= 499
value = 25001,floor(Random/80)

;Set enemy type
[State 25001, EnemyType]
type = VarSet
trigger1 = Time = 0
v = 0
value = Floor(Random/280)

;Set the Y position
[State 25001, SetY]
type = PosSet
trigger1 = Time = 0
Y = IfElse(var(0)=0,0,IfElse(var(0)=3,-50,10))

;Set enemies to correct X
[State 25001, CorrectX]
type = PosSet
triggerall = Time = 0
trigger1 = var(0) = 0
trigger2 = var(0) = 2
X = IfElse(var(0)=0,163,-160)

;Move in the right direction
[State 25001, Move]
type = PosAdd
triggerall = Anim = 25100+(10*var(0))
trigger1 = var(0) = 0 && Time >= 10
trigger2 = var(0) = 2
trigger3 = var(0) = 3 && AnimElemTime(1) < 20
X = IfElse(var(0)=0,-3,3)
Y = IfElse(var(0)=3,3,0)

;Set time till they shoot
[State 25001, FireTime]
type = VarSet
trigger1 = Time = 0
v = 1
value = Ceil(Random/8)+50

;Set which player to kill
[State 25001, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
trigger1 = Time%var(1) = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25001, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time%var(1) = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25001, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = Time%var(1) = 0
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25001, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Anim = 25102+(10*var(0))
trigger1 = AnimElem = 2
v = IfElse(var(3)=0,3,4)
value = -1

;Reset Gun and Bullets
[State 25000, ResetGun]
type = ParentVarSet
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Anim = 25102+(10*var(0))
trigger1 = AnimElem = 2
v = IfElse(var(3)=0,7,8)
value = 0

[State 25000, ResetBullets]
type = ParentVarSet
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Anim = 25102+(10*var(0))
trigger1 = AnimElem = 2
v = IfElse(var(3)=0,5,6)
value = 8

;Fix Initial Position
[State 25001, PosChange]
type = PosAdd
triggerall = Anim != [25100+(10*var(0)),25102+(10*var(0))]
trigger1 = ScreenPos Y != [148,152]
trigger1 = var(0) = 3
Y = IfElse(ScreenPos Y < 150,2,-2)

[State 25001, Invis]
type = AssertSpecial
trigger1 = Anim != [25100+(10*var(0)),25102+(10*var(0))]
trigger1 = ScreenPos Y != [148,152]
flag = Invisible

;Change Animation to enter animation
[State 25001, AnimSet]
type = ChangeAnim
triggerall = Anim != [25100+(10*var(0)),25102+(10*var(0))]
trigger1 = ScreenPos Y = [148,152]
trigger2 = var(0) < 3
value = 25100+(10*var(0))

;Shoot!
[State 25001, Shoot]
type = ChangeAnim
trigger1 = Time%var(1) = 0
trigger1 = Anim = 25101+(10*var(0))
value = 25102+(10*var(0))

[State 25001, ShootSound]
type = PlaySnd
triggerall = Anim = 25102+(10*var(0))
trigger1 = AnimElem = 1
trigger2 = var(0) = 3 && AnimElem = 5
value = 26000,0

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Anim = 25102+(10*var(0))
trigger1 = AnimElem = 2
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Go to idle position after shoot
[State 25001, Shoot]
type = ChangeAnim
trigger1 = Anim = 25002+(10*var(0))
trigger1 = AnimTime = 0
value = 25003+(10*var(0))

;Enemies aims at you
[State 25001, EnemyAim]
type = ChangeAnim
trigger1 = Anim = 25100+(10*var(0)) && AnimTime = 0
trigger2 = Anim = 25102+(10*var(0)) && AnimTime = 0
value = 25101+(10*var(0))

;Destroy when round over
[State 25001, Destroy]
type = DestroySelf
trigger1 = RoundState > 2

;---------------------------------------------------------------------------
; Innocents (Pop Up)
[Statedef 25002]
type = S
anim = 0
sprpriority = -4

;Set Innocent classification
[State 25002, SetInnocent]
type = VarSet
trigger1 = Time = 0
v = 4
value = 2

;Set victim type
[State 25002, VictimType]
type = VarSet
trigger1 = Time = 0
v = 0
value = Floor(Random/390)

;Quote
[State 25002, VictimTalk]
type = PlaySnd
trigger1 = Time = 0
trigger1 = var(0) > 0
value = 25002,floor(Random/390)

;Random X Set
[State 25002, RandomX]
type = PosSet
trigger1 = Time = 0
X = (Random/5)-120

;Fix Initial Position
[State 25002, PosChange]
type = PosAdd
trigger1 = ScreenPos Y != [118,122]
Y = IfElse(var(0)=5,-4,IfElse(ScreenPos Y < 120,2,-2))

[State 25002, Invis]
type = AssertSpecial
trigger1 = Anim != 25200+(10*var(0)) && ScreenPos Y != [118,122]
flag = Invisible

;Change Animation to pop up animation
[State 25002, AnimSet]
type = ChangeAnim
triggerall = Anim != [25200+(10*var(0)),25202+(10*var(0))]
trigger1 = ScreenPos Y = [118,122]
value = 25200+(10*var(0))

;Duck back down
[State 25002, DuckBackDown]
type = ChangeAnim
trigger1 = Anim = 25201+(10*var(0))
trigger1 = AnimTime = 0
value = 25202+(10*var(0))

;Disappear
[State 25002, Disappear]
type = DestroySelf
trigger1 = Anim = 25202+(10*var(0))
trigger1 = AnimTime = 0
trigger2 = RoundState > 2

;Victim pauses
[State 25002, victimPauses]
type = ChangeAnim
triggerall = Anim = 25200+(10*var(0))
trigger1 = AnimTime = 0
value = 25201+(10*var(0))

;---------------------------------------------------------------------------
; Enemy Die
[Statedef 25005]
type = S
anim = IfElse(var(4)=0,25005+(10*var(0)),25103+(10*var(0)))
sprpriority = IfElse(var(4)=0,-4,-3)

;Sound
[State 25005, Sound]
type = PlaySnd
trigger1 = Time = 0
value = 25000,floor(Random/120)

[State 25005, NoHit]
type = NotHitBy
trigger1 = 1
value = SCA

;Flash
[State 25005, Flash]
type = AssertSpecial
trigger1 = Time%2 = 0
flag = Invisible

;Destroy enemy
[State 25005, DestroyEnemy]
type = DestroySelf
trigger1 = Time = 40
trigger2 = RoundState > 2

;---------------------------------------------------------------------------
; Innocents Die
[Statedef 25006]
type = S
anim = 25203+(10*var(0))
sprpriority = -4

;Sound
[State 25006, Sound]
type = PlaySnd
trigger1 = Time = 0
value = IfElse(var(0)=0,25000,25003),IfElse(var(0)=0,floor(Random/120),floor(Random/280))

[State 25006, NoHit]
type = NotHitBy
trigger1 = 1
value = SCA

;Destroy
[State 25006, DestroyEnemy]
type = DestroySelf
trigger1 = Time = 90
trigger2 = RoundState > 2

;No lives lost while bullet hole is on screen
;---------------------------------------------------------------------------
; Bullet Hole
[Statedef 11100]
type = S
anim = IfElse(MatchNo+(root,var(24))=1,11100,30000)
sprpriority = 0

;Hurt sound
[State 11100, Sound]
type = PlaySnd
trigger1 = Time = 0
trigger1 = MatchNo+root,var(24) != 4
value = 5000,MatchNo+(root,var(24))-1

;Blaster Sound for Star Wars Level
[State 11100, Sound]
type = PlaySnd
trigger1 = Time = 0
trigger1 = MatchNo+root,var(24) = 4
trigger1 = RoundNo+root,var(25) = 1
value = 0,10

;Make the screen flash
[State 11100, RedFlash]
type = AllPalFX
trigger1 = Time = 0
time = 1
add = 256,0,0
mul = 256,0,0

[State 11100, NoHit]
type = NotHitBy
trigger1 = 1
value = SCA

;Destroy enemy
[State 11100, DestroyEnemy]
type = DestroySelf
trigger1 = Time = 200
trigger2 = RoundState > 2

;---------------------------------------------------------------------------
; Items
[Statedef 25010]
type = S
anim = 30001
sprpriority = -1

;Set the item
[State 25010, RandomGun]
type = VarSet
trigger1 = Time = 0
v = 0
value = floor(Random/155)+1

;Display the item.
[State 25010,ItemDisplay]
type = Explod
trigger1 = Time = 0
anim = 10100+var(0)
ID = 25010
postype = p1
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -1
pos = 0,0
scale = 0.15,0.15

;Destroy Self after certain time
[State 25010, HideItem]
type = RemoveExplod
trigger1 = Time = 500
trigger2 = RoundState > 2
ID = 25010

[State 25010, Destroy]
type = DestroySelf
trigger1 = Time = 500
trigger2 = RoundState > 2

;---------------------------------------------------------------------------
; Get Item
[Statedef 25011]
type = S
anim = 30000
sprpriority = -1

;Go out of sight
[State 25011, OutofSight]
type = PosAdd
trigger1 = 1
Y = 10

;Hide Explod when out of sight
[State 25011, HideExplod]
type = RemoveExplod
trigger1 = ScreenPos Y > 300
ID = 25010

;Destroy self when out of sight.
[State 25011, DestroyMe]
type = DestroySelf
trigger1 = ScreenPos Y > 300
trigger2 = RoundState > 2

;--------------------------------------------------------------------------
; Boss 1-2
[Statedef 25030]
type = S
anim = 25300
sprpriority = -3

;DISPLAY LIFE BAR
;Remove HP Explod for Modification
[State -2, RemoveHPBar]
type = RemoveExplod
trigger1 = RoundState = 2
trigger1 = NumExplod(16001) > 0
ID = 16001

[State -2, RemoveOuterHPBar]
type = RemoveExplod
trigger1 = RoundState = 2
trigger1 = NumExplod(16000) > 0
ID = 16000

[State -2,BossLifeBar]
type = Explod
triggerall = RoundState = 2
triggerall = NumExplod(16000) = 0
trigger1 = var(5) > 0
trigger1 = var(6) > 0
anim = 16000
ID = 16000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 105,215

[State -2,BossLifeFill]
type = Explod
triggerall = RoundState = 2
triggerall = NumExplod(16001) = 0
trigger1 = var(5) > 0
trigger1 = helper(25000),var(6) > 0
anim = 16001
ID = 16001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -1
pos = 105-(floor(100*var(6)/var(5)))+3,215
scale = floor(100*var(6)/var(5))-2,1

;Set initial pos
[State 25030, InitialPos]
type = PosAdd
trigger1 = Time = 0
trigger1 = var(5) = 0
Y = 80-ScreenPos Y

;PREPARE TO DIE sound
[State 25030, Vocal]
type = PlaySnd
trigger1 = Time = 0
trigger1 = var(5) = 0
value = 25001,13

;Set HP
[State 25030, MaxHP]
type = VarSet
trigger1 = Time = 0
trigger1 = var(5) = 0
v = 5
value = 100

[State 25030,HP]
type = VarSet
trigger1 = Time = 0
trigger1 = var(6) = 0
v = 6
value = var(5)

;Display Name
[State 25030, Name]
type = Explod
trigger1 = RoundState = 2
trigger1 = NumExplod(15022) = 0
anim = 15022
ID = 15022
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 105,205

;Set initial Vel
[State 25030, Vel]
type = VelSet
trigger1 = Time = 0
trigger1 = Vel X = 0 && Vel Y = 0
X = -2
Y = -2

;Change Vel X
[State 25030, VelChange]
type = VelSet
trigger1 = ScreenPos X < 20
trigger2 = ScreenPos X > 300
trigger3 = GameTime%50=0 && Random<=300
X = -Vel X

;Change Vel Y
[State 25030, VelChange]
type = VelSet
trigger1 = ScreenPos Y < 30
trigger2 = ScreenPos Y > 140
trigger3 = GameTime%50=0 && Random>=700
Y = -Vel Y

;I got hit.
;Flash
[State 25030, Flash]
type = AssertSpecial
trigger1 = Time%2 = 0
trigger1 = var(7) > 0
flag = invisible

;Do not hurt me while invincible.
[State 25030, NoHurt]
type = NotHitBy
trigger1 = var(7) > 0
value = SCA

;Decrease invincibility timer.
[State 25030, Timer]
type = VarAdd
trigger1 = var(7) > 0
v = 7
value = -1

;Destroy
[State 25030, Disappear]
type = DestroySelf
trigger1 = RoundState > 2

;---------------------------------------------------------------------------
; Shooting Skulls
[Statedef 25031]
type = S
anim = 25301
sprpriority = -2

;Start small, then grow large
[State 25031, Scale]
type = AngleDraw
trigger1 = Time < 100
scale = Time*0.015,Time*0.015

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
trigger1 = Time = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = Time = 0
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Time = 100
v = IfElse(var(3)=0,3,4)
value = -1

;Reset Gun and Bullets
[State 25000, ResetGun]
type = ParentVarSet
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Time = 100
v = IfElse(var(3)=0,7,8)
value = 0

[State 25000, ResetBullets]
type = ParentVarSet
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Time = 100
v = IfElse(var(3)=0,5,6)
value = 8

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Time = 100
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Destroy Self
[State 25031, Destroy]
type = DestroySelf
trigger1 = Time = 100
trigger2 = RoundState > 2
trigger3 = helper(25000),var(6) <= 0

;---------------------------------------------------------------------------
; Boss 1-2 Die
[Statedef 25032]
type = S
sprpriority = -2
velset = 0,0

;Add to P1 Score
[State 5000, Score]
type = ParentVarAdd
triggerall = Time = 0
trigger1 = GetHitVar(damage)=1
trigger2 = GetHitvar(damage)=3 && enemy,TeamSide = 1
v = 1
value = 5000

;Add to P2 Score
[State 5000, P2Score]
type = ParentVarAdd
triggerall = Time = 0
trigger1 = GetHitVar(damage)=3 && enemy,TeamSide = 2
trigger2 = GetHitVar(damage)=2
v = 2
value = 5000

;Scream
[State 25032, Scream]
type = PlaySnd
trigger1 = Time = 0
value = 25000,11

;Can't be hit
[State 25032, NoHit]
type = NotHitBy
trigger1 = 1
value = SCA

;Random Explosions
[State 25032, ExplodeSound]
type = PlaySnd
trigger1 = Time%20 = 0
value = 25000,9

[State 25032,Explode]
type = Explod
trigger1 = Time%20 = 0
anim = 25302
ID = 25032
postype = p1
bindtime = -1
removetime = -2
ownpal = 1
sprpriority = -1
pos = ceil(Random/40)-13,ceil(Random/40)-13

;Remove name Explod
[State 25032, NoName]
type = RemoveExplod
trigger1 = Time = 0
ID = 15022

;Remove Life Bar
[State 25032, NoName]
type = RemoveExplod
trigger1 = Time = 0
ID = 16000

[State 25032, NoName]
type = RemoveExplod
trigger1 = Time = 0
ID = 16001

;Trigger end of round
[State 25032, EndRound]
type = ParentVarSet
trigger1 = Time = 199
v = 0
value = 7199

[State 25032, EndRound]
type = ParentVarSet
trigger1 = Time = 200
v = 0
value = 7200

;Destroy Self
[State 25032, Destroy]
type = DestroySelf
trigger1 = Time = 200
trigger2 = RoundState > 2

;---------------------------------------------------------------------------
; Skull Destroy
[Statedef 25033]
type = S
anim = 25302
sprpriority = -2

;Explosion
[State 25033, Explosion]
type = PlaySnd
trigger1 = Time = 0
value = 25000,9

;Disappear
[State 25033, Disappear]
type = DestroySelf
trigger1 = AnimTime = 0
trigger2 = RoundState > 2

;---------------------------------------------------------------------------
; Duck Hunt - Dog Entrance
[Statedef 25400]
type = S
anim = 25400
sprpriority = -2

;Walk right
[State 25400, Walk]
type = VelSet
trigger1 = Time < 360
trigger1 = AnimElem = 1,1
X = 0.5

;Stop walking
[State 25400, Stop]
type = VelSet
trigger1 = AnimElem = 13,0
trigger2 = Time = 360
X = 0

;Change Animation to Jump
[State 25400, JumpInBush]
type = ChangeAnim
trigger1 = Time = 360
value = 25401

;Bark
[State 25400, Bark]
type = PlaySnd
trigger1 = Anim = 25401
trigger1 = AnimElem = 2,0
value = 25400,0

;Set Jump Vel
[State 25400, Jump!]
type = VelSet
trigger1 = Anim = 25401
trigger1 = AnimElem = 2,0
X = 0.2
Y = -3

;Go behind bush
[State 25400, BehindBush]
type = SprPriority
trigger1 = Vel Y < 0
trigger1 = ScreenPos Y = [115,125]
value = -4

;Jump down
[State 25400, JumpDown]
type = VelSet
trigger1 = Vel Y < 0
trigger1 = ScreenPos Y = [115,125]
Y = 1.5

;Go to Idle State
[State 25400, Hide]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = ScreenPos Y >= 250
value = 25401

;Destroy
[State 25400, DestroySelf]
type = DestroySelf
trigger1 = RoundState > 2

;--------------------------------------------------------------------------
; Duck Hunt - Dog Idle State
;Initial animation used to trigger the entrance of the ducks.
[Statedef 25401]
type = S
anim = 25412
sprpriority = -4
velset = 0,0

;Reset Duck Shot var
[State 25402, ResetDuckShot]
type = ParentVarSet
trigger1 = Time = 0
v = 26
value = 0

;Invisible until ducks shot or missed.
[State 25402, Invisible]
type = AssertSpecial
trigger1 = 1
flag = invisible

;Change Animation to different number to end duck trigger.
[State 25402, EndTrigger]
type = ChangeAnim
trigger1 = Anim = 25412
trigger1 = Time = 10
value = 25402

;Change to pop up state for when ducks shot/missed
[State 25402, EndState]
type = ChangeState
trigger1 = Anim != 25412
trigger1 = parent,NumHelper(25403) = 0
value = 25402

;Destroy
[State 25402, DestroySelf]
type = DestroySelf
trigger1 = RoundState > 2

;--------------------------------------------------------------------------
; Duck Hunt - Dog Pop Up (Ducks Shot/Missed)
[Statedef 25402]
type = S
sprpriority = -4
velset = 0,-2

;Set animation
[State 25402, SetAnim]
type = ChangeAnim
trigger1 = Time = 0
value = 25402+parent,var(26)

;Set initial position
[State 25402, PosAdd]
type = PosAdd
trigger1 = Time = 0
Y = -34

;Stop vel
[State 25402, VelStop]
type = VelSet
trigger1 = Time = 36
Y = 0

;Go back down
[State 25402, GoDown]
type = VelSet
trigger1 = Time = 60
Y = 2

;Ducks hit
[State 25402, DucksHitSound]
type = PlaySnd
trigger1 = Time = 0
trigger1 = parent,var(26) > 0
value = 25400, 2

;Ducks missed
[State 25402, DucksHitSound]
type = PlaySnd
trigger1 = Time = 0
trigger1 = parent,var(26) = 0
value = 25400, 5

;Set new Y pos
[State 25402, PosAdd]
type = PosAdd
trigger1 = Time = 96
Y = 34

;Go back to idle state
[State 25402, BackToIdle]
type = ChangeState
trigger1 = Time = 96
value = 25401

;Destroy
[State 25402, DestroySelf]
type = DestroySelf
trigger1 = RoundState > 2

;--------------------------------------------------------------------------
; Duck Hunt - Duck Fly State
[Statedef 25403]
type = S
anim = 25405
sprpriority = -4
velset = 0,0

;Add Ducks Count
[State 25403, DucksCount]
type = ParentVarAdd
trigger1 = Time = 0
v = 27
value = 1

;Set Bullets
[State 25403, SetP1Bullets]
type = ParentVarset
trigger1 = Time = 0
v = 5
value = 3

[State 25403, SetP2Bullets]
type = ParentVarset
trigger1 = Time = 0
v = 6
value = 3

;Set Random X
[State 25403, RandomX]
type = PosAdd
trigger1 = Time = 0
X = floor(Random/5)-100

;Start loop of quacking
[State 25403, Quack]
type = PlaySnd
trigger1 = parent,NumHelper(25403) = 1
trigger2 = helper(25403),StateNo = 25404
value = 25400, 1
volume = 1
channel = 5
loop = 1
lowpriority = 5

;Set Flying Velocity
[State 25403, FlyChange]
type = VelSet
trigger1 = Time < 400
trigger1 = GameTime%20 = 0
trigger1 = Random <= 500
X = floor(Random/150)-3
Y = floor(Random/150)-3

;Against the walls.  Turn Around
;Change Vel X
[State 25403, VelChange]
type = Velset
triggerall = Time < 400
trigger1 = ScreenPos X < 20 && Vel X < 0
trigger2 = ScreenPos X > 300 && Vel X > 0
X = -Vel X

;Change Vel Y
[State 25403, VelChange]
type = VelSet
triggerall = Time < 400
trigger1 = ScreenPos Y < 30 && Vel Y < 0
trigger2 = ScreenPos Y > 140 && Vel Y > 0
Y = -Vel Y

;Now display the proper flying animation
[State 25403, Fly Left-Right]
type = ChangeAnim
triggerall = Time < 400
triggerall = Anim != [25407,25408]
trigger1 = Vel Y > 1
trigger2 = Vel X > 0 && Anim = 25408
trigger3 = Vel X <= 0 && Anim = 25407
value = IfElse(Vel X > 0,25407,25408)

[State 25403, FlyDiag]
type = ChangeAnim
triggerall = Time < 400
triggerall = Anim != [25405,25406]
trigger1 = Vel Y <= 1
trigger2 = Vel X > 0 && Anim = 25406
trigger3 = Vel X <= 0 && Anim = 25405
value = IfElse(Vel X > 0,25405,25406)

;Time ran out.  Fly away

[State 25403, StopFlyingSound]
type = StopSnd
trigger1 = ScreenPos Y <= -100
channel = 5

[State 25403, NotHit]
type = NotHitBy
trigger1 = Time >= 400
value = SCA

[State 25403, AnimChange]
type = ChangeAnim
trigger1 = Time = 400
value = 25409

[State 25403, SetFlyingVel]
type = VelSet
trigger1 = Time = 400
X = 0
Y = -2

;Disappear
[State 25403, Disappear]
type = DestroySelf
trigger1 = Time >= 400
trigger1 = ScreenPos Y <= -100
trigger2 = RoundState > 2

;--------------------------------------------------------------------------
; Duck Hunt - Duck Fall
[Statedef 25404]
type = S
anim = 25410
sprpriority = -4
velset = 0,0

;Add to duck shot count
[State 25402, DuckShotCount]
type = ParentVarAdd
trigger1 = Time = 0
v = 26
value = 1

;Stop Quacking
[State 25404, NoQuack]
type = StopSnd
trigger1 = Time = 0
channel = 5

;Play Falling Sound
[State 25404, Fall]
type = PlaySnd
trigger1 = Anim = 25410
trigger1 = AnimTime = 0
value = 25400, 3
channel = IfElse(helper(25403),StateNo = 25404,9,10)

;Set falling velocity
[State 25404, FallVel]
type = VelSet
trigger1 = Anim = 25410
trigger1 = AnimTime = 0
Y = 2

;Change Animation to falling animation
[State 25404, FallAnim]
type = ChangeAnim
trigger1 = Anim = 25410
trigger1 = AnimTime = 0
value = 25411

;Stop falling sound
[State 25404, StopFall]
type = StopSnd
trigger1 = Vel Y > 0
trigger1 = Anim = 25411
trigger1 = ScreenPos Y = [180,185]
channel = IfElse(helper(25403),StateNo = 25404,9,10)

;Play hit ground sound
[State 25404, HitGroundSound]
type = PlaySnd
trigger1 = Vel Y > 0
trigger1 = Anim = 25411
trigger1 = ScreenPos Y = [180,185]
value = 25400,4

;Stop falling once you're behind the bush.
[State 25404, StopFall]
type = VelSet
trigger1 = Vel Y > 0
trigger1 = Anim = 25411
trigger1 = ScreenPos Y = [180,185]
Y = 0

;Disappear
[State 25404, Vanish]
type = DestroySelf
trigger1 = Time = 150
trigger2 = RoundState > 2

;--------------------------------------------------------------------------
; Duck Hunt - Disc Toss
[Statedef 25405]
type = S
anim = 30000
sprpriority = -3
velset = 0,0

;Add to disc count
[State 25405, DiscAdd]
type = ParentVarAdd
trigger1 = Time = 0
v = 27
value = 1

[State 25405, RandomX]
type = PosAdd
trigger1 = Time = 0
X = floor(Random/3.1)

;Not in the right Y position.  Fix.
[State 25405, FixY]
type = PosAdd
trigger1 = Anim = 30000
trigger1 = ScreenPos Y != [230,240]
Y = IfElse(ScreenPos Y < 230,2,-2)

;Stop previous in flight sound
[State 25405, StopFlight]
type = StopSnd
trigger1 = Anim = 30000
trigger1 = ScreenPos Y = [230,240]
channel = 3

;In Flight Sound
[State 25405, StartFlight]
type = PlaySnd
trigger1 = Anim = 30000
trigger1 = ScreenPos Y = [230,240]
value = 25400,7
volume = 1
channel = 3
lowpriority = 3

[State 25405, Toss Sound]
type = PlaySnd
trigger1 = Anim = 30000
trigger1 = ScreenPos Y = [230,240]
value = 25400,6

[State 25404, InitialVel]
type = VelSet
trigger1 = Anim = 30000
trigger1 = ScreenPos Y = [230,240]
X = IfElse(ScreenPos X < 160,1.5,-1.5)
Y = -2.5

;Add bullet to P1/P2
[State 25405, AddBulletP1]
type = ParentVarAdd
trigger1 = Anim = 30000
trigger1 = ScreenPos Y = [230,240]
trigger1 = parent,var(5) < 3
v = 5
value = 1

[State 25405, AddBulletP2]
type = ParentVarAdd
trigger1 = Anim = 30000
trigger1 = ScreenPos Y = [230,240]
trigger1 = parent,var(6) < 3
v = 6
value = 1

[State 25405, FoundYAnim]
type = ChangeAnim
trigger1 = Anim = 30000
trigger1 = ScreenPos Y = [230,240]
value = 25413

;Scaling Var
[State 25405, ScalingVar]
type = VarSet
trigger1 = Anim = 25413
fv = 0
value = 1-AnimElemTime(1)*0.0026

;Get Smaller
[State 25405, Shrink]
type = AngleDraw
trigger1 = Anim = 25413
scale = fvar(0),fvar(0)

[State 25405, Gravity]
type = VelAdd
trigger1 = Anim = 25413
Y = 0.014

;Trigger end of round
[State -2, EndRound]
type = ParentVarSet
trigger1 = parent,var(27) >= 100
trigger1 = ScreenPos Y = [140,145]
trigger1 = Vel Y > 0
trigger1 = parent,NumHelper(25403) = 1
v = 0
value = 7199

;Disappear
[State 25405, DestroySelf]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos Y = [140,145]
trigger2 = Vel Y > 0

;--------------------------------------------------------------------------
; Duck Hunt - Disc Destroy
[Statedef 25406]
type = S
anim = 25414
sprpriority = -3
velset = 0,0

;Stop previous in flight sound
[State 25405, StopFlight]
type = StopSnd
trigger1 = Time = 0
channel = 3

;Scale
[State 25405, Shrink]
type = AngleDraw
trigger1 = 1
scale = fvar(0),fvar(0)

;Play break apart sound
[State 25405, DestroySound]
type = PlaySnd
trigger1 = Time = 0
value = 25400,8

;Trigger end of round
[State -2, EndRound]
type = ParentVarSet
trigger1 = parent,var(27) >= 100
trigger1 = AnimTime = 0
trigger1 = parent,NumHelper(25403) = 1
v = 0
value = 7199

;Disappear
[State 25405, DestroySelf]
type = DestroySelf
trigger1 = AnimTime = 0
trigger2 = RoundState > 2

;--------------------------------------------------------------------------
; Mario - Decide Which Enemy Appears (Stage 3-1)
[Statedef 25450]
type = S
sprpriority = -2
velset = 0,0

;Randomly pick an enemy.
[State 25450, EnemyPick]
type = VarSet
trigger1 = Time = 0
v = 0
value = floor(Random/153)

;Fix enemy type
[State 25450, EnemyFix]
type = Varset
trigger1 = var(0) = 3
trigger2 = var(0) = 5
v = 0
value = 0;IfElse(var(0)=3,2,4)

;Now go to correct state.
[State 25450, GotoState]
type = ChangeState
trigger1 = Time = 0
value = 25451+var(0)

;--------------------------------------------------------------------------
; Mario - Goomba State
[Statedef 25451]
type = S
anim = 25420
sprpriority = -2
velset = 0,0

;Set Vel X
[State 25451, VelXSet]
type = VelSet
trigger1 = Time = 0
X = IfElse(ScreenPos X <= -8,0.5,-0.5)

;Find correct Y value
[State 25451, FindY]
type = PosAdd
trigger1 = Time = 0
Y = 200-ScreenPos Y

;Disappear
[State 25451, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Vel X > 0 && ScreenPos X > 332
trigger3 = Vel X < 0 && ScreenPos X < -12

;--------------------------------------------------------------------------
; Mario - Koopa Troopa State
[Statedef 25452]
type = S
anim = 25423
sprpriority = -2
velset = IfElse(ScreenPos X <= -8,1,-1),0

;Find correct Y value
[State 25451, FindY]
type = PosAdd
trigger1 = Time = 0
Y = 80-ScreenPos Y

;Add offset
[State 25451, YOffset]
type = PosAdd
trigger1 = Time = 0
Y = floor(Random/16.5)-30

;Turn around
[State 25452, Turn]
type = Turn
trigger1 = Anim = 25423
trigger1 = facing = 1 && Vel X < 0

;Fly towards player
[State 25452, FlyTowards]
type = ChangeAnim
trigger1 = Anim = 25423
trigger1 = Time >= 150
trigger1 = Random <= 500
value = 25424

;Stop flying forward
[State 25452, NoFlyForward]
type = VelSet
trigger1 = Anim = 25424
trigger1 = Vel X != 0
X = 0

;Grow larger
[State 25452, Grow]
type = VarAdd
trigger1 = Anim = 25424
trigger1 = fvar(0) < 2
fv = 0
value = 0.02

;Scale
[State 25452, Scale]
type = AngleDraw
trigger1 = Anim = 25424
scale = 1+fvar(0),1+fvar(0)

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
trigger1 = Time = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = Time = 0
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = fvar(0) >= 2
v = IfElse(var(3)=0,3,4)
value = -1

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = fvar(0) >= 2
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Disappear
[State 25451, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Vel X > 0 && ScreenPos X > 332
trigger3 = Vel X < 0 && ScreenPos X < -12
trigger4 = fvar(0) >= 2

;--------------------------------------------------------------------------
; Mario - Lakitu State
[Statedef 25453]
type = S
anim = 25426
sprpriority = -2
velset = IfElse(ScreenPos X <= -8,1.5,-1.5),0

;Find correct Y value
[State 25451, FindY]
type = PosAdd
trigger1 = Time = 0
Y = 80-ScreenPos Y

;Add offset
[State 25451, YOffset]
type = PosAdd
trigger1 = Time = 0
Y = floor(Random/16.5)-30

;Turn around
[State 25452, Turn]
type = Turn
trigger1 = Anim = 25426
trigger1 = facing = 1 && Vel X < 0

;Throw Spiny
[State 25452, ThrowSpiny]
type = ChangeAnim
trigger1 = ScreenPos X = [20,300]
trigger1 = Anim = 25426
trigger1 = Time >= 50
trigger1 = Random <= 500
trigger1 = NumHelper(25454) = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
value = 25427

;Create Spiny
[State -2, CreateSpiny]
type = Helper
trigger1 = Anim = 25427
trigger1 = AnimTime = 0
helpertype = normal
name = "Spiny"
ID = 25454
postype = p1
ownpal = 1
stateno = 25454
pos = 0,0

;Go back to flying state after Spiny Throw
[State 25452, FlyAnim]
type = ChangeAnim
trigger1 = Anim = 25427
trigger1 = AnimTime = 0
value = 25426

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
trigger1 = Time = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = Time = 0
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumHelper(25454) > 0
trigger1 = helper(25454),fvar(0) >= 2
v = IfElse(var(3)=0,3,4)
value = -1

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumHelper(25454) > 0
trigger1 = helper(25454),fvar(0) >= 2
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Disappear
[State 25451, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos X > 332
trigger3 = ScreenPos X < -12

;Fix score problem

;Add to P1 Score
[State 5000, Score]
type = ParentVarAdd
trigger1 = var(1) > 0
v = 1
value = var(1)

;Add to P2 Score
[State 5000, P2Score]
type = ParentVarAdd
trigger1 = var(2) > 0
v = 2
value = var(2)

;Add P1 enemy hit count
[State 5000, P1EnemyHit]
type = ParentVarAdd
trigger1 = var(11) > 0
v = 11
value = 1

;Add P2 enemy hit count
[State 5000, P2EnemyHit]
type = ParentVarAdd
trigger1 = var(12) > 0
v = 12
value = 1

;Reset vars
[State 5000, VarReset]
type = VarRangeSet
trigger1 = var(1) > 0
trigger2 = var(2) > 0
value = 0
first = 1
last = 2

[State 5000, VarReset]
type = VarRangeSet
trigger1 = var(11) > 0
trigger2 = var(12) > 0
value = 0
first = 11
last = 12

;--------------------------------------------------------------------------
; Mario - Spiny State
[Statedef 25454]
type = S
anim = 25429
sprpriority = -2
velset = 0,0

;Set enemy type
[State 25454, EnemyType]
type = VarSet
trigger1 = Time = 0
v = 0
value = 3

;Grow larger
[State 25454, Grow]
type = VarAdd
trigger1 = fvar(0) < 2.1
fv = 0
value = 0.04

;Scale
[State 25454, Scale]
type = AngleDraw
trigger1 = 1
scale = 1+fvar(0),1+fvar(0)

;Disappear
[State 25454, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Vel X > 0 && ScreenPos X > 332
trigger3 = Vel X < 0 && ScreenPos X < -12
trigger4 = fvar(0) >= 2.1

;--------------------------------------------------------------------------
; Mario - Bullet Cannon State
[Statedef 25455]
type = S
anim = 25432
sprpriority = -2
velset = IfElse(ScreenPos X <= -8,1.2,-1.2),0

;Find correct Y value
[State 25451, FindY]
type = PosAdd
trigger1 = Time = 0
Y = 80-ScreenPos Y

;Add offset
[State 25451, YOffset]
type = PosAdd
trigger1 = Time = 0
Y = floor(Random/16.5)-30

;Create Bullet Bill
[State -2, CreateSpiny]
type = Helper
trigger1 = ScreenPos X = [20,300]
trigger1 = Time >= 50
trigger1 = Random <= 300
trigger1 = NumHelper(25454) = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
helpertype = normal
name = "Bullet Bill"
ID = 25454
postype = p1
ownpal = 1
stateno = 25456
pos = 0,-20

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
trigger1 = Time = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = Time = 0
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumHelper(25454) > 0
trigger1 = helper(25454),fvar(0) >= 2
v = IfElse(var(3)=0,3,4)
value = -1

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumHelper(25454) > 0
trigger1 = helper(25454),fvar(0) >= 2
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Disappear
[State 25451, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos X > 332
trigger3 = ScreenPos X < -12

;Fix score problem

;Add to P1 Score
[State 5000, Score]
type = ParentVarAdd
trigger1 = var(1) > 0
v = 1
value = var(1)

;Add to P2 Score
[State 5000, P2Score]
type = ParentVarAdd
trigger1 = var(2) > 0
v = 2
value = var(2)

;Add P1 enemy hit count
[State 5000, P1EnemyHit]
type = ParentVarAdd
trigger1 = var(11) > 0
v = 11
value = 1

;Add P2 enemy hit count
[State 5000, P2EnemyHit]
type = ParentVarAdd
trigger1 = var(12) > 0
v = 12
value = 1

;Reset vars
[State 5000, VarReset]
type = VarRangeSet
trigger1 = var(1) > 0
trigger2 = var(2) > 0
value = 0
first = 1
last = 2

[State 5000, VarReset]
type = VarRangeSet
trigger1 = var(11) > 0
trigger2 = var(12) > 0
value = 0
first = 11
last = 12

;--------------------------------------------------------------------------
; Mario - Bullet Bill
[Statedef 25456]
type = S
anim = 25435
sprpriority = -2
velset = 0,0

;Play Cannon sound
[state 25454, CannonSound]
type = PlaySnd
trigger1 = Time = 0
value = 25410,1

;Set enemy type
[State 25454, EnemyType]
type = VarSet
trigger1 = Time = 0
v = 0
value = 5

;Grow larger
[State 25454, Grow]
type = VarAdd
trigger1 = fvar(0) < 2.1
fv = 0
value = 0.03

;Scale
[State 25454, Scale]
type = AngleDraw
trigger1 = 1
scale = 1+fvar(0),1+fvar(0)

;Disappear
[State 25454, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Vel X > 0 && ScreenPos X > 332
trigger3 = Vel X < 0 && ScreenPos X < -12
trigger4 = fvar(0) >= 2.1

;--------------------------------------------------------------------------
; Mario - Hammer Bros
[Statedef 25457]
type = S
anim = 25438
sprpriority = -4
velset = 0,0

;Play Pipe Warping Sound
[State 25457, PipeWarp]
type = PlaySnd
trigger1 = Time = 0
trigger2 = Time = 90
value = 25410,2

;Find correct X/Y value
[State 25457, FindY]
type = PosAdd
trigger1 = Time = 0
X = IfElse(ScreenPos X <= -8,95-ScreenPos X,217-ScreenPos X)
Y = 170-ScreenPos Y

;Go up pipe
[State 25457, UpPipe]
type = PosAdd
trigger1 = Time < 20
Y = -1

;Throw Hammer
[State -2, Throw Hammer]
type = Helper
trigger1 = Time = [50,60]
trigger1 = Random <= 300
trigger1 = NumHelper(25459) = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
helpertype = normal
name = "Hammer"
ID = 25459
postype = p1
ownpal = 1
stateno = 25459
pos = 5,-20

;Go down pipe
[State 25457, DownPipe]
type = PosAdd
trigger1 = Time >= 90
Y = 1

;Disappear
[State 25457, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Time >= 110

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
trigger1 = Time = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = Time = 0
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumHelper(25459) > 0
trigger1 = helper(25459),fvar(0) >= 2
v = IfElse(var(3)=0,3,4)
value = -1

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumHelper(25459) > 0
trigger1 = helper(25459),fvar(0) >= 2
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Fix score problem

;Add P1 enemy hit count
[State 5000, P1EnemyHit]
type = ParentVarAdd
trigger1 = var(11) > 0
v = 11
value = 1

;Add P2 enemy hit count
[State 5000, P2EnemyHit]
type = ParentVarAdd
trigger1 = var(12) > 0
v = 12
value = 1

[State 5000, VarReset]
type = VarRangeSet
trigger1 = var(11) > 0
trigger2 = var(12) > 0
value = 0
first = 11
last = 12

;--------------------------------------------------------------------------
; Mario - Enemy Die
[Statedef 25458]
type = S
anim = 25422+(3*var(0))
sprpriority = -2
velset = 0,-4

;Play Sound
[State 25458, DeathSound]
type = PlaySnd
trigger1 = Time = 0
value = 25410,0

;Gravity
[State 25458, Gravity]
type = Gravity
trigger1 = 1

;Scale
[State 25458, Scale]
type = AngleDraw
trigger1 = 1
scale = 1+fvar(0),1+fvar(0)

;Disappear
[State 25458, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos Y >= 350

;--------------------------------------------------------------------------
; Mario - Hammer State
[Statedef 25459]
type = S
anim = 25441
sprpriority = -2
velset = 0,0

;Grow larger
[State 25459, Grow]
type = VarAdd
trigger1 = fvar(0) < 2.1
fv = 0
value = 0.04

;Scale
[State 25459, Scale]
type = AngleDraw
trigger1 = 1
scale = 1+fvar(0),1+fvar(0)

;Disappear
[State 25459, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Vel X > 0 && ScreenPos X > 332
trigger3 = Vel X < 0 && ScreenPos X < -12
trigger4 = fvar(0) >= 2.1

;--------------------------------------------------------------------------
; Mario - Hammer Repel
[Statedef 25460]
type = S
sprpriority = -2
velset = 0,-7

;Play Sound
[State 25460, DeathSound]
type = PlaySnd
trigger1 = Time = 0
value = 25410,0

;Scale
[State 25458, Scale]
type = AngleDraw
trigger1 = 1
scale = 1+fvar(0),1+fvar(0)

;Disappear
[State 25458, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos Y <= -20

;--------------------------------------------------------------------------
; Mario - Item Block State
[Statedef 25461]
type = S
sprpriority = -2
velset = 0,0
anim = IfElse(Random<=500,25442,25446)

;Set initial Y to 0.
[State 25461, ZeroY]
type = PosAdd
trigger1 = Time = 0
Y = -ScreenPos Y

;Now Get Y between 30 and 130
[State 25461, RandomY]
type = PosAdd
trigger1 = Time = 0
Y = floor(Random/9.9)+30

;Cannot be hit for the first few seconds.
[State 25461, NoHit]
type = NotHitBy
trigger1 = Time < 50
value = SCA

;Flash in and out (appear)
[State 25461, Flash]
type = AssertSpecial
triggerall = Time%2 = 0
trigger1 = Time < 50
trigger2 = Time > 500
flag = invisible

;Disappear
[State 25461, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Time >= 550

;--------------------------------------------------------------------------
; Mario - Item Block State (Hit)
[Statedef 25463]
type = S
sprpriority = -1
velset = 0,0

;1UP or Coin?
[State 25461, 1UpCoin]
type = VarSet
trigger1 = Time = 0
trigger1 = Anim = 25442
v = 0
value = IfElse(Random<=300,1,0)

;Test for 1UP
[State 25461, Make1Up]
type = Helper
trigger1 = Time = 0
trigger1 = Anim = 25442
trigger1 = var(0) = 1
helpertype = normal
name = "Stage 3-1 1UP"
ID = 25464
postype = p1
stateno = 25464

;Make a coin appear.
[State 25461, CoinSound]
type = PlaySnd
trigger1 = Time = 0
trigger1 = Anim = 25442
trigger1 = var(0) = 0
value = 180,2

[State 25461, CoinExplod]
type = Explod
trigger1 = Time = 0
trigger1 = Anim = 25442
trigger1 = var(0) = 0
anim = 25445
ID = 25462
postype = p1
bindtime = 1
removetime = 40
ownpal = 1
sprpriority = -2
pos = 0,0
vel = 0,-4
accel = 0,0.2

;Make block pieces appear.
[State 25461, BrickSound]
type = PlaySnd
trigger1 = Time = 0
trigger1 = Anim = 25446
value = 25410,3

[State 25461, Brick Piece UL]
type = Explod
trigger1 = Time = 0
trigger1 = Anim = 25446
anim = 25447
ID = 25462
postype = p1
bindtime = 1
removetime = 80
ownpal = 1
sprpriority = -2
pos = -5,-5
vel = -0.5,-4
accel = 0,0.5

[State 25461, Brick Piece LL]
type = Explod
trigger1 = Time = 0
trigger1 = Anim = 25446
anim = 25447
ID = 25462
postype = p1
bindtime = 1
removetime = 80
ownpal = 1
sprpriority = -2
pos = -5,5
vel = -0.3,-4
accel = 0,0.5

[State 25461, Brick Piece UR]
type = Explod
trigger1 = Time = 0
trigger1 = Anim = 25446
anim = 25447
ID = 25462
postype = p1
bindtime = 1
removetime = 80
ownpal = 1
sprpriority = -2
pos = 5,-5
vel = 0.5,-4
accel = 0,0.5

[State 25461, Brick Piece LR]
type = Explod
trigger1 = Time = 0
trigger1 = Anim = 25446
anim = 25447
ID = 25462
postype = p1
bindtime = 1
removetime = 80
ownpal = 1
sprpriority = -2
pos = 5,5
vel = 0.3,-4
accel = 0,0.5

;Add to P1 Score
[State 25461, Score]
type = ParentVarAdd
triggerall = Time = 0
triggerall = (Anim = 25442 && var(0) = 0) || Anim = 25446
trigger1 = GetHitVar(damage)=1
trigger2 = GetHitvar(damage)=3 && enemy,TeamSide = 1
v = 1
value = IfElse(Anim = 25442,100,50)

;Add to P2 Score
[State 25461, P2Score]
type = ParentVarAdd
triggerall = Time = 0
triggerall = (Anim = 25442 && var(0) = 0) || Anim = 25446
trigger1 = GetHitVar(damage)=3 && enemy,TeamSide = 2
trigger2 = GetHitVar(damage)=2
v = 2
value = IfElse(Anim = 25442,100,50)

;Change Block Animation to hit block
[State 25461, BlockHit]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = Anim != 25446
value = 25443

;Flash in and out (appear)
[State 25461, Flash]
type = AssertSpecial
triggerall = Time%2 = 0
trigger1 = Time > 400
flag = invisible

;EXTRA LIFE
[State 5000, P1Life]
type = ParentVarAdd
trigger1 = var(3) > 0
v = 3
value = 1

[State 5000, P2Life]
type = ParentVarAdd
trigger1 = var(4) > 0
v = 4
value = 1

;Reset Vars
[State 5000, VarReset]
type = VarRangeSet
trigger1 = var(3) > 0
trigger2 = var(4) > 0
first = 3
last = 4
value = 0

;Disappear
[State 25461, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Time >= 450
trigger3 = Anim = 25446

;--------------------------------------------------------------------------
; Mario - 1UP State
[Statedef 25464]
type = S
sprpriority = -2
velset = 0,-0.2
anim = 25444

;Item come up sound
[State 25461, ItemSound]
type = PlaySnd
trigger1 = Time = 0
value = 25410,4

;Stop going up / Start going down-right
[State 25464, StopGoingup]
type = VelSet
trigger1 = Time = 80
X = 1
Y = 2

;Stop going down
[State 25464, StopGoingup]
type = VelSet
trigger1 = Time > 80
trigger1 = ScreenPos Y >= 200
Y = 0

;Disappear
[State 25464, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos X >= 340

;--------------------------------------------------------------------------
; Mario - 1UP State (Hit)
[Statedef 25465]
type = S
sprpriority = -2
velset = 0,-3
anim = 25448

;1Up Sound
[State 25464, 1UPSound]
type = PlaySnd
trigger1 = Time = 0
value = 2,7

;EXTRA LIFE
[State 5000, P1Life]
type = ParentVarAdd
triggerall = Time = 0
trigger1 = GetHitVar(damage)=1
trigger2 = GetHitvar(damage)=3 && enemy,TeamSide = 1
v = 3
value = 1

[State 5000, P2Life]
type = ParentVarAdd
triggerall = Time = 0
trigger1 = GetHitVar(damage)=3 && enemy,TeamSide = 2
trigger2 = GetHitVar(damage)=2
v = 4
value = 1

;Disappear
[State 25465, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Time = 100

;--------------------------------------------------------------------------
; Mario - Bowser's Castle Windows
[Statedef 60011]
type = S
anim = 60011
sprpriority = -5
velset = 0,0

;Set correct Y pos
[State 60011, CorrectY]
type = PosAdd
trigger1 = Time = 0
Y = -ScreenPos Y

;Set Thunder
[State 60011, ThunderAnim]
type = ChangeAnim
trigger1 = Anim = 60011
trigger1 = Random >= 980
value = 60012

;Thunder Sound
[State 60011, ThunderSound]
type = PlaySnd
trigger1 = AnimElem = 1,0
value = 25410,5

;Back to black window
[State 60011, BlackWindow]
type = ChangeAnim
trigger1 = Anim = 60012
trigger1 = AnimTime = 0
value = 60011

;Disappear
[State 60011, Disappear]
type = DestroySelf
trigger1 = RoundState > 3

;--------------------------------------------------------------------------
; Mario - Bowser State
[Statedef 25466]
type = S
sprpriority = -4

;DISPLAY LIFE BAR
;Remove HP Explod for Modification
[State -2, RemoveHPBar]
type = RemoveExplod
triggerall = NumExplod(16001) > 0
triggerall = RoundState = 2
trigger1 = GetHitVar(damage) > 0
trigger2 = helper(25471),var(7) =  29
trigger3 = helper(25472),var(7) =  29
trigger4 = helper(25473),var(7) =  29
ID = 16001

[State -2, RemoveOuterHPBar]
type = RemoveExplod
triggerall = NumExplod(16000) > 0
triggerall = RoundState = 2
trigger1 = GetHitVar(damage) > 0
trigger2 = helper(25471),var(7) =  29
trigger3 = helper(25472),var(7) =  29
trigger4 = helper(25473),var(7) =  29
ID = 16000

[State -2, RemoveNamePlate]
type = RemoveExplod
triggerall = NumExplod(15022) > 0
triggerall = RoundState = 2
trigger1 = GetHitVar(damage) > 0
trigger2 = helper(25471),var(7) =  29
trigger3 = helper(25472),var(7) =  29
trigger4 = helper(25473),var(7) =  29
ID = 15022

[State -2,BossLifeBar]
type = Explod
triggerall = RoundState = 2
triggerall = NumExplod(16000) = 0
trigger1 = var(5) > 0
trigger1 = var(6) > 0
trigger1 = GetHitVar(damage) > 0
anim = 16000
ID = 16000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 105,215

[State -2,BossLifeFill]
type = Explod
triggerall = RoundState = 2
triggerall = NumExplod(16001) = 0
trigger1 = var(5) > 0
trigger1 = var(6) > 0
trigger1 = GetHitVar(damage) > 0
anim = 16001
ID = 16001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -1
pos = 105-(floor(100*var(6)/var(5)))+3,215
scale = floor(100*var(6)/var(5))-2,1

;Set Initial Animation
[State 25030, InitialAnim]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = var(5) = 0
value = 25450

;Set initial pos
[State 25030, InitialPos]
type = PosAdd
trigger1 = Time = 0
trigger1 = var(5) = 0
X = 160-ScreenPos X
Y = 180-ScreenPos Y

;Set HP
[State 25030, MaxHP]
type = VarSet
trigger1 = Time = 0
trigger1 = var(5) = 0
v = 5
value = 150

[State 25030,HP]
type = VarSet
trigger1 = Time = 0
trigger1 = var(6) = 0
v = 6
value = var(5)

;Display Name
[State 25030, Name]
type = Explod
trigger1 = RoundState = 2
trigger1 = NumExplod(15022) = 0
trigger1 = GetHitVar(damage) > 0
anim = 15023
ID = 15022
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 105,205

;I got hit.
;Flash
[State 25030, Flash]
type = AssertSpecial
trigger1 = Time%2 = 0
trigger1 = var(7) > 0
flag = invisible

;Do not hurt me while invincible.
[State 25030, NoHurt]
type = NotHitBy
trigger1 = var(7) > 0
value = SCA

;Decrease invincibility timer.
[State 25030, Timer]
type = VarAdd
trigger1 = var(7) > 0
v = 7
value = -1

;Destroy
[State 25030, Disappear]
type = DestroySelf
trigger1 = RoundState > 2

;BOWSER'S MOVES GO HERE

;;;;;;;;;;;;;;
;; BIG JUMP ;;
;;;;;;;;;;;;;;
;Set the animation
[State 25466, BigJump]
type = ChangeAnim
trigger1 = Anim = 25450
trigger1 = Random <= 150
value = 25451

;Play the Jump Sound
[State 25466, JumpSound]
type = PlaySnd
trigger1 = Anim = 25451
trigger1 = AnimElem = 6
value = 25410,6

;Set the jump vel
[State 25466, JumpVel]
type = Velset
trigger1 = Anim = 25451
trigger1 = AnimElem = 6
trigger1 = Vel Y = 0
Y = -5

;Set the new position
[STate 25466, NewX]
type = PosSet
trigger1 = Anim = 25451
trigger1 = Vel Y < 0
trigger1 = ScreenPos Y <= -100
X = floor(Random/3.84)-130

;Go down
[State 25466, GoDown]
type = VelSet
trigger1 = Anim = 25451
trigger1 = Vel Y < 0
trigger1 = ScreenPos Y <= -100
Y = -Vel Y

;Change to jump down anim
[State 25466, DownAnim]
type = ChangeAnim
trigger1 = Anim = 25451
trigger1 = Vel Y > 0
value = 25452

;Play landing sound
[State 25466, LandSound]
type = PlaySnd
trigger1 = Anim = 25452
trigger1 = Vel Y > 0
trigger1 = ScreenPos Y >= 180
value = 25410,7

;Go to landing anim
[State 25466, LandAnim]
type = ChangeAnim
trigger1 = Anim = 25452
trigger1 = Vel Y > 0
trigger1 = ScreenPos Y >= 180
value = 25453

;Stop Moving down
[State 25466, StopDown]
type = VelSet
trigger1 = Anim = 25453
trigger1 = Vel Y > 0
trigger1 = ScreenPos Y >= 180
Y = 0

;Go back to idle anim
[State 25466, StopDown]
type = ChangeAnim
trigger1 = Anim = 25453
trigger1 = AnimTime = 0
value = 25450

;Add P1 enemy hit count
[State 5000, P1EnemyHit]
type = ParentVarAdd
trigger1 = var(11) > 0
v = 11
value = 1

;Add P2 enemy hit count
[State 5000, P2EnemyHit]
type = ParentVarAdd
trigger1 = var(12) > 0
v = 12
value = 1

;Reset hit vars
[State 25466, HitVarReset]
type = VarRangeSet
trigger1 = var(11) > 0
trigger2 = var(12) > 0
first = 11
last = 12
value = 0

;;;;;;;;;;;;;;;;
;; SHELL SPIN ;;
;;;;;;;;;;;;;;;;
;Set the animation
[State 25466, GoIntoShell]
type = ChangeAnim
trigger1 = Anim = 25450
trigger1 = Random <= 100
trigger1 = NumHelper(25468) = 0
value = 25455

;Create Thwomps
[State 25466, Thwomps]
type = Helper
trigger1 = Anim = 25455
trigger1 = NumHelper(25468) < 2
helpertype = normal
name = "Stage 3-2 Thwomp"
ID = 25468
postype = left
ownpal = 1
stateno = 25468
pos = 0,0

;Set initial velocity
[State 25466, SetVel]
type = VelSet
trigger1 = Anim = 25455
trigger1 = AnimTime = 0
X = IfElse(Random <= 500,-5,5)

;Set Shell spinning anim
[State 25466, ShellSpin]
type = ChangeAnim
trigger1 = Anim = 25455
trigger1 = AnimTime = 0
value = 25456

;Against the walls.  Go in the opposite direction
[State 25466, ShellSpin]
type = VelSet
trigger1 = Anim = 25456
trigger1 = ScreenPos X < 10 || ScreenPos X > 310
X = -Vel X

;Hurt!  Come out of shell sound.
[State 25466, HurtOutOfShellSound]
type = PlaySnd
trigger1 = Anim = 25456
trigger1 = GetHitVar(damage) = 20
value = 25410,9

;Come out of shell.
[State 25466, ShellSpin]
type = ChangeAnim
trigger1 = Anim = 25456
trigger1 = GetHitVar(damage) = 20
value = 25457

;Stop moving.
[State 25466, ShellSpin]
type = Velset
trigger1 = Anim = 25457
trigger1 = Vel X != 0
X = 0

;Tears.
[State 25466, Tears]
type = ChangeAnim
trigger1 = Anim = 25457
trigger1 = AnimTime = 0
value = 25458

;Move is finished.
[State 25466, BacktoIdle]
type = ChangeAnim
trigger1 = Anim = 25458
trigger1 = AnimTime = 0
value = 25450

;;;;;;;;;;;;;;;;;
;; FIRE BREATH ;;
;;;;;;;;;;;;;;;;;
;Set the animation
[State 25466, GoIntoShell]
type = ChangeAnim
trigger1 = Anim = 25450
trigger1 = Random <= 300
trigger1 = NumHelper(25469) < 3
value = 25454

;Fire Sound
[State 25466, FireSound]
type = PlaySnd
trigger1 = Anim = 25454
trigger1 = AnimElem = 5,0
value = 25410,8

;Create the Fire
[State 25466, FireLeft]
type = Helper
triggerall = NumHelper(25469) < 3
trigger1 = Anim = 25454
trigger1 = AnimElem = 5,1 || AnimElem = 5,2 || AnimElem = 5,3
;trigger2 = Anim = 25456
;trigger2 = AnimElem = 2
;trigger2 = Random <= 200
helpertype = normal
name = "Bowser Fire"
ID = 25469
postype = p1
stateno = 25469
pos = 0,0

;Move is finished.
[State 25466, BacktoIdle]
type = ChangeAnim
trigger1 = Anim = 25454
trigger1 = AnimTime = 0
value = 25450

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = Anim = 25454 && AnimElem = 2
trigger2 = Anim = 25456 && AnimElem = 2
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumHelper(25469) > 0
trigger1 = helper(25469),fvar(0) >= 2
v = IfElse(var(3)=0,3,4)
value = -1

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumHelper(25469) > 0
trigger1 = helper(25469),fvar(0) >= 2
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Fix score problem

;Add P1 enemy hit count
[State 5000, P1EnemyHit]
type = ParentVarAdd
trigger1 = var(11) > 0
v = 11
value = 1

;Add P2 enemy hit count
[State 5000, P2EnemyHit]
type = ParentVarAdd
trigger1 = var(12) > 0
v = 12
value = 1

[State 5000, VarReset]
type = VarRangeSet
trigger1 = var(11) > 0
trigger2 = var(12) > 0
value = 0
first = 11
last = 12

;--------------------------------------------------------------------------
; Mario - Bowser Die State
[Statedef 25467]
type = S
sprpriority = -4
anim = 25450
velset = 0,-4

;Add to P1 Score
[State 5000, Score]
type = ParentVarAdd
triggerall = Time = 0
trigger1 = GetHitVar(damage)=1
trigger2 = GetHitvar(damage)=3 && enemy,TeamSide = 1
v = 1
value = 5000

;Add to P2 Score
[State 5000, P2Score]
type = ParentVarAdd
triggerall = Time = 0
trigger1 = GetHitVar(damage)=3 && enemy,TeamSide = 2
trigger2 = GetHitVar(damage)=2
v = 2
value = 5000

;Can't hit me
[State 25467, NoHit]
type = NotHitBy
trigger1 = 1
value = SCA

;Play Death Sound
[State 25467, DeathSound]
type = PlaySnd
trigger1 = Time = 0
value = 25410, 10

;Turn Upside Down
[State 25467, UpsideDown]
type = AngleDraw
trigger1 = 1
value = 180

;Apply Gravity
[State 25467, Gravity]
type = VelAdd
trigger1 = ScreenPos Y < 210
Y = 0.1

;Sink slowly into lava
[State 25467, LavaSink]
type = VelSet
trigger1 = ScreenPos Y >= 210
Y = 0.3

;Remove name Explod
[State 25032, NoName]
type = RemoveExplod
trigger1 = Time = 0
ID = 15022

;Remove Life Bar
[State 25032, NoName]
type = RemoveExplod
trigger1 = Time = 0
ID = 16000

[State 25032, NoName]
type = RemoveExplod
trigger1 = Time = 0
ID = 16001

;Trigger end of round
[State 25032, EndRound]
type = ParentVarSet
trigger1 = ScreenPos Y >= 260
v = 0
value = 7199

;Destroy Self
[State 25032, Destroy]
type = DestroySelf
trigger1 = RoundState > 2

;--------------------------------------------------------------------------
; Mario - Thwomp State
[Statedef 25468]
type = S
sprpriority = -4

;Set initial pos
[State 25468, InitialPos]
type = PosAdd
trigger1 = Time = 0
trigger1 = Vel Y = 0
trigger1 = Anim != [25459,25460]
X = IfElse(parent,NumHelper(25468)=1,80-ScreenPos X,240-ScreenPos X)
Y = 30-ScreenPos Y

;Set initial anim
[State 25468, InitialAnim]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = Anim != [25459,25460]
trigger1 = Vel Y = 0
value = 25459

;Can't hit me.
[State 25468, NoHit]
type = NotHitBy
trigger1 = ScreenPos Y != 30
value = SCA

;Set StateType
[State 25468, AttackStateType]
type = StateTypeSet
trigger1 = Anim = 25460
movetype = A

[State 25468, IdleStateType]
type = StateTypeSet
trigger1 = Anim = 25459
movetype = I

;Thwomp Hit Detection
[State 25468, Hit Detection]
type = HitDef
trigger1 = ScreenPos Y = 30
damage = 20,20
attr = S,N
sparkno = -1
affectteam = B

;Add P1 enemy hit count
[State 5000, P1EnemyHit]
type = ParentVarAdd
triggerall = GetHitVar(damage) > 0
trigger1 = GetHitVar(damage)=1
trigger2 = GetHitvar(damage)=3 && enemy,TeamSide = 1
v = 11
value = 1

;Add P2 enemy hit count
[State 5000, P2EnemyHit]
type = ParentVarAdd
triggerall = GetHitVar(damage) > 0
trigger1 = GetHitVar(damage)=3 && enemy,TeamSide = 2
trigger2 = GetHitVar(damage)=2
v = 12
value = 1

;GoDownAnim
[State 25468, GoDownAnim]
type = ChangeAnim
trigger1 = GetHitVar(damage) > 0
trigger1 = Anim = 25459
value = 25460

;Go down
[State 25468, GoDown]
type = VelSet
trigger1 = GetHitVar(damage) > 0
trigger1 = Vel Y = 0
Y = 3

;Land sound
[State 25468, LandSound]
type = PlaySnd
trigger1 = Vel Y > 0
trigger1 = ScreenPos Y >= 180
trigger1 = Anim = 25460
value = 25410,7

;OriginalAnim
[State 25468, GoUpAnim]
type = ChangeAnim
trigger1 = Vel Y > 0
trigger1 = ScreenPos Y >= 180
trigger1 = Anim = 25460
value = 25459

;Go back up
[State 25468, GoDown]
type = VelSet
trigger1 = Vel Y > 0
trigger1 = ScreenPos Y >= 180
trigger1 = Anim = 25459
Y = -3

;Stop going up
[State 25468, StopUp]
type = VelSet
trigger1 = Vel Y < 0
trigger1 = ScreenPos Y <= 30
trigger1 = Anim = 25459
Y = 0

;Disappear
[State 25468, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = helper(25000),Anim = 25450
trigger3 = helper(25000),StateNo = 25467

;--------------------------------------------------------------------------
; Mario - Bowser Fire State
[Statedef 25469]
type = S
anim = 25461
sprpriority = -3

;Fire Sound
[State 25466, FireSound]
type = PlaySnd
trigger1 = Time = 0
trigger1 = parent,Anim = [25463,25465]
value = 25410,8

;Velset
[State 25469, VelSet]
type = VelSet
trigger1 = parent,Anim = 25454
trigger1 = Time = 0
X = IfElse(parent,NumHelper(25469)=1,-1,IfElse(parent,NumHelper(25469)=3,1,0))

;Grow larger
[State 25469, Grow]
type = VarAdd
trigger1 = fvar(0) < 2.1
fv = 0
value = 0.03

;Scale
[State 25469, Scale]
type = AngleDraw
trigger1 = 1
scale = 1+fvar(0),1+fvar(0)

;Got hit sound
[State 5000, HitSound]
type = PlaySnd
trigger1 = Time = 0
trigger1 = GetHitVar(damage) > 0
value = 25410,0

;Add P1 enemy hit count
[State 5000, P1EnemyHit]
type = ParentVarAdd
triggerall = Time = 0
trigger1 = GetHitVar(damage)=1
trigger2 = GetHitvar(damage)=3 && enemy,TeamSide = 1
v = 11
value = 1

;Add P2 enemy hit count
[State 5000, P2EnemyHit]
type = ParentVarAdd
triggerall = Time = 0
trigger1 = GetHitVar(damage)=3 && enemy,TeamSide = 2
trigger2 = GetHitVar(damage)=2
v = 12
value = 1

;Disappear
[State 25469, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Vel X > 0 && ScreenPos X > 332
trigger3 = Vel X < 0 && ScreenPos X < -12
trigger4 = fvar(0) >= 2.1
trigger5 = GetHitVar(damage) > 0
trigger6 = helper(25000),StateNo = 25467

;--------------------------------------------------------------------------
; Mario - Jumping Fire State
[Statedef 25470]
type = S
anim = 25462
sprpriority = -4
velset = 0,-6

;Set initial position
[State 25470, InitialPos]
type = PosAdd
trigger1 = Time = 0
X = floor(Random/3.56)+40-ScreenPos X
Y = 260-ScreenPos Y

;Entry sound
[State 25470, EntrySound]
type = PlaySnd
trigger1 = Time = 0
value = 25410,12

;Apply gravity
[State 25470, Gravity]
type = VelAdd
trigger1 = Vel Y < 0
Y = 0.1

;Grow larger
[State 25470, Grow]
type = VarAdd
trigger1 = Vel Y >= 0
fv = 0
value = 0.05

;Scale
[State 25469, Scale]
type = AngleDraw
trigger1 = 1
value = IfElse(Vel Y >= 0,180,0)
scale = 1+fvar(0),1+fvar(0)

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = Time = 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = fvar(0) >= 2
v = IfElse(var(3)=0,3,4)
value = -1

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = fvar(0) >= 2
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Go to die state when Bowser dead
[State 25470, DieState]
type = ChangeState
trigger1 = helper(25000),StateNo = 25467
value = 25472

;Disappear
[State 25470, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = fvar(0) >= 2

;--------------------------------------------------------------------------
; Mario - Koopaling State
[Statedef 25471]
type = S
sprpriority = -4

;DISPLAY LIFE BAR
;Remove HP Explod for Modification
[State -2, RemoveHPBar]
type = RemoveExplod
triggerall = RoundState = 2
triggerall= NumExplod(16001) > 0
trigger1 = GetHitVar(damage) > 0
trigger2 = helper(25000),var(7) = 49
trigger3 = Anim = 25463 && (helper(25472),var(7) = 29 || helper(25473),var(7) = 29)
trigger4 = Anim = 25464 && (helper(25471),var(7) = 29 || helper(25473),var(7) = 29)
trigger5 = Anim = 25465 && (helper(25471),var(7) = 29 || helper(25472),var(7) = 29)
ID = 16001

[State -2, RemoveOuterHPBar]
type = RemoveExplod
triggerall = RoundState = 2
triggerall = NumExplod(16000) > 0
trigger1 = GetHitVar(damage) > 0
trigger2 = helper(25000),var(7) = 49
trigger3 = Anim = 25463 && (helper(25472),var(7) = 29 || helper(25473),var(7) = 29)
trigger4 = Anim = 25464 && (helper(25471),var(7) = 29 || helper(25473),var(7) = 29)
trigger5 = Anim = 25465 && (helper(25471),var(7) = 29 || helper(25472),var(7) = 29)
ID = 16000

[State -2, RemoveNamePlate]
type = RemoveExplod
triggerall = RoundState = 2
triggerall = NumExplod(15022) > 0
trigger1 = GetHitVar(damage) > 0
trigger2 = helper(25000),var(7) = 49
trigger3 = Anim = 25463 && (helper(25472),var(7) = 29 || helper(25473),var(7) = 29)
trigger4 = Anim = 25464 && (helper(25471),var(7) = 29 || helper(25473),var(7) = 29)
trigger5 = Anim = 25465 && (helper(25471),var(7) = 29 || helper(25472),var(7) = 29)
ID = 15022

[State -2,BossLifeBar]
type = Explod
triggerall = RoundState = 2
triggerall = NumExplod(16000) = 0
trigger1 = var(5) > 0
trigger1 = var(6) > 0
trigger1 = GetHitVar(damage) > 0
anim = 16000
ID = 16000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 105,215

[State -2,BossLifeFill]
type = Explod
triggerall = RoundState = 2
triggerall = NumExplod(16001) = 0
trigger1 = var(5) > 0
trigger1 = var(6) > 0
trigger1 = GetHitVar(damage) > 0
anim = 16001
ID = 16001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -1
pos = 105-(floor(100*var(6)/var(5)))+3,215
scale = floor(100*var(6)/var(5))-2,1

;Display Name
[State 25030, Name]
type = Explod
trigger1 = RoundState = 2
trigger1 = NumExplod(15022) = 0
trigger1 = GetHitVar(damage) > 0
anim = 15024+Anim-25463
ID = 15022
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 105,205

;Set HP
[State 25030, MaxHP]
type = VarSet
trigger1 = Time = 0
trigger1 = var(5) = 0
v = 5
value = 80

[State 25030,HP]
type = VarSet
trigger1 = Time = 0
trigger1 = var(6) = 0
v = 6
value = var(5)

;Set initial position
[State 25470, InitialPos]
type = PosAdd
trigger1 = Anim != [25463,25465]
trigger1 = Time = 0
X = floor(Random/3.56)+40-ScreenPos X
Y = 180-ScreenPos Y

;Set initial anim
[State 25470, KoopaAnim]
type = ChangeAnim
trigger1 = Anim != [25463,25465]
trigger1 = Time = 0
value = IfElse(parent,var(0)=1,25463,IfElse(parent,var(0)=2,25464,25465))

;I got hit.
;Flash
[State 25030, Flash]
type = AssertSpecial
trigger1 = Time%2 = 0
trigger1 = var(7) > 0
flag = invisible

;Do not hurt me while invincible.
[State 25030, NoHurt]
type = NotHitBy
trigger1 = var(7) > 0
value = SCA

;Decrease invincibility timer.
[State 25030, Timer]
type = VarAdd
trigger1 = var(7) > 0
v = 7
value = -1

;Go to die state when Bowser dead
[State 25470, DieState]
type = ChangeState
trigger1 = helper(25000),StateNo = 25467
value = 25472

;Disappear
[State 25470, Disappear]
type = DestroySelf
trigger1 = RoundState > 2

;;;;;;;;;;;;;
;; JUMPING ;;
;;;;;;;;;;;;;
;Play Jump Sound
[State 25471, JumpSound]
type = PlaySnd
trigger1 = Vel X = 0
trigger1 = Vel Y = 0
value = 25410,6

;Reset rotation timer
[State 25471, ResetRotateTime]
type = VarSet
trigger1 = Vel X = 0
trigger1 = Vel Y = 0
v = 1
value = 0

;Increase rotation timer
[State 25471, ResetRotateTime]
type = VarAdd
trigger1 = Vel Y != 0
v = 1
value = 1

;Rotate
[State 25471, Rotate]
type = AngleDraw
trigger1 = Vel Y != 0
value = (-Vel X/2)*var(1)*3.6

;Set jump vel
[State 25471, JumpVel]
type = VelSet
trigger1 = Vel X = 0
trigger1 = Vel Y = 0
X = IfElse(Random<=500,-2,2)
Y = -5

;Gravity
[State 25471, Gravity]
type = VelAdd
trigger1 = Vel Y != 0
Y = 0.1

;Against the walls.  Change Vel
[State 25471, OppositeVel]
type = VelSet
trigger1 = Vel X < 0 && ScreenPos X <= 10
trigger2 = Vel X > 0 && ScreenPos X >= 310
X = -Vel X

;Stop jump
[State 25471, JumpStop]
type = VelSet
trigger1 = Vel Y > 0
trigger1 = ScreenPos Y >= 180
X = 0
Y = 0

;Create the Fire
[State 25466, FireLeft]
type = Helper
trigger1 = helper(25000),NumHelper(25469) < 3
trigger1 = Random <= 100
trigger1 = NumHelper(25469) = 0
trigger1 = GameTime%30 = 0
helpertype = normal
name = "Bowser Fire"
ID = 25469
postype = p1
stateno = 25469
pos = 0,0

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumHelper(25469) > 0
trigger1 = helper(25469),fvar(0) >= 2
v = IfElse(var(3)=0,3,4)
value = -1

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumHelper(25469) > 0
trigger1 = helper(25469),fvar(0) >= 2
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Fix score problem

;Add P1 enemy hit count
[State 5000, P1EnemyHit]
type = ParentVarAdd
trigger1 = var(11) > 0
v = 11
value = 1

;Add P2 enemy hit count
[State 5000, P2EnemyHit]
type = ParentVarAdd
trigger1 = var(12) > 0
v = 12
value = 1

[State 5000, VarReset]
type = VarRangeSet
trigger1 = var(11) > 0
trigger2 = var(12) > 0
value = 0
first = 11
last = 12

;--------------------------------------------------------------------------
; Mario - Fire / Koopaling Die State
[Statedef 25472]
type = S
sprpriority = -4
velset = 0,-4

;Add to P1 Score
[State 5000, Score]
type = ParentVarAdd
triggerall = Time = 0
triggerall = Anim = [25463,25465]
trigger1 = GetHitVar(damage)=1
trigger2 = GetHitvar(damage)=3 && enemy,TeamSide = 1
v = 1
value = 3000

;Add to P2 Score
[State 5000, P2Score]
type = ParentVarAdd
triggerall = Time = 0
triggerall = Anim = [25463,25465]
trigger1 = GetHitVar(damage)=3 && enemy,TeamSide = 2
trigger2 = GetHitVar(damage)=2
v = 2
value = 5000

;Remove HP Explod for Modification
[State -2, RemoveHPBar]
type = RemoveExplod
trigger1 = NumExplod(16001) > 0
trigger1 = Time = 0
ID = 16001

[State -2, RemoveOuterHPBar]
type = RemoveExplod
trigger1 = NumExplod(16000) > 0
trigger1 = Time = 0
ID = 16000

[State -2, RemoveNamePlate]
type = RemoveExplod
trigger1= NumExplod(15022) > 0
trigger1 = Time = 0
ID = 15022

;Can't hit me
[State 25467, NoHit]
type = NotHitBy
trigger1 = 1
value = SCA

;Play Death Sound
[State 25467, DeathSound]
type = PlaySnd
trigger1 = Time = 0
value = 25410, 0

;Turn Upside Down
[State 25467, UpsideDown]
type = AngleDraw
trigger1 = 1
value = IfElse(Anim = 25462,0,180)
scale = 1+fvar(0),1+fvar(0)

;Apply Gravity
[State 25467, Gravity]
type = VelAdd
trigger1 = ScreenPos Y < 210
Y = 0.1

;Sink slowly into lava
[State 25467, LavaSink]
type = VelSet
trigger1 = ScreenPos Y >= 220
Y = 0.3

;Destroy Self
[State 25032, Destroy]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos Y >= 260

;--------------------------------------------------------------------------
; Star Wars - Stormtrooper/Officer State
[Statedef 25473]
type = S
sprpriority = -4
velset = 0,0

;Set initial anim to behind rock anim (sets enemy type as well)
[State 25473, InitialAnim]
type = ChangeAnim
trigger1 = Time = 0
value = IfElse(Random<=500,25470,25474)

;Set initial X
[State 25473, InitialX]
type = PosAdd
trigger1 = Time = 0
X = IfElse(Random>=0&&Random<333,-10-ScreenPos X,IfElse(Random>=333&&Random<666,330-ScreenPos X,floor(Random/9.9)+110-ScreenPos X))

;Set initial Y
[State 25473, InitialY]
type = PosAdd
trigger1 = Time = 0
Y = IfElse(ScreenPos X<=-10||ScreenPos X>=330,floor(Random/64)+210-ScreenPos Y,180-ScreenPos Y)

;Change sprite to walk
[State 25473, Sprite]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = ScreenPos X <= -10 || ScreenPos X >= 330
value = Anim+1

;Turn around if on other side of screen.
[State 25473, Turn]
type = Turn
trigger1 = Time = 0
trigger1 = ScreenPos X >= 330 && facing = 1

;Change sprite priority if in front of rock
[State 25473, SprPriority]
type = SprPriority
trigger1 = Time = 0
trigger1 = ScreenPos X <= -10 || ScreenPos X >= 330
value = -3

;WALKING IN
;Set vel
[State 25473, WalkVel]
type = VelSet
trigger1 = Vel X = 0
trigger1 = Anim = 25471 || Anim = 25475
X = IfElse(Anim = 25471,1.5,2)

;BEHIND THE ROCK
[State 25473, Appear]
type = PosAdd
trigger1 = Anim = 25470 || Anim = 25474
trigger1 = ScreenPos Y > 160
Y = -1

;Aim
[State 25473, Aim]
type = ChangeAnim
trigger1 = Anim = 25471 || Anim = 25475
trigger1 = ScreenPos X = [30,290]
trigger1 = Random <= 100
trigger1 = GameTime%10 = 0
trigger2 = Anim = 25470 || Anim = 25474
trigger2 = ScreenPos Y <= 160
value = IfElse(Anim=25471||Anim=25475,Anim+1,IfElse(Anim=25470,25478,25479))

;Quote
[State 25473, Quote]
type = PlaySnd
trigger1 = Anim = 25472 || Anim = 25473 || Anim = 25478 || Anim = 25479
trigger1 = AnimElem = 1
value = 25421,floor(Random/300)

;Stop walking
[State 25473, StopWalk]
type = VelSet
trigger1 = Vel X != 0
trigger1 = Anim = 25472 || Anim = 25476
X = 0
Y = 0

;Place laser blast on the screen.
[State 25473, LaserBlast]
type = Explod
triggerall = RoundState = 2
triggerall = NumExplod(25478) = 0
triggerall = NumHelper(11100) = 0
triggerall = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = GameTime%30 = 0
trigger1 = Random >= 900
trigger1 = Anim = 25472 || Anim = 25476 || Anim = 25478 || Anim = 25479
anim = 25480
ID = 25478
postype = p1
bindtime = -1
removetime = -2
ownpal = 1
sprpriority = -2
scale = 0.5,0.5
pos = 0,IfElse(Anim=25472 || Anim=25478,-30,-50)

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
triggerall = NumExplod(25478) = 1
triggerall = NumHelper(11100) = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = NumExplod(25478) = 1
triggerall = NumHelper(11100) = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = NumHelper(11100) = 0
trigger1 = NumExplod(25478) = 1
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumExplod(25478) = 1
trigger1 = Time%7 = 0
v = IfElse(var(3)=0,3,4)
value = -1

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = NumExplod(25478) = 1
trigger1 = Time%7 = 0
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Disappear
[State 25473, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos X < -10
trigger3 = ScreenPos X > 330

;--------------------------------------------------------------------------
; Star Wars - Stormtrooper/Officer Die State
[Statedef 25474]
type = S
velset = 0,0
anim = IfElse(Anim < 25474||Anim=25478,25473,25477)
sprpriority = IfElse(ScreenPos Y <= 180,-4,-3)

;Explosion sound
[State 25474, Sound]
type = PlaySnd
trigger1 = Time = 0
value = 25420,0

;Groan?
[State 25474, DieSound]
type = PlaySnd
trigger1 = Time = 0
trigger1 = Random <= 200
value = 25420,floor(Random/400)+1

;Flash and vanish
[State 25474, Flash]
type = AssertSpecial
trigger1 = Time >= 100
trigger1 = Time%2 = 0
flag = invisible

;Disappear
[State 25474, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Time = 200
trigger3 = ScreenPos Y <= 180
trigger3 = Anim = 25473 || Anim = 25477
trigger3 = AnimElem = 5

;--------------------------------------------------------------------------
; Star Wars - Tie Fighter State
[Statedef 25475]
type = S
velset = 0,0
anim = 25481
sprpriority = -3

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 90
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 90
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
triggerall = Time = 90
trigger1 = NumHelper(11100) = 0
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Laser Sound
[State 25000, LaserSound]
type = PlaySnd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Time = 90
value = 25420,5

;Place laser blast on the screen.
[State 25473, LaserBlast]
type = Explod
triggerall = RoundState = 2
triggerall = NumExplod(25478) = 0
triggerall = NumHelper(11100) = 0
triggerall = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = Time = 90
anim = 25480
ID = 25478
postype = p1
bindtime = 1
removetime = -2
ownpal = 1
sprpriority = -2
scale = 0.5,0.5
pos = 0,0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Time = 90
v = IfElse(var(3)=0,3,4)
value = -1

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Time = 90
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Set initial pos
[State 25475,InitialPos]
type = PosAdd
trigger1 = Time = 0
X = floor(Random/24.9)+140-ScreenPos X
Y = floor(Random/9.99)+40-ScreenPos Y

;Can't hit me
[State 25475, NoHit]
type = NotHitBy
trigger1 = Time < 40
value = SCA

;Tie fighter sound
[State 25475, Sound]
type = PlaySnd
trigger1 = Time = 0
value = 25420,4
channel = 4
lowpriority = 4

;Scaling var
[State 25475, ScaleVar]
type = VarSet
trigger1 = 1
fv = 0
value = Time*0.008

;Grow in size
[State 25475, Grow]
type = AngleDraw
trigger1 = 1
scale = fvar(0),fvar(0)

;Go out of screen
[State 25475, OutofScreen]
type = PosAdd
trigger1 = Time >= 100
Y = -5

;Disappear
[State 25475, Vanish]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos Y < -80
trigger3 = parent,NumHelper(25477) = 1
trigger3 = helper(25477),Vel Y = -10 || (helper(25477),Vel Y = 0 && helper(25477),ScreenPos Y < 0)

;--------------------------------------------------------------------------
; Star Wars - Tie Fighter Die State
[Statedef 25476]
type = S
velset = 0,0
anim = 25302
sprpriority = -3

;Explosion
[State 25475, Explosion]
type = PlaySnd
trigger1 = Time = 0
value = 25000,9

;Resize explosion
[State 25475, Resize]
type = AngleDraw
trigger1 = 1
scale = 2*fvar(0),2*fvar(0)

;Disappear
[State 25475, Vanish]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = AnimTime = 0

;--------------------------------------------------------------------------
; Star Wars - Darth Vader State
[Statedef 25477]
type = S
sprpriority = -3

;Shrink
[State 25030, AngleDraw]
type = AngleDraw
trigger1 = 1
scale = 0.8,0.8

;Set HP
[State 25030, MaxHP]
type = VarSet
trigger1 = Time = 0
trigger1 = var(5) = 0
v = 5
value = 150

[State 25030,HP]
type = VarSet
trigger1 = Time = 0
trigger1 = var(6) = 0
v = 6
value = var(5)

;DISPLAY LIFE BAR
;Remove HP Explod for Modification
[State -2, RemoveHPBar]
type = RemoveExplod
triggerall = NumExplod(16001) > 0
triggerall = RoundState = 2
trigger1 = Time = 0
ID = 16001

[State -2, RemoveOuterHPBar]
type = RemoveExplod
triggerall = NumExplod(16000) > 0
triggerall = RoundState = 2
trigger1 = Time = 0
ID = 16000

[State -2,BossLifeBar]
type = Explod
triggerall = RoundState = 2
triggerall = NumExplod(16000) = 0
trigger1 = Time = 0
anim = 16000
ID = 16000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 105,215

[State -2,BossLifeFill]
type = Explod
triggerall = RoundState = 2
triggerall = NumExplod(16001) = 0
trigger1 = Time = 0
anim = 16001
ID = 16001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -1
pos = 105-(floor(100*var(6)/var(5)))+3,215
scale = floor(100*var(6)/var(5))-2,1

;Display Name
[State 25030, Name]
type = Explod
trigger1 = RoundState = 2
trigger1 = NumExplod(15022) = 0
anim = 15027
ID = 15022
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 105,205

;Set initial pos
[State 25477, InitialPos]
type = PosAdd
trigger1 = Anim != 25482
trigger1 = Time = 0
X = 160-ScreenPos X
Y = -40-ScreenPos Y

;Set initial vel
[State 25477, InitialVel]
type = VelSet
trigger1 = Anim != 25482
trigger1 = Time = 0
Y = 5

;Don't hit
[State 25477, NoHit]
type = NotHitBy
trigger1 = Vel Y = 5
trigger2 = var(7) > 0
value = SCA

;Tie fighter sound
[State 25477, Sound]
type = PlaySnd
trigger1 = Anim != 25482
trigger1 = Time = 0
value = 25420,4
channel = 4
lowpriority = 4

;Darth Vader sound
[State 25477, Sound]
type = PlaySnd
trigger1 = Anim != 25482
trigger1 = Time = 0
value = 25420,6

;Set animation
[State 25477, SetAnim]
type = ChangeAnim
trigger1 = Anim != 25482
trigger1 = Time = 0
value = 25482

;Stop moving.
[State 25477, VelStop]
type = VelSet
trigger1 = Vel Y = 5
trigger1 = ScreenPos Y = [115,125]
Y = 0

;Move around screen
[State 25477, RandomMove]
type = VelSet
triggerall = Anim = 25482
trigger1 = Vel Y = 0
trigger1 = Vel X = 0
trigger2 = GameTime%10 = 0
trigger2 = Random <= 200 && Vel Y != 5
trugger2 = ScreenPos X = [20,300]
trigger2 = ScreenPos Y = [20,220]
X = floor(Random/160)-3
Y = floor(Random/160)-3

;Reverse Direction
[State 25477, Reverse]
type = VelSet
triggerall = Vel Y != 5
trigger1 = ScreenPos X < 20 || ScreenPos X > 300
trigger2 = ScreenPos Y < 20 || ScreenPos Y > 220
X = IfElse(ScreenPos X < 20||ScreenPos X > 300,-Vel X,Vel X)
Y = IfElse(ScreenPos Y < 20||ScreenPos Y > 220,-Vel Y,Vel Y)

;I got hit.
;Flash
[State 25030, Flash]
type = AssertSpecial
trigger1 = Time%2 = 0
trigger1 = var(7) > 0
flag = invisible

;Decrease invincibility timer.
[State 25030, Timer]
type = VarAdd
trigger1 = var(7) > 0
v = 7
value = -1

;Disappear
[State 25475, Vanish]
type = DestroySelf
trigger1 = RoundState > 2

;--------------------------------------------------------------------------
; Star Wars - Darth Vader Die State
[Statedef 25478]
type = S
sprpriority = -3
velset = 0,-10

;Add to P1 Score
[State 5000, Score]
type = ParentVarAdd
triggerall = Time = 0
trigger1 = GetHitVar(damage)=1
trigger2 = GetHitvar(damage)=3 && enemy,TeamSide = 1
v = 1
value = 3000

;Add to P2 Score
[State 5000, P2Score]
type = ParentVarAdd
triggerall = Time = 0
trigger1 = GetHitVar(damage)=3 && enemy,TeamSide = 2
trigger2 = GetHitVar(damage)=2
v = 2
value = 3000

;Play finale music
[State 25478, Finale]
type = PlaySnd
trigger1 = Time = 0
value = 25422,4
channel = 5

;Set time to fire torpedo
[State 25478, TorpedoTime]
type = ParentVarSet
trigger1 = Time = 0
v = 28
value = 1

[State -2, RemoveHPBar]
type = RemoveExplod
trigger1 = NumExplod(16001) > 0
ID = 16001

[State -2, RemoveOuterHPBar]
type = RemoveExplod
trigger1 = NumExplod(16000) > 0
ID = 16000

[State -2, RemoveName]
type = RemoveExplod
trigger1 = NumExplod(15022) > 0
ID = 15022

;Scale
[State 25475, Scale]
type = AngleDraw
trigger1 = 1
scale = 0.8,0.8

;Vader
[State 25475, VaderVoice]
type = PlaySnd
trigger1 = Time = 0
value = 25422,3

;Cant be hit
[State 25475, NoHit]
type = NotHitBy
trigger1 = 1
value = SCA

;Porthole Top Half
[State -2, HoleTop]
type = Explod
trigger1 = NumExplod(60000) = 0
trigger1 = ScreenPos Y <= -50
trigger1 = Vel Y != 0
anim = 60017
ID = 60000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -5
pos = 0,0

;Porthole Bottom Half
[State -2, HoleBottom]
type = Explod
trigger1 = NumExplod(60001) = 0
trigger1 = ScreenPos Y <= -50
trigger1 = Vel Y != 0
anim = 60018
ID = 60001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -3
pos = 0,0

;Too late to fire torpedo
[State 25478, TorpedoTime]
type = ParentVarSet
trigger1 = Time = 170
trigger1 = parent,var(28) = 1
v = 28
value = 2

;Add Score
[State 25478, TorpedoSound]
type = ParentVarAdd
triggerall = parent,var(28) = 1
trigger1 = parent,Command = "a"
trigger1 = parent,ScreenPos X = [122,196]
trigger1 = parent,ScreenPos Y = [100,125]
trigger1 = parent,var(3) > 0
trigger2 = enemy,Command = "a"
trigger2 = enemy,ScreenPos X = [122,196]
trigger2 = enemy,ScreenPos Y = [100,125]
trigger2 = parent,var(21) = 0
trigger2 = parent,var(4) > 0
v = IfElse(parent,Command="a",1,2)
value = 3000

;Torpedo fired!
[State 25478, TorpedoSound]
type = PlaySnd
triggerall = parent,var(28) = 1
trigger1 = parent,Command = "a"
trigger1 = parent,ScreenPos X = [122,196]
trigger1 = parent,ScreenPos Y = [100,125]
trigger1 = parent,var(3) > 0
trigger2 = enemy,Command = "a"
trigger2 = enemy,ScreenPos X = [122,196]
trigger2 = enemy,ScreenPos Y = [100,125]
trigger2 = parent,var(21) = 0
trigger2 = parent,var(4) > 0
value = 25422,5

;Torpedo Helpers
[State 25478, LeftTorpedo]
type = Helper
triggerall = parent,var(28) = 1
trigger1 = parent,Command = "a"
trigger1 = parent,ScreenPos X = [122,196]
trigger1 = parent,ScreenPos Y = [100,125]
trigger1 = parent,var(3) > 0
trigger2 = enemy,Command = "a"
trigger2 = enemy,ScreenPos X = [122,196]
trigger2 = enemy,ScreenPos Y = [100,125]
trigger2 = parent,var(21) = 0
trigger2 = parent,var(4) > 0
helpertype = normal
name = "Torpedo"
ID = 25478
postype = left
ownpal = 1
stateno = 25479
pos = 0,0

[State 25478, RightTorpedo]
type = Helper
triggerall = parent,var(28) = 1
trigger1 = parent,Command = "a"
trigger1 = parent,ScreenPos X = [122,196]
trigger1 = parent,ScreenPos Y = [100,125]
trigger1 = parent,var(3) > 0
trigger2 = enemy,Command = "a"
trigger2 = enemy,ScreenPos X = [122,196]
trigger2 = enemy,ScreenPos Y = [100,125]
trigger2 = parent,var(21) = 0
trigger2 = parent,var(4) > 0
helpertype = normal
name = "Torpedo"
ID = 25479
postype = left
ownpal = 1
stateno = 25479
pos = 0,0

[State 25478, SetTorpedoVar]
type = ParentVarSet
triggerall = parent,var(28) = 1
trigger1 = parent,Command = "a"
trigger1 = parent,ScreenPos X = [122,196]
trigger1 = parent,ScreenPos Y = [100,125]
trigger1 = parent,var(3) > 0
trigger2 = enemy,Command = "a"
trigger2 = enemy,ScreenPos X = [122,196]
trigger2 = enemy,ScreenPos Y = [100,125]
trigger2 = parent,var(21) = 0
trigger2 = parent,var(4) > 0
v = 28
value = 3

;RemoveExplods
[State 25475, RemoveTop]
type = RemoveExplod
triggerall = NumExplod(60000) > 0
trigger1 = Time = 200
trigger2 = Time = 800
ID = 60000

[State 25475, RemoveBottom]
type = RemoveExplod
triggerall = NumExplod(60001) > 0
trigger1 = Time = 200
trigger2 = Time = 800
ID = 60001

;Star BG
[State -2, StarBG]
type = Explod
trigger1 = NumExplod(60000) = 0
trigger1 = Time = 200
anim = 60015
ID = 60000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -5
pos = 0,0

;Death Star
[State -2, StarBG]
type = Explod
trigger1 = NumExplod(60001) = 0
trigger1 = Time = 200
anim = 25483
ID = 60001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -4
pos = 160,120

;Explode!
[State 25475, ExplodeSound]
type = PlaySnd
trigger1 = Time = 250
trigger1 = parent,var(28) = 3
value = 25422,6

;Varset for explosion
[State 25475, ExplodeColor]
type = VarAdd
trigger1 = Time = [250,350]
trigger1 = parent,var(28) = 3
v = 2
value = IfElse(Time>=250&&Time<=265,16,IfElse(Time>=335&&Time<=350,-16,0))

;Remove Death Star
[State 25475, RemoveBottom]
type = RemoveExplod
triggerall = NumExplod(60001) > 0
trigger1 = Time = 300
trigger1 = parent,var(28) = 3
ID = 60001

;Make the screen flash
[State 11100, Flash]
type = AllPalFX
trigger1 = Time = [250,350]
trigger1 = parent,var(28) = 3
time = 1
add = var(2),var(2),var(2)
mul = 256,256,256

;X wing sound
[State 25475, XWingSound]
type = PlaySnd
trigger1 = Time = 500
value = 25422,7

;X wing explod
[State 25475, XWing]
type = Explod
trigger1 = NumExplod(60002) = 0
trigger1 = Time = 500
anim = 25484
ID = 60002
postype = left
bindtime = 1
removetime = 150
ownpal = 1
sprpriority = -3
pos = 320,0
scale = 0.5,0.5
vel = -5,3

;Stop moving
[State 25475, NoMove]
type = VelSet
trigger1 = ScreenPos Y <= -50
Y = 0

;Trigger end of round
[State 25475, EndRound]
type = ParentVarSet
trigger1 = Time >= 800
v = 0
value = 7199

;Disappear
[State 25475, Vanish]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Time >= 800

;--------------------------------------------------------------------------
; Star Wars - Torpedo State
[Statedef 25479]
type = S
sprpriority = -2
velset = 0,0
anim = 25485

;Set initial pos
[State 25475, InitialPos]
type = PosAdd
trigger1 = Time = 0
X = IfElse(IsHelper(25478),100-ScreenPos X,220-ScreenPos X)
Y = 240-ScreenPos Y

;Turn right missle around
[State 25475, Turn]
type = Turn
trigger1 = Time = 0
trigger1 = IsHelper(25479)

;Set velocity
[State 25475, Velocity]
type = VelSet
trigger1 = Time = 0
X = 2
Y = -7

;Change sprpriority
[State 25475, SprPriority]
type = SprPriority
trigger1 = Anim = 25485
trigger1 = ScreenPos Y = [100,110]
value = -4

;Change Animation
[State 25475, ChangeAnim]
type = ChangeAnim
trigger1 = Anim = 25485
trigger1 = ScreenPos Y = [100,110]
value = 25486

;Reverse Vel
[State 25475, VelReverse]
type = VelSet
trigger1 = Anim = 25486
trigger1 = Vel Y < 0
Y = -Vel Y

;Disappear
[State 25475, Vanish]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos Y >= 320

;--------------------------------------------------------------------------
; Star Wars - Vader's Laser
[Statedef 25480]
type = S
anim = 25487
sprpriority = -2

;Laser sound
[State 25480, Laser]
type = PlaySnd
trigger1 = Time = 0
value = 25420,5

;Vader voice
[State 25480, Vader]
type = PlaySnd
trigger1 = Time = 0
trigger1 = Random <= 100
value = 25422,8

;Explosion sound
[State 25480, Explosion]
type = PlaySnd
trigger1 = Time = 80
value = 25420,0

;Start small, then grow large
[State 25031, Scale]
type = AngleDraw
trigger1 = Time < 80
scale = Time*0.04,Time*0.04

;Set which player to kill
[State 25000, PlayerSelect]
type = VarSet
triggerall = RoundState = 2
trigger1 = Time = 0
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
v = 3
value = IfElse(Random<=499,0,1)

;Hit other player if select one is dead.
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = Time = 0
trigger1 = var(3) = 0 && parent,var(3) <= 0
trigger2 = var(3) = 1 && parent,var(4) <= 0
v = 3
value = IfElse((var(3) = 0 && parent,var(3) <= 0),1,0)

;Hit me if other player is AI
[State 25000, ChangePlayer]
type = VarSet
triggerall = RoundState = 2
triggerall = parent,NumHelper(90000) > 0 || (enemy,Name = "XTSM" && var(21) = 1)
trigger1 = Time = 0
trigger1 = var(3) = 1 && helper(90000),var(21) = 1
v = 3
value = 0

;Take Life Away
[State 25000, BulletHole]
type = ParentVarAdd
triggerall = RoundState = 2
trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Time = 80
v = IfElse(var(3)=0,3,4)
value = -1

;BulletHole
[State -2, BulletHole]
type = Helper
triggerall = RoundState = 2
;trigger1 = parent,var(3) > 0 || parent,var(4) > 0
trigger1 = NumHelper(11100) = 0
trigger1 = Time = 80
helpertype = normal
name = "Bullet Hole"
ID = 11100
postype = p1
stateno = 11100

;Destroy Self
[State 25031, Destroy]
type = DestroySelf
trigger1 = Time = 80
trigger2 = RoundState > 2
trigger3 = helper(25477),var(6) <= 0

;--------------------------------------------------------------------------
; Sonic - Which character jumps out?
[Statedef 25481]
type = S

;Set char variable.
[State 25481, SelectChar]
type = VarSet
trigger1 = Time = 0
v = 2
value = IfElse(IsHelper(25481)||IsHelper(25484),0,IfElse(IsHelper(25482)||IsHelper(25485),1,IfElse(IsHelper(25483)||IsHelper(25486),2,0)))

;Go to correct state
[State 25481, GoToState]
type = ChangeState
trigger1 = Time = 0
value = 25482

;--------------------------------------------------------------------------
; Sonic - Sonic State (Jump In)
[Statedef 25482]
type = S
movetype = A
sprpriority = -3
velset = 0,-12
anim = 25488+(6*var(2))

;Set initial pos var
[State 25481, PosVar]
type = VarSet
trigger1 = Time = 0
trigger1 = var(1) = 0
v = 1
value = floor(parent,ScreenPos Y)

;Player 2 Sonic
[State 25481, PalFX]
type = PalFX
trigger1 = parent,TeamSide = 2
trigger2 = IsHelper(25484) || IsHelper(25485) || IsHelper(25486)
time = 1
add = 0,180,180
mul = 0,140,140

;Set Gravity Var
[State 25481, GravityVar]
type = VarSet
triggerall = var(0) = 0
trigger1 = floor(var(1)-ScreenPos Y) >= -40
v = 0
value = 1

;Gravity
[State 25481, Gravity]
type = VelAdd
trigger1 = var(0) = 1
Y = 1

;Gradually get smaller
[State 25481, AngleDraw]
type = AngleDraw
trigger1 = Time < 30
scale = 2-(Time*0.03),2-(Time*0.03)

;Change to turn around
[State 25481, Turn]
type = ChangeState
trigger1 = Vel Y > 0
trigger1 = ScreenPos Y >= 205
value = 25483

;Damage
[State 25481, Attack]
type = HitDef
trigger1 = var(0) = 1
damage = IfElse(TeamSide=1&&(parent,ID=root,ID),1,IfElse(parent,IsHelper(90000),2,3)),IfElse(TeamSide=1&&(parent,ID=root,ID),1,IfElse(parent,IsHelper(90000),2,3))
attr = S,NA
sparkno = -1
affectteam = B

;Disappear
[State 25031, Destroy]
type = DestroySelf
trigger1 = ScreenPos Y > 600
trigger2 = RoundState > 2

;--------------------------------------------------------------------------
; Sonic - Sonic State (Turn Around and Jump Back)
[Statedef 25483]
type = S
sprpriority = -3
velset = 0,0
movetype = A

;Set correct anim
[State 25483, SetAnim]
type = ChangeAnim
trigger1 = Time = 0
trigger1 = Anim != 25489+(6*var(2))
value = 25489+(6*var(2))

;Can't hurt me.
[State 25481, NoHit]
type = NotHitBy
trigger1 = (IsHelper(25481) || IsHelper(25482) || IsHelper(25483)) && root,var(33) > 0
trigger2 = (IsHelper(25484) || IsHelper(25485) || IsHelper(25486)) && root,var(34) > 0
trigger3 = PrevStateNo = 25484
value = SCA 

;Invincibility
[State 25481, Attack]
type = HitDef
trigger1 = (IsHelper(25481) || IsHelper(25482) || IsHelper(25483)) && root,var(33) > 0
trigger2 = (IsHelper(25484) || IsHelper(25485) || IsHelper(25486)) && root,var(34) > 0
damage = IfElse(TeamSide=1&&(parent,ID=root,ID),1,IfElse(parent,IsHelper(90000),2,3)),IfElse(TeamSide=1&&(parent,ID=root,ID),1,IfElse(parent,IsHelper(90000),2,3))
attr = S,N
sparkno = -1
affectteam = B

;Player 2 Sonic
[State 25481, PalFX]
type = PalFX
trigger1 = parent,TeamSide = 2
trigger2 = IsHelper(25484) || IsHelper(25485) || IsHelper(25486)
time = 1
add = 0,180,180
mul = 0,140,140

;Set initial pos
[State 25482, InitialPos]
type = PosAdd
trigger1 = Time = 0
Y = 205-ScreenPos Y

;Jump back
[State 25482, SetVel]
type = VelSet
trigger1 = Anim = 25489+(6*var(2))
trigger1 = AnimTime = 0
Y = -2

[State 25482, JumpSound]
type = PlaySnd
trigger1 = Anim = 25489+(6*var(2))
trigger1 = AnimTime = 0
value = 0,12

[State 25482, JumpAnim]
type = ChangeAnim
trigger1 = Anim = 25489+(6*var(2))
trigger1 = AnimTime = 0
value = 25490+(6*var(2))

[State 25482, GrowVar]
type = VarAdd
trigger1 = Anim = 25490+(6*var(2))
fv = 0
value = 0.05

[State 25482, Scale]
type = AngleDraw
trigger1 = Anim = 25490+(6*var(2))
scale = 1+fvar(0),1+fvar(0)

[State 25482, Destroy]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = fvar(0) >= 1

;--------------------------------------------------------------------------
; Sonic - Sonic State (Hurt)
[Statedef 25484]
type = S
sprpriority = -3
velset = 0,-5

;Player 2 Sonic
[State 25481, PalFX]
type = PalFX
trigger1 = parent,TeamSide = 2
trigger2 = IsHelper(25484) || IsHelper(25485) || IsHelper(25486)
time = 1
add = 0,180,180
mul = 0,140,140

;Cant hit me
[State 25484, CantHitMe]
type = NotHitBy
trigger1 = 1
value = SCA

;Set Mod Var
[State 25461, WhichPlayer?]
type = VarSet
trigger1 = Time = 0
trigger1 = (IsHelper(25484) || IsHelper(25485) || IsHelper(25486))
v = 3
value = 1

;Set the correct animation.
[State 25461, LoseRings]
type = ChangeAnim
triggerall = Time = 0
trigger1 = var(3) = 0 && ((root,var(15) > 0 && root,var(33) <= 0) || root,var(31) = 1)
trigger2 = var(3) = 1 && ((root,var(16) > 0 && root,var(34) <= 0) || root,var(32) = 1)
value = 25491+(6*var(2))

[State 25461, Die]
type = ChangeAnim
triggerall = Time = 0
trigger1 = var(3) = 0 && root,var(15) <= 0 && root,var(33) <= 0
trigger2 = var(3) = 1 && root,var(16) <= 0 && root,var(34) <= 0
value = 25492+(6*var(2))

;Sound effects
[State 25461, Sound]
type = PlaySnd
trigger1 = Time = 0
trigger1 = (var(3)=0&&root,var(33)<=0) || (var(3)=1&&root,var(34)<=0)
value = 25430,IfElse(((var(3)=0&&root,var(15)>0&&root,var(31)=0)||(var(3)=1&&root,var(16)>0&&root,var(32)=0)),5,7)

[State 25461, LoseLives]
type = ParentVarSet
triggerall = Time = 0
trigger1 = var(3) = 0 && root,var(15) <= 0 && root,var(33) <= 0
trigger2 = var(3) = 1 && root,var(16) <= 0 && root,var(34) <= 0
v = IfElse(var(3)=0,3,4)
value = IfElse(var(3)=0,root,var(3)-1,root,var(4)-1)

[State 25461, LoseRings]
type = ParentVarAdd;ParentVarSet
triggerall = Time = 0
trigger1 = var(3) = 0 && root,var(15) > 0 && root,var(31) = 0 && root,var(33) <= 0
trigger2 = var(3) = 1 && root,var(16) > 0 && root,var(32) = 0 && root,var(34) <= 0
v = IfElse(var(3)=0,15,16)
value = -15;IfElse(var(3)=0,IfElse(root,var(15)-15>0,root,var(15)-15,0),IfElse(root,var(16)-15>0,root,var(16)-15,0))

[State 25461, LoseShield]
type = ParentVarSet
triggerall = Time = 0
trigger1 = var(3) = 0 && root,var(31) = 1 && root,var(33) <= 0
trigger2 = var(3) = 1 && root,var(32) = 1 && root,var(34) <= 0
v = IfElse(var(3)=0,31,32)
value = IfElse(parent,IsHelper,-1,0)

;Gravity
[State 25461, Gravity]
type = VelAdd
trigger1 = 1
Y = 0.2

;Move backwards (Still have Rings)
[State 25461, Back]
type = PosAdd
trigger1 = Anim = 25491+(6*var(2))
trigger1 = ScreenPos X > 10
trigger1 = ScreenPos X < 310
X = -3

;Change Animation (Still Have Rings)
[State 25461, AnimBack]
type = ChangeAnim
trigger1 = Anim = 25491+(6*var(2))
trigger1 = ScreenPos Y >= 205
trigger1 = Vel Y > 0
value = 25489+(6*var(2))
elem = 7

;Go back to jump state.
[State 25461, BackToJump]
type = ChangeState
trigger1 = Anim = 25489+(6*var(2))
value = 25483

;Disappear
[State 25484, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos Y >= 260

;--------------------------------------------------------------------------
; Sonic - Ring State
[Statedef 25485]
type = S
sprpriority = -3
anim = 25506

;Set initial Y to 0.
[State 25461, ZeroY]
type = PosAdd
trigger1 = Time = 0
Y = -ScreenPos Y

;Now Get Y between 30 and 130
[State 25461, RandomY]
type = PosAdd
trigger1 = Time = 0
Y = floor(Random/9.9)+30

;Cannot be hit for the first few seconds.
[State 25461, NoHit]
type = NotHitBy
trigger1 = Time < 50
value = SCA

;Flash in and out (appear)
[State 25461, Flash]
type = AssertSpecial
triggerall = Time%2 = 0
trigger1 = Time < 50
trigger2 = Time > 500
flag = invisible

;Disappear
[State 25461, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Time >= 550

;--------------------------------------------------------------------------
; Sonic - Ring State (Vanish)
[Statedef 25486]
type = S
sprpriority = -3
anim = 25507

;Ring Sound
[State 25461, RingSound]
type = PlaySnd
trigger1 = Time = 0
value = 25430,0

;Disappear
[State 25461, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = AnimTime = 0

;--------------------------------------------------------------------------
; Sonic - Select Item State
[Statedef 25487]
type = S
sprpriority = -5

;NoHit
[State 25487, NoHit]
type = NotHitBy
trigger1 = 1
value = SCA

;Set initial Y pos
[State 25487, InitialY]
type = PosAdd
trigger1 = Time = 0
Y = 240-ScreenPos Y

;Play item sound
[State 25487, ItemSound]
type = PlaySnd
trigger1 = Time = 0
value = 25430,2

;Set item timer
[State 25487, ItemTimer]
type = VarSet
trigger1 = Time = 0
v = 1
value = 300

;Which item to choose?
[State 25487, ItemChoose]
type = VarSet
trigger1 = Time = 0
v = 0
value = floor(Random/132)

;Go to item state
[State 25487, GoToState]
type = ChangeState
trigger1 = Time = 0
value = 25488

;--------------------------------------------------------------------------
; Sonic - Item State
[Statedef 25488]
type = S
sprpriority = -5

;Cant hit me
[State 25487, NoHit]
type = NotHitBy
trigger1 = ScreenPos Y > 205
value = SCA

;Can't be hit by enemies.
[State 25487, NoEnemyHit]
type = NotHitBy
trigger1 = 1
value = , SA

;Set the initial animation.
[State 25487, InitialAnim]
type = ChangeAnim
trigger1 = Anim != 25508+var(0)
value = 25508+var(0)

;Add Pos to correct position
[State 25487, PosAdd]
type = PosAdd
trigger1 = ScreenPos Y > 205
Y = -2

;Decrease disappear timer
[State 25487, TimerDecrease]
type = VarAdd
trigger1 = var(1) > 0
v = 1
value = -1

;Flash in and out (disappear)
[State 25487, Flash]
type = AssertSpecial
trigger1 = var(1) <= 50
trigger1 = Time%2 = 0
flag = invisible

;Disappear
[State 25461, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = var(1) = 0

;--------------------------------------------------------------------------
; Sonic - Item Destroyed State
[Statedef 25489]
type = S
sprpriority = -5
anim = 25522

;Give to P2, else give to P1
[State 25489, PlayerItem]
type = VarSet
trigger1 = Time = 0
trigger1 = GetHitVar(damage)=3 && enemy,TeamSide = 2
trigger2 = GetHitVar(damage)=2
v = 2
value = 1

[State 25489, ExplodeSound]
type = PlaySnd
trigger1 = Time = 0
value = 25430,3

;Explosion explod
[State 25489, Explosion]
type = Explod
trigger1 = Time = 0
anim = 25523
postype = p1
bindtime = -1
removetime = -2
ownpal = 1
sprpriority = -2
pos = 0,-10

;Item explod
[State 25489, Item]
type = Explod
trigger1 = Time = 0
anim = 25515+var(0)
postype = p1
bindtime = 1
removetime = 30
ownpal = 1
sprpriority = -2
pos = 0,0
vel = 0,-3
accel = 0,0.1

;;;;;;;;;;;;;;;;
;; ITEM BONUS ;;
;;;;;;;;;;;;;;;;

;Play Sound.  Take care of simple cases.
[State 25489, Sound]
type = PlaySnd
trigger1 = Time = 30
trigger1 = var(0) = 0 || var(0) = 1 || var(0) = 3
value = 25430,IfElse(var(0)=0,0,IfElse(var(0)=1,4,1))

;RING
[State 25461, AddRings]
type = ParentVarAdd
trigger1 = var(0) = 0
trigger1 = Time = 30
v = IfElse(var(2)=0,15,16)
value = 10

;EXTRA LIVES
[State 25461, AddLives]
type = ParentVarAdd
trigger1 = var(0) = 3
trigger1 = Time = 30
v = IfElse(var(2)=0,3,4)
value = 1

;SHIELD
[State 25461, AddShield]
type = ParentVarSet
trigger1 = var(0) = 1
trigger1 = Time = 30
v = IfElse(var(2)=0,31,32)
value = 1

;INVINCIBILITY
[State 25461, AddLives]
type = ParentVarSet
trigger1 = var(0) = 2
trigger1 = Time = 30
v = IfElse(var(2)=0,33,34)
value = 1200

;ROBOTNIK
[State 25461, Sound]
type = PlaySnd
trigger1 = var(0) = 6
trigger1 = Time = 30
trigger1 = (var(2)=0&&root,var(33)<=0) || (var(2)=1&&root,var(34)<=0)
value = 25430,IfElse(((var(2)=0&&root,var(15)>0&&root,var(31)=0)||(var(2)=1&&root,var(16)>0&&root,var(32)=0)),5,7)

[State 25461, LoseLives]
type = ParentVarAdd
triggerall = var(0) = 6
triggerall = Time = 30
trigger1 = var(2) = 0 && root,var(15) <= 0 && root,var(33) <= 0
trigger2 = var(2) = 1 && root,var(16) <= 0 && root,var(34) <= 0
v = IfElse(var(2)=0,3,4)
value = -1

[State 25461, LoseRings]
type = ParentVarSet
triggerall = var(0) = 6
triggerall = Time = 30
trigger1 = var(2) = 0 && root,var(15) > 0 && root,var(31) = 0 && root,var(33) <= 0
trigger2 = var(2) = 1 && root,var(16) > 0 && root,var(32) = 0 && root,var(34) <= 0
v = IfElse(var(2)=0,15,16)
value = IfElse(var(2)=0,ceil(root,var(15)/2),ceil(root,var(16)/2))

[State 25461, LoseShield]
type = ParentVarSet
triggerall = var(0) = 6
triggerall = Time = 30
trigger1 = var(2) = 0 && root,var(31) = 1 && root,var(33) <= 0
trigger2 = var(2) = 1 && root,var(32) = 1 && root,var(34) <= 0
v = IfElse(var(2)=0,31,32)
value = 0

;Tails-Knuckles
[State 25461, RingSound]
type = PlaySnd
triggerall = var(0) = 4 || var(0) = 5
triggerall = Time = 30
trigger1 = var(2) = 0 && var(0) = 4 && root,var(29) = 0
trigger2 = var(2) = 1 && var(0) = 4 && root,var(30) = 0
trigger3 = var(2) = 0 && var(0) = 5 && root,var(29) = 1
trigger4 = var(2) = 1 && var(0) = 5 && root,var(30) = 1
value = 25430,0

[State 25461, LifeSound]
type = PlaySnd
triggerall = var(0) = 4 || var(0) = 5
triggerall = Time = 30
trigger1 = var(2) = 0 && var(0) = 4 && root,var(29) >= 1
trigger2 = var(2) = 1 && var(0) = 4 && root,var(30) >= 1
trigger3 = var(2) = 0 && var(0) = 5 && root,var(29) >= 2
trigger4 = var(2) = 1 && var(0) = 5 && root,var(30) >= 2
value = 25430,1

;Add Extra Life
[State 25451, AddLife]
type = ParentVarAdd
triggerall = var(0) = 4 || var(0) = 5
triggerall = Time = 30
trigger1 = var(2) = 0 && var(0) = 4 && root,var(29) >= 1
trigger2 = var(2) = 0 && var(0) = 5 && root,var(29) >= 2
trigger3 = var(2) = 1 && var(0) = 4 && root,var(30) >= 1
trigger4 = var(2) = 1 && var(0) = 5 && root,var(30) >= 2
v = IfElse(var(2)=0,3,4)
value = 1

;Add Tails/Knuckles
[State 25451, AddHelp]
type = ParentVarAdd
triggerall = var(0) = 4 || var(0) = 5
triggerall = Time = 30
trigger1 = var(2) = 0 && var(0) = 4 && root,var(29) = 0
trigger2 = var(2) = 0 && var(0) = 5 && root,var(29) = 1
trigger3 = var(2) = 1 && var(0) = 4 && root,var(30) = 0
trigger4 = var(2) = 1 && var(0) = 5 && root,var(30) = 1
v = IfElse(var(2)=0,29,30)
value = 1

;Disappear
[State 25461, Disappear]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = Time = 150


;--------------------------------------------------------------------------
; Sonic - Enemy Select
[Statedef 25490]
type = S

;Cant hit me
[State 25490, NoHit]
type = NotHitBy
trigger1 = 1
value = SCA

;Select which enemy.
[State 25490, EnemySelect]
type = VarSet
trigger1 = Time = 0
value = 0 ;For now.

;Go to correct state
[State 25492, EnemyState]
type = ChangeState
trigger1 = Time = 0
value = 25492+var(0)

;--------------------------------------------------------------------------
; Sonic - Enemy Die
[Statedef 25491]
type = S
velset = 0,-3

[State 25489, ExplodeSound]
type = PlaySnd
trigger1 = Time = 0
value = 25430,3

;Explosion explod
[State 25489, Explosion]
type = Explod
trigger1 = Time = 0
anim = 25523
postype = p1
bindtime = 1
removetime = -2
ownpal = 1
sprpriority = -2
pos = 0,0

;Set a displacement.
[State 25491, Displace]
type = PosAdd
trigger1 = Time = 0
Y = -5

;Set initial anim
[State 25491, AnimSet]
type = ChangeAnim
trigger1 = Time = 0
value = 25526+floor(Random/105)

;Gravity
[State 25491, Gravity]
type = VelAdd
trigger1 = 1
Y = 0.2

;Change Animation
[State 25491, Gravity]
type = ChangeAnim
trigger1 = Anim = [25526,25535]
trigger1 = ScreenPos Y >= 205
value = Anim+10

;Stop gravity.  Set moving vel.
[State 25491, Gravity]
type = VelSet
trigger1 = Vel Y > 0
trigger1 = Anim = [25536,25545]
trigger1 = ScreenPos Y >= 205
X = 2
Y = IfElse(Anim=25537||Anim=25539||Anim=25540,-6,IfElse(Anim=25545,-1,IfElse(Anim=25536,-3,-2)))

;Disappear
[State 25491, Destroy]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos X > 330
trigger3 = ScreenPos X < -10

;--------------------------------------------------------------------------
; Sonic - Crabmeat State
[Statedef 25492]
type = S
movetype = A
velset = 0,0

;Can't be hit by other enemies.
[State 25492, NoEnemyHit]
type = NotHitBy
trigger1 = 1
value = , SA

;Damage
[State 25492, Attack]
type = HitDef
trigger1 = 1
damage = 5,5
attr = S,SA
sparkno = -1
affectteam = B

;Set initial position
[State 25492, InitialPos]
type = PosAdd
trigger1 = Time = 0
trigger1 = PrevStateNo != 5000
X = IfElse(Random<=500,-ScreenPos X,320-ScreenPos X)
Y = 205-ScreenPos Y

;Turn around?
[State 25492, Turn?]
type = Turn
trigger1 = Time = 0
trigger1 = Anim != [25546,25547]
trigger1 = ScreenPos X = 320
trigger1 = PrevStateNo != 5000

;Set initial animation.
[State 25492, Anim]
type = ChangeAnim
trigger1 = Anim != [25546,25547]
value = 25546

;Set velocity
[State 25492, SetVel]
type = VelSet
trigger1 = 1
X = IfElse(Anim=25546,1,0)

;Disappear
[State 25492, Destroy]
type = DestroySelf
trigger1 = RoundState > 2
trigger2 = ScreenPos X < -10 && facing = -1
trigger3 = ScreenPos X > 330 && facing = 1

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

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

;Match Fixer
[State -2, MatchEdit]
type = VarSet
trigger1 = MatchNo+var(24) >= 5
v = 24
value = -MatchNo+1

;Round Fixer
[State -2, RoundEdit]
type = VarSet
trigger1 = RoundNo+var(25) >= 3
v = 25
value = -RoundNo+1

;Fix Score < 0
[State -2, ScoreFix1]
type = VarSet
trigger1 = var(1) < 0
v = 1
value = 0

[State -2, ScoreFix2]
type = VarSet
trigger1 = var(2) < 0
v = 2
value = 0

;Fix Lives > 99
[State -2, LifeFix1]
type = VarSet
trigger1 = var(3) > 99
v = 3
value = 99

[State -2, LifeFix2]
type = VarSet
trigger1 = var(4) > 99
v = 4
value = 99

;Fix Lives < 0
[State -2, LifeFix1]
type = VarSet
trigger1 = var(3) < 0
v = 3
value = 0

[State -2, LifeFix2]
type = VarSet
trigger1 = var(4) < 0
v = 4
value = 0

;Fix Score > 9999999
[State -2, ScoreFix3]
type = VarSet
trigger1 = var(1) > 9999999
v = 1
value = 9999999

[State -2, ScoreFix4]
type = VarSet
trigger1 = var(2) > 9999999
v = 2
value = 9999999

;Fix Rings > 999
[State -2, RingFix1]
type = VarSet
trigger1 = var(15) > 999
v = 15
value = 999

[State -2, RingFix2]
type = VarSet
trigger1 = var(16) > 999
v = 16
value = 999

;Fix Rings < 0
[State -2, RingFix1]
type = VarSet
trigger1 = !IsHelper
trigger1 = var(15) < 0
v = 15
value = 0

[State -2, RingFix2]
type = VarSet
trigger1 = !IsHelper
trigger1 = var(16) < 0
v = 16
value = 0

;Do not hurt crosshair
[State -2, NoHit]
type = NotHitBy
trigger1 = 1
value = SCA

;Unset backgrounds, autoturning
[State -2, PreSet1]
type = AssertSpecial
trigger1 = 1
flag = noBG
flag2 = noFG
flag3 = noautoturn

;No Guard
[State -2, PreSet2]
type = AssertSpecial
trigger1 = 1
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard

;No Shadow, No Timer
[State -2, PreSet3]
type = AssertSpecial
trigger1 = 1
flag = noshadow
flag2 = timerfreeze

;No Lifebars, No Music, No KO slow
[State -2, PreSet4]
type = AssertSpecial
trigger1 = 1
flag = nobardisplay
flag2 = nomusic
flag3 = nokoslow

;No Push
[State -2, NoPush]
type = PlayerPush
trigger1 = 1
value = 0

;Stay in Screen
[State -2, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 1

[State -2, FixLowY]
type = PosSet
triggerall = MoveType != A
triggerall = RoundState = 2
trigger1 = Pos Y > 20
Y = 20

[State -2, FixHighY]
type = PosSet
triggerall = MoveType != A
triggerall = RoundState = 2
trigger1 = Pos Y < -210
;trigger1 = !(ScreenPos Y = [20,239])
Y = -210

;Force P2 into crosshair state
[State -2, ForceTarget]
type = Projectile
trigger1 = RoundState < 3
trigger1 = !IsHelper
trigger1 = enemy,Name != "XTSM"
trigger1 = enemy,StateNo != 90000
attr = S,N
sparkno = -1
p2stateno = 90000
projanim = 30000
projremovetime = 1
affectteam = E

;Enemy crosshair
[State -2, EnemyCrosshair]
type = Helper
trigger1 = !IsHelper
trigger1 = NumHelper(90000) = 0
trigger1 = enemy,Name != "XTSM"
trigger1 = enemy,StateNo = 90000
helpertype = player
name = "Helper Crosshair"
ID = 90000
postype = p2
stateno = 90005

;;;;;;;;;;;;;;;;;;;;;
;; LOAD BACKGROUND ;;
;;;;;;;;;;;;;;;;;;;;;
;---------------------------------------------------------------------------
;LETHAL ENFORCERS STAGE

;Saloon 1 BG
[State -2, Saloon1A]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60000) = 0
anim = 60000
ID = 60000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -5
pos = 0,0

;Saloon1 Right Side
[State -2, Saloon1B]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60002) = 0
anim = 60002
ID = 60002
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -3
pos = 158,115

;Saloon1 Left Side
[State -2, Saloon1C]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60001) = 0
anim = 60001
ID = 60001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -3
pos = 0,115

;Saloon 2 BG
[State -2, Saloon2]
type = Explod
triggerall = MatchNo+var(24) = 1
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60000) = 0
anim = 60003
ID = 60000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -5
pos = 0,0

;Start Stage Music
[State -2, StartMusic]
type = PlaySnd
triggerall = MatchNo+var(24) = 1
triggerall = !IsHelper
triggerall = var(0) = 1
triggerall = id > partner, id
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
value = IfElse(RoundNo+var(25)=1,10000,10001),0
volume = 1
channel = 5
loop = 1
lowpriority = 5
;---------------------------------------------------------------------------
;DUCK HUNT

;Sky BG
[State -2, SkyBG]
type = Explod
triggerall = MatchNo+var(24) = 2
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60000) = 0
anim = 60004
ID = 60000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -5
pos = 0,0

;Grass BG
[State -2, FieldBG]
type = Explod
triggerall = MatchNo+var(24) = 2
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60001) = 0
anim = 60005
ID = 60001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -3
pos = 0,0

;Field BG
[State -2, SkyBG]
type = Explod
triggerall = MatchNo+var(24) = 2
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60000) = 0
anim = 60006
ID = 60000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -5
pos = 0,0

;Start Stage Music
[State -2, StartMusic]
type = PlaySnd
triggerall = MatchNo+var(24) = 2
triggerall = !IsHelper
triggerall = var(0) = 1
triggerall = id > partner, id
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
value = IfElse(RoundNo+var(25)=1,10002,10003),0
volume = 1
channel = 5
lowpriority = 5

;--------------------------------------------------------------------------
;MARIO

;Main BG
[State -2, SkyBG]
type = Explod
triggerall = MatchNo+var(24) = 3
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60000) = 0
anim = 60007
ID = 60000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -5
pos = 0,0

;Pipes
[State -2, FieldBG]
type = Explod
triggerall = MatchNo+var(24) = 3
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60001) = 0
anim = 60008
ID = 60001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -3
pos = 0,0

;Castle BG
[State -2, CastleBG]
type = Explod
triggerall = MatchNo+var(24) = 3
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60000) = 0
anim = 60009
ID = 60000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -5
pos = 0,0

;Lava BG
[State -2, LavaBG]
type = Explod
triggerall = MatchNo+var(24) = 3
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60001) = 0
anim = 60010
ID = 60001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -3
pos = 0,0

[State -3, CastleWindows]
type = Helper
triggerall = MatchNo+var(24) = 3
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = NumHelper(60002) = 0
triggerall = RoundState = 2
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
helpertype = normal
name = "Stage 3-2 Windows"
ID = 60002
postype = left
stateno = 60011

;Start Stage Music
[State -2, StartMusic]
type = PlaySnd
triggerall = MatchNo+var(24) = 3
triggerall = !IsHelper
triggerall = var(0) = 1
triggerall = id > partner, id
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
value = IfElse(RoundNo+var(25)=1,10004,10005),0
volume = 1
channel = IfElse(RoundNo+var(25)=1,5,6)
lowpriority = 5
loop = IfElse(RoundNo+var(25)=1,1,0)

;Bowser Loop Music
[State -2, StartMusic]
type = PlaySnd
triggerall = MatchNo+var(24) = 3
triggerall = RoundNo+var(25) = 2
triggerall = NumHelper(20100) > 0
triggerall = helper(20100),var(0) = 200
triggerall = !IsHelper
triggerall = id > partner, id
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
value = 10005,1
volume = 1
channel = 5
lowpriority = 5
loop = 1

;--------------------------------------------------------------------------
;STAR WARS

;Yavin Swamp BG
[State -2, Yavin1BG]
type = Explod
triggerall = MatchNo+var(24) = 4
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60000) = 0
anim = 60013
ID = 60000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -5
pos = 0,0

;Rocks and Trees
[State -2, YavinTreeRockBG]
type = Explod
triggerall = MatchNo+var(24) = 4
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60001) = 0
anim = 60014
ID = 60001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -3
pos = 0,0

;Star BG
[State -2, StarBG]
type = Explod
triggerall = MatchNo+var(24) = 4
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60000) = 0
trigger1 = NumHelper(25477) = 0
anim = 60015
ID = 60000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -5
pos = 0,0

;Trench BG
[State -2, TrenchBG]
type = Explod
triggerall = MatchNo+var(24) = 4
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = var(28) = 0
trigger1 = RoundState = 2
trigger1 = NumExplod(60001) = 0
trigger1 = NumHelper(25477) = 0
anim = 60016
ID = 60001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -4
pos = 0,0

;Start Stage Music
[State -2, StartMusic]
type = PlaySnd
triggerall = MatchNo+var(24) = 4
triggerall = !IsHelper
triggerall = var(0) = 1
triggerall = id > partner, id
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
value = IfElse(RoundNo+var(25)=1,10006,10007),0
volume = 0
channel = 5
loop = 1
lowpriority = IfElse(RoundNo+var(25)=1,5,0)

;--------------------------------------------------------------------------
;SONIC

;5-1 Sky BG
[State -2, SkyBG]
type = Explod
triggerall = MatchNo+var(24) = 5
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60000) = 0
anim = 60019
ID = 60000
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -5
pos = 0,0

;5-2 Grass BG
[State -2, FieldBG]
type = Explod
triggerall = MatchNo+var(24) = 5
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
trigger1 = RoundState = 2
trigger1 = NumExplod(60001) = 0
anim = 60020
ID = 60001
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -4
pos = 0,0

;Start Stage Music
[State -2, StartMusic]
type = PlaySnd
triggerall = MatchNo+var(24) = 5
triggerall = !IsHelper
triggerall = var(0) = 1
triggerall = id > partner, id
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
value = IfElse(RoundNo+var(25)=1,10008,10009),0
volume = 1
channel = 5
loop = 1
lowpriority = 5

;--------------------------------------------------------------------------
;Keep track of time in round.
[State -2, InRoundTime]
type = VarAdd
triggerall = RoundState = 2
trigger1 = var(0) < 4
v = 0
value = 1

;Set P1 Lives
[State -2, Test]
type = VarSet
trigger1 = RoundNo = 1
trigger1 = RoundState != 2
trigger1 = var(3) = 0
v = 3
value = IfElse(var(20)=1,10,5)

;Set P2 Lives
[State -2, Test]
type = VarSet
trigger1 = RoundNo = 1
trigger1 = RoundState != 2
trigger1 = var(4) = 0
v = 4
value = IfElse(var(20)=1,10,5)

;Set P1 Bullets
[State -2, Test]
type = VarSet
triggerall = RoundState != 2
trigger1 = var(5) = 0
trigger2 = MatchNo+var(24) = 2
v = 5
value = IfElse(MatchNo+var(24)=1,8,3)

;Set P2 Bullets
[State -2, Test]
type = VarSet
triggerall = RoundState != 2
trigger1 = var(6) = 0
trigger2 = MatchNo+var(24) = 2
v = 6
value = IfElse(MatchNo+var(24)=1,8,3)

;Set P1 Gun
[State -2, Test]
type = VarSet
trigger1 = var(7) = 0
trigger1 = RoundState != 2
v = 7
value = 0

;Set P2 Gun
[State -2, Test]
type = VarSet
trigger1 = var(8) = 0
v = 8
value = 0

;Reset Bonus Vars
[State -2, BonusReset]
type = VarRangeSet
trigger1 = var(0) = 1
value = 0
first = 9
last = 18

[State -2, BonusReset]
type = VarRangeSet
trigger1 = var(0) = 1
value = 0
first = 22
last = 23

;Display Game Over
[State -2,Game Over]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = NumExplod(15013) = 0
trigger1 = var(3) <= 0
anim = 15013
ID = 15013
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,4,190+42),20

;Remove Explods for modification

;Remove Background
[State 180, RemoveBG]
type = RemoveExplod
triggerall = !IsHelper
triggerall = NumExplod(60000) > 0
trigger1 = RoundState = 4
trigger2 = MatchNo+var(24) = 4 && RoundNo+var(25) = 2
trigger2 = NumHelper(25477) = 1
trigger2 = helper(25477),ScreenPos Y <= -50
ID = 60000

[State 180, RemoveBG]
type = RemoveExplod
triggerall = !IsHelper
triggerall = NumExplod(60001) > 0
trigger1 = RoundState = 4
trigger2 = MatchNo+var(24) = 4 && RoundNo+var(25) = 2
trigger2 = NumHelper(25477) = 1
trigger2 = helper(25477),ScreenPos Y <= -50
ID = 60001

[State 180, RemoveBG]
type = RemoveExplod
triggerall = !IsHelper
triggerall = NumExplod(60002) > 0
trigger1 = RoundState = 4
trigger2 = MatchNo+var(24) = 4 && RoundNo+var(24) = 2
trigger2 = NumHelper(25477) = 1
trigger2 = helper(25477),ScreenPos Y <= -50
ID = 60002

;Remove 1P/2P
[State -2, Remove1P/2P]
type = RemoveExplod
triggerall = !IsHelper
triggerall = RoundState = 4
trigger1 = NumExplod(15010) > 0
ID = 15010

;Remove REST
[State -2, RemoveREST]
type = RemoveExplod
triggerall = !IsHelper
triggerall = RoundState = 4
trigger1 = NumExplod(15012) > 0
ID = 15012

;Remove RINGS
[State -2, RemoveRINGS]
type = RemoveExplod
triggerall = !IsHelper
triggerall = RoundState = 4
trigger1 = NumExplod(15016) > 0
ID = 15016

;Remove STAGE
[State -2, RemoveSTAGE]
type = RemoveExplod
triggerall = !IsHelper
triggerall = RoundState = 4
trigger1 = NumExplod(15019) > 0
ID = 15019

;Remove STAGE #-00
[State -2, RemoveSTAGE]
type = RemoveExplod
triggerall = !IsHelper
triggerall = RoundState = 4
trigger1 = NumExplod(15029) > 0
ID = 15029

;Remove STAGE 0-#0
[State -2, RemoveSTAGE]
type = RemoveExplod
triggerall = !IsHelper
triggerall = RoundState = 4
trigger1 = NumExplod(15030) > 0
ID = 15030

;Remove STAGE 0-0#
[State -2, RemoveSTAGE]
type = RemoveExplod
triggerall = !IsHelper
triggerall = RoundState = 4
trigger1 = NumExplod(15031) > 0
ID = 15031

[State -2, HideGameOver]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15013) > 0
trigger1 = var(3) > 0
ID = 15013

[State -2, RemoveGun]
type = RemoveExplod
triggerall = !IsHelper
triggerall = NumExplod(15040) = 1
trigger1 = MatchNo+var(24) = 1
trigger2 = MatchNo+var(24) = 5
trigger3 = RoundState = 4
ID = 15040

[State -2, RemoveBulletDigit]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15041) = 1
ID = 15041

[State -2, RemoveBulletDigit2]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15042) = 1
ID = 15042

[State -2, RemoveDigit1Rest]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15020) = 1
ID = 15020

[State -2, RemoveDigit2Rest]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15021) = 1
ID = 15021

[State -2, RemoveDigit1Score]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15022) = 1
ID = 15022

[State -2, RemoveDigit2Score]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15023) = 1
ID = 15023

[State -2, RemoveDigit3Score]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15024) = 1
ID = 15024

[State -2, RemoveDigit4Score]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15025) = 1
ID = 15025

[State -2, RemoveDigit5Score]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15026) = 1
ID = 15026

[State -2, RemoveDigit6Score]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15027) = 1
ID = 15027

[State -2, RemoveDigit7Score]
type = RemoveExplod
triggerall = !IsHelper
;trigger1 = RoundState = 2
trigger1 = NumExplod(15028) = 1
ID = 15028

[State -2, RemoveDigit1Rings]
type = RemoveExplod
triggerall = !IsHelper
trigger1 = NumExplod(15060) = 1
ID = 15060

[State -2, RemoveDigit2Rings]
type = RemoveExplod
triggerall = !IsHelper
trigger1 = NumExplod(15061) = 1
ID = 15061

[State -2, RemoveDigit3Rings]
type = RemoveExplod
triggerall = !IsHelper
trigger1 = NumExplod(15062) = 1
ID = 15062

[State -2, RemoveTails]
type = RemoveExplod
triggerall = !IsHelper
trigger1 = NumExplod(15070) > 0
trigger1 = NumHelper(25482) > 0
trigger2 = RoundState = 4
ID = 15070

;Remove RINGS
[State -2, RemoveKnuckles]
type = RemoveExplod
triggerall = !IsHelper
trigger1 = NumExplod(15071) > 0
trigger2 = RoundState = 4
ID = 15071

[State -2, RemoveStars]
type = RemoveExplod
triggerall = !IsHelper
trigger1 = NumExplod(15076) > 0
trigger1 = var(33) <= 0
trigger2 = RoundState = 4
ID = 15076

[State -2, RemoveShield]
type = RemoveExplod
triggerall = !IsHelper
trigger1 = NumExplod(15074) > 0
trigger1 = var(31) != 1
trigger2 = RoundState = 4
trigger3 = var(33) > 0 
ID = 15074

;;;;;;;;;;;;;;;;;;
;; STAT DISPLAY ;;
;;;;;;;;;;;;;;;;;;

;Display 1P/2P
[State -2,1P2P]
type = Explod
triggerall = !IsHelper
triggerall = RoundState <= 3
trigger1 = NumExplod(15010) = 0
anim = IfElse(TeamSide = 1,15010,15011)
ID = 15010
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,4,190+42),4

;Display STAGE
[State -2,Stage]
type = Explod
triggerall = !IsHelper
triggerall = RoundState <= 3
triggerall = NumExplod(15019) = 0
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
anim = 15019
ID = 15019
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 124,4

;Display #0-0 Stage
[State -2,Digit1 Stage]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = NumExplod(15029) = 0
triggerall = MatchNo+var(24) >= 10
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
anim = 15000+((MatchNo+var(24))/10%10)
ID = 15029
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 170,4

;Display 0#-0 Stage
[State -2,Digit2 Stage]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = NumExplod(15030) = 0
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
anim = 15000+((MatchNo+var(24))%10)
ID = 15030
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 178,4

;Display 00-# Stage
[State -2,Digit3 Stage]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = NumExplod(15031) = 0
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
anim = 15000+((RoundNo+var(25))%10)
ID = 15031
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = 196,4

;Display RINGS
[State -2,RINGS]
type = Explod
triggerall = !IsHelper
triggerall = RoundState <= 3
triggerall = MatchNo+var(24) = 5
trigger1 = NumExplod(15016) = 0
anim = 15016
ID = 15016
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,4,190+42),28

;Display Rings #00
[State -2,Digit1 Rings]
type = Explod
triggerall = var(15) >= 100
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = MatchNo+var(24) = 5
trigger1 = NumExplod(15060) = 0
anim = 15000+(var(15)/100%10)
ID = 15060
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,50,236+42),28

;Display Rings 0#0
[State -2,Digit2 Rings]
type = Explod
triggerall = var(15) >= 10
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = MatchNo+var(24) = 5
trigger1 = NumExplod(15061) = 0
anim = 15000+(var(15)/10%10)
ID = 15061
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,58,244+42),28

;Display Rings 00#
[State -2,Digit3 Rings]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = MatchNo+var(24) = 5
trigger1 = NumExplod(15062) = 0
anim = 15000+(var(15)%10)
ID = 15062
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,66,252+42),28

;Display REST
[State -2,REST]
type = Explod
triggerall = !IsHelper
triggerall = RoundState <= 3
trigger1 = NumExplod(15012) = 0
anim = 15012
ID = 15012
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,4,190+42),12

;Display Digit1 of Rest
[State -2,Digit1 Rest]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
trigger1 = NumExplod(15020) = 0
anim = 15000+(var(3)/10)
ID = 15020
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,42,228+42),12

;Display Digit2 of Rest
[State -2,Digit2 Rest]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
trigger1 = NumExplod(15021) = 0
anim = 15000+(var(3)%10)
ID = 15021
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,50,236+42),12

;Display Digit 1 of Score
[State -2,Digit1 Score]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
trigger1 = NumExplod(15022) = 0
anim = 15000+(var(1)/1000000%10)
ID = 15022
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,34,220+42),4

;Display Digit 2 of Score
[State -2,Digit2 Score]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
trigger1 = NumExplod(15023) = 0
anim = 15000+(var(1)/100000%10)
ID = 15023
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,42,228+42),4

;Display Digit 3 of Score
[State -2,Digit3 Score]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
trigger1 = NumExplod(15024) = 0
anim = 15000+(var(1)/10000%10)
ID = 15024
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,50,236+42),4

;Display Digit 4 of Score
[State -2,Digit4 Score]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
trigger1 = NumExplod(15025) = 0
anim = 15000+(var(1)/1000%10)
ID = 15025
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,58,244+42),4

;Display Digit 5 of Score
[State -2,Digit5 Score]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
trigger1 = NumExplod(15026) = 0
anim = 15000+(var(1)/100%10)
ID = 15026
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,66,252+42),4

;Display Digit 6 of Score
[State -2,Digit6 Score]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
trigger1 = NumExplod(15027) = 0
anim = 15000+(var(1)/10%10)
ID = 15027
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,74,260+42),4

;Display Digit 7 of Score
[State -2,Digit7 Score]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
trigger1 = NumExplod(15028) = 0
anim = 15000+(var(1)%10)
ID = 15028
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,82,268+42),4

;Display Gun
[State -2,GunDisplay]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = NumExplod(15040) = 0
trigger1 = MatchNo+var(24) != 5
trigger2 = MatchNo+var(24) = 5 && NumHelper(25481) = 0
anim = IfElse(MatchNo+var(24)=1,10100+var(7),IfElse(MatchNo+var(24)=2,10108,IfElse(MatchNo+var(24)=3,10109,IfElse(MatchNo+var(24)=4,10109+RoundNo+var(25),10112))))
ID = 15040
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,24,210+42),222
scale = IfElse(MatchNo+var(24)=3,1,IfElse(MatchNo+var(24)=4&&RoundNo+var(25)=2,0.3,IfElse(MatchNo+var(24)=5,0.5,0.15))),IfElse(MatchNo+var(24)=3,1,IfElse(MatchNo+var(24)=4&&RoundNo+var(25)=2,0.3,IfElse(MatchNo+var(24)=5,0.5,0.15)))

;Display Digit1 of BulletCount
[State -2,Digit1 Bullet]
type = Explod
triggerall = MatchNo+var(24) < 3
triggerall = RoundState <= 3
triggerall = !IsHelper
trigger1 = NumExplod(15041) = 0
anim = 15000+(var(5)/10)
ID = 15041
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,58,244+42),222

;Display Digit2 of BulletCount
[State -2,Digit2 Bullet]
type = Explod
triggerall = MatchNo+var(24) < 3
triggerall = RoundState <= 3
triggerall = !IsHelper
trigger1 = NumExplod(15042) = 0
anim = 15000+(var(5)%10)
ID = 15042
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,66,252+42),222

;Display Tails (Sonic Round)
[State -2,DisplayTails]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = NumExplod(15070) = 0
trigger1 = MatchNo+var(24) = 5 && NumHelper(25482) = 0 && var(29) >= 1
anim = 10113
ID = 15070
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,24,210+42),222
scale = 0.5,0.5

;Display Knuckles (Sonic Round)
[State -2,DisplayKnux]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = NumExplod(15071) = 0
trigger1 = MatchNo+var(24) = 5 && NumHelper(25483) = 0 && var(29) >= 2
anim = 10114
ID = 15071
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,24,210+42),222
scale = 0.5,0.5

;Display Gun
[State -2,GunDisplay]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = NumExplod(15040) = 0
trigger1 = MatchNo+var(24) != 5
trigger2 = MatchNo+var(24) = 5 && NumHelper(25481) = 0
anim = IfElse(MatchNo+var(24)=1,10100+var(7),IfElse(MatchNo+var(24)=2,10108,IfElse(MatchNo+var(24)=3,10109,IfElse(MatchNo+var(24)=4,10109+RoundNo+var(25),10112))))
ID = 15040
postype = left
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2
pos = IfElse(TeamSide=1,24,210+42),222

;Display Shield on Crosshair (Sonic Round)
[State -2,DisplayShield]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = NumExplod(15074) = 0
trigger1 = MatchNo+var(24)
trigger1 = var(31) = 1
trigger1 = var(33) <= 0
anim = 25524
ID = 15074
postype = p1
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2

;Display Stars on Crosshair (Sonic Round)
[State -2,DisplayStars]
type = Explod
triggerall = RoundState <= 3
triggerall = !IsHelper
triggerall = NumExplod(15076) = 0
trigger1 = MatchNo+var(24)
trigger1 = var(33) > 0
anim = 25525
ID = 15076
postype = p1
bindtime = -1
removetime = -1
ownpal = 1
sprpriority = -2

;Decrease Star Counter P1
[State -2, DecreaseStarCounter]
type = VarAdd
trigger1 = var(33) > 0
v = 33
value = -1

;Decrease Star Counter P2
[State -2, DecreaseStarCounter]
type = VarAdd
trigger1 = var(34) > 0
v = 34
value = -1

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

;P2 Live Record on P1 side < P2 actual lives, take away bullets and reset gun
[State -2, ResetP2Gun]
type = VarSet
trigger1 = TeamSide = 2
trigger1 = enemy,Name = "XTSM"
trigger1 = !IsHelper
trigger1 = enemy,var(4) < var(3)
v = 7
value = 0

[State -2, ResetP2Bullets]
type = VarSet
trigger1 = TeamSide = 2
trigger1 = enemy,Name = "XTSM"
trigger1 = !IsHelper
trigger1 = enemy,var(4) < var(3)
v = 5
value = 8

;P2 is XTSM, Lives = 0, they press start.
[State -2, CoinSound]
type = PlaySnd
trigger1 = TeamSide = 1
trigger1 = enemy,Name = "XTSM"
trigger1 = !IsHelper
trigger1 = enemy,var(3) = 0
trigger1 = enemy,Command = "start"
value = 1,3

[State -2, Set Points]
type = VarAdd
trigger1 = TeamSide = 1
trigger1 = enemy,Name = "XTSM"
trigger1 = !IsHelper
trigger1 = enemy,var(3) = 0
trigger1 = enemy,Command = "start"
v = 2
value = -1000

[State -2, Set Lives]
type = VarSet
trigger1 = TeamSide = 1
trigger1 = enemy,Name = "XTSM"
trigger1 = !IsHelper
trigger1 = enemy,var(3) = 0
trigger1 = enemy,Command = "start"
v = 4
value = IfElse(var(20)=1,10,5)

;On P1 Side.  P2 is XTSM.  Sonic takes damage.  Change vars.
[State -2, P2LosesRings]
type = VarSet
triggerall = MatchNo+var(24) = 5
triggerall = !IsHelper
triggerall = TeamSide = 1
triggerall = enemy,Name = "XTSM"
triggerall = var(16) < enemy,var(15)
trigger1 = enemy,NumHelper(25481) > 0
trigger2 = enemy,NumHelper(25482) > 0
trigger3 = enemy,NumHelper(25483) > 0
v = 16
value = enemy,var(15)

;On P2 side and is XTSM.  Copy P1 variables.
[State -2, CopyP1Score]
type = VarSet
trigger1 = TeamSide = 2
trigger1 = enemy,Name = "XTSM"
trigger1 = !IsHelper
trigger1 = var(1) != enemy,var(2)
v = 1
value = enemy,var(2)

[State -2, CopyP1Lives]
type = VarSet
triggerall = TeamSide = 2
triggerall = enemy,Name = "XTSM"
triggerall = !IsHelper
trigger1 = var(3) != enemy,var(4)
v = 3
value = enemy,var(4)

[State -2, CopyP1Gun]
type = VarSet
triggerall = TeamSide = 2
triggerall = enemy,Name = "XTSM"
triggerall = !IsHelper
trigger1 = var(7) != enemy,var(8)
v = 7
value = enemy,var(8)

[State -2, CopyP1Bullets]
type = VarSet
triggerall = TeamSide = 2
triggerall = enemy,Name = "XTSM"
triggerall = !IsHelper
trigger1 = var(5) != enemy,var(6)
v = 5
value = enemy,var(6)

;Copy Sonic Stuff
[State -2, CopyP1Rings]
type = VarSet
triggerall = TeamSide = 2
triggerall = enemy,Name = "XTSM"
triggerall = !IsHelper
trigger1 = var(15) != enemy,var(16)
v = 15
value = enemy,var(16)

[State -2, CopyP1CharCount]
type = VarSet
triggerall = TeamSide = 2
triggerall = enemy,Name = "XTSM"
triggerall = !IsHelper
trigger1 = var(29) != enemy,var(30)
v = 29
value = enemy,var(30)

[State -2, CopyP1Shield]
type = VarSet
triggerall = TeamSide = 2
triggerall = enemy,Name = "XTSM"
triggerall = !IsHelper
trigger1 = var(31) != enemy,var(32)
v = 31
value = enemy,var(32)

[State -2, CopyP1Invincibility]
type = VarSet
triggerall = TeamSide = 2
triggerall = enemy,Name = "XTSM"
triggerall = !IsHelper
trigger1 = var(33) != enemy,var(34)
v = 33
value = enemy,var(34)

;Take Away Bullets in LEII Round
[State -2, P2Attack]
type = VarAdd
triggerall = TeamSide = 1 && enemy,Name = "XTSM"
triggerall = MatchNo+var(24) = 1
triggerall = var(4) > 0
triggerall = RoundState = 2
triggerall = var(6) > 0
triggerall = !(enemy,Pos Y = [18,20])
trigger1 = enemy,command = "a"
trigger2 = enemy,command = "holda" && var(8) = 1 && GameTime%6 = 0
trigger3 = enemy,command = "holda" && var(8) = 3 && GameTime%5 = 0
trigger4 = enemy,command = "holda" && var(8) = 4 && GameTime%4 = 0
trigger5 = enemy,command = "holda" && var(8) = 5 && GameTime%4 = 0
v = 6
value = -1

;Take Away Bullets in Duck Hunt Round
[State 90005, Attack]
type = ParentVarAdd
triggerall = TeamSide = 1 && enemy,Name = "XTSM"
triggerall = MatchNo+var(24) = 2
triggerall = var(21) = 0
triggerall = var(4) > 0
triggerall = RoundState = 2
triggerall = var(6) > 0
triggerall = NumHelper(25403) > 0
trigger1 = enemy,Command = "a"
v = 6
value = -1

;P1 Side.  Copy P2 variables for end of round bonus
[State -2, CopyP2Shots]
type = VarSet
triggerall = TeamSide = 1
triggerall = enemy,Name = "XTSM"
triggerall = !IsHelper
trigger1 = var(10) != enemy,var(9)
v = 10
value = enemy,var(9)

;Player 1/Player 2 (when enemy is not XTSM) can't die!
[State -2, NoDieP1]
type = LifeSet
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
value = 1000

;Hide when round is over
[State -2, InvisibleAtRoundOver]
type = AssertSpecial
trigger1 = RoundState > 2
flag = Invisible

;Force into LieDead state when Life = 0
[State -2, 1]
type = ChangeState
triggerall = !IsHelper
trigger1 = Life = 0
trigger1 = StateNo != 5150
value = 5150

;;;;;;;;;;;;;
;; ENEMIES ;;
;;;;;;;;;;;;;
;--------------------------------------------------------------------------
;LETHAL ENFORCERS II STAGE

;1-1
[State -2, CreateEnemy]
type = Helper
triggerall = MatchNo+var(24) = 1
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(3) > 0 || var(4) > 0
trigger1 = TeamSide = 1 && NumHelper(25000) < 6 && GameTime%50 = 0
trigger2 = TeamSide = 2 && enemy,Name != "XTSM" && NumHelper(25000) < 6 && GameTime%50 = 0
helpertype = normal
name = "Stage 1-1 Enemy"
ID = 25000
postype = left
ownpal = 1
stateno = 24999
pos = 50,-80

;1-2
;Boss
[State -2, CreateBoss]
type = Helper
triggerall = MatchNo+var(24) = 1
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(0) = 1
trigger1 = TeamSide = 1 && NumHelper(25000) < 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM" && NumHelper(25000) < 1
helpertype = normal
name = "Stage 1-2 Boss"
ID = 25000
postype = left
ownpal = 1
stateno = 25030
pos = 50,-80

;Skulls
[State -2, CreateSkulls]
type = Helper
triggerall = MatchNo+var(24) = 1
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = NumHelper(25000) > 0
triggerall = NumHelper(25031) < 3
triggerall = helper(25000),var(6) > 0
triggerall = GameTime%60 = 0
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
helpertype = normal
name = "Stage 1-2 Skull"
ID = 25031
postype = left
ownpal = 1
stateno = 25031
pos = floor(helper(25000),ScreenPos X),floor(helper(25000),Pos Y)

;Randomly leave new gun
[State -2, NewGun]
type = Helper
triggerall = MatchNo+var(24) = 1
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(3) > 0 || var(4) > 0
triggerall = NumHelper(25000) > 0 
triggerall = NumHelper(25010) = 0
triggerall = Random >= 800
triggerall = TeamSide = 1 || (TeamSide = 2 && enemy,Name != "XTSM")
trigger1 = RoundNo+var(25) = 1
trigger1 = helper(25000),StateNo = 25005
trigger1 = helper(25000),AnimElem = 3,30
trigger2 = RoundNo+var(25) = 2
trigger2 = NumHelper(25031) > 0
trigger2 = helper(25031),StateNo = 25033
trigger2 = helper(25031),AnimElem = 11,0
helpertype = normal
name = "Item"
ID = 25010
postype = left
ownpal = 1
stateno = 25010
pos = floor(helper(25000),ScreenPos X),floor(helper(25000),Pos Y)
;--------------------------------------------------------------------------
;DUCK HUNT STAGE
;Dog Entrance
[State -2, CreateDog]
type = Helper
triggerall = MatchNo+var(24) = 2
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(0) = 1
trigger1 = TeamSide = 1 && NumHelper(25400) = 0
trigger2 = TeamSide = 2 && enemy,Name != "XTSM" && NumHelper(25400) = 0
helpertype = normal
name = "Stage 2-1 Dog"
ID = 25400
postype = left
ownpal = 1
stateno = 25400
pos = 0,-10

;Trigger end of round
[State -2, EndRound]
type = VarSet
triggerall = var(27) >= 50
triggerall = MatchNo+var(24) = 2
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = NumHelper(25400) > 0
triggerall = helper(25400),StateNo = 25401
triggerall = helper(25400),Anim = 25412
triggerall = helper(25400),AnimElem = 1,4 || helper(25400),AnimElem = 1,5
triggerall = NumHelper(25403) < 2
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
v = 0
value = 7199

;Create Ducks
[State -2, CreateDucks]
type = Helper
triggerall = var(27) < 50
triggerall = MatchNo+var(24) = 2
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = NumHelper(25400) > 0
triggerall = helper(25400),StateNo = 25401
triggerall = helper(25400),Anim = 25412
triggerall = helper(25400),AnimElem = 1,4 || helper(25400),AnimElem = 1,5
triggerall = NumHelper(25403) < 2
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
helpertype = normal
name = "Stage 2-1 Duck"
ID = 25403
postype = left
ownpal = 1
stateno = 25403
pos = floor((helper(25400),ScreenPos X)),floor((helper(25400),Pos Y))-80

;Create Discs
[State -2, CreateDiscs]
type = Helper
triggerall = var(27) < 100
triggerall = MatchNo+var(24) = 2
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = NumHelper(25403) < 8
triggerall = TeamSide = 1 || (TeamSide = 2 && enemy,Name != "XTSM")
triggerall = helper(20100),var(0) >= 300
trigger1 = GameTime%50 = 0
helpertype = normal
name = "Stage 2-2 Disc"
ID = 25403
postype = left
ownpal = 1
stateno = 25405
pos = 0,40

;Reset Duck/Disc Counts/Torpedo Var
[State -2, DuckReset]
type = VarRangeSet
trigger1 = var(0) = 1
value = 0
first = 26
last = 28

;--------------------------------------------------------------------------
;MARIO STAGE
;Create Enemies for Stage 1
[State -2, CreateStage1Enemy]
type = Helper
triggerall = Gametime%50 = 0
triggerall = MatchNo+var(24) = 3
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = Random <= 600
triggerall = NumHelper(25450) < 6
triggerall = var(3) > 0 || var(4) > 0
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
helpertype = normal
name = "Stage 3-1 Enemy"
ID = 25450
postype = left
ownpal = 1
stateno = 25450
pos = IfElse(Random<=500,-8,328),40

;Create Item Blocks
[State -2, CreateStage1Block]
type = Helper
triggerall = Gametime%100 = 0
triggerall = MatchNo+var(24) = 3
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = NumHelper(25461) < 5
triggerall = Random <= 500
triggerall = var(3) > 0 || var(4) > 0
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
helpertype = normal
name = "Stage 3-1 Block"
ID = 25461
postype = left
ownpal = 1
stateno = 25461
pos = floor(Random/4.15)+40,0

;Create Bowser
[State -2, CreateBowser]
type = Helper
triggerall = MatchNo+var(24) = 3
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(0) = 1
trigger1 = TeamSide = 1 && NumHelper(25000) < 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM" && NumHelper(25000) < 1
helpertype = normal
name = "Stage 3-2 Boss"
ID = 25000
postype = left
ownpal = 1
stateno = 25466
pos = 0,0

;Create Jumping Fire
[State -2, CreateJumpingFire]
type = Helper
triggerall = MatchNo+var(24) = 3
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = Random <= 300
triggerall = GameTime%50 = 0
triggerall = helper(25000),StateNo != 25467
trigger1 = TeamSide = 1 && NumHelper(25470) < 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM" && NumHelper(25470) < 1
helpertype = normal
name = "Stage 3-2 Jumping Fire"
ID = 25470
postype = left
ownpal = 1
stateno = 25470
pos = 0,0

;Create Koopalings
[State -2, CreateKoopalings]
type = Helper
triggerall = MatchNo+var(24) = 3
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(0) < 4
trigger1 = TeamSide = 1 && NumHelper(25471+var(0)-1) < 3
trigger2 = TeamSide = 2 && enemy,Name != "XTSM" && NumHelper(25471+var(0)-1) < 3
helpertype = normal
name = "Stage 3-2 Koopaling"
ID = 25471+var(0)-1
postype = left
ownpal = 1
stateno = 25471
pos = 0,0
;--------------------------------------------------------------------------
;STAR WARS STAGE

;4-1
[State -2, CreateEnemy]
type = Helper
triggerall = MatchNo+var(24) = 4
triggerall = RoundNo+var(25) = 1
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(3) > 0 || var(4) > 0
trigger1 = TeamSide = 1 && NumHelper(25000) < 8 && GameTime%30 = 0
trigger2 = TeamSide = 2 && enemy,Name != "XTSM" && NumHelper(25000) < 8 && GameTime%30 = 0
helpertype = normal
name = "Stage 4-1 Enemy"
ID = 25000
postype = left
ownpal = 1
stateno = 25473
pos = 0,0

;4-2 - TieFighter
[State -2, CreateTieFighter]
type = Helper
triggerall = MatchNo+var(24) = 4
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(3) > 0 || var(4) > 0
trigger1 = TeamSide = 1 && NumHelper(25000) < 5 && GameTime%30 = 0 && NumHelper(25477) = 0
trigger2 = TeamSide = 2 && enemy,Name != "XTSM" && NumHelper(25000) < 5 && GameTime%30 = 0 && NumHelper(25477) = 0
trigger3 = NumHelper(25477) = 1
trigger3 = helper(25477),Vel Y = [-3,3]
trigger3 = helper(25477),Vel Y != 0
trigger3 = GameTime%40 = 0
trigger3 = Random <= 80
helpertype = normal
name = "Stage 4-2 Enemy"
ID = 25000
postype = left
ownpal = 1
stateno = 25475
pos = 0,0

;4-2 - DarthVader
[State -2, CreateDarthVader]
type = Helper
triggerall = MatchNo+var(24) = 4
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(3) > 0 || var(4) > 0
triggerall = helper(20100),var(0) = 7200
trigger1 = TeamSide = 1 && NumHelper(25477) = 0
trigger2 = TeamSide = 2 && enemy,Name != "XTSM" && NumHelper(25477) = 0
helpertype = normal
name = "Stage 4-2 Darth Vader"
ID = 25477
postype = left
ownpal = 1
stateno = 25477
pos = 0,0

;Vader lasers
[State -2, Laser]
type = Helper
triggerall = MatchNo+var(24) = 4
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(3) > 0 || var(4) > 0
triggerall = NumHelper(25477) = 1
triggerall = NumHelper(25480) < 3
trigger1 = helper(25477),Vel Y = [-3,3]
trigger1 = helper(25477),Vel Y != 0
trigger1 = GameTime%20 = 0
trigger1 = Random <= 300
helpertype = normal
name = "Vader Laser"
ID = 25480
postype = left
ownpal = 1
stateno = 25480
pos = floor(helper(25477),ScreenPos X),floor(helper(25477),Pos Y)

;Stop BGMusic
[State -2 StopBGMusic]
type = StopSnd
triggerall = MatchNo+var(24) = 4
triggerall = RoundNo+var(25) = 2
triggerall = !IsHelper
triggerall = RoundState = 2
trigger1 = NumHelper(25477) = 1
trigger1 = helper(25477),var(7) <= 0
trigger1 = helper(25477),Vel Y = -10
channel = 5

;--------------------------------------------------------------------------
;SONIC STAGE

;5-1
;Create Rings
[State -2, CreateRings]
type = Helper
triggerall = Gametime%30 = 0
triggerall = MatchNo+var(24) = 5
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = NumHelper(25487) < 5
triggerall = Random <= 500
triggerall = var(3) > 0 || var(4) > 0
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
helpertype = normal
name = "Stage 5 Ring"
ID = 25487
postype = left
ownpal = 1
stateno = 25485
pos = floor(Random/4.15)+40,0

;Create Items
[State -2, CreateItemBlocks]
type = Helper
triggerall = Gametime%30 = 0
triggerall = MatchNo+var(24) = 5
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = NumHelper(25488) < 1
triggerall = Random <= 500
triggerall = var(3) > 0 || var(4) > 0
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
helpertype = normal
name = "Stage 5 Item"
ID = 25488
postype = left
ownpal = 1
stateno = 25487
pos = floor(Random/4.15)+40,0

;Create Enemies
[State -2, CreateEnemies]
type = Helper
triggerall = Gametime%30 = 0
triggerall = MatchNo+var(24) = 5
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = NumHelper(25000) < 3
triggerall = Random <= 500
triggerall = var(3) > 0 || var(4) > 0
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
helpertype = normal
name = "Stage 5 Enemy"
ID = 25000
postype = left
ownpal = 1
stateno = 25490
pos = 0,0

;Stop BGMusic
[State -2, StopBGMusic]
type = StopSnd
triggerall = MatchNo+var(24) = 5
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(33) = 1199 || var(34) = 1199
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
channel = 5

;Invincibility Music
[State -2, StartMusic]
type = PlaySnd
triggerall = MatchNo+var(24) = 5
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = var(33) = 1199 || var(34) = 1199
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
value = 25430,9
volume = 1
channel = 6
loop = 1
lowpriority = 6

;Stop Invincibility
[State -2, StopBGMusic]
type = StopSnd
triggerall = MatchNo+var(24) = 5
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = (var(33) = 1 && var(34) <= 0) || (var(34) = 1 && var(33) <= 0)
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
channel = 6

;Start Regular BG Music again
[State -2, StartMusic]
type = PlaySnd
triggerall = MatchNo+var(24) = 5
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = (var(33) = 1 && var(34) <= 0) || (var(34) = 1 && var(33) <= 0)
trigger1 = TeamSide = 1 && enemy,Name != "XTSM"
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
trigger3 = TeamSide = 1 && enemy,Name = "XTSM"
value = IfElse(RoundNo+var(25)=1,10008,10009),0
volume = 1
channel = 5
loop = 1
lowpriority = 5

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

;Kill myself if enemy is XTSM and Round is over
[State -2, Die]
type = LifeSet
triggerall = TeamSide = 2
triggerall = enemy,Name = "XTSM"
triggerall = RoundState = 2
trigger1 = enemy,var(0) = 7199
value = 0

[State -2, Debug]
type = DisplayToClipboard
trigger1 = 1
text = "NumSonic = %d"
params = NumHelper(25481)

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

[State -3, StayInScreen]
type = Helper
triggerall = !IsHelper
triggerall = NumHelper(20000) = 0
trigger1 = Time = 0
helpertype = player
name = "ScreenBind"
ID = 20000
postype = p1
stateno = 20000

[State -3, GameTimer]
type = Helper
triggerall = !IsHelper
triggerall = NumHelper(20100) = 0
triggerall = RoundState = 2
trigger1 = TeamSide = 1
trigger2 = TeamSide = 2 && enemy,Name != "XTSM"
helpertype = player
name = "GameTimer"
ID = 20100
postype = p1
stateno = 20100

;Edit Match
[State -3, MatchEdit]
type = VarSet
trigger1 = Time = 0
v = 24
value = 0;IfElse(MatchNo+var(24)<4,0,-MatchNo+1)

;Edit Round
[State -3, RoundEdit]
type = VarSet
trigger1 = Time = 0
v = 25
value = 0