author | Henek |
Tue, 21 Dec 2010 14:42:47 +0100 | |
changeset 4594 | 5645462cc78f |
permissions | -rw-r--r-- |
4594
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
1 |
-- Hedgewars SniperRifle Training |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
2 |
-- Scripting Example |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
3 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
4 |
-- Lines such as this one are comments - they are ignored |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
5 |
-- by the game, no matter what kind of text is in there. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
6 |
-- It's also possible to place a comment after some real |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
7 |
-- instruction as you see below. In short, everything |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
8 |
-- following "--" is ignored. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
9 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
10 |
--------------------------------------------------------------- |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
11 |
-- At first we implement the localization library using loadfile. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
12 |
-- This allows us to localize strings without needing to think |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
13 |
-- about translations. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
14 |
-- We can use the function loc(text) to localize a string. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
15 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
16 |
loadfile(GetDataPath() .. "Scripts/Locale.lua")() |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
17 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
18 |
-- This variable will hold the number of destroyed targets. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
19 |
local score = 0 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
20 |
-- This variable represents the number of targets to destroy. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
21 |
local score_goal = 31 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
22 |
-- This variable controls how many milliseconds/ticks we'd |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
23 |
-- like to wait before we end the round once all targets |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
24 |
-- have been destroyed. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
25 |
local end_timer = 5000 -- 5000 ms = 5 s |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
26 |
-- This variable is set to true if the game is lost (i.e. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
27 |
-- time runs out). |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
28 |
local game_lost = false |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
29 |
-- This variable will point to the hog's gear |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
30 |
local player = nil |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
31 |
-- This variable will grab the time left at the end of the round |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
32 |
local time_goal = 0 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
33 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
34 |
local target = nil |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
35 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
36 |
local last_hit_time = 0 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
37 |
-- This is a custom function to make it easier to |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
38 |
-- spawn more targets with just one line of code |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
39 |
-- You may define as many custom functions as you |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
40 |
-- like. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
41 |
function spawnTarget(x, y) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
42 |
-- add a new target gear |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
43 |
target = AddGear(x, y, gtTarget, 0, 0, 0, 0) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
44 |
-- have the camera move to the target so the player knows where it is |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
45 |
FollowGear(target) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
46 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
47 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
48 |
function blowUp(x, y) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
49 |
-- adds some TNT |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
50 |
gear = AddGear(x, y, gtDynamite, 0, 0, 0, 0) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
51 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
52 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
53 |
-- This function is called before the game loads its |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
54 |
-- resources. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
55 |
-- It's one of the predefined function names that will |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
56 |
-- be called by the game. They give you entry points |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
57 |
-- where you're able to call your own code using either |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
58 |
-- provided instructions or custom functions. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
59 |
function onGameInit() |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
60 |
-- At first we have to overwrite/set some global variables |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
61 |
-- that define the map, the game has to load, as well as |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
62 |
-- other things such as the game rules to use, etc. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
63 |
-- Things we don't modify here will use their default values. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
64 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
65 |
-- The base number for the random number generator |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
66 |
Seed = 0 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
67 |
-- Game settings and rules |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
68 |
GameFlags = gfMultiWeapon + gfOneClanMode + gfArtillery |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
69 |
-- The time the player has to move each round (in ms) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
70 |
TurnTime = 150000 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
71 |
-- The frequency of crate drops |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
72 |
CaseFreq = 0 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
73 |
-- The number of mines being placed |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
74 |
MinesNum = 0 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
75 |
-- The number of explosives being placed |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
76 |
Explosives = 0 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
77 |
-- The delay between each round |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
78 |
Delay = 0 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
79 |
-- The map to be played |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
80 |
Map = "Ropes" |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
81 |
-- The theme to be used |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
82 |
Theme = "City" |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
83 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
84 |
-- Create the player team |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
85 |
AddTeam(loc("Sniperz"), 14483456, "Simple", "Island", "Default") |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
86 |
-- And add a hog to it |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
87 |
player = AddHog(loc("Hunter"), 0, 1, "Sniper") |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
88 |
SetGearPosition(player, 602, 1465) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
89 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
90 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
91 |
-- This function is called when the round starts |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
92 |
-- it spawns the first target that has to be destroyed. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
93 |
-- In addition it shows the scenario goal(s). |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
94 |
function onGameStart() |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
95 |
-- Spawn the first target. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
96 |
spawnTarget(860,1020) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
97 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
98 |
-- Show some nice mission goals. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
99 |
-- Parameters are: caption, sub caption, description, |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
100 |
-- extra text, icon and time to show. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
101 |
-- A negative icon parameter (-n) represents the n-th weapon icon |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
102 |
-- A positive icon paramter (n) represents the (n+1)-th mission icon |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
103 |
-- A timeframe of 0 is replaced with the default time to show. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
104 |
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) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
105 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
106 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
107 |
-- This function is called every game tick. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
108 |
-- Note that there are 1000 ticks within one second. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
109 |
-- You shouldn't try to calculate too complicated |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
110 |
-- code here as this might slow down your game. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
111 |
function onGameTick() |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
112 |
if game_lost then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
113 |
return |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
114 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
115 |
-- after a target is destroyed, show hog, then target |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
116 |
if (target ~= nil) and (TurnTimeLeft + 1300 < last_hit_time) then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
117 |
-- move camera to the target |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
118 |
FollowGear(target) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
119 |
elseif TurnTimeLeft + 300 < last_hit_time then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
120 |
-- move camera to the hog |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
121 |
FollowGear(player) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
122 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
123 |
-- If time's up, set the game to be lost. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
124 |
-- We actually check the time to be "1 ms" as it |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
125 |
-- will be at "0 ms" right at the start of the game. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
126 |
if TurnTimeLeft == 1 and score < score_goal then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
127 |
game_lost = true |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
128 |
-- ... and show a short message. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
129 |
ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
130 |
-- How about killing our poor hog due to his poor performance? |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
131 |
SetHealth(player, 0) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
132 |
-- Just to be sure set the goal time to 1 ms |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
133 |
time_goal = 1 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
134 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
135 |
-- If the goal is reached or we've lost ... |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
136 |
if score == score_goal or game_lost then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
137 |
-- ... check to see if the time we'd like to |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
138 |
-- wait has passed and then ... |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
139 |
if end_timer == 0 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
140 |
-- ... end the game ... |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
141 |
EndGame() |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
142 |
else |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
143 |
-- ... or just lower the timer by 1. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
144 |
end_timer = end_timer - 1 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
145 |
-- Reset the time left to stop the timer |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
146 |
TurnTimeLeft = time_goal |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
147 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
148 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
149 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
150 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
151 |
-- This function is called when the game is initialized |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
152 |
-- to request the available ammo and probabilities |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
153 |
function onAmmoStoreInit() |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
154 |
-- add an unlimited supply of shotgun ammo |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
155 |
SetAmmo(amSniperRifle, 9, 0, 0, 0) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
156 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
157 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
158 |
-- This function is called when a new gear is added. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
159 |
-- We don't need it for this training, so we can |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
160 |
-- keep it empty. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
161 |
function onGearAdd(gear) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
162 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
163 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
164 |
-- This function is called before a gear is destroyed. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
165 |
-- We use it to count the number of targets destroyed. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
166 |
function onGearDelete(gear) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
167 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
168 |
if GetGearType(gear) == gtCase then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
169 |
game_lost = true |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
170 |
return |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
171 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
172 |
|
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
173 |
if (GetGearType(gear) == gtTarget) then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
174 |
-- remember when the target was hit for adjusting the camera |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
175 |
last_hit_time = TurnTimeLeft |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
176 |
-- Add one point to our score/counter |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
177 |
score = score + 1 |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
178 |
-- If we haven't reached the goal ... |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
179 |
if score < score_goal then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
180 |
-- ... spawn another target. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
181 |
if score == 1 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
182 |
spawnTarget(1520,1350) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
183 |
elseif score == 2 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
184 |
spawnTarget(1730,1040) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
185 |
elseif score == 3 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
186 |
spawnTarget(2080,780) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
187 |
elseif score == 4 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
188 |
blowUp(1730,1226) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
189 |
blowUp(1440,1595) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
190 |
blowUp(1527,1575) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
191 |
blowUp(1614,1595) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
192 |
blowUp(1420,1675) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
193 |
blowUp(1527,1675) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
194 |
blowUp(1634,1675) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
195 |
blowUp(1440,1755) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
196 |
blowUp(1527,1775) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
197 |
blowUp(1614,1755) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
198 |
spawnTarget(1527,1667) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
199 |
elseif score == 5 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
200 |
spawnTarget(1527,1667) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
201 |
elseif score == 6 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
202 |
spawnTarget(2175,1300) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
203 |
elseif score == 7 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
204 |
spawnTarget(2250,940) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
205 |
elseif score == 8 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
206 |
spawnTarget(2665,1540) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
207 |
elseif score == 9 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
208 |
spawnTarget(3040,1160) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
209 |
elseif score == 10 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
210 |
spawnTarget(2930,1500) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
211 |
elseif score == 11 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
212 |
spawnTarget(700,720) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
213 |
elseif score == 12 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
214 |
blowUp(914,1222) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
215 |
blowUp(1050,1222) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
216 |
blowUp(1160,1008) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
217 |
blowUp(1160,1093) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
218 |
blowUp(1160,1188) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
219 |
blowUp(375,911) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
220 |
blowUp(510,911) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
221 |
blowUp(640,911) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
222 |
blowUp(780,911) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
223 |
blowUp(920,911) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
224 |
blowUp(1060,913) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
225 |
blowUp(1198,913) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
226 |
spawnTarget(1200,730) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
227 |
elseif score == 13 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
228 |
spawnTarget(1200,830) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
229 |
elseif score == 14 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
230 |
spawnTarget(1430,450) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
231 |
elseif score == 15 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
232 |
spawnTarget(796,240) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
233 |
elseif score == 16 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
234 |
spawnTarget(300,10) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
235 |
elseif score == 17 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
236 |
spawnTarget(2080,820) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
237 |
elseif score == 18 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
238 |
blowUp(2110,920) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
239 |
blowUp(2210,920) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
240 |
blowUp(2200,305) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
241 |
blowUp(2300,305) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
242 |
blowUp(2300,400) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
243 |
blowUp(2300,500) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
244 |
blowUp(2300,600) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
245 |
blowUp(2300,700) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
246 |
blowUp(2300,800) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
247 |
blowUp(2300,900) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
248 |
blowUp(2401,305) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
249 |
blowUp(2532,305) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
250 |
blowUp(2663,305) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
251 |
spawnTarget(2300,760) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
252 |
elseif score == 19 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
253 |
spawnTarget(2300,760) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
254 |
elseif score == 20 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
255 |
spawnTarget(2738,190) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
256 |
elseif score == 21 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
257 |
spawnTarget(2590,-100) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
258 |
elseif score == 22 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
259 |
blowUp(2790,305) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
260 |
blowUp(2930,305) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
261 |
blowUp(3060,305) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
262 |
blowUp(3190,305) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
263 |
blowUp(3310,305) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
264 |
blowUp(3393,613) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
265 |
blowUp(2805,370) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
266 |
blowUp(2805,500) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
267 |
blowUp(2805,630) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
268 |
blowUp(2805,760) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
269 |
blowUp(2805,890) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
270 |
blowUp(2700,890) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
271 |
blowUp(3258,370) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
272 |
blowUp(3258,475) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
273 |
blowUp(3264,575) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
274 |
spawnTarget(3230,240) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
275 |
elseif score == 23 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
276 |
spawnTarget(3230,290) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
277 |
elseif score == 24 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
278 |
spawnTarget(3670,250) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
279 |
elseif score == 25 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
280 |
spawnTarget(2620,-100) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
281 |
elseif score == 26 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
282 |
spawnTarget(2870,300) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
283 |
elseif score == 27 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
284 |
spawnTarget(3850,900) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
285 |
elseif score == 28 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
286 |
spawnTarget(3780,300) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
287 |
elseif score == 29 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
288 |
spawnTarget(3670,0) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
289 |
elseif score == 30 then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
290 |
spawnTarget(3480,1200) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
291 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
292 |
else |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
293 |
if not game_lost then |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
294 |
-- Otherwise show that the goal was accomplished |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
295 |
ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
296 |
-- Also let the hogs shout "victory!" |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
297 |
PlaySound(sndVictory) |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
298 |
-- Save the time left so we may keep it. |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
299 |
time_goal = TurnTimeLeft |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
300 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
301 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
302 |
end |
5645462cc78f
removing all " " in filenames under share and replacing "_" with " " in missions
Henek
parents:
diff
changeset
|
303 |
end |