share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua
changeset 15252 515a4a317e52
parent 15130 13e7d4eccb67
child 15788 acf70c44065b
equal deleted inserted replaced
15251:9be05ae1b726 15252:515a4a317e52
    87 ----------to read about tables properly
    87 ----------to read about tables properly
    88 ------------------ "Oh well, they probably have the memory"
    88 ------------------ "Oh well, they probably have the memory"
    89 
    89 
    90 local gameStarted = false
    90 local gameStarted = false
    91 local gameOver = false
    91 local gameOver = false
       
    92 local winningClan = -1
    92 local captureLimit = 3
    93 local captureLimit = 3
    93 
    94 
    94 --------------------------
    95 --------------------------
    95 -- hog and team tracking variales
    96 -- hog and team tracking variales
    96 --------------------------
    97 --------------------------
   176 
   177 
   177 function CheckScore(clanID)
   178 function CheckScore(clanID)
   178 
   179 
   179 	if fCaptures[clanID] == captureLimit then
   180 	if fCaptures[clanID] == captureLimit then
   180 		gameOver = true
   181 		gameOver = true
       
   182 		winningClan = clanID
   181 		-- Capture limit reached! We have a winner!
   183 		-- Capture limit reached! We have a winner!
   182 		for i = 0, (numhhs-1) do
   184 		for i = 0, (numhhs-1) do
   183 			if hhs[i] ~= nil then
   185 			if hhs[i] ~= nil then
   184 				-- Kill all losers
   186 				-- Kill all losers
   185 				if GetHogClan(hhs[i]) ~= clanID then
   187 				if GetHogClan(hhs[i]) ~= winningClan then
   186 					SetEffect(hhs[i], heResurrectable, 0)
   188 					SetEffect(hhs[i], heResurrectable, 0)
   187 					SetHealth(hhs[i],0)
   189 					SetHealth(hhs[i],0)
   188 				end
   190 				end
   189 			end
   191 			end
   190 		end
   192 		end
   627 		if (hhs[i] == nil) then
   629 		if (hhs[i] == nil) then
   628 			hhs[i] = gear
   630 			hhs[i] = gear
   629 			break
   631 			break
   630 		end
   632 		end
   631 	end
   633 	end
       
   634 	if gameOver and GetHogClan(gear) ~= winningClan then
       
   635 		SetEffect(gear, heResurrectable, 0)
       
   636 		SetHealth(gear, 0)
       
   637 	end
   632 end
   638 end
   633 
   639 
   634 function onHogAttack(ammoType)
   640 function onHogAttack(ammoType)
   635 	if not gameStarted and ammoType == amTardis then
   641 	if not gameStarted and ammoType == amTardis then
   636 		local i = GetHogClan(CurrentHedgehog)
   642 		local i = GetHogClan(CurrentHedgehog)