281 -- AddCaption(GetTimer(RCGear)) |
292 -- AddCaption(GetTimer(RCGear)) |
282 --end |
293 --end |
283 |
294 |
284 --end |
295 --end |
285 |
296 |
|
297 function onGameTick20() |
|
298 if RCGear ~= nil then |
|
299 if(GetTimer(RCGear) < 3000 and planeUhOh == false) then |
|
300 PlaySound(sndUhOh, player) |
|
301 planeUhOh = true |
|
302 end |
|
303 planeTimer = planeTimer + 20 |
|
304 end |
|
305 if commentTimer > 0 then |
|
306 commentTimer = commentTimer - 20 |
|
307 elseif(nextComment ~= sndNone) then |
|
308 PlaySound(nextComment, player) |
|
309 nextComment = sndNone |
|
310 end |
|
311 if missileScanTimer > 0 then |
|
312 missileScanTimer = missileScanTimer - 20 |
|
313 else |
|
314 if crateStreak == 0 and missiles == 3 then |
|
315 PlaySound(sndMissed, player) |
|
316 missiles = 4 |
|
317 end |
|
318 end |
|
319 end |
|
320 |
286 function onNewTurn() |
321 function onNewTurn() |
287 TurnTimeLeft = -1 |
322 TurnTimeLeft = -1 |
288 end |
323 end |
289 |
324 |
290 function onGearAdd(gear) |
325 function onGearAdd(gear) |
291 |
326 |
292 if GetGearType(gear) == gtRCPlane then |
327 if GetGearType(gear) == gtRCPlane then |
293 RCGear = gear |
328 RCGear = gear |
294 planesUsed = planesUsed + 1 |
329 planesUsed = planesUsed + 1 |
|
330 planeTimer = 0 |
|
331 missiles = 0 |
295 end |
332 end |
296 |
333 |
297 if GetGearType(gear) == gtCase then |
334 if GetGearType(gear) == gtCase then |
298 cratesLeft = cratesLeft + 1 |
335 cratesLeft = cratesLeft + 1 |
299 end |
336 end |
300 |
337 |
|
338 if GetGearType(gear) == gtAirBomb then |
|
339 totalMissiles = totalMissiles + 1 |
|
340 end |
301 end |
341 end |
302 |
342 |
303 function onGearDelete(gear) |
343 function onGearDelete(gear) |
304 |
344 |
305 if GetGearType(gear) == gtRCPlane then |
345 if GetGearType(gear) == gtRCPlane then |
306 |
346 |
307 RCGear = nil |
347 RCGear = nil |
308 AddCaption(loc("Planes Used:") .. " " .. planesUsed) |
348 planeUhOh = false |
|
349 missiles = 0 |
|
350 AddCaption(string.format(loc("Planes used: %d"), planesUsed)) |
|
351 |
|
352 if(planeTimer < 2000 and crateStreak == 0) then |
|
353 nextComment = sndStupid |
|
354 commentTimer = math.min(2000-planeTimer, 800) |
|
355 elseif(planeTimer < 5000 and crateStreak == 0) then |
|
356 PlaySound(sndOops, player) |
|
357 elseif(planesUsed == 72) then |
|
358 PlaySound(sndStupid, player) |
|
359 elseif(planesUsed == 50) then |
|
360 PlaySound(sndNutter, player) |
|
361 elseif(planesUsed == 30) then |
|
362 PlaySound(sndOops, player) |
|
363 end |
|
364 |
|
365 crateStreak = 0 |
|
366 |
|
367 elseif GetGearType(gear) == gtAirBomb then |
|
368 missiles = missiles + 1 |
|
369 missileScanTimer = 500 |
309 |
370 |
310 elseif GetGearType(gear) == gtCase then |
371 elseif GetGearType(gear) == gtCase then |
311 |
372 |
312 AddCaption(loc("Crates Left:") .. " " .. cratesLeft) |
|
313 cratesLeft = cratesLeft - 1 |
373 cratesLeft = cratesLeft - 1 |
|
374 crateStreak = crateStreak + 1 |
|
375 if(crateStreak > longestCrateStreak) then |
|
376 longestCrateStreak = crateStreak |
|
377 end |
|
378 |
|
379 AddCaption(string.format(loc("Crates left: %d"), cratesLeft)) |
314 |
380 |
315 if cratesLeft == 0 then |
381 if cratesLeft == 0 then |
316 |
382 |
|
383 local rank = "unknown" |
|
384 local color = 0xFFFFFFFF |
|
385 local sound = sndVictory |
|
386 if planesUsed >= 156 then |
|
387 rank = loc("Destroyer of planes") |
|
388 color = 0xD06700FF |
|
389 sound = sndLaugh |
|
390 elseif planesUsed >= 98 then |
|
391 rank = loc("Hopeless case") |
|
392 color = 0xFF0000FF |
|
393 elseif planesUsed >= 72 then |
|
394 rank = loc("Drunk greenhorn") |
|
395 color = 0xFF0040FF |
|
396 elseif planesUsed >= 50 then |
|
397 rank = loc("Greenhorn") -- a.k.a. "absolute beginner" |
|
398 color = 0xFF0080FF |
|
399 elseif planesUsed >= 39 then |
|
400 rank = loc("Beginner") |
|
401 color = 0xFF00BFFF |
|
402 elseif planesUsed >= 30 then |
|
403 rank = loc("Experienced beginner") |
|
404 color = 0xFF00CCFF |
|
405 elseif planesUsed >= 21 then |
|
406 rank = loc("Below-average pilot") |
|
407 color = 0xFF00FFFF |
|
408 elseif planesUsed >= 17 then |
|
409 rank = loc("Average pilot") |
|
410 color = 0xBF00FFFF |
|
411 elseif planesUsed >= 13 then |
|
412 rank = loc("Above-average pilot") |
|
413 color = 0x8000FFFF |
|
414 elseif planesUsed >= 8 then |
|
415 rank = loc("Professional pilot") |
|
416 color = 0x4000FFFF |
|
417 elseif planesUsed >= 5 then |
|
418 rank = loc("Professional stunt pilot") |
|
419 color = 0x0000FFFF |
|
420 elseif planesUsed >= 3 then |
|
421 rank = loc("Elite pilot") |
|
422 color = 0x0040FFFF |
|
423 elseif planesUsed == 2 then |
|
424 rank = loc("Upper-class elite pilot") |
|
425 color = 0x0080FFFF |
|
426 elseif planesUsed == 1 then |
|
427 rank = loc("Top-class elite pilot") |
|
428 color = 0x00FFFFFF |
|
429 sound = sndFlawless |
|
430 else |
|
431 rank = loc("Cheater") |
|
432 color = 0xFF0000FF |
|
433 sound = sndCoward |
|
434 end |
|
435 AddCaption(string.format(loc("Rank: %s"), rank), color, capgrpMessage2) |
|
436 SendStat(siCustomAchievement, string.format(loc("Your rank: %s"), rank)) |
317 if planesUsed == 1 then |
437 if planesUsed == 1 then |
318 AddCaption(loc("Achievement Unlocked") .. ": " .. loc("Prestigious Pilot"),0xffba00ff,capgrpMessage2) |
438 AddCaption(loc("Flawless victory!")) |
|
439 SendStat(siGameResult, loc("You have perfectly beaten the challenge!")) |
|
440 SendStat(siCustomAchievement, loc("You have used only 1 RC plane. Outstanding!")) |
|
441 else |
|
442 AddCaption(loc("Victory!")) |
|
443 SendStat(siGameResult, loc("You have finished the challenge!")) |
|
444 SendStat(siCustomAchievement, string.format(loc("You have used %d RC planes."), planesUsed)) |
|
445 end |
|
446 |
|
447 if(totalMissiles > 1) then |
|
448 SendStat(siCustomAchievement, string.format(loc("You have dropped %d missiles."), totalMissiles)) |
|
449 end |
|
450 |
|
451 if(longestCrateStreak > 5) then |
|
452 if(planesUsed == 1) then |
|
453 SendStat(siCustomAchievement, string.format(loc("In your best (and only) flight you took out %d crates with one RC plane!"), longestCrateStreak)) |
|
454 else |
|
455 SendStat(siCustomAchievement, string.format(loc("In your best flight you took out %d crates with one RC plane."), longestCrateStreak)) |
|
456 end |
|
457 end |
|
458 |
|
459 if(planesUsed == 2) then |
|
460 SendStat(siCustomAchievement, loc("This was an awesome performance! But this challenge can be finished with even just one RC plane. Can you figure out how?")) |
|
461 end |
|
462 if(planesUsed == 1) then |
|
463 SendStat(siCustomAchievement, loc("Congratulations! You have truly mastered this challenge! Don't forget to save the demo.")) |
|
464 SendStat(siCustomAchievement, string.format(loc("You have gained an achievement: %s"), loc("Prestigious Pilot"))) |
319 end |
465 end |
320 |
466 |
321 ShowMission ( |
467 ShowMission ( |
322 loc("CHALLENGE COMPLETE"), |
468 loc("CHALLENGE COMPLETE"), |
323 loc("Congratulations!"), |
469 loc("Congratulations!"), |
324 loc("Planes Used") .. ": " .. planesUsed .. "|" .. |
470 string.format(loc("Planes used: %d"), planesUsed) .. "|" .. |
325 "", 0, 0 |
471 "", 0, 0 |
326 ) |
472 ) |
327 |
473 SetState(player, gstWinner) |
|
474 PlaySound(sound, player) |
328 |
475 |
329 |
476 |
330 DismissTeam(loc("Wannabe Flyboys")) |
477 DismissTeam(loc("Wannabe Flyboys")) |
|
478 EndGame() |
331 end |
479 end |
332 |
480 |
333 if RCGear ~= nil then |
481 if RCGear ~= nil then |
334 SetTimer(RCGear, GetTimer(RCGear) + 10000) |
482 SetTimer(RCGear, GetTimer(RCGear) + 10000) |
335 end |
483 end |
336 |
|
337 end |
484 end |
338 |
485 |
339 end |
486 end |
340 |
487 |
341 function onAmmoStoreInit() |
488 function onAmmoStoreInit() |