share/hedgewars/Data/Missions/Training/Shotgun.lua
changeset 4506 37744d5c877e
parent 4493 45db8e97d282
equal deleted inserted replaced
4505:4a8f87eb67cb 4506:37744d5c877e
     6 -- It's also possible to place a comment after some real
     6 -- It's also possible to place a comment after some real
     7 -- instruction as you see below. In short, everything
     7 -- instruction as you see below. In short, everything
     8 -- following "--" is ignored.
     8 -- following "--" is ignored.
     9 
     9 
    10 ---------------------------------------------------------------
    10 ---------------------------------------------------------------
    11 -- At first we put all text we'd like to use in some arrays.
    11 -- At first we implement the localization library using loadfile.
    12 -- This way we're able to localize the text to be shown without
    12 -- This allows us to localize strings without needing to think
    13 -- modifying other files.
    13 -- about translations.
    14 -- The language to be used is stored in the global variable
    14 -- We can use the function loc(text) to localize a string.
    15 -- 'L' that is set by the game (string).
       
    16 -- Text may then be accessed using "arrayname[L]".
       
    17 
    15 
    18 local caption = {
    16 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
    19 	["en"] = "Shotgun Training",
       
    20 	["de"] = "Schrotflinten-Training",
       
    21 	["es"] = "Entrenamiento con escopeta",
       
    22 	["pl"] = "Trening strzelecki",
       
    23 	["pt_PT"] = "Treino com Caçadeira",
       
    24 	["pt_BR"] = "Treino com a Escopeta",
       
    25 	["sv"] = "Hagelgevärsträning",
       
    26 	["sk"] = "Tréning s brokovnicou"
       
    27 	-- To add other languages, just add lines similar to the
       
    28 	-- existing ones - don't forget the trailing ","!
       
    29 	}
       
    30 
       
    31 local subcaption = {
       
    32 	["en"] = "Aiming Practice",
       
    33 	["de"] = "Zielübung",
       
    34 	["es"] = "Practica tu puntería",
       
    35 	["pl"] = "Potrenuj celność",
       
    36 	["pt_PT"] = "Pratica a tua pontaria",
       
    37 	["pt_BR"] = "Pratique a sua pontaria",
       
    38 	["sv"] = "Siktesövning",
       
    39 	["sk"] = "Tréning presnosti"
       
    40 	}
       
    41 
       
    42 local goal = {
       
    43 	["en"] = "Eliminate all targets before your time runs out.|You have unlimited ammo for this mission.",
       
    44 	["de"] = "Eliminiere alle Ziele bevor die Zeit ausläuft.|Du hast in dieser Mission unbegrenzte Munition.",
       
    45 	["es"] = "Destruye todos los objetivos antes de que se agote el tiempo.|La munición en esta misión es ilimitada.",
       
    46 	["pl"] = "Zniszcz wszystkie cele zanim upłynie czas.|W tej misji masz nieskończoną ilość amunicji.",
       
    47 	["pt_PT"] = "Destrói todos os alvos antes do tempo terminar.|Tens munições infinitas para esta missão.",
       
    48 	["pt_BR"] = "Destrua todos os alvos antes que o tempo acabe.|Você tem munição infinita para esta missão.",
       
    49 	["sv"] = "Förstör alla målen innan din tid tar slut.|Du har obegränsad ammunition för deta uppdrag",
       
    50 	["sk"] = "Zneškodnite všetky ciele pred vypršaním času.|Na túto misiu máte neobmedzené množstvo streliva."
       
    51 	}
       
    52 
       
    53 local timeout = {
       
    54 	["en"] = "Oh no! Time's up! Just try again.",
       
    55 	["de"] = "Oh nein! Die Zeit ist um! Versuche es nochmal.",
       
    56 	["es"] = "¡Oh, no, se te acabó el tiempo! ¿Por qué no lo intentas de nuevo?",
       
    57 	["pl"] = "Ajajaj! Koniec czasu! Spróbuj jeszcze raz.",
       
    58 	["pt_PT"] = "Oh não! Acabou o tempo! Tenta novamente.",
       
    59 	["pt_BR"] = "Oh não! O tempo acabou! Tente novamente.",
       
    60 	["sv"] = "Åh nej! Tiden är ute! Pröva igen.",
       
    61 	["sk"] = "Ale nie! Čas vypršal! Tak to skúste znovu."
       
    62 	}
       
    63 
       
    64 local success = {
       
    65 	["en"] = "Congratulations! You've eliminated all targets|within the allowed time frame.",
       
    66 	["de"] = "Gratulation! Du hast alle Ziele innerhalb der|verfügbaren Zeit ausgeschaltet.",
       
    67 	["es"] = "¡Felicidades! Has destruido todos los objectivos|dentro del tiempo establecido.",
       
    68 	["pl"] = "Gratulacje! Zniszczyłeś wszystkie cele przed upłynięciem czasu.",
       
    69 	["pt_PT"] = "Parabéns! Eliminaste todos os alvos|dentro do tempo limite.",
       
    70 	["pt_BR"] = "Parabéns! Você eliminou todos os alvos|dentro do tempo limite.",
       
    71 	["sv"] = "Grattis! Du har förstört alla målen inom den|tillåtna tidsramen.",
       
    72 	["sk"] = "Gratulujem! Zneškodnili ste všetky ciele|v stanovenom čase."
       
    73 	}
       
    74 
       
    75 local teamname = {
       
    76 	["en"] = "Shotgun Team",
       
    77 	["de"] = "Die Knalltüten",
       
    78 	["es"] = "Escopeteros",
       
    79 	["pl"] = "Shotgun Team",
       
    80 	["pt_PT"] = "Caçadores",
       
    81 	["pt_PT"] = "Carabineiros",
       
    82 	["sv"] = "Hagelgevärslaget",
       
    83 	["sk"] = "Shotgun tím"
       
    84 	}
       
    85 
       
    86 local hogname = {
       
    87 	["en"] = "Hunter",
       
    88 	["de"] = "Jäger",
       
    89 	["es"] = "Cazador",
       
    90 	["pl"] = "Strzelec",
       
    91 	["pt_PT"] = "Comando",
       
    92 	["pt_BR"] = "Caçador",
       
    93 	["sv"] = "Jägare",
       
    94 	["sk"] = "Lovec"
       
    95 	}
       
    96 
       
    97 -- To handle missing texts we define a small wrapper function that
       
    98 -- we'll use to retrieve text.
       
    99 local function loc(text)
       
   100 	if text == nil then return "**missing**"
       
   101 	elseif text[L] == nil then return text["en"]
       
   102 	else return text[L]
       
   103 	end
       
   104 end
       
   105 
       
   106 ---------------------------------------------------------------
       
   107 
    17 
   108 -- This variable will hold the number of destroyed targets.
    18 -- This variable will hold the number of destroyed targets.
   109 local score = 0
    19 local score = 0
   110 -- This variable represents the number of targets to destroy.
    20 -- This variable represents the number of targets to destroy.
   111 local score_goal = 5
    21 local score_goal = 5
   169 	Map = "Mushrooms"
    79 	Map = "Mushrooms"
   170 	-- The theme to be used
    80 	-- The theme to be used
   171 	Theme = "Nature"
    81 	Theme = "Nature"
   172 
    82 
   173 	-- Create the player team
    83 	-- Create the player team
   174 	AddTeam(loc(teamname), 14483456, "Simple", "Island", "Default")
    84 	AddTeam(loc("Shotgun Team"), 14483456, "Simple", "Island", "Default")
   175 	-- And add a hog to it
    85 	-- And add a hog to it
   176 	player = AddHog(loc(hogname), 0, 1, "NoHat")
    86 	player = AddHog(loc("Hunter"), 0, 1, "NoHat")
   177 	SetGearPosition(player, 2334, 1254)
    87 	SetGearPosition(player, 2334, 1254)
   178 end
    88 end
   179 
    89 
   180 -- This function is called when the round starts
    90 -- This function is called when the round starts
   181 -- it spawns the first target that has to be destroyed.
    91 -- it spawns the first target that has to be destroyed.
   188 	-- Parameters are: caption, sub caption, description,
    98 	-- Parameters are: caption, sub caption, description,
   189 	-- extra text, icon and time to show.
    99 	-- extra text, icon and time to show.
   190 	-- A negative icon parameter (-n) represents the n-th weapon icon
   100 	-- A negative icon parameter (-n) represents the n-th weapon icon
   191 	-- A positive icon paramter (n) represents the (n+1)-th mission icon
   101 	-- 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.
   102 	-- A timeframe of 0 is replaced with the default time to show.
   193 	ShowMission(loc(caption), loc(subcaption), loc(goal), -amShotgun, 0)
   103 	ShowMission(loc("Shotgun Training"), loc("Aiming Practice"), loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission."), -amShotgun, 0)
   194 end
   104 end
   195 
   105 
   196 -- This function is called every game tick.
   106 -- This function is called every game tick.
   197 -- Note that there are 1000 ticks within one second.
   107 -- Note that there are 1000 ticks within one second.
   198 -- You shouldn't try to calculate too complicated
   108 -- You shouldn't try to calculate too complicated
   202 	-- We actually check the time to be "1 ms" as it
   112 	-- We actually check the time to be "1 ms" as it
   203 	-- will be at "0 ms" right at the start of the game.
   113 	-- will be at "0 ms" right at the start of the game.
   204 	if TurnTimeLeft == 1 and score < score_goal then
   114 	if TurnTimeLeft == 1 and score < score_goal then
   205 		game_lost = true
   115 		game_lost = true
   206 		-- ... and show a short message.
   116 		-- ... and show a short message.
   207 		ShowMission(loc(caption), loc(subcaption), loc(timeout), -amSkip, 0)
   117 		ShowMission(loc("Shotgun Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
   208 		-- How about killing our poor hog due to his poor performance?
   118 		-- How about killing our poor hog due to his poor performance?
   209 		SetHealth(player, 0)
   119 		SetHealth(player, 0)
   210 		-- Just to be sure set the goal time to 1 ms
   120 		-- Just to be sure set the goal time to 1 ms
   211 		time_goal = 1
   121 		time_goal = 1
   212 	end
   122 	end
   251 			-- ... spawn another target.
   161 			-- ... spawn another target.
   252 			spawnTarget()
   162 			spawnTarget()
   253 		else
   163 		else
   254 			if not game_lost then
   164 			if not game_lost then
   255 			-- Otherwise show that the goal was accomplished
   165 			-- Otherwise show that the goal was accomplished
   256 			ShowMission(loc(caption), loc(subcaption), loc(success), 0, 0)
   166 			ShowMission(loc("Shotgun Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0)
   257 			-- Also let the hogs shout "victory!"
   167 			-- Also let the hogs shout "victory!"
   258 			PlaySound(sndVictory)
   168 			PlaySound(sndVictory)
   259 			-- Save the time left so we may keep it.
   169 			-- Save the time left so we may keep it.
   260 			time_goal = TurnTimeLeft
   170 			time_goal = TurnTimeLeft
   261 			end
   171 			end