author | Wuzzy <Wuzzy2@mail.ru> |
Sat, 21 Oct 2017 18:21:27 +0200 | |
changeset 12728 | 745d5c9a3abc |
parent 12727 | 23fb2179945f |
child 12729 | 4e0e59255856 |
permissions | -rw-r--r-- |
11015 | 1 |
-- Hedgewars SniperRifle Training |
2 |
-- Scripting Example |
|
3 |
||
4 |
-- Lines such as this one are comments - they are ignored |
|
5 |
-- by the game, no matter what kind of text is in there. |
|
6 |
-- It's also possible to place a comment after some real |
|
7 |
-- instruction as you see below. In short, everything |
|
8 |
-- following "--" is ignored. |
|
9 |
||
10 |
--------------------------------------------------------------- |
|
11 |
-- At first we implement the localization library using loadfile. |
|
12 |
-- This allows us to localize strings without needing to think |
|
13 |
-- about translations. |
|
14 |
-- We can use the function loc(text) to localize a string. |
|
15 |
||
16 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
17 |
||
18 |
-- This variable will hold the number of destroyed targets. |
|
19 |
local score = 0 |
|
20 |
-- This variable will hold the number of shots from the sniper rifle |
|
21 |
local shots = 0 |
|
22 |
-- This variable represents the number of targets to destroy. |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
23 |
local score_goal = 27 |
11015 | 24 |
-- This variable controls how many milliseconds/ticks we'd |
25 |
-- like to wait before we end the round once all targets |
|
26 |
-- have been destroyed. |
|
27 |
local end_timer = 1000 -- 1000 ms = 1 s |
|
28 |
-- This variable is set to true if the game is lost (i.e. |
|
29 |
-- time runs out). |
|
30 |
local game_lost = false |
|
31 |
-- This variable will point to the hog's gear |
|
32 |
local player = nil |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
33 |
-- Current target gear |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
34 |
local target = nil |
11015 | 35 |
-- This variable will grab the time left at the end of the round |
36 |
local time_goal = 0 |
|
37 |
||
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
38 |
-- Like score, but targets before a blow-up sequence count double. |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
39 |
-- Used to calculate final target score |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
40 |
local score_bonus = 0 |
11015 | 41 |
|
11528 | 42 |
local cinematic = false |
43 |
||
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
44 |
-- Number of dynamite gears currently in game |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
45 |
local dynamiteCounter = 0 |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
46 |
|
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
47 |
-- Position for delayed targets |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
48 |
local delayedTargetTargetX, delayedTargetY |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
49 |
|
11015 | 50 |
-- This is a custom function to make it easier to |
51 |
-- spawn more targets with just one line of code |
|
52 |
-- You may define as many custom functions as you |
|
53 |
-- like. |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
54 |
|
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
55 |
-- Spawns a target at (x, y) |
11015 | 56 |
function spawnTarget(x, y) |
57 |
-- add a new target gear |
|
58 |
target = AddGear(x, y, gtTarget, 0, 0, 0, 0) |
|
59 |
-- have the camera move to the target so the player knows where it is |
|
60 |
FollowGear(target) |
|
61 |
end |
|
62 |
||
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
63 |
-- Remembers position to spawn a target at (x, y) after a dynamite explosion |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
64 |
function spawnTargetDelayed(x, y) |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
65 |
delayedTargetX = x |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
66 |
delayedTargetY = y |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
67 |
end |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
68 |
|
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
69 |
-- Cut sequence to blow up land with dynamite |
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
70 |
function blowUp(x, y, follow) |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
71 |
if cinematic == false then |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
72 |
cinematic = true |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
73 |
SetCinematicMode(true) |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
74 |
end |
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
75 |
local dyna = AddGear(x, y, gtDynamite, 0, 0, 0, 0) |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
76 |
if follow then |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
77 |
FollowGear(dyna) |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
78 |
end |
11015 | 79 |
end |
80 |
||
81 |
function onNewTurn() |
|
82 |
SetWeapon(amSniperRifle) |
|
83 |
end |
|
84 |
||
85 |
-- This function is called before the game loads its |
|
86 |
-- resources. |
|
87 |
-- It's one of the predefined function names that will |
|
88 |
-- be called by the game. They give you entry points |
|
89 |
-- where you're able to call your own code using either |
|
90 |
-- provided instructions or custom functions. |
|
91 |
function onGameInit() |
|
92 |
-- At first we have to overwrite/set some global variables |
|
93 |
-- that define the map, the game has to load, as well as |
|
94 |
-- other things such as the game rules to use, etc. |
|
95 |
-- Things we don't modify here will use their default values. |
|
96 |
||
97 |
-- The base number for the random number generator |
|
98 |
Seed = 0 |
|
99 |
-- Game settings and rules |
|
100 |
GameFlags = gfMultiWeapon + gfOneClanMode + gfArtillery |
|
101 |
-- The time the player has to move each round (in ms) |
|
102 |
TurnTime = 150000 |
|
103 |
-- The frequency of crate drops |
|
104 |
CaseFreq = 0 |
|
105 |
-- The number of mines being placed |
|
106 |
MinesNum = 0 |
|
107 |
-- The number of explosives being placed |
|
108 |
Explosives = 0 |
|
109 |
-- The delay between each round |
|
110 |
Delay = 0 |
|
111 |
-- The map to be played |
|
112 |
Map = "Ropes" |
|
113 |
-- The theme to be used |
|
11017
16c47a5573e4
change theme used by sniper training, for performance reasons
sheepluva
parents:
11015
diff
changeset
|
114 |
Theme = "Golf" |
12224
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
12049
diff
changeset
|
115 |
-- Disable Sudden Death |
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
12049
diff
changeset
|
116 |
WaterRise = 0 |
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
12049
diff
changeset
|
117 |
HealthDecrease = 0 |
11015 | 118 |
|
119 |
-- Create the player team |
|
12049
030464f34d47
Tweak flags used in all missions to fit more to the theme
Wuzzy <almikes@aol.com>
parents:
11968
diff
changeset
|
120 |
AddTeam(loc("Sniperz"), 14483456, "Simple", "Island", "Default", "cm_crosshair") |
11015 | 121 |
-- And add a hog to it |
122 |
player = AddHog(loc("Hunter"), 0, 1, "Sniper") |
|
123 |
SetGearPosition(player, 602, 1465) |
|
124 |
end |
|
125 |
||
126 |
-- This function is called when the round starts |
|
127 |
-- it spawns the first target that has to be destroyed. |
|
128 |
-- In addition it shows the scenario goal(s). |
|
129 |
function onGameStart() |
|
130 |
-- Disable graph in stats screen |
|
131 |
SendHealthStatsOff() |
|
132 |
-- Spawn the first target. |
|
133 |
spawnTarget(860,1020) |
|
11017
16c47a5573e4
change theme used by sniper training, for performance reasons
sheepluva
parents:
11015
diff
changeset
|
134 |
|
11015 | 135 |
-- Show some nice mission goals. |
136 |
-- Parameters are: caption, sub caption, description, |
|
137 |
-- extra text, icon and time to show. |
|
138 |
-- A negative icon parameter (-n) represents the n-th weapon icon |
|
139 |
-- A positive icon paramter (n) represents the (n+1)-th mission icon |
|
140 |
-- A timeframe of 0 is replaced with the default time to show. |
|
141 |
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) |
|
142 |
end |
|
143 |
||
144 |
-- This function is called every game tick. |
|
145 |
-- Note that there are 1000 ticks within one second. |
|
146 |
-- You shouldn't try to calculate too complicated |
|
147 |
-- code here as this might slow down your game. |
|
148 |
function onGameTick20() |
|
149 |
if game_lost then |
|
150 |
return |
|
151 |
end |
|
152 |
-- If time's up, set the game to be lost. |
|
153 |
-- We actually check the time to be "1 ms" as it |
|
154 |
-- will be at "0 ms" right at the start of the game. |
|
155 |
if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal and game_lost == false then |
|
156 |
game_lost = true |
|
157 |
-- ... and show a short message. |
|
158 |
AddCaption(loc("Time's up!")) |
|
159 |
ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0) |
|
160 |
-- and generate the stats and go to the stats screen |
|
161 |
generateStats() |
|
162 |
EndGame() |
|
163 |
-- Just to be sure set the goal time to 1 ms |
|
164 |
time_goal = 1 |
|
165 |
end |
|
166 |
-- If the goal is reached or we've lost ... |
|
167 |
if score == score_goal or game_lost then |
|
168 |
-- ... check to see if the time we'd like to |
|
169 |
-- wait has passed and then ... |
|
170 |
if end_timer == 0 then |
|
171 |
-- ... end the game ... |
|
172 |
generateStats() |
|
173 |
EndGame() |
|
174 |
else |
|
175 |
-- ... or just lower the timer by 1. |
|
176 |
-- Reset the time left to stop the timer |
|
177 |
TurnTimeLeft = time_goal |
|
178 |
end |
|
179 |
end_timer = end_timer - 20 |
|
180 |
end |
|
181 |
end |
|
182 |
||
183 |
-- This function is called when the game is initialized |
|
184 |
-- to request the available ammo and probabilities |
|
185 |
function onAmmoStoreInit() |
|
186 |
-- add an unlimited supply of shotgun ammo |
|
187 |
SetAmmo(amSniperRifle, 9, 0, 0, 0) |
|
188 |
end |
|
189 |
||
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
190 |
--[[ Re-center camera to target after using sniper rifle. |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
191 |
This makes it easier to find the target. If we don't |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
192 |
do this, the camera would contantly bounce back to |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
193 |
the hog which would be annoying. ]] |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
194 |
function onAttack() |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
195 |
if target and GetCurAmmoType() == amSniperRifle then |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
196 |
FollowGear(target) |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
197 |
end |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
198 |
end |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
199 |
|
11015 | 200 |
-- This function is called when a new gear is added. |
201 |
-- We use it to count the number of shots, which we |
|
202 |
-- in turn use to calculate the final score and stats |
|
203 |
function onGearAdd(gear) |
|
204 |
if GetGearType(gear) == gtSniperRifleShot then |
|
205 |
shots = shots + 1 |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
206 |
elseif GetGearType(gear) == gtDynamite then |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
207 |
dynamiteCounter = dynamiteCounter + 1 |
11015 | 208 |
end |
209 |
end |
|
210 |
||
211 |
-- This function is called before a gear is destroyed. |
|
212 |
-- We use it to count the number of targets destroyed. |
|
213 |
function onGearDelete(gear) |
|
11528 | 214 |
local gt = GetGearType(gear) |
11017
16c47a5573e4
change theme used by sniper training, for performance reasons
sheepluva
parents:
11015
diff
changeset
|
215 |
|
11528 | 216 |
if gt == gtCase then |
11015 | 217 |
game_lost = true |
218 |
return |
|
219 |
end |
|
11017
16c47a5573e4
change theme used by sniper training, for performance reasons
sheepluva
parents:
11015
diff
changeset
|
220 |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
221 |
if (gt == gtDynamite) then |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
222 |
-- Dynamite blow-up, used to continue the game. |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
223 |
dynamiteCounter = dynamiteCounter - 1 |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
224 |
|
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
225 |
-- Wait for all dynamites to be destroyed before we continue. |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
226 |
-- Most cut scenes spawn multiple dynamites. |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
227 |
if dynamiteCounter == 0 then |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
228 |
if cinematic then |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
229 |
cinematic = false |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
230 |
SetCinematicMode(false) |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
231 |
end |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
232 |
-- Add bonus score for the previuos target |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
233 |
score_bonus = score_bonus + 1 |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
234 |
-- Now *actually* spawn the delayed target |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
235 |
spawnTarget(delayedTargetX, delayedTargetY) |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
236 |
end |
11528 | 237 |
return |
238 |
end |
|
239 |
||
240 |
if gt == gtTarget then |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
241 |
target = nil |
11015 | 242 |
-- Add one point to our score/counter |
243 |
score = score + 1 |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
244 |
score_bonus = score_bonus + 1 |
11015 | 245 |
-- If we haven't reached the goal ... |
246 |
if score < score_goal then |
|
247 |
-- ... spawn another target. |
|
248 |
if score == 1 then |
|
249 |
spawnTarget(1520,1350) |
|
250 |
elseif score == 2 then |
|
251 |
spawnTarget(1730,1040) |
|
252 |
elseif score == 3 then |
|
253 |
spawnTarget(2080,780) |
|
254 |
elseif score == 4 then |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
255 |
-- Short cut scene, blows up up lots up land and prepares |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
256 |
-- next target position. |
11015 | 257 |
AddCaption(loc("Good so far!") .. " " .. loc("Keep it up!")); |
258 |
blowUp(1730,1226) |
|
259 |
blowUp(1440,1595) |
|
260 |
blowUp(1527,1575) |
|
261 |
blowUp(1614,1595) |
|
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
262 |
blowUp(1420,1675, true) |
11015 | 263 |
blowUp(1527,1675) |
264 |
blowUp(1634,1675) |
|
265 |
blowUp(1440,1755) |
|
266 |
blowUp(1527,1775) |
|
267 |
blowUp(1614,1755) |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
268 |
-- Target appears *after* the cutscene. |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
269 |
spawnTargetDelayed(1527,1667) |
11015 | 270 |
elseif score == 5 then |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
271 |
spawnTarget(2175,1300) |
11015 | 272 |
elseif score == 6 then |
273 |
spawnTarget(2250,940) |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
274 |
elseif score == 7 then |
11015 | 275 |
spawnTarget(2665,1540) |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
276 |
elseif score == 8 then |
11015 | 277 |
spawnTarget(3040,1160) |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
278 |
elseif score == 9 then |
11015 | 279 |
spawnTarget(2930,1500) |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
280 |
elseif score == 10 then |
11015 | 281 |
AddCaption(loc("This one's tricky.")); |
282 |
spawnTarget(700,720) |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
283 |
elseif score == 11 then |
11015 | 284 |
AddCaption(loc("Well done.")); |
285 |
blowUp(914,1222) |
|
286 |
blowUp(1050,1222) |
|
287 |
blowUp(1160,1008) |
|
288 |
blowUp(1160,1093) |
|
289 |
blowUp(1160,1188) |
|
290 |
blowUp(375,911) |
|
291 |
blowUp(510,911) |
|
292 |
blowUp(640,911) |
|
293 |
blowUp(780,911) |
|
294 |
blowUp(920,911) |
|
295 |
blowUp(1060,913) |
|
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
296 |
blowUp(1198,913, true) |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
297 |
spawnTargetDelayed(1200,830) |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
298 |
elseif score == 12 then |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
299 |
spawnTarget(1430,450) |
11015 | 300 |
elseif score == 13 then |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
301 |
spawnTarget(796,240) |
11015 | 302 |
elseif score == 14 then |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
303 |
spawnTarget(300,10) |
11015 | 304 |
elseif score == 15 then |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
305 |
spawnTarget(2080,820) |
11015 | 306 |
elseif score == 16 then |
307 |
AddCaption(loc("Demolition is fun!")); |
|
308 |
blowUp(2110,920) |
|
309 |
blowUp(2210,920) |
|
310 |
blowUp(2200,305) |
|
311 |
blowUp(2300,305) |
|
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
312 |
blowUp(2300,400, true) |
11015 | 313 |
blowUp(2300,500) |
314 |
blowUp(2300,600) |
|
315 |
blowUp(2300,700) |
|
316 |
blowUp(2300,800) |
|
317 |
blowUp(2300,900) |
|
318 |
blowUp(2401,305) |
|
319 |
blowUp(2532,305) |
|
320 |
blowUp(2663,305) |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
321 |
spawnTargetDelayed(2300,760) |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
322 |
elseif score == 17 then |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
323 |
spawnTarget(2738,190) |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
324 |
elseif score == 18 then |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
325 |
spawnTarget(2590,-100) |
11015 | 326 |
elseif score == 19 then |
327 |
AddCaption(loc("Will this ever end?")); |
|
328 |
blowUp(2790,305) |
|
329 |
blowUp(2930,305) |
|
330 |
blowUp(3060,305) |
|
331 |
blowUp(3190,305) |
|
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
332 |
blowUp(3310,305, true) |
11015 | 333 |
blowUp(3393,613) |
334 |
blowUp(2805,370) |
|
335 |
blowUp(2805,500) |
|
336 |
blowUp(2805,630) |
|
337 |
blowUp(2805,760) |
|
338 |
blowUp(2805,890) |
|
339 |
blowUp(3258,370) |
|
340 |
blowUp(3258,475) |
|
341 |
blowUp(3264,575) |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
342 |
spawnTargetDelayed(3230,290) |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
343 |
elseif score == 20 then |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
344 |
spawnTarget(3670,250) |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
345 |
elseif score == 21 then |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
346 |
spawnTarget(2620,-100) |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
347 |
elseif score == 22 then |
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
348 |
spawnTarget(2870,300) |
11015 | 349 |
elseif score == 23 then |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
350 |
spawnTarget(3850,900) |
11015 | 351 |
elseif score == 24 then |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
352 |
spawnTarget(3780,300) |
11015 | 353 |
elseif score == 25 then |
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
354 |
spawnTarget(3670,0) |
11015 | 355 |
elseif score == 26 then |
356 |
AddCaption(loc("Last Target!")); |
|
357 |
spawnTarget(3480,1200) |
|
358 |
end |
|
359 |
else |
|
360 |
if not game_lost then |
|
361 |
-- Otherwise show that the goal was accomplished |
|
362 |
ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0) |
|
363 |
-- Also let the hogs shout "victory!" |
|
364 |
PlaySound(sndVictory) |
|
365 |
-- Save the time left so we may keep it. |
|
366 |
time_goal = TurnTimeLeft |
|
367 |
end |
|
368 |
end |
|
369 |
end |
|
370 |
end |
|
371 |
||
372 |
-- This function calculates the final score of the player and provides some texts and |
|
373 |
-- data for the final stats screen |
|
374 |
function generateStats() |
|
375 |
local accuracy = (score/shots)*100 |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
376 |
local end_score_targets = (score_bonus * 200) |
11015 | 377 |
local end_score_overall |
378 |
if not game_lost then |
|
379 |
local end_score_time = math.ceil(time_goal/5) |
|
380 |
local end_score_accuracy = math.ceil(accuracy * 100) |
|
381 |
end_score_overall = end_score_time + end_score_targets + end_score_accuracy |
|
382 |
||
383 |
SendStat(siGameResult, loc("You have successfully finished the sniper rifle training!")) |
|
384 |
SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), score, score_goal, end_score_targets)) |
|
385 |
SendStat(siCustomAchievement, string.format(loc("You have made %d shots."), shots)) |
|
386 |
SendStat(siCustomAchievement, string.format(loc("Accuracy bonus: +%d points"), end_score_accuracy)) |
|
387 |
SendStat(siCustomAchievement, string.format(loc("You had %.2fs remaining on the clock (+%d points)."), (time_goal/1000), end_score_time)) |
|
388 |
else |
|
389 |
SendStat(siGameResult, loc("You lose!")) |
|
11017
16c47a5573e4
change theme used by sniper training, for performance reasons
sheepluva
parents:
11015
diff
changeset
|
390 |
|
11015 | 391 |
SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), score, score_goal, end_score_targets)) |
392 |
SendStat(siCustomAchievement, string.format(loc("You have made %d shots."), shots)) |
|
393 |
end_score_overall = end_score_targets |
|
394 |
end |
|
12346
fb22caa19600
Fix incorrect PointsType in sniper rifle training and That Sinking Feeling
Wuzzy <almikes@aol.com>
parents:
12224
diff
changeset
|
395 |
SendStat(siPointType, loc("points")) |
11015 | 396 |
SendStat(siPlayerKills, tostring(end_score_overall), loc("Sniperz")) |
397 |
end |
|
12727
23fb2179945f
Sniper rifle mission: Fix targets spawning twice in dynamite scenes, jacking up the total amount of targets
Wuzzy <Wuzzy2@mail.ru>
parents:
12346
diff
changeset
|
398 |