share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
changeset 7139 a47fd17ba463
parent 6253 d73317579ae4
child 7142 8842fa26698b
equal deleted inserted replaced
7137:5587ab553f32 7139:a47fd17ba463
   105 -------
   105 -------
   106 -- racer vars
   106 -- racer vars
   107 --------
   107 --------
   108 
   108 
   109 local cGear = nil
   109 local cGear = nil
   110 local gTimer = 0
       
   111 
   110 
   112 local bestClan = nil
   111 local bestClan = nil
   113 local bestTime = nil
   112 local bestTime = nil
   114 
   113 
   115 local gameBegun = false
   114 local gameBegun = false
   116 local gameOver = false
   115 local gameOver = false
   117 local racerActive = false
   116 local racerActive = false
   118 local trackTime = 0
   117 local trackTime = 0
   119 local wpCheckCounter = 0
       
   120 
   118 
   121 local wpCirc = {}
   119 local wpCirc = {}
   122 local wpX = {}
   120 local wpX = {}
   123 local wpY = {}
   121 local wpY = {}
   124 local wpCol = {}
   122 local wpCol = {}
   550 	AddAmmo(CurrentHedgehog, amNapalm, 0)
   548 	AddAmmo(CurrentHedgehog, amNapalm, 0)
   551 	AddAmmo(CurrentHedgehog, amPiano, 0)
   549 	AddAmmo(CurrentHedgehog, amPiano, 0)
   552 
   550 
   553 end
   551 end
   554 
   552 
   555 function onGameTick()
   553 function onGameTick20()
   556 
   554 
   557 	-- airstrike detected, convert this into a potential waypoint spot
   555 	-- airstrike detected, convert this into a potential waypoint spot
   558 	if cGear ~= nil then
   556 	if cGear ~= nil then
   559 		x,y = GetGearTarget(cGear)
   557 		x,y = GetGearTarget(cGear)
   560 
   558 
   611 
   609 
   612 		-- if the RACE has started, show tracktimes and keep tabs on waypoints
   610 		-- if the RACE has started, show tracktimes and keep tabs on waypoints
   613 		if (racerActive == true) and (gameBegun == true) then
   611 		if (racerActive == true) and (gameBegun == true) then
   614 
   612 
   615 			--ghost
   613 			--ghost
   616 			gTimer = gTimer + 1
   614 			if GameTime%40 == 0 then
   617 			if gTimer == 40 then
       
   618 				gTimer = 0
       
   619 				HandleGhost()
   615 				HandleGhost()
   620 			end
   616 			end
   621 
   617 
   622 			trackTime = trackTime + 1
   618 			trackTime = trackTime + 20
   623 
   619 
   624 			wpCheckCounter = wpCheckCounter + 1
   620 			if GameTime%100 == 0 then
   625 			if (wpCheckCounter == 100) then
   621 
   626 
       
   627 				wpCheckCounter = 0
       
   628 				AddCaption(trackTime/1000,GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)
   622 				AddCaption(trackTime/1000,GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)
   629 
   623 
   630 				if (CheckWaypoints() == true) then
   624 				if (CheckWaypoints() == true) then
   631 					AdjustScores()
   625 					AdjustScores()
   632 					racerActive = false
   626 					racerActive = false
   638 		end
   632 		end
   639 
   633 
   640 
   634 
   641 
   635 
   642 		-- if the player has expended his tunbling time, stop him tumbling
   636 		-- if the player has expended his tunbling time, stop him tumbling
   643 		if TurnTimeLeft <= 1 then
   637 		if TurnTimeLeft <= 20 then
   644 			DisableTumbler()
   638 			DisableTumbler()
   645 		end
   639 		end
   646 
   640 
   647 	end
   641 	end
   648 
   642