share/hedgewars/Data/Missions/Training/Basic_Training_-_Shotgun.lua
changeset 7165 aad1aea05f1e
parent 4665 fa7ad5f3725f
child 7877 b3fb94986255
equal deleted inserted replaced
7164:fad64b97947e 7165:aad1aea05f1e
   109 
   109 
   110 -- This function is called every game tick.
   110 -- This function is called every game tick.
   111 -- Note that there are 1000 ticks within one second.
   111 -- Note that there are 1000 ticks within one second.
   112 -- You shouldn't try to calculate too complicated
   112 -- You shouldn't try to calculate too complicated
   113 -- code here as this might slow down your game.
   113 -- code here as this might slow down your game.
   114 function onGameTick()
   114 function onGameTick20()
   115 	-- If time's up, set the game to be lost.
   115 	-- If time's up, set the game to be lost.
   116 	-- We actually check the time to be "1 ms" as it
   116 	-- We actually check the time to be "1 ms" as it
   117 	-- will be at "0 ms" right at the start of the game.
   117 	-- will be at "0 ms" right at the start of the game.
   118 	if TurnTimeLeft == 1 and score < score_goal then
   118 	if TurnTimeLeft < 40 and TurnTimeLeft > 20 and score < score_goal then
   119 		game_lost = true
   119 		game_lost = true
   120 		-- ... and show a short message.
   120 		-- ... and show a short message.
   121 		ShowMission(loc("Shotgun Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
   121 		ShowMission(loc("Shotgun Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
   122 		-- How about killing our poor hog due to his poor performance?
   122 		-- How about killing our poor hog due to his poor performance?
   123 		SetHealth(player, 0)
   123 		SetHealth(player, 0)
   131 		if end_timer == 0 then
   131 		if end_timer == 0 then
   132 			-- ... end the game ...
   132 			-- ... end the game ...
   133 			EndGame()
   133 			EndGame()
   134 		else
   134 		else
   135 			-- ... or just lower the timer by 1.
   135 			-- ... or just lower the timer by 1.
   136 			end_timer = end_timer - 1
   136 			end_timer = end_timer - 20
   137 			-- Reset the time left to stop the timer
   137 			-- Reset the time left to stop the timer
   138 			TurnTimeLeft = time_goal
   138 			TurnTimeLeft = time_goal
   139 		end
   139 		end
   140 	end
   140 	end
   141 end
   141 end
   148 end
   148 end
   149 
   149 
   150 -- This function is called when a new gear is added.
   150 -- This function is called when a new gear is added.
   151 -- We don't need it for this training, so we can
   151 -- We don't need it for this training, so we can
   152 -- keep it empty.
   152 -- keep it empty.
   153 function onGearAdd(gear)
   153 -- function onGearAdd(gear)
   154 end
   154 -- end
   155 
   155 
   156 -- This function is called before a gear is destroyed.
   156 -- This function is called before a gear is destroyed.
   157 -- We use it to count the number of targets destroyed.
   157 -- We use it to count the number of targets destroyed.
   158 function onGearDelete(gear)
   158 function onGearDelete(gear)
   159 	-- We're only interested in target gears.
   159 	-- We're only interested in target gears.