share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua
changeset 13104 e0ec37c8104d
parent 13103 cf2a58dccc4a
child 13106 115d7438aa3d
equal deleted inserted replaced
13103:cf2a58dccc4a 13104:e0ec37c8104d
   415 	gameStarted = true
   415 	gameStarted = true
   416 	AddCaption(loc("Game Started!"))
   416 	AddCaption(loc("Game Started!"))
   417 
   417 
   418 	for i = 0, 1 do
   418 	for i = 0, 1 do
   419 
   419 
   420 		-- if someone uses kamikaze downwards, this can happen as the hog won't respawn
       
   421 		if (LAND_HEIGHT - fSpawnY[i]) < 0 then
       
   422 			tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
       
   423      			FindPlace(tempG, true, 0, LAND_WIDTH, true)
       
   424 			fSpawnX[i], fSpawnY[i] = GetGearPosition(tempG)
       
   425 			DeleteGear(tempG)
       
   426 		end
       
   427 
       
   428 		fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   420 		fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   429 		fCirc[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   421 		fCirc[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   430 		fSpawnC[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   422 		fSpawnC[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   431 
   423 
   432 		fGearX[i] = fSpawnX[i]
   424 		fGearX[i] = fSpawnX[i]
   513 				FindPlace(hhs[g], false, LAND_WIDTH/2, LAND_WIDTH)
   505 				FindPlace(hhs[g], false, LAND_WIDTH/2, LAND_WIDTH)
   514 			end
   506 			end
   515 		end
   507 		end
   516 	end]]
   508 	end]]
   517 
   509 
   518 	fPlaced[0] = false
   510 	for i=0, 1 do
   519 	fPlaced[1] = false
   511 		fPlaced[i] = false
       
   512 		fCaptures[i] = 0
       
   513 	end
   520 
   514 
   521 	--zxc = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   515 	--zxc = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
   522 
   516 
   523 
   517 
   524 	--SetVisualGearValues(zxc, 1000,1000, 20, 255, 1,    10,                     0,         200,        1,      GetClanColor(0))
   518 	--SetVisualGearValues(zxc, 1000,1000, 20, 255, 1,    10,                     0,         200,        1,      GetClanColor(0))
   525 					--minO,max0 -glowyornot	--pulsate timer	 -- fuckall      -- radius -- width  -- colour
   519 					--minO,max0 -glowyornot	--pulsate timer	 -- fuckall      -- radius -- width  -- colour
   526 	for h=1, numhhs do
   520 	for h=1, numhhs do
   527 		-- Tardis causes too many unexpected situations, so we forbid it
       
   528 		AddAmmo(hhs[h], amTardis, 0)
       
   529 		-- Hogs are resurrected for free, so this is pointless
   521 		-- Hogs are resurrected for free, so this is pointless
   530 		AddAmmo(hhs[h], amResurrector, 0)
   522 		AddAmmo(hhs[h], amResurrector, 0)
   531 	end
   523 	end
       
   524 
       
   525 	updateScores()
   532 
   526 
   533 end
   527 end
   534 
   528 
   535 
   529 
   536 function onNewTurn()
   530 function onNewTurn()
   591 			i = 0
   585 			i = 0
   592 		elseif GetHogClan(CurrentHedgehog) == 1 then
   586 		elseif GetHogClan(CurrentHedgehog) == 1 then
   593 			i = 1
   587 			i = 1
   594 		end
   588 		end
   595 
   589 
   596 		if TurnTimeLeft == 0 then
   590 		if TurnTimeLeft == 0 and GetX(CurrentHedgehog) then
   597 			fSpawnX[i] = GetX(CurrentHedgehog)
   591 			fSpawnX[i] = GetX(CurrentHedgehog)
   598 			fSpawnY[i] = GetY(CurrentHedgehog)
   592 			fSpawnY[i] = GetY(CurrentHedgehog)
   599 		end
   593 		end
   600 
   594 
   601 	end
   595 	end
   652 			match = true
   646 			match = true
   653 		end
   647 		end
   654 	end
   648 	end
   655 end
   649 end
   656 
   650 
       
   651 function onHogAttack(ammoType)
       
   652 	if not gameStarted and ammoType == amTardis then
       
   653 		local i = GetHogClan(CurrentHedgehog)
       
   654 		fSpawnX[i] = GetX(CurrentHedgehog)
       
   655 		fSpawnY[i] = GetY(CurrentHedgehog)
       
   656 	end
       
   657 end
   657 
   658 
   658 function onGearAdd(gear)
   659 function onGearAdd(gear)
   659 
   660 
   660 	if GetGearType(gear) == gtHedgehog then
   661 	if GetGearType(gear) == gtHedgehog then
   661 		hhs[numhhs] = gear
   662 		hhs[numhhs] = gear
   676 
   677 
   677 function onGearDelete(gear)
   678 function onGearDelete(gear)
   678 
   679 
   679 	if GetGearType(gear) == gtHedgehog then
   680 	if GetGearType(gear) == gtHedgehog then
   680 		InABetterPlaceNow(gear)
   681 		InABetterPlaceNow(gear)
   681 	end
   682 	elseif GetGearType(gear) == gtKamikaze and not gameStarted then
   682 
   683 		local i = GetHogClan(CurrentHedgehog)
   683 end
   684 		fSpawnX[i] = GetX(CurrentHedgehog)
       
   685 		fSpawnY[i] = GetY(CurrentHedgehog)
       
   686 	end
       
   687 
       
   688 end