Space Invasion: Localize most global variables
authorWuzzy <Wuzzy2@mail.ru>
Sat, 07 Jul 2018 18:41:28 +0200
changeset 13453 6aca4f45ab0a
parent 13452 93ba1826b8c2
child 13454 57de4f050891
Space Invasion: Localize most global variables
share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Sat Jul 07 18:37:21 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Sat Jul 07 18:41:28 2018 +0200
@@ -346,6 +346,7 @@
 
 -- gaudyRacer
 local boosterOn = false
+local preciseOn = false
 local roundLimit = 3		-- can be overridden by script parameter "rounds"
 local roundNumber = 0
 local firstClan = 10
@@ -464,7 +465,7 @@
 local shockwaveHealth = 0
 local shockwaveRad = 300
 
-local Timer100 = 0
+local timer100 = 0
 
 local vTag = {}
 
@@ -472,11 +473,11 @@
 -- CIRCLY GOODIES
 -----------------------------------------------
 
-local CirclesAreGo = false
+local circlesAreGo = false
 local playerIsFine = true
 local targetHit = false
 
-local FadeAlpha = 0 -- used to fade the circles out gracefully when player dies
+local fadeAlpha = 0 -- used to fade the circles out gracefully when player dies
 local pTimer = 0 -- tracking projectiles following player
 
 local circAdjustTimer = 0		-- handle adjustment of circs direction
@@ -563,7 +564,6 @@
 
 	DeleteVisualGear(vTag[i])
 	vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
-	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vTag[i])
 	SetVisualGearValues	(
 				vTag[i], 		--id
 				-(ScreenWidth/2) + xOffset,	--xoffset
@@ -572,7 +572,7 @@
 				0, 			--dy
 				zoomL, 			--zoom
 				1, 			--~= 0 means align to screen
-				g7, 			--frameticks
+				nil, 			--frameticks
 				tValue, 		--value
 				240000, 		--timer
 				tCol		--GetClanColor( GetHogClan(CurrentHedgehog) )
@@ -594,12 +594,12 @@
 
 	for i = 0, (numhhs-1) do
 
-		z = 0
-		unfinished = true
+		local z = 0
+		local unfinished = true
 		while(unfinished == true) do
 
-			newTeam = true
-			tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name
+			local newTeam = true
+			local tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name
 
 			if tempHogTeamName == teamNameArr[z] then
 				newTeam = false
@@ -951,6 +951,7 @@
 
 function setNewGearValues(gear)
 
+	local lfs
 	if GetGearType(gear) == gtShell then
 		lfs = 50	-- roughly 5 seconds
 		shellID = shellID + 1
@@ -1052,9 +1053,9 @@
 		if wep[wepIndex] == loc("Barrel Launcher") then
 			shotsFired = shotsFired +1
 
-			morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
+			local morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
 			CopyPV(CurrentHedgehog, morte) -- new addition
-			x,y = GetGearVelocity(morte)
+			local x,y = GetGearVelocity(morte)
 			x = x*2
 			y = y*2
 			SetGearVelocity(morte, x, y)
@@ -1068,7 +1069,7 @@
 			DrawTag(1)
 
 		elseif wep[wepIndex] == loc("Mine Deployer") then
-			morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtAirBomb, 0, 0, 0, 0)
+			local morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtAirBomb, 0, 0, 0, 0)
 			SetTimer(morte, 1000)
 			DrawTag(1)
 		end
@@ -1334,7 +1335,6 @@
 	end
 
 	if gameOver == true then
-		gameBegun = false
 		stopMovement = true
 		tumbleStarted = false
 		SetMyCircles(false)
@@ -1367,7 +1367,7 @@
 	HandleLifeSpan(gear)
 	DeleteFarFlungBarrel(gear)
 
-	if CirclesAreGo == true then
+	if circlesAreGo == true then
 		CheckVarious(gear)
 		ProjectileTrack(gear)
 	end
@@ -1396,9 +1396,9 @@
 
 	HandleCircles()
 
-	Timer100 = Timer100 + 1
-	if Timer100 >= 100 then
-		Timer100 = 0
+	timer100 = timer100 + 1
+	if timer100 >= 100 then
+		timer100 = 0
 
 		if beam == true then
 			shieldHealth = shieldHealth - 1
@@ -1424,13 +1424,13 @@
 
 		--nw WriteLnToConsole("Finished ThingsToBeRunOnGears()")
 
-		if CirclesAreGo == true then
+		if circlesAreGo == true then
 			CheckDistances()
 		end
 
 		-- white smoke trail as player falls from the sky
 		if (TimeLeft <= 0) and (stopMovement == true) and (CurrentHedgehog ~= nil) then
-			j,k = GetGearVelocity(CurrentHedgehog)
+			local j,k = GetGearVelocity(CurrentHedgehog)
 			if (j ~= 0) and (k ~= 0) then
 				AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, true)
 			end
@@ -1446,7 +1446,7 @@
 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
 			tumbleStarted = true
 			TimeLeft = (TurnTime/1000)
-			FadeAlpha = 0
+			fadeAlpha = 0
 			rAlpha = 255
 			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
 			DrawTag(0)
@@ -1510,7 +1510,7 @@
 
 				if shieldMiser == true then
 
-					p = (roundKills*3.5) - ((roundKills*3.5)%1) + 2
+					local p = (roundKills*3.5) - ((roundKills*3.5)%1) + 2
 
 					AddCaption(string.format(loc("Shield Miser! +%d points!"), p),0xffba00ff,capgrpAmmoinfo)
 					AwardPoints(p)
@@ -1575,22 +1575,21 @@
 				---------------
 				-- the trail lets you know you have 5s left to pilot, akin to birdy feathers
 				if (TimeLeft <= 5) and (TimeLeft > 0) then							--vgtSmoke
-					tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, true)
-					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
-					SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(GetHogClan(CurrentHedgehog)) )
+					local tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, true)
+					SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(CurrentHedgehog)) )
 				end
 				--------------
 				--------------
 
-				dx, dy = GetGearVelocity(CurrentHedgehog)
+				local dx, dy = GetGearVelocity(CurrentHedgehog)
 
 				--WriteLnToConsole("I just got the velocity of currenthedgehog. It is dx: " .. dx .. "; dy: " .. dy)
 				--WriteLnToConsole("The above event occured game Time: " .. GameTime .. "; luaTicks: " .. luaGameTicks)
 
+				local dxlimit, dylimit
 				if boosterOn == true then
-					tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtDust, 0, false)
-					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
-					SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, 1, g9, GetClanColor(GetHogClan(CurrentHedgehog)) )
+					local tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtDust, 0, false)
+					SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, 1, nil, GetClanColor(GetHogClan(CurrentHedgehog)) )
 					dxlimit = 0.8*fMod
 					dylimit = 0.8*fMod
 				else
@@ -1733,24 +1732,24 @@
 function DoHorribleThings(cUID)
 
 	-- work out the distance to the target
-	g1X, g1Y = GetGearPosition(CurrentHedgehog)
-	g2X, g2Y = vCircX[cUID], vCircY[cUID]
-	q = g1X - g2X
-	w = g1Y - g2Y
-	r = math.sqrt( (q*q) + (w*w) )	--alternate
-
-	opp = w
+	local g1X, g1Y = GetGearPosition(CurrentHedgehog)
+	local g2X, g2Y = vCircX[cUID], vCircY[cUID]
+	local q = g1X - g2X
+	local w = g1Y - g2Y
+	local r = math.sqrt( (q*q) + (w*w) )	--alternate
+
+	local opp = w
 	if opp < 0 then
 		opp = opp*-1
 	end
 
 	-- work out the angle (theta) to the target
-	t = math.deg ( math.asin(opp / r) )
+	local t = math.deg ( math.asin(opp / r) )
 
 	-- based on the radius of the radar, calculate what x/y displacement should be
-	NR = 150 -- radius at which to draw circs
-	NX = math.cos( math.rad(t) ) * NR
-	NY = math.sin( math.rad(t) ) * NR
+	local NR = 150 -- radius at which to draw circs
+	local NX = math.cos( math.rad(t) ) * NR
+	local NY = math.sin( math.rad(t) ) * NR
 
 	-- displace xy based on where this thing actually is
 
@@ -1777,17 +1776,17 @@
 end
 
 function GetDistFromXYtoXY(a, b, c, d)
-	q = a - c
-	w = b - d
+	local q = a - c
+	local w = b - d
 	return ( (q*q) + (w*w) )
 end
 
 function GetDistFromGearToGear(gear, gear2)
 
-	g1X, g1Y = GetGearPosition(gear)
-	g2X, g2Y = GetGearPosition(gear2)
-	q = g1X - g2X
-	w = g1Y - g2Y
+	local g1X, g1Y = GetGearPosition(gear)
+	local g2X, g2Y = GetGearPosition(gear2)
+	local q = g1X - g2X
+	local w = g1Y - g2Y
 
 	return ( (q*q) + (w*w) )
 
@@ -1795,9 +1794,9 @@
 
 function GetDistFromGearToXY(gear, g2X, g2Y)
 
-	g1X, g1Y = GetGearPosition(gear)
-	q = g1X - g2X
-	w = g1Y - g2Y
+	local g1X, g1Y = GetGearPosition(gear)
+	local q = g1X - g2X
+	local w = g1Y - g2Y
 
 	return ( (q*q) + (w*w) )
 
@@ -1853,11 +1852,11 @@
 
 function IGotMeASafeXYValue(i)
 
-	acceptibleDistance = 800
+	local acceptibleDistance = 800
 
 	vCircX[i] = GetRandom(5000)
 	vCircY[i] = GetRandom(2000)
-	dist = GetDistFromGearToXY(CurrentHedgehog, vCircX[i], vCircY[i])
+	local dist = GetDistFromGearToXY(CurrentHedgehog, vCircX[i], vCircY[i])
 	if dist > acceptibleDistance*acceptibleDistance then
 		return(true)
 	else
@@ -1868,7 +1867,7 @@
 
 function CircleDamaged(i)
 
-	res = ""
+	local res = ""
 	vCircHealth[i] = vCircHealth[i] -1
 
 	if vCircHealth[i] <= 0 then
@@ -1882,7 +1881,7 @@
 			AddCaption(string.format(loc("Time extended! +%dsec"), timeBonus), 0xff0000ff,capgrpMessage )
 			DrawTag(0)
 
-			morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1)
+			local morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1)
 			SetHealth(morte, 0)
 
 			RK = RK + 1
@@ -1943,7 +1942,7 @@
 			tauntGear = CurrentHedgehog
 			AddCaption(loc("Boss defeated! +30 points!"), 0x0050ffff,capgrpMessage)
 
-			morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1)
+			local morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1)
 			SetHealth(morte, 0)
 
 			BK = BK + 1
@@ -1973,7 +1972,7 @@
 	-- circle is merely damaged
 	-- do damage effects/sounds
 		AddVisualGear(vCircX[i], vCircY[i], vgtSteam, 0, false)
-		r = math.random(1,4)
+		local r = math.random(1,4)
 		PlaySound(_G["sndHellishImpact" .. tostring(r)])
 		res = "non-fatal"
 
@@ -1986,7 +1985,7 @@
 function SetUpCircle(i)
 
 
-	r = GetRandom(10)
+	local r = GetRandom(10)
 	-- 80% of spawning either red/green
 	if r <= 7 then
 
@@ -2032,7 +2031,7 @@
 	end
 
 	-- regenerate circle xy if too close to player or until sanity limit kicks in
-	reN = 0
+	local reN = 0
 	while (reN < 10) do
 		if IGotMeASafeXYValue(i) == false then
 			reN = reN + 1
@@ -2043,11 +2042,9 @@
 
 	vCircRadius[i] = vCircRadMax[i] - GetRandom(vCircRadMin[i])
 
-	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i])
-	SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], vCircWidth[i], vCircCol[i]-0x000000ff)
-
-	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(rCirc[i])
-	SetVisualGearValues(rCirc[i], 0, 0, g3, g4, g5, g6, g7, g8, g9, vCircCol[i]-0x000000ff)
+	SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], nil, nil, nil, nil, nil, vCircRadius[i], vCircWidth[i], vCircCol[i]-0x000000ff)
+
+	SetVisualGearValues(rCirc[i], 0, 0, nil, nil, nil, nil, nil, nil, nil, vCircCol[i]-0x000000ff)
 
 
 	vCircActive[i] = true
@@ -2060,7 +2057,7 @@
 
 function SetMyCircles(s)
 
-	CirclesAreGo = s
+	circlesAreGo = s
 	playerIsFine = s
 
 	if s == true then
@@ -2120,7 +2117,7 @@
 
 	-- if circle is hit by player fire
 	if (GetGearType(gear) == gtExplosives) then
-		circsHit = 0
+		local circsHit = 0
 
 		for i = 0,(vCCount-1) do
 
@@ -2128,9 +2125,10 @@
 
 			--nw WriteLnToConsole("YES. about to calc distance between gtExplosives and circ " .. i)
 
-			dist = GetDistFromGearToXY(gear, vCircX[i], vCircY[i])
+			local dist = GetDistFromGearToXY(gear, vCircX[i], vCircY[i])
 
 			-- calculate my real radius if I am an aura
+			local NR
 			if vCircType[i] == 0 then
 				NR = vCircRadius[i]
 			else
@@ -2185,14 +2183,13 @@
 	-- if player is hit by circle bazooka
 	elseif (GetGearType(gear) == gtShell) and (CurrentHedgehog ~= nil) then
 
-		dist = GetDistFromGearToGear(gear, CurrentHedgehog)
+		local dist = GetDistFromGearToGear(gear, CurrentHedgehog)
 
 		if beam == true then
 
 			if dist < 3000 then
-				tempE = AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, true)
-				g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
-				SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, 0xff00ffff )
+				local tempE = AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, true)
+				SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xff00ffff )
 				PlaySound(sndVaporize)
 				DeleteGear(gear)
 
@@ -2233,16 +2230,17 @@
 
 		--nw WriteLnToConsole("Attempting to calculate dist of circ " .. i)
 
-		g1X, g1Y = GetGearPosition(CurrentHedgehog)
-		g2X, g2Y = vCircX[i], vCircY[i]
+		local g1X, g1Y = GetGearPosition(CurrentHedgehog)
+		local g2X, g2Y = vCircX[i], vCircY[i]
 
 		g1X = g1X - g2X
 		g1Y = g1Y - g2Y
-		dist = (g1X*g1X) + (g1Y*g1Y)
+		local dist = (g1X*g1X) + (g1Y*g1Y)
 
 		--nw WriteLnToConsole("Calcs done. Dist to CurrentHedgehog is " .. dist)
 
 		-- calculate my real radius if I am an aura
+		local NR
 		if vCircType[i] == 0 then
 			NR = vCircRadius[i]
 		else
@@ -2261,7 +2259,7 @@
 					( (vType[i] == "drone") or (vType[i] == "blueboss") )
 			then
 
-				ss = CircleDamaged(i)
+				local ss = CircleDamaged(i)
 				local explosion
 				if vType[i] == "blueboss" then explosion = true else explosion = false end
 
@@ -2338,6 +2336,7 @@
 				vCircRadCounter[i] = 0
 
 				-- make my radius increase/decrease faster if I am an aura
+				local M
 				if vCircType[i] == 0 then
 					M = 1
 				else
@@ -2361,37 +2360,32 @@
 				--vgtSmokeTrace
 				if vType[i] == "ammo" then
 
-					tempE = AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, true)
-					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
-					SetVisualGearValues(tempE, vCircX[i], vCircY[i], g3, g4, g5, g6, g7, g8, g9, vCircCol[i] )
+					local tempE = AddVisualGear(vCircX[i], vCircY[i], vgtSmoke, 0, true)
+					SetVisualGearValues(tempE, vCircX[i], vCircY[i], nil, nil, nil, nil, nil, nil, nil, vCircCol[i] )
 
 				elseif vType[i] == "bonus" then
 
-					tempE = AddVisualGear(vCircX[i], vCircY[i], vgtDust, 0, true)
-					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
-					SetVisualGearValues(tempE, vCircX[i], vCircY[i], g3, g4, g5, g6, g7, 1, g9, 0xff00ffff )
+					local tempE = AddVisualGear(vCircX[i], vCircY[i], vgtDust, 0, true)
+					SetVisualGearValues(tempE, vCircX[i], vCircY[i], nil, nil, nil, nil, nil, 1, nil, 0xff00ffff )
 
 
 				elseif vType[i] == "blueboss" then
 
-					k = 25
-					g = vgtSteam
-					trailColour = 0xae00ffff
+					local k = 25
+					local g = vgtSteam
+					local trailColour = 0xae00ffff
 
 					-- 0xffae00ff -- orange
 					-- 0xae00ffff -- purp
 
-					tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true)
-					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
-					SetVisualGearValues(tempE, vCircX[i], vCircY[i]+k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 )
+					local tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true)
+					SetVisualGearValues(tempE, vCircX[i], vCircY[i]+k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
 
 					tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true)
-					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
-					SetVisualGearValues(tempE, vCircX[i]+k, vCircY[i]-k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 )
+					SetVisualGearValues(tempE, vCircX[i]+k, vCircY[i]-k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
 
 					tempE = AddVisualGear(vCircX[i], vCircY[i], g, 0, true)
-					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
-					SetVisualGearValues(tempE, vCircX[i]-k, vCircY[i]-k, g3, g4, g5, g6, g7, g8, g9, trailColour-75 )
+					SetVisualGearValues(tempE, vCircX[i]-k, vCircY[i]-k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
 
 
 				end
@@ -2421,7 +2415,7 @@
 				vCircDX[i] = 5	--5 circmovchange
 			else
 
-				z = GetRandom(2)
+				local z = GetRandom(2)
 				if z == 1 then
 					z = 1
 				else
@@ -2435,7 +2429,7 @@
 			elseif vCircY[i] < -2900 then
 				vCircDY[i] = 5	--5 circmovchange
 			else
-				z = GetRandom(2)
+				local z = GetRandom(2)
 				if z == 1 then
 					z = 1
 				else
@@ -2465,9 +2459,9 @@
 
 		if (TimeLeft == 0) and (tumbleStarted == true) then
 
-			FadeAlpha = FadeAlpha + 1
-			if FadeAlpha >= 255 then
-				FadeAlpha = 255
+			fadeAlpha = fadeAlpha + 1
+			if fadeAlpha >= 255 then
+				fadeAlpha = 255
 			end
 
 		end
@@ -2482,33 +2476,29 @@
 	end
 
 	for i = 0,(vCCount-1) do
-		g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i])
-		SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], g9, g10)
+		SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], nil, nil, nil, nil, nil, vCircRadius[i])
 	end
 
 	if 	(TimeLeft == 0) or
 		((tumbleStarted == false)) then
 		for i = 0,(vCCount-1) do
-			g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vCirc[i])
-			SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], g3, g4, g5, g6, g7, vCircRadius[i], g9, (vCircCol[i]-FadeAlpha))
+			SetVisualGearValues(vCirc[i], vCircX[i], vCircY[i], nil, nil, nil, nil, nil, vCircRadius[i], nil, (vCircCol[i]-fadeAlpha))
 		end
 	end
 
 
 	if (CurrentHedgehog ~= nil) then
 		if beam == true then
-			g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(pShield)
-			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 200, g9, 0xa800ffff-0x000000ff - -shieldHealth )
+			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, 200, nil, 0xa800ffff-0x000000ff - -shieldHealth )
 			DrawTag(2)
 		else
-			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 0, g9, g10 )
+			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, 0)
 		end
 
 		if shockwaveHealth > 0 then
-			g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(shockwave)
-			SetVisualGearValues(shockwave, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, shockwaveRad, g9, 0xff3300ff-0x000000ff - -shockwaveHealth )
+			SetVisualGearValues(shockwave, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, shockwaveRad, nil, 0xff3300ff-0x000000ff - -shockwaveHealth )
 		else
-			SetVisualGearValues(shockwave, GetX(CurrentHedgehog), GetY(CurrentHedgehog), g3, g4, g5, g6, g7, 0, g9, g10 )
+			SetVisualGearValues(shockwave, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, 0)
 		end
 
 	end
@@ -2522,11 +2512,9 @@
 
 		--nw WriteLnToConsole("ProjectileTrack() for Shell ID: " .. getGearValue(gear,"ID"))
 
-		if (GetGearType(gear) == gtShell) then
-			turningSpeed = 0.1*fMod
-		end
-
-		dx, dy = GetGearVelocity(gear)
+		local turningSpeed = 0.1*fMod
+
+		local dx, dy = GetGearVelocity(gear)
 
 		--WriteLnToConsole("I'm trying to track currenthedge with shell ID: " .. getGearValue(gear,"ID"))
 		--WriteLnToConsole("I just got the velocity of the shell. It is dx: " .. dx .. "; dy: " .. dy)
@@ -2545,10 +2533,8 @@
 		end
 
 
-		if (GetGearType(gear) == gtShell) then
-			dxlimit = 0.4*fMod
-			dylimit = 0.4*fMod
-		end
+		local dxlimit = 0.4*fMod
+		local dylimit = 0.4*fMod
 
 		if dx > dxlimit then
 			dx = dxlimit