share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua
changeset 5827 a416f1070fdf
parent 5821 afb988c1a2fe
child 7838 5c2337f8dbb2
equal deleted inserted replaced
5825:a6eab1b7c00d 5827:a416f1070fdf
    82 ----------because someone is too lazy
    82 ----------because someone is too lazy
    83 ----------to read about tables properly
    83 ----------to read about tables properly
    84 ------------------ "Oh well, they probably have the memory"
    84 ------------------ "Oh well, they probably have the memory"
    85 
    85 
    86 local gameStarted = false
    86 local gameStarted = false
    87 local gameTurns = 0	
    87 local gameTurns = 0
    88 
    88 
    89 --------------------------
    89 --------------------------
    90 -- hog and team tracking variales
    90 -- hog and team tracking variales
    91 --------------------------
    91 --------------------------
    92 
    92 
   140 		alt = 0
   140 		alt = 0
   141 	end
   141 	end
   142 
   142 
   143 	if fCaptures[teamID] == 3 then
   143 	if fCaptures[teamID] == 3 then
   144 		for i = 0, (numhhs-1) do
   144 		for i = 0, (numhhs-1) do
   145 			if hhs[i] ~= nil then			
   145 			if hhs[i] ~= nil then
   146 				if GetHogClan(hhs[i]) == alt then
   146 				if GetHogClan(hhs[i]) == alt then
   147 					SetEffect(hhs[i], heResurrectable, false)
   147 					SetEffect(hhs[i], heResurrectable, false)
   148 					SetHealth(hhs[i],0)
   148 					SetHealth(hhs[i],0)
   149 				end
   149 				end
   150 			end
   150 			end
   151 		end
   151 		end
   152 		if CurrentHedgehog ~= nil then		
   152 		if CurrentHedgehog ~= nil then
   153 			ShowMission(loc("GAME OVER!"), loc("Victory for the ") .. GetHogTeamName(CurrentHedgehog), loc("Hooray!"), 0, 0)
   153 			ShowMission(loc("GAME OVER!"), loc("Victory for the ") .. GetHogTeamName(CurrentHedgehog), loc("Hooray!"), 0, 0)
   154 		end
   154 		end
   155 	end
   155 	end
   156 
   156 
   157 end
   157 end
   163 		bbq = 1
   163 		bbq = 1
   164 	elseif (gear == fGear[1]) then
   164 	elseif (gear == fGear[1]) then
   165 		wtf = 1
   165 		wtf = 1
   166 		bbq = 0
   166 		bbq = 0
   167 	end
   167 	end
   168 	
   168 
   169 	-- player has successfully captured the enemy flag
   169 	-- player has successfully captured the enemy flag
   170 	if (GetHogClan(CurrentHedgehog) == wtf) and (CurrentHedgehog == fThief[bbq]) and (fIsMissing[wtf] == false) then
   170 	if (GetHogClan(CurrentHedgehog) == wtf) and (CurrentHedgehog == fThief[bbq]) and (fIsMissing[wtf] == false) then
   171 		
   171 
   172 		DeleteVisualGear(fGear[wtf])
   172 		DeleteVisualGear(fGear[wtf])
   173 		fGear[wtf] = nil -- the flag has now disappeared				
   173 		fGear[wtf] = nil -- the flag has now disappeared
   174 				
   174 
   175 		fIsMissing[wtf] = false
   175 		fIsMissing[wtf] = false
   176 		fNeedsRespawn[wtf] = true
   176 		fNeedsRespawn[wtf] = true
   177 		fIsMissing[bbq] = false
   177 		fIsMissing[bbq] = false
   178 		fNeedsRespawn[bbq] = true
   178 		fNeedsRespawn[bbq] = true
   179 		fCaptures[wtf] = fCaptures[wtf] +1				
   179 		fCaptures[wtf] = fCaptures[wtf] +1
   180 		ShowMission(loc("You have SCORED!!"), GetHogTeamName(CurrentHedgehog) .. ": " .. fCaptures[wtf], loc("Opposing Team: ") .. fCaptures[bbq], 0, 0)
   180 		ShowMission(loc("You have SCORED!!"), GetHogTeamName(CurrentHedgehog) .. ": " .. fCaptures[wtf], loc("Opposing Team: ") .. fCaptures[bbq], 0, 0)
   181 		PlaySound(sndVictory)
   181 		PlaySound(sndVictory)
   182 		fThief[bbq] = nil -- player no longer has the enemy flag
   182 		fThief[bbq] = nil -- player no longer has the enemy flag
   183 		CheckScore(wtf)
   183 		CheckScore(wtf)
   184 
   184 
   185 	--if the player is returning the flag
   185 	--if the player is returning the flag
   186 	elseif (GetHogClan(CurrentHedgehog) == wtf) and (fIsMissing[wtf] == true) then
   186 	elseif (GetHogClan(CurrentHedgehog) == wtf) and (fIsMissing[wtf] == true) then
   187 			
   187 
   188 		DeleteVisualGear(fGear[wtf])
   188 		DeleteVisualGear(fGear[wtf])
   189 		fGear[wtf] = nil -- the flag has now disappeared
   189 		fGear[wtf] = nil -- the flag has now disappeared
   190 					
   190 
   191 		fNeedsRespawn[wtf] = true					
   191 		fNeedsRespawn[wtf] = true
   192 		HandleRespawns() -- this will set fIsMissing[wtf] to false :)
   192 		HandleRespawns() -- this will set fIsMissing[wtf] to false :)
   193 		AddCaption(loc("Flag returned!"))
   193 		AddCaption(loc("Flag returned!"))
   194 	
   194 
   195 	--if the player is taking the enemy flag
   195 	--if the player is taking the enemy flag
   196 	elseif GetHogClan(CurrentHedgehog) == bbq then
   196 	elseif GetHogClan(CurrentHedgehog) == bbq then
   197 				
   197 
   198 		DeleteVisualGear(fGear[wtf])
   198 		DeleteVisualGear(fGear[wtf])
   199 		fGear[wtf] = nil -- the flag has now disappeared				
   199 		fGear[wtf] = nil -- the flag has now disappeared
   200 				
   200 
   201 		fIsMissing[wtf] = true
   201 		fIsMissing[wtf] = true
   202 		for i = 0,numhhs-1 do
   202 		for i = 0,numhhs-1 do
   203 			if CurrentHedgehog ~= nil then			
   203 			if CurrentHedgehog ~= nil then
   204 				if CurrentHedgehog == hhs[i] then
   204 				if CurrentHedgehog == hhs[i] then
   205 					fThief[wtf] = hhs[i]
   205 					fThief[wtf] = hhs[i]
   206 				end
   206 				end
   207 			end
   207 			end
   208 		end
   208 		end
   209 		AddCaption(loc("Flag captured!"))
   209 		AddCaption(loc("Flag captured!"))
   210 
   210 
   211 	end
   211 	end
   212 	
   212 
   213 end
   213 end
   214 
   214 
   215 function CheckFlagProximity() 
   215 function CheckFlagProximity()
   216 
   216 
   217 	for i = 0, 1 do
   217 	for i = 0, 1 do
   218 		if fGear[i] ~= nil then
   218 		if fGear[i] ~= nil then
   219 			
   219 
   220 			g1X = fGearX[i]
   220 			g1X = fGearX[i]
   221 			g1Y = fGearY[i]			
   221 			g1Y = fGearY[i]
   222 	
   222 
   223 			g2X, g2Y = GetGearPosition(CurrentHedgehog)
   223 			g2X, g2Y = GetGearPosition(CurrentHedgehog)
   224 
   224 
   225 			q = g1X - g2X
   225 			q = g1X - g2X
   226 			w = g1Y - g2Y
   226 			w = g1Y - g2Y
   227 			dist = (q*q) + (w*w)
   227 			dist = (q*q) + (w*w)
   228 			
   228 
   229 			if dist < 500 then --1600
   229 			if dist < 500 then --1600
   230 				DoFlagStuff(fGear[i])
   230 				DoFlagStuff(fGear[i])
   231 			end
   231 			end
   232 		end
   232 		end
   233 	end
   233 	end
   240 	for i = 0, 1 do
   240 	for i = 0, 1 do
   241 
   241 
   242 		if fNeedsRespawn[i] == true then
   242 		if fNeedsRespawn[i] == true then
   243 			fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   243 			fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   244 			fGearX[i] = fSpawnX[i]
   244 			fGearX[i] = fSpawnX[i]
   245 			fGearY[i] = fSpawnY[i]			
   245 			fGearY[i] = fSpawnY[i]
   246 
   246 
   247 			fNeedsRespawn[i] = false
   247 			fNeedsRespawn[i] = false
   248 			fIsMissing[i] = false -- new, this should solve problems of a respawned flag being "returned" when a player tries to score
   248 			fIsMissing[i] = false -- new, this should solve problems of a respawned flag being "returned" when a player tries to score
   249 			AddCaption(loc("Flag respawned!"))
   249 			AddCaption(loc("Flag respawned!"))
   250 		end
   250 		end
   263 		wtf = 1
   263 		wtf = 1
   264 		bbq = 0
   264 		bbq = 0
   265 	end
   265 	end
   266 
   266 
   267 	if fThief[wtf] ~= nil then
   267 	if fThief[wtf] ~= nil then
   268 		-- falls into water		
   268 		-- falls into water
   269 		--ShowMission(LAND_HEIGHT,  fThiefY[wtf], (LAND_HEIGHT - fThiefY[wtf]), 0, 0)	
   269 		--ShowMission(LAND_HEIGHT,  fThiefY[wtf], (LAND_HEIGHT - fThiefY[wtf]), 0, 0)
   270 		if (LAND_HEIGHT - fThiefY[wtf]) < 15 then
   270 		if (LAND_HEIGHT - fThiefY[wtf]) < 15 then
   271 			fIsMissing[wtf] = true
   271 			fIsMissing[wtf] = true
   272 			fNeedsRespawn[wtf] = true
   272 			fNeedsRespawn[wtf] = true
   273 			HandleRespawns()
   273 			HandleRespawns()
   274 		else	--normally	
   274 		else	--normally
   275 			fGearX[wtf]  =  fThiefX[wtf]
   275 			fGearX[wtf]  =  fThiefX[wtf]
   276 			fGearY[wtf]  =  fThiefY[wtf]	
   276 			fGearY[wtf]  =  fThiefY[wtf]
   277 			fGear[wtf] = AddVisualGear(fGearX[wtf],fGearY[wtf],vgtCircle,0,true)		
   277 			fGear[wtf] = AddVisualGear(fGearX[wtf],fGearY[wtf],vgtCircle,0,true)
   278 		end
   278 		end
   279 
   279 
   280 		AddVisualGear(fThiefX[wtf], fThiefY[wtf], vgtBigExplosion, 0, false)
   280 		AddVisualGear(fThiefX[wtf], fThiefY[wtf], vgtBigExplosion, 0, false)
   281 		fThief[wtf] = nil
   281 		fThief[wtf] = nil
   282 	end
   282 	end
   288 	fGearTimer = fGearTimer + 1
   288 	fGearTimer = fGearTimer + 1
   289 	if fGearTimer == 50 then
   289 	if fGearTimer == 50 then
   290 		fGearTimer = 0
   290 		fGearTimer = 0
   291 		fGearRad = fGearRad + 1
   291 		fGearRad = fGearRad + 1
   292 		if fGearRad > fGearRadMax then
   292 		if fGearRad > fGearRadMax then
   293 			fGearRad = fGearRadMin	
   293 			fGearRad = fGearRadMin
   294 		end
   294 		end
   295 	end
   295 	end
   296 
   296 
   297 	for i = 0, 1 do
   297 	for i = 0, 1 do
   298 		
   298 
   299 		--SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, 50, 3, fCol[i]) -- draw a circ for spawning area
   299 		--SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, 50, 3, fCol[i]) -- draw a circ for spawning area
   300 		
   300 
   301 		if fIsMissing[i] == false then -- draw a flag marker at the flag's spawning place
   301 		if fIsMissing[i] == false then -- draw a flag marker at the flag's spawning place
   302 			SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 20, 0, 10, 0, 33, 3, fCol[i])
   302 			SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 20, 0, 10, 0, 33, 3, fCol[i])
   303 			if fGear[i] ~= nil then -- draw the flag gear itself
   303 			if fGear[i] ~= nil then -- draw the flag gear itself
   304 				SetVisualGearValues(fGear[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
   304 				SetVisualGearValues(fGear[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
   305 			end
   305 			end
   306 		elseif (fIsMissing[i] == true) and (fNeedsRespawn[i] == false) then
   306 		elseif (fIsMissing[i] == true) and (fNeedsRespawn[i] == false) then
   307 			if fThief[i] ~= nil then -- draw circle round flag carrier			-- 33
   307 			if fThief[i] ~= nil then -- draw circle round flag carrier			-- 33
   308 				SetVisualGearValues(fCirc[i], fThiefX[i], fThiefY[i], 20, 200, 0, 0, 100, 50, 3, fCol[i])
   308 				SetVisualGearValues(fCirc[i], fThiefX[i], fThiefY[i], 20, 200, 0, 0, 100, 50, 3, fCol[i])
   309 				--AddCaption("circle marking carrier")
   309 				--AddCaption("circle marking carrier")
   310 			elseif fThief[i] == nil then -- draw cirle round dropped flag
   310 			elseif fThief[i] == nil then -- draw cirle round dropped flag
   311 				--g1X,g1Y,g4,g5,g6,g7,g8,g9,g10,g11 =  GetVisualGearValues(fGear[i])				
   311 				--g1X,g1Y,g4,g5,g6,g7,g8,g9,g10,g11 =  GetVisualGearValues(fGear[i])
   312 				--SetVisualGearValues(fCirc[i], g1X, g1Y, 20, 200, 0, 0, 100, 33, 2, fCol[i])
   312 				--SetVisualGearValues(fCirc[i], g1X, g1Y, 20, 200, 0, 0, 100, 33, 2, fCol[i])
   313 				SetVisualGearValues(fCirc[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, 33, 3, fCol[i])
   313 				SetVisualGearValues(fCirc[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, 33, 3, fCol[i])
   314 				--AddCaption('dropped circle marker')				
   314 				--AddCaption('dropped circle marker')
   315 				if fGear[i] ~= nil then -- flag gear itself
   315 				if fGear[i] ~= nil then -- flag gear itself
   316 					--SetVisualGearValues(fGear[i], g1X, g1Y, 20, 200, 0, 0, 100, 10, 4, fCol[i])					
   316 					--SetVisualGearValues(fGear[i], g1X, g1Y, 20, 200, 0, 0, 100, 10, 4, fCol[i])
   317 					SetVisualGearValues(fGear[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
   317 					SetVisualGearValues(fGear[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
   318 					--AddCaption('dropped flag itself')
   318 					--AddCaption('dropped flag itself')
   319 				end
   319 				end
   320 			end
   320 			end
   321 		end
   321 		end
   408 	gameStarted = true
   408 	gameStarted = true
   409 	AddCaption(loc("Game Started!"))
   409 	AddCaption(loc("Game Started!"))
   410 
   410 
   411 	for i = 0, 1 do
   411 	for i = 0, 1 do
   412 
   412 
   413 		-- if someone uses kamikaze downwards, this can happen as the hog won't respawn		
   413 		-- if someone uses kamikaze downwards, this can happen as the hog won't respawn
   414 		if (LAND_HEIGHT - fSpawnY[i]) < 0 then
   414 		if (LAND_HEIGHT - fSpawnY[i]) < 0 then
   415 			tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
   415 			tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
   416      			FindPlace(tempG, true, 0, LAND_WIDTH, true)			
   416      			FindPlace(tempG, true, 0, LAND_WIDTH, true)
   417 			fSpawnX[i], fSpawnY[i] = GetGearPosition(tempG)
   417 			fSpawnX[i], fSpawnY[i] = GetGearPosition(tempG)
   418 			DeleteGear(tempG)
   418 			DeleteGear(tempG)
   419 		end  		
   419 		end
   420 
   420 
   421 		fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   421 		fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   422 		fCirc[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   422 		fCirc[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   423 		fSpawnC[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   423 		fSpawnC[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   424 
   424 
   427 
   427 
   428 		fCol[i] = GetClanColor(i)
   428 		fCol[i] = GetClanColor(i)
   429 		fIsMissing[i] = false
   429 		fIsMissing[i] = false
   430 		fNeedsRespawn[i] = false
   430 		fNeedsRespawn[i] = false
   431 		fCaptures[i] = 0
   431 		fCaptures[i] = 0
   432 		
   432 
   433 		--SetVisualGearValues(zxc, 1000,1000, 20, 100, 0,    10,                     1,         100,        5,      GetClanColor(0))		
   433 		--SetVisualGearValues(zxc, 1000,1000, 20, 100, 0,    10,                     1,         100,        5,      GetClanColor(0))
   434 		
   434 
   435 		SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 100, 0, 10, 0, 75, 5, fCol[i])
   435 		SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 100, 0, 10, 0, 75, 5, fCol[i])
   436 				
   436 
   437 	end
   437 	end
   438 
   438 
   439 end
   439 end
   440 
   440 
   441 ------------------------
   441 ------------------------
   444 
   444 
   445 function onGameInit()
   445 function onGameInit()
   446 
   446 
   447 	GameFlags = band(bor(GameFlags, gfDivideTeams), bnot(gfKing + gfForts))
   447 	GameFlags = band(bor(GameFlags, gfDivideTeams), bnot(gfKing + gfForts))
   448 	--SuddenDeathTurns = 999 -- suddendeath is off, effectively
   448 	--SuddenDeathTurns = 999 -- suddendeath is off, effectively
   449 	WaterRise = 0	
   449 	WaterRise = 0
   450 	Delay = 10 
   450 	Delay = 10
   451 
   451 
   452 end
   452 end
   453 
   453 
   454 
   454 
   455 function onGameStart()
   455 function onGameStart()
   456 
   456 
   457 	--ShowMission(loc(caption), loc(subcaption), loc(goal), 0, 0)
   457 	--ShowMission(loc(caption), loc(subcaption), loc(goal), 0, 0)
   458 	ShowMission(loc("CAPTURE THE FLAG"), loc("Flags, and their home base will be placed where each team ends their first turn."), "", 0, 0)
   458 	ShowMission(loc("CAPTURE THE FLAG"), loc("Flags, and their home base will be placed where each team ends their first turn."), "", 0, 0)
   459 
   459 
   460 	RebuildTeamInfo()
   460 	RebuildTeamInfo()
   461 	
   461 
   462 	-- should gfDivideTeams do this automatically?	
   462 	-- should gfDivideTeams do this automatically?
   463 	--[[for i = 0, (TeamsCount-1) do
   463 	--[[for i = 0, (TeamsCount-1) do
   464 		for g = teamIndex[i], (teamIndex[i]+teamSize[i]-1) do
   464 		for g = teamIndex[i], (teamIndex[i]+teamSize[i]-1) do
   465 			if GetHogClan(hhs[g]) == 0 then
   465 			if GetHogClan(hhs[g]) == 0 then
   466 				FindPlace(hhs[g], false, 0, LAND_WIDTH/2)
   466 				FindPlace(hhs[g], false, 0, LAND_WIDTH/2)
   467 			elseif GetHogClan(hhs[g]) == 1 then
   467 			elseif GetHogClan(hhs[g]) == 1 then
   473 	fPlaced[0] = false
   473 	fPlaced[0] = false
   474 	fPlaced[1] = false
   474 	fPlaced[1] = false
   475 
   475 
   476 	--zxc = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   476 	--zxc = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   477 
   477 
   478 	
   478 
   479 	--SetVisualGearValues(zxc, 1000,1000, 20, 255, 1,    10,                     0,         200,        1,      GetClanColor(0))
   479 	--SetVisualGearValues(zxc, 1000,1000, 20, 255, 1,    10,                     0,         200,        1,      GetClanColor(0))
   480 					--minO,max0 -glowyornot	--pulsate timer	 -- fuckall      -- radius -- width  -- colour
   480 					--minO,max0 -glowyornot	--pulsate timer	 -- fuckall      -- radius -- width  -- colour
   481 end
   481 end
   482 
   482 
   483 
   483 
   484 function onNewTurn()
   484 function onNewTurn()
   485 
   485 
   486 	gameTurns = gameTurns + 1
   486 	gameTurns = gameTurns + 1
   487 	
   487 
   488 	if lastTeam ~= GetHogTeamName(CurrentHedgehog) then
   488 	if lastTeam ~= GetHogTeamName(CurrentHedgehog) then
   489 		lastTeam = GetHogTeamName(CurrentHedgehog)
   489 		lastTeam = GetHogTeamName(CurrentHedgehog)
   490 	end
   490 	end
   491 
   491 
   492 	--AddCaption("Handling respawns")
   492 	--AddCaption("Handling respawns")
   493 	if gameStarted == true then
   493 	if gameStarted == true then
   494 		HandleRespawns()
   494 		HandleRespawns()
   495 	--new method of placing starting flags	
   495 	--new method of placing starting flags
   496 	elseif gameTurns == 1 then
   496 	elseif gameTurns == 1 then
   497 		ShowMission(loc("CAPTURE THE FLAG"), loc("Flags, and their home base will be placed where each team ends their first turn."), "", 0, 0)
   497 		ShowMission(loc("CAPTURE THE FLAG"), loc("Flags, and their home base will be placed where each team ends their first turn."), "", 0, 0)
   498 	elseif gameTurns == 2 then
   498 	elseif gameTurns == 2 then
   499 		fPlaced[0] = true
   499 		fPlaced[0] = true
   500 		ShowMission(loc("CAPTURE THE FLAG"), loc("RULES OF THE GAME [Press ESC to view]"), loc(" - Return the enemy flag to your base to score | - First team to 3 captures wins | - You may only score when your flag is in your base | - Hogs will drop the flag if killed, or drowned | - Dropped flags may be returned or recaptured | - Hogs respawn when killed"), 0, 0)
   500 		ShowMission(loc("CAPTURE THE FLAG"), loc("RULES OF THE GAME [Press ESC to view]"), loc(" - Return the enemy flag to your base to score | - First team to 3 captures wins | - You may only score when your flag is in your base | - Hogs will drop the flag if killed, or drowned | - Dropped flags may be returned or recaptured | - Hogs respawn when killed"), 0, 0)
   501 	elseif gameTurns == 3 then
   501 	elseif gameTurns == 3 then
   502 		fPlaced[1] = true	
   502 		fPlaced[1] = true
   503 		StartTheGame()
   503 		StartTheGame()
   504 	end
   504 	end
   505 
   505 
   506 end
   506 end
   507 
   507 
   533 		HandleCircles()
   533 		HandleCircles()
   534 		if CurrentHedgehog ~= nil then
   534 		if CurrentHedgehog ~= nil then
   535 			CheckFlagProximity()
   535 			CheckFlagProximity()
   536 		end
   536 		end
   537 	elseif CurrentHedgehog ~= nil then -- if the game hasn't started yet, keep track of where we are gonna put the flags on turn end
   537 	elseif CurrentHedgehog ~= nil then -- if the game hasn't started yet, keep track of where we are gonna put the flags on turn end
   538 				
   538 
   539 		if GetHogClan(CurrentHedgehog) == 0 then
   539 		if GetHogClan(CurrentHedgehog) == 0 then
   540 			i = 0			
   540 			i = 0
   541 		elseif GetHogClan(CurrentHedgehog) == 1 then
   541 		elseif GetHogClan(CurrentHedgehog) == 1 then
   542 			i = 1			
   542 			i = 1
   543 		end			
   543 		end
   544 		
   544 
   545 		fSpawnX[i] = GetX(CurrentHedgehog)
   545 		fSpawnX[i] = GetX(CurrentHedgehog)
   546 		fSpawnY[i] = GetY(CurrentHedgehog)
   546 		fSpawnY[i] = GetY(CurrentHedgehog)
   547 			
   547 
   548 	end
   548 	end
   549 
   549 
   550 end
   550 end
   551 
   551 
   552 function onGearResurrect(gear)
   552 function onGearResurrect(gear)
   573 end
   573 end
   574 
   574 
   575 function InABetterPlaceNow(gear)
   575 function InABetterPlaceNow(gear)
   576 	for i = 0, (numhhs-1) do
   576 	for i = 0, (numhhs-1) do
   577 		if gear == hhs[i] then
   577 		if gear == hhs[i] then
   578 				
   578 
   579 			for i = 0,1 do
   579 			for i = 0,1 do
   580 				if gear == fThief[i] then
   580 				if gear == fThief[i] then
   581 					FlagThiefDead(gear)
   581 					FlagThiefDead(gear)
   582 				end
   582 				end
   583 			end				
   583 			end
   584 			hhs[i] = nil	
   584 			hhs[i] = nil
   585 		end		
   585 		end
   586 	end
   586 	end
   587 end
   587 end
   588 
   588 
   589 function onHogHide(gear)
   589 function onHogHide(gear)
   590 	 InABetterPlaceNow(gear)
   590 	 InABetterPlaceNow(gear)
   591 end
   591 end
   592 
   592 
   593 function onHogRestore(gear)
   593 function onHogRestore(gear)
   594 	match = false	
   594 	match = false
   595 	for i = 0, (numhhs-1) do
   595 	for i = 0, (numhhs-1) do
   596 		if (hhs[i] == nil) and (match == false) then
   596 		if (hhs[i] == nil) and (match == false) then
   597 			hhs[i] = gear
   597 			hhs[i] = gear
   598 			--AddCaption(GetHogName(gear) .. " has reappeared it seems!")	
   598 			--AddCaption(GetHogName(gear) .. " has reappeared it seems!")
   599 			match = true
   599 			match = true
   600 		end
   600 		end
   601 	end
   601 	end
   602 end
   602 end
   603 
   603 
   606 
   606 
   607 	if GetGearType(gear) == gtHedgehog then
   607 	if GetGearType(gear) == gtHedgehog then
   608 		hhs[numhhs] = gear
   608 		hhs[numhhs] = gear
   609 		numhhs = numhhs + 1
   609 		numhhs = numhhs + 1
   610 		SetEffect(gear, heResurrectable, true)
   610 		SetEffect(gear, heResurrectable, true)
   611 	
   611 
   612 	elseif GetGearType(gear) == gtPiano then
   612 	elseif GetGearType(gear) == gtPiano then
   613 
   613 
   614 		for i = 0, 1 do
   614 		for i = 0, 1 do
   615 			if CurrentHedgehog == fThief[i] then
   615 			if CurrentHedgehog == fThief[i] then
   616 				FlagThiefDead(gear)			
   616 				FlagThiefDead(gear)
   617 			end
   617 			end
   618 		end
   618 		end
   619 
   619 
   620 	end
   620 	end
   621 
   621 
   622 end
   622 end
   623 
   623 
   624 function onGearDelete(gear)
   624 function onGearDelete(gear)
   625 
   625 
   626 	if GetGearType(gear) == gtHedgehog then
   626 	if GetGearType(gear) == gtHedgehog then
   627 		InABetterPlaceNow(gear)		
   627 		InABetterPlaceNow(gear)
   628 	end
   628 	end
   629 
   629 
   630 end
   630 end