share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua
changeset 13106 115d7438aa3d
parent 13104 e0ec37c8104d
child 13109 59ebdb80d693
equal deleted inserted replaced
13105:b14cac8ac56c 13106:115d7438aa3d
   271 		bbq = 0
   271 		bbq = 0
   272 	end
   272 	end
   273 
   273 
   274 	if fThief[wtf] ~= nil then
   274 	if fThief[wtf] ~= nil then
   275 		-- falls into water
   275 		-- falls into water
   276 		--ShowMission(LAND_HEIGHT,  fThiefY[wtf], (LAND_HEIGHT - fThiefY[wtf]), 0, 0)
       
   277 		if (LAND_HEIGHT - fThiefY[wtf]) < 15 then
   276 		if (LAND_HEIGHT - fThiefY[wtf]) < 15 then
   278 			fIsMissing[wtf] = true
   277 			fIsMissing[wtf] = true
   279 			fNeedsRespawn[wtf] = true
   278 			fNeedsRespawn[wtf] = true
   280 			HandleRespawns()
   279 			HandleRespawns()
   281 		else	--normally
   280 		else	--normally
   301 		end
   300 		end
   302 	end
   301 	end
   303 
   302 
   304 	for i = 0, 1 do
   303 	for i = 0, 1 do
   305 
   304 
   306 		--SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, 50, 3, fCol[i]) -- draw a circ for spawning area
       
   307 
       
   308 		if fIsMissing[i] == false then -- draw a flag marker at the flag's spawning place
   305 		if fIsMissing[i] == false then -- draw a flag marker at the flag's spawning place
   309 			SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 20, 0, 10, 0, 33, 3, fCol[i])
   306 			SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 20, 0, 10, 0, 33, 3, fCol[i])
   310 			if fGear[i] ~= nil then -- draw the flag gear itself
   307 			if fGear[i] ~= nil then -- draw the flag gear itself
   311 				SetVisualGearValues(fGear[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
   308 				SetVisualGearValues(fGear[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
   312 			end
   309 			end
   313 		elseif (fIsMissing[i] == true) and (fNeedsRespawn[i] == false) then
   310 		elseif (fIsMissing[i] == true) and (fNeedsRespawn[i] == false) then
   314 			if fThief[i] ~= nil then -- draw circle round flag carrier			-- 33
   311 			if fThief[i] ~= nil then -- draw circle round flag carrier			-- 33
   315 				SetVisualGearValues(fCirc[i], fThiefX[i], fThiefY[i], 20, 200, 0, 0, 100, 50, 3, fCol[i])
   312 				SetVisualGearValues(fCirc[i], fThiefX[i], fThiefY[i], 20, 200, 0, 0, 100, 50, 3, fCol[i])
   316 				--AddCaption("circle marking carrier")
       
   317 			elseif fThief[i] == nil then -- draw cirle round dropped flag
   313 			elseif fThief[i] == nil then -- draw cirle round dropped flag
   318 				--g1X,g1Y,g4,g5,g6,g7,g8,g9,g10,g11 =  GetVisualGearValues(fGear[i])
       
   319 				--SetVisualGearValues(fCirc[i], g1X, g1Y, 20, 200, 0, 0, 100, 33, 2, fCol[i])
       
   320 				SetVisualGearValues(fCirc[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, 33, 3, fCol[i])
   314 				SetVisualGearValues(fCirc[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, 33, 3, fCol[i])
   321 				--AddCaption('dropped circle marker')
       
   322 				if fGear[i] ~= nil then -- flag gear itself
   315 				if fGear[i] ~= nil then -- flag gear itself
   323 					--SetVisualGearValues(fGear[i], g1X, g1Y, 20, 200, 0, 0, 100, 10, 4, fCol[i])
       
   324 					SetVisualGearValues(fGear[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
   316 					SetVisualGearValues(fGear[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
   325 					--AddCaption('dropped flag itself')
       
   326 				end
   317 				end
   327 			end
   318 			end
   328 		end
   319 		end
   329 
   320 
   330 		if fNeedsRespawn[i] == true then -- if the flag has been destroyed, no need for a circle
   321 		if fNeedsRespawn[i] == true then -- if the flag has been destroyed, no need for a circle
   331 			SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, 0, 0, fCol[i])
   322 			SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, 0, 0, fCol[i])
   332 			--AddCaption("needs respawn = true. flag 'destroyed'?")
       
   333 		end
   323 		end
   334 	end
   324 	end
   335 
   325 
   336 end
   326 end
   337 
   327 
   426 
   416 
   427 		fCol[i] = GetClanColor(i)
   417 		fCol[i] = GetClanColor(i)
   428 		fIsMissing[i] = false
   418 		fIsMissing[i] = false
   429 		fNeedsRespawn[i] = false
   419 		fNeedsRespawn[i] = false
   430 		fCaptures[i] = 0
   420 		fCaptures[i] = 0
   431 
       
   432 		--SetVisualGearValues(zxc, 1000,1000, 20, 100, 0,    10,                     1,         100,        5,      GetClanColor(0))
       
   433 
   421 
   434 		SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 100, 0, 10, 0, 75, 5, fCol[i])
   422 		SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 100, 0, 10, 0, 75, 5, fCol[i])
   435 
   423 
   436 	end
   424 	end
   437 
   425 
   494 
   482 
   495 	showCTFMission()
   483 	showCTFMission()
   496 
   484 
   497 	RebuildTeamInfo()
   485 	RebuildTeamInfo()
   498 
   486 
   499 	-- should gfDivideTeams do this automatically?
       
   500 	--[[for i = 0, (TeamsCount-1) do
       
   501 		for g = teamIndex[i], (teamIndex[i]+teamSize[i]-1) do
       
   502 			if GetHogClan(hhs[g]) == 0 then
       
   503 				FindPlace(hhs[g], false, 0, LAND_WIDTH/2)
       
   504 			elseif GetHogClan(hhs[g]) == 1 then
       
   505 				FindPlace(hhs[g], false, LAND_WIDTH/2, LAND_WIDTH)
       
   506 			end
       
   507 		end
       
   508 	end]]
       
   509 
       
   510 	for i=0, 1 do
   487 	for i=0, 1 do
   511 		fPlaced[i] = false
   488 		fPlaced[i] = false
   512 		fCaptures[i] = 0
   489 		fCaptures[i] = 0
   513 	end
   490 	end
   514 
   491 
   515 	--zxc = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
       
   516 
       
   517 
       
   518 	--SetVisualGearValues(zxc, 1000,1000, 20, 255, 1,    10,                     0,         200,        1,      GetClanColor(0))
       
   519 					--minO,max0 -glowyornot	--pulsate timer	 -- fuckall      -- radius -- width  -- colour
       
   520 	for h=1, numhhs do
   492 	for h=1, numhhs do
   521 		-- Hogs are resurrected for free, so this is pointless
   493 		-- Hogs are resurrected for free, so this is pointless
   522 		AddAmmo(hhs[h], amResurrector, 0)
   494 		AddAmmo(hhs[h], amResurrector, 0)
   523 	end
   495 	end
   524 
   496 
   533 
   505 
   534 	if lastTeam ~= GetHogTeamName(CurrentHedgehog) then
   506 	if lastTeam ~= GetHogTeamName(CurrentHedgehog) then
   535 		lastTeam = GetHogTeamName(CurrentHedgehog)
   507 		lastTeam = GetHogTeamName(CurrentHedgehog)
   536 	end
   508 	end
   537 
   509 
   538 	--AddCaption("Handling respawns")
       
   539 	if gameStarted == true then
   510 	if gameStarted == true then
   540 		HandleRespawns()
   511 		HandleRespawns()
   541 	--new method of placing starting flags
   512 	--new method of placing starting flags
   542 	elseif gameTurns == 1 then
   513 	elseif gameTurns == 1 then
   543 		showCTFMission()
   514 		showCTFMission()
   550 
   521 
   551 end
   522 end
   552 
   523 
   553 function onGameTick()
   524 function onGameTick()
   554 
   525 
   555 	-- onRessurect calls AFTER you have resurrected,
   526 	for i = 0,1 do
   556 	-- so keeping track of x,y a few milliseconds before
   527 		if fThief[i] ~= nil then
   557 	-- is useful
   528 			fThiefX[i] = GetX(fThief[i])
   558 	--FTTC = FTTC + 1
   529 			fThiefY[i] = GetY(fThief[i])
   559 	--if FTTC == 100 then
   530 		end
   560 	--	FTTC = 0
       
   561 		for i = 0,1 do
       
   562 			if fThief[i] ~= nil then
       
   563 				fThiefX[i] = GetX(fThief[i])
       
   564 				fThiefY[i] = GetY(fThief[i])
       
   565 			end
       
   566 		end
       
   567 	--end
       
   568 
       
   569 	-- things we wanna check often
       
   570 	if (CurrentHedgehog ~= nil) then
       
   571 		--AddCaption(LAND_HEIGHT - GetY(CurrentHedgehog))
       
   572 		--AddCaption(GetX(CurrentHedgehog) .. "; " .. GetY(CurrentHedgehog))
       
   573 		--CheckTeleporters()
       
   574 
       
   575 	end
   531 	end
   576 
   532 
   577 	if gameStarted == true then
   533 	if gameStarted == true then
   578 		HandleCircles()
   534 		HandleCircles()
   579 		if CurrentHedgehog ~= nil then
   535 		if CurrentHedgehog ~= nil then
   596 
   552 
   597 end
   553 end
   598 
   554 
   599 function onGearResurrect(gear)
   555 function onGearResurrect(gear)
   600 
   556 
   601 	--AddCaption("A gear has been resurrected!")
       
   602 
       
   603 	-- mark the flag thief as dead if he needed a respawn
   557 	-- mark the flag thief as dead if he needed a respawn
   604 	for i = 0,1 do
   558 	for i = 0,1 do
   605 		if gear == fThief[i] then
   559 		if gear == fThief[i] then
   606 			FlagThiefDead(gear)
   560 			FlagThiefDead(gear)
   607 		end
   561 		end
   608 	end
   562 	end
   609 
       
   610 	-- should be covered by gfDivideTeams, actually
       
   611 	-- place hogs belonging to each clan either left or right side of map
       
   612 	--if GetHogClan(gear) == 0 then
       
   613 	--	FindPlace(gear, false, 0, LAND_WIDTH/2)
       
   614 	--elseif GetHogClan(gear) == 1 then
       
   615 	--	FindPlace(gear, false, LAND_WIDTH/2, LAND_WIDTH)
       
   616 	--end
       
   617 
   563 
   618 	AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   564 	AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   619 
   565 
   620 end
   566 end
   621 
   567 
   640 function onHogRestore(gear)
   586 function onHogRestore(gear)
   641 	match = false
   587 	match = false
   642 	for i = 0, (numhhs-1) do
   588 	for i = 0, (numhhs-1) do
   643 		if (hhs[i] == nil) and (match == false) then
   589 		if (hhs[i] == nil) and (match == false) then
   644 			hhs[i] = gear
   590 			hhs[i] = gear
   645 			--AddCaption(GetHogName(gear) .. " has reappeared it seems!")
       
   646 			match = true
   591 			match = true
   647 		end
   592 		end
   648 	end
   593 	end
   649 end
   594 end
   650 
   595