Fix hog not getting new ammo in Highlander when it takes 2 consecutive turns
authorWuzzy <almikes@aol.com>
Sat, 22 Apr 2017 23:55:49 +0200
changeset 12308 82951b9b3c2f
parent 12307 cbc34bb96b1f
child 12309 6b34067a6344
Fix hog not getting new ammo in Highlander when it takes 2 consecutive turns This happens when all enemy hogs are frozen
ChangeLog.txt
share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua
--- a/ChangeLog.txt	Sat Apr 22 23:30:46 2017 +0200
+++ b/ChangeLog.txt	Sat Apr 22 23:55:49 2017 +0200
@@ -45,6 +45,7 @@
 Highlander:
  + Show collected weapons after kill and play sound
  + Mission panel now shows all game modifiers (e.g. mines time, vampirism, etc.)
+ * Fix hog not receiving new ammo when it takes two consecutive turns (happens when all enemy hogs are frozen)
 
 Construction Mode:
  + Added script parameter support:
--- a/share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua	Sat Apr 22 23:30:46 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua	Sat Apr 22 23:55:49 2017 +0200
@@ -118,8 +118,6 @@
 local atkChoices = {}
 local utilChoices = {}
 
-local currHog
-local lastHog
 local started = false
 local switchStage = 0
 
@@ -311,33 +309,19 @@
 	runOnGears(ConvertValues)
 end
 
-function CheckForHogSwitch()
-
-	if (CurrentHedgehog ~= nil) then
-
-		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
-
-		lastHog = currHog
-
+function AssignHogAmmo()
+	-- 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
 
 function onNewTurn()
-	CheckForHogSwitch()
+	AssignHogAmmo()
 end
 
 --function onGameTick20()