Merge henek's changes
authornemo
Tue, 21 Dec 2010 15:12:06 -0500 (2010-12-21)
changeset 4596 3bf748d3bec7
parent 4589 98890a2d4cd7 (current diff)
parent 4594 5645462cc78f (diff)
child 4598 7cb8c9db6e8d
Merge henek's changes
share/hedgewars/Data/Missions/Campaign/01#Boot Camp.lua
share/hedgewars/Data/Missions/Training/SniperRifle.lua
share/hedgewars/Data/Music/main theme.ogg
--- a/QTfrontend/SDLs.cpp	Tue Dec 21 14:57:33 2010 -0500
+++ b/QTfrontend/SDLs.cpp	Tue Dec 21 15:12:06 2010 -0500
@@ -166,7 +166,7 @@
     SDLMusicInit();
 
     if (music == NULL) {
-        music = Mix_LoadMUS((datadir->absolutePath() + "/Music/main theme.ogg").toLocal8Bit().constData());
+        music = Mix_LoadMUS((datadir->absolutePath() + "/Music/main_theme.ogg").toLocal8Bit().constData());
 
     }
     Mix_VolumeMusic(MIX_MAX_VOLUME - 28);
--- a/QTfrontend/hwform.cpp	Tue Dec 21 14:57:33 2010 -0500
+++ b/QTfrontend/hwform.cpp	Tue Dec 21 15:12:06 2010 -0500
@@ -86,7 +86,7 @@
 
     ui.setupUi(this);
     setMinimumSize(760, 580);
-    setFocusPolicy(Qt::StrongFocus);
+    //setFocusPolicy(Qt::StrongFocus);
     CustomizePalettes();
 
     ui.pageOptions->CBResolution->addItems(sdli.getResolutions());
@@ -308,11 +308,13 @@
   }
 }
 
+/*
 void HWForm::keyReleaseEvent(QKeyEvent *event)
 {
-  if (event->key() == Qt::Key_Escape /*|| event->key() == Qt::Key_Backspace*/ ) 
+  if (event->key() == Qt::Key_Escape) 
     this->GoBack();
 }
+*/
 
 void HWForm::CustomizePalettes()
 {
@@ -1170,7 +1172,7 @@
     QStringList entries = tmpdir.entryList(QStringList("*#*.lua"));
     //entries.sort();
     for(int i = 0; (i < entries.count()) && (i <= team.CampaignProgress); i++)
-        ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2"), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1"));
+        ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1"));
 }
 
 void HWForm::AssociateFiles()
--- a/QTfrontend/hwform.h	Tue Dec 21 14:57:33 2010 -0500
+++ b/QTfrontend/hwform.h	Tue Dec 21 15:12:06 2010 -0500
@@ -122,7 +122,7 @@
     void closeEvent(QCloseEvent *event);
     void CustomizePalettes();
     void resizeEvent(QResizeEvent * event);
-    void keyReleaseEvent(QKeyEvent *event);
+    //void keyReleaseEvent(QKeyEvent *event);
     
     enum PageIDs {
         ID_PAGE_SETUP_TEAM      =  0,
--- a/QTfrontend/pages.cpp	Tue Dec 21 14:57:33 2010 -0500
+++ b/QTfrontend/pages.cpp	Tue Dec 21 15:12:06 2010 -0500
@@ -1063,7 +1063,10 @@
     tmpdir.setFilter(QDir::Files);
     CBSelect->addItems(tmpdir.entryList(QStringList("*.lua")).replaceInStrings(QRegExp("^(.*)\\.lua"), "\\1"));
     for(int i = 0; i < CBSelect->count(); i++)
+    {
         CBSelect->setItemData(i, CBSelect->itemText(i));
+        CBSelect->setItemText(i, CBSelect->itemText(i).replace("_", " "));
+    }
 
     pageLayout->addWidget(CBSelect, 1, 1);
     
--- a/QTfrontend/pages.h	Tue Dec 21 14:57:33 2010 -0500
+++ b/QTfrontend/pages.h	Tue Dec 21 15:12:06 2010 -0500
@@ -74,7 +74,7 @@
     Q_UNUSED(parent);
 
     font14 = new QFont("MS Shell Dlg", 14);
-    setFocusPolicy(Qt::StrongFocus);
+    //setFocusPolicy(Qt::StrongFocus);
   }
   virtual ~AbstractPage() {};
 
--- a/hedgewars/uScript.pas	Tue Dec 21 14:57:33 2010 -0500
+++ b/hedgewars/uScript.pas	Tue Dec 21 15:12:06 2010 -0500
@@ -1082,6 +1082,18 @@
         lua_pushstring(L, str2pchar(Pathz[ptData]));
     lc_getdatapath:= 1
 end;
+
+function lc_maphasborder(L : Plua_State) : LongInt; Cdecl;
+begin
+    if lua_gettop(L) <> 0 then
+        begin
+        LuaError('Lua: Wrong number of parameters passed to MapHasBorder!');
+        lua_pushnil(L);
+        end
+    else
+        lua_pushboolean(L, hasBorder);
+    lc_maphasborder:= 1
+end;
 ///////////////////
 
 procedure ScriptPrintStack;
@@ -1492,6 +1504,7 @@
 lua_register(luaState, 'GetRandom', @lc_getrandom);
 lua_register(luaState, 'SetWind', @lc_setwind);
 lua_register(luaState, 'GetDataPath', @lc_getdatapath);
+lua_register(luaState, 'MapHasBorder', @lc_maphasborder);
 
 
 ScriptClearStack; // just to be sure stack is empty
--- a/share/hedgewars/Data/Missions/Campaign/01#Boot Camp.lua	Tue Dec 21 14:57:33 2010 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,357 +0,0 @@
--- IMPORTANT -- THIS IS WORK IN PROGRESS AND VERY LIKELY TO BE CHANGED AGAIN
--- IMPORTANT -- DO NOT TRANSLATE THIS AS IT USES THE OLD SYSTEM AND WILL BE UPDATED LATER!
-
-local teamnames = {}
-local hognames = {}
-teamnames[0] = {
-	["en"] = "Bloody Rookies",
-	["de"] = "Blutige Anfänger",
-	["pl"] = "Żótodzioby",
-	["sv"] = "Blodiga nybörjare",
-	["es"] = "Reclutas",
-	["pt_PT"] = "Recrutas",
-	["pt_BR"] = "Maldito Recrutas",
-	["sk"] = "Regruti"
-}
-
-teamnames[1] = {
-	["en"] = "Instructors",
-	["de"] = "Ausbilder",
-	["pl"] = "Instruktor",
-	["sv"] = "Instruktör",
-	["es"] = "Instructores",
-	["pt_PT"] = "Instrutores",
-	["pt_BR"] = "Instrutores",
-	["sk"] = "Inštruktori"
-}
-
-hognames[0] = {
-	["en"] = "Joker",
-	["de"] = "Joker",
-	["pl"] = "Joker",
-	["sv"] = "Joker",
-	["es"] = "Joker",
-	["pt_PT"] = "Joker",
-	["pt_BR"] = "Comediante",
-	["sk"] = "Komediant"
-}
-
-hognames[1] = {
-	["en"] = "Harthog",
-	["de"] = "Harthog",
-	["pl"] = "Harthog",
-	["sv"] = "Harthog",
-	["es"] = "Harthog",
-	["pt_PT"] = "Harthog",
-	["pt_BR"] = "Harthog",
-	["sk"] = "Harthog"
-}
-
-local caption = {
-	["en"] = "Boot Camp",
-	["de"] = "Grundausbildung",
-	["pl"] = "Poligon",
-	["sv"] = "Grundutbildning",
-	["es"] = "Campamento militar",
-	["pt_PT"] = "Acampamento militar",
-	["pt_BR"] = "Acampamento Militar",
-	["sk"] = "Výcvikový tábor"
-
-}
-
-local subcaption = {
-	["en"] = "Follow the instructions!",
-	["de"] = "Befolge die Anweisungen!",
-	["pl"] = "Wykonuj polecenia!",
-	["sv"] = "Följ instruktioner!",
-	["es"] = "¡Sigue las órdenes!",
-	["pt_PT"] = "Segue as instruções!",
-	["pt_BR"] = "Siga as ordens!",
-	["sk"] = "Postupujte podľa inštrukcií!"
-}
-
-local goals = {}
-
-goals[0] = {
-	["en"] = "Listen to your Drill Instructor and follow his lead!",
-	["de"] = "Höre deinem Ausbilder zu und befolge seine Anweisungen!",
-	["pl"] = "Słuchaj instruktora i wykonuj jego rozkazy!",
-	["sv"] = "Lyssna på din instruktör och gör som han säger!",
-	["es"] = "¡Escucha atentamente a tu instructor de maniobras y sigue sus órdenes!",
-	["pt_PT"] = "Ouve atentamente o teu Instrutor e segue as suas ordens!",
-	["pt_BR"] = "Escute seu instrutor de escavação e siga seu líder",
-	["sk"] = "Počúvajte vášho inštruktora výcviku a vykonávajte jeho rozkazy!"
-}
-
-goals[1] = {
-	["en"] = "Destroy the target to finish this mission!",
-	["de"] = "Zerstöre das Ziel, um diese Mission abzuschließen!",
-	["pl"] = "Zniszcz cel by ukończyć misję!",
-	["sv"] = "Förstör målet för att avklara uppdraget!",
-	["es"] = "¡Destruye el objetivo para completar esta misión!",
-	["pt_PT"] = "Destrói o alvo para completar esta missão!",
-	["pt_BR"] = "Destrua o alvo para concluir a missão",
-	["sk"] = "Pre ukončenie misie zneškodnite cieľ!"
-}
-
-goals[2] = {
-	["en"] = "Excellent! You've passed the Boot Camp!",
-	["de"] = "Ausgezeichnet! Du hast das Ausbildungslager bestanden!",
-	["pl"] = "Doskonale! Wyszedłeś cało z poligonu!",
-	["sv"] = "Brilliant! Du har klarat av grundutbildningen!",
-	["es"] = "¡Excelente! ¡Has completado la maniobra de hoy!",
-	["pt_PT"] = "Excelente! Completaste o treino para recrutas!",
-	["pt_BR"] = "Excelente! Você completou a manobra",
-	["pt_BR"] = "Výborne! Prešli ste výcvikovým táborom!"
-}
-
-local failed = {
-	["en"] = "You failed! Follow the instructions and shoot the target only!",
-	["de"] = "Du hast versagt! Befolge die Anweisungen und schieß nur auf das Ziel!",
-	["pl"] = "Przegrałeś! Wykonuj instrukcje poprawnie i strzelaj tylko w podane cele!",
-	["sv"] = "Du har misslyckats! Följ instruktionerna och sjut endast på målen!",
-	["es"] = "¡Has fallado! ¡Sigue las instrucciones y destruye únicamente el objetivo!",
-	["pt_PT"] = "Falhaste! Segue as instruções e destrói apenas o alvo!",
-	["pt_BR"] = "Você falhou! Siga as instruções e atire somente no alvo",
-	["sk"] = "Prehrali ste! Nasledujte inštrukcie a strieľajte iba na cieľ!"
-}
-
-local drill = {}
-
-drill[0] = {
-	["en"] = "Allright, maggot!",
-	["de"] = "Also gut, du Made!",
-	["pl"] = "Słuchaj mnie gnido!",
-	["sv"] = "Dåså, din mask!",
-	["es"] = "¡Muy bien, escoria!",
-	["pt_PT"] = "Bom trabalho verme!",
-	["pt_BR"] = "Parabéns escória",
-	["sk"] = "Počúvaj, ty červík!"
-}
-
-drill[1] = {
-	["en"] = "Show that you aren't that useless.",
-	["de"] = "Zeig, dass du nicht so nutzlos bist.",
-	["pl"] = "Udowodnij, że nie jesteś bezwartościowy.",
-	["sv"] = "Visa att du inte är så värdelös!",
-	["es"] = "Demuéstrame que no eres tan inútil como pareces.",
-	["pt_PT"] = "Prova-me que não és tão inútil como pareces.",
-	["pt_BR"] = "Mostre que você não é um inútil.",
-	["sk"] = "Dokáž, že nie si na svete úplne zbytočným."
-}
-
-drill[2] = {
-	["en"] = "Use [left] to move to the left!",
-	["de"] = "Benutze [Links], um nach links zu gehen!",
-	["pl"] = "Użyj [lewo] by poruszyć się w lewą stronę!",
-	["sv"] = "Använd [vänster] för att gå åt vänster!",
-	["es"] = "¡Aprieta [izquierda] para desplazarte a la izquierda!",
-	["pt_PT"] = "Carrega [esquerda] para te moveres para a esquerda!",
-	["pt_BR"] = "Use [esquerda] para mover para a esquerda",
-	["sk"] = "Stlačte [vľavo] pre pohyb doľava"
-}
-
-drill[3] = {
-	["en"] = "Good! Now use [right] to come back!",
-	["de"] = "Gut! Nun komm mit [Rechts] zurück!",
-	["pl"] = "Dobzre, Teraz użyj [prawo] by wrócić!",
-	["sv"] = "Bra! Använd nu [höger] för att gå tillbaka!",
-	["es"] = "¡Muy bien! ¡Ahora presiona [derecha] para volver!",
-	["pt_PT"] = "Muito bem! Agora pressiona [direita] para voltar!",
-	["pt_BR"] = "Bom! Agora use [direita] para voltar",
-	["sk"] = "Dobre! Teraz použite [vpravo] a vráťte sa naspäť!"
-}
-
-drill[4] = {
-	["en"] = "Excellent!",
-	["de"] = "Ausgezeichnet!",
-	["pl"] = "Wspaniale!",
-	["sv"] = "Utmärkt!",
-	["es"] = "¡Excelente!",
-	["pt_PT"] = "Excelente!",
-	["pt_BR"] = "Excelente!",
-	["sk"] = "Výborne!"
-}
-
-drill[5] = {
-	["en"] = "Now jump to the left using [return]!",
-	["de"] = "Jetzt springe mit [Eingabetaste] nach links!",
-	["pl"] = "Teraz skocz w lewo używając [Enter]",
-	["sv"] = "Hoppa nu åt vänster med hjälp av [enter]!",
-	["es"] = "¡Ahora salta hacia la izquierda usando [intro]!",
-	["pt_PT"] = "Agora salta para a esquerda pressionando [retrocesso]!",
-	["pt_BR"] = "Agora pule para a esquerda usando [return]!",
-	["sk"] = "Teraz skočte doľava stlačením [enter]!"
-}
-
-drill[6] = {
-	["en"] = "Use [up] and [down] to aim.",
-	["de"] = "Benutze [Hoch] und [Runter], um zu zielen.",
-	["pl"] = "Użyj klawiszy [góra] i [dół] by celować.",
-	["sv"] = "Använd [upp] och [ner] för att sikta!",
-	["es"] = "Presiora [arriba] y [abajo] para apuntar.",
-	["pt_PT"] = "Pressiona [cima] e [baixo] para apontar.",
-	["pt_BR"] = "Pressione [acima] e [abaixo] para mirar.",
-	["sk"] = "Stlačte [hore] a [dole] pre mierenie."
-}
-
-drill[7] = {
-	["en"] = "Hold [space] to power up your shot and then release it to shoot.",
-	["de"] = "Halte [Leertaste], um deinen Schuss aufzuladen, und lasse dann rechtzeitig los.",
-	["pl"] = "Przytrzymaj spację by zwiększyć siłę strzału.",
-	["sv"] = "Håll ner [mellanslag] för att få kraft och släpp för att skjuta!",
-	["es"] = "Mantén presionada la [barra espaciadora] para controlar la fuerza del disparo y suéltala para disparar.",
-	["pt_PT"] = "Mantem a [barra de espaços] pressionada para controlar a força do tiro e larga-a para disparar.",
-	["pt_BR"] = "Mantenha pressionado [espaço] para aumentar a força do seu tiro e solte para atirar",
-	["sk"] = "Držte stlačený [medzerník] pre nabíjanie, jeho uvoľnením vystrelíte."
-}
-
-drill[8] = {
-	["en"] = "Destroy the target to finish your basic training!",
-	["de"] = "Zerstöre das Ziel, um deine Grundausbildung abzuschließen!",
-	["pl"] = "Zniszcz cel by by ukończyć trening podstawowy!",
-	["sv"] = "Förstör målet för att avsluta din grundutbildning!",
-	["es"] = "¡Destruye el objetivo para completar el entrenamiento básico!",
-	["pt_PT"] = "Destrói o alvo para completar o treino básico!",
-	["pt_BR"] = "Destrua o alvo para terminar o treino básico",
-	["sk"] = "Zneškodnite cieľ na ukončenie základného výcviku!"
-}
-
-local function loc(text)
-	if text == nil then return "**missing**"
-	elseif text[L] == nil then return text["en"]
-	else return text[L]
-	end
-end
-
-local player = nil
-local instructor = nil
-local target = nil
-
-function onGameStart()
-
-end
-
-local player_start_x = 2300
-local player_start_y = 1250
-local target_x = 1900
-local target_y = 1250
-local player_health = 100
-local instructor_health = 100
-local teamcolor = 14483456
-
-local progress = 0
-local time_start = 0
-
-function onGameTick()
-	if progress == -1 and (time_start + 2500) == GameTime then
-		EndGame()
-	elseif progress == -1 then
-		
-	elseif progress > 0 and ((TurnTimeLeft == 0) or (GetHealth(player) ~= player_health) or (GetHealth(instructor) ~= instructor_health)) then
-		progress = -1
-		ShowMission(loc(caption), loc(subcaption), loc(failed), -amBazooka, 0)
-		time_start = GameTime
-		PlaySound(sndNooo)
-		TurnTimeLeft = 0
-	elseif GameTime == 0 then
-		ShowMission(loc(caption), loc(subcaption), loc(goals[0]), -amBazooka, 0)
-		TurnTimeLeft = 60000
-	elseif GameTime == 2500 then
-		FollowGear(instructor)
-		HogSay(instructor, loc(drill[0]), SAY_SAY)
-	elseif GameTime == 5000 then
-		FollowGear(instructor)
-		HogSay(instructor, loc(drill[1]), SAY_SAY)
-	elseif GameTime == 7500 then
-		FollowGear(instructor)
-		HogSay(instructor, loc(drill[2]), SAY_SHOUT)
-		progress = 1
-		TurnTimeLeft = 10000
-	elseif progress == 1 then
-		local x, y = GetGearPosition(player)
-		if x < player_start_x - 50 then
-			progress = 2
-			FollowGear(instructor)
-			HogSay(instructor, loc(drill[3]), SAY_SHOUT)
-			TurnTimeLeft = 10000
-		end
-	elseif progress == 2 then
-		local x, y = GetGearPosition(player)
-		if x > player_start_x then
-			progress = 3
-			FollowGear(instructor)
-			HogSay(instructor, loc(drill[4]), SAY_SAY)
-			time_start = GameTime
-		end
-	elseif progress == 3 and (time_start + 2500 == GameTime) then
-		progress = 4
-		FollowGear(instructor)
-		HogSay(instructor, loc(drill[5]), SAY_SHOUT)
-		HogTurnLeft(player, true)
-		TurnTimeLeft = 10000
-	elseif progress == 4 then
-		local x, y = GetGearPosition(player)
-		if y < player_start_y then
-			progress = 5
-			FollowGear(instructor)
-			HogSay(instructor, "Yeah!", SAY_SAY)
-			time_start = GameTime
-			TurnTimeLeft = 30000
-		end
-	elseif progress == 5 and (time_start + 2500 == GameTime) then
-		FollowGear(instructor)
-		HogSay(instructor, loc(drill[6]), SAY_SAY)
-	elseif progress == 5 and (time_start + 5000 == GameTime) then
-		FollowGear(instructor)
-		HogSay(instructor, loc(drill[7]), SAY_SAY)
-	elseif progress == 5 and (time_start + 7500 == GameTime) then
-		FollowGear(instructor)
-		HogSay(instructor, loc(drill[8]), SAY_SHOUT)
-		ShowMission(loc(caption), loc(subcaption), loc(goals[1]), 1, 0)
-		target = AddGear(target_x, target_y, gtTarget, 0, 0, 0, 0)
-		TurnTimeLeft = 60000
-	elseif progress == 5 and (time_start + 10000 == GameTime) then
-		FollowGear(target)
-	elseif progress == 6 then
-		progress = 7
-		ShowMission(loc(caption), loc(subcaption), loc(goals[2]), 0, 0)
-		PlaySound(sndVictory)
-		time_start = GameTime
-	elseif progress == 7 and (time_start + 2500 == GameTime) then
-		EndGame()
-	end
-end
-
-function onGameInit()
-	Seed = 0
-	GameFlags = gfMultiWeapon + gfOneClanMode
-	TurnTime = 25000
-	CaseFreq = 0
-	MinesNum = 0
-	Explosives = 0
-	Delay = 2500
-	Map = "Mushrooms"
-	Theme = "Nature"
-	
-	AddTeam(loc(teamnames[0]), teamcolor, "Simple", "Island", "Default")
-	player = AddHog(loc(hognames[0]), 0, player_health, "NoHat")
-	SetGearPosition(player, player_start_x, player_start_y)
-	
-	AddTeam(loc(teamnames[1]), teamcolor + 1, "Simple", "Island", "Default")
-	instructor = AddHog(loc(hognames[1]), 0, instructor_health, "NoHat")
-	SetGearPosition(instructor, player_start_x + 100, player_start_y)
-	HogTurnLeft(instructor, true)
-
-	FollowGear(player)
-end
-
-function onAmmoStoreInit()
-	SetAmmo(amBazooka, 9, 0, 0, 0)
-end
-
-function onGearDelete(gear)
-	if GetGearType(gear) == gtTarget then
-		progress = 6
-	end
-end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Missions/Campaign/01#Boot_Camp.lua	Tue Dec 21 15:12:06 2010 -0500
@@ -0,0 +1,357 @@
+-- IMPORTANT -- THIS IS WORK IN PROGRESS AND VERY LIKELY TO BE CHANGED AGAIN
+-- IMPORTANT -- DO NOT TRANSLATE THIS AS IT USES THE OLD SYSTEM AND WILL BE UPDATED LATER!
+
+local teamnames = {}
+local hognames = {}
+teamnames[0] = {
+	["en"] = "Bloody Rookies",
+	["de"] = "Blutige Anfänger",
+	["pl"] = "Żótodzioby",
+	["sv"] = "Blodiga nybörjare",
+	["es"] = "Reclutas",
+	["pt_PT"] = "Recrutas",
+	["pt_BR"] = "Maldito Recrutas",
+	["sk"] = "Regruti"
+}
+
+teamnames[1] = {
+	["en"] = "Instructors",
+	["de"] = "Ausbilder",
+	["pl"] = "Instruktor",
+	["sv"] = "Instruktör",
+	["es"] = "Instructores",
+	["pt_PT"] = "Instrutores",
+	["pt_BR"] = "Instrutores",
+	["sk"] = "Inštruktori"
+}
+
+hognames[0] = {
+	["en"] = "Joker",
+	["de"] = "Joker",
+	["pl"] = "Joker",
+	["sv"] = "Joker",
+	["es"] = "Joker",
+	["pt_PT"] = "Joker",
+	["pt_BR"] = "Comediante",
+	["sk"] = "Komediant"
+}
+
+hognames[1] = {
+	["en"] = "Harthog",
+	["de"] = "Harthog",
+	["pl"] = "Harthog",
+	["sv"] = "Harthog",
+	["es"] = "Harthog",
+	["pt_PT"] = "Harthog",
+	["pt_BR"] = "Harthog",
+	["sk"] = "Harthog"
+}
+
+local caption = {
+	["en"] = "Boot Camp",
+	["de"] = "Grundausbildung",
+	["pl"] = "Poligon",
+	["sv"] = "Grundutbildning",
+	["es"] = "Campamento militar",
+	["pt_PT"] = "Acampamento militar",
+	["pt_BR"] = "Acampamento Militar",
+	["sk"] = "Výcvikový tábor"
+
+}
+
+local subcaption = {
+	["en"] = "Follow the instructions!",
+	["de"] = "Befolge die Anweisungen!",
+	["pl"] = "Wykonuj polecenia!",
+	["sv"] = "Följ instruktioner!",
+	["es"] = "¡Sigue las órdenes!",
+	["pt_PT"] = "Segue as instruções!",
+	["pt_BR"] = "Siga as ordens!",
+	["sk"] = "Postupujte podľa inštrukcií!"
+}
+
+local goals = {}
+
+goals[0] = {
+	["en"] = "Listen to your Drill Instructor and follow his lead!",
+	["de"] = "Höre deinem Ausbilder zu und befolge seine Anweisungen!",
+	["pl"] = "Słuchaj instruktora i wykonuj jego rozkazy!",
+	["sv"] = "Lyssna på din instruktör och gör som han säger!",
+	["es"] = "¡Escucha atentamente a tu instructor de maniobras y sigue sus órdenes!",
+	["pt_PT"] = "Ouve atentamente o teu Instrutor e segue as suas ordens!",
+	["pt_BR"] = "Escute seu instrutor de escavação e siga seu líder",
+	["sk"] = "Počúvajte vášho inštruktora výcviku a vykonávajte jeho rozkazy!"
+}
+
+goals[1] = {
+	["en"] = "Destroy the target to finish this mission!",
+	["de"] = "Zerstöre das Ziel, um diese Mission abzuschließen!",
+	["pl"] = "Zniszcz cel by ukończyć misję!",
+	["sv"] = "Förstör målet för att avklara uppdraget!",
+	["es"] = "¡Destruye el objetivo para completar esta misión!",
+	["pt_PT"] = "Destrói o alvo para completar esta missão!",
+	["pt_BR"] = "Destrua o alvo para concluir a missão",
+	["sk"] = "Pre ukončenie misie zneškodnite cieľ!"
+}
+
+goals[2] = {
+	["en"] = "Excellent! You've passed the Boot Camp!",
+	["de"] = "Ausgezeichnet! Du hast das Ausbildungslager bestanden!",
+	["pl"] = "Doskonale! Wyszedłeś cało z poligonu!",
+	["sv"] = "Brilliant! Du har klarat av grundutbildningen!",
+	["es"] = "¡Excelente! ¡Has completado la maniobra de hoy!",
+	["pt_PT"] = "Excelente! Completaste o treino para recrutas!",
+	["pt_BR"] = "Excelente! Você completou a manobra",
+	["pt_BR"] = "Výborne! Prešli ste výcvikovým táborom!"
+}
+
+local failed = {
+	["en"] = "You failed! Follow the instructions and shoot the target only!",
+	["de"] = "Du hast versagt! Befolge die Anweisungen und schieß nur auf das Ziel!",
+	["pl"] = "Przegrałeś! Wykonuj instrukcje poprawnie i strzelaj tylko w podane cele!",
+	["sv"] = "Du har misslyckats! Följ instruktionerna och sjut endast på målen!",
+	["es"] = "¡Has fallado! ¡Sigue las instrucciones y destruye únicamente el objetivo!",
+	["pt_PT"] = "Falhaste! Segue as instruções e destrói apenas o alvo!",
+	["pt_BR"] = "Você falhou! Siga as instruções e atire somente no alvo",
+	["sk"] = "Prehrali ste! Nasledujte inštrukcie a strieľajte iba na cieľ!"
+}
+
+local drill = {}
+
+drill[0] = {
+	["en"] = "Allright, maggot!",
+	["de"] = "Also gut, du Made!",
+	["pl"] = "Słuchaj mnie gnido!",
+	["sv"] = "Dåså, din mask!",
+	["es"] = "¡Muy bien, escoria!",
+	["pt_PT"] = "Bom trabalho verme!",
+	["pt_BR"] = "Parabéns escória",
+	["sk"] = "Počúvaj, ty červík!"
+}
+
+drill[1] = {
+	["en"] = "Show that you aren't that useless.",
+	["de"] = "Zeig, dass du nicht so nutzlos bist.",
+	["pl"] = "Udowodnij, że nie jesteś bezwartościowy.",
+	["sv"] = "Visa att du inte är så värdelös!",
+	["es"] = "Demuéstrame que no eres tan inútil como pareces.",
+	["pt_PT"] = "Prova-me que não és tão inútil como pareces.",
+	["pt_BR"] = "Mostre que você não é um inútil.",
+	["sk"] = "Dokáž, že nie si na svete úplne zbytočným."
+}
+
+drill[2] = {
+	["en"] = "Use [left] to move to the left!",
+	["de"] = "Benutze [Links], um nach links zu gehen!",
+	["pl"] = "Użyj [lewo] by poruszyć się w lewą stronę!",
+	["sv"] = "Använd [vänster] för att gå åt vänster!",
+	["es"] = "¡Aprieta [izquierda] para desplazarte a la izquierda!",
+	["pt_PT"] = "Carrega [esquerda] para te moveres para a esquerda!",
+	["pt_BR"] = "Use [esquerda] para mover para a esquerda",
+	["sk"] = "Stlačte [vľavo] pre pohyb doľava"
+}
+
+drill[3] = {
+	["en"] = "Good! Now use [right] to come back!",
+	["de"] = "Gut! Nun komm mit [Rechts] zurück!",
+	["pl"] = "Dobzre, Teraz użyj [prawo] by wrócić!",
+	["sv"] = "Bra! Använd nu [höger] för att gå tillbaka!",
+	["es"] = "¡Muy bien! ¡Ahora presiona [derecha] para volver!",
+	["pt_PT"] = "Muito bem! Agora pressiona [direita] para voltar!",
+	["pt_BR"] = "Bom! Agora use [direita] para voltar",
+	["sk"] = "Dobre! Teraz použite [vpravo] a vráťte sa naspäť!"
+}
+
+drill[4] = {
+	["en"] = "Excellent!",
+	["de"] = "Ausgezeichnet!",
+	["pl"] = "Wspaniale!",
+	["sv"] = "Utmärkt!",
+	["es"] = "¡Excelente!",
+	["pt_PT"] = "Excelente!",
+	["pt_BR"] = "Excelente!",
+	["sk"] = "Výborne!"
+}
+
+drill[5] = {
+	["en"] = "Now jump to the left using [return]!",
+	["de"] = "Jetzt springe mit [Eingabetaste] nach links!",
+	["pl"] = "Teraz skocz w lewo używając [Enter]",
+	["sv"] = "Hoppa nu åt vänster med hjälp av [enter]!",
+	["es"] = "¡Ahora salta hacia la izquierda usando [intro]!",
+	["pt_PT"] = "Agora salta para a esquerda pressionando [retrocesso]!",
+	["pt_BR"] = "Agora pule para a esquerda usando [return]!",
+	["sk"] = "Teraz skočte doľava stlačením [enter]!"
+}
+
+drill[6] = {
+	["en"] = "Use [up] and [down] to aim.",
+	["de"] = "Benutze [Hoch] und [Runter], um zu zielen.",
+	["pl"] = "Użyj klawiszy [góra] i [dół] by celować.",
+	["sv"] = "Använd [upp] och [ner] för att sikta!",
+	["es"] = "Presiora [arriba] y [abajo] para apuntar.",
+	["pt_PT"] = "Pressiona [cima] e [baixo] para apontar.",
+	["pt_BR"] = "Pressione [acima] e [abaixo] para mirar.",
+	["sk"] = "Stlačte [hore] a [dole] pre mierenie."
+}
+
+drill[7] = {
+	["en"] = "Hold [space] to power up your shot and then release it to shoot.",
+	["de"] = "Halte [Leertaste], um deinen Schuss aufzuladen, und lasse dann rechtzeitig los.",
+	["pl"] = "Przytrzymaj spację by zwiększyć siłę strzału.",
+	["sv"] = "Håll ner [mellanslag] för att få kraft och släpp för att skjuta!",
+	["es"] = "Mantén presionada la [barra espaciadora] para controlar la fuerza del disparo y suéltala para disparar.",
+	["pt_PT"] = "Mantem a [barra de espaços] pressionada para controlar a força do tiro e larga-a para disparar.",
+	["pt_BR"] = "Mantenha pressionado [espaço] para aumentar a força do seu tiro e solte para atirar",
+	["sk"] = "Držte stlačený [medzerník] pre nabíjanie, jeho uvoľnením vystrelíte."
+}
+
+drill[8] = {
+	["en"] = "Destroy the target to finish your basic training!",
+	["de"] = "Zerstöre das Ziel, um deine Grundausbildung abzuschließen!",
+	["pl"] = "Zniszcz cel by by ukończyć trening podstawowy!",
+	["sv"] = "Förstör målet för att avsluta din grundutbildning!",
+	["es"] = "¡Destruye el objetivo para completar el entrenamiento básico!",
+	["pt_PT"] = "Destrói o alvo para completar o treino básico!",
+	["pt_BR"] = "Destrua o alvo para terminar o treino básico",
+	["sk"] = "Zneškodnite cieľ na ukončenie základného výcviku!"
+}
+
+local function loc(text)
+	if text == nil then return "**missing**"
+	elseif text[L] == nil then return text["en"]
+	else return text[L]
+	end
+end
+
+local player = nil
+local instructor = nil
+local target = nil
+
+function onGameStart()
+
+end
+
+local player_start_x = 2300
+local player_start_y = 1250
+local target_x = 1900
+local target_y = 1250
+local player_health = 100
+local instructor_health = 100
+local teamcolor = 14483456
+
+local progress = 0
+local time_start = 0
+
+function onGameTick()
+	if progress == -1 and (time_start + 2500) == GameTime then
+		EndGame()
+	elseif progress == -1 then
+		
+	elseif progress > 0 and ((TurnTimeLeft == 0) or (GetHealth(player) ~= player_health) or (GetHealth(instructor) ~= instructor_health)) then
+		progress = -1
+		ShowMission(loc(caption), loc(subcaption), loc(failed), -amBazooka, 0)
+		time_start = GameTime
+		PlaySound(sndNooo)
+		TurnTimeLeft = 0
+	elseif GameTime == 0 then
+		ShowMission(loc(caption), loc(subcaption), loc(goals[0]), -amBazooka, 0)
+		TurnTimeLeft = 60000
+	elseif GameTime == 2500 then
+		FollowGear(instructor)
+		HogSay(instructor, loc(drill[0]), SAY_SAY)
+	elseif GameTime == 5000 then
+		FollowGear(instructor)
+		HogSay(instructor, loc(drill[1]), SAY_SAY)
+	elseif GameTime == 7500 then
+		FollowGear(instructor)
+		HogSay(instructor, loc(drill[2]), SAY_SHOUT)
+		progress = 1
+		TurnTimeLeft = 10000
+	elseif progress == 1 then
+		local x, y = GetGearPosition(player)
+		if x < player_start_x - 50 then
+			progress = 2
+			FollowGear(instructor)
+			HogSay(instructor, loc(drill[3]), SAY_SHOUT)
+			TurnTimeLeft = 10000
+		end
+	elseif progress == 2 then
+		local x, y = GetGearPosition(player)
+		if x > player_start_x then
+			progress = 3
+			FollowGear(instructor)
+			HogSay(instructor, loc(drill[4]), SAY_SAY)
+			time_start = GameTime
+		end
+	elseif progress == 3 and (time_start + 2500 == GameTime) then
+		progress = 4
+		FollowGear(instructor)
+		HogSay(instructor, loc(drill[5]), SAY_SHOUT)
+		HogTurnLeft(player, true)
+		TurnTimeLeft = 10000
+	elseif progress == 4 then
+		local x, y = GetGearPosition(player)
+		if y < player_start_y then
+			progress = 5
+			FollowGear(instructor)
+			HogSay(instructor, "Yeah!", SAY_SAY)
+			time_start = GameTime
+			TurnTimeLeft = 30000
+		end
+	elseif progress == 5 and (time_start + 2500 == GameTime) then
+		FollowGear(instructor)
+		HogSay(instructor, loc(drill[6]), SAY_SAY)
+	elseif progress == 5 and (time_start + 5000 == GameTime) then
+		FollowGear(instructor)
+		HogSay(instructor, loc(drill[7]), SAY_SAY)
+	elseif progress == 5 and (time_start + 7500 == GameTime) then
+		FollowGear(instructor)
+		HogSay(instructor, loc(drill[8]), SAY_SHOUT)
+		ShowMission(loc(caption), loc(subcaption), loc(goals[1]), 1, 0)
+		target = AddGear(target_x, target_y, gtTarget, 0, 0, 0, 0)
+		TurnTimeLeft = 60000
+	elseif progress == 5 and (time_start + 10000 == GameTime) then
+		FollowGear(target)
+	elseif progress == 6 then
+		progress = 7
+		ShowMission(loc(caption), loc(subcaption), loc(goals[2]), 0, 0)
+		PlaySound(sndVictory)
+		time_start = GameTime
+	elseif progress == 7 and (time_start + 2500 == GameTime) then
+		EndGame()
+	end
+end
+
+function onGameInit()
+	Seed = 0
+	GameFlags = gfMultiWeapon + gfOneClanMode
+	TurnTime = 25000
+	CaseFreq = 0
+	MinesNum = 0
+	Explosives = 0
+	Delay = 2500
+	Map = "Mushrooms"
+	Theme = "Nature"
+	
+	AddTeam(loc(teamnames[0]), teamcolor, "Simple", "Island", "Default")
+	player = AddHog(loc(hognames[0]), 0, player_health, "NoHat")
+	SetGearPosition(player, player_start_x, player_start_y)
+	
+	AddTeam(loc(teamnames[1]), teamcolor + 1, "Simple", "Island", "Default")
+	instructor = AddHog(loc(hognames[1]), 0, instructor_health, "NoHat")
+	SetGearPosition(instructor, player_start_x + 100, player_start_y)
+	HogTurnLeft(instructor, true)
+
+	FollowGear(player)
+end
+
+function onAmmoStoreInit()
+	SetAmmo(amBazooka, 9, 0, 0, 0)
+end
+
+function onGearDelete(gear)
+	if GetGearType(gear) == gtTarget then
+		progress = 6
+	end
+end
--- a/share/hedgewars/Data/Missions/Training/SniperRifle.lua	Tue Dec 21 14:57:33 2010 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,303 +0,0 @@
--- Hedgewars SniperRifle Training
--- Scripting Example
-
--- Lines such as this one are comments - they are ignored
--- by the game, no matter what kind of text is in there.
--- It's also possible to place a comment after some real
--- instruction as you see below. In short, everything
--- following "--" is ignored.
-
----------------------------------------------------------------
--- At first we implement the localization library using loadfile.
--- This allows us to localize strings without needing to think
--- about translations.
--- We can use the function loc(text) to localize a string.
-
-loadfile(GetDataPath() .. "Scripts/Locale.lua")()
-
--- This variable will hold the number of destroyed targets.
-local score = 0
--- This variable represents the number of targets to destroy.
-local score_goal = 31
--- This variable controls how many milliseconds/ticks we'd
--- like to wait before we end the round once all targets
--- have been destroyed.
-local end_timer = 5000 -- 5000 ms = 5 s
--- This variable is set to true if the game is lost (i.e.
--- time runs out).
-local game_lost = false
--- This variable will point to the hog's gear
-local player = nil
--- This variable will grab the time left at the end of the round
-local time_goal = 0
-
-local target = nil
-
-local last_hit_time = 0
--- This is a custom function to make it easier to
--- spawn more targets with just one line of code
--- You may define as many custom functions as you
--- like.
-function spawnTarget(x, y)
-	-- add a new target gear
-	target = AddGear(x, y, gtTarget, 0, 0, 0, 0)
-	-- have the camera move to the target so the player knows where it is
-	FollowGear(target)
-end
-
-function blowUp(x, y)
-	-- adds some TNT
-	gear = AddGear(x, y, gtDynamite, 0, 0, 0, 0)
-end
-
--- This function is called before the game loads its
--- resources.
--- It's one of the predefined function names that will
--- be called by the game. They give you entry points
--- where you're able to call your own code using either
--- provided instructions or custom functions.
-function onGameInit()
-	-- At first we have to overwrite/set some global variables
-	-- that define the map, the game has to load, as well as
-	-- other things such as the game rules to use, etc.
-	-- Things we don't modify here will use their default values.
-
-	-- The base number for the random number generator
-	Seed = 0
-	-- Game settings and rules
-	GameFlags = gfMultiWeapon + gfOneClanMode + gfArtillery
-	-- The time the player has to move each round (in ms)
-	TurnTime = 150000
-	-- The frequency of crate drops
-	CaseFreq = 0
-	-- The number of mines being placed
-	MinesNum = 0
-	-- The number of explosives being placed
-	Explosives = 0
-	-- The delay between each round
-	Delay = 0
-	-- The map to be played
-	Map = "Ropes"
-	-- The theme to be used
-	Theme = "City"
-
-	-- Create the player team
-	AddTeam(loc("Sniperz"), 14483456, "Simple", "Island", "Default")
-	-- And add a hog to it
-	player = AddHog(loc("Hunter"), 0, 1, "Sniper")
-	SetGearPosition(player, 602, 1465)
-end
-
--- This function is called when the round starts
--- it spawns the first target that has to be destroyed.
--- In addition it shows the scenario goal(s).
-function onGameStart()
-	-- Spawn the first target.
-	spawnTarget(860,1020)
-	
-	-- Show some nice mission goals.
-	-- Parameters are: caption, sub caption, description,
-	-- extra text, icon and time to show.
-	-- A negative icon parameter (-n) represents the n-th weapon icon
-	-- A positive icon paramter (n) represents the (n+1)-th mission icon
-	-- A timeframe of 0 is replaced with the default time to show.
-	ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission."), -amSniperRifle, 0)
-end
-
--- This function is called every game tick.
--- Note that there are 1000 ticks within one second.
--- You shouldn't try to calculate too complicated
--- code here as this might slow down your game.
-function onGameTick()
-	if game_lost then
-		return
-	end
-	-- after a target is destroyed, show hog, then target
-	if (target ~= nil) and (TurnTimeLeft + 1300 < last_hit_time) then
-		-- move camera to the target
-		FollowGear(target)
-	elseif TurnTimeLeft + 300 < last_hit_time then
-		-- move camera to the hog
-		FollowGear(player)
-	end
-	-- If time's up, set the game to be lost.
-	-- We actually check the time to be "1 ms" as it
-	-- will be at "0 ms" right at the start of the game.
-	if TurnTimeLeft == 1 and score < score_goal then
-		game_lost = true
-		-- ... and show a short message.
-		ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
-		-- How about killing our poor hog due to his poor performance?
-		SetHealth(player, 0)
-		-- Just to be sure set the goal time to 1 ms
-		time_goal = 1
-	end
-	-- If the goal is reached or we've lost ...
-	if score == score_goal or game_lost then
-		-- ... check to see if the time we'd like to
-		-- wait has passed and then ...
-		if end_timer == 0 then
-			-- ... end the game ...
-			EndGame()
-		else
-			-- ... or just lower the timer by 1.
-			end_timer = end_timer - 1
-			-- Reset the time left to stop the timer
-			TurnTimeLeft = time_goal
-		end
-	end
-end
-
--- This function is called when the game is initialized
--- to request the available ammo and probabilities
-function onAmmoStoreInit()
-	-- add an unlimited supply of shotgun ammo
-	SetAmmo(amSniperRifle, 9, 0, 0, 0)
-end
-
--- This function is called when a new gear is added.
--- We don't need it for this training, so we can
--- keep it empty.
-function onGearAdd(gear)
-end
-
--- This function is called before a gear is destroyed.
--- We use it to count the number of targets destroyed.
-function onGearDelete(gear)
-    
-	if GetGearType(gear) == gtCase then
-		game_lost = true
-		return
-	end
-	
-	if (GetGearType(gear) == gtTarget) then
-		-- remember when the target was hit for adjusting the camera
-		last_hit_time = TurnTimeLeft
-		-- Add one point to our score/counter
-		score = score + 1
-		-- If we haven't reached the goal ...
-		if score < score_goal then
-			-- ... spawn another target.
-			if score == 1 then
-				spawnTarget(1520,1350)
-			elseif score == 2 then
-				spawnTarget(1730,1040)
-			elseif score == 3 then
-				spawnTarget(2080,780)
-			elseif score == 4 then
-				blowUp(1730,1226)
-				blowUp(1440,1595)
-				blowUp(1527,1575)
-				blowUp(1614,1595)
-				blowUp(1420,1675)
-				blowUp(1527,1675)
-				blowUp(1634,1675)
-				blowUp(1440,1755)
-				blowUp(1527,1775)
-				blowUp(1614,1755)
-				spawnTarget(1527,1667)
-			elseif score == 5 then
-				spawnTarget(1527,1667)
-			elseif score == 6 then
-				spawnTarget(2175,1300)
-			elseif score == 7 then
-				spawnTarget(2250,940)
-			elseif score == 8 then
-				spawnTarget(2665,1540)
-			elseif score == 9 then
-				spawnTarget(3040,1160)
-			elseif score == 10 then
-				spawnTarget(2930,1500)
-			elseif score == 11 then
-				spawnTarget(700,720)
-			elseif score == 12 then
-				blowUp(914,1222)
-				blowUp(1050,1222)
-				blowUp(1160,1008)
-				blowUp(1160,1093)
-				blowUp(1160,1188)
-				blowUp(375,911)
-				blowUp(510,911)
-				blowUp(640,911)
-				blowUp(780,911)
-				blowUp(920,911)
-				blowUp(1060,913)
-				blowUp(1198,913)
-				spawnTarget(1200,730)
-			elseif score == 13 then
-				spawnTarget(1200,830)
-			elseif score == 14 then
-				spawnTarget(1430,450)
-			elseif score == 15 then
-				spawnTarget(796,240)
-			elseif score == 16 then
-				spawnTarget(300,10)
-			elseif score == 17 then
-				spawnTarget(2080,820)
-			elseif score == 18 then
-				blowUp(2110,920)
-				blowUp(2210,920)
-				blowUp(2200,305)
-				blowUp(2300,305)
-				blowUp(2300,400)
-				blowUp(2300,500)
-				blowUp(2300,600)
-				blowUp(2300,700)
-				blowUp(2300,800)
-				blowUp(2300,900)
-				blowUp(2401,305)
-				blowUp(2532,305)
-				blowUp(2663,305)
-				spawnTarget(2300,760)
-			elseif score == 19 then
-				spawnTarget(2300,760)
-			elseif score == 20 then
-				spawnTarget(2738,190)
-			elseif score == 21 then
-				spawnTarget(2590,-100)
-			elseif score == 22 then
-				blowUp(2790,305)
-				blowUp(2930,305)
-				blowUp(3060,305)
-				blowUp(3190,305)
-				blowUp(3310,305)
-				blowUp(3393,613)
-				blowUp(2805,370)
-				blowUp(2805,500)
-				blowUp(2805,630)
-				blowUp(2805,760)
-				blowUp(2805,890)
-				blowUp(2700,890)
-				blowUp(3258,370)
-				blowUp(3258,475)
-				blowUp(3264,575)
-				spawnTarget(3230,240)
-			elseif score == 23 then
-				spawnTarget(3230,290)
-			elseif score == 24 then
-				spawnTarget(3670,250)
-			elseif score == 25 then
-				spawnTarget(2620,-100)
-			elseif score == 26 then
-				spawnTarget(2870,300)
-			elseif score == 27 then
-				spawnTarget(3850,900)
-			elseif score == 28 then
-				spawnTarget(3780,300)
-			elseif score == 29 then
-				spawnTarget(3670,0)
-			elseif score == 30 then
-				spawnTarget(3480,1200)
-			end
-		else
-			if not game_lost then
-			-- Otherwise show that the goal was accomplished
-			ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0)
-			-- Also let the hogs shout "victory!"
-			PlaySound(sndVictory)
-			-- Save the time left so we may keep it.
-			time_goal = TurnTimeLeft
-			end
-		end
-	end
-end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Missions/Training/Sniper_Rifle.lua	Tue Dec 21 15:12:06 2010 -0500
@@ -0,0 +1,303 @@
+-- Hedgewars SniperRifle Training
+-- Scripting Example
+
+-- Lines such as this one are comments - they are ignored
+-- by the game, no matter what kind of text is in there.
+-- It's also possible to place a comment after some real
+-- instruction as you see below. In short, everything
+-- following "--" is ignored.
+
+---------------------------------------------------------------
+-- At first we implement the localization library using loadfile.
+-- This allows us to localize strings without needing to think
+-- about translations.
+-- We can use the function loc(text) to localize a string.
+
+loadfile(GetDataPath() .. "Scripts/Locale.lua")()
+
+-- This variable will hold the number of destroyed targets.
+local score = 0
+-- This variable represents the number of targets to destroy.
+local score_goal = 31
+-- This variable controls how many milliseconds/ticks we'd
+-- like to wait before we end the round once all targets
+-- have been destroyed.
+local end_timer = 5000 -- 5000 ms = 5 s
+-- This variable is set to true if the game is lost (i.e.
+-- time runs out).
+local game_lost = false
+-- This variable will point to the hog's gear
+local player = nil
+-- This variable will grab the time left at the end of the round
+local time_goal = 0
+
+local target = nil
+
+local last_hit_time = 0
+-- This is a custom function to make it easier to
+-- spawn more targets with just one line of code
+-- You may define as many custom functions as you
+-- like.
+function spawnTarget(x, y)
+	-- add a new target gear
+	target = AddGear(x, y, gtTarget, 0, 0, 0, 0)
+	-- have the camera move to the target so the player knows where it is
+	FollowGear(target)
+end
+
+function blowUp(x, y)
+	-- adds some TNT
+	gear = AddGear(x, y, gtDynamite, 0, 0, 0, 0)
+end
+
+-- This function is called before the game loads its
+-- resources.
+-- It's one of the predefined function names that will
+-- be called by the game. They give you entry points
+-- where you're able to call your own code using either
+-- provided instructions or custom functions.
+function onGameInit()
+	-- At first we have to overwrite/set some global variables
+	-- that define the map, the game has to load, as well as
+	-- other things such as the game rules to use, etc.
+	-- Things we don't modify here will use their default values.
+
+	-- The base number for the random number generator
+	Seed = 0
+	-- Game settings and rules
+	GameFlags = gfMultiWeapon + gfOneClanMode + gfArtillery
+	-- The time the player has to move each round (in ms)
+	TurnTime = 150000
+	-- The frequency of crate drops
+	CaseFreq = 0
+	-- The number of mines being placed
+	MinesNum = 0
+	-- The number of explosives being placed
+	Explosives = 0
+	-- The delay between each round
+	Delay = 0
+	-- The map to be played
+	Map = "Ropes"
+	-- The theme to be used
+	Theme = "City"
+
+	-- Create the player team
+	AddTeam(loc("Sniperz"), 14483456, "Simple", "Island", "Default")
+	-- And add a hog to it
+	player = AddHog(loc("Hunter"), 0, 1, "Sniper")
+	SetGearPosition(player, 602, 1465)
+end
+
+-- This function is called when the round starts
+-- it spawns the first target that has to be destroyed.
+-- In addition it shows the scenario goal(s).
+function onGameStart()
+	-- Spawn the first target.
+	spawnTarget(860,1020)
+	
+	-- Show some nice mission goals.
+	-- Parameters are: caption, sub caption, description,
+	-- extra text, icon and time to show.
+	-- A negative icon parameter (-n) represents the n-th weapon icon
+	-- A positive icon paramter (n) represents the (n+1)-th mission icon
+	-- A timeframe of 0 is replaced with the default time to show.
+	ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission."), -amSniperRifle, 0)
+end
+
+-- This function is called every game tick.
+-- Note that there are 1000 ticks within one second.
+-- You shouldn't try to calculate too complicated
+-- code here as this might slow down your game.
+function onGameTick()
+	if game_lost then
+		return
+	end
+	-- after a target is destroyed, show hog, then target
+	if (target ~= nil) and (TurnTimeLeft + 1300 < last_hit_time) then
+		-- move camera to the target
+		FollowGear(target)
+	elseif TurnTimeLeft + 300 < last_hit_time then
+		-- move camera to the hog
+		FollowGear(player)
+	end
+	-- If time's up, set the game to be lost.
+	-- We actually check the time to be "1 ms" as it
+	-- will be at "0 ms" right at the start of the game.
+	if TurnTimeLeft == 1 and score < score_goal then
+		game_lost = true
+		-- ... and show a short message.
+		ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
+		-- How about killing our poor hog due to his poor performance?
+		SetHealth(player, 0)
+		-- Just to be sure set the goal time to 1 ms
+		time_goal = 1
+	end
+	-- If the goal is reached or we've lost ...
+	if score == score_goal or game_lost then
+		-- ... check to see if the time we'd like to
+		-- wait has passed and then ...
+		if end_timer == 0 then
+			-- ... end the game ...
+			EndGame()
+		else
+			-- ... or just lower the timer by 1.
+			end_timer = end_timer - 1
+			-- Reset the time left to stop the timer
+			TurnTimeLeft = time_goal
+		end
+	end
+end
+
+-- This function is called when the game is initialized
+-- to request the available ammo and probabilities
+function onAmmoStoreInit()
+	-- add an unlimited supply of shotgun ammo
+	SetAmmo(amSniperRifle, 9, 0, 0, 0)
+end
+
+-- This function is called when a new gear is added.
+-- We don't need it for this training, so we can
+-- keep it empty.
+function onGearAdd(gear)
+end
+
+-- This function is called before a gear is destroyed.
+-- We use it to count the number of targets destroyed.
+function onGearDelete(gear)
+    
+	if GetGearType(gear) == gtCase then
+		game_lost = true
+		return
+	end
+	
+	if (GetGearType(gear) == gtTarget) then
+		-- remember when the target was hit for adjusting the camera
+		last_hit_time = TurnTimeLeft
+		-- Add one point to our score/counter
+		score = score + 1
+		-- If we haven't reached the goal ...
+		if score < score_goal then
+			-- ... spawn another target.
+			if score == 1 then
+				spawnTarget(1520,1350)
+			elseif score == 2 then
+				spawnTarget(1730,1040)
+			elseif score == 3 then
+				spawnTarget(2080,780)
+			elseif score == 4 then
+				blowUp(1730,1226)
+				blowUp(1440,1595)
+				blowUp(1527,1575)
+				blowUp(1614,1595)
+				blowUp(1420,1675)
+				blowUp(1527,1675)
+				blowUp(1634,1675)
+				blowUp(1440,1755)
+				blowUp(1527,1775)
+				blowUp(1614,1755)
+				spawnTarget(1527,1667)
+			elseif score == 5 then
+				spawnTarget(1527,1667)
+			elseif score == 6 then
+				spawnTarget(2175,1300)
+			elseif score == 7 then
+				spawnTarget(2250,940)
+			elseif score == 8 then
+				spawnTarget(2665,1540)
+			elseif score == 9 then
+				spawnTarget(3040,1160)
+			elseif score == 10 then
+				spawnTarget(2930,1500)
+			elseif score == 11 then
+				spawnTarget(700,720)
+			elseif score == 12 then
+				blowUp(914,1222)
+				blowUp(1050,1222)
+				blowUp(1160,1008)
+				blowUp(1160,1093)
+				blowUp(1160,1188)
+				blowUp(375,911)
+				blowUp(510,911)
+				blowUp(640,911)
+				blowUp(780,911)
+				blowUp(920,911)
+				blowUp(1060,913)
+				blowUp(1198,913)
+				spawnTarget(1200,730)
+			elseif score == 13 then
+				spawnTarget(1200,830)
+			elseif score == 14 then
+				spawnTarget(1430,450)
+			elseif score == 15 then
+				spawnTarget(796,240)
+			elseif score == 16 then
+				spawnTarget(300,10)
+			elseif score == 17 then
+				spawnTarget(2080,820)
+			elseif score == 18 then
+				blowUp(2110,920)
+				blowUp(2210,920)
+				blowUp(2200,305)
+				blowUp(2300,305)
+				blowUp(2300,400)
+				blowUp(2300,500)
+				blowUp(2300,600)
+				blowUp(2300,700)
+				blowUp(2300,800)
+				blowUp(2300,900)
+				blowUp(2401,305)
+				blowUp(2532,305)
+				blowUp(2663,305)
+				spawnTarget(2300,760)
+			elseif score == 19 then
+				spawnTarget(2300,760)
+			elseif score == 20 then
+				spawnTarget(2738,190)
+			elseif score == 21 then
+				spawnTarget(2590,-100)
+			elseif score == 22 then
+				blowUp(2790,305)
+				blowUp(2930,305)
+				blowUp(3060,305)
+				blowUp(3190,305)
+				blowUp(3310,305)
+				blowUp(3393,613)
+				blowUp(2805,370)
+				blowUp(2805,500)
+				blowUp(2805,630)
+				blowUp(2805,760)
+				blowUp(2805,890)
+				blowUp(2700,890)
+				blowUp(3258,370)
+				blowUp(3258,475)
+				blowUp(3264,575)
+				spawnTarget(3230,240)
+			elseif score == 23 then
+				spawnTarget(3230,290)
+			elseif score == 24 then
+				spawnTarget(3670,250)
+			elseif score == 25 then
+				spawnTarget(2620,-100)
+			elseif score == 26 then
+				spawnTarget(2870,300)
+			elseif score == 27 then
+				spawnTarget(3850,900)
+			elseif score == 28 then
+				spawnTarget(3780,300)
+			elseif score == 29 then
+				spawnTarget(3670,0)
+			elseif score == 30 then
+				spawnTarget(3480,1200)
+			end
+		else
+			if not game_lost then
+			-- Otherwise show that the goal was accomplished
+			ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0)
+			-- Also let the hogs shout "victory!"
+			PlaySound(sndVictory)
+			-- Save the time left so we may keep it.
+			time_goal = TurnTimeLeft
+			end
+		end
+	end
+end
Binary file share/hedgewars/Data/Music/main theme.ogg has changed
Binary file share/hedgewars/Data/Music/main_theme.ogg has changed
--- a/share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.lua	Tue Dec 21 14:57:33 2010 -0500
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Random_Weapon.lua	Tue Dec 21 15:12:06 2010 -0500
@@ -1,17 +1,29 @@
+loadfile(GetDataPath() .. "Scripts/Locale.lua")()
+
 local weapons = { amGrenade, amClusterBomb, amBazooka, amBee, amShotgun,
             amMine, amDEagle, amDynamite, amFirePunch, amWhip, amPickHammer,
-            amBaseballBat, amAirAttack, amMineStrike, amTeleport, amMortar, amCake,
-            amSeduction, amWatermelon, amHellishBomb, amNapalm, amDrill, amBallgun,
-            amRCPlane, amSniperRifle, amMolotov, amBirdy, amBlowTorch,
-            amGasBomb, amFlamethrower, amSMine, amHammer, amDrillStrike }
+            amBaseballBat, amTeleport, amMortar, amCake, amSeduction,
+            amWatermelon, amHellishBomb, amDrill, amBallgun, amRCPlane,
+            amSniperRifle, amMolotov, amBirdy, amBlowTorch, amGasBomb,
+            amFlamethrower, amSMine, amHammer, amSnowball }
 
-local lastRound = -1
-local weapon = 0
+local airweapons = { amAirAttack, amMineStrike, amNapalm, amDrillStrike }
+
 
 function onGameInit()
     GameFlags = band(bor(GameFlags, gfResetWeps), bnot(gfInfAttack + gfPerHogAmmo))
 end
 
+function onGameStart()
+    if MapHasBorder() == false then
+        for i, w in pairs(airweapons) do
+            table.insert(weapons, w)
+        end
+    end
+
+    ShowMission(loc("Random Weapons"), loc("A game of luck"), loc("There has been a mix-up with your gear and now you|have to utilize whatever is coming your way!"), -amSkip, 0)
+end
+
 function onAmmoStoreInit()
     SetAmmo(amSkip, 9, 0, 0, 0)
 
@@ -31,12 +43,12 @@
     for i, w in pairs(weapons) do
         SetAmmo(w, 0, 0, 0, 1)
     end
+
+    for i, w in pairs(airweapons) do
+        SetAmmo(w, 0, 0, 0, 1)
+    end
 end
 
 function onNewTurn()
-    if lastRound ~= TotalRounds then
-        weapon = GetRandom(table.maxn(weapons)) + 1
-        lastRound = TotalRounds
-    end
-    AddAmmo(CurrentHedgehog, weapons[weapon])
+    AddAmmo(CurrentHedgehog, weapons[GetRandom(table.maxn(weapons)) + 1])
 end