share/hedgewars/Data/Missions/Training/Shotgun.lua
changeset 4493 45db8e97d282
parent 4350 cdb3d7a39fa2
child 4506 37744d5c877e
equal deleted inserted replaced
4492:e5554b06b68f 4493:45db8e97d282
   172 
   172 
   173 	-- Create the player team
   173 	-- Create the player team
   174 	AddTeam(loc(teamname), 14483456, "Simple", "Island", "Default")
   174 	AddTeam(loc(teamname), 14483456, "Simple", "Island", "Default")
   175 	-- And add a hog to it
   175 	-- And add a hog to it
   176 	player = AddHog(loc(hogname), 0, 1, "NoHat")
   176 	player = AddHog(loc(hogname), 0, 1, "NoHat")
   177 	SetGearPosition(player, 2334, 1254);
   177 	SetGearPosition(player, 2334, 1254)
   178 end
   178 end
   179 
   179 
   180 -- This function is called when the round starts
   180 -- This function is called when the round starts
   181 -- it spawns the first target that has to be destroyed.
   181 -- it spawns the first target that has to be destroyed.
   182 -- In addition it shows the scenario goal(s).
   182 -- In addition it shows the scenario goal(s).
   188 	-- Parameters are: caption, sub caption, description,
   188 	-- Parameters are: caption, sub caption, description,
   189 	-- extra text, icon and time to show.
   189 	-- extra text, icon and time to show.
   190 	-- A negative icon parameter (-n) represents the n-th weapon icon
   190 	-- A negative icon parameter (-n) represents the n-th weapon icon
   191 	-- A positive icon paramter (n) represents the (n+1)-th mission icon
   191 	-- A positive icon paramter (n) represents the (n+1)-th mission icon
   192 	-- A timeframe of 0 is replaced with the default time to show.
   192 	-- A timeframe of 0 is replaced with the default time to show.
   193 	ShowMission(loc(caption), loc(subcaption), loc(goal), -amShotgun, 0);
   193 	ShowMission(loc(caption), loc(subcaption), loc(goal), -amShotgun, 0)
   194 end
   194 end
   195 
   195 
   196 -- This function is called every game tick.
   196 -- This function is called every game tick.
   197 -- Note that there are 1000 ticks within one second.
   197 -- Note that there are 1000 ticks within one second.
   198 -- You shouldn't try to calculate too complicated
   198 -- You shouldn't try to calculate too complicated
   202 	-- We actually check the time to be "1 ms" as it
   202 	-- We actually check the time to be "1 ms" as it
   203 	-- will be at "0 ms" right at the start of the game.
   203 	-- will be at "0 ms" right at the start of the game.
   204 	if TurnTimeLeft == 1 and score < score_goal then
   204 	if TurnTimeLeft == 1 and score < score_goal then
   205 		game_lost = true
   205 		game_lost = true
   206 		-- ... and show a short message.
   206 		-- ... and show a short message.
   207 		ShowMission(loc(caption), loc(subcaption), loc(timeout), -amSkip, 0);
   207 		ShowMission(loc(caption), loc(subcaption), loc(timeout), -amSkip, 0)
   208 		-- How about killing our poor hog due to his poor performance?
   208 		-- How about killing our poor hog due to his poor performance?
   209 		SetHealth(player, 0);
   209 		SetHealth(player, 0)
   210 		-- Just to be sure set the goal time to 1 ms
   210 		-- Just to be sure set the goal time to 1 ms
   211 		time_goal = 1
   211 		time_goal = 1
   212 	end
   212 	end
   213 	-- If the goal is reached or we've lost ...
   213 	-- If the goal is reached or we've lost ...
   214 	if score == score_goal or game_lost then
   214 	if score == score_goal or game_lost then
   251 			-- ... spawn another target.
   251 			-- ... spawn another target.
   252 			spawnTarget()
   252 			spawnTarget()
   253 		else
   253 		else
   254 			if not game_lost then
   254 			if not game_lost then
   255 			-- Otherwise show that the goal was accomplished
   255 			-- Otherwise show that the goal was accomplished
   256 			ShowMission(loc(caption), loc(subcaption), loc(success), 0, 0);
   256 			ShowMission(loc(caption), loc(subcaption), loc(success), 0, 0)
   257 			-- Also let the hogs shout "victory!"
   257 			-- Also let the hogs shout "victory!"
   258 			PlaySound(sndVictory)
   258 			PlaySound(sndVictory)
   259 			-- Save the time left so we may keep it.
   259 			-- Save the time left so we may keep it.
   260 			time_goal = TurnTimeLeft
   260 			time_goal = TurnTimeLeft
   261 			end
   261 			end