148 ShowMission(params.missionTitle, loc("Aiming practice"), params.goalText, -params.ammoType, 5000) |
148 ShowMission(params.missionTitle, loc("Aiming practice"), params.goalText, -params.ammoType, 5000) |
149 spawnTarget() |
149 spawnTarget() |
150 end |
150 end |
151 |
151 |
152 _G.onNewTurn = function() |
152 _G.onNewTurn = function() |
153 -- TODO: Remove the else branch when 0.9.21 has been released |
153 SetWeapon(params.ammoType) |
154 if SetWeapon ~= nil then |
|
155 SetWeapon(params.ammoType) |
|
156 else |
|
157 ParseCommand("/setweap "..string.char(params.ammoType)) |
|
158 end |
|
159 end |
154 end |
160 |
155 |
161 _G.spawnTarget = function() |
156 _G.spawnTarget = function() |
162 gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
157 gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
163 |
158 |
164 x = targets[scored+1].x |
159 x = targets[scored+1].x |
165 y = targets[scored+1].y |
160 y = targets[scored+1].y |
166 |
161 |
167 SetGearPosition(gear, x, y) |
162 SetGearPosition(gear, x, y) |
|
163 |
|
164 return gear |
168 end |
165 end |
169 |
166 |
170 _G.onGameTick20 = function() |
167 _G.onGameTick20 = function() |
171 if TurnTimeLeft < 40 and TurnTimeLeft > 0 and scored < total_targets and game_lost == false then |
168 if TurnTimeLeft < 40 and TurnTimeLeft > 0 and scored < total_targets and game_lost == false then |
172 game_lost = true |
169 game_lost = true |
227 time_goal = 1 |
224 time_goal = 1 |
228 end |
225 end |
229 end |
226 end |
230 end |
227 end |
231 |
228 |
|
229 _G.onGearDelete = function(gear) |
|
230 if GetGearType(gear) == gtTarget and band(GetState(gear), gstDrowning) ~= 0 then |
|
231 AddCaption(loc("You lost your target, try again!", 0xFFFFFFFF, capgrpGameState)) |
|
232 local newTarget = spawnTarget() |
|
233 local x, y = GetGearPosition(newTarget) |
|
234 local success = PlaceSprite(x, y + 24, sprAmGirder, 0, 0xFFFFFFFF, false, false, false) |
|
235 if not success then |
|
236 WriteLnToConsole("ERROR: Failed to spawn girder under respawned target!") |
|
237 end |
|
238 end |
|
239 end |
|
240 |
232 _G.generateStats = function() |
241 _G.generateStats = function() |
233 local accuracy = (scored/shots)*100 |
242 local accuracy = (scored/shots)*100 |
234 local end_score_targets = scored * math.ceil(6000/#targets) |
243 local end_score_targets = scored * math.ceil(6000/#targets) |
235 local end_score_overall |
244 local end_score_overall |
236 if not game_lost then |
245 if not game_lost then |
252 if(shots > 0) then |
261 if(shots > 0) then |
253 SendStat(siCustomAchievement, string.format(loc("Your accuracy was %.1f%%."), accuracy)) |
262 SendStat(siCustomAchievement, string.format(loc("Your accuracy was %.1f%%."), accuracy)) |
254 end |
263 end |
255 end_score_overall = end_score_targets |
264 end_score_overall = end_score_targets |
256 end |
265 end |
|
266 SendStat(siPointType, loc("point(s)")) |
257 SendStat(siPlayerKills, tostring(end_score_overall), loc(params.teamName)) |
267 SendStat(siPlayerKills, tostring(end_score_overall), loc(params.teamName)) |
258 SendStat(siPointType, loc("points")) |
|
259 end |
268 end |
260 end |
269 end |