share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua
changeset 13709 e2b1abb4fba5
parent 13687 a8b2a5e7e9db
child 13710 0da36902e5b6
equal deleted inserted replaced
13708:3264a26bbf8b 13709:e2b1abb4fba5
    89 
    89 
    90 -- add support for other world edges (they are currently disabled)
    90 -- add support for other world edges (they are currently disabled)
    91 
    91 
    92 -- maybe add a check for a tie, IMPOSSIBRU THERE ARE NO TIES
    92 -- maybe add a check for a tie, IMPOSSIBRU THERE ARE NO TIES
    93 
    93 
    94 -- if more weps are added, replace primshotsfired all over the place
    94 -- if more weapons are added, replace primshotsfired all over the place
    95 
    95 
    96 -- look for derp and let invaders shoot again
    96 -- look for derp and let invaders shoot again
    97 
    97 
    98 -- more weps? flamer/machineballgun,
    98 -- more weapons? flamer/machineballgun,
    99 -- some kind of bomb that just drops straight down
    99 -- some kind of bomb that just drops straight down
   100 -- "fire and forget" missile
   100 -- "fire and forget" missile
   101 -- shockwave
   101 -- shockwave
   102 
   102 
   103 -- some kind of ability-meter that lets you do something awesome when you are
   103 -- some kind of ability-meter that lets you do something awesome when you are
   104 -- doing really well in a given round.
   104 -- doing really well in a given round.
   105 -- probably new kind of shield that pops any invaders who come near
   105 -- probably new kind of shield that pops any invaders who come near
   106 
   106 
   107 -- new invader: golden snitch, doesn't show up on your radar
   107 -- new invader: golden snitch, doesn't show up on your radar
   108 
   108 
   109 -- maybe replace (48/100*vCircRadius[i])/2 with something better
   109 -- maybe replace (48/100*SI.vCircRadius[i])/2 with something better
   110 
   110 
   111 -------------------
   111 -------------------
   112 -- CAPTION TYPES --
   112 -- CAPTION TYPES --
   113 -------------------
   113 -------------------
   114 --[[
   114 --[[
   126 
   126 
   127 ----------------------------------
   127 ----------------------------------
   128 -- so I herd u liek wariables
   128 -- so I herd u liek wariables
   129 ----------------------------------
   129 ----------------------------------
   130 
   130 
   131 local fMod = 1000000 -- use this for dev and .16+ games
   131 -- The table that holds the Space Invasion variables
       
   132 local SI = {}
       
   133 
       
   134 SI.fMod = 1000000 -- use this for dev and .16+ games
   132 
   135 
   133 -- Tag IDs
   136 -- Tag IDs
   134 local TAG_TIME = 0
   137 SI.TAG_TIME = 0
   135 local TAG_BARRELS = 1
   138 SI.TAG_BARRELS = 1
   136 local TAG_SHIELD = 2
   139 SI.TAG_SHIELD = 2
   137 local TAG_ROUND_SCORE = 4
   140 SI.TAG_ROUND_SCORE = 4
   138 
   141 
   139 -- some console stuff
   142 -- some console stuff
   140 local shellID = 0
   143 SI.shellID = 0
   141 local explosivesID = 0
   144 SI.explosivesID = 0
   142 local luaGameTicks = 0
       
   143 
   145 
   144 -- gaudyRacer
   146 -- gaudyRacer
   145 local boosterOn = false
   147 SI.boosterOn = false
   146 local preciseOn = false
   148 SI.preciseOn = false
   147 local roundLimit = 3		-- can be overridden by script parameter "rounds"
   149 SI.roundLimit = 3		-- can be overridden by script parameter "rounds"
   148 local roundNumber = 0
   150 SI.roundNumber = 0
   149 local firstClan = 10
   151 SI.firstClan = 10
   150 local gameOver = false
   152 SI.gameOver = false
   151 local gameBegun = false
   153 SI.gameBegun = false
   152 
   154 
   153 local bestClan = 10
   155 SI.bestClan = 65535
   154 local bestScore = 0
   156 SI.bestScore = 0
   155 local sdScore = {}
       
   156 local sdName = {}
       
   157 local sdKills = {}
       
   158 
       
   159 local roundN = 0
       
   160 local lastRound
       
   161 local RoundHasChanged = true
       
   162 
   157 
   163 -- for script parameters
   158 -- for script parameters
   164 -- NOTE: If you change this, also change the default “Space Invasion” game scheme
   159 -- NOTE: If you change this, also change the default “Space Invasion” game scheme
   165 local startBarrels = 5		-- "barrels"
   160 SI.startBarrels = 5		-- "barrels"
   166 local startShield = 30		-- "shield"
   161 SI.startShield = 30		-- "shield"
   167 local startRadShots = 2		-- "pings"
   162 SI.startRadShots = 2		-- "pings"
   168 local shieldBonus = 30		-- "shieldbonus"
   163 SI.shieldBonus = 30		-- "shieldbonus"
   169 local barrelBonus = 3		-- "barrelbonus"
   164 SI.barrelBonus = 3		-- "barrelbonus"
   170 local timeBonus = 4		-- "timebonus"
   165 SI.timeBonus = 4		-- "timebonus"
   171 local forceTheme = true		-- "forcetheme"
   166 SI.forceTheme = true		-- "forcetheme"
   172 
   167 
   173 --------------------------
   168 --------------------------
   174 -- hog and team tracking variales
   169 -- hog and team tracking variales
   175 --------------------------
   170 --------------------------
   176 
   171 
   177 local numhhs = 0
   172 SI.numhhs = 0
   178 local hhs = {}
   173 SI.hhs = {}
   179 
   174 
   180 local numTeams
   175 SI.numTeams = 0
   181 local teamNameArr = {}
   176 SI.teamNameArr = {}
   182 local teamClan = {}
   177 SI.teamClan = {}
   183 local teamSize = {}
   178 SI.teamSize = {}
   184 local teamIndex = {}
   179 SI.teamIndex = {}
   185 
   180 
   186 local teamScore = {}
   181 SI.teamScore = {}
   187 local teamCircsKilled = {}
   182 SI.teamCircsKilled = {}
   188 local teamSurfer = {}
   183 SI.teamSurfer = {}
   189 
   184 
   190 -- stats variables
   185 -- stats variables
   191 local roundKills = 0
   186 SI.roundKills = 0
   192 local roundScore = 0
   187 SI.roundScore = 0
   193 local RK = 0
   188 SI.RK = 0
   194 local GK = 0
   189 SI.GK = 0
   195 local BK = 0
   190 SI.BK = 0
   196 local OK = 0
   191 SI.OK = 0
   197 local SK = 0
   192 SI.SK = 0
   198 local shieldMiser = true
   193 SI.shieldMiser = true
   199 local fierceComp = false
   194 SI.fierceComp = false
   200 local chainCounter = 0
   195 SI.chainCounter = 0
   201 local chainLength = 0
   196 SI.chainLength = 0
   202 local shotsFired = 0
   197 SI.shotsFired = 0
   203 local shotsHit = 0
   198 SI.shotsHit = 0
   204 local sniperHits = 0
   199 SI.sniperHits = 0
   205 local pointBlankHits = 0
   200 SI.pointBlankHits = 0
   206 
   201 
   207 ---------------------
   202 ---------------------
   208 -- awards (for stats section, just for fun)
   203 -- awards (for stats section, just for fun)
   209 ---------------------
   204 ---------------------
   210 -- global awards
   205 -- global awards
   211 local awardTotalKills=0	-- overall killed invaders (min. 30)
   206 SI.awardTotalKills=0	-- overall killed invaders (min. 30)
   212 
   207 
   213 -- hog awards
   208 -- hog awards
   214 local awardRoundScore	-- hog with most score in 1 round (min. 50)
   209 SI.awardRoundScore = nil	-- hog with most score in 1 round (min. 50)
   215 local awardRoundKills	-- most kills in 1 round (min. 5)
   210 SI.awardRoundKills = nil	-- most kills in 1 round (min. 5)
   216 local awardAccuracy	-- awarded to hog who didn’t miss once in his round, with most kills (min. 5)
   211 SI.awardAccuracy = nil	-- awarded to hog who didn’t miss once in his round, with most kills (min. 5)
   217 local awardCombo	-- hog with longest combo (min. 5)
   212 SI.awardCombo = nil	-- hog with longest combo (min. 5)
   218 
   213 
   219 
   214 
   220 
   215 
   221 -- Taunt trackers
   216 -- Taunt trackers
   222 local tauntTimer = -1
   217 SI.tauntTimer = -1
   223 local tauntGear = nil
   218 SI.tauntGear = nil
   224 local tauntSound = nil
   219 SI.tauntSound = nil
   225 local tauntClanShots = 0 -- hogs of same clans shot in this turn
   220 SI.tauntClanShots = 0 -- hogs of same clans shot in this turn
   226 
   221 
   227 ---------------------
   222 ---------------------
   228 -- tumbler goods
   223 -- tumbler goods
   229 ---------------------
   224 ---------------------
   230 
   225 
   231 local moveTimer = 0
   226 SI.moveTimer = 0
   232 local leftOn = false
   227 SI.leftOn = false
   233 local rightOn = false
   228 SI.rightOn = false
   234 local upOn = false
   229 SI.upOn = false
   235 local downOn = false
   230 SI.downOn = false
   236 
   231 
   237 ----------------
   232 ----------------
   238 -- TUMBLER
   233 -- TUMBLER
   239 local wep = {}
   234 SI.wep = {}
   240 local wepAmmo = {}
   235 SI.wepAmmo = {}
   241 local wepIndex = 0
   236 SI.wepIndex = 0
   242 local wepCount = 0
   237 SI.wepCount = 0
   243 ----------------
   238 ----------------
   244 
   239 
   245 
   240 
   246 
   241 
   247 local primShotsMax = 5
   242 SI.primShotsMax = 5
   248 local primShotsLeft = 0
   243 SI.primShotsLeft = 0
   249 
   244 
   250 local TimeLeftCounter = 0
   245 SI.TimeLeftCounter = 0
   251 local TimeLeft = 0
   246 SI.TimeLeft = 0
   252 local stopMovement = false
   247 SI.stopMovement = false
   253 local tumbleStarted = false
   248 SI.tumbleStarted = false
   254 
   249 
   255 local beam = false
   250 SI.beam = false
   256 local pShield
   251 SI.pShield = nil
   257 local shieldHealth
   252 SI.shieldHealth = 0
   258 
   253 
   259 local timer100 = 0
   254 SI.timer100 = 0
   260 
   255 
   261 local vTag = {}
   256 SI.vTag = {}
   262 
   257 
   263 -----------------------------------------------
   258 -----------------------------------------------
   264 -- CIRCLY GOODIES
   259 -- CIRCLY GOODIES
   265 -----------------------------------------------
   260 -----------------------------------------------
   266 
   261 
   267 local circlesAreGo = false
   262 SI.circlesAreGo = false
   268 local playerIsFine = true
   263 SI.playerIsFine = true
   269 local targetHit = false
   264 SI.targetHit = false
   270 
   265 
   271 local fadeAlpha = 0 -- used to fade the circles out gracefully when player dies
   266 SI.fadeAlpha = 0 -- used to fade the circles out gracefully when player dies
   272 local pTimer = 0 -- tracking projectiles following player
   267 SI.pTimer = 0 -- tracking projectiles following player
   273 
   268 
   274 local circAdjustTimer = 0		-- handle adjustment of circs direction
   269 SI.circAdjustTimer = 0		-- handle adjustment of circs direction
   275 local m2Count = 0		-- handle speed of circs
   270 SI.m2Count = 0		-- handle speed of circs
   276 
   271 
   277 local vCirc = {}
   272 SI.vCirc = {}
   278 local vCCount = 0
   273 SI.vCCount = 0
   279 
   274 
   280 local rCirc = {}
   275 SI.rCirc = {}
   281 local rCircX = {}
   276 SI.rCircX = {}
   282 local rCircY = {}
   277 SI.rCircY = {}
   283 local rAlpha = 255
   278 SI.rAlpha = 255
   284 local rPingTimer = 0
   279 SI.rPingTimer = 0
   285 local radShotsLeft = 0
   280 SI.radShotsLeft = 0
   286 
   281 
   287 local vCircActive = {}
   282 SI.vCircActive = {}
   288 local vCircHealth = {}
   283 SI.vCircHealth = {}
   289 local vType = {}
   284 SI.vType = {}
   290 local vCounter = {}		-- how often this circ gets to "fire" etc
   285 SI.vCounter = {}		-- how often this circ gets to "fire" etc
   291 local vCounterLim = {} -- when vCounter == vCounterLim circle performs its special
   286 SI.vCounterLim = {} -- when SI.vCounter == SI.vCounterLim circle performs its special
   292 local vCircScore = {} -- how many points killing this invader gives
   287 SI.vCircScore = {} -- how many points killing this invader gives
   293 
   288 
   294 local vCircRadMax = {}
   289 SI.vCircRadMax = {}
   295 local vCircRadMin = {}
   290 SI.vCircRadMin = {}
   296 local vCircRadDir = {}
   291 SI.vCircRadDir = {}
   297 local vCircRadCounter = {}
   292 SI.vCircRadCounter = {}
   298 
   293 
   299 local vCircDX = {}
   294 SI.vCircDX = {}
   300 local vCircDY = {}
   295 SI.vCircDY = {}
   301 
   296 
   302 local vCircX = {}
   297 SI.vCircX = {}
   303 local vCircY = {}
   298 SI.vCircY = {}
   304 local vCircMinA = {}
   299 SI.vCircMinA = {}
   305 local vCircMaxA = {}
   300 SI.vCircMaxA = {}
   306 local vCircType = {}
   301 SI.vCircType = {}
   307 local vCircPulse = {}
   302 SI.vCircPulse = {}
   308 local vCircFuckAll = {}
   303 SI.vCircFuckAll = {}
   309 local vCircRadius = {}
   304 SI.vCircRadius = {}
   310 local vCircWidth = {}
   305 SI.vCircWidth = {}
   311 local vCircCol = {}
   306 SI.vCircCol = {}
   312 
   307 
   313 -- Colors
   308 -- Colors
   314 -- Invaders
   309 -- Invaders
   315 local colorDrone = 0xFF0000FF
   310 SI.colorDrone = 0xFF0000FF
   316 local colorBoss = 0x0050FFFF
   311 SI.colorBoss = 0x0050FFFF
   317 local colorBossParticle = colorBoss
   312 SI.colorBossParticle = SI.colorBoss
   318 local colorAmmo = 0x00FF00FF
   313 SI.colorAmmo = 0x00FF00FF
   319 local colorShield = 0xA800FFFF
   314 SI.colorShield = 0xA800FFFF
   320 local colorShieldParticle = colorShield
   315 SI.colorShieldParticle = SI.colorShield
   321 local colorDisabled = 0xFFFFFFFF -- disabled invader at end of turn
   316 SI.colorDisabled = 0xFFFFFFFF -- disabled invader at end of turn
   322 
   317 
   323 -- Other colors
   318 -- Other SI.colors
   324 local colorMsgDepleted = 0xFF0000FF
   319 SI.colorMsgDepleted = 0xFF0000FF
   325 local colorMsgBonus = 0xFFBA00FF
   320 SI.colorMsgBonus = 0xFFBA00FF
   326 local colorTimer = 0xFFEE00FF
   321 SI.colorTimer = 0xFFEE00FF
   327 local colorScore = 0xFFFFFFFF
   322 SI.colorScore = 0xFFFFFFFF
   328 
   323 
   329 -------------------------------------------
   324 -------------------------------------------
   330 -- some lazy copypasta/modified methods
   325 -- some lazy copypasta/modified methods
   331 -------------------------------------------
   326 -------------------------------------------
   332 
   327 
   333 
   328 
   334 
   329 
   335 function HideTag(i)
   330 function HideTag(i)
   336 
   331 
   337 	SetVisualGearValues(vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xFFFFFF00)
   332 	SetVisualGearValues(SI.vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xFFFFFF00)
   338 
   333 
   339 end
   334 end
   340 
   335 
   341 function DrawTag(i)
   336 function DrawTag(i)
   342 
   337 
   343 	local zoomL = 1.3
   338 	local zoomL = 1.3
   344 	local xOffset = 40
   339 	local xOffset = 40
   345 	local yOffset, tValue, tCol
   340 	local yOffset, tValue, tCol
   346 
   341 
   347 	if i == TAG_TIME then
   342 	if i == SI.TAG_TIME then
   348 		yOffset = 40
   343 		yOffset = 40
   349 		tCol = colorTimer
   344 		tCol = SI.colorTimer
   350 		tValue = TimeLeft
   345 		tValue = SI.TimeLeft
   351 	elseif i == TAG_BARRELS then
   346 	elseif i == SI.TAG_BARRELS then
   352 		zoomL = 1.1
   347 		zoomL = 1.1
   353 		yOffset = 70
   348 		yOffset = 70
   354 		tCol = colorAmmo
   349 		tCol = SI.colorAmmo
   355 		tValue = wepAmmo[wepIndex]
   350 		tValue = SI.wepAmmo[SI.wepIndex]
   356 	elseif i == TAG_SHIELD then
   351 	elseif i == SI.TAG_SHIELD then
   357 		zoomL = 1.1
   352 		zoomL = 1.1
   358 		xOffset = 40 + 35
   353 		xOffset = 40 + 35
   359 		yOffset = 70
   354 		yOffset = 70
   360 		tCol = colorShield
   355 		tCol = SI.colorShield
   361 		tValue = shieldHealth - 80
   356 		tValue = SI.shieldHealth - 80
   362 	elseif i == TAG_ROUND_SCORE then
   357 	elseif i == SI.TAG_ROUND_SCORE then
   363 		zoomL = 1.1
   358 		zoomL = 1.1
   364 		xOffset = 40
   359 		xOffset = 40
   365 		yOffset = 100
   360 		yOffset = 100
   366 		tCol = colorScore
   361 		tCol = SI.colorScore
   367 		tValue = roundScore
   362 		tValue = SI.roundScore
   368 	end
   363 	end
   369 
   364 
   370 	DeleteVisualGear(vTag[i])
   365 	DeleteVisualGear(SI.vTag[i])
   371 	vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
   366 	SI.vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
   372 	SetVisualGearValues	(
   367 	SetVisualGearValues	(
   373 				vTag[i], 		--id
   368 				SI.vTag[i], 		--id
   374 				-(div(ScreenWidth, 2)) + xOffset,	--xoffset
   369 				-(div(ScreenWidth, 2)) + xOffset,	--xoffset
   375 				ScreenHeight - yOffset, --yoffset
   370 				ScreenHeight - yOffset, --yoffset
   376 				0, 			--dx
   371 				0, 			--dx
   377 				0, 			--dy
   372 				0, 			--dy
   378 				zoomL, 			--zoom
   373 				zoomL, 			--zoom
   387 
   382 
   388 function RebuildTeamInfo()
   383 function RebuildTeamInfo()
   389 
   384 
   390 	-- make a list of individual team names
   385 	-- make a list of individual team names
   391 	for i = 0, (TeamsCount-1) do
   386 	for i = 0, (TeamsCount-1) do
   392 		teamSize[i] = 0
   387 		SI.teamSize[i] = 0
   393 		teamIndex[i] = 0
   388 		SI.teamIndex[i] = 0
   394 		teamScore[i] = 0
   389 		SI.teamScore[i] = 0
   395 		teamCircsKilled[i] = 0
   390 		SI.teamCircsKilled[i] = 0
   396 		teamSurfer[i] = false
   391 		SI.teamSurfer[i] = false
   397 	end
   392 	end
   398 	numTeams = 0
   393 	SI.numTeams = 0
   399 
   394 
   400 	for i = 0, (numhhs-1) do
   395 	for i = 0, (SI.numhhs-1) do
   401 
   396 
   402 		local z = 0
   397 		local z = 0
   403 		local unfinished = true
   398 		local unfinished = true
   404 		while(unfinished == true) do
   399 		while(unfinished == true) do
   405 
   400 
   406 			local newTeam = true
   401 			local newTeam = true
   407 			local tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name
   402 			local tempHogTeamName = GetHogTeamName(SI.hhs[i]) -- this is the new name
   408 
   403 
   409 			if tempHogTeamName == teamNameArr[z] then
   404 			if tempHogTeamName == SI.teamNameArr[z] then
   410 				newTeam = false
   405 				newTeam = false
   411 				unfinished = false
   406 				unfinished = false
   412 			end
   407 			end
   413 
   408 
   414 			z = z + 1
   409 			z = z + 1
   415 
   410 
   416 			if z == (TeamsCount-1) then
   411 			if z == (TeamsCount-1) then
   417 				unfinished = false
   412 				unfinished = false
   418 				if newTeam == true then
   413 				if newTeam == true then
   419 					teamNameArr[numTeams] = tempHogTeamName
   414 					SI.teamNameArr[SI.numTeams] = tempHogTeamName
   420 					numTeams = numTeams + 1
   415 					SI.numTeams = SI.numTeams + 1
   421 				end
   416 				end
   422 			end
   417 			end
   423 
   418 
   424 		end
   419 		end
   425 
   420 
   426 	end
   421 	end
   427 
   422 
   428 	-- find out how many hogs per team, and the index of the first hog in hhs
   423 	-- find out how many hogs per team, and the index of the first hog in SI.hhs
   429 	for i = 0, (TeamsCount-1) do
   424 	for i = 0, (TeamsCount-1) do
   430 
   425 
   431 		for z = 0, (numhhs-1) do
   426 		for z = 0, (SI.numhhs-1) do
   432 			if GetHogTeamName(hhs[z]) == teamNameArr[i] then
   427 			if GetHogTeamName(SI.hhs[z]) == SI.teamNameArr[i] then
   433 				teamClan[i] = GetHogClan(hhs[z])
   428 				SI.teamClan[i] = GetHogClan(SI.hhs[z])
   434 				if teamSize[i] == 0 then
   429 				if SI.teamSize[i] == 0 then
   435 					teamIndex[i] = z -- should give starting index
   430 					SI.teamIndex[i] = z -- should give starting index
   436 				end
   431 				end
   437 				teamSize[i] = teamSize[i] + 1
   432 				SI.teamSize[i] = SI.teamSize[i] + 1
   438 				--add a pointer so this hog appears at i in hhs
   433 				--add a pointer so this hog appears at i in SI.hhs
   439 			end
   434 			end
   440 		end
   435 		end
   441 
   436 
   442 	end
   437 	end
   443 
   438 
   444 	for i=0, TeamsCount-1 do
   439 	for i=0, TeamsCount-1 do
   445 		SetTeamLabel(teamNameArr[i], teamScore[i])
   440 		SetTeamLabel(SI.teamNameArr[i], SI.teamScore[i])
   446 	end
   441 	end
   447 
   442 
   448 end
   443 end
   449 
   444 
   450 -- control
   445 -- control
   451 function AwardPoints(p)
   446 function AwardPoints(p)
   452 	roundScore = roundScore + p
   447 	SI.roundScore = SI.roundScore + p
   453 	DrawTag(TAG_ROUND_SCORE)
   448 	DrawTag(SI.TAG_ROUND_SCORE)
   454 
   449 
   455 	for i = 0,(TeamsCount-1) do
   450 	for i = 0,(TeamsCount-1) do
   456 		if teamClan[i] == GetHogClan(CurrentHedgehog) then
   451 		if SI.teamClan[i] == GetHogClan(CurrentHedgehog) then
   457 			teamScore[i] = teamScore[i] + p
   452 			SI.teamScore[i] = SI.teamScore[i] + p
   458 			SetTeamLabel(teamNameArr[i], teamScore[i])
   453 			SetTeamLabel(SI.teamNameArr[i], SI.teamScore[i])
   459 		end
   454 		end
   460 	end
   455 	end
   461 
   456 
   462 end
   457 end
   463 
   458 
   464 function AwardKills(t)
   459 function AwardKills(t)
   465 
   460 
   466 	roundKills = roundKills + 1
   461 	SI.roundKills = SI.roundKills + 1
   467 
   462 
   468 	for i = 0,(TeamsCount-1) do
   463 	for i = 0,(TeamsCount-1) do
   469 		if teamClan[i] == GetHogClan(CurrentHedgehog) then
   464 		if SI.teamClan[i] == GetHogClan(CurrentHedgehog) then
   470 			teamCircsKilled[i] = teamCircsKilled[i] + 1
   465 			SI.teamCircsKilled[i] = SI.teamCircsKilled[i] + 1
   471 			awardTotalKills = awardTotalKills + 1
   466 			SI.awardTotalKills = SI.awardTotalKills + 1
   472 
   467 
   473 		end
   468 		end
   474 	end
   469 	end
   475 
   470 
   476 end
   471 end
   506 end
   501 end
   507 
   502 
   508 function CommentOnScore()
   503 function CommentOnScore()
   509 	local teamStats = {}
   504 	local teamStats = {}
   510 	for i = 0,(TeamsCount-1) do
   505 	for i = 0,(TeamsCount-1) do
   511 		sdScore[i] = teamScore[i]
   506 		table.insert(teamStats, {score = SI.teamScore[i], kills = SI.teamCircsKilled[i], name = SI.teamNameArr[i]})
   512 		sdKills[i] = teamCircsKilled[i]
       
   513 		sdName[i] = teamNameArr[i]
       
   514 		table.insert(teamStats, {score = teamScore[i], kills = teamCircsKilled[i], name = teamNameArr[i]})
       
   515 	end
   507 	end
   516 
   508 
   517 	local scorecomp = function (v1, v2)
   509 	local scorecomp = function (v1, v2)
   518 		if v1.score > v2.score then
   510 		if v1.score > v2.score then
   519 			return true
   511 			return true
   544 	local entireC = ""
   536 	local entireC = ""
   545 	for i = TeamsCount,1,-1 do
   537 	for i = TeamsCount,1,-1 do
   546 		entireC = entireC .. teamComment[i]
   538 		entireC = entireC .. teamComment[i]
   547 	end
   539 	end
   548 	local statusText, scoreText
   540 	local statusText, scoreText
   549 	if roundNumber >= roundLimit then
   541 	if SI.roundNumber >= SI.roundLimit then
   550 		statusText = loc("Game over!")
   542 		statusText = loc("Game over!")
   551 		scoreText = loc("Final team scores:")
   543 		scoreText = loc("Final team scores:")
   552 	else
   544 	else
   553 		AddCaption(string.format(loc("Rounds complete: %d/%d"), roundNumber, roundLimit), capcolDefault, capgrpMessage)
   545 		AddCaption(string.format(loc("Rounds complete: %d/%d"), SI.roundNumber, SI.roundLimit), capcolDefault, capgrpMessage)
   554 		return
   546 		return
   555 	end
   547 	end
   556 	local displayTime
   548 	local displayTime
   557 	if roundNumber >= roundLimit then
   549 	if SI.roundNumber >= SI.roundLimit then
   558 		displayTime = 20000
   550 		displayTime = 20000
   559 	else
   551 	else
   560 		displayTime = 1
   552 		displayTime = 1
   561 	end
   553 	end
   562 	ShowMission(	loc("Space Invasion"),
   554 	ShowMission(	loc("Space Invasion"),
   563 			statusText,
   555 			statusText,
   564 			string.format(loc("Rounds complete: %d/%d"), roundNumber, roundLimit) .. "| " .. "|" ..
   556 			string.format(loc("Rounds complete: %d/%d"), SI.roundNumber, SI.roundLimit) .. "| " .. "|" ..
   565 			scoreText .. " |" ..entireC, 4, displayTime)
   557 			scoreText .. " |" ..entireC, 4, displayTime)
   566 
   558 
   567 	if roundNumber >= roundLimit then
   559 	if SI.roundNumber >= SI.roundLimit then
   568 		local winnerTeam = teamStats[1].name
   560 		local winnerTeam = teamStats[1].name
   569 		for i = 0, (numhhs-1) do
   561 		for i = 0, (SI.numhhs-1) do
   570 			if GetHogTeamName(hhs[i]) == winnerTeam then
   562 			if GetHogTeamName(SI.hhs[i]) == winnerTeam then
   571 				SetState(hhs[i], bor(GetState(hhs[i]), gstWinner))
   563 				SetState(SI.hhs[i], bor(GetState(SI.hhs[i]), gstWinner))
   572 			end
   564 			end
   573 		end
   565 		end
   574 		AddCaption(string.format(loc("%s wins!"), winnerTeam), capcolDefault, capgrpGameState)
   566 		AddCaption(string.format(loc("%s wins!"), winnerTeam), capcolDefault, capgrpGameState)
   575 		SendStat(siGameResult, string.format(loc("%s wins!"), winnerTeam))
   567 		SendStat(siGameResult, string.format(loc("%s wins!"), winnerTeam))
   576 
   568 
   590 
   582 
   591 --[[ Award some awards (just for fun, its for the stats screen only
   583 --[[ Award some awards (just for fun, its for the stats screen only
   592 and has no effect on the score or game outcome. ]]
   584 and has no effect on the score or game outcome. ]]
   593 		local awardsGiven = 0
   585 		local awardsGiven = 0
   594 	
   586 	
   595 		if awardTotalKills >= 30 then
   587 		if SI.awardTotalKills >= 30 then
   596 			awardsGiven = awardsGiven + 1
   588 			awardsGiven = awardsGiven + 1
   597 			SendStat(siCustomAchievement,
   589 			SendStat(siCustomAchievement,
   598 				string.format(loc("%d invaders have been destroyed in this game."), awardTotalKills))
   590 				string.format(loc("%d invaders have been destroyed in this game."), SI.awardTotalKills))
   599 		end
   591 		end
   600 
   592 
   601 		table.sort(teamStats, killscomp)
   593 		table.sort(teamStats, killscomp)
   602 		local bestKills = teamStats[1].kills
   594 		local bestKills = teamStats[1].kills
   603 		if bestKills > 10 then
   595 		if bestKills > 10 then
   613 			SendStat(siCustomAchievement,
   605 			SendStat(siCustomAchievement,
   614 			string.format(text,
   606 			string.format(text,
   615 	                teamStats[1].name, teamStats[1].kills))
   607 	                teamStats[1].name, teamStats[1].kills))
   616 		end
   608 		end
   617 
   609 
   618 		if awardRoundKills ~= nil then
   610 		if SI.awardRoundKills ~= nil then
   619 			awardsGiven = awardsGiven + 1
   611 			awardsGiven = awardsGiven + 1
   620 			local text
   612 			local text
   621 			if awardRoundKills.value >= 33 then
   613 			if SI.awardRoundKills.value >= 33 then
   622 				text = loc("%s (%s) has been invited to join the Planetary Association of the Hedgehogs, it destroyed a staggering %d invaders in just one round!")
   614 				text = loc("%s (%s) has been invited to join the Planetary Association of the Hedgehogs, it destroyed a staggering %d invaders in just one round!")
   623 			elseif awardRoundKills.value >= 22 then
   615 			elseif SI.awardRoundKills.value >= 22 then
   624 				if awardRoundKills.hogName == "Rambo" then
   616 				if SI.awardRoundKills.hogName == "Rambo" then
   625 					text = loc("The hardships of the war turned %s (%s) into a killing machine: %d invaders destroyed in one round!")
   617 					text = loc("The hardships of the war turned %s (%s) into a killing machine: %d invaders destroyed in one round!")
   626 				else
   618 				else
   627 					text = loc("%s (%s) is Rambo in a hedgehog costume! He destroyed %d invaders in one round.")
   619 					text = loc("%s (%s) is Rambo in a hedgehog costume! He destroyed %d invaders in one round.")
   628 				end
   620 				end
   629 			elseif awardRoundKills.value >= 11 then
   621 			elseif SI.awardRoundKills.value >= 11 then
   630 				text = loc("%s (%s) is addicted to killing: %d invaders destroyed in one round.")
   622 				text = loc("%s (%s) is addicted to killing: %d invaders destroyed in one round.")
   631 			else
   623 			else
   632 				text = loc("%s (%s) destroyed %d invaders in one round.")
   624 				text = loc("%s (%s) destroyed %d invaders in one round.")
   633 			end
   625 			end
   634 			SendStat(siCustomAchievement,
   626 			SendStat(siCustomAchievement,
   635 			string.format(text,
   627 			string.format(text,
   636 			awardRoundKills.hogName, awardRoundKills.teamName, awardRoundKills.value))
   628 			SI.awardRoundKills.hogName, SI.awardRoundKills.teamName, SI.awardRoundKills.value))
   637 		end
   629 		end
   638 		if awardRoundScore ~= nil then
   630 		if SI.awardRoundScore ~= nil then
   639 			awardsGiven = awardsGiven + 1
   631 			awardsGiven = awardsGiven + 1
   640 			local text
   632 			local text
   641 			if awardRoundScore.value >= 300 then
   633 			if SI.awardRoundScore.value >= 300 then
   642 				text = loc("%s (%s) was undoubtedly the very best professional tumbler in this game: %d points in one round!")
   634 				text = loc("%s (%s) was undoubtedly the very best professional tumbler in this game: %d points in one round!")
   643 			elseif awardRoundScore.value >= 250 then
   635 			elseif SI.awardRoundScore.value >= 250 then
   644 				text = loc("%s (%s) struck like a meteor: %d points in only one round!")
   636 				text = loc("%s (%s) struck like a meteor: %d points in only one round!")
   645 			elseif awardRoundScore.value >= 200 then
   637 			elseif SI.awardRoundScore.value >= 200 then
   646 				text = loc("%s (%s) is good at this: %d points in only one round!")
   638 				text = loc("%s (%s) is good at this: %d points in only one round!")
   647 			elseif awardRoundScore.value >= 150 then
   639 			elseif SI.awardRoundScore.value >= 150 then
   648 				text = loc("%s (%s) tumbles like no other: %d points in one round.")
   640 				text = loc("%s (%s) tumbles like no other: %d points in one round.")
   649 			elseif awardRoundScore.value >= 100 then
   641 			elseif SI.awardRoundScore.value >= 100 then
   650 				text = loc("%s (%s) is a tumbleweed: %d points in one round.")
   642 				text = loc("%s (%s) is a tumbleweed: %d points in one round.")
   651 			else
   643 			else
   652 				text = loc("%s (%s) was the best baby tumbler: %d points in one round.")
   644 				text = loc("%s (%s) was the best baby tumbler: %d points in one round.")
   653 			end
   645 			end
   654 			SendStat(siCustomAchievement,
   646 			SendStat(siCustomAchievement,
   655 			string.format(text,
   647 			string.format(text,
   656 			awardRoundScore.hogName, awardRoundScore.teamName, awardRoundScore.value))
   648 			SI.awardRoundScore.hogName, SI.awardRoundScore.teamName, SI.awardRoundScore.value))
   657 		end
   649 		end
   658 		if awardAccuracy ~= nil then
   650 		if SI.awardAccuracy ~= nil then
   659 			awardsGiven = awardsGiven + 1
   651 			awardsGiven = awardsGiven + 1
   660 			local text
   652 			local text
   661 			if awardAccuracy.value >= 20 then
   653 			if SI.awardAccuracy.value >= 20 then
   662 				text = loc("The Society of Perfectionists greets %s (%s): No misses and %d hits in its best round.")
   654 				text = loc("The Society of Perfectionists greets %s (%s): No misses and %d hits in its best round.")
   663 			elseif awardAccuracy.value >= 10 then
   655 			elseif SI.awardAccuracy.value >= 10 then
   664 				text = loc("%s (%s) is a hardened hunter: No misses and %d hits in its best round!")
   656 				text = loc("%s (%s) is a hardened hunter: No misses and %d hits in its best round!")
   665 			else
   657 			else
   666 				text = loc("%s (%s) shot %d invaders and never missed in the best round!")
   658 				text = loc("%s (%s) shot %d invaders and never missed in the best round!")
   667 			end
   659 			end
   668 			SendStat(siCustomAchievement,
   660 			SendStat(siCustomAchievement,
   669 			string.format(text,
   661 			string.format(text,
   670 			awardAccuracy.hogName, awardAccuracy.teamName, awardAccuracy.value))
   662 			SI.awardAccuracy.hogName, SI.awardAccuracy.teamName, SI.awardAccuracy.value))
   671 		end
   663 		end
   672 		if awardCombo ~= nil then
   664 		if SI.awardCombo ~= nil then
   673 			awardsGiven = awardsGiven + 1
   665 			awardsGiven = awardsGiven + 1
   674 			local text
   666 			local text
   675 			if awardCombo.value >= 11 then
   667 			if SI.awardCombo.value >= 11 then
   676 				text = loc("%s (%s) was lightning-fast! Longest combo of %d, absolutely insane!")
   668 				text = loc("%s (%s) was lightning-fast! Longest combo of %d, absolutely insane!")
   677 			elseif awardCombo.value >= 8 then
   669 			elseif SI.awardCombo.value >= 8 then
   678 				text = loc("%s (%s) gave short shrift to the invaders: Longest combo of %d!")
   670 				text = loc("%s (%s) gave short shrift to the invaders: Longest combo of %d!")
   679 			else
   671 			else
   680 				text = loc("%s (%s) was on fire: Longest combo of %d.")
   672 				text = loc("%s (%s) was on fire: Longest combo of %d.")
   681 			end
   673 			end
   682 			SendStat(siCustomAchievement,
   674 			SendStat(siCustomAchievement,
   683 			string.format(text,
   675 			string.format(text,
   684 			awardCombo.hogName, awardCombo.teamName, awardCombo.value))
   676 			SI.awardCombo.hogName, SI.awardCombo.teamName, SI.awardCombo.value))
   685 		end
   677 		end
   686 		if awardsGiven == 0 then
   678 		if awardsGiven == 0 then
   687 			local text
   679 			local text
   688 			local r = math.random(1,4)
   680 			local r = math.random(1,4)
   689 			if r == 1 then text = loc("This game wasn’t really exciting.")
   681 			if r == 1 then text = loc("This game wasn’t really exciting.")
   696 		end
   688 		end
   697 	end
   689 	end
   698 end
   690 end
   699 
   691 
   700 function onNewRound()
   692 function onNewRound()
   701 	roundNumber = roundNumber + 1
   693 	SI.roundNumber = SI.roundNumber + 1
   702 
   694 
   703 	CommentOnScore()
   695 	CommentOnScore()
   704 
   696 
   705 	-- end game if its at round limit
   697 	-- end game if its at round limit
   706 	if roundNumber >= roundLimit then
   698 	if SI.roundNumber >= SI.roundLimit then
   707 
   699 
   708 		for i = 0, (TeamsCount-1) do
   700 		for i = 0, (TeamsCount-1) do
   709 			if teamScore[i] > bestScore then
   701 			if SI.teamScore[i] > SI.bestScore then
   710 				bestScore = teamScore[i]
   702 				SI.bestScore = SI.teamScore[i]
   711 				bestClan = teamClan[i]
   703 				SI.bestClan = SI.teamClan[i]
   712 			end
   704 			end
   713 		end
   705 		end
   714 
   706 
   715 		-- Kill off all the losers
   707 		-- Kill off all the losers
   716 		for i = 0, (numhhs-1) do
   708 		for i = 0, (SI.numhhs-1) do
   717 			if GetHogClan(hhs[i]) ~= bestClan then
   709 			if GetHogClan(SI.hhs[i]) ~= SI.bestClan then
   718 				SetEffect(hhs[i], heResurrectable, 0)
   710 				SetEffect(SI.hhs[i], heResurrectable, 0)
   719 				SetHealth(hhs[i],0)
   711 				SetHealth(SI.hhs[i],0)
   720 			end
   712 			end
   721 		end
   713 		end
   722 
   714 
   723 		-- Game over
   715 		-- Game over
   724 		gameOver = true
   716 		SI.gameOver = true
   725 		EndTurn(true)
   717 		EndTurn(true)
   726 		TimeLeft = 0
   718 		SI.TimeLeft = 0
   727 		SendStat(siGraphTitle, loc("Score graph"))
   719 		SendStat(siGraphTitle, loc("Score graph"))
   728 	end
   720 	end
   729 end
   721 end
   730 
   722 
   731 -- gaudy racer
   723 -- gaudy racer
   732 function CheckForNewRound()
   724 function CheckForNewRound()
   733 
   725 
   734 	if GetHogClan(CurrentHedgehog) == firstClan then
   726 	if GetHogClan(CurrentHedgehog) == SI.firstClan then
   735 		onNewRound()
   727 		onNewRound()
   736 	end
   728 	end
   737 
   729 
   738 end
   730 end
   739 
   731 
   757 function setNewGearValues(gear)
   749 function setNewGearValues(gear)
   758 
   750 
   759 	local lfs
   751 	local lfs
   760 	if GetGearType(gear) == gtShell then
   752 	if GetGearType(gear) == gtShell then
   761 		lfs = 50	-- roughly 5 seconds
   753 		lfs = 50	-- roughly 5 seconds
   762 		shellID = shellID + 1
   754 		SI.shellID = SI.shellID + 1
   763 		setGearValue(gear,"ID",shellID)
   755 		setGearValue(gear,"ID",SI.shellID)
   764 	elseif GetGearType(gear) == gtBall then
   756 	elseif GetGearType(gear) == gtBall then
   765 		lfs = 5 --70	-- 7s
   757 		lfs = 5 --70	-- 7s
   766 	elseif GetGearType(gear) == gtExplosives then
   758 	elseif GetGearType(gear) == gtExplosives then
   767 		lfs = 15	-- 1.5s
   759 		lfs = 15	-- 1.5s
   768 		explosivesID = explosivesID + 1
   760 		SI.explosivesID = SI.explosivesID + 1
   769 		setGearValue(gear,"ID",explosivesID)
   761 		setGearValue(gear,"ID",SI.explosivesID)
   770 		setGearValue(gear,"XP", GetX(gear))
   762 		setGearValue(gear,"XP", GetX(gear))
   771 		setGearValue(gear,"YP", GetY(gear))
   763 		setGearValue(gear,"YP", GetY(gear))
   772 	elseif GetGearType(gear) == gtFlame then
   764 	elseif GetGearType(gear) == gtFlame then
   773 		lfs = 5	-- 0.5s
   765 		lfs = 5	-- 0.5s
   774 	else
   766 	else
   821 -- action keys
   813 -- action keys
   822 -----------------------
   814 -----------------------
   823 
   815 
   824 function ChangeWeapon()
   816 function ChangeWeapon()
   825 
   817 
   826 	wepIndex = wepIndex + 1
   818 	SI.wepIndex = SI.wepIndex + 1
   827 	if wepIndex == wepCount then
   819 	if SI.wepIndex == SI.wepCount then
   828 		wepIndex = 0
   820 		SI.wepIndex = 0
   829 	end
   821 	end
   830 	AddCaption(wep[wepIndex], GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmoinfo)
   822 	AddCaption(SI.wep[SI.wepIndex], GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmoinfo)
   831 end
   823 end
   832 
   824 
   833 -- derp tumbler
   825 -- derp tumbler
   834 function onPrecise()
   826 function onPrecise()
   835 
   827 
   836 	if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and (wepAmmo[wepIndex] > 0) then
   828 	if (CurrentHedgehog ~= nil) and (SI.stopMovement == false) and (SI.tumbleStarted == true) and (SI.wepAmmo[SI.wepIndex] > 0) then
   837 
   829 
   838 		wepAmmo[wepIndex] = wepAmmo[wepIndex] - 1
   830 		SI.wepAmmo[SI.wepIndex] = SI.wepAmmo[SI.wepIndex] - 1
   839 
   831 
   840 		if wep[wepIndex] == loc("Barrel Launcher") then
   832 		if SI.wep[SI.wepIndex] == loc("Barrel Launcher") then
   841 			shotsFired = shotsFired +1
   833 			SI.shotsFired = SI.shotsFired +1
   842 
   834 
   843 			local morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
   835 			local morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
   844 			CopyPV(CurrentHedgehog, morte)
   836 			CopyPV(CurrentHedgehog, morte)
   845 			local x,y = GetGearVelocity(morte)
   837 			local x,y = GetGearVelocity(morte)
   846 			x = x*2
   838 			x = x*2
   847 			y = y*2
   839 			y = y*2
   848 			SetGearVelocity(morte, x, y)
   840 			SetGearVelocity(morte, x, y)
   849 
   841 
   850 			if wepAmmo[wepIndex] == 0 then
   842 			if SI.wepAmmo[SI.wepIndex] == 0 then
   851 				PlaySound(sndSuddenDeath)
   843 				PlaySound(sndSuddenDeath)
   852 				AddCaption(loc("Ammo depleted!"),colorMsgDepleted,capgrpAmmostate)
   844 				AddCaption(loc("Ammo depleted!"),SI.colorMsgDepleted,capgrpAmmostate)
   853 			else
   845 			else
   854 				PlaySound(sndThrowRelease)
   846 				PlaySound(sndThrowRelease)
   855 			end
   847 			end
   856 			DrawTag(TAG_BARRELS)
   848 			DrawTag(SI.TAG_BARRELS)
   857 
   849 
   858 		elseif wep[wepIndex] == loc("Mine Deployer") then
   850 		elseif SI.wep[SI.wepIndex] == loc("Mine Deployer") then
   859 			local morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtAirBomb, 0, 0, 0, 0)
   851 			local morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtAirBomb, 0, 0, 0, 0)
   860 			SetTimer(morte, 1000)
   852 			SetTimer(morte, 1000)
   861 			DrawTag(TAG_BARRELS)
   853 			DrawTag(SI.TAG_BARRELS)
   862 		end
   854 		end
   863 
   855 
   864 	elseif (wepAmmo[wepIndex] == 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then
   856 	elseif (SI.wepAmmo[SI.wepIndex] == 0) and (CurrentHedgehog ~= nil) and (SI.stopMovement == false) and (SI.tumbleStarted == true) then
   865 		PlaySound(sndDenied)
   857 		PlaySound(sndDenied)
   866 		AddCaption(loc("Ammo depleted!"),colorMsgDepleted,capgrpAmmostate)
   858 		AddCaption(loc("Ammo depleted!"),SI.colorMsgDepleted,capgrpAmmostate)
   867 	end
   859 	end
   868 
   860 
   869 	preciseOn = true
   861 	SI.preciseOn = true
   870 
   862 
   871 end
   863 end
   872 
   864 
   873 function onPreciseUp()
   865 function onPreciseUp()
   874 	preciseOn = false
   866 	SI.preciseOn = false
   875 end
   867 end
   876 
   868 
   877 function onLJump()
   869 function onLJump()
   878 
   870 
   879 	if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then
   871 	if (CurrentHedgehog ~= nil) and (SI.stopMovement == false) and (SI.tumbleStarted == true) then
   880 		shieldMiser = false
   872 		SI.shieldMiser = false
   881 		if shieldHealth == 80 then
   873 		if SI.shieldHealth == 80 then
   882 			AddCaption(loc("Shield depleted"),colorMsgDepleted,capgrpAmmostate)
   874 			AddCaption(loc("Shield depleted"),SI.colorMsgDepleted,capgrpAmmostate)
   883 			PlaySound(sndDenied)
   875 			PlaySound(sndDenied)
   884 		elseif (beam == false) and (shieldHealth > 80) then
   876 		elseif (SI.beam == false) and (SI.shieldHealth > 80) then
   885 			beam = true
   877 			SI.beam = true
   886 			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 40, 255, 1, 10, 0, 300, 1, colorShield)
   878 			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 40, 255, 1, 10, 0, 300, 1, SI.colorShield)
   887 			AddCaption( string.format(loc("Shield ON: %d power remaining"), shieldHealth - 80), colorShield, capgrpAmmostate)
   879 			AddCaption( string.format(loc("Shield ON: %d power remaining"), SI.shieldHealth - 80), SI.colorShield, capgrpAmmostate)
   888 			PlaySound(sndInvulnerable)
   880 			PlaySound(sndInvulnerable)
   889 		else
   881 		else
   890 			beam = false
   882 			SI.beam = false
   891 			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 0, 0, 1, 10, 0, 0, 0, colorShield)
   883 			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 0, 0, 1, 10, 0, 0, 0, SI.colorShield)
   892 			AddCaption( string.format(loc("Shield OFF: %d power remaining"), shieldHealth - 80), colorShield, capgrpAmmostate)
   884 			AddCaption( string.format(loc("Shield OFF: %d power remaining"), SI.shieldHealth - 80), SI.colorShield, capgrpAmmostate)
   893 		end
   885 		end
   894 	end
   886 	end
   895 end
   887 end
   896 
   888 
   897 function onHJump()
   889 function onHJump()
   898 
   890 
   899 	if (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) and
   891 	if (CurrentHedgehog ~= nil) and (SI.stopMovement == false) and (SI.tumbleStarted == true) and
   900 	(rAlpha == 255) then
   892 	(SI.rAlpha == 255) then
   901 		if radShotsLeft > 0 then
   893 		if SI.radShotsLeft > 0 then
   902 			rPingTimer = 0
   894 			SI.rPingTimer = 0
   903 			rAlpha = 0
   895 			SI.rAlpha = 0
   904 			radShotsLeft = radShotsLeft -1
   896 			SI.radShotsLeft = SI.radShotsLeft -1
   905 			AddCaption(string.format(loc("Pings left: %d"), radShotsLeft),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmostate)
   897 			AddCaption(string.format(loc("Pings left: %d"), SI.radShotsLeft),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmostate)
   906 			-- Play sonar sound
   898 			-- Play sonar sound
   907 			PlaySound(sndJetpackLaunch)
   899 			PlaySound(sndJetpackLaunch)
   908 
   900 
   909 		else
   901 		else
   910 			AddCaption(loc("No radar pings left!"),colorMsgDepleted,capgrpAmmostate)
   902 			AddCaption(loc("No radar pings left!"),SI.colorMsgDepleted,capgrpAmmostate)
   911 			PlaySound(sndDenied)
   903 			PlaySound(sndDenied)
   912 		end
   904 		end
   913 	end
   905 	end
   914 
   906 
   915 end
   907 end
   917 -----------------
   909 -----------------
   918 -- movement keys
   910 -- movement keys
   919 -----------------
   911 -----------------
   920 
   912 
   921 function onLeft()
   913 function onLeft()
   922 	leftOn = true
   914 	SI.leftOn = true
   923 end
   915 end
   924 
   916 
   925 function onRight()
   917 function onRight()
   926 	rightOn = true
   918 	SI.rightOn = true
   927 end
   919 end
   928 
   920 
   929 function onUp()
   921 function onUp()
   930 	upOn = true
   922 	SI.upOn = true
   931 end
   923 end
   932 
   924 
   933 function onDown()
   925 function onDown()
   934 	downOn = true
   926 	SI.downOn = true
   935 end
   927 end
   936 
   928 
   937 function onDownUp()
   929 function onDownUp()
   938 	downOn = false
   930 	SI.downOn = false
   939 end
   931 end
   940 
   932 
   941 function onUpUp()
   933 function onUpUp()
   942 	upOn = false
   934 	SI.upOn = false
   943 end
   935 end
   944 
   936 
   945 function onLeftUp()
   937 function onLeftUp()
   946 	leftOn = false
   938 	SI.leftOn = false
   947 end
   939 end
   948 
   940 
   949 function onRightUp()
   941 function onRightUp()
   950 	rightOn = false
   942 	SI.rightOn = false
   951 end
   943 end
   952 
   944 
   953 --------------------------
   945 --------------------------
   954 -- other event handlers
   946 -- other event handlers
   955 --------------------------
   947 --------------------------
   956 
   948 
   957 function onParameters()
   949 function onParameters()
   958 	parseParams()
   950 	parseParams()
   959 	if params["rounds"] ~= nil then
   951 	if params["rounds"] ~= nil then
   960 		roundLimit = math.floor(tonumber(params["rounds"]))
   952 		SI.roundLimit = math.floor(tonumber(params["rounds"]))
   961 	end
   953 	end
   962 	if params["barrels"] ~= nil then
   954 	if params["barrels"] ~= nil then
   963 		startBarrels = math.floor(tonumber(params["barrels"]))
   955 		SI.startBarrels = math.floor(tonumber(params["barrels"]))
   964 	end
   956 	end
   965 	if params["pings"] ~= nil then
   957 	if params["pings"] ~= nil then
   966 		startRadShots = math.floor(tonumber(params["pings"]))
   958 		SI.startRadShots = math.floor(tonumber(params["pings"]))
   967 	end
   959 	end
   968 	if params["shield"] ~= nil then
   960 	if params["shield"] ~= nil then
   969 		startShield = math.floor(tonumber(params["shield"]))
   961 		SI.startShield = math.floor(tonumber(params["shield"]))
   970 	end
   962 	end
   971 
   963 
   972 	if params["barrelbonus"] ~= nil then
   964 	if params["barrelbonus"] ~= nil then
   973 		barrelBonus = math.floor(tonumber(params["barrelbonus"]))
   965 		SI.barrelBonus = math.floor(tonumber(params["barrelbonus"]))
   974 	end
   966 	end
   975 	if params["shieldbonus"] ~= nil then
   967 	if params["shieldbonus"] ~= nil then
   976 		shieldBonus = math.floor(tonumber(params["shieldbonus"]))
   968 		SI.shieldBonus = math.floor(tonumber(params["shieldbonus"]))
   977 	end
   969 	end
   978 	if params["timebonus"] ~= nil then
   970 	if params["timebonus"] ~= nil then
   979 		timeBonus = math.floor(tonumber(params["timebonus"]))
   971 		SI.timeBonus = math.floor(tonumber(params["timebonus"]))
   980 	end
   972 	end
   981 	if params["forcetheme"] == "false" then
   973 	if params["forcetheme"] == "false" then
   982 		forceTheme = false
   974 		SI.forceTheme = false
   983 	else
   975 	else
   984 		forceTheme = true
   976 		SI.forceTheme = true
   985 	end
   977 	end
   986 end
   978 end
   987 
   979 
   988 function onGameInit()
   980 function onGameInit()
   989 	--[[ Only GameFlags which are listed here are allowed. All other game flags will be discarded.
   981 	--[[ Only GameFlags which are listed here are allowed. All other game flags will be discarded.
  1001 		gfBorder 	-- technically possible, but not very fun to play
   993 		gfBorder 	-- technically possible, but not very fun to play
  1002 		-- any other flag is FORBIDDEN and will be disabled when it is on anyways!
   994 		-- any other flag is FORBIDDEN and will be disabled when it is on anyways!
  1003 
   995 
  1004 	GameFlags = band(GameFlags, allowedFlags)
   996 	GameFlags = band(GameFlags, allowedFlags)
  1005 
   997 
  1006 	if forceTheme then
   998 	if SI.forceTheme then
  1007 		Theme = "EarthRise"
   999 		Theme = "EarthRise"
  1008 	end
  1000 	end
  1009 	CaseFreq = 0
  1001 	CaseFreq = 0
  1010 	HealthCaseProb = 0
  1002 	HealthCaseProb = 0
  1011 	Delay = 1000
  1003 	Delay = 1000
  1012 	SuddenDeathTurns = 50
  1004 	SuddenDeathTurns = 50
  1013 	WaterRise = 0
  1005 	WaterRise = 0
  1014 	HealthDecrease = 0
  1006 	HealthDecrease = 0
  1015 	WorldEdge = weNone
  1007 	WorldEdge = weNone
  1016 
  1008 
  1017 	local tags = { TAG_TIME, TAG_BARRELS, TAG_SHIELD, TAG_ROUND_SCORE }
  1009 	local tags = { SI.TAG_TIME, SI.TAG_BARRELS, SI.TAG_SHIELD, SI.TAG_ROUND_SCORE }
  1018 	for t=1, #tags do
  1010 	for t=1, #tags do
  1019 		vTag[tags[t]] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
  1011 		SI.vTag[tags[t]] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
  1020 		HideTag(tags[t])
  1012 		HideTag(tags[t])
  1021 	end
  1013 	end
  1022 
  1014 
  1023 	wep[0] = loc("Barrel Launcher")
  1015 	SI.wep[0] = loc("Barrel Launcher")
  1024 	wep[1] = loc("Mine Deployer")
  1016 	SI.wep[1] = loc("Mine Deployer")
  1025 	wep[2] = loc("Flamer")
  1017 	SI.wep[2] = loc("Flamer")
  1026 
  1018 
  1027 	wepCount = 3
  1019 	SI.wepCount = 3
  1028 
  1020 
  1029 end
  1021 end
  1030 
  1022 
  1031 function onGameStart()
  1023 function onGameStart()
  1032 	SendGameResultOff()
  1024 	SendGameResultOff()
  1045 				loc("Avoid bazookas, red and blue invaders.") .. "|" ..
  1037 				loc("Avoid bazookas, red and blue invaders.") .. "|" ..
  1046 				loc("Collect the green and purple invaders.") .. "|" ..
  1038 				loc("Collect the green and purple invaders.") .. "|" ..
  1047 				loc("Use the shield to protect yourself from bazookas.") .. "|" ..
  1039 				loc("Use the shield to protect yourself from bazookas.") .. "|" ..
  1048 				" " .. "|" ..
  1040 				" " .. "|" ..
  1049 
  1041 
  1050 				string.format(loc("Round Limit: %d"), roundLimit) .. "|" ..
  1042 				string.format(loc("Round Limit: %d"), SI.roundLimit) .. "|" ..
  1051 				" " .. "|" ..
  1043 				" " .. "|" ..
  1052 
  1044 
  1053 				loc("Movement: [Up], [Down], [Left], [Right]") .. "|" ..
  1045 				loc("Movement: [Up], [Down], [Left], [Right]") .. "|" ..
  1054 				loc("Fire: [Precise]") .. "|" ..
  1046 				loc("Fire: [Precise]") .. "|" ..
  1055 				loc("Toggle Shield: [Long jump]") .. "|" ..
  1047 				loc("Toggle Shield: [Long jump]") .. "|" ..
  1058 				"", 4, 5000
  1050 				"", 4, 5000
  1059 				)
  1051 				)
  1060 
  1052 
  1061 	CreateMeSomeCircles()
  1053 	CreateMeSomeCircles()
  1062 	RebuildTeamInfo() -- control
  1054 	RebuildTeamInfo() -- control
  1063 	lastRound = TotalRounds
       
  1064 
  1055 
  1065 end
  1056 end
  1066 
  1057 
  1067 function onScreenResize()
  1058 function onScreenResize()
  1068 
  1059 
  1069 	-- redraw Tags so that their screen locations are updated
  1060 	-- redraw Tags so that their screen locations are updated
  1070 	if (gameBegun == true) then
  1061 	if (SI.gameBegun == true) then
  1071 		DrawTag(TAG_ROUND_SCORE)
  1062 		DrawTag(SI.TAG_ROUND_SCORE)
  1072 		if (stopMovement == false) then
  1063 		if (SI.stopMovement == false) then
  1073 			DrawTag(TAG_BARRELS)
  1064 			DrawTag(SI.TAG_BARRELS)
  1074 			DrawTag(TAG_SHIELD)
  1065 			DrawTag(SI.TAG_SHIELD)
  1075 			if (tumbleStarted == true) then
  1066 			if (SI.tumbleStarted == true) then
  1076 				DrawTag(TAG_TIME)
  1067 				DrawTag(SI.TAG_TIME)
  1077 			end
  1068 			end
  1078 		end
  1069 		end
  1079 	end
  1070 	end
  1080 
  1071 
  1081 end
  1072 end
  1082 
  1073 
  1083 function onNewTurn()
  1074 function onNewTurn()
  1084 
  1075 
  1085 	radShotsLeft = startRadShots
  1076 	SI.radShotsLeft = SI.startRadShots
  1086 	stopMovement = false
  1077 	SI.stopMovement = false
  1087 	tumbleStarted = false
  1078 	SI.tumbleStarted = false
  1088 	boosterOn = false
  1079 	SI.boosterOn = false
  1089 	beam = false
  1080 	SI.beam = false
  1090 	shieldHealth = startShield + 80 -- 50 = 5 secs, roughly
  1081 	SI.shieldHealth = SI.startShield + 80 -- 50 = 5 secs, roughly
  1091 
  1082 
  1092 	RK = 0
  1083 	SI.RK = 0
  1093 	GK = 0
  1084 	SI.GK = 0
  1094 	BK = 0
  1085 	SI.BK = 0
  1095 	OK = 0
  1086 	SI.OK = 0
  1096 	SK = 0
  1087 	SI.SK = 0
  1097 	roundKills = 0
  1088 	SI.roundKills = 0
  1098 	roundScore = 0
  1089 	SI.roundScore = 0
  1099 	shieldMiser = true
  1090 	SI.shieldMiser = true
  1100 	fierceComp = false
  1091 	SI.fierceComp = false
  1101 	shotsFired = 0
  1092 	SI.shotsFired = 0
  1102 	shotsHit = 0
  1093 	SI.shotsHit = 0
  1103 	sniperHits = 0
  1094 	SI.sniperHits = 0
  1104 	pointBlankHits = 0
  1095 	SI.pointBlankHits = 0
  1105 	chainLength = 0
  1096 	SI.chainLength = 0
  1106 	chainCounter = 0
  1097 	SI.chainCounter = 0
  1107 
  1098 
  1108 	tauntClanShots = 0
  1099 	SI.tauntClanShots = 0
  1109 	tauntTimer = -1
  1100 	SI.tauntTimer = -1
  1110 
  1101 
  1111 	-------------------------
  1102 	-------------------------
  1112 	-- gaudy racer
  1103 	-- gaudy racer
  1113 	-------------------------
  1104 	-------------------------
  1114 	CheckForNewRound()
  1105 	CheckForNewRound()
  1115 
  1106 
  1116 	-- Handle Starting Stage of Game
  1107 	-- Handle Starting Stage of Game
  1117 	if (gameOver == false) and (gameBegun == false) then
  1108 	if (SI.gameOver == false) and (SI.gameBegun == false) then
  1118 		gameBegun = true
  1109 		SI.gameBegun = true
  1119 		roundNumber = 0 -- 0
  1110 		SI.roundNumber = 0 -- 0
  1120 		firstClan = GetHogClan(CurrentHedgehog)
  1111 		SI.firstClan = GetHogClan(CurrentHedgehog)
  1121 	end
  1112 	end
  1122 
  1113 
  1123 	if gameOver == true then
  1114 	if SI.gameOver == true then
  1124 		stopMovement = true
  1115 		SI.stopMovement = true
  1125 		tumbleStarted = false
  1116 		SI.tumbleStarted = false
  1126 		SetMyCircles(false)
  1117 		SetMyCircles(false)
  1127 	end
  1118 	end
  1128 
  1119 
  1129 
  1120 
  1130 	-------
  1121 	-------
  1131 	-- tumbler
  1122 	-- tumbler
  1132 	----
  1123 	----
  1133 
  1124 
  1134 	wepAmmo[0] = startBarrels
  1125 	SI.wepAmmo[0] = SI.startBarrels
  1135 	wepAmmo[1] = startRadShots
  1126 	SI.wepAmmo[1] = SI.startRadShots
  1136 	wepAmmo[2] = 5000
  1127 	SI.wepAmmo[2] = 5000
  1137 	wepIndex = 2
  1128 	SI.wepIndex = 2
  1138 	ChangeWeapon()
  1129 	ChangeWeapon()
  1139 
  1130 
  1140 
  1131 
  1141 	HideTag(TAG_TIME)
  1132 	HideTag(SI.TAG_TIME)
  1142 	if not gameOver then
  1133 	if not SI.gameOver then
  1143 		DrawTag(TAG_BARRELS)
  1134 		DrawTag(SI.TAG_BARRELS)
  1144 		DrawTag(TAG_SHIELD)
  1135 		DrawTag(SI.TAG_SHIELD)
  1145 		DrawTag(TAG_ROUND_SCORE)
  1136 		DrawTag(SI.TAG_ROUND_SCORE)
  1146 	else
  1137 	else
  1147 		HideTag(TAG_BARRELS)
  1138 		HideTag(SI.TAG_BARRELS)
  1148 		HideTag(TAG_SHIELD)
  1139 		HideTag(SI.TAG_SHIELD)
  1149 		HideTag(TAG_ROUND_SCORE)
  1140 		HideTag(SI.TAG_ROUND_SCORE)
  1150 	end
  1141 	end
  1151 
  1142 
  1152 end
  1143 end
  1153 
  1144 
  1154 function ThingsToBeRunOnGears(gear)
  1145 function ThingsToBeRunOnGears(gear)
  1155 
  1146 
  1156 	HandleLifeSpan(gear)
  1147 	HandleLifeSpan(gear)
  1157 	DeleteFarFlungBarrel(gear)
  1148 	DeleteFarFlungBarrel(gear)
  1158 
  1149 
  1159 	if circlesAreGo == true then
  1150 	if SI.circlesAreGo == true then
  1160 		CheckVarious(gear)
  1151 		CheckVarious(gear)
  1161 		ProjectileTrack(gear)
  1152 		ProjectileTrack(gear)
  1162 	end
  1153 	end
  1163 
  1154 
  1164 end
  1155 end
  1165 
  1156 
  1166 function onGearWaterSkip(gear)
  1157 function onGearWaterSkip(gear)
  1167 	if gear == CurrentHedgehog then
  1158 	if gear == CurrentHedgehog then
  1168 
  1159 
  1169 		for i = 0,(TeamsCount-1) do
  1160 		for i = 0,(TeamsCount-1) do
  1170 			if teamClan[i] == GetHogClan(CurrentHedgehog) and (teamSurfer[i] == false) then
  1161 			if SI.teamClan[i] == GetHogClan(CurrentHedgehog) and (SI.teamSurfer[i] == false) then
  1171 				teamSurfer[i] = true
  1162 				SI.teamSurfer[i] = true
  1172 				AddCaption(loc("Surfer! +15 points!"),colorMsgBonus,capgrpMessage)
  1163 				AddCaption(loc("Surfer! +15 points!"),SI.colorMsgBonus,capgrpMessage)
  1173 				AwardPoints(15)
  1164 				AwardPoints(15)
  1174 			end
  1165 			end
  1175 		end
  1166 		end
  1176 
  1167 
  1177 	end
  1168 	end
  1178 end
  1169 end
  1179 
  1170 
  1180 function onGameTick()
  1171 function onGameTick()
  1181 
  1172 
  1182 	luaGameTicks = luaGameTicks + 1
       
  1183 
       
  1184 	HandleCircles()
  1173 	HandleCircles()
  1185 
  1174 
  1186 	timer100 = timer100 + 1
  1175 	SI.timer100 = SI.timer100 + 1
  1187 	if timer100 >= 100 then
  1176 	if SI.timer100 >= 100 then
  1188 		timer100 = 0
  1177 		SI.timer100 = 0
  1189 
  1178 
  1190 		if beam == true then
  1179 		if SI.beam == true then
  1191 			shieldHealth = shieldHealth - 1
  1180 			SI.shieldHealth = SI.shieldHealth - 1
  1192 			if shieldHealth < 80 then
  1181 			if SI.shieldHealth < 80 then
  1193 				shieldHealth = 80
  1182 				SI.shieldHealth = 80
  1194 				beam = false
  1183 				SI.beam = false
  1195 				AddCaption(loc("Shield depleted"),colorMsgDepleted,capgrpAmmostate)
  1184 				AddCaption(loc("Shield depleted"),SI.colorMsgDepleted,capgrpAmmostate)
  1196 				PlaySound(sndMineTick)
  1185 				PlaySound(sndMineTick)
  1197 				PlaySound(sndSwitchHog)
  1186 				PlaySound(sndSwitchHog)
  1198 			end
  1187 			end
  1199 		end
  1188 		end
  1200 
  1189 
  1201 		if tauntTimer > 0 then
  1190 		if SI.tauntTimer > 0 then
  1202 			tauntTimer = tauntTimer - 100
  1191 			SI.tauntTimer = SI.tauntTimer - 100
  1203 			if tauntTimer <= 0 and tumbleStarted and not stopMovement then
  1192 			if SI.tauntTimer <= 0 and SI.tumbleStarted and not SI.stopMovement then
  1204 				PlaySound(tauntSound, tauntGear)
  1193 				PlaySound(SI.tauntSound, SI.tauntGear)
  1205 			end
  1194 			end
  1206 		end
  1195 		end
  1207 
  1196 
  1208 		runOnGears(ThingsToBeRunOnGears)
  1197 		runOnGears(ThingsToBeRunOnGears)
  1209 
  1198 
  1210 		if circlesAreGo == true then
  1199 		if SI.circlesAreGo == true then
  1211 			CheckDistances()
  1200 			CheckDistances()
  1212 		end
  1201 		end
  1213 
  1202 
  1214 		-- white smoke trail as player falls from the sky
  1203 		-- white smoke trail as player falls from the sky
  1215 		if (TimeLeft <= 0) and (stopMovement == true) and (CurrentHedgehog ~= nil) then
  1204 		if (SI.TimeLeft <= 0) and (SI.stopMovement == true) and (CurrentHedgehog ~= nil) then
  1216 			local j,k = GetGearVelocity(CurrentHedgehog)
  1205 			local j,k = GetGearVelocity(CurrentHedgehog)
  1217 			if (j ~= 0) and (k ~= 0) then
  1206 			if (j ~= 0) and (k ~= 0) then
  1218 				AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, false)
  1207 				AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, false)
  1219 			end
  1208 			end
  1220 		end
  1209 		end
  1221 
  1210 
  1222 	end
  1211 	end
  1223 
  1212 
  1224 
  1213 
  1225 	-- start the player tumbling with a boom once their turn has actually begun
  1214 	-- start the player tumbling with a boom once their turn has actually begun
  1226 	if (tumbleStarted == false) and (gameOver == false) then
  1215 	if (SI.tumbleStarted == false) and (SI.gameOver == false) then
  1227 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
  1216 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
  1228 			tumbleStarted = true
  1217 			SI.tumbleStarted = true
  1229 			TimeLeft = (TurnTime/1000)
  1218 			SI.TimeLeft = (TurnTime/1000)
  1230 			fadeAlpha = 0
  1219 			SI.fadeAlpha = 0
  1231 			rAlpha = 255
  1220 			SI.rAlpha = 255
  1232 			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
  1221 			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
  1233 			DrawTag(TAG_TIME)
  1222 			DrawTag(SI.TAG_TIME)
  1234 			DrawTag(TAG_BARRELS)
  1223 			DrawTag(SI.TAG_BARRELS)
  1235 			DrawTag(TAG_SHIELD)
  1224 			DrawTag(SI.TAG_SHIELD)
  1236 			DrawTag(TAG_ROUND_SCORE)
  1225 			DrawTag(SI.TAG_ROUND_SCORE)
  1237 			SetMyCircles(true)
  1226 			SetMyCircles(true)
  1238 		end
  1227 		end
  1239 	end
  1228 	end
  1240 
  1229 
  1241 	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
  1230 	if (CurrentHedgehog ~= nil) and (SI.tumbleStarted == true) then
  1242 
  1231 
  1243 		-- Calculate and display turn time
  1232 		-- Calculate and display turn time
  1244 		TimeLeftCounter = TimeLeftCounter + 1
  1233 		SI.TimeLeftCounter = SI.TimeLeftCounter + 1
  1245 		if TimeLeftCounter == 1000 then
  1234 		if SI.TimeLeftCounter == 1000 then
  1246 			TimeLeftCounter = 0
  1235 			SI.TimeLeftCounter = 0
  1247 			TimeLeft = TimeLeft - 1
  1236 			SI.TimeLeft = SI.TimeLeft - 1
  1248 
  1237 
  1249 			if TimeLeft >= 0 then
  1238 			if SI.TimeLeft >= 0 then
  1250 				DrawTag(TAG_TIME)
  1239 				DrawTag(SI.TAG_TIME)
  1251 			end
  1240 			end
  1252 
  1241 
  1253 		end
  1242 		end
  1254 
  1243 
  1255 		if (TimeLeftCounter % 1000) == 0 then
  1244 		if (SI.TimeLeftCounter % 1000) == 0 then
  1256 			if TimeLeft == 5 then
  1245 			if SI.TimeLeft == 5 then
  1257 				PlaySound(sndHurry, CurrentHedgehog)
  1246 				PlaySound(sndHurry, CurrentHedgehog)
  1258 			elseif TimeLeft <= 4 and TimeLeft >= 1 then
  1247 			elseif SI.TimeLeft <= 4 and SI.TimeLeft >= 1 then
  1259 				PlaySound(_G["sndCountdown"..TimeLeft])
  1248 				PlaySound(_G["sndCountdown"..SI.TimeLeft])
  1260 			end
  1249 			end
  1261 		end
  1250 		end
  1262 
  1251 
  1263 		-------------------------------
  1252 		-------------------------------
  1264 		-- Player has run out of luck (out of time or hit by gtShell)
  1253 		-- Player has run out of luck (out of time or hit by gtShell)
  1265 		-------------------------------
  1254 		-------------------------------
  1266 		-- checks in FloatyThings
  1255 		-- checks in FloatyThings
  1267 		if PlayerIsFine() == false then
  1256 		if PlayerIsFine() == false then
  1268 			TimeLeft = 0
  1257 			SI.TimeLeft = 0
  1269 		end
  1258 		end
  1270 
  1259 
  1271 		if (TimeLeft == 0) then
  1260 		if (SI.TimeLeft == 0) then
  1272 			if PlayerIsFine() then
  1261 			if PlayerIsFine() then
  1273 				AddCaption(loc("Time's up!"), capcolDefault, capgrpGameState)
  1262 				AddCaption(loc("Time's up!"), capcolDefault, capgrpGameState)
  1274 			end
  1263 			end
  1275 			if (stopMovement == false) then	--time to stop the player
  1264 			if (SI.stopMovement == false) then	--time to stop the player
  1276 				stopMovement = true
  1265 				SI.stopMovement = true
  1277 				boosterOn = false
  1266 				SI.boosterOn = false
  1278 				beam = false
  1267 				SI.beam = false
  1279 				upOn = false
  1268 				SI.upOn = false
  1280 				downOn = false
  1269 				SI.downOn = false
  1281 				leftOn = false
  1270 				SI.leftOn = false
  1282 				rightOn = false
  1271 				SI.rightOn = false
  1283 				SetMyCircles(false)
  1272 				SetMyCircles(false)
  1284 				rAlpha = 255
  1273 				SI.rAlpha = 255
  1285 				FailGraphics()
  1274 				FailGraphics()
  1286 
  1275 
  1287 				if shieldMiser == true then
  1276 				if SI.shieldMiser == true then
  1288 
  1277 
  1289 					local p = (roundKills*3.5) - ((roundKills*3.5)%1) + 2
  1278 					local p = (SI.roundKills*3.5) - ((SI.roundKills*3.5)%1) + 2
  1290 
  1279 
  1291 					AddCaption(string.format(loc("Shield Miser! +%d points!"), p), colorMsgBonus, capgrpAmmoinfo)
  1280 					AddCaption(string.format(loc("Shield Miser! +%d points!"), p), SI.colorMsgBonus, capgrpAmmoinfo)
  1292 					AwardPoints(p)
  1281 					AwardPoints(p)
  1293 				end
  1282 				end
  1294 
  1283 
  1295 				local accuracy = (shotsHit / shotsFired) * 100
  1284 				local accuracy = (SI.shotsHit / SI.shotsFired) * 100
  1296 				if (accuracy >= 80) and (shotsFired > 4) then
  1285 				if (accuracy >= 80) and (SI.shotsFired > 4) then
  1297 					AddCaption(loc("Accuracy Bonus! +15 points"),colorMsgBonus,capgrpAmmostate)
  1286 					AddCaption(loc("Accuracy Bonus! +15 points"),SI.colorMsgBonus,capgrpAmmostate)
  1298 					AwardPoints(15)
  1287 					AwardPoints(15)
  1299 
  1288 
  1300 
  1289 
  1301 					-- special award for no misses
  1290 					-- special award for no misses
  1302 					local award = false
  1291 					local award = false
  1303 					if awardAccuracy == nil then
  1292 					if SI.awardAccuracy == nil then
  1304 						if (shotsHit >= shotsFired) then
  1293 						if (SI.shotsHit >= SI.shotsFired) then
  1305 							award = true
  1294 							award = true
  1306 						end
  1295 						end
  1307 					elseif (shotsHit == shotsFired) and shotsHit > awardAccuracy.value then
  1296 					elseif (SI.shotsHit == SI.shotsFired) and SI.shotsHit > SI.awardAccuracy.value then
  1308 						award = true
  1297 						award = true
  1309 					end
  1298 					end
  1310 					if award then
  1299 					if award then
  1311 						awardAccuracy = {
  1300 						SI.awardAccuracy = {
  1312 							hogName = GetHogName(CurrentHedgehog),
  1301 							hogName = GetHogName(CurrentHedgehog),
  1313 							teamName = GetHogTeamName(CurrentHedgehog),
  1302 							teamName = GetHogTeamName(CurrentHedgehog),
  1314 							value = shotsHit, 
  1303 							value = SI.shotsHit, 
  1315 						}
  1304 						}
  1316 					end
  1305 					end
  1317 		
  1306 		
  1318 				end
  1307 				end
  1319 
  1308 
  1320 				-- other awards
  1309 				-- other awards
  1321 				awardRoundScore = UpdateSimpleAward(awardRoundScore, roundScore, 50)
  1310 				SI.awardRoundScore = UpdateSimpleAward(SI.awardRoundScore, SI.roundScore, 50)
  1322 				awardRoundKills = UpdateSimpleAward(awardRoundKills, roundKills, 5)
  1311 				SI.awardRoundKills = UpdateSimpleAward(SI.awardRoundKills, SI.roundKills, 5)
  1323 
  1312 
  1324 				HideTag(TAG_TIME)
  1313 				HideTag(SI.TAG_TIME)
  1325 				HideTag(TAG_BARRELS)
  1314 				HideTag(SI.TAG_BARRELS)
  1326 				HideTag(TAG_SHIELD)
  1315 				HideTag(SI.TAG_SHIELD)
  1327 
  1316 
  1328 			end
  1317 			end
  1329 		else -- remove this if you want tumbler to fall slowly on death
  1318 		else -- remove this if you want tumbler to fall slowly on death
  1330 		-------------------------------
  1319 		-------------------------------
  1331 		-- Player is still in luck
  1320 		-- Player is still in luck
  1332 		-------------------------------
  1321 		-------------------------------
  1333 
  1322 
  1334 			if chainCounter > 0 then
  1323 			if SI.chainCounter > 0 then
  1335 				chainCounter = chainCounter -1
  1324 				SI.chainCounter = SI.chainCounter -1
  1336 				if chainCounter == 0 then
  1325 				if SI.chainCounter == 0 then
  1337 					chainLength = 0
  1326 					SI.chainLength = 0
  1338 				end
  1327 				end
  1339 			end
  1328 			end
  1340 
  1329 
  1341 			-- handle movement based on IO
  1330 			-- handle movement based on IO
  1342 			moveTimer = moveTimer + 1
  1331 			SI.moveTimer = SI.moveTimer + 1
  1343 			if moveTimer == 100 then -- 100
  1332 			if SI.moveTimer == 100 then -- 100
  1344 				moveTimer = 0
  1333 				SI.moveTimer = 0
  1345 
  1334 
  1346 				---------------
  1335 				---------------
  1347 				-- new trail code
  1336 				-- new trail code
  1348 				---------------
  1337 				---------------
  1349 				-- the trail lets you know you have 5s left to pilot, akin to birdy feathers
  1338 				-- the trail lets you know you have 5s left to pilot, akin to birdy feathers
  1350 				if (TimeLeft <= 5) and (TimeLeft > 0) then							--vgtSmoke
  1339 				if (SI.TimeLeft <= 5) and (SI.TimeLeft > 0) then							--vgtSmoke
  1351 					local tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, false)
  1340 					local tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, false)
  1352 					SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(CurrentHedgehog)) )
  1341 					SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(CurrentHedgehog)) )
  1353 				end
  1342 				end
  1354 				--------------
  1343 				--------------
  1355 				--------------
  1344 				--------------
  1356 
  1345 
  1357 				local dx, dy = GetGearVelocity(CurrentHedgehog)
  1346 				local dx, dy = GetGearVelocity(CurrentHedgehog)
  1358 
  1347 
  1359 				local dxlimit, dylimit
  1348 				local dxlimit, dylimit
  1360 				if boosterOn == true then
  1349 				if SI.boosterOn == true then
  1361 					local tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtDust, 0, false)
  1350 					local tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtDust, 0, false)
  1362 					SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, 1, nil, GetClanColor(GetHogClan(CurrentHedgehog)) )
  1351 					SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, 1, nil, GetClanColor(GetHogClan(CurrentHedgehog)) )
  1363 					dxlimit = 0.8*fMod
  1352 					dxlimit = 0.8*SI.fMod
  1364 					dylimit = 0.8*fMod
  1353 					dylimit = 0.8*SI.fMod
  1365 				else
  1354 				else
  1366 					dxlimit = 0.4*fMod
  1355 					dxlimit = 0.4*SI.fMod
  1367 					dylimit = 0.4*fMod
  1356 					dylimit = 0.4*SI.fMod
  1368 				end
  1357 				end
  1369 
  1358 
  1370 				if dx > dxlimit then
  1359 				if dx > dxlimit then
  1371 					dx = dxlimit
  1360 					dx = dxlimit
  1372 				end
  1361 				end
  1379 				if dy < -dylimit then
  1368 				if dy < -dylimit then
  1380 					dy = -dylimit
  1369 					dy = -dylimit
  1381 				end
  1370 				end
  1382 
  1371 
  1383 
  1372 
  1384 				if leftOn == true then
  1373 				if SI.leftOn == true then
  1385 					dx = dx - 0.1*fMod
  1374 					dx = dx - 0.1*SI.fMod
  1386 				end
  1375 				end
  1387 				if rightOn == true then
  1376 				if SI.rightOn == true then
  1388 					dx = dx + 0.1*fMod
  1377 					dx = dx + 0.1*SI.fMod
  1389 				end
  1378 				end
  1390 
  1379 
  1391 				if upOn == true then
  1380 				if SI.upOn == true then
  1392 					dy = dy - 0.1*fMod
  1381 					dy = dy - 0.1*SI.fMod
  1393 				end
  1382 				end
  1394 				if downOn == true then
  1383 				if SI.downOn == true then
  1395 					dy = dy + 0.1*fMod
  1384 					dy = dy + 0.1*SI.fMod
  1396 				end
  1385 				end
  1397 
  1386 
  1398 				SetGearVelocity(CurrentHedgehog, dx, dy)
  1387 				SetGearVelocity(CurrentHedgehog, dx, dy)
  1399 
  1388 
  1400 			end
  1389 			end
  1407 end
  1396 end
  1408 
  1397 
  1409 function onGearDamage(gear, damage)
  1398 function onGearDamage(gear, damage)
  1410 	if GetGearType(gear) == gtHedgehog and damage >= 60 then
  1399 	if GetGearType(gear) == gtHedgehog and damage >= 60 then
  1411 		if GetHogClan(gear) ~= GetHogClan(CurrentHedgehog) then
  1400 		if GetHogClan(gear) ~= GetHogClan(CurrentHedgehog) then
  1412 			if (fierceComp == false) then
  1401 			if (SI.fierceComp == false) then
  1413 				fierceComp = true
  1402 				SI.fierceComp = true
  1414 				AddCaption(loc("Fierce Competition! +8 points!"),colorMsgBonus,capgrpMessage)
  1403 				AddCaption(loc("Fierce Competition! +8 points!"),SI.colorMsgBonus,capgrpMessage)
  1415 				AwardPoints(8)
  1404 				AwardPoints(8)
  1416 			end
  1405 			end
  1417 
  1406 
  1418 			tauntTimer = 500
  1407 			SI.tauntTimer = 500
  1419 			tauntGear = gear
  1408 			SI.tauntGear = gear
  1420 			local r = math.random(1, 2)
  1409 			local r = math.random(1, 2)
  1421 			if r == 1 then
  1410 			if r == 1 then
  1422 				tauntSound = sndIllGetYou
  1411 				SI.tauntSound = sndIllGetYou
  1423 			else
  1412 			else
  1424 				tauntSound = sndJustYouWait
  1413 				SI.tauntSound = sndJustYouWait
  1425 			end
  1414 			end
  1426 		elseif gear ~= CurrentHedgehog then
  1415 		elseif gear ~= CurrentHedgehog then
  1427 			tauntTimer = 500
  1416 			SI.tauntTimer = 500
  1428 			tauntGear = gear
  1417 			SI.tauntGear = gear
  1429 			if tauntClanShots == 0 then
  1418 			if SI.tauntClanShots == 0 then
  1430 				tauntSound = sndSameTeam
  1419 				SI.tauntSound = sndSameTeam
  1431 			else
  1420 			else
  1432 				tauntSound = sndTraitor
  1421 				SI.tauntSound = sndTraitor
  1433 			end
  1422 			end
  1434 			tauntClanShots = tauntClanShots + 1
  1423 			SI.tauntClanShots = SI.tauntClanShots + 1
  1435 		end
  1424 		end
  1436 	end
  1425 	end
  1437 end
  1426 end
  1438 
  1427 
  1439 function onGearResurrect(gear)
  1428 function onGearResurrect(gear)
  1440 
  1429 
  1441 	-- did I fall into the water? well, that was a stupid thing to do
  1430 	-- did I fall into the water? well, that was a stupid thing to do
  1442 	if gear == CurrentHedgehog then
  1431 	if gear == CurrentHedgehog then
  1443 		TimeLeft = 0
  1432 		SI.TimeLeft = 0
  1444 		playerIsFine = false
  1433 		SI.playerIsFine = false
  1445 	end
  1434 	end
  1446 
  1435 
  1447 end
  1436 end
  1448 
  1437 
  1449 function onGearAdd(gear)
  1438 function onGearAdd(gear)
  1456 	if GetGearType(gear) == gtHedgehog then
  1445 	if GetGearType(gear) == gtHedgehog then
  1457 		SetEffect(gear, heResurrectable, 1)
  1446 		SetEffect(gear, heResurrectable, 1)
  1458 
  1447 
  1459 		-----------
  1448 		-----------
  1460 		-- control
  1449 		-- control
  1461 		hhs[numhhs] = gear
  1450 		SI.hhs[SI.numhhs] = gear
  1462 		numhhs = numhhs + 1
  1451 		SI.numhhs = SI.numhhs + 1
  1463 		-----------
  1452 		-----------
  1464 	end
  1453 	end
  1465 
  1454 
  1466 end
  1455 end
  1467 
  1456 
  1493 
  1482 
  1494 function DoHorribleThings(cUID)
  1483 function DoHorribleThings(cUID)
  1495 
  1484 
  1496 	-- work out the distance to the target
  1485 	-- work out the distance to the target
  1497 	local g1X, g1Y = GetGearPosition(CurrentHedgehog)
  1486 	local g1X, g1Y = GetGearPosition(CurrentHedgehog)
  1498 	local g2X, g2Y = vCircX[cUID], vCircY[cUID]
  1487 	local g2X, g2Y = SI.vCircX[cUID], SI.vCircY[cUID]
  1499 	local q = g1X - g2X
  1488 	local q = g1X - g2X
  1500 	local w = g1Y - g2Y
  1489 	local w = g1Y - g2Y
  1501 	local r = math.sqrt( (q*q) + (w*w) )	--alternate
  1490 	local r = math.sqrt( (q*q) + (w*w) )	--alternate
  1502 
  1491 
  1503 	local opp = w
  1492 	local opp = w
  1514 	local NY = math.sin( math.rad(t) ) * NR
  1503 	local NY = math.sin( math.rad(t) ) * NR
  1515 
  1504 
  1516 	-- displace xy based on where this thing actually is
  1505 	-- displace xy based on where this thing actually is
  1517 
  1506 
  1518 	if r < NR then
  1507 	if r < NR then
  1519 		rCircX[cUID] = g2X
  1508 		SI.rCircX[cUID] = g2X
  1520 	elseif q > 0 then
  1509 	elseif q > 0 then
  1521 		rCircX[cUID] = g1X - NX
  1510 		SI.rCircX[cUID] = g1X - NX
  1522 	else
  1511 	else
  1523 		rCircX[cUID] = g1X + NX
  1512 		SI.rCircX[cUID] = g1X + NX
  1524 	end
  1513 	end
  1525 
  1514 
  1526 	if r < NR then
  1515 	if r < NR then
  1527 		rCircY[cUID] = g2Y
  1516 		SI.rCircY[cUID] = g2Y
  1528 	elseif w > 0 then
  1517 	elseif w > 0 then
  1529 		rCircY[cUID] = g1Y - NY
  1518 		SI.rCircY[cUID] = g1Y - NY
  1530 	else
  1519 	else
  1531 		rCircY[cUID] = g1Y + NY
  1520 		SI.rCircY[cUID] = g1Y + NY
  1532 	end
  1521 	end
  1533 
  1522 
  1534 end
  1523 end
  1535 
  1524 
  1536 function PlayerIsFine()
  1525 function PlayerIsFine()
  1537 	return (playerIsFine)
  1526 	return (SI.playerIsFine)
  1538 end
  1527 end
  1539 
  1528 
  1540 function GetDistFromXYtoXY(a, b, c, d)
  1529 function GetDistFromXYtoXY(a, b, c, d)
  1541 	local q = a - c
  1530 	local q = a - c
  1542 	local w = b - d
  1531 	local w = b - d
  1565 end
  1554 end
  1566 
  1555 
  1567 function CreateMeSomeCircles()
  1556 function CreateMeSomeCircles()
  1568 
  1557 
  1569 	for i = 0, 7 do
  1558 	for i = 0, 7 do
  1570 		vCCount = vCCount +1
  1559 		SI.vCCount = SI.vCCount +1
  1571 		vCirc[i] = AddVisualGear(0,0,vgtCircle,0,true)
  1560 		SI.vCirc[i] = AddVisualGear(0,0,vgtCircle,0,true)
  1572 
  1561 
  1573 		rCirc[i] = AddVisualGear(0,0,vgtCircle,0,true)
  1562 		SI.rCirc[i] = AddVisualGear(0,0,vgtCircle,0,true)
  1574 		rCircX[i] = 0
  1563 		SI.rCircX[i] = 0
  1575 		rCircY[i] = 0
  1564 		SI.rCircY[i] = 0
  1576 
  1565 
  1577 		vCircDX[i] = 0
  1566 		SI.vCircDX[i] = 0
  1578 		vCircDY[i] = 0
  1567 		SI.vCircDY[i] = 0
  1579 
  1568 
  1580 		vType[i] = "generic"
  1569 		SI.vType[i] = "generic"
  1581 		vCounter[i] = 0
  1570 		SI.vCounter[i] = 0
  1582 		vCounterLim[i] = 3000
  1571 		SI.vCounterLim[i] = 3000
  1583 		vCircScore[i] = 0
  1572 		SI.vCircScore[i] = 0
  1584 		vCircHealth[i] = 1
  1573 		SI.vCircHealth[i] = 1
  1585 
  1574 
  1586 		vCircMinA[i] = 80
  1575 		SI.vCircMinA[i] = 80
  1587 		vCircMaxA[i] = 255
  1576 		SI.vCircMaxA[i] = 255
  1588 		vCircType[i] = 1
  1577 		SI.vCircType[i] = 1
  1589 		vCircPulse[i] = 10
  1578 		SI.vCircPulse[i] = 10
  1590 		vCircFuckAll[i] = 0
  1579 		SI.vCircFuckAll[i] = 0
  1591 		vCircRadius[i] = 0
  1580 		SI.vCircRadius[i] = 0
  1592 		vCircWidth[i] = 3
  1581 		SI.vCircWidth[i] = 3
  1593 
  1582 
  1594 		vCircRadMax[i] = 0
  1583 		SI.vCircRadMax[i] = 0
  1595 		vCircRadMin[i] = 0
  1584 		SI.vCircRadMin[i] = 0
  1596 		vCircRadDir[i] = -1
  1585 		SI.vCircRadDir[i] = -1
  1597 		vCircRadCounter[i] = 0
  1586 		SI.vCircRadCounter[i] = 0
  1598 
  1587 
  1599 		vCircX[i], vCircY[i] = 0,0
  1588 		SI.vCircX[i], SI.vCircY[i] = 0,0
  1600 
  1589 
  1601 		vCircCol[i] = 0xFF00FFFF
  1590 		SI.vCircCol[i] = 0xFF00FFFF
  1602 
  1591 
  1603 		SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], vCircMinA[i], vCircMaxA[i], vCircType[i], vCircPulse[i], vCircFuckAll[i], vCircRadius[i], vCircWidth[i], vCircCol[i])
  1592 		SetVisualGearValues(SI.vCirc[i], SI.vCircX[i], SI.vCircY[i], SI.vCircMinA[i], SI.vCircMaxA[i], SI.vCircType[i], SI.vCircPulse[i], SI.vCircFuckAll[i], SI.vCircRadius[i], SI.vCircWidth[i], SI.vCircCol[i])
  1604 
  1593 
  1605 		SetVisualGearValues(rCirc[i], 0, 0, 100, 255, 1, 10, 0, 40, 3, vCircCol[i])
  1594 		SetVisualGearValues(SI.rCirc[i], 0, 0, 100, 255, 1, 10, 0, 40, 3, SI.vCircCol[i])
  1606 
  1595 
  1607 	end
  1596 	end
  1608 
  1597 
  1609 	pShield = AddVisualGear(0,0,vgtCircle,0,true)
  1598 	SI.pShield = AddVisualGear(0,0,vgtCircle,0,true)
  1610 
  1599 
  1611 end
  1600 end
  1612 
  1601 
  1613 function IGotMeASafeXYValue(i)
  1602 function IGotMeASafeXYValue(i)
  1614 
  1603 
  1615 	local acceptibleDistance = 800
  1604 	local acceptibleDistance = 800
  1616 
  1605 
  1617 	vCircX[i] = GetRandom(5000)
  1606 	SI.vCircX[i] = GetRandom(5000)
  1618 	vCircY[i] = GetRandom(2000)
  1607 	SI.vCircY[i] = GetRandom(2000)
  1619 	local dist = GetDistFromGearToXY(CurrentHedgehog, vCircX[i], vCircY[i])
  1608 	local dist = GetDistFromGearToXY(CurrentHedgehog, SI.vCircX[i], SI.vCircY[i])
  1620 	if dist > acceptibleDistance*acceptibleDistance then
  1609 	if dist > acceptibleDistance*acceptibleDistance then
  1621 		return(true)
  1610 		return(true)
  1622 	else
  1611 	else
  1623 		return(false)
  1612 		return(false)
  1624 	end
  1613 	end
  1626 end
  1615 end
  1627 
  1616 
  1628 function CircleDamaged(i)
  1617 function CircleDamaged(i)
  1629 
  1618 
  1630 	local res = ""
  1619 	local res = ""
  1631 	vCircHealth[i] = vCircHealth[i] -1
  1620 	SI.vCircHealth[i] = SI.vCircHealth[i] -1
  1632 
  1621 
  1633 	if vCircHealth[i] <= 0 then
  1622 	if SI.vCircHealth[i] <= 0 then
  1634 	-- circle is dead, do death effects/consequences
  1623 	-- circle is dead, do death effects/consequences
  1635 
  1624 
  1636 		vCircActive[i] = false
  1625 		SI.vCircActive[i] = false
  1637 
  1626 
  1638 		if (vType[i] == "drone") then
  1627 		if (SI.vType[i] == "drone") then
  1639 			PlaySound(sndHellishImpact4)
  1628 			PlaySound(sndHellishImpact4)
  1640 			TimeLeft = TimeLeft + timeBonus
  1629 			SI.TimeLeft = SI.TimeLeft + SI.timeBonus
  1641 			AddCaption(string.format(loc("Time extended! +%dsec"), timeBonus), colorDrone, capgrpMessage )
  1630 			AddCaption(string.format(loc("Time extended! +%dsec"), SI.timeBonus), SI.colorDrone, capgrpMessage )
  1642 			DrawTag(TAG_TIME)
  1631 			DrawTag(SI.TAG_TIME)
  1643 
  1632 
  1644 			local morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1)
  1633 			local morte = AddGear(SI.vCircX[i], SI.vCircY[i], gtExplosives, 0, 0, 0, 1)
  1645 			SetHealth(morte, 0)
  1634 			SetHealth(morte, 0)
  1646 
  1635 
  1647 			RK = RK + 1
  1636 			SI.RK = SI.RK + 1
  1648 			if RK == 5 then
  1637 			if SI.RK == 5 then
  1649 				RK = 0
  1638 				SI.RK = 0
  1650 				AddCaption(loc("Drone Hunter! +10 points!"),colorMsgBonus,capgrpMessage2)
  1639 				AddCaption(loc("Drone Hunter! +10 points!"),SI.colorMsgBonus,capgrpMessage2)
  1651 				AwardPoints(10)
  1640 				AwardPoints(10)
  1652 			end
  1641 			end
  1653 
  1642 
  1654 		elseif (vType[i] == "ammo") then
  1643 		elseif (SI.vType[i] == "ammo") then
  1655 			AddVisualGear(vCircX[i], vCircY[i], vgtExplosion, 0, false)
  1644 			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtExplosion, 0, false)
  1656 			PlaySound(sndExplosion)
  1645 			PlaySound(sndExplosion)
  1657 			PlaySound(sndShotgunReload)
  1646 			PlaySound(sndShotgunReload)
  1658 			wepAmmo[0] = wepAmmo[0] + barrelBonus
  1647 			SI.wepAmmo[0] = SI.wepAmmo[0] + SI.barrelBonus
  1659 			AddCaption(string.format(loc("+%d Ammo"), barrelBonus), colorAmmo,capgrpMessage)
  1648 			AddCaption(string.format(loc("+%d Ammo"), SI.barrelBonus), SI.colorAmmo,capgrpMessage)
  1660 			DrawTag(TAG_BARRELS)
  1649 			DrawTag(SI.TAG_BARRELS)
  1661 
  1650 
  1662 			GK = GK + 1
  1651 			SI.GK = SI.GK + 1
  1663 			if GK == 3 then
  1652 			if SI.GK == 3 then
  1664 				GK = 0
  1653 				SI.GK = 0
  1665 				AddCaption(loc("Ammo Maniac! +5 points!"),colorMsgBonus,capgrpMessage2)
  1654 				AddCaption(loc("Ammo Maniac! +5 points!"),SI.colorMsgBonus,capgrpMessage2)
  1666 				AwardPoints(5)
  1655 				AwardPoints(5)
  1667 			end
  1656 			end
  1668 
  1657 
  1669 		elseif (vType[i] == "bonus") then
  1658 		elseif (SI.vType[i] == "bonus") then
  1670 
  1659 
  1671 			AddVisualGear(vCircX[i], vCircY[i], vgtExplosion, 0, false)
  1660 			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtExplosion, 0, false)
  1672 			PlaySound(sndExplosion)
  1661 			PlaySound(sndExplosion)
  1673 
  1662 
  1674 			AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false)
  1663 			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtFire, 0, false)
  1675 			AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false)
  1664 			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtFire, 0, false)
  1676 			AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false)
  1665 			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtFire, 0, false)
  1677 			AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false)
  1666 			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtFire, 0, false)
  1678 			AddVisualGear(vCircX[i], vCircY[i], vgtFire, 0, false)
  1667 			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtFire, 0, false)
  1679 			AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, false)
  1668 			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtSmoke, 0, false)
  1680 
  1669 
  1681 			PlaySound(sndVaporize)
  1670 			PlaySound(sndVaporize)
  1682 
  1671 
  1683 			shieldHealth = shieldHealth + shieldBonus
  1672 			SI.shieldHealth = SI.shieldHealth + SI.shieldBonus
  1684 			if shieldHealth >= 250 then
  1673 			if SI.shieldHealth >= 250 then
  1685 				shieldHealth = 250
  1674 				SI.shieldHealth = 250
  1686 				AddCaption(loc("Shield is fully recharged!"),colorShield,capgrpMessage)
  1675 				AddCaption(loc("Shield is fully recharged!"),SI.colorShield,capgrpMessage)
  1687 			else
  1676 			else
  1688 				AddCaption(string.format(loc("Shield boosted! +%d power"),shieldBonus), colorShield,capgrpMessage)
  1677 				AddCaption(string.format(loc("Shield boosted! +%d power"),SI.shieldBonus), SI.colorShield,capgrpMessage)
  1689 			end
  1678 			end
  1690 			DrawTag(TAG_SHIELD)
  1679 			DrawTag(SI.TAG_SHIELD)
  1691 
  1680 
  1692 			OK = OK + 1
  1681 			SI.OK = SI.OK + 1
  1693 			if OK == 3 then
  1682 			if SI.OK == 3 then
  1694 				OK = 0
  1683 				SI.OK = 0
  1695 				AddCaption(loc("Shield Seeker! +10 points!"),colorShield,capgrpMessage2)
  1684 				AddCaption(loc("Shield Seeker! +10 points!"),SI.colorShield,capgrpMessage2)
  1696 				AwardPoints(10)
  1685 				AwardPoints(10)
  1697 			end
  1686 			end
  1698 
  1687 
  1699 		elseif (vType[i] == "blueboss") then
  1688 		elseif (SI.vType[i] == "blueboss") then
  1700 			PlaySound(sndHellishImpact3)
  1689 			PlaySound(sndHellishImpact3)
  1701 			tauntTimer = 300
  1690 			SI.tauntTimer = 300
  1702 			tauntSound = sndEnemyDown
  1691 			SI.tauntSound = sndEnemyDown
  1703 			tauntGear = CurrentHedgehog
  1692 			SI.tauntGear = CurrentHedgehog
  1704 			AddCaption(loc("Boss defeated! +30 points!"), colorBoss,capgrpMessage)
  1693 			AddCaption(loc("Boss defeated! +30 points!"), SI.colorBoss,capgrpMessage)
  1705 
  1694 
  1706 			local morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1)
  1695 			local morte = AddGear(SI.vCircX[i], SI.vCircY[i], gtExplosives, 0, 0, 0, 1)
  1707 			SetHealth(morte, 0)
  1696 			SetHealth(morte, 0)
  1708 
  1697 
  1709 			BK = BK + 1
  1698 			SI.BK = SI.BK + 1
  1710 			if BK == 2 then
  1699 			if SI.BK == 2 then
  1711 				BK = 0
  1700 				SI.BK = 0
  1712 				AddCaption(loc("Boss Slayer! +25 points!"),colorMsgBonus,capgrpMessage2)
  1701 				AddCaption(loc("Boss Slayer! +25 points!"),SI.colorMsgBonus,capgrpMessage2)
  1713 				AwardPoints(25)
  1702 				AwardPoints(25)
  1714 			end
  1703 			end
  1715 
  1704 
  1716 		end
  1705 		end
  1717 
  1706 
  1718 		AwardPoints(vCircScore[i])
  1707 		AwardPoints(SI.vCircScore[i])
  1719 		AwardKills()
  1708 		AwardKills()
  1720 		SetUpCircle(i)
  1709 		SetUpCircle(i)
  1721 		res = "fatal"
  1710 		res = "fatal"
  1722 
  1711 
  1723 		chainCounter = 3000
  1712 		SI.chainCounter = 3000
  1724 		chainLength = chainLength + 1
  1713 		SI.chainLength = SI.chainLength + 1
  1725 		if chainLength > 1 then
  1714 		if SI.chainLength > 1 then
  1726 			AddCaption( string.format(loc("%d-Hit Combo! +%d points!"), chainLength, chainLength*2),colorMsgBonus,capgrpVolume)
  1715 			AddCaption( string.format(loc("%d-Hit Combo! +%d points!"), SI.chainLength, SI.chainLength*2),SI.colorMsgBonus,capgrpVolume)
  1727 			AwardPoints(chainLength*2)
  1716 			AwardPoints(SI.chainLength*2)
  1728 		end
  1717 		end
  1729 
  1718 
  1730 		awardCombo = UpdateSimpleAward(awardCombo, chainLength, 5)
  1719 		SI.awardCombo = UpdateSimpleAward(SI.awardCombo, SI.chainLength, 5)
  1731 
  1720 
  1732 	else
  1721 	else
  1733 	-- circle is merely damaged
  1722 	-- circle is merely damaged
  1734 	-- do damage effects/sounds
  1723 	-- do damage effects/sounds
  1735 		AddVisualGear(vCircX[i], vCircY[i], vgtSteam, 0, false)
  1724 		AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtSteam, 0, false)
  1736 		local r = math.random(1,4)
  1725 		local r = math.random(1,4)
  1737 		PlaySound(_G["sndHellishImpact" .. tostring(r)])
  1726 		PlaySound(_G["sndHellishImpact" .. tostring(r)])
  1738 		res = "non-fatal"
  1727 		res = "non-fatal"
  1739 
  1728 
  1740 	end
  1729 	end
  1750 	-- 80% of spawning either drone/ammo
  1739 	-- 80% of spawning either drone/ammo
  1751 	if r <= 7 then
  1740 	if r <= 7 then
  1752 
  1741 
  1753 		r = GetRandom(2)
  1742 		r = GetRandom(2)
  1754 		if r == 0 then
  1743 		if r == 0 then
  1755 			vCircCol[i] = colorDrone
  1744 			SI.vCircCol[i] = SI.colorDrone
  1756 			vType[i] = "drone"
  1745 			SI.vType[i] = "drone"
  1757 			vCircRadMin[i] = 50	*5
  1746 			SI.vCircRadMin[i] = 50	*5
  1758 			vCircRadMax[i] = 90	*5
  1747 			SI.vCircRadMax[i] = 90	*5
  1759 			vCounterLim[i] = 3000
  1748 			SI.vCounterLim[i] = 3000
  1760 			vCircScore[i] = 10
  1749 			SI.vCircScore[i] = 10
  1761 			vCircHealth[i] = 1
  1750 			SI.vCircHealth[i] = 1
  1762 		elseif r == 1 then
  1751 		elseif r == 1 then
  1763 			vCircCol[i] = colorAmmo
  1752 			SI.vCircCol[i] = SI.colorAmmo
  1764 			vType[i] = "ammo"
  1753 			SI.vType[i] = "ammo"
  1765 			vCircRadMin[i] = 25	*7
  1754 			SI.vCircRadMin[i] = 25	*7
  1766 			vCircRadMax[i] = 30	*7
  1755 			SI.vCircRadMax[i] = 30	*7
  1767 			vCircScore[i] = 3
  1756 			SI.vCircScore[i] = 3
  1768 			vCircHealth[i] = 1
  1757 			SI.vCircHealth[i] = 1
  1769 		end
  1758 		end
  1770 
  1759 
  1771 	-- 20% chance of spawning boss or bonus
  1760 	-- 20% chance of spawning boss or bonus
  1772 	else
  1761 	else
  1773 		r = GetRandom(5)
  1762 		r = GetRandom(5)
  1774 		if r <= 1 then
  1763 		if r <= 1 then
  1775 			vCircCol[i] = colorBoss
  1764 			SI.vCircCol[i] = SI.colorBoss
  1776 			vType[i] = "blueboss"
  1765 			SI.vType[i] = "blueboss"
  1777 			vCircRadMin[i] = 100*5
  1766 			SI.vCircRadMin[i] = 100*5
  1778 			vCircRadMax[i] = 180*5
  1767 			SI.vCircRadMax[i] = 180*5
  1779 			vCircWidth[i] = 1
  1768 			SI.vCircWidth[i] = 1
  1780 			vCounterLim[i] = 2000
  1769 			SI.vCounterLim[i] = 2000
  1781 			vCircScore[i] = 30
  1770 			SI.vCircScore[i] = 30
  1782 			vCircHealth[i] = 3
  1771 			SI.vCircHealth[i] = 3
  1783 		else
  1772 		else
  1784 			vCircCol[i] = colorShield
  1773 			SI.vCircCol[i] = SI.colorShield
  1785 			vType[i] = "bonus"
  1774 			SI.vType[i] = "bonus"
  1786 			vCircRadMin[i] = 20 *7
  1775 			SI.vCircRadMin[i] = 20 *7
  1787 			vCircRadMax[i] = 40 *7
  1776 			SI.vCircRadMax[i] = 40 *7
  1788 			vCircScore[i] = 5
  1777 			SI.vCircScore[i] = 5
  1789 			vCircHealth[i] = 1
  1778 			SI.vCircHealth[i] = 1
  1790 		end
  1779 		end
  1791 
  1780 
  1792 	end
  1781 	end
  1793 
  1782 
  1794 	-- regenerate circle xy if too close to player or until sanity limit kicks in
  1783 	-- regenerate circle xy if too close to player or until sanity limit kicks in
  1799 		else
  1788 		else
  1800 			reN = 15
  1789 			reN = 15
  1801 		end
  1790 		end
  1802 	end
  1791 	end
  1803 
  1792 
  1804 	vCircRadius[i] = vCircRadMax[i] - GetRandom(vCircRadMin[i])
  1793 	SI.vCircRadius[i] = SI.vCircRadMax[i] - GetRandom(SI.vCircRadMin[i])
  1805 
  1794 
  1806 	SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], nil, nil, nil, nil, nil, vCircRadius[i], vCircWidth[i], vCircCol[i]-0x000000FF)
  1795 	SetVisualGearValues(SI.vCirc[i], SI.vCircX[i], SI.vCircY[i], nil, nil, nil, nil, nil, SI.vCircRadius[i], SI.vCircWidth[i], SI.vCircCol[i]-0x000000FF)
  1807 
  1796 
  1808 	SetVisualGearValues(rCirc[i], 0, 0, nil, nil, nil, nil, nil, nil, nil, vCircCol[i]-0x000000FF)
  1797 	SetVisualGearValues(SI.rCirc[i], 0, 0, nil, nil, nil, nil, nil, nil, nil, SI.vCircCol[i]-0x000000FF)
  1809 
  1798 
  1810 
  1799 
  1811 	vCircActive[i] = true
  1800 	SI.vCircActive[i] = true
  1812 
  1801 
  1813 end
  1802 end
  1814 
  1803 
  1815 function SetMyCircles(s)
  1804 function SetMyCircles(s)
  1816 
  1805 
  1817 	circlesAreGo = s
  1806 	SI.circlesAreGo = s
  1818 	playerIsFine = s
  1807 	SI.playerIsFine = s
  1819 
  1808 
  1820 	for i = 0,(vCCount-1) do
  1809 	for i = 0,(SI.vCCount-1) do
  1821 
  1810 
  1822 		if s == false then
  1811 		if s == false then
  1823 			vCircActive[i] = false
  1812 			SI.vCircActive[i] = false
  1824 		elseif s == true then
  1813 		elseif s == true then
  1825 			SetUpCircle(i)
  1814 			SetUpCircle(i)
  1826 		end
  1815 		end
  1827 
  1816 
  1828 	end
  1817 	end
  1835 		PlaySound(sndExplosion)
  1824 		PlaySound(sndExplosion)
  1836 		local r = math.random(1,3)
  1825 		local r = math.random(1,3)
  1837 		PlaySound(_G["sndOoff"..r], CurrentHedgehog)
  1826 		PlaySound(_G["sndOoff"..r], CurrentHedgehog)
  1838 	end
  1827 	end
  1839 
  1828 
  1840 	playerIsFine = false
  1829 	SI.playerIsFine = false
  1841 	FailGraphics()
  1830 	FailGraphics()
  1842 
  1831 
  1843 	if not kamikaze then
  1832 	if not kamikaze then
  1844 		AddCaption(loc("GOTCHA!"), capcolDefault, capgrpGameState)
  1833 		AddCaption(loc("GOTCHA!"), capcolDefault, capgrpGameState)
  1845 		PlaySound(sndHellish)
  1834 		PlaySound(sndHellish)
  1846 	end
  1835 	end
  1847 
  1836 
  1848 	targetHit = true
  1837 	SI.targetHit = true
  1849 
  1838 
  1850 end
  1839 end
  1851 
  1840 
  1852 -- Turn all circles white to indicate they can't be hit anymore
  1841 -- Turn all circles white to indicate they can't be hit anymore
  1853 function FailGraphics()
  1842 function FailGraphics()
  1854 	for i = 0,(vCCount-1) do
  1843 	for i = 0,(SI.vCCount-1) do
  1855 		vCircCol[i] = colorDisabled
  1844 		SI.vCircCol[i] = SI.colorDisabled
  1856 	end
  1845 	end
  1857 end
  1846 end
  1858 
  1847 
  1859 --- collision detection for weapons fire
  1848 --- collision detection for weapons fire
  1860 function CheckVarious(gear)
  1849 function CheckVarious(gear)
  1861 
  1850 
  1862 	targetHit = false
  1851 	SI.targetHit = false
  1863 
  1852 
  1864 	-- if circle is hit by player fire
  1853 	-- if circle is hit by player fire
  1865 	if (GetGearType(gear) == gtExplosives) then
  1854 	if (GetGearType(gear) == gtExplosives) then
  1866 		local circsHit = 0
  1855 		local circsHit = 0
  1867 
  1856 
  1868 		for i = 0,(vCCount-1) do
  1857 		for i = 0,(SI.vCCount-1) do
  1869 
  1858 
  1870 			local dist = GetDistFromGearToXY(gear, vCircX[i], vCircY[i])
  1859 			local dist = GetDistFromGearToXY(gear, SI.vCircX[i], SI.vCircY[i])
  1871 
  1860 
  1872 			-- calculate my real radius if I am an aura
  1861 			-- calculate my real radius if I am an aura
  1873 			local NR
  1862 			local NR
  1874 			if vCircType[i] == 0 then
  1863 			if SI.vCircType[i] == 0 then
  1875 				NR = vCircRadius[i]
  1864 				NR = SI.vCircRadius[i]
  1876 			else
  1865 			else
  1877 				NR = (48/100*vCircRadius[i])/2
  1866 				NR = (48/100*SI.vCircRadius[i])/2
  1878 			end
  1867 			end
  1879 
  1868 
  1880 			if dist <= NR*NR then
  1869 			if dist <= NR*NR then
  1881 
  1870 
  1882 				dist = (GetDistFromXYtoXY(vCircX[i], vCircY[i], getGearValue(gear,"XP"), getGearValue(gear,"YP")) - (NR*NR))
  1871 				dist = (GetDistFromXYtoXY(SI.vCircX[i], SI.vCircY[i], getGearValue(gear,"XP"), getGearValue(gear,"YP")) - (NR*NR))
  1883 				if dist >= 1000000 then
  1872 				if dist >= 1000000 then
  1884 					sniperHits = sniperHits +1
  1873 					SI.sniperHits = SI.sniperHits +1
  1885 					AddCaption(loc("Sniper! +8 points!"),colorMsgBonus,capgrpAmmostate)
  1874 					AddCaption(loc("Sniper! +8 points!"),SI.colorMsgBonus,capgrpAmmostate)
  1886 					AwardPoints(8)
  1875 					AwardPoints(8)
  1887 					if sniperHits == 3 then
  1876 					if SI.sniperHits == 3 then
  1888 						sniperHits = 0
  1877 						SI.sniperHits = 0
  1889 						AddCaption(loc("They Call Me Bullseye! +16 points!"),colorMsgBonus,capgrpAmmostate)
  1878 						AddCaption(loc("They Call Me Bullseye! +16 points!"),SI.colorMsgBonus,capgrpAmmostate)
  1890 						AwardPoints(16)
  1879 						AwardPoints(16)
  1891 					end
  1880 					end
  1892 				elseif dist <= 6000 then
  1881 				elseif dist <= 6000 then
  1893 					pointBlankHits = pointBlankHits +1
  1882 					SI.pointBlankHits = SI.pointBlankHits +1
  1894 					if pointBlankHits == 3 then
  1883 					if SI.pointBlankHits == 3 then
  1895 						pointBlankHits = 0
  1884 						SI.pointBlankHits = 0
  1896 						AddCaption(loc("Point Blank Combo! +5 points!"),colorMsgBonus,capgrpAmmostate)
  1885 						AddCaption(loc("Point Blank Combo! +5 points!"),SI.colorMsgBonus,capgrpAmmostate)
  1897 						AwardPoints(5)
  1886 						AwardPoints(5)
  1898 					end
  1887 					end
  1899 				end
  1888 				end
  1900 
  1889 
  1901 				AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
  1890 				AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
  1902 
  1891 
  1903 				targetHit = true
  1892 				SI.targetHit = true
  1904 				CircleDamaged(i)
  1893 				CircleDamaged(i)
  1905 
  1894 
  1906 				circsHit = circsHit + 1
  1895 				circsHit = circsHit + 1
  1907 				if circsHit > 1 then
  1896 				if circsHit > 1 then
  1908 					AddCaption(loc("Multi-shot! +15 points!"),colorMsgBonus,capgrpAmmoinfo)
  1897 					AddCaption(loc("Multi-shot! +15 points!"),SI.colorMsgBonus,capgrpAmmoinfo)
  1909 					AwardPoints(15)
  1898 					AwardPoints(15)
  1910 						circsHit = 0
  1899 						circsHit = 0
  1911 				end
  1900 				end
  1912 
  1901 
  1913 				shotsHit = shotsHit + 1
  1902 				SI.shotsHit = SI.shotsHit + 1
  1914 
  1903 
  1915 			end
  1904 			end
  1916 
  1905 
  1917 		end
  1906 		end
  1918 
  1907 
  1919 	-- if player is hit by circle bazooka
  1908 	-- if player is hit by circle bazooka
  1920 	elseif (GetGearType(gear) == gtShell) and (CurrentHedgehog ~= nil) then
  1909 	elseif (GetGearType(gear) == gtShell) and (CurrentHedgehog ~= nil) then
  1921 
  1910 
  1922 		local dist = GetDistFromGearToGear(gear, CurrentHedgehog)
  1911 		local dist = GetDistFromGearToGear(gear, CurrentHedgehog)
  1923 
  1912 
  1924 		if beam == true then
  1913 		if SI.beam == true then
  1925 
  1914 
  1926 			if dist < 3000 then
  1915 			if dist < 3000 then
  1927 				local tempE = AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
  1916 				local tempE = AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
  1928 				SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xFF00FFFF)
  1917 				SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xFF00FFFF)
  1929 				PlaySound(sndVaporize)
  1918 				PlaySound(sndVaporize)
  1930 				DeleteGear(gear)
  1919 				DeleteGear(gear)
  1931 
  1920 
  1932 				SK = SK + 1
  1921 				SI.SK = SI.SK + 1
  1933 				if SK == 5 then
  1922 				if SI.SK == 5 then
  1934 					SK = 0
  1923 					SI.SK = 0
  1935 					AddCaption(loc("Shield Master! +10 points!"),colorMsgBonus,capgrpMessage)
  1924 					AddCaption(loc("Shield Master! +10 points!"),SI.colorMsgBonus,capgrpMessage)
  1936 					AwardPoints(10)
  1925 					AwardPoints(10)
  1937 				end
  1926 				end
  1938 			end
  1927 			end
  1939 
  1928 
  1940 		elseif dist < 1600 then
  1929 		elseif dist < 1600 then
  1941 			WellHeAintGonnaJumpNoMore(GetX(gear), GetY(gear), true)
  1930 			WellHeAintGonnaJumpNoMore(GetX(gear), GetY(gear), true)
  1942 		end
  1931 		end
  1943 
  1932 
  1944 	end
  1933 	end
  1945 
  1934 
  1946 	if targetHit == true then
  1935 	if SI.targetHit == true then
  1947 		DeleteGear(gear)
  1936 		DeleteGear(gear)
  1948 	end
  1937 	end
  1949 
  1938 
  1950 end
  1939 end
  1951 
  1940 
  1954 
  1943 
  1955 	if not CurrentHedgehog then
  1944 	if not CurrentHedgehog then
  1956 		return
  1945 		return
  1957 	end
  1946 	end
  1958 
  1947 
  1959 	for i = 0,(vCCount-1) do
  1948 	for i = 0,(SI.vCCount-1) do
  1960 
  1949 
  1961 		local g1X, g1Y = GetGearPosition(CurrentHedgehog)
  1950 		local g1X, g1Y = GetGearPosition(CurrentHedgehog)
  1962 		local g2X, g2Y = vCircX[i], vCircY[i]
  1951 		local g2X, g2Y = SI.vCircX[i], SI.vCircY[i]
  1963 
  1952 
  1964 		g1X = g1X - g2X
  1953 		g1X = g1X - g2X
  1965 		g1Y = g1Y - g2Y
  1954 		g1Y = g1Y - g2Y
  1966 		local dist = (g1X*g1X) + (g1Y*g1Y)
  1955 		local dist = (g1X*g1X) + (g1Y*g1Y)
  1967 
  1956 
  1968 		-- calculate my real radius if I am an aura
  1957 		-- calculate my real radius if I am an aura
  1969 		local NR
  1958 		local NR
  1970 		if vCircType[i] == 0 then
  1959 		if SI.vCircType[i] == 0 then
  1971 			NR = vCircRadius[i]
  1960 			NR = SI.vCircRadius[i]
  1972 		else
  1961 		else
  1973 			NR = (48/100*vCircRadius[i])/2
  1962 			NR = (48/100*SI.vCircRadius[i])/2
  1974 		end
  1963 		end
  1975 
  1964 
  1976 		if dist <= NR*NR then
  1965 		if dist <= NR*NR then
  1977 
  1966 
  1978 			if 	(vCircActive[i] == true) and
  1967 			if 	(SI.vCircActive[i] == true) and
  1979 				((vType[i] == "ammo") or (vType[i] == "bonus") )
  1968 				((SI.vType[i] == "ammo") or (SI.vType[i] == "bonus") )
  1980 			then
  1969 			then
  1981 
  1970 
  1982 				CircleDamaged(i)
  1971 				CircleDamaged(i)
  1983 
  1972 
  1984 			elseif (vCircActive[i] == true) and
  1973 			elseif (SI.vCircActive[i] == true) and
  1985 					( (vType[i] == "drone") or (vType[i] == "blueboss") )
  1974 					( (SI.vType[i] == "drone") or (SI.vType[i] == "blueboss") )
  1986 			then
  1975 			then
  1987 
  1976 
  1988 				local ss = CircleDamaged(i)
  1977 				local ss = CircleDamaged(i)
  1989 				local explosion
  1978 				local explosion
  1990 				if vType[i] == "blueboss" then explosion = true else explosion = false end
  1979 				if SI.vType[i] == "blueboss" then explosion = true else explosion = false end
  1991 
  1980 
  1992 				local kamikaze = false
  1981 				local kamikaze = false
  1993 				if ss == "fatal" then
  1982 				if ss == "fatal" then
  1994 					if (wepAmmo[0] == 0) and (TimeLeft <= 9) then
  1983 					if (SI.wepAmmo[0] == 0) and (SI.TimeLeft <= 9) then
  1995 						AddCaption(loc("Kamikaze Expert! +15 points!"),colorMsgBonus,capgrpGameState)
  1984 						AddCaption(loc("Kamikaze Expert! +15 points!"),SI.colorMsgBonus,capgrpGameState)
  1996 						AwardPoints(15)
  1985 						AwardPoints(15)
  1997 						PlaySound(sndKamikaze, CurrentHedgehog)
  1986 						PlaySound(sndKamikaze, CurrentHedgehog)
  1998 						kamikaze = true
  1987 						kamikaze = true
  1999 					elseif (wepAmmo[0] == 0) then
  1988 					elseif (SI.wepAmmo[0] == 0) then
  2000 						AddCaption(loc("Depleted Kamikaze! +5 points!"),colorMsgBonus,capgrpGameState)
  1989 						AddCaption(loc("Depleted Kamikaze! +5 points!"),SI.colorMsgBonus,capgrpGameState)
  2001 						AwardPoints(5)
  1990 						AwardPoints(5)
  2002 						PlaySound(sndKamikaze, CurrentHedgehog)
  1991 						PlaySound(sndKamikaze, CurrentHedgehog)
  2003 						kamikaze = true
  1992 						kamikaze = true
  2004 					elseif TimeLeft <= 9 then
  1993 					elseif SI.TimeLeft <= 9 then
  2005 						AddCaption(loc("Timed Kamikaze! +10 points!"),colorMsgBonus,capgrpGameState)
  1994 						AddCaption(loc("Timed Kamikaze! +10 points!"),SI.colorMsgBonus,capgrpGameState)
  2006 						AwardPoints(10)
  1995 						AwardPoints(10)
  2007 						PlaySound(sndKamikaze, CurrentHedgehog)
  1996 						PlaySound(sndKamikaze, CurrentHedgehog)
  2008 						kamikaze = true
  1997 						kamikaze = true
  2009 					end
  1998 					end
  2010 				end
  1999 				end
  2019 
  2008 
  2020 end
  2009 end
  2021 
  2010 
  2022 function HandleCircles()
  2011 function HandleCircles()
  2023 
  2012 
  2024 	if rAlpha ~= 255 then
  2013 	if SI.rAlpha ~= 255 then
  2025 
  2014 
  2026 		rPingTimer = rPingTimer + 1
  2015 		SI.rPingTimer = SI.rPingTimer + 1
  2027 		if rPingTimer == 100 then
  2016 		if SI.rPingTimer == 100 then
  2028 			rPingTimer = 0
  2017 			SI.rPingTimer = 0
  2029 
  2018 
  2030 			rAlpha = rAlpha + 5
  2019 			SI.rAlpha = SI.rAlpha + 5
  2031 			if rAlpha >= 255 then
  2020 			if SI.rAlpha >= 255 then
  2032 				rAlpha = 255
  2021 				SI.rAlpha = 255
  2033 			end
  2022 			end
  2034 		end
  2023 		end
  2035 
  2024 
  2036 	end
  2025 	end
  2037 
  2026 
  2038 	for i = 0,(vCCount-1) do
  2027 	for i = 0,(SI.vCCount-1) do
  2039 
  2028 
  2040 		SetVisualGearValues(rCirc[i], rCircX[i], rCircY[i], 100, 255, 1, 10, 0, 40, 3, vCircCol[i]-rAlpha)
  2029 		SetVisualGearValues(SI.rCirc[i], SI.rCircX[i], SI.rCircY[i], 100, 255, 1, 10, 0, 40, 3, SI.vCircCol[i]-SI.rAlpha)
  2041 
  2030 
  2042 		vCounter[i] = vCounter[i] + 1
  2031 		SI.vCounter[i] = SI.vCounter[i] + 1
  2043 		if vCounter[i] >= vCounterLim[i] then
  2032 		if SI.vCounter[i] >= SI.vCounterLim[i] then
  2044 
  2033 
  2045 			vCounter[i] = 0
  2034 			SI.vCounter[i] = 0
  2046 
  2035 
  2047 			if 	((vType[i] == "drone") or (vType[i] == "blueboss") ) and
  2036 			if 	((SI.vType[i] == "drone") or (SI.vType[i] == "blueboss") ) and
  2048 				(vCircActive[i] == true) then
  2037 				(SI.vCircActive[i] == true) then
  2049 				AddGear(vCircX[i], vCircY[i], gtShell, 0, 0, 0, 1)
  2038 				AddGear(SI.vCircX[i], SI.vCircY[i], gtShell, 0, 0, 0, 1)
  2050 
  2039 
  2051 			end
  2040 			end
  2052 
  2041 
  2053 		end
  2042 		end
  2054 
  2043 
  2055 		if (vCircActive[i] == true) then
  2044 		if (SI.vCircActive[i] == true) then
  2056 
  2045 
  2057 			vCircRadCounter[i] = vCircRadCounter[i] + 1
  2046 			SI.vCircRadCounter[i] = SI.vCircRadCounter[i] + 1
  2058 			if vCircRadCounter[i] == 100 then
  2047 			if SI.vCircRadCounter[i] == 100 then
  2059 
  2048 
  2060 				vCircRadCounter[i] = 0
  2049 				SI.vCircRadCounter[i] = 0
  2061 
  2050 
  2062 				-- make my radius increase/decrease faster if I am an aura
  2051 				-- make my radius increase/decrease faster if I am an aura
  2063 				local M
  2052 				local M
  2064 				if vCircType[i] == 0 then
  2053 				if SI.vCircType[i] == 0 then
  2065 					M = 1
  2054 					M = 1
  2066 				else
  2055 				else
  2067 					M = 10
  2056 					M = 10
  2068 				end
  2057 				end
  2069 
  2058 
  2070 				vCircRadius[i] = vCircRadius[i] + vCircRadDir[i]
  2059 				SI.vCircRadius[i] = SI.vCircRadius[i] + SI.vCircRadDir[i]
  2071 				if vCircRadius[i] > vCircRadMax[i] then
  2060 				if SI.vCircRadius[i] > SI.vCircRadMax[i] then
  2072 					vCircRadDir[i] = -M
  2061 					SI.vCircRadDir[i] = -M
  2073 				elseif vCircRadius[i] < vCircRadMin[i] then
  2062 				elseif SI.vCircRadius[i] < SI.vCircRadMin[i] then
  2074 					vCircRadDir[i] = M
  2063 					SI.vCircRadDir[i] = M
  2075 				end
  2064 				end
  2076 
  2065 
  2077 
  2066 
  2078 				-- random effect test
  2067 				-- random effect test
  2079 				-- maybe use this to tell the difference between circs
  2068 				-- maybe use this to tell the difference between circs
  2080 				-- you can kill by shooting or not
  2069 				-- you can kill by shooting or not
  2081 				--vgtSmoke vgtSmokeWhite
  2070 				--vgtSmoke vgtSmokeWhite
  2082 				--vgtSteam -- nice long trail
  2071 				--vgtSteam -- nice long trail
  2083 				--vgtDust -- short trail on earthrise
  2072 				--vgtDust -- short trail on earthrise
  2084 				--vgtSmokeTrace
  2073 				--vgtSmokeTrace
  2085 				if vType[i] == "ammo" then
  2074 				if SI.vType[i] == "ammo" then
  2086 
  2075 
  2087 					local tempE = AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, false)
  2076 					local tempE = AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtSmoke, 0, false)
  2088 					SetVisualGearValues(tempE, vCircX[i], vCircY[i], nil, nil, nil, nil, nil, nil, nil, vCircCol[i] )
  2077 					SetVisualGearValues(tempE, SI.vCircX[i], SI.vCircY[i], nil, nil, nil, nil, nil, nil, nil, SI.vCircCol[i] )
  2089 
  2078 
  2090 				elseif vType[i] == "bonus" then
  2079 				elseif SI.vType[i] == "bonus" then
  2091 
  2080 
  2092 					local tempE = AddVisualGear(vCircX[i], vCircY[i], vgtDust, 0, false)
  2081 					local tempE = AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtDust, 0, false)
  2093 					SetVisualGearValues(tempE, vCircX[i], vCircY[i], nil, nil, nil, nil, nil, 1, nil, colorShieldParticle)
  2082 					SetVisualGearValues(tempE, SI.vCircX[i], SI.vCircY[i], nil, nil, nil, nil, nil, 1, nil, SI.colorShieldParticle)
  2094 
  2083 
  2095 
  2084 
  2096 				elseif vType[i] == "blueboss" then
  2085 				elseif SI.vType[i] == "blueboss" then
  2097 
  2086 
  2098 					local k = 25
  2087 					local k = 25
  2099 					local g = vgtSteam
  2088 					local g = vgtSteam
  2100 					local trailColour = colorBossParticle
  2089 					local trailColour = SI.colorBossParticle
  2101 
  2090 
  2102 					local tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, false)
  2091 					local tempE = AddVisualGear(SI.vCircX[i], SI.vCircY[i], g, 0, false)
  2103 					SetVisualGearValues(tempE, vCircX[i], vCircY[i]+k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
  2092 					SetVisualGearValues(tempE, SI.vCircX[i], SI.vCircY[i]+k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
  2104 
  2093 
  2105 					tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, false)
  2094 					tempE = AddVisualGear(SI.vCircX[i], SI.vCircY[i], g, 0, false)
  2106 					SetVisualGearValues(tempE, vCircX[i]+k, vCircY[i]-k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
  2095 					SetVisualGearValues(tempE, SI.vCircX[i]+k, SI.vCircY[i]-k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
  2107 
  2096 
  2108 					tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, false)
  2097 					tempE = AddVisualGear(SI.vCircX[i], SI.vCircY[i], g, 0, false)
  2109 					SetVisualGearValues(tempE, vCircX[i]-k, vCircY[i]-k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
  2098 					SetVisualGearValues(tempE, SI.vCircX[i]-k, SI.vCircY[i]-k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
  2110 
  2099 
  2111 
  2100 
  2112 				end
  2101 				end
  2113 
  2102 
  2114 
  2103 
  2118 
  2107 
  2119 
  2108 
  2120 	end
  2109 	end
  2121 
  2110 
  2122 	-- alter the circles velocities
  2111 	-- alter the circles velocities
  2123 	circAdjustTimer = circAdjustTimer + 1
  2112 	SI.circAdjustTimer = SI.circAdjustTimer + 1
  2124 	if circAdjustTimer == 2000 then
  2113 	if SI.circAdjustTimer == 2000 then
  2125 
  2114 
  2126 		circAdjustTimer = 0
  2115 		SI.circAdjustTimer = 0
  2127 
  2116 
  2128 		for i = 0,(vCCount-1) do
  2117 		for i = 0,(SI.vCCount-1) do
  2129 
  2118 
  2130 			-- bounce the circles off the edges if they go too far
  2119 			-- bounce the circles off the edges if they go too far
  2131 			-- or make them move in random directions
  2120 			-- or make them move in random directions
  2132 
  2121 
  2133 			if vCircX[i] > 5500 then
  2122 			if SI.vCircX[i] > 5500 then
  2134 				vCircDX[i] = -5	--5 circmovchange
  2123 				SI.vCircDX[i] = -5	--5 circmovchange
  2135 			elseif vCircX[i] < -1500 then
  2124 			elseif SI.vCircX[i] < -1500 then
  2136 				vCircDX[i] = 5	--5 circmovchange
  2125 				SI.vCircDX[i] = 5	--5 circmovchange
  2137 			else
  2126 			else
  2138 
  2127 
  2139 				local z = GetRandom(2)
  2128 				local z = GetRandom(2)
  2140 				if z == 1 then
  2129 				if z == 1 then
  2141 					z = 1
  2130 					z = 1
  2142 				else
  2131 				else
  2143 					z = -1
  2132 					z = -1
  2144 				end
  2133 				end
  2145 				vCircDX[i] = vCircDX[i] + GetRandom(3)*z	--3 circmovchange
  2134 				SI.vCircDX[i] = SI.vCircDX[i] + GetRandom(3)*z	--3 circmovchange
  2146 			end
  2135 			end
  2147 
  2136 
  2148 			if vCircY[i] > 1500 then
  2137 			if SI.vCircY[i] > 1500 then
  2149 				vCircDY[i] = -5	--5 circmovchange
  2138 				SI.vCircDY[i] = -5	--5 circmovchange
  2150 			elseif vCircY[i] < -2900 then
  2139 			elseif SI.vCircY[i] < -2900 then
  2151 				vCircDY[i] = 5	--5 circmovchange
  2140 				SI.vCircDY[i] = 5	--5 circmovchange
  2152 			else
  2141 			else
  2153 				local z = GetRandom(2)
  2142 				local z = GetRandom(2)
  2154 				if z == 1 then
  2143 				if z == 1 then
  2155 					z = 1
  2144 					z = 1
  2156 				else
  2145 				else
  2157 					z = -1
  2146 					z = -1
  2158 				end
  2147 				end
  2159 				vCircDY[i] = vCircDY[i] + GetRandom(3)*z	--3 circmovchange
  2148 				SI.vCircDY[i] = SI.vCircDY[i] + GetRandom(3)*z	--3 circmovchange
  2160 			end
  2149 			end
  2161 
  2150 
  2162 		end
  2151 		end
  2163 
  2152 
  2164 	end
  2153 	end
  2165 
  2154 
  2166 	-- move the circles according to their current velocities
  2155 	-- move the circles according to their current velocities
  2167 	m2Count = m2Count + 1
  2156 	SI.m2Count = SI.m2Count + 1
  2168 	if m2Count == 25 then	--25 circmovchange
  2157 	if SI.m2Count == 25 then	--25 circmovchange
  2169 
  2158 
  2170 		m2Count = 0
  2159 		SI.m2Count = 0
  2171 		for i = 0,(vCCount-1) do
  2160 		for i = 0,(SI.vCCount-1) do
  2172 			vCircX[i] = vCircX[i] + vCircDX[i]
  2161 			SI.vCircX[i] = SI.vCircX[i] + SI.vCircDX[i]
  2173 			vCircY[i] = vCircY[i] + vCircDY[i]
  2162 			SI.vCircY[i] = SI.vCircY[i] + SI.vCircDY[i]
  2174 
  2163 
  2175 			if (CurrentHedgehog ~= nil) and (rAlpha ~= 255) then
  2164 			if (CurrentHedgehog ~= nil) and (SI.rAlpha ~= 255) then
  2176 				DoHorribleThings(i)
  2165 				DoHorribleThings(i)
  2177 			end
  2166 			end
  2178 
  2167 
  2179 		end
  2168 		end
  2180 
  2169 
  2181 		if (TimeLeft == 0) and (tumbleStarted == true) then
  2170 		if (SI.TimeLeft == 0) and (SI.tumbleStarted == true) then
  2182 
  2171 
  2183 			fadeAlpha = fadeAlpha + 1
  2172 			SI.fadeAlpha = SI.fadeAlpha + 1
  2184 			if fadeAlpha >= 255 then
  2173 			if SI.fadeAlpha >= 255 then
  2185 				fadeAlpha = 255
  2174 				SI.fadeAlpha = 255
  2186 			end
  2175 			end
  2187 
  2176 
  2188 		end
  2177 		end
  2189 
  2178 
  2190 	end
  2179 	end
  2191 
  2180 
  2192 	for i = 0,(vCCount-1) do
  2181 	for i = 0,(SI.vCCount-1) do
  2193 		SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], nil, nil, nil, nil, nil, vCircRadius[i])
  2182 		SetVisualGearValues(SI.vCirc[i], SI.vCircX[i], SI.vCircY[i], nil, nil, nil, nil, nil, SI.vCircRadius[i])
  2194 	end
  2183 	end
  2195 
  2184 
  2196 	if 	(TimeLeft == 0) or
  2185 	if 	(SI.TimeLeft == 0) or
  2197 		((tumbleStarted == false)) then
  2186 		((SI.tumbleStarted == false)) then
  2198 		for i = 0,(vCCount-1) do
  2187 		for i = 0,(SI.vCCount-1) do
  2199 			SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], nil, nil, nil, nil, nil, vCircRadius[i], nil, (vCircCol[i]-fadeAlpha))
  2188 			SetVisualGearValues(SI.vCirc[i], SI.vCircX[i], SI.vCircY[i], nil, nil, nil, nil, nil, SI.vCircRadius[i], nil, (SI.vCircCol[i]-SI.fadeAlpha))
  2200 		end
  2189 		end
  2201 	end
  2190 	end
  2202 
  2191 
  2203 
  2192 
  2204 	if (CurrentHedgehog ~= nil) then
  2193 	if (CurrentHedgehog ~= nil) then
  2205 		if beam == true then
  2194 		if SI.beam == true then
  2206 			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, 200, nil, colorShield-0x000000FF - -shieldHealth )
  2195 			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, 200, nil, SI.colorShield-0x000000FF - -SI.shieldHealth )
  2207 			DrawTag(TAG_SHIELD)
  2196 			DrawTag(SI.TAG_SHIELD)
  2208 		else
  2197 		else
  2209 			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, 0)
  2198 			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, 0)
  2210 		end
  2199 		end
  2211 
  2200 
  2212 	end
  2201 	end
  2213 
  2202 
  2214 
  2203 
  2216 
  2205 
  2217 function ProjectileTrack(gear)
  2206 function ProjectileTrack(gear)
  2218 
  2207 
  2219 	if (GetGearType(gear) == gtShell) then
  2208 	if (GetGearType(gear) == gtShell) then
  2220 
  2209 
  2221 		local turningSpeed = 0.1*fMod
  2210 		local turningSpeed = 0.1*SI.fMod
  2222 
  2211 
  2223 		local dx, dy = GetGearVelocity(gear)
  2212 		local dx, dy = GetGearVelocity(gear)
  2224 
  2213 
  2225 		if GetX(gear) > GetX(CurrentHedgehog) then
  2214 		if GetX(gear) > GetX(CurrentHedgehog) then
  2226 			dx = dx - turningSpeed
  2215 			dx = dx - turningSpeed
  2233 		else
  2222 		else
  2234 			dy = dy + turningSpeed
  2223 			dy = dy + turningSpeed
  2235 		end
  2224 		end
  2236 
  2225 
  2237 
  2226 
  2238 		local dxlimit = 0.4*fMod
  2227 		local dxlimit = 0.4*SI.fMod
  2239 		local dylimit = 0.4*fMod
  2228 		local dylimit = 0.4*SI.fMod
  2240 
  2229 
  2241 		if dx > dxlimit then
  2230 		if dx > dxlimit then
  2242 			dx = dxlimit
  2231 			dx = dxlimit
  2243 		end
  2232 		end
  2244 		if dy > dylimit then
  2233 		if dy > dylimit then