share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua
changeset 7165 aad1aea05f1e
parent 7094 f5a5578be66b
child 7877 b3fb94986255
equal deleted inserted replaced
7164:fad64b97947e 7165:aad1aea05f1e
   112 
   112 
   113 -- This function is called every game tick.
   113 -- This function is called every game tick.
   114 -- Note that there are 1000 ticks within one second.
   114 -- Note that there are 1000 ticks within one second.
   115 -- You shouldn't try to calculate too complicated
   115 -- You shouldn't try to calculate too complicated
   116 -- code here as this might slow down your game.
   116 -- code here as this might slow down your game.
   117 function onGameTick()
   117 function onGameTick20()
   118 	-- If time's up, set the game to be lost.
   118 	-- If time's up, set the game to be lost.
   119 	-- We actually check the time to be "1 ms" as it
   119 	-- We actually check the time to be "1 ms" as it
   120 	-- will be at "0 ms" right at the start of the game.
   120 	-- will be at "0 ms" right at the start of the game.
   121 	if TurnTimeLeft == 1 and score < score_goal then
   121 	if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal then
   122 		game_lost = true
   122 		game_lost = true
   123 		-- ... and show a short message.
   123 		-- ... and show a short message.
   124 		ShowMission(loc("Grenade Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
   124 		ShowMission(loc("Grenade Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
   125 		-- How about killing our poor hog due to his poor performance?
   125 		-- How about killing our poor hog due to his poor performance?
   126 		SetHealth(player, 0)
   126 		SetHealth(player, 0)
   143 				team_death = true
   143 				team_death = true
   144 				ParseCommand("teamgone " .. "Grenadiers")
   144 				ParseCommand("teamgone " .. "Grenadiers")
   145 			end
   145 			end
   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 	-- We're only interested in target gears.
   171 	-- We're only interested in target gears.