author | Wuzzy <Wuzzy2@mail.ru> |
Fri, 18 Jan 2019 00:36:48 +0100 | |
changeset 14652 | 92ebe33c5eb6 |
parent 14612 | b4089fa16b34 |
child 14669 | be8af70adf2c |
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 |
||
14496
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
16 |
HedgewarsScriptLoad("/Scripts/Utils.lua") |
11015 | 17 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
18 |
||
19 |
-- This variable will hold the number of destroyed targets. |
|
20 |
local score = 0 |
|
21 |
-- This variable will hold the number of shots from the sniper rifle |
|
22 |
local shots = 0 |
|
23 |
-- 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
|
24 |
local score_goal = 27 |
11015 | 25 |
-- This variable controls how many milliseconds/ticks we'd |
26 |
-- like to wait before we end the round once all targets |
|
27 |
-- have been destroyed. |
|
28 |
local end_timer = 1000 -- 1000 ms = 1 s |
|
29 |
-- This variable is set to true if the game is lost (i.e. |
|
30 |
-- time runs out). |
|
31 |
local game_lost = false |
|
32 |
-- This variable will point to the hog's gear |
|
33 |
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
|
34 |
-- 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
|
35 |
local target = nil |
11015 | 36 |
-- This variable will grab the time left at the end of the round |
37 |
local time_goal = 0 |
|
38 |
||
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
|
39 |
-- 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
|
40 |
-- 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
|
41 |
local score_bonus = 0 |
11015 | 42 |
|
11528 | 43 |
local cinematic = false |
44 |
||
12729
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
45 |
-- Timer of dynamite (shorter than usual) |
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
46 |
local dynamiteTimer = 2000 |
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
|
47 |
-- 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
|
48 |
local dynamiteCounter = 0 |
12729
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
49 |
-- Table of dynamite gears, indexed by gear ID |
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
50 |
local dynamiteGears = {} |
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
|
51 |
|
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
|
52 |
-- 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
|
53 |
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
|
54 |
|
13065
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
55 |
-- Team name of the player's team |
14501
208359558642
Use player-chosen team identity for training and a few challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14496
diff
changeset
|
56 |
local playerTeamName |
13065
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
57 |
|
11015 | 58 |
-- This is a custom function to make it easier to |
59 |
-- spawn more targets with just one line of code |
|
60 |
-- You may define as many custom functions as you |
|
61 |
-- 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
|
62 |
|
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 |
-- Spawns a target at (x, y) |
11015 | 64 |
function spawnTarget(x, y) |
65 |
-- add a new target gear |
|
66 |
target = AddGear(x, y, gtTarget, 0, 0, 0, 0) |
|
67 |
-- have the camera move to the target so the player knows where it is |
|
68 |
FollowGear(target) |
|
69 |
end |
|
70 |
||
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 |
-- 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
|
72 |
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
|
73 |
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
|
74 |
delayedTargetY = y |
13065
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
75 |
-- The previous target always counts double after destruction |
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
76 |
score_bonus = score_bonus + 1 |
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
77 |
end |
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
78 |
|
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
79 |
function getTargetScore() |
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
80 |
return score_bonus * 200 |
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
|
81 |
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
|
82 |
|
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
|
83 |
-- 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
|
84 |
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
|
85 |
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
|
86 |
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
|
87 |
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
|
88 |
end |
12729
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
89 |
-- Spawn dynamite with short timer |
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
90 |
local dyna = AddGear(x, y, gtDynamite, 0, 0, 0, dynamiteTimer) |
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
91 |
-- Fix dynamite animation due to non-default timer |
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
92 |
SetTag(dyna, div(5000-dynamiteTimer, 166)) |
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
93 |
if follow then |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
94 |
FollowGear(dyna) |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
95 |
end |
11015 | 96 |
end |
97 |
||
98 |
function onNewTurn() |
|
99 |
SetWeapon(amSniperRifle) |
|
100 |
end |
|
101 |
||
102 |
-- This function is called before the game loads its |
|
103 |
-- resources. |
|
104 |
-- It's one of the predefined function names that will |
|
105 |
-- be called by the game. They give you entry points |
|
106 |
-- where you're able to call your own code using either |
|
107 |
-- provided instructions or custom functions. |
|
108 |
function onGameInit() |
|
109 |
-- At first we have to overwrite/set some global variables |
|
110 |
-- that define the map, the game has to load, as well as |
|
111 |
-- other things such as the game rules to use, etc. |
|
112 |
-- Things we don't modify here will use their default values. |
|
113 |
||
114 |
-- The base number for the random number generator |
|
115 |
Seed = 0 |
|
116 |
-- Game settings and rules |
|
13099
071dcdf33f86
Fix artillery being broken in some missions
Wuzzy <Wuzzy2@mail.ru>
parents:
13065
diff
changeset
|
117 |
ClearGameFlags() |
071dcdf33f86
Fix artillery being broken in some missions
Wuzzy <Wuzzy2@mail.ru>
parents:
13065
diff
changeset
|
118 |
EnableGameFlags(gfMultiWeapon, gfOneClanMode, gfArtillery) |
11015 | 119 |
-- The time the player has to move each round (in ms) |
120 |
TurnTime = 150000 |
|
121 |
-- The frequency of crate drops |
|
122 |
CaseFreq = 0 |
|
123 |
-- The number of mines being placed |
|
124 |
MinesNum = 0 |
|
125 |
-- The number of explosives being placed |
|
126 |
Explosives = 0 |
|
127 |
-- The map to be played |
|
128 |
Map = "Ropes" |
|
129 |
-- The theme to be used |
|
11017
16c47a5573e4
change theme used by sniper training, for performance reasons
sheepluva
parents:
11015
diff
changeset
|
130 |
Theme = "Golf" |
12224
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
12049
diff
changeset
|
131 |
-- Disable Sudden Death |
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
12049
diff
changeset
|
132 |
WaterRise = 0 |
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
12049
diff
changeset
|
133 |
HealthDecrease = 0 |
11015 | 134 |
|
135 |
-- Create the player team |
|
14516 | 136 |
playerTeamName = AddMissionTeam(-1) |
11015 | 137 |
-- And add a hog to it |
14501
208359558642
Use player-chosen team identity for training and a few challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14496
diff
changeset
|
138 |
player = AddMissionHog(1) |
11015 | 139 |
SetGearPosition(player, 602, 1465) |
140 |
end |
|
141 |
||
142 |
-- This function is called when the round starts |
|
143 |
-- it spawns the first target that has to be destroyed. |
|
144 |
-- In addition it shows the scenario goal(s). |
|
145 |
function onGameStart() |
|
146 |
-- Disable graph in stats screen |
|
147 |
SendHealthStatsOff() |
|
148 |
-- Spawn the first target. |
|
149 |
spawnTarget(860,1020) |
|
11017
16c47a5573e4
change theme used by sniper training, for performance reasons
sheepluva
parents:
11015
diff
changeset
|
150 |
|
14496
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
151 |
local highscore = getReadableChallengeRecord("Highscore") |
11015 | 152 |
-- Show some nice mission goals. |
153 |
-- Parameters are: caption, sub caption, description, |
|
154 |
-- extra text, icon and time to show. |
|
155 |
-- A negative icon parameter (-n) represents the n-th weapon icon |
|
156 |
-- A positive icon paramter (n) represents the (n+1)-th mission icon |
|
157 |
-- A timeframe of 0 is replaced with the default time to show. |
|
14496
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
158 |
ShowMission(loc("Sniper Training"), loc("Aiming Practice"), |
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
159 |
loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission.") |
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
160 |
.. "|" .. highscore, -amSniperRifle, 0) |
13065
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
161 |
|
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
162 |
-- Displayed initial player score |
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
163 |
SetTeamLabel(playerTeamName, "0") |
11015 | 164 |
end |
165 |
||
166 |
-- This function is called every game tick. |
|
167 |
-- Note that there are 1000 ticks within one second. |
|
168 |
-- You shouldn't try to calculate too complicated |
|
169 |
-- code here as this might slow down your game. |
|
170 |
function onGameTick20() |
|
171 |
if game_lost then |
|
172 |
return |
|
173 |
end |
|
174 |
-- If time's up, set the game to be lost. |
|
175 |
-- We actually check the time to be "1 ms" as it |
|
176 |
-- will be at "0 ms" right at the start of the game. |
|
177 |
if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal and game_lost == false then |
|
178 |
game_lost = true |
|
179 |
-- and generate the stats and go to the stats screen |
|
180 |
generateStats() |
|
181 |
EndGame() |
|
182 |
-- Just to be sure set the goal time to 1 ms |
|
183 |
time_goal = 1 |
|
184 |
end |
|
185 |
-- If the goal is reached or we've lost ... |
|
186 |
if score == score_goal or game_lost then |
|
187 |
-- ... check to see if the time we'd like to |
|
188 |
-- wait has passed and then ... |
|
189 |
if end_timer == 0 then |
|
190 |
-- ... end the game ... |
|
191 |
generateStats() |
|
192 |
EndGame() |
|
193 |
end |
|
14547
797e3f441c14
Make turn timer gray when finishing target practice
Wuzzy <Wuzzy2@mail.ru>
parents:
14516
diff
changeset
|
194 |
end_timer = end_timer - 20 |
11015 | 195 |
end |
196 |
end |
|
197 |
||
198 |
-- This function is called when the game is initialized |
|
199 |
-- to request the available ammo and probabilities |
|
200 |
function onAmmoStoreInit() |
|
201 |
-- add an unlimited supply of shotgun ammo |
|
202 |
SetAmmo(amSniperRifle, 9, 0, 0, 0) |
|
203 |
end |
|
204 |
||
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
205 |
--[[ 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
|
206 |
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
|
207 |
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
|
208 |
the hog which would be annoying. ]] |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
209 |
function onAttack() |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
210 |
if target and GetCurAmmoType() == amSniperRifle then |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
211 |
FollowGear(target) |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
212 |
end |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
213 |
end |
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
214 |
|
12729
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
215 |
-- Insta-blow up dynamite with precise key |
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
216 |
function onPrecise() |
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
217 |
for gear, _ in pairs(dynamiteGears) do |
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
218 |
SetTimer(gear, 0) |
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
219 |
end |
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
220 |
end |
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
221 |
|
11015 | 222 |
-- This function is called when a new gear is added. |
223 |
-- We use it to count the number of shots, which we |
|
224 |
-- in turn use to calculate the final score and stats |
|
225 |
function onGearAdd(gear) |
|
226 |
if GetGearType(gear) == gtSniperRifleShot then |
|
227 |
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
|
228 |
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
|
229 |
dynamiteCounter = dynamiteCounter + 1 |
12729
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
230 |
dynamiteGears[gear] = true |
11015 | 231 |
end |
232 |
end |
|
233 |
||
234 |
-- This function is called before a gear is destroyed. |
|
235 |
-- We use it to count the number of targets destroyed. |
|
236 |
function onGearDelete(gear) |
|
11528 | 237 |
local gt = GetGearType(gear) |
11017
16c47a5573e4
change theme used by sniper training, for performance reasons
sheepluva
parents:
11015
diff
changeset
|
238 |
|
11528 | 239 |
if gt == gtCase then |
11015 | 240 |
game_lost = true |
241 |
return |
|
242 |
end |
|
11017
16c47a5573e4
change theme used by sniper training, for performance reasons
sheepluva
parents:
11015
diff
changeset
|
243 |
|
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 |
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
|
245 |
-- 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
|
246 |
dynamiteCounter = dynamiteCounter - 1 |
12729
4e0e59255856
Sniper rifle mission: Faster dynamite blow-up, also skip with precise
Wuzzy <Wuzzy2@mail.ru>
parents:
12728
diff
changeset
|
247 |
dynamiteGears[gear] = 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
|
248 |
|
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
|
249 |
-- 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
|
250 |
-- 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
|
251 |
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
|
252 |
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
|
253 |
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
|
254 |
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
|
255 |
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
|
256 |
-- 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
|
257 |
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
|
258 |
end |
11528 | 259 |
return |
260 |
end |
|
261 |
||
262 |
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
|
263 |
target = nil |
11015 | 264 |
-- Add one point to our score/counter |
265 |
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
|
266 |
score_bonus = score_bonus + 1 |
11015 | 267 |
-- If we haven't reached the goal ... |
268 |
if score < score_goal then |
|
269 |
-- ... spawn another target. |
|
270 |
if score == 1 then |
|
271 |
spawnTarget(1520,1350) |
|
272 |
elseif score == 2 then |
|
273 |
spawnTarget(1730,1040) |
|
274 |
elseif score == 3 then |
|
275 |
spawnTarget(2080,780) |
|
276 |
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
|
277 |
-- 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
|
278 |
-- next target position. |
11015 | 279 |
AddCaption(loc("Good so far!") .. " " .. loc("Keep it up!")); |
280 |
blowUp(1730,1226) |
|
281 |
blowUp(1440,1595) |
|
282 |
blowUp(1527,1575) |
|
283 |
blowUp(1614,1595) |
|
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
284 |
blowUp(1420,1675, true) |
11015 | 285 |
blowUp(1527,1675) |
286 |
blowUp(1634,1675) |
|
287 |
blowUp(1440,1755) |
|
288 |
blowUp(1527,1775) |
|
289 |
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
|
290 |
-- 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
|
291 |
spawnTargetDelayed(1527,1667) |
11015 | 292 |
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
|
293 |
spawnTarget(2175,1300) |
11015 | 294 |
elseif score == 6 then |
295 |
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
|
296 |
elseif score == 7 then |
11015 | 297 |
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
|
298 |
elseif score == 8 then |
11015 | 299 |
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
|
300 |
elseif score == 9 then |
11015 | 301 |
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
|
302 |
elseif score == 10 then |
11015 | 303 |
AddCaption(loc("This one's tricky.")); |
304 |
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
|
305 |
elseif score == 11 then |
11015 | 306 |
AddCaption(loc("Well done.")); |
307 |
blowUp(914,1222) |
|
308 |
blowUp(1050,1222) |
|
309 |
blowUp(1160,1008) |
|
310 |
blowUp(1160,1093) |
|
311 |
blowUp(1160,1188) |
|
312 |
blowUp(375,911) |
|
313 |
blowUp(510,911) |
|
314 |
blowUp(640,911) |
|
315 |
blowUp(780,911) |
|
316 |
blowUp(920,911) |
|
317 |
blowUp(1060,913) |
|
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
318 |
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
|
319 |
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
|
320 |
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
|
321 |
spawnTarget(1430,450) |
11015 | 322 |
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
|
323 |
spawnTarget(796,240) |
11015 | 324 |
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
|
325 |
spawnTarget(300,10) |
11015 | 326 |
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
|
327 |
spawnTarget(2080,820) |
11015 | 328 |
elseif score == 16 then |
329 |
AddCaption(loc("Demolition is fun!")); |
|
330 |
blowUp(2110,920) |
|
331 |
blowUp(2210,920) |
|
332 |
blowUp(2200,305) |
|
333 |
blowUp(2300,305) |
|
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
334 |
blowUp(2300,400, true) |
11015 | 335 |
blowUp(2300,500) |
336 |
blowUp(2300,600) |
|
337 |
blowUp(2300,700) |
|
338 |
blowUp(2300,800) |
|
339 |
blowUp(2300,900) |
|
340 |
blowUp(2401,305) |
|
341 |
blowUp(2532,305) |
|
342 |
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
|
343 |
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
|
344 |
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
|
345 |
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
|
346 |
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
|
347 |
spawnTarget(2590,-100) |
11015 | 348 |
elseif score == 19 then |
349 |
AddCaption(loc("Will this ever end?")); |
|
350 |
blowUp(2790,305) |
|
351 |
blowUp(2930,305) |
|
352 |
blowUp(3060,305) |
|
353 |
blowUp(3190,305) |
|
12728
745d5c9a3abc
Sniper rifle training: Fix general camera weirdness
Wuzzy <Wuzzy2@mail.ru>
parents:
12727
diff
changeset
|
354 |
blowUp(3310,305, true) |
11015 | 355 |
blowUp(3393,613) |
356 |
blowUp(2805,370) |
|
357 |
blowUp(2805,500) |
|
358 |
blowUp(2805,630) |
|
359 |
blowUp(2805,760) |
|
360 |
blowUp(2805,890) |
|
361 |
blowUp(3258,370) |
|
362 |
blowUp(3258,475) |
|
363 |
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
|
364 |
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
|
365 |
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
|
366 |
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
|
367 |
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
|
368 |
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
|
369 |
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
|
370 |
spawnTarget(2870,300) |
11015 | 371 |
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
|
372 |
spawnTarget(3850,900) |
11015 | 373 |
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
|
374 |
spawnTarget(3780,300) |
11015 | 375 |
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
|
376 |
spawnTarget(3670,0) |
11015 | 377 |
elseif score == 26 then |
378 |
AddCaption(loc("Last Target!")); |
|
379 |
spawnTarget(3480,1200) |
|
380 |
end |
|
14547
797e3f441c14
Make turn timer gray when finishing target practice
Wuzzy <Wuzzy2@mail.ru>
parents:
14516
diff
changeset
|
381 |
elseif not game_lost then |
12730
2c4a07eb2112
Sniper rifle training: Fix missing victory sound, also disable controls at the end
Wuzzy <Wuzzy2@mail.ru>
parents:
12729
diff
changeset
|
382 |
-- Victory! |
14485
ead8928a59f8
Report mission victory for most missions
Wuzzy <Wuzzy2@mail.ru>
parents:
14422
diff
changeset
|
383 |
SaveMissionVar("Won", "true") |
13643 | 384 |
AddCaption(loc("Victory!"), capcolDefault, capgrpGameState) |
11015 | 385 |
ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0) |
386 |
-- Also let the hogs shout "victory!" |
|
12730
2c4a07eb2112
Sniper rifle training: Fix missing victory sound, also disable controls at the end
Wuzzy <Wuzzy2@mail.ru>
parents:
12729
diff
changeset
|
387 |
PlaySound(sndVictory, CurrentHedgehog) |
2c4a07eb2112
Sniper rifle training: Fix missing victory sound, also disable controls at the end
Wuzzy <Wuzzy2@mail.ru>
parents:
12729
diff
changeset
|
388 |
FollowGear(CurrentHedgehog) |
2c4a07eb2112
Sniper rifle training: Fix missing victory sound, also disable controls at the end
Wuzzy <Wuzzy2@mail.ru>
parents:
12729
diff
changeset
|
389 |
|
12913
20e627c1ac20
ClimbHome, Sniper Rifle training: Unselect weapon after victory
Wuzzy <Wuzzy2@mail.ru>
parents:
12731
diff
changeset
|
390 |
-- Unselect sniper rifle and disable hog controls |
12730
2c4a07eb2112
Sniper rifle training: Fix missing victory sound, also disable controls at the end
Wuzzy <Wuzzy2@mail.ru>
parents:
12729
diff
changeset
|
391 |
SetInputMask(0) |
12913
20e627c1ac20
ClimbHome, Sniper Rifle training: Unselect weapon after victory
Wuzzy <Wuzzy2@mail.ru>
parents:
12731
diff
changeset
|
392 |
SetWeapon(amNothing) |
12730
2c4a07eb2112
Sniper rifle training: Fix missing victory sound, also disable controls at the end
Wuzzy <Wuzzy2@mail.ru>
parents:
12729
diff
changeset
|
393 |
AddAmmo(CurrentHedgehog, amSniperRifle, 0) |
2c4a07eb2112
Sniper rifle training: Fix missing victory sound, also disable controls at the end
Wuzzy <Wuzzy2@mail.ru>
parents:
12729
diff
changeset
|
394 |
|
11015 | 395 |
-- Save the time left so we may keep it. |
396 |
time_goal = TurnTimeLeft |
|
14547
797e3f441c14
Make turn timer gray when finishing target practice
Wuzzy <Wuzzy2@mail.ru>
parents:
14516
diff
changeset
|
397 |
|
797e3f441c14
Make turn timer gray when finishing target practice
Wuzzy <Wuzzy2@mail.ru>
parents:
14516
diff
changeset
|
398 |
-- Freeze the clock because the challenge has been completed |
797e3f441c14
Make turn timer gray when finishing target practice
Wuzzy <Wuzzy2@mail.ru>
parents:
14516
diff
changeset
|
399 |
SetTurnTimePaused(true) |
11015 | 400 |
end |
13065
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
401 |
SetTeamLabel(playerTeamName, getTargetScore()) |
11015 | 402 |
end |
403 |
end |
|
404 |
||
405 |
-- This function calculates the final score of the player and provides some texts and |
|
406 |
-- data for the final stats screen |
|
407 |
function generateStats() |
|
14612
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
408 |
local accuracy |
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
409 |
local accuracy_int |
12731
2b0a4a4b1ba2
Fix division by 0 in sniper rifle training
Wuzzy <Wuzzy2@mail.ru>
parents:
12730
diff
changeset
|
410 |
if shots > 0 then |
2b0a4a4b1ba2
Fix division by 0 in sniper rifle training
Wuzzy <Wuzzy2@mail.ru>
parents:
12730
diff
changeset
|
411 |
accuracy = (score/shots)*100 |
14612
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
412 |
accuracy_int = div(score*100, shots) |
12731
2b0a4a4b1ba2
Fix division by 0 in sniper rifle training
Wuzzy <Wuzzy2@mail.ru>
parents:
12730
diff
changeset
|
413 |
end |
13065
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
414 |
local end_score_targets = getTargetScore() |
11015 | 415 |
local end_score_overall |
416 |
if not game_lost then |
|
417 |
local end_score_time = math.ceil(time_goal/5) |
|
14612
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
418 |
local end_score_accuracy = 0 |
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
419 |
if shots > 0 then |
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
420 |
end_score_accuracy = math.ceil(accuracy * 100) |
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
421 |
end |
11015 | 422 |
end_score_overall = end_score_time + end_score_targets + end_score_accuracy |
13065
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
423 |
SetTeamLabel(playerTeamName, tostring(end_score_overall)) |
11015 | 424 |
|
425 |
SendStat(siGameResult, loc("You have successfully finished the sniper rifle training!")) |
|
426 |
SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), score, score_goal, end_score_targets)) |
|
427 |
SendStat(siCustomAchievement, string.format(loc("You have made %d shots."), shots)) |
|
14612
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
428 |
if end_score_accuracy > 0 then |
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
429 |
SendStat(siCustomAchievement, string.format(loc("Accuracy bonus: +%d points"), end_score_accuracy)) |
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
430 |
end |
11015 | 431 |
SendStat(siCustomAchievement, string.format(loc("You had %.2fs remaining on the clock (+%d points)."), (time_goal/1000), end_score_time)) |
14612
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
432 |
|
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
433 |
if(shots > 0) then |
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
434 |
updateChallengeRecord("AccuracyRecord", accuracy_int) |
b4089fa16b34
Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
435 |
end |
11015 | 436 |
else |
14611
c5f18710a184
Remove "loser" messages in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14599
diff
changeset
|
437 |
SendStat(siGameResult, loc("Challenge over!")) |
11017
16c47a5573e4
change theme used by sniper training, for performance reasons
sheepluva
parents:
11015
diff
changeset
|
438 |
|
11015 | 439 |
SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), score, score_goal, end_score_targets)) |
440 |
SendStat(siCustomAchievement, string.format(loc("You have made %d shots."), shots)) |
|
441 |
end_score_overall = end_score_targets |
|
442 |
end |
|
14599
50f511588635
Outsource commonly used words in siPointType to QTfrontend
Wuzzy <Wuzzy2@mail.ru>
parents:
14547
diff
changeset
|
443 |
SendStat(siPointType, "!POINTS") |
13065
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
444 |
SendStat(siPlayerKills, tostring(end_score_overall), playerTeamName) |
14496
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
445 |
updateChallengeRecord("Highscore", end_score_overall) |
11015 | 446 |
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
|
447 |