share/hedgewars/Data/Missions/Training/Basic_Training_-_Sniper_Rifle.lua
changeset 7165 aad1aea05f1e
parent 5836 6d6041b50b09
child 8043 da083f8d95e6
equal deleted inserted replaced
7164:fad64b97947e 7165:aad1aea05f1e
   110 
   110 
   111 -- This function is called every game tick.
   111 -- This function is called every game tick.
   112 -- Note that there are 1000 ticks within one second.
   112 -- Note that there are 1000 ticks within one second.
   113 -- You shouldn't try to calculate too complicated
   113 -- You shouldn't try to calculate too complicated
   114 -- code here as this might slow down your game.
   114 -- code here as this might slow down your game.
   115 function onGameTick()
   115 function onGameTick20()
   116 	if game_lost then
   116 	if game_lost then
   117 		return
   117 		return
   118 	end
   118 	end
   119 	-- after a target is destroyed, show hog, then target
   119 	-- after a target is destroyed, show hog, then target
   120 	if (target ~= nil) and (TurnTimeLeft + 1300 < last_hit_time) then
   120 	if (target ~= nil) and (TurnTimeLeft + 1300 < last_hit_time) then
   125 		FollowGear(player)
   125 		FollowGear(player)
   126 	end
   126 	end
   127 	-- If time's up, set the game to be lost.
   127 	-- If time's up, set the game to be lost.
   128 	-- We actually check the time to be "1 ms" as it
   128 	-- We actually check the time to be "1 ms" as it
   129 	-- will be at "0 ms" right at the start of the game.
   129 	-- will be at "0 ms" right at the start of the game.
   130 	if TurnTimeLeft == 1 and score < score_goal then
   130 	if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal then
   131 		game_lost = true
   131 		game_lost = true
   132 		-- ... and show a short message.
   132 		-- ... and show a short message.
   133 		ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
   133 		ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
   134 		-- How about killing our poor hog due to his poor performance?
   134 		-- How about killing our poor hog due to his poor performance?
   135 		SetHealth(player, 0)
   135 		SetHealth(player, 0)
   143 		if end_timer == 0 then
   143 		if end_timer == 0 then
   144 			-- ... end the game ...
   144 			-- ... end the game ...
   145 			EndGame()
   145 			EndGame()
   146 		else
   146 		else
   147 			-- ... or just lower the timer by 1.
   147 			-- ... or just lower the timer by 1.
   148 			end_timer = end_timer - 1
   148 			end_timer = end_timer - 20
   149 			-- Reset the time left to stop the timer
   149 			-- Reset the time left to stop the timer
   150 			TurnTimeLeft = time_goal
   150 			TurnTimeLeft = time_goal
   151 		end
   151 		end
   152 	end
   152 	end
   153 end
   153 end
   160 end
   160 end
   161 
   161 
   162 -- This function is called when a new gear is added.
   162 -- This function is called when a new gear is added.
   163 -- We don't need it for this training, so we can
   163 -- We don't need it for this training, so we can
   164 -- keep it empty.
   164 -- keep it empty.
   165 function onGearAdd(gear)
   165 -- function onGearAdd(gear)
   166 end
   166 -- end
   167 
   167 
   168 -- This function is called before a gear is destroyed.
   168 -- This function is called before a gear is destroyed.
   169 -- We use it to count the number of targets destroyed.
   169 -- We use it to count the number of targets destroyed.
   170 function onGearDelete(gear)
   170 function onGearDelete(gear)
   171     
   171