share/hedgewars/Data/Missions/Training/SniperRifle.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, "Sniper")
   176 	player = AddHog(loc(hogname), 0, 1, "Sniper")
   177 	SetGearPosition(player, 602, 1465);
   177 	SetGearPosition(player, 602, 1465)
   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), -amSniperRifle, 0);
   193 	ShowMission(loc(caption), loc(subcaption), loc(goal), -amSniperRifle, 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
   213 	-- We actually check the time to be "1 ms" as it
   213 	-- We actually check the time to be "1 ms" as it
   214 	-- will be at "0 ms" right at the start of the game.
   214 	-- will be at "0 ms" right at the start of the game.
   215 	if TurnTimeLeft == 1 and score < score_goal then
   215 	if TurnTimeLeft == 1 and score < score_goal then
   216 		game_lost = true
   216 		game_lost = true
   217 		-- ... and show a short message.
   217 		-- ... and show a short message.
   218 		ShowMission(loc(caption), loc(subcaption), loc(timeout), -amSkip, 0);
   218 		ShowMission(loc(caption), loc(subcaption), loc(timeout), -amSkip, 0)
   219 		-- How about killing our poor hog due to his poor performance?
   219 		-- How about killing our poor hog due to his poor performance?
   220 		SetHealth(player, 0);
   220 		SetHealth(player, 0)
   221 		-- Just to be sure set the goal time to 1 ms
   221 		-- Just to be sure set the goal time to 1 ms
   222 		time_goal = 1
   222 		time_goal = 1
   223 	end
   223 	end
   224 	-- If the goal is reached or we've lost ...
   224 	-- If the goal is reached or we've lost ...
   225 	if score == score_goal or game_lost then
   225 	if score == score_goal or game_lost then
   379 				spawnTarget(3480,1200)
   379 				spawnTarget(3480,1200)
   380 			end
   380 			end
   381 		else
   381 		else
   382 			if not game_lost then
   382 			if not game_lost then
   383 			-- Otherwise show that the goal was accomplished
   383 			-- Otherwise show that the goal was accomplished
   384 			ShowMission(loc(caption), loc(subcaption), loc(success), 0, 0);
   384 			ShowMission(loc(caption), loc(subcaption), loc(success), 0, 0)
   385 			-- Also let the hogs shout "victory!"
   385 			-- Also let the hogs shout "victory!"
   386 			PlaySound(sndVictory)
   386 			PlaySound(sndVictory)
   387 			-- Save the time left so we may keep it.
   387 			-- Save the time left so we may keep it.
   388 			time_goal = TurnTimeLeft
   388 			time_goal = TurnTimeLeft
   389 			end
   389 			end