share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua
changeset 13109 e0ec37c8104d
parent 13108 cf2a58dccc4a
child 13111 115d7438aa3d
--- a/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua	Thu Mar 08 01:22:00 2018 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua	Thu Mar 08 02:03:23 2018 +0100
@@ -417,14 +417,6 @@
 
 	for i = 0, 1 do
 
-		-- if someone uses kamikaze downwards, this can happen as the hog won't respawn
-		if (LAND_HEIGHT - fSpawnY[i]) < 0 then
-			tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
-     			FindPlace(tempG, true, 0, LAND_WIDTH, true)
-			fSpawnX[i], fSpawnY[i] = GetGearPosition(tempG)
-			DeleteGear(tempG)
-		end
-
 		fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
 		fCirc[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
 		fSpawnC[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
@@ -515,8 +507,10 @@
 		end
 	end]]
 
-	fPlaced[0] = false
-	fPlaced[1] = false
+	for i=0, 1 do
+		fPlaced[i] = false
+		fCaptures[i] = 0
+	end
 
 	--zxc = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
 
@@ -524,12 +518,12 @@
 	--SetVisualGearValues(zxc, 1000,1000, 20, 255, 1,    10,                     0,         200,        1,      GetClanColor(0))
 					--minO,max0 -glowyornot	--pulsate timer	 -- fuckall      -- radius -- width  -- colour
 	for h=1, numhhs do
-		-- Tardis causes too many unexpected situations, so we forbid it
-		AddAmmo(hhs[h], amTardis, 0)
 		-- Hogs are resurrected for free, so this is pointless
 		AddAmmo(hhs[h], amResurrector, 0)
 	end
 
+	updateScores()
+
 end
 
 
@@ -593,7 +587,7 @@
 			i = 1
 		end
 
-		if TurnTimeLeft == 0 then
+		if TurnTimeLeft == 0 and GetX(CurrentHedgehog) then
 			fSpawnX[i] = GetX(CurrentHedgehog)
 			fSpawnY[i] = GetY(CurrentHedgehog)
 		end
@@ -654,6 +648,13 @@
 	end
 end
 
+function onHogAttack(ammoType)
+	if not gameStarted and ammoType == amTardis then
+		local i = GetHogClan(CurrentHedgehog)
+		fSpawnX[i] = GetX(CurrentHedgehog)
+		fSpawnY[i] = GetY(CurrentHedgehog)
+	end
+end
 
 function onGearAdd(gear)
 
@@ -678,6 +679,10 @@
 
 	if GetGearType(gear) == gtHedgehog then
 		InABetterPlaceNow(gear)
+	elseif GetGearType(gear) == gtKamikaze and not gameStarted then
+		local i = GetHogClan(CurrentHedgehog)
+		fSpawnX[i] = GetX(CurrentHedgehog)
+		fSpawnY[i] = GetY(CurrentHedgehog)
 	end
 
 end