merge
authoralfadur
Mon, 09 Jul 2018 19:39:15 +0300
changeset 13484 38f9097b6bbc
parent 13483 d79795acaa73 (current diff)
parent 13461 7a0a56c52fd2 (diff)
child 13485 fb37745c5bca
merge
--- a/ChangeLog.txt	Sat Jul 07 20:22:31 2018 +0300
+++ b/ChangeLog.txt	Mon Jul 09 19:39:15 2018 +0300
@@ -4,6 +4,10 @@
 Game:
  * Fix extreme amounts of droplets when shooting with minigun into ocean world edge
  * Fix hog being unable to walk after using sniper rifle without firing both shots
+ * Fix teleport tooltip claiming it doesn't end turn in hog placing phase with inf. attack
+
+Highlander:
+ * Fix all hogs getting teleport after hog placement phase
 
 Continental supplies:
  + Continents are now selected before the game starts
@@ -22,11 +26,19 @@
  * Don't play “Missed” and “Laugh” taunt when those don't make sense
  * Fix retreat timer not turning red for some weapons
 
+Space Invation:
+ + Display round score in a separate row
+ + Keep round score displayed after round ends, remove round score announcer message
+ * Fix rare Lua error message spam at end of game
+ * Fix round score and other info numbers messing up after screen resize
+
 Lua API:
  + New call: Retreat(time [, respectGetAwayTimeFactor): Force current turn into retreating mode
  + New call: GetAmmoTimer(gearUid, ammoType): Returns current set timer for given ammoType and hog gear in ms. Returns nil for non-timerable ammo
  + New call: EnableSwitchHog(): Enable hog switching
+ + New call: GetAmmo(ammoType): Returns ammo configuration (corresponds to SetAmmo)
  + New parameter: SetAmmoTexts: 5th param. showExtra: Set to false to hide texts like “Not yet available”
+ * Fixed variable: TotalRounds was -1 (instead of 0) in first real round after hog placement phase
 
 ====================== 0.9.24.1 ====================
  * Fix crash when portable portal device is fired at reduced graphics quality
--- a/hedgewars/uAmmos.pas	Sat Jul 07 20:22:31 2018 +0300
+++ b/hedgewars/uAmmos.pas	Mon Jul 09 19:39:15 2018 +0300
@@ -52,11 +52,10 @@
 implementation
 uses uVariables, uCommands, uUtils, uCaptions, uDebug, uScript;
 
-type TAmmoCounts = array[TAmmoType] of Longword;
-     TAmmoArray = array[TAmmoType] of TAmmo;
+type TAmmoArray = array[TAmmoType] of TAmmo;
 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
     ammoLoadout, ammoProbability, ammoDelay, ammoReinforcement: shortstring;
-    InitialCounts: array[0..Pred(cMaxHHs)] of TAmmoCounts;
+    InitialCountsLocal: array[0..Pred(cMaxHHs)] of TAmmoCounts;
 
 procedure FillAmmoStore(Ammo: PHHAmmo; var newAmmo: TAmmoArray);
 var mi: array[0..cMaxSlotIndex] of byte;
@@ -79,7 +78,6 @@
 end;
 
 procedure AddAmmoStore;
-const probability: array [0..8] of LongWord = (0,20,30,60,100,200,400,600,800);
 var cnt: Longword;
     a: TAmmoType;
     ammos: TAmmoCounts;
@@ -99,7 +97,7 @@
     begin
     if a <> amNothing then
         begin
-        Ammoz[a].Probability:= probability[byte(ammoProbability[ord(a)]) - byte('0')];
+        Ammoz[a].Probability:= probabilityLevels[byte(ammoProbability[ord(a)]) - byte('0')];
         Ammoz[a].SkipTurns:= (byte(ammoDelay[ord(a)]) - byte('0'));
         Ammoz[a].NumberInCase:= (byte(ammoReinforcement[ord(a)]) - byte('0'));
         cnt:= byte(ammoLoadout[ord(a)]) - byte('0');
@@ -140,9 +138,15 @@
     else
         ammos[a]:= AMMO_INFINITE;
     if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
-        InitialCounts[Pred(StoreCnt)][a]:= cnt
+        begin
+        InitialCountsLocal[Pred(StoreCnt)][a]:= cnt;
+        InitialAmmoCounts[a]:= cnt;
+        end
     else
-        InitialCounts[Pred(StoreCnt)][a]:= ammos[a];
+        begin
+        InitialCountsLocal[Pred(StoreCnt)][a]:= ammos[a];
+        InitialAmmoCounts[a]:= ammos[a];
+        end
     end;
 
     for a:= Low(TAmmoType) to High(TAmmoType) do
@@ -458,7 +462,7 @@
                 if (Propz and ammoprop_NotBorder) <> 0 then
                     begin
                     Count:= 0;
-                    InitialCounts[i][AmmoType]:= 0
+                    InitialCountsLocal[i][AmmoType]:= 0
                     end;
 
         PackAmmo(StoresList[i], slot)
@@ -506,7 +510,7 @@
 for i:= 0 to Pred(StoreCnt) do
     begin
     for a:= Low(TAmmoType) to High(TAmmoType) do
-        newAmmos[a].Count:= InitialCounts[i][a];
+        newAmmos[a].Count:= InitialCountsLocal[i][a];
     FillAmmoStore(StoresList[i], newAmmos);
     end;
 
@@ -546,7 +550,7 @@
         ammoDelay:= ammoDelay + '0';
         ammoReinforcement:= ammoReinforcement + '0'
         end;
-    FillChar(InitialCounts, sizeof(InitialCounts), 0)
+    FillChar(InitialCountsLocal, sizeof(InitialCountsLocal), 0)
 end;
 
 procedure freeModule;
--- a/hedgewars/uConsts.pas	Sat Jul 07 20:22:31 2018 +0300
+++ b/hedgewars/uConsts.pas	Mon Jul 09 19:39:15 2018 +0300
@@ -315,6 +315,8 @@
     AMMO_INFINITE = 100;
     AMMO_FINITE_MAX = 99;
 
+    probabilityLevels: array [0..8] of LongWord = (0,20,30,60,100,200,400,600,800);
+
     // explosion flags
     //EXPLAllDamageInRadius = $00000001;  Completely unused for ages
     EXPLAutoSound         = $00000002;
--- a/hedgewars/uScript.pas	Sat Jul 07 20:22:31 2018 +0300
+++ b/hedgewars/uScript.pas	Mon Jul 09 19:39:15 2018 +0300
@@ -2591,6 +2591,42 @@
     lc_setammo:= 0
 end;
 
+
+function lc_getammo(L : Plua_State) : LongInt; Cdecl;
+var i, at, rawProb, probLevel: LongInt;
+const
+    call = 'GetAmmo';
+    params = 'ammoType';
+begin
+    if CheckLuaParamCount(L, 1, call, params) then
+        begin
+        at:= LuaToAmmoTypeOrd(L, 1, call, params);
+        if at >= 0 then
+            begin
+            // Ammo count
+            i:= InitialAmmoCounts[TAmmoType(at)];
+            if i = AMMO_INFINITE then
+                i:= 9;
+            lua_pushnumber(L, i);
+            // Probability
+            rawProb:=  Ammoz[TAmmoType(at)].Probability;
+            probLevel:= -1;
+            for i := 0 to High(probabilityLevels) do
+                if rawProb = probabilityLevels[i] then
+                    probLevel:= i;
+            lua_pushnumber(L, probLevel);
+            // Delay in turns
+            lua_pushnumber(L, Ammoz[TAmmoType(at)].SkipTurns);
+            // Number in case
+            lua_pushnumber(L, Ammoz[TAmmoType(at)].NumberInCase);
+            lc_getammo:= 4
+            end
+        else
+            lc_getammo:= 0
+        end;
+end;
+
+
 function lc_setammodelay(L : Plua_State) : LongInt; Cdecl;
 var at: LongInt;
 const
@@ -3959,6 +3995,7 @@
 lua_register(luaState, _P'SetAmmoDescriptionAppendix', @lc_setammodescriptionappendix);
 lua_register(luaState, _P'AddCaption', @lc_addcaption);
 lua_register(luaState, _P'SetAmmo', @lc_setammo);
+lua_register(luaState, _P'GetAmmo', @lc_getammo);
 lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay);
 lua_register(luaState, _P'PlaySound', @lc_playsound);
 lua_register(luaState, _P'SetSoundMask', @lc_setsoundmask);
--- a/hedgewars/uStore.pas	Sat Jul 07 20:22:31 2018 +0300
+++ b/hedgewars/uStore.pas	Mon Jul 09 19:39:15 2018 +0300
@@ -1017,7 +1017,7 @@
             extra:= trmsg[sidNotYetAvailable];
         extracolor:= LongInt($ffc77070);
         end
-    else if (((GameFlags and gfInfAttack) <> 0) and ((Ammoz[atype].Ammo.Propz and ammoprop_ForceTurnEnd) = 0)) or ((Ammoz[atype].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) then
+    else if ((((GameFlags and gfInfAttack) <> 0) and ((Ammoz[atype].Ammo.Propz and ammoprop_ForceTurnEnd) = 0)) or ((Ammoz[atype].Ammo.Propz and ammoprop_NoRoundEnd) <> 0)) and (not (PlacingHogs and (atype = amTeleport))) then
         // weapon or utility will not end your turn
         begin
         extra:= trmsg[sidNoEndTurn];
--- a/hedgewars/uTeams.pas	Sat Jul 07 20:22:31 2018 +0300
+++ b/hedgewars/uTeams.pas	Mon Jul 09 19:39:15 2018 +0300
@@ -287,7 +287,8 @@
         for i:= 0 to ClansCount do
             if ClansArray[i] <> nil then
                 ClansArray[i]^.TurnNumber:= 0;
-        ResetWeapons
+        ResetWeapons;
+        inc(TotalRounds)
         end
     end;
 
--- a/hedgewars/uVariables.pas	Sat Jul 07 20:22:31 2018 +0300
+++ b/hedgewars/uVariables.pas	Mon Jul 09 19:39:15 2018 +0300
@@ -816,9 +816,11 @@
             PosSprite: TSprite;
             ejectX, ejectY: Longint;
             end;
+    TAmmoCounts = array[TAmmoType] of Longword;
 
 var
     Ammoz: array [TAmmoType] of TAmmozRec;
+    InitialAmmoCounts: TAmmoCounts;
 
 const
     AmmozInit: array [TAmmoType] of TAmmozRec = (
--- a/share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua	Sat Jul 07 20:22:31 2018 +0300
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua	Mon Jul 09 19:39:15 2018 +0300
@@ -3,90 +3,21 @@
 -- by mikade
 --------------------------------
 
--- Ancient changelog:
-
------------
---0.1
------------
-
--- concept test
-
------------
---0.2
------------
-
--- remove tardis till Henek fixes his tracker
--- change wep crates to health crates
--- reset arb turntimevalue
--- include randomOrder
--- Until fixed .17 methods come out, remove switches and resurrector
--- on request, removed kamikaze and piano weapons
--- provisional fixing of bugs that can't actually be fixed yet
-
------------
---0.3
------------
-
--- meh, update incorrect display
--- may change this in the future to have switches
--- but for now people are used to it without, so~
-
--- mudball is now counted as a utility
-
------------
---0.3b
------------
-
--- cleaned up code and got rid of unneccessary vars
--- mudball is a weapon again
--- landgun is now a utility
--- extra time, vampirism utility removed
--- hammer wep removed
--- all hogs have kamikaze
-
------------
---0.3c
------------
-
--- restructured some code
--- added napalm (whoops) to list of possible weapons you can get
--- hogs no longer recieve airstrike-related weps on border maps
-
------------
---0.4
------------
--- fix same name/blank weapon transfer bug (issue 541)
--- show next hog ammo set in full (issue 312)
--- allow mid-kill multi-shot weapon transfers (issue 503)
--- allow users to configure hog health
--- remove 'switched to' message
--- remove some extraeneous code
--- add more whitespace
--- break everything
-
------------
---0.4b
------------
--- as per request, add ice-gun
-
 -------------------------
 -- ideas for the future
 -------------------------
 -- add structure
 -- allow switcher, resurrector
--- add abuse
 -- nerf teleport
--- allow more customization
--- poison hogs using the default team? :/
 -- balance weapon distribution across entire team / all teams
 -- add other inequalities/bonuses like... ???
--- some hogs start off with an extra 25 health?
--- some hogs start off poisoned?
--- some hogs start off with a rope and 2 drills but die after their turn?
+-- * some hogs start off with an extra 25 health?
+-- * some hogs start off poisoned?
+-- * some hogs start off with a rope and 2 drills but die after their turn?
 
--------------------------------
--- derp, script follows
--------------------------------
+------------------
+-- script follows
+------------------
 
 HedgewarsScriptLoad("/Scripts/Locale.lua")
 HedgewarsScriptLoad("/Scripts/Tracker.lua")
@@ -95,25 +26,25 @@
 -- These define weps allowed by the script.
 -- These were arbitrarily defined out-of-order in initial script, so that was preserved here, resulting 
 -- in a moderately odd syntax.
-local atkWeps = 	{
-					[amBazooka]=true, [amBee]=true, [amMortar]=true, [amDrill]=true, [amSnowball]=true,
-                    [amGrenade]=true, [amClusterBomb]=true, [amMolotov]=true, [amWatermelon]=true,
-                    [amHellishBomb]=true, [amGasBomb]=true, [amShotgun]=true, [amDEagle]=true,
-                    [amFlamethrower]=true, [amSniperRifle]=true, [amSineGun]=true, [amMinigun]=true,
-					[amFirePunch]=true, [amWhip]=true, [amBaseballBat]=true, [amKamikaze]=true,
-                    [amSeduction]=true, [amHammer]=true, [amMine]=true, [amDynamite]=true, [amCake]=true,
-                    [amBallgun]=true, [amSMine]=true, [amRCPlane]=true, [amBirdy]=true, [amKnife]=true,
-                    [amAirAttack]=true, [amMineStrike]=true, [amNapalm]=true, [amDrillStrike]=true, [amPiano]=true, [amAirMine] = true,
-                    [amDuck]=true,
-					}
+local atkWeps = {
+	[amBazooka]=true, [amBee]=true, [amMortar]=true, [amDrill]=true, [amSnowball]=true,
+	[amGrenade]=true, [amClusterBomb]=true, [amMolotov]=true, [amWatermelon]=true,
+	[amHellishBomb]=true, [amGasBomb]=true, [amShotgun]=true, [amDEagle]=true,
+	[amFlamethrower]=true, [amSniperRifle]=true, [amSineGun]=true, [amMinigun]=true,
+	[amFirePunch]=true, [amWhip]=true, [amBaseballBat]=true, [amKamikaze]=true,
+	[amSeduction]=true, [amHammer]=true, [amMine]=true, [amDynamite]=true, [amCake]=true,
+	[amBallgun]=true, [amSMine]=true, [amRCPlane]=true, [amBirdy]=true, [amKnife]=true,
+	[amAirAttack]=true, [amMineStrike]=true, [amNapalm]=true, [amDrillStrike]=true, [amPiano]=true, [amAirMine] = true,
+	[amDuck]=true,
+}
 
 local utilWeps =  {
-					[amBlowTorch]=true, [amPickHammer]=true, [amGirder]=true, [amPortalGun]=true,
-					[amRope]=true, [amParachute]=true, [amTeleport]=true, [amJetpack]=true,
-					[amInvulnerable]=true, [amLaserSight]=true, [amVampiric]=true,
-					[amLowGravity]=true, [amExtraDamage]=true, [amExtraTime]=true,
-					[amLandGun]=true, [amRubber]=true, [amIceGun]=true,
-					}
+	[amBlowTorch]=true, [amPickHammer]=true, [amGirder]=true, [amPortalGun]=true,
+	[amRope]=true, [amParachute]=true, [amTeleport]=true, [amJetpack]=true,
+	[amInvulnerable]=true, [amLaserSight]=true, [amVampiric]=true,
+	[amLowGravity]=true, [amExtraDamage]=true, [amExtraTime]=true,
+	[amLandGun]=true, [amRubber]=true, [amIceGun]=true,
+}
 
 -- Intentionally left out:
 -- * Resurrector (guaranteed to screw up the game)
@@ -137,7 +68,7 @@
 local atktot = 0
 local utiltot = 0
 
-local someHog = nil -- just for looking up the weps
+local teleportConverted = false -- used for special handling of teleport when gfPlaceHog is active
 
 -- Script parameter stuff
 
@@ -159,32 +90,32 @@
 that is, the state to which your inventory will get reset in the next turn.
 
 No Multi-Use (default):
-    If you kill a hog who owns a weapon you currently have in your reset inventory,
-    but not your inventory, you DO NOT get this weapon again.
+	If you kill a hog who owns a weapon you currently have in your reset inventory,
+	but not your inventory, you DO NOT get this weapon again.
 
 Multi-Use:
-    If you kill a hog who owns a weapon you currently have in your reset inventory,
-    but not your inventory, you DO get this weapon.
+	If you kill a hog who owns a weapon you currently have in your reset inventory,
+	but not your inventory, you DO get this weapon.
 
 Example 1:
-    You have a ballgun, and use it to kill a hog who also owns a ballgun.
-    No Multi-Use: You will NOT get another ballgun, since it's in your
-                  reset inventory.
-    Multi-Use: You get another ballgun.
+	You have a ballgun, and use it to kill a hog who also owns a ballgun.
+	No Multi-Use: You will NOT get another ballgun, since it's in your
+	reset inventory.
+	Multi-Use: You get another ballgun.
 
 Example 2:
-    You have a grenade and a bazooka in your inventory. You use the bazooka
-    to kill a hedgehog who owns a grenade.
-    In both ammo limit modes, you do NOT win any ammo since you already have
-    a grenade in your inventory (not just your reset inventory), and the
-    rule “no more than 1 ammo per type” applies.
+	You have a grenade and a bazooka in your inventory. You use the bazooka
+	to kill a hedgehog who owns a grenade.
+	In both ammo limit modes, you do NOT win any ammo since you already have
+	a grenade in your inventory (not just your reset inventory), and the
+	rule “no more than 1 ammo per type” applies.
 ]]
 local multiUse = false
 
 function onParameters()
-    parseParams()
-    multiUse = params["multiuse"] == "true"
-    loyal = params["loyal"] == "true"
+	parseParams()
+	multiUse = params["multiuse"] == "true"
+	loyal = params["loyal"] == "true"
 end
 
 function CheckForWeaponSwap()
@@ -208,58 +139,52 @@
 end
 
 function StartingSetUp(gear)
-    for i = 0, AmmoTypeMax do
-        if i ~= amNothing then
-            setGearValue(gear,i,0)
-        end
-    end
-    for w,c in pairs(wepArray) do
-        if c == 9 and (atkWeps[w] or utilWeps[w])  then
-            setGearValue(gear,w,1)
-        end
+	for i = 0, AmmoTypeMax do
+		if i ~= amNothing then
+			setGearValue(gear,i,0)
+		end
+	end
+	for w,c in pairs(wepArray) do
+		if c == 9 and (atkWeps[w] or utilWeps[w])  then
+			setGearValue(gear,w,1)
+		end
 	end
 
 	setGearValue(gear,amSkip,100)
    
-    local r = 0
-    if atktot > 0 then
-        r = GetRandom(atktot)+1
-        for i = 0, AmmoTypeMax do
-            if i ~= amNothing then
-                if atkChoices[i] >= r then
-                    setGearValue(gear,i,1)
-                    break
-                end
-            end
-        end
-    end
-    if utiltot > 0 then
-        r = GetRandom(utiltot)+1
-        for i = 0, AmmoTypeMax do
-            if i ~= amNothing then
-                if utilChoices[i] >= r then
-                    setGearValue(gear,i,1)
-                    break
-                end
-            end
-        end
-    end
+	local r = 0
+	if atktot > 0 then
+		r = GetRandom(atktot)+1
+		for i = 0, AmmoTypeMax do
+			if i ~= amNothing then
+				if atkChoices[i] >= r then
+					setGearValue(gear,i,1)
+					break
+				end
+			end
+		end
+	end
+	if utiltot > 0 then
+		r = GetRandom(utiltot)+1
+		for i = 0, AmmoTypeMax do
+			if i ~= amNothing then
+				if utilChoices[i] >= r then
+					setGearValue(gear,i,1)
+					break
+				end
+			end
+		end
+	end
 end
 
---[[function SaveWeapons(gear)
--- er, this has no 0 check so presumably if you use a weapon then when it saves  you wont have it
-
-	for i = 1, (#wepArray) do
-		setGearValue(gear, wepArray[i], GetAmmoCount(gear, wepArray[i]) )
-		 --AddAmmo(gear, wepArray[i], getGearValue(gear,wepArray[i]) )
+function ConvertValues(gear)
+	for w,c in pairs(wepArray) do
+		-- Add hog ammo loadout, but don't touch teleport if in hog placement phase.
+		-- If in hog placement phase, teleport will be touched later (see onNewTurn).
+		if not (GetGameFlag(gfPlaceHog) and TotalRounds == -1 and (w == amTeleport)) then
+			AddAmmo(gear, w, getGearValue(gear,w) )
+		end
 	end
-
-end]]
-
-function ConvertValues(gear)
-    for w,c in pairs(wepArray) do
-		AddAmmo(gear, w, getGearValue(gear,w) )
-    end
 end
 
 -- this is called when a hog dies
@@ -267,19 +192,19 @@
 
 	if CurrentHedgehog ~= nil and CurrentHedgehog ~= gear and (not loyal or (GetHogClan(CurrentHedgehog) ~= GetHogClan(gear))) then
 
-        local x,y,color
-        local vgear
-        local vgtX, vgtY, vgtdX, vgtdY, vgtAngle, vgtFrame, vgtFrameTicks, vgtState, vgtTimer, vgtTint
-        local dspl = IsHogLocal(CurrentHedgehog)
-        local ammolist = ''
+		local x,y,color
+		local vgear
+		local vgtX, vgtY, vgtdX, vgtdY, vgtAngle, vgtFrame, vgtFrameTicks, vgtState, vgtTimer, vgtTint
+		local dspl = IsHogLocal(CurrentHedgehog)
+		local ammolist = ''
 
-        if dspl then
-            x,y = GetGearPosition(CurrentHedgehog)
-            color = GetClanColor(GetHogClan(CurrentHedgehog))
-        end
+		if dspl then
+			x,y = GetGearPosition(CurrentHedgehog)
+			color = GetClanColor(GetHogClan(CurrentHedgehog))
+		end
 
-        for w,c in pairs(wepArray) do
-			val = getGearValue(gear,w)
+		for w,c in pairs(wepArray) do
+			local val = getGearValue(gear,w)
 			if val ~= 0 and (multiUse or (wepArray[w] ~= 9 and getGearValue(CurrentHedgehog, w) == 0))  then
 				setGearValue(CurrentHedgehog, w, val)
 
@@ -290,29 +215,29 @@
 				else
 					AddAmmo(CurrentHedgehog, w, val)
 				end
-                if dspl then
-                    if ammolist == '' then
-                        ammolist = GetAmmoName(w)
-                    else
-                        ammolist = ammolist .. ' • ' .. GetAmmoName(w)
-                    end
-                    x = x + 2
-                    y = y + 32
-                    vgear = AddVisualGear(x, y, vgtAmmo, 0, true)
-                    if vgear ~= nil then
-                        vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint = GetVisualGearValues(vgear)
-                        vgtFrame = w
-                        SetVisualGearValues(vgear,vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint)
-                    end
-                end
+				if dspl then
+					if ammolist == '' then
+						ammolist = GetAmmoName(w)
+					else
+						ammolist = ammolist .. ' • ' .. GetAmmoName(w)
+					end
+					x = x + 2
+					y = y + 32
+					vgear = AddVisualGear(x, y, vgtAmmo, 0, true)
+					if vgear ~= nil then
+						vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint = GetVisualGearValues(vgear)
+						vgtFrame = w
+						SetVisualGearValues(vgear,vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint)
+					end
+				end
 
 			end
 		end
 
-        if dspl and ammolist ~= '' then
-            PlaySound(sndShotgunReload);
-            AddCaption(ammolist, color, capgrpAmmoinfo)
-        end
+		if dspl and ammolist ~= '' then
+			PlaySound(sndShotgunReload);
+			AddCaption(ammolist, color, capgrpAmmoinfo)
+		end
 	end
 
 end
@@ -336,34 +261,31 @@
 end
 
 function onGameStart()
-    utilChoices[amSkip] = 0
-    local c = 0
-    for i = 0, AmmoTypeMax do
-        if i ~= amNothing then
-            atkChoices[i] = 0
-            utilChoices[i] = 0
-            if i ~= 7 then
-                wepArray[i] = 0
-                c = GetAmmoCount(someHog, i)
-                if c > 8 then c = 9 end
-                wepArray[i] = c
-                if c < 9 and c > 0 then
-                    if atkWeps[i] then
-                        --WriteLnToConsole('a    c: '..c..' w:'..i)
-                        atktot = atktot + probability[c]
-                        atkChoices[i] = atktot
-                    elseif utilWeps[i] then
-                        --WriteLnToConsole('u    c: '..c..' w:'..i)
-                            utiltot = utiltot + probability[c]
-                        utilChoices[i] = utiltot
-                    end
-                end
-            end
-        end
-    end
-
-    --WriteLnToConsole('utiltot:'..utiltot..' atktot:'..atktot)
-        
+	utilChoices[amSkip] = 0
+	local c = 0
+	for i = 0, AmmoTypeMax do
+		if i ~= amNothing then
+			atkChoices[i] = 0
+			utilChoices[i] = 0
+			if i ~= 7 then
+				wepArray[i] = 0
+				c = GetAmmo(i)
+				if c > 8 then
+					c = 9
+				end
+				wepArray[i] = c
+				if c < 9 and c > 0 then
+					if atkWeps[i] then
+						atktot = atktot + probability[c]
+						atkChoices[i] = atktot
+					elseif utilWeps[i] then
+						utiltot = utiltot + probability[c]
+						utilChoices[i] = utiltot
+					end
+				end
+			end
+		end
+	end
 
 	runOnGears(StartingSetUp)
 	runOnGears(ConvertValues)
@@ -383,7 +305,7 @@
 
 			-- re-assign ammo to this guy, so that his entire ammo set will
 			-- be visible during another player's turn
-			if lastHog ~= nil then
+			if lastHog ~= nil and GetHealth(lastHog) then
 				ConvertValues(lastHog)
 			end
 
@@ -400,40 +322,28 @@
 
 function onNewTurn()
 	CheckForHogSwitch()
+
+	-- If hog placement phase is over, set the hog's actual teleport loadout
+	if GetGameFlag(gfPlaceHog) and TotalRounds == 0 and not teleportConverted then
+		runOnHogs(function(gear)
+			AddAmmo(gear, amTeleport, getGearValue(gear, amTeleport))
+		end)
+		-- This makes sure this code is only run once
+		teleportConverted = true
+	end
 end
 
---function onGameTick20()
---CheckForHogSwitch()
--- if we use gfPerHogAmmo is this even needed? Err, well, weapons reset, so... yes?
--- orrrr, should we rather call the re-assignment of weapons onNewTurn()? probably not because
--- then you cant switch hogs... unless we add a thing in onSwitch or whatever
--- ye, that is probably better actually, but I'll add that when/if I add switch
---end
-
---[[function onHogHide(gear)
-	-- waiting for Henek
-end
-
-function onHogRestore(gear)
-	-- waiting for Henek
-end]]
-
 function onGearAdd(gear)
 
-	--if GetGearType(gear) == gtSwitcher then
-	--	SaveWeapons(CurrentHedgehog)
-	--end
-
 	if (GetGearType(gear) == gtHedgehog) then
 		trackGear(gear)
-        if someHog == nil then someHog = gear end
 	end
 
 end
 
 function onGearDelete(gear)
 
-	if (GetGearType(gear) == gtHedgehog) then --or (GetGearType(gear) == gtResurrector) then
+	if (GetGearType(gear) == gtHedgehog) then
 		TransferWeps(gear)
 		trackDeletion(gear)
 	end
--- a/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Sat Jul 07 20:22:31 2018 +0300
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Mon Jul 09 19:39:15 2018 +0300
@@ -339,6 +339,12 @@
 
 local fMod = 1000000 -- use this for dev and .16+ games
 
+-- Tag IDs
+local TAG_TIME = 0
+local TAG_BARRELS = 1
+local TAG_SHIELD = 2
+local TAG_ROUND_SCORE = 4
+
 -- some console stuff
 local shellID = 0
 local explosivesID = 0
@@ -346,6 +352,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 +471,7 @@
 local shockwaveHealth = 0
 local shockwaveRad = 300
 
-local Timer100 = 0
+local timer100 = 0
 
 local vTag = {}
 
@@ -472,11 +479,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
@@ -524,11 +531,9 @@
 
 
 
-function HideTags()
-
-	for i = 0, 4 do
-		SetVisualGearValues(vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
-	end
+function HideTag(i)
+
+	SetVisualGearValues(vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
 
 end
 
@@ -538,41 +543,40 @@
 	local xOffset = 40
 	local yOffset, tValue, tCol
 
-	if i == 0 then
+	if i == TAG_TIME then
 		yOffset = 40
 		tCol = 0xffee00ff
 		tValue = TimeLeft
-	elseif i == 1 then
+	elseif i == TAG_BARRELS then
 		zoomL = 1.1
 		yOffset = 70
 		tCol = 0x00ff00ff
 		tValue = wepAmmo[wepIndex] --primShotsLeft
-	elseif i == 2 then
+	elseif i == TAG_SHIELD then
 		zoomL = 1.1
 		xOffset = 40 + 35
 		yOffset = 70
 		tCol = 0xa800ffff
 		tValue = shieldHealth - 80
-	elseif i == 4 then
+	elseif i == TAG_ROUND_SCORE then
 		zoomL = 1.1
-		xOffset = 40 + 80
-		yOffset = 70
+		xOffset = 40
+		yOffset = 100
 		tCol = 0xffffffff
 		tValue = roundScore
 	end
 
 	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
+				-(div(ScreenWidth, 2)) + xOffset,	--xoffset
 				ScreenHeight - yOffset, --yoffset
 				0, 			--dx
 				0, 			--dy
 				zoomL, 			--zoom
 				1, 			--~= 0 means align to screen
-				g7, 			--frameticks
+				nil, 			--frameticks
 				tValue, 		--value
 				240000, 		--timer
 				tCol		--GetClanColor( GetHogClan(CurrentHedgehog) )
@@ -594,12 +598,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
@@ -645,7 +649,7 @@
 -- control
 function AwardPoints(p)
 	roundScore = roundScore + p
-	DrawTag(4)
+	DrawTag(TAG_ROUND_SCORE)
 
 	for i = 0,(TeamsCount-1) do
 		if teamClan[i] == GetHogClan(CurrentHedgehog) then
@@ -951,6 +955,7 @@
 
 function setNewGearValues(gear)
 
+	local lfs
 	if GetGearType(gear) == gtShell then
 		lfs = 50	-- roughly 5 seconds
 		shellID = shellID + 1
@@ -1052,9 +1057,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)
@@ -1065,12 +1070,12 @@
 			else
 				PlaySound(sndThrowRelease)
 			end
-			DrawTag(1)
+			DrawTag(TAG_BARRELS)
 
 		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)
+			DrawTag(TAG_BARRELS)
 		end
 
 	elseif (wepAmmo[wepIndex] == 0) and (CurrentHedgehog ~= nil) and (stopMovement == false) and (tumbleStarted == true) then
@@ -1230,7 +1235,10 @@
 		vTag[0] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
 	end
 
-	HideTags()
+	HideTag(TAG_TIME)
+	HideTag(TAG_BARRELS)
+	HideTag(TAG_SHIELD)
+	HideTag(TAG_ROUND_SCORE)
 
 	wep[0] = loc("Barrel Launcher")
 	wep[1] = loc("Mine Deployer")
@@ -1283,11 +1291,15 @@
 function onScreenResize()
 
 	-- redraw Tags so that their screen locations are updated
-	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
-			DrawTag(0)
-			DrawTag(1)
-			DrawTag(2)
-			DrawTag(4)
+	if (gameBegun == true) then
+		DrawTag(TAG_ROUND_SCORE)
+		if (stopMovement == false) then
+			DrawTag(TAG_BARRELS)
+			DrawTag(TAG_SHIELD)
+			if (tumbleStarted == true) then
+				DrawTag(TAG_TIME)
+			end
+		end
 	end
 
 end
@@ -1334,7 +1346,6 @@
 	end
 
 	if gameOver == true then
-		gameBegun = false
 		stopMovement = true
 		tumbleStarted = false
 		SetMyCircles(false)
@@ -1352,7 +1363,16 @@
 	ChangeWeapon()
 
 
-	HideTags()
+	HideTag(TAG_TIME)
+	if not gameOver then
+		DrawTag(TAG_BARRELS)
+		DrawTag(TAG_SHIELD)
+		DrawTag(TAG_ROUND_SCORE)
+	else
+		HideTag(TAG_BARRELS)
+		HideTag(TAG_SHIELD)
+		HideTag(TAG_ROUND_SCORE)
+	end
 
 	---------------
 	---------------
@@ -1367,7 +1387,7 @@
 	HandleLifeSpan(gear)
 	DeleteFarFlungBarrel(gear)
 
-	if CirclesAreGo == true then
+	if circlesAreGo == true then
 		CheckVarious(gear)
 		ProjectileTrack(gear)
 	end
@@ -1396,9 +1416,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 +1444,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,13 +1466,13 @@
 		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)
-			DrawTag(1)
-			DrawTag(2)
-			DrawTag(4)
+			DrawTag(TAG_TIME)
+			DrawTag(TAG_BARRELS)
+			DrawTag(TAG_SHIELD)
+			DrawTag(TAG_ROUND_SCORE)
 			SetMyCircles(true)
 		end
 	end
@@ -1468,7 +1488,7 @@
 			TimeLeft = TimeLeft - 1
 
 			if TimeLeft >= 0 then
-				DrawTag(0)
+				DrawTag(TAG_TIME)
 			end
 
 		end
@@ -1510,7 +1530,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)
@@ -1541,13 +1561,13 @@
 		
 				end
 
-				AddCaption(loc(string.format(loc("Round score: %d"), roundScore)), 0xFFFFFFFF, capgrpMessage2)
-
 				-- other awards
 				awardRoundScore = UpdateSimpleAward(awardRoundScore, roundScore, 50)
 				awardRoundKills = UpdateSimpleAward(awardRoundKills, roundKills, 5)
 
-				HideTags()
+				HideTag(TAG_TIME)
+				HideTag(TAG_BARRELS)
+				HideTag(TAG_SHIELD)
 
 			end
 		else -- remove this if you want tumbler to fall slowly on death
@@ -1575,22 +1595,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 +1752,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 +1796,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 +1814,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 +1872,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 +1887,7 @@
 
 function CircleDamaged(i)
 
-	res = ""
+	local res = ""
 	vCircHealth[i] = vCircHealth[i] -1
 
 	if vCircHealth[i] <= 0 then
@@ -1880,9 +1899,9 @@
 			PlaySound(sndHellishImpact4)
 			TimeLeft = TimeLeft + timeBonus
 			AddCaption(string.format(loc("Time extended! +%dsec"), timeBonus), 0xff0000ff,capgrpMessage )
-			DrawTag(0)
-
-			morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1)
+			DrawTag(TAG_TIME)
+
+			local morte = AddGear(vCircX[i], vCircY[i], gtExplosives, 0, 0, 0, 1)
 			SetHealth(morte, 0)
 
 			RK = RK + 1
@@ -1898,7 +1917,7 @@
 			PlaySound(sndShotgunReload)
 			wepAmmo[0] = wepAmmo[0] + barrelBonus
 			AddCaption(string.format(loc("+%d Ammo"), barrelBonus), 0x00ff00ff,capgrpMessage)
-			DrawTag(1)
+			DrawTag(TAG_BARRELS)
 
 			GK = GK + 1
 			if GK == 3 then
@@ -1927,7 +1946,7 @@
 				shieldHealth = 250
 				AddCaption(loc("Shield is fully recharged!"),0xa800ffff,capgrpMessage)
 			end
-			DrawTag(2)
+			DrawTag(TAG_SHIELD)
 
 			OK = OK + 1
 			if OK == 3 then
@@ -1943,7 +1962,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 +1992,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 +2005,7 @@
 function SetUpCircle(i)
 
 
-	r = GetRandom(10)
+	local r = GetRandom(10)
 	-- 80% of spawning either red/green
 	if r <= 7 then
 
@@ -2032,7 +2051,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 +2062,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 +2077,7 @@
 
 function SetMyCircles(s)
 
-	CirclesAreGo = s
+	circlesAreGo = s
 	playerIsFine = s
 
 	if s == true then
@@ -2120,7 +2137,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 +2145,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
@@ -2183,16 +2201,15 @@
 		end
 
 	-- if player is hit by circle bazooka
-	elseif (GetGearType(gear) == gtShell) then
-
-		dist = GetDistFromGearToGear(gear, CurrentHedgehog)
+	elseif (GetGearType(gear) == gtShell) and (CurrentHedgehog ~= nil) then
+
+		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)
 
@@ -2223,6 +2240,9 @@
 -- collision detection for player entering a circle
 function CheckDistances()
 
+	if not CurrentHedgehog then
+		return
+	end
 	--nw WriteLnToConsole("Start of CheckDistances()")
 
 	for i = 0,(vCCount-1) do
@@ -2230,16 +2250,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
@@ -2258,7 +2279,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
 
@@ -2335,6 +2356,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
@@ -2358,37 +2380,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
@@ -2418,7 +2435,7 @@
 				vCircDX[i] = 5	--5 circmovchange
 			else
 
-				z = GetRandom(2)
+				local z = GetRandom(2)
 				if z == 1 then
 					z = 1
 				else
@@ -2432,7 +2449,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
@@ -2462,9 +2479,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
@@ -2479,33 +2496,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 )
-			DrawTag(2)
+			SetVisualGearValues(pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, 200, nil, 0xa800ffff-0x000000ff - -shieldHealth )
+			DrawTag(TAG_SHIELD)
 		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
@@ -2519,11 +2532,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)
@@ -2542,10 +2553,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