share/hedgewars/Data/Missions/Training/Bazooka Training.lua
author sheepluva
Thu, 01 Apr 2010 00:56:38 +0000
changeset 3227 ac48cbe175c8
permissions -rw-r--r--
add fixed mission script files incl. inu's translation (portuguese I believe)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3227
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
     1
-- Hedgewars Bazooka Training
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
     2
-- Scripting Example
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
     3
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
     4
-- Lines such as this one are comments - they are ignored
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
     5
-- by the game, no matter what kind of text is in there.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
     6
-- It's also possible to place a comment after some real
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
     7
-- instruction as you see below. In short, everything
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
     8
-- following "--" is ignored.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
     9
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    10
---------------------------------------------------------------
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    11
-- At first we put all text we'd like to use in some arrays.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    12
-- This way we're able to localize the text to be shown without
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    13
-- modifying other files.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    14
-- The language to be used is stored in the global variable
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    15
-- 'L' that is set by the game (string).
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    16
-- Text may then be accessed using "arrayname[L]".
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    17
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    18
local caption = {
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    19
	["en"] = "Bazooka Training",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    20
	["de"] = "Bazooka-Training",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    21
	["es"] = "Entrenamiento con bazuca",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    22
	["pl"] = "Trening bazooki",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    23
	["pt_PT"] = "Treino com Bazuca"
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    24
	-- To add other languages, just add lines similar to the
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    25
	-- existing ones - don't forget the trailing ","!
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    26
	}
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    27
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    28
local subcaption = {
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    29
	["en"] = "Aiming Practice",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    30
	["de"] = "Zielübung",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    31
	["es"] = "Practica tu puntería",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    32
	["pl"] = "Potrenuj celność",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    33
	["pt_PT"] = "Pratica a tua pontaria"
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    34
	}
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    35
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    36
local goal = {
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    37
	["en"] = "Eliminate all targets before your time runs out.|You have unlimited ammo for this mission.",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    38
	["de"] = "Eliminiere alle Ziele bevor die Zeit ausläuft.|Du hast in dieser Mission unbegrenzte Munition.",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    39
	["es"] = "Destruye todos los objetivos antes de que se agote el tiempo.|La munición en esta misión es ilimitada.",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    40
	["pl"] = "Zniszcz wszystkie cele zanim upłynie czas.|W tej misji masz nieskończoną ilość amunicji.",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    41
	["pt_PT"] = "Destrói todos os alvos antes do tempo terminar.|Tens munições infinitas para esta missão."
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    42
	}
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    43
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    44
local timeout = {
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    45
	["en"] = "Oh no! Time's up! Just try again.",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    46
	["de"] = "Oh nein! Die Zeit ist um! Versuche es nochmal.",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    47
	["es"] = "¡Oh, no, se te acabó el tiempo! ¿Por qué no lo intentas de nuevo?",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    48
	["pl"] = "Ajajaj! Koniec czasu! Spróbuj jeszcze raz.",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    49
	["pt_PT"] = "Oh não! Acabou o tempo! Tenta novamente."
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    50
	}
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    51
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    52
local success = {
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    53
	["en"] = "Congratulations! You've eliminated all targets|within the allowed time frame.",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    54
	["de"] = "Gratulation! Du hast alle Ziele innerhalb der|verfügbaren Zeit ausgeschaltet.",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    55
	["es"] = "¡Felicidades! Has destruido todos los objectivos|dentro del tiempo establecido.",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    56
	["pl"] = "Gratulacje! Zniszczyłeś przed czasem wszystkie cele.",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    57
	["pt_PT"] = "Parabéns! Eliminaste todos os alvos|dentro do tempo limite."
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    58
	}
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    59
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    60
local teamname = {
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    61
	["en"] = "'Zooka Team",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    62
	["de"] = "Die Knalltüten",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    63
	["es"] = "Bazuqueros",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    64
	["pl"] = "Bazookinierzy",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    65
	["pt_PT"] = "Bazuqueiros"
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    66
	}
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    67
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    68
local hogname = {
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    69
	["en"] = "Hunter",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    70
	["de"] = "Jäger",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    71
	["es"] = "Artillero",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    72
	["pl"] = "Strzelec",
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    73
	["pt_PT"] = "Comando"
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    74
	}
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    75
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    76
-- To handle missing texts we define a small wrapper function that
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    77
-- we'll use to retrieve text.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    78
local function loc(text)
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    79
	if text == nil then return "**missing**"
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    80
	elseif text[L] == nil then return text["en"]
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    81
	else return text[L]
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    82
	end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    83
end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    84
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    85
---------------------------------------------------------------
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    86
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    87
-- This variable will hold the number of destroyed targets.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    88
local score = 0
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    89
-- This variable represents the number of targets to destroy.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    90
local score_goal = 5
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    91
-- This variable controls how many milliseconds/ticks we'd
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    92
-- like to wait before we end the round once all targets
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    93
-- have been destroyed.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    94
local end_timer = 5000 -- 5000 ms = 5 s
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    95
-- This variable is set to true if the game is lost (i.e.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    96
-- time runs out).
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    97
local game_lost = false
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    98
-- This variable will point to the hog's gear
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
    99
local player = nil
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   100
-- This variable will grab the time left at the end of the round
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   101
local time_goal = 0
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   102
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   103
-- This is a custom function to make it easier to
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   104
-- spawn more targets with just one line of code
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   105
-- You may define as many custom functions as you
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   106
-- like.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   107
function spawnTarget()
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   108
	-- add a new target gear
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   109
	gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   110
	
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   111
	-- move it to a random position within 0 and
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   112
	-- LAND_WIDTH - the width of the map
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   113
	FindPlace(gear, true, 0, LAND_WIDTH)
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   114
	
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   115
	-- move the target to a higher vertical position
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   116
	-- to ensure it's not somewhere down below
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   117
	x, y = GetGearPosition(gear)
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   118
	SetGearPosition(gear, x, 500)
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   119
end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   120
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   121
-- This function is called before the game loads its
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   122
-- resources.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   123
-- It's one of the predefined function names that will
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   124
-- be called by the game. They give you entry points
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   125
-- where you're able to call your own code using either
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   126
-- provided instructions or custom functions.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   127
function onGameInit()
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   128
	-- At first we have to overwrite/set some global variables
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   129
	-- that define the map, the game has to load, as well as
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   130
	-- other things such as the game rules to use, etc.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   131
	-- Things we don't modify here will use their default values.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   132
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   133
	-- The base number for the random number generator
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   134
	Seed = 0
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   135
	-- Game settings and rules
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   136
	GameFlags = gfMultiWeapon + gfOneClanMode + gfSolidLand
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   137
	-- The time the player has to move each round (in ms)
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   138
	TurnTime = 60000
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   139
	-- The frequency of crate drops
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   140
	CaseFreq = 0
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   141
	-- The number of mines being placed
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   142
	LandAdds = 0
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   143
	-- The number of explosives being placed
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   144
	Explosives = 0
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   145
	-- The delay between each round
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   146
	Delay = 0
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   147
	-- The map to be played
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   148
	Map = "Bamboo"
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   149
	-- The theme to be used
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   150
	Theme = "Bamboo"
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   151
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   152
	-- Create the player team
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   153
	AddTeam(loc(teamname), 14483456, "Simple", "Island", "Default")
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   154
	-- And add a hog to it
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   155
	player = AddHog(loc(hogname), 0, 1, "NoHat")
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   156
	SetGearPosition(player, 1960, 1160);
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   157
end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   158
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   159
-- This function is called when the round starts
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   160
-- it spawns the first target that has to be destroyed.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   161
-- In addition it shows the scenario goal(s).
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   162
function onGameStart()
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   163
	-- Spawn the first target.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   164
	spawnTarget()
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   165
	
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   166
	-- Show some nice mission goals.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   167
	-- Parameters are: caption, sub caption, description,
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   168
	-- extra text, icon and time to show.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   169
	-- A negative icon parameter (-n) represents the n-th weapon icon
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   170
	-- A positive icon paramter (n) represents the (n+1)-th mission icon
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   171
	-- A timeframe of 0 is replaced with the default time to show.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   172
	ShowMission(loc(caption), loc(subcaption), loc(goal), -amBazooka, 0);
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   173
end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   174
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   175
-- This function is called every game tick.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   176
-- Note that there are 1000 ticks within one second.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   177
-- You shouldn't try to calculate too complicated
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   178
-- code here as this might slow down your game.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   179
function onGameTick()
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   180
	-- If time's up, set the game to be lost.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   181
	-- We actually check the time to be "1 ms" as it
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   182
	-- will be at "0 ms" right at the start of the game.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   183
	if TurnTimeLeft == 1 and score < score_goal then
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   184
		game_lost = true
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   185
		-- ... and show a short message.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   186
		ShowMission(loc(caption), loc(subcaption), loc(timeout), -amSkip, 0);
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   187
		-- How about killing our poor hog due to his poor performance?
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   188
		SetHealth(player, 0);
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   189
		-- Just to be sure set the goal time to 1 ms
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   190
		time_goal = 1
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   191
	end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   192
	-- If the goal is reached or we've lost ...
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   193
	if score == score_goal or game_lost then
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   194
		-- ... check to see if the time we'd like to
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   195
		-- wait has passed and then ...
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   196
		if end_timer == 0 then
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   197
			-- ... end the game ...
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   198
			EndGame()
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   199
		else
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   200
			-- ... or just lower the timer by 1.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   201
			end_timer = end_timer - 1
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   202
			-- Reset the time left to stop the timer
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   203
			TurnTimeLeft = time_goal
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   204
		end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   205
	end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   206
end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   207
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   208
-- This function is called when the game is initialized
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   209
-- to request the available ammo and probabilities
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   210
function onAmmoStoreInit()
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   211
	-- add an unlimited supply of bazooka ammo
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   212
	SetAmmo(amBazooka, 9, 0, 0)
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   213
end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   214
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   215
-- This function is called when a new gear is added.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   216
-- We don't need it for this training, so we can
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   217
-- keep it empty.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   218
function onGearAdd(gear)
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   219
end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   220
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   221
-- This function is called before a gear is destroyed.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   222
-- We use it to count the number of targets destroyed.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   223
function onGearDelete(gear)
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   224
	-- We're only interested in target gears.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   225
	if GetGearType(gear) == gtTarget then
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   226
		-- Add one point to our score/counter
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   227
		score = score + 1
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   228
		-- If we haven't reached the goal ...
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   229
		if score < score_goal then
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   230
			-- ... spawn another target.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   231
			spawnTarget()
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   232
		else
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   233
			if not game_lost then
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   234
			-- Otherwise show that the goal was accomplished
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   235
			ShowMission(loc(caption), loc(subcaption), loc(success), 0, 0);
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   236
			-- Also let the hogs shout "victory!"
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   237
			PlaySound(sndVictory)
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   238
			-- Save the time left so we may keep it.
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   239
			time_goal = TurnTimeLeft
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   240
			end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   241
		end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   242
	end
ac48cbe175c8 add fixed mission script files incl. inu's translation (portuguese I believe)
sheepluva
parents:
diff changeset
   243
end