share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua
changeset 12320 a85212a8d0e0
parent 12309 6b34067a6344
child 12321 1be56fa243c8
--- a/share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua	Mon Apr 24 23:11:51 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua	Tue Apr 25 02:13:18 2017 +0200
@@ -118,6 +118,8 @@
 local atkChoices = {}
 local utilChoices = {}
 
+local currHog
+local lastHog
 local started = false
 local switchStage = 0
 
@@ -128,7 +130,6 @@
 local atktot = 0
 local utiltot = 0
 
-local lastHog = nil
 local someHog = nil -- just for looking up the weps
 
 local mode = nil
@@ -310,23 +311,33 @@
 	runOnGears(ConvertValues)
 end
 
-function AssignHogAmmo()
+function CheckForHogSwitch()
+
 	if (CurrentHedgehog ~= nil) then
-		-- Re-assign ammo to this guy, so that his entire ammo set will
-		-- be visible during another player's turn
-		if lastHog ~= nil then
-			ConvertValues(lastHog)
+
+		currHog = CurrentHedgehog
+
+		if currHog ~= lastHog then
+
+			-- re-assign ammo to this guy, so that his entire ammo set will
+			-- be visible during another player's turn
+			if lastHog ~= nil then
+				ConvertValues(lastHog)
+			end
+
+			-- give the new hog what he is supposed to have, too
+			ConvertValues(CurrentHedgehog)
+
 		end
 
-		-- Give the new hog what he is supposed to have, too
-		ConvertValues(CurrentHedgehog)
+		lastHog = currHog
 
-		lastHog = CurrentHedgehog
 	end
+
 end
 
 function onNewTurn()
-	AssignHogAmmo()
+	CheckForHogSwitch()
 end
 
 --function onGameTick20()