share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua
changeset 15257 515a4a317e52
parent 15135 13e7d4eccb67
--- a/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua	Thu Jul 18 03:25:15 2019 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua	Thu Jul 18 03:39:58 2019 +0200
@@ -89,6 +89,7 @@
 
 local gameStarted = false
 local gameOver = false
+local winningClan = -1
 local captureLimit = 3
 
 --------------------------
@@ -178,11 +179,12 @@
 
 	if fCaptures[clanID] == captureLimit then
 		gameOver = true
+		winningClan = clanID
 		-- Capture limit reached! We have a winner!
 		for i = 0, (numhhs-1) do
 			if hhs[i] ~= nil then
 				-- Kill all losers
-				if GetHogClan(hhs[i]) ~= clanID then
+				if GetHogClan(hhs[i]) ~= winningClan then
 					SetEffect(hhs[i], heResurrectable, 0)
 					SetHealth(hhs[i],0)
 				end
@@ -629,6 +631,10 @@
 			break
 		end
 	end
+	if gameOver and GetHogClan(gear) ~= winningClan then
+		SetEffect(gear, heResurrectable, 0)
+		SetHealth(gear, 0)
+	end
 end
 
 function onHogAttack(ammoType)