share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua
changeset 4662 63aafc9c2a81
child 5277 09beef0752ab
equal deleted inserted replaced
4661:f5d858e4b634 4662:63aafc9c2a81
       
     1 --------------------------------
       
     2 -- CAPTURE_THE_FLAG_CUSTOM 0.3
       
     3 -- by mikade
       
     4 --------------------------------
       
     5 
       
     6 -- Version History
       
     7 ---------
       
     8 -- 0.1
       
     9 ---------
       
    10 
       
    11 -- [conversion from map-dependant CTF_Blizzard to map independant Capture the Flag]
       
    12 -- added an intial starting stage where flagspawn is decided by the players (weapon set will require a jetpack unless I set)
       
    13 -- changed the flag from a crate to a visual gear, and all associated methods and checks relating to flags (five hours later, lol)
       
    14 -- changed starting/respawning positioning to accommodate different map sizes
       
    15 -- added another circle to mark flag spawn
       
    16 -- added gameFlag filter
       
    17 -- changed scoring feedback
       
    18 -- cleaned up some code
       
    19 
       
    20 -- removing own flag from spawning point no longer possible
       
    21 -- destroying flags no longer possible.
       
    22 -- added basic glowing circle effect to spawn area
       
    23 -- added expanding circle to fgear itself
       
    24 
       
    25 -- removed teleporters
       
    26 -- removed random crate drops (this should be decided by scheme)
       
    27 -- removed set map criteria like minesNum, turnTime, explosives etc. except for sudden death
       
    28 -- removed weapon defintions
       
    29 -- removed placement and respawning methods, hopefully divideTeams will have this covered
       
    30 
       
    31 ---------
       
    32 -- 0.2
       
    33 ---------
       
    34 
       
    35 -- [now with user friendliness]
       
    36 -- flag is now placed wherever you end up at the end of your first turn, this ensures that it is always placed by turn 3
       
    37 -- removed a bunch of backup code and no-longer needed variables / methods from CTF_Blizzard days
       
    38 -- removed an aura that was still mistakenly hanging about
       
    39 -- added an in-game note about placements
       
    40 -- added an in-game note about the rules of the game
       
    41 -- added translation support and loc()'ed everything
       
    42 -- changed things so the seed is no longer always the same...
       
    43 
       
    44 -- In this version:
       
    45 ---------
       
    46 -- 0.3
       
    47 ---------
       
    48 -- [fufufufu kamikaze fix]
       
    49 -- added nill checks to make sure the player doesn't generate errors by producing a nil value in hhs[] when he uses kamikaze
       
    50 -- added a check to make sure the player doesn't kamikaze straight down and make the flag's starting point underwater
       
    51 -- added a check to make sure the player drops the flag if he has it and he uses kamikaze
       
    52 
       
    53 -----------------
       
    54 --SCRIPT BEGINS
       
    55 -----------------
       
    56 
       
    57 -- enable awesome translaction support so we can use loc() wherever we want
       
    58 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
       
    59 
       
    60 ---------------------------------------------------------------
       
    61 ----------lots of bad variables and things
       
    62 ----------because someone is too lazy
       
    63 ----------to read about tables properly
       
    64 ------------------ "Oh well, they probably have the memory"
       
    65 
       
    66 local gameStarted = false
       
    67 local gameTurns = 0	
       
    68 
       
    69 --------------------------
       
    70 -- hog and team tracking variales
       
    71 --------------------------
       
    72 
       
    73 local numhhs = 0 -- store number of hedgehogs
       
    74 local hhs = {} -- store hedgehog gears
       
    75 
       
    76 local numTeams --  store the number of teams in the game
       
    77 local teamNameArr = {}	-- store the list of teams
       
    78 local teamSize = {}	-- store how many hogs per team
       
    79 local teamIndex = {} -- at what point in the hhs{} does each team begin
       
    80 
       
    81 -------------------
       
    82 -- flag variables
       
    83 -------------------
       
    84 
       
    85 local fPlaced = {} -- has the flag been placed TRUE/FALSE
       
    86 
       
    87 local fGear = {}	-- pointer to the visual gears that represent the flag
       
    88 local fGearX = {}
       
    89 local fGearY = {}
       
    90 
       
    91 local fThief = {}	-- pointer to the hogs who stole the flags
       
    92 local fIsMissing = {}	-- have the flags been destroyed or captured
       
    93 local fNeedsRespawn = {}	-- do the flags need to be respawned
       
    94 local fCaptures = {}	-- the team "scores" how many captures
       
    95 local fSpawnX = {}		-- spawn X for flags
       
    96 local fSpawnY = {}		-- spawn Y for flags
       
    97 
       
    98 local fThiefX = {}
       
    99 local fThiefY = {}
       
   100 local FTTC = 0 -- flag thief tracker counter
       
   101 
       
   102 local fSpawnC = {} -- spawn circle marker
       
   103 local fCirc = {} -- flag/carrier marker circles
       
   104 local fCol = {} -- colour of the clans
       
   105 
       
   106 local fGearRad = 0
       
   107 local fGearRadMin = 5
       
   108 local fGearRadMax = 33
       
   109 local fGearTimer = 0
       
   110 
       
   111 ------------------------
       
   112 --flag methods
       
   113 ------------------------
       
   114 
       
   115 function CheckScore(teamID)
       
   116 
       
   117 	if teamID == 0 then
       
   118 		alt = 1
       
   119 	elseif teamID == 1 then
       
   120 		alt = 0
       
   121 	end
       
   122 
       
   123 	if fCaptures[teamID] == 3 then
       
   124 		for i = 0, (numhhs-1) do
       
   125 			if hhs[i] ~= nil then			
       
   126 				if GetHogClan(hhs[i]) == alt then
       
   127 					SetEffect(hhs[i], heResurrectable, false)
       
   128 					SetHealth(hhs[i],0)
       
   129 				end
       
   130 			end
       
   131 		end
       
   132 		if CurrentHedgehog ~= nil then		
       
   133 			ShowMission(loc("GAME OVER!"), loc("Victory for the ") .. GetHogTeamName(CurrentHedgehog), loc("Hooray!"), 0, 0)
       
   134 		end
       
   135 	end
       
   136 
       
   137 end
       
   138 
       
   139 function DoFlagStuff(gear)
       
   140 
       
   141 	if (gear == fGear[0]) then
       
   142 		wtf = 0
       
   143 		bbq = 1
       
   144 	elseif (gear == fGear[1]) then
       
   145 		wtf = 1
       
   146 		bbq = 0
       
   147 	end
       
   148 	
       
   149 	-- player has successfully captured the enemy flag
       
   150 	if (GetHogClan(CurrentHedgehog) == wtf) and (CurrentHedgehog == fThief[bbq]) and (fIsMissing[wtf] == false) then
       
   151 		
       
   152 		DeleteVisualGear(fGear[wtf])
       
   153 		fGear[wtf] = nil -- the flag has now disappeared				
       
   154 				
       
   155 		fIsMissing[wtf] = false
       
   156 		fNeedsRespawn[wtf] = true
       
   157 		fIsMissing[bbq] = false
       
   158 		fNeedsRespawn[bbq] = true
       
   159 		fCaptures[wtf] = fCaptures[wtf] +1				
       
   160 		ShowMission(loc("You have SCORED!!"), GetHogTeamName(CurrentHedgehog) .. ": " .. fCaptures[wtf], loc("Opposing Team: ") .. fCaptures[bbq], 0, 0)
       
   161 		PlaySound(sndVictory)
       
   162 		fThief[bbq] = nil -- player no longer has the enemy flag
       
   163 		CheckScore(wtf)
       
   164 
       
   165 	--if the player is returning the flag
       
   166 	elseif (GetHogClan(CurrentHedgehog) == wtf) and (fIsMissing[wtf] == true) then
       
   167 			
       
   168 		DeleteVisualGear(fGear[wtf])
       
   169 		fGear[wtf] = nil -- the flag has now disappeared
       
   170 					
       
   171 		fNeedsRespawn[wtf] = true					
       
   172 		HandleRespawns() -- this will set fIsMissing[wtf] to false :)
       
   173 		AddCaption(loc("Flag returned!"))
       
   174 	
       
   175 	--if the player is taking the enemy flag
       
   176 	elseif GetHogClan(CurrentHedgehog) == bbq then
       
   177 				
       
   178 		DeleteVisualGear(fGear[wtf])
       
   179 		fGear[wtf] = nil -- the flag has now disappeared				
       
   180 				
       
   181 		fIsMissing[wtf] = true
       
   182 		for i = 0,numhhs-1 do
       
   183 			if CurrentHedgehog ~= nil then			
       
   184 				if CurrentHedgehog == hhs[i] then
       
   185 					fThief[wtf] = hhs[i]
       
   186 				end
       
   187 			end
       
   188 		end
       
   189 		AddCaption(loc("Flag captured!"))
       
   190 
       
   191 	--below line doesnt usually get called
       
   192 	--else 
       
   193 		-- now gets called if you go over your own flag, presumably		
       
   194 		--AddCaption("Hmm... that wasn't supposed to happen...")
       
   195 	end
       
   196 	
       
   197 end
       
   198 
       
   199 function CheckFlagProximity() 
       
   200 
       
   201 	for i = 0, 1 do
       
   202 		if fGear[i] ~= nil then
       
   203 			
       
   204 			g1X = fGearX[i]
       
   205 			g1Y = fGearY[i]			
       
   206 	
       
   207 			g2X, g2Y = GetGearPosition(CurrentHedgehog)
       
   208 
       
   209 			q = g1X - g2X
       
   210 			w = g1Y - g2Y
       
   211 			dist = (q*q) + (w*w)
       
   212 			
       
   213 			if dist < 500 then --1600
       
   214 				DoFlagStuff(fGear[i])
       
   215 			end
       
   216 		end
       
   217 	end
       
   218 
       
   219 end
       
   220 
       
   221 
       
   222 function HandleRespawns()
       
   223 
       
   224 	for i = 0, 1 do
       
   225 
       
   226 		if fNeedsRespawn[i] == true then
       
   227 			fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
       
   228 			fGearX[i] = fSpawnX[i]
       
   229 			fGearY[i] = fSpawnY[i]			
       
   230 			--fGear[i] = SpawnAmmoCrate(fSpawnX[i],fSpawnY[i],amSkip)
       
   231 			fNeedsRespawn[i] = false
       
   232 			fIsMissing[i] = false -- new, this should solve problems of a respawned flag being "returned" when a player tries to score
       
   233 			AddCaption(loc("Flag respawned!"))
       
   234 		end
       
   235 
       
   236 	end
       
   237 
       
   238 end
       
   239 
       
   240 
       
   241 function FlagThiefDead(gear)
       
   242 
       
   243 	if (gear == fThief[0]) then
       
   244 		wtf = 0
       
   245 		bbq = 1
       
   246 	elseif (gear == fThief[1]) then
       
   247 		wtf = 1
       
   248 		bbq = 0
       
   249 	end
       
   250 
       
   251 	if fThief[wtf] ~= nil then
       
   252 		-- falls into water		
       
   253 		--ShowMission(LAND_HEIGHT,  fThiefY[wtf], (LAND_HEIGHT - fThiefY[wtf]), 0, 0)	
       
   254 		if (LAND_HEIGHT - fThiefY[wtf]) < 15 then
       
   255 			fIsMissing[wtf] = true
       
   256 			fNeedsRespawn[wtf] = true
       
   257 			HandleRespawns()
       
   258 			--AddCaption("hah??")
       
   259 		else	--normally	
       
   260 			fGearX[wtf]  =  fThiefX[wtf]
       
   261 			fGearY[wtf]  =  fThiefY[wtf]	
       
   262 			fGear[wtf] = AddVisualGear(fGearX[wtf],fGearY[wtf],vgtCircle,0,true)		
       
   263 			--fGear[wtf] = AddVisualGear(fThiefX[wtf],fThiefY[wtf],vgtCircle,0,true)
       
   264 		end
       
   265 
       
   266 		AddVisualGear(fThiefX[wtf], fThiefY[wtf], vgtBigExplosion, 0, false)
       
   267 		fThief[wtf] = nil
       
   268 	end
       
   269 
       
   270 end
       
   271 
       
   272 function HandleCircles()
       
   273 
       
   274 	fGearTimer = fGearTimer + 1
       
   275 	if fGearTimer == 50 then
       
   276 		fGearTimer = 0
       
   277 		fGearRad = fGearRad + 1
       
   278 		if fGearRad > fGearRadMax then
       
   279 			fGearRad = fGearRadMin	
       
   280 		end
       
   281 	end
       
   282 
       
   283 	for i = 0, 1 do
       
   284 		
       
   285 		--SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, 50, 3, fCol[i]) -- draw a circ for spawning area
       
   286 		
       
   287 		if fIsMissing[i] == false then -- draw a flag marker at the flag's spawning place
       
   288 			SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 20, 0, 10, 0, 33, 3, fCol[i])
       
   289 			if fGear[i] ~= nil then -- draw the flag gear itself
       
   290 				SetVisualGearValues(fGear[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
       
   291 			end
       
   292 		elseif (fIsMissing[i] == true) and (fNeedsRespawn[i] == false) then
       
   293 			if fThief[i] ~= nil then -- draw circle round flag carrier
       
   294 				SetVisualGearValues(fCirc[i], fThiefX[i], fThiefY[i], 20, 200, 0, 0, 100, 33, 3, fCol[i])
       
   295 				--AddCaption("circle marking carrier")
       
   296 			elseif fThief[i] == nil then -- draw cirle round dropped flag
       
   297 				--g1X,g1Y,g4,g5,g6,g7,g8,g9,g10,g11 =  GetVisualGearValues(fGear[i])				
       
   298 				--SetVisualGearValues(fCirc[i], g1X, g1Y, 20, 200, 0, 0, 100, 33, 2, fCol[i])
       
   299 				SetVisualGearValues(fCirc[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, 33, 3, fCol[i])
       
   300 				--AddCaption('dropped circle marker')				
       
   301 				if fGear[i] ~= nil then -- flag gear itself
       
   302 					--SetVisualGearValues(fGear[i], g1X, g1Y, 20, 200, 0, 0, 100, 10, 4, fCol[i])					
       
   303 					SetVisualGearValues(fGear[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
       
   304 					--AddCaption('dropped flag itself')
       
   305 				end
       
   306 			end
       
   307 		end
       
   308 
       
   309 		if fNeedsRespawn[i] == true then -- if the flag has been destroyed, no need for a circle
       
   310 			SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, 0, 0, fCol[i])
       
   311 			--AddCaption("needs respawn = true. flag 'destroyed'?")
       
   312 		end
       
   313 	end
       
   314 
       
   315 end
       
   316 
       
   317 ------------------------
       
   318 -- general methods
       
   319 ------------------------
       
   320 
       
   321 function CheckDistance(gear1, gear2)
       
   322 
       
   323 	g1X, g1Y = GetGearPosition(gear1)
       
   324 	g2X, g2Y = GetGearPosition(gear2)
       
   325 
       
   326 	g1X = g1X - g2X
       
   327 	g1Y = g1Y - g2Y
       
   328 	z = (g1X*g1X) + (g1Y*g1Y)
       
   329 
       
   330 	dist = z
       
   331 
       
   332 	return dist
       
   333 
       
   334 end
       
   335 
       
   336 function RebuildTeamInfo()
       
   337 
       
   338 
       
   339 	-- make a list of individual team names
       
   340 	for i = 0, 5 do
       
   341 		teamNameArr[i] = i
       
   342 		teamSize[i] = 0
       
   343 		teamIndex[i] = 0
       
   344 	end
       
   345 	numTeams = 0
       
   346 
       
   347 	for i = 0, (numhhs-1) do
       
   348 
       
   349 		z = 0
       
   350 		unfinished = true
       
   351 		while(unfinished == true) do
       
   352 
       
   353 			newTeam = true
       
   354 			tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name
       
   355 
       
   356 			if tempHogTeamName == teamNameArr[z] then
       
   357 				newTeam = false
       
   358 				unfinished = false
       
   359 			end
       
   360 
       
   361 			z = z + 1
       
   362 
       
   363 			if z == TeamsCount then
       
   364 				unfinished = false
       
   365 				if newTeam == true then
       
   366 					teamNameArr[numTeams] = tempHogTeamName
       
   367 					numTeams = numTeams + 1
       
   368 				end
       
   369 			end
       
   370 
       
   371 		end
       
   372 
       
   373 	end
       
   374 
       
   375 	-- find out how many hogs per team, and the index of the first hog in hhs
       
   376 	for i = 0, numTeams-1 do
       
   377 
       
   378 		for z = 0, numhhs-1 do
       
   379 			if GetHogTeamName(hhs[z]) == teamNameArr[i] then
       
   380 				if teamSize[i] == 0 then
       
   381 					teamIndex[i] = z -- should give starting index
       
   382 				end
       
   383 				teamSize[i] = teamSize[i] + 1
       
   384 				--add a pointer so this hog appears at i in hhs
       
   385 			end
       
   386 		end
       
   387 
       
   388 	end
       
   389 
       
   390 end
       
   391 
       
   392 function StartTheGame()
       
   393 
       
   394 	gameStarted = true
       
   395 	AddCaption(loc("Game Started!"))
       
   396 
       
   397 	for i = 0, 1 do
       
   398 
       
   399 		-- if someone uses kamikaze downwards, this can happen as the hog won't respawn		
       
   400 		if (LAND_HEIGHT - fSpawnY[i]) < 0 then
       
   401 			tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
       
   402      			FindPlace(tempG, true, 0, LAND_WIDTH, true)			
       
   403 			fSpawnX[i], fSpawnY[i] = GetGearPosition(tempG)
       
   404 			DeleteGear(tempG)
       
   405 		end  		
       
   406 
       
   407 		fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
       
   408 		fCirc[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
       
   409 		fSpawnC[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
       
   410 
       
   411 		fGearX[i] = fSpawnX[i]
       
   412 		fGearY[i] = fSpawnY[i]
       
   413 
       
   414 		fCol[i] = GetClanColor(i)
       
   415 		fIsMissing[i] = false
       
   416 		fNeedsRespawn[i] = false
       
   417 		fCaptures[i] = 0
       
   418 		
       
   419 		--SetVisualGearValues(zxc, 1000,1000, 20, 100, 0,    10,                     1,         100,        5,      GetClanColor(0))		
       
   420 		
       
   421 		SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 100, 0, 10, 0, 75, 5, fCol[i])
       
   422 		--SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 20, 0, 10, 0, 33, 3, fCol[i])
       
   423 
       
   424 				
       
   425 	end
       
   426 
       
   427 end
       
   428 
       
   429 ------------------------
       
   430 -- game methods
       
   431 ------------------------
       
   432 
       
   433 function onGameInit()
       
   434 
       
   435 	-- Things we don't modify here will use their default values.
       
   436 	
       
   437 	GameFlags = band(bor(GameFlags, gfDivideTeams), bnot(gfKing + gfForts))
       
   438 	SuddenDeathTurns = 99 -- suddendeath is off, effectively
       
   439 	--TurnTime = 30000 -- (was 30) The time the player has to move each round (in ms)
       
   440 	--Delay = 10 -- The delay between each round
       
   441 
       
   442 end
       
   443 
       
   444 
       
   445 function onGameStart()
       
   446 
       
   447 	--ShowMission(loc(caption), loc(subcaption), loc(goal), 0, 0)
       
   448 	ShowMission(loc("CAPTURE THE FLAG"), loc("by mikade"), loc("CUSTOM BUILD 0.2"), 0, 0)
       
   449 
       
   450 	RebuildTeamInfo()
       
   451 	
       
   452 	-- should gfDivideTeams do this automatically?	
       
   453 	--[[for i = 0, (TeamsCount-1) do
       
   454 		for g = teamIndex[i], (teamIndex[i]+teamSize[i]-1) do
       
   455 			if GetHogClan(hhs[g]) == 0 then
       
   456 				FindPlace(hhs[g], false, 0, LAND_WIDTH/2)
       
   457 			elseif GetHogClan(hhs[g]) == 1 then
       
   458 				FindPlace(hhs[g], false, LAND_WIDTH/2, LAND_WIDTH)
       
   459 			end
       
   460 		end
       
   461 	end]]
       
   462 
       
   463 	fPlaced[0] = false
       
   464 	fPlaced[1] = false
       
   465 
       
   466 	--zxc = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
       
   467 
       
   468 	
       
   469 	--SetVisualGearValues(zxc, 1000,1000, 20, 255, 1,    10,                     0,         200,        1,      GetClanColor(0))
       
   470 					--minO,max0 -glowyornot	--pulsate timer	 -- fuckall      -- radius -- width  -- colour
       
   471 end
       
   472 
       
   473 
       
   474 function onNewTurn()
       
   475 
       
   476 	gameTurns = gameTurns + 1
       
   477 	
       
   478 	if lastTeam ~= GetHogTeamName(CurrentHedgehog) then
       
   479 		lastTeam = GetHogTeamName(CurrentHedgehog)
       
   480 	end
       
   481 
       
   482 	--AddCaption("Handling respawns")
       
   483 	if gameStarted == true then
       
   484 		HandleRespawns()
       
   485 	--new method of placing starting flags	
       
   486 	elseif gameTurns == 1 then
       
   487 		ShowMission(loc("CAPTURE THE FLAG"), loc("Flags will be placed where each team ends their turn."), "", 0, 0)
       
   488 	elseif gameTurns == 2 then
       
   489 		fPlaced[0] = true
       
   490 		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)
       
   491 	elseif gameTurns == 3 then
       
   492 		fPlaced[1] = true	
       
   493 		StartTheGame()
       
   494 	end
       
   495 
       
   496 end
       
   497 
       
   498 function onGameTick()
       
   499 
       
   500 	-- onRessurect calls AFTER you have resurrected,
       
   501 	-- so keeping track of x,y a few milliseconds before
       
   502 	-- is useful
       
   503 	--FTTC = FTTC + 1
       
   504 	--if FTTC == 100 then
       
   505 	--	FTTC = 0
       
   506 		for i = 0,1 do
       
   507 			if fThief[i] ~= nil then
       
   508 				fThiefX[i] = GetX(fThief[i])
       
   509 				fThiefY[i] = GetY(fThief[i])
       
   510 			end
       
   511 		end
       
   512 	--end
       
   513 
       
   514 	-- things we wanna check often
       
   515 	if (CurrentHedgehog ~= nil) then
       
   516 		--AddCaption(LAND_HEIGHT - GetY(CurrentHedgehog))
       
   517 		--AddCaption(GetX(CurrentHedgehog) .. "; " .. GetY(CurrentHedgehog))
       
   518 		--CheckTeleporters()
       
   519 
       
   520 	end
       
   521 
       
   522 	if gameStarted == true then
       
   523 		HandleCircles()
       
   524 		if CurrentHedgehog ~= nil then
       
   525 			CheckFlagProximity()
       
   526 		end
       
   527 	elseif CurrentHedgehog ~= nil then -- if the game hasn't started yet, keep track of where we are gonna put the flags on turn end
       
   528 				
       
   529 		if GetHogClan(CurrentHedgehog) == 0 then
       
   530 			i = 0			
       
   531 		elseif GetHogClan(CurrentHedgehog) == 1 then
       
   532 			i = 1			
       
   533 		end			
       
   534 		
       
   535 		fSpawnX[i] = GetX(CurrentHedgehog)
       
   536 		fSpawnY[i] = GetY(CurrentHedgehog)
       
   537 			
       
   538 	end
       
   539 
       
   540 end
       
   541 
       
   542 function onGearResurrect(gear)
       
   543 
       
   544 	--AddCaption("A gear has been resurrected!")
       
   545 
       
   546 	-- mark the flag thief as dead if he needed a respawn
       
   547 	for i = 0,1 do
       
   548 		if gear == fThief[i] then
       
   549 			FlagThiefDead(gear)
       
   550 		end
       
   551 	end
       
   552 
       
   553 	-- should be covered by gfDivideTeams, actually
       
   554 	-- place hogs belonging to each clan either left or right side of map
       
   555 	--if GetHogClan(gear) == 0 then
       
   556 	--	FindPlace(gear, false, 0, LAND_WIDTH/2)
       
   557 	--elseif GetHogClan(gear) == 1 then
       
   558 	--	FindPlace(gear, false, LAND_WIDTH/2, LAND_WIDTH)
       
   559 	--end
       
   560 
       
   561 	AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
       
   562 
       
   563 end
       
   564 
       
   565 function onGearDamage(gear, damage)
       
   566 --
       
   567 end
       
   568 
       
   569 function onGearAdd(gear)
       
   570 
       
   571 	if GetGearType(gear) == gtHedgehog then
       
   572 		hhs[numhhs] = gear
       
   573 		numhhs = numhhs + 1
       
   574 		SetEffect(gear, heResurrectable, true)
       
   575 	end
       
   576 
       
   577 end
       
   578 
       
   579 function onGearDelete(gear)
       
   580 
       
   581 	if GetGearType(gear) == gtHedgehog then
       
   582 	--AddCaption("gear deleted!")
       
   583 		for i = 0, (numhhs-1) do
       
   584 			if gear == hhs[i] then
       
   585 				
       
   586 				for i = 0,1 do
       
   587 					if gear == fThief[i] then
       
   588 						FlagThiefDead(gear)
       
   589 					end
       
   590 				end				
       
   591 				hhs[i] = nil
       
   592 				--AddCaption("for real")	
       
   593 			end		
       
   594 		end
       
   595 	end
       
   596 
       
   597 end