equal
deleted
inserted
replaced
37 |
37 |
38 -- Like score, but targets before a blow-up sequence count double. |
38 -- Like score, but targets before a blow-up sequence count double. |
39 -- Used to calculate final target score |
39 -- Used to calculate final target score |
40 local score_bonus = 0 |
40 local score_bonus = 0 |
41 |
41 |
42 local last_hit_time = 0 |
|
43 |
|
44 local cinematic = false |
42 local cinematic = false |
45 |
43 |
46 -- Number of dynamite gears currently in game |
44 -- Number of dynamite gears currently in game |
47 local dynamiteCounter = 0 |
45 local dynamiteCounter = 0 |
48 |
46 |
67 delayedTargetX = x |
65 delayedTargetX = x |
68 delayedTargetY = y |
66 delayedTargetY = y |
69 end |
67 end |
70 |
68 |
71 -- Cut sequence to blow up land with dynamite |
69 -- Cut sequence to blow up land with dynamite |
72 function blowUp(x, y) |
70 function blowUp(x, y, follow) |
73 if cinematic == false then |
71 if cinematic == false then |
74 cinematic = true |
72 cinematic = true |
75 SetCinematicMode(true) |
73 SetCinematicMode(true) |
76 end |
74 end |
77 AddGear(x, y, gtDynamite, 0, 0, 0, 0) |
75 local dyna = AddGear(x, y, gtDynamite, 0, 0, 0, 0) |
|
76 if follow then |
|
77 FollowGear(dyna) |
|
78 end |
78 end |
79 end |
79 |
80 |
80 function onNewTurn() |
81 function onNewTurn() |
81 SetWeapon(amSniperRifle) |
82 SetWeapon(amSniperRifle) |
82 end |
83 end |
146 -- code here as this might slow down your game. |
147 -- code here as this might slow down your game. |
147 function onGameTick20() |
148 function onGameTick20() |
148 if game_lost then |
149 if game_lost then |
149 return |
150 return |
150 end |
151 end |
151 -- after a target is destroyed, show hog, then target |
|
152 if (target ~= nil) and (TurnTimeLeft + 1300 < last_hit_time) then |
|
153 -- move camera to the target |
|
154 FollowGear(target) |
|
155 elseif TurnTimeLeft + 300 < last_hit_time then |
|
156 -- move camera to the hog |
|
157 FollowGear(player) |
|
158 end |
|
159 -- If time's up, set the game to be lost. |
152 -- If time's up, set the game to be lost. |
160 -- We actually check the time to be "1 ms" as it |
153 -- We actually check the time to be "1 ms" as it |
161 -- will be at "0 ms" right at the start of the game. |
154 -- will be at "0 ms" right at the start of the game. |
162 if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal and game_lost == false then |
155 if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal and game_lost == false then |
163 game_lost = true |
156 game_lost = true |
192 function onAmmoStoreInit() |
185 function onAmmoStoreInit() |
193 -- add an unlimited supply of shotgun ammo |
186 -- add an unlimited supply of shotgun ammo |
194 SetAmmo(amSniperRifle, 9, 0, 0, 0) |
187 SetAmmo(amSniperRifle, 9, 0, 0, 0) |
195 end |
188 end |
196 |
189 |
|
190 --[[ Re-center camera to target after using sniper rifle. |
|
191 This makes it easier to find the target. If we don't |
|
192 do this, the camera would contantly bounce back to |
|
193 the hog which would be annoying. ]] |
|
194 function onAttack() |
|
195 if target and GetCurAmmoType() == amSniperRifle then |
|
196 FollowGear(target) |
|
197 end |
|
198 end |
|
199 |
197 -- This function is called when a new gear is added. |
200 -- This function is called when a new gear is added. |
198 -- We use it to count the number of shots, which we |
201 -- We use it to count the number of shots, which we |
199 -- in turn use to calculate the final score and stats |
202 -- in turn use to calculate the final score and stats |
200 function onGearAdd(gear) |
203 function onGearAdd(gear) |
201 if GetGearType(gear) == gtSniperRifleShot then |
204 if GetGearType(gear) == gtSniperRifleShot then |
234 return |
237 return |
235 end |
238 end |
236 |
239 |
237 if gt == gtTarget then |
240 if gt == gtTarget then |
238 target = nil |
241 target = nil |
239 -- remember when the target was hit for adjusting the camera |
|
240 last_hit_time = TurnTimeLeft |
|
241 -- Add one point to our score/counter |
242 -- Add one point to our score/counter |
242 score = score + 1 |
243 score = score + 1 |
243 score_bonus = score_bonus + 1 |
244 score_bonus = score_bonus + 1 |
244 -- If we haven't reached the goal ... |
245 -- If we haven't reached the goal ... |
245 if score < score_goal then |
246 if score < score_goal then |
256 AddCaption(loc("Good so far!") .. " " .. loc("Keep it up!")); |
257 AddCaption(loc("Good so far!") .. " " .. loc("Keep it up!")); |
257 blowUp(1730,1226) |
258 blowUp(1730,1226) |
258 blowUp(1440,1595) |
259 blowUp(1440,1595) |
259 blowUp(1527,1575) |
260 blowUp(1527,1575) |
260 blowUp(1614,1595) |
261 blowUp(1614,1595) |
261 blowUp(1420,1675) |
262 blowUp(1420,1675, true) |
262 blowUp(1527,1675) |
263 blowUp(1527,1675) |
263 blowUp(1634,1675) |
264 blowUp(1634,1675) |
264 blowUp(1440,1755) |
265 blowUp(1440,1755) |
265 blowUp(1527,1775) |
266 blowUp(1527,1775) |
266 blowUp(1614,1755) |
267 blowUp(1614,1755) |
290 blowUp(510,911) |
291 blowUp(510,911) |
291 blowUp(640,911) |
292 blowUp(640,911) |
292 blowUp(780,911) |
293 blowUp(780,911) |
293 blowUp(920,911) |
294 blowUp(920,911) |
294 blowUp(1060,913) |
295 blowUp(1060,913) |
295 blowUp(1198,913) |
296 blowUp(1198,913, true) |
296 spawnTargetDelayed(1200,830) |
297 spawnTargetDelayed(1200,830) |
297 elseif score == 12 then |
298 elseif score == 12 then |
298 spawnTarget(1430,450) |
299 spawnTarget(1430,450) |
299 elseif score == 13 then |
300 elseif score == 13 then |
300 spawnTarget(796,240) |
301 spawnTarget(796,240) |
306 AddCaption(loc("Demolition is fun!")); |
307 AddCaption(loc("Demolition is fun!")); |
307 blowUp(2110,920) |
308 blowUp(2110,920) |
308 blowUp(2210,920) |
309 blowUp(2210,920) |
309 blowUp(2200,305) |
310 blowUp(2200,305) |
310 blowUp(2300,305) |
311 blowUp(2300,305) |
311 blowUp(2300,400) |
312 blowUp(2300,400, true) |
312 blowUp(2300,500) |
313 blowUp(2300,500) |
313 blowUp(2300,600) |
314 blowUp(2300,600) |
314 blowUp(2300,700) |
315 blowUp(2300,700) |
315 blowUp(2300,800) |
316 blowUp(2300,800) |
316 blowUp(2300,900) |
317 blowUp(2300,900) |
326 AddCaption(loc("Will this ever end?")); |
327 AddCaption(loc("Will this ever end?")); |
327 blowUp(2790,305) |
328 blowUp(2790,305) |
328 blowUp(2930,305) |
329 blowUp(2930,305) |
329 blowUp(3060,305) |
330 blowUp(3060,305) |
330 blowUp(3190,305) |
331 blowUp(3190,305) |
331 blowUp(3310,305) |
332 blowUp(3310,305, true) |
332 blowUp(3393,613) |
333 blowUp(3393,613) |
333 blowUp(2805,370) |
334 blowUp(2805,370) |
334 blowUp(2805,500) |
335 blowUp(2805,500) |
335 blowUp(2805,630) |
336 blowUp(2805,630) |
336 blowUp(2805,760) |
337 blowUp(2805,760) |