Add support for more players.
authormikade
Fri, 09 Sep 2011 03:00:03 +0200
changeset 5819 e23ced69e03d
parent 5817 70208e400a59
child 5821 afb988c1a2fe
Add support for more players. (Hopefully) prevent Time-Box (or is that Time Box?) ruining my life.
share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua	Fri Sep 09 02:11:51 2011 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua	Fri Sep 09 03:00:03 2011 +0200
@@ -1,5 +1,5 @@
 ---------------------------------------
--- CAPTURE_THE_FLAG GAMEPLAY MODE 0.4
+-- CAPTURE_THE_FLAG GAMEPLAY MODE 0.5
 -- by mikade
 ---------------------------------------
 
@@ -61,6 +61,14 @@
 -- changed starting feedback a little
 -- increased the radius around the circle indicating the flag thief so that it doesn't obscure his health
 
+--------
+-- 0.5
+--------
+
+-- add support for more players
+-- stop TimeBox ruining my life
+-- profit???
+
 -----------------
 --SCRIPT BEGINS
 -----------------
@@ -342,7 +350,7 @@
 
 
 	-- make a list of individual team names
-	for i = 0, 5 do
+	for i = 0, (TeamsCount-1) do
 		teamNameArr[i] = i
 		teamSize[i] = 0
 		teamIndex[i] = 0
@@ -562,6 +570,36 @@
 
 end
 
+function InABetterPlaceNow(gear)
+	for i = 0, (numhhs-1) do
+		if gear == hhs[i] then
+				
+			for i = 0,1 do
+				if gear == fThief[i] then
+					FlagThiefDead(gear)
+				end
+			end				
+			hhs[i] = nil	
+		end		
+	end
+end
+
+function onHogHide(gear)
+	 InABetterPlaceNow(gear)
+end
+
+function onHogRestore(gear)
+	match = false	
+	for i = 0, (numhhs-1) do
+		if (hhs[i] == nil) and (match == false) then
+			hhs[i] = gear
+			--AddCaption(GetHogName(gear) .. " has reappeared it seems!")	
+			match = true
+		end
+	end
+end
+
+
 function onGearAdd(gear)
 
 	if GetGearType(gear) == gtHedgehog then
@@ -584,17 +622,7 @@
 function onGearDelete(gear)
 
 	if GetGearType(gear) == gtHedgehog then
-		for i = 0, (numhhs-1) do
-			if gear == hhs[i] then
-				
-				for i = 0,1 do
-					if gear == fThief[i] then
-						FlagThiefDead(gear)
-					end
-				end				
-				hhs[i] = nil	
-			end		
-		end
+		InABetterPlaceNow(gear)		
 	end
 
 end