share/hedgewars/Data/Missions/Bazooka Training.hwt
changeset 2950 81dd71096b1f
parent 2949 d137a9da7701
child 2958 e6f7620da87e
equal deleted inserted replaced
2949:d137a9da7701 2950:81dd71096b1f
    12 -- This way we're able to localize the text to be shown without
    12 -- This way we're able to localize the text to be shown without
    13 -- modifying other files.
    13 -- modifying other files.
    14 -- The language to be used is stored in the global variable
    14 -- The language to be used is stored in the global variable
    15 -- 'L' that is set by the game (string).
    15 -- 'L' that is set by the game (string).
    16 -- Text may then be accessed using "arrayname[L]".
    16 -- Text may then be accessed using "arrayname[L]".
       
    17 
    17 local caption = {
    18 local caption = {
    18 	["en"] = "Bazooka Training",
    19 	["en"] = "Bazooka Training",
    19 	["de"] = "Bazooka-Training"
    20 	["de"] = "Bazooka-Training"
    20 	}
    21 	}
    21 local subcaption = {
    22 local subcaption = {
    45 
    46 
    46 local hogname = {
    47 local hogname = {
    47 	["en"] = "Hunter",
    48 	["en"] = "Hunter",
    48 	["de"] = "Jäger"
    49 	["de"] = "Jäger"
    49 	}
    50 	}
       
    51 
       
    52 -- To handle missing texts we define a small wrapper function that
       
    53 -- we'll use to retrieve text.
       
    54 local function loc(text)
       
    55 	if text == nil then return "**missing**"
       
    56 	elseif text[L] == nil then return text["en"]
       
    57 	else return text[L]
       
    58 	end
       
    59 end
       
    60 
    50 ---------------------------------------------------------------
    61 ---------------------------------------------------------------
    51 
    62 
    52 -- This variable will hold the number of destroyed targets.
    63 -- This variable will hold the number of destroyed targets.
    53 local score = 0
    64 local score = 0
    54 -- This variable represents the number of targets to destroy.
    65 -- This variable represents the number of targets to destroy.
   111 	Map = "Bamboo"
   122 	Map = "Bamboo"
   112 	-- The theme to be used
   123 	-- The theme to be used
   113 	Theme = "Bamboo"
   124 	Theme = "Bamboo"
   114 
   125 
   115 	-- Create the player team
   126 	-- Create the player team
   116 	AddTeam(teamname[L], 14483456, "Simple", "Island", "Default")
   127 	AddTeam(loc(teamname), 14483456, "Simple", "Island", "Default")
   117 	-- And add a hog to it
   128 	-- And add a hog to it
   118 	player = AddHog(hogname[L], 0, 1, "NoHat")
   129 	player = AddHog(loc(hogname), 0, 1, "NoHat")
   119 	SetGearPosition(player, 1960, 1160);
   130 	SetGearPosition(player, 1960, 1160);
   120 end
   131 end
   121 
   132 
   122 -- This function is called when the round starts
   133 -- This function is called when the round starts
   123 -- it spawns the first target that has to be destroyed.
   134 -- it spawns the first target that has to be destroyed.
   130 	-- Parameters are: caption, sub caption, description,
   141 	-- Parameters are: caption, sub caption, description,
   131 	-- extra text, icon and time to show.
   142 	-- extra text, icon and time to show.
   132 	-- A negative icon parameter (-n) represents the n-th weapon icon
   143 	-- A negative icon parameter (-n) represents the n-th weapon icon
   133 	-- A positive icon paramter (n) represents the (n+1)-th mission icon
   144 	-- A positive icon paramter (n) represents the (n+1)-th mission icon
   134 	-- A timeframe of 0 is replaced with the default time to show.
   145 	-- A timeframe of 0 is replaced with the default time to show.
   135 	ShowMission(caption[L], subcaption[L], goal[L], -amBazooka, 0);
   146 	ShowMission(loc(caption), loc(subcaption), loc(goal), -amBazooka, 0);
   136 end
   147 end
   137 
   148 
   138 -- This function is called every game tick.
   149 -- This function is called every game tick.
   139 -- Note that there are 1000 ticks within one second.
   150 -- Note that there are 1000 ticks within one second.
   140 -- You shouldn't try to calculate too complicated
   151 -- You shouldn't try to calculate too complicated
   144 	-- We actually check the time to be "1 ms" as it
   155 	-- We actually check the time to be "1 ms" as it
   145 	-- will be at "0 ms" right at the start of the game.
   156 	-- will be at "0 ms" right at the start of the game.
   146 	if TurnTimeLeft == 1 and score < score_goal then
   157 	if TurnTimeLeft == 1 and score < score_goal then
   147 		game_lost = true
   158 		game_lost = true
   148 		-- ... and show a short message.
   159 		-- ... and show a short message.
   149 		ShowMission(caption[L], subcaption[L], timeout[L], -amSkip, 0);
   160 		ShowMission(loc(caption), loc(subcaption), loc(timeout), -amSkip, 0);
   150 		-- How about killing our poor hog due to his poor performance?
   161 		-- How about killing our poor hog due to his poor performance?
   151 		SetHealth(player, 0);
   162 		SetHealth(player, 0);
   152 		-- Just to be sure set the goal time to 1 ms
   163 		-- Just to be sure set the goal time to 1 ms
   153 		time_goal = 1
   164 		time_goal = 1
   154 	end
   165 	end
   193 			-- ... spawn another target.
   204 			-- ... spawn another target.
   194 			spawnTarget()
   205 			spawnTarget()
   195 		else
   206 		else
   196 			if not game_lost then
   207 			if not game_lost then
   197 			-- Otherwise show that the goal was accomplished
   208 			-- Otherwise show that the goal was accomplished
   198 			ShowMission(caption[L], subcaption[L], success[L], 0, 0);
   209 			ShowMission(loc(caption), loc(subcaption), loc(success), 0, 0);
   199 			-- Also let the hogs shout "victory!"
   210 			-- Also let the hogs shout "victory!"
   200 			PlaySound(sndVictory)
   211 			PlaySound(sndVictory)
   201 			-- Save the time left so we may keep it.
   212 			-- Save the time left so we may keep it.
   202 			time_goal = TurnTimeLeft
   213 			time_goal = TurnTimeLeft
   203 			end
   214 			end