14 local missionName = loc("Spacetrip") |
14 local missionName = loc("Spacetrip") |
15 local timeForGuard1ToTurn = 1000 * 5 -- 5 sec |
15 local timeForGuard1ToTurn = 1000 * 5 -- 5 sec |
16 local timeForGuard1ToTurnLeft = timeForGuard1ToTurn |
16 local timeForGuard1ToTurnLeft = timeForGuard1ToTurn |
17 local saucerAcquired = false |
17 local saucerAcquired = false |
18 local status |
18 local status |
|
19 local getReadyForRumble = false -- guards wake up |
|
20 local ropeDestroyed = false -- for detecting if player roped to the moon |
19 local checkPointReached = 1 -- 1 is start of the game |
21 local checkPointReached = 1 -- 1 is start of the game |
20 local objectives = loc("Go to the moon by using the flying saucer and complete the main mission").."|".. |
22 local objectives = loc("Go to the moon by using the flying saucer and complete the main mission").."|".. |
21 loc("Come back to this mission and visit the other planets to collect the crates").."|".. |
23 loc("Come back to this mission and visit the other planets to collect the crates").."|".. |
22 loc("Visit the Death Planet after completing all the other planets' main missions").."|".. |
24 loc("Visit the Death Planet after completing all the other planets' main missions").."|".. |
23 loc("Come back to this mission after collecting all the device parts") |
25 loc("Come back to this mission after collecting all the device parts") |
177 |
179 |
178 -- do checkpoint stuff needed after game starts |
180 -- do checkpoint stuff needed after game starts |
179 if checkPointReached == 1 then |
181 if checkPointReached == 1 then |
180 AddAnim(dialog01) |
182 AddAnim(dialog01) |
181 AddAmmo(hero.gear, amRope, 1) |
183 AddAmmo(hero.gear, amRope, 1) |
182 AddAmmo(guard1.gear, amDEagle, 2) |
184 AddAmmo(guard1.gear, amDEagle, 100) |
183 AddAmmo(guard2.gear, amDEagle, 2) |
185 AddAmmo(guard2.gear, amDEagle, 100) |
184 SpawnUtilityCrate(saucerX, saucerY, amJetpack) |
186 SpawnUtilityCrate(saucerX, saucerY, amJetpack) |
185 -- EVENT HANDLERS |
187 -- EVENT HANDLERS |
186 AddEvent(onHeroBeforeTreePosition, {hero.gear}, heroBeforeTreePosition, {hero.gear}, 0) |
188 AddEvent(onHeroBeforeTreePosition, {hero.gear}, heroBeforeTreePosition, {hero.gear}, 0) |
187 AddEvent(onHeroAtSaucerPosition, {hero.gear}, heroAtSaucerPosition, {hero.gear}, 0) |
189 AddEvent(onHeroAcquiredSaucer, {hero.gear}, heroAcquiredSaucer, {hero.gear}, 0) |
188 AddEvent(onHeroOutOfGuardSight, {hero.gear}, heroOutOfGuardSight, {hero.gear}, 0) |
190 AddEvent(onHeroOutOfGuardSight, {hero.gear}, heroOutOfGuardSight, {hero.gear}, 0) |
189 elseif checkPointReached == 2 then |
191 elseif checkPointReached == 2 then |
190 AddAmmo(hero.gear, amJetpack, 1) |
192 AddAmmo(hero.gear, amJetpack, 1) |
191 AddAnim(dialog02) |
193 AddAnim(dialog02) |
192 elseif checkPointReached == 3 then |
194 elseif checkPointReached == 3 then |
259 end |
261 end |
260 |
262 |
261 local abandonCheck = false |
263 local abandonCheck = false |
262 |
264 |
263 function onNewTurn() |
265 function onNewTurn() |
|
266 if saucerAcquired then |
|
267 -- The only way for the player to have a saucer at turn start is by having used the rope |
|
268 -- before; there's no other way to get it. We can therefore conclude the rope has been |
|
269 -- used. |
|
270 ropeDestroyed = true |
|
271 end |
264 if not abandonCheck and checkPointReached == 5 then |
272 if not abandonCheck and checkPointReached == 5 then |
265 if abandonedPlanetMission then |
273 if abandonedPlanetMission then |
266 HogSay(hero.gear, loc("I just forgot all checkpoints of incomplete missions."), SAY_THINK) |
274 HogSay(hero.gear, loc("I just forgot all checkpoints of incomplete missions."), SAY_THINK) |
267 end |
275 end |
268 abandonCheck = false |
276 abandonCheck = false |
269 end |
277 end |
270 |
278 |
271 if guard1.keepTurning then |
279 if CurrentHedgehog == hero.gear then |
272 AnimSwitchHog(hero.gear) |
280 -- Hero just got spotted by guards |
273 TurnTimeLeft = -1 |
281 if getReadyForRumble then |
274 end |
282 EndTurn(true) |
|
283 getReadyForRumble = false |
|
284 else |
|
285 if guard1.keepTurning then |
|
286 TurnTimeLeft = -1 |
|
287 end |
|
288 end |
|
289 elseif CurrentHedgehog == director.gear or CurrentHedgehog == doctor.gear then |
|
290 EndTurn(true) |
|
291 elseif (CurrentHedgehog == guard1.gear or CurrentHedgehog == guard2.gear) and guard1.keepTurning then |
|
292 EndTurn(true) |
|
293 end |
|
294 |
275 end |
295 end |
276 |
296 |
277 -------------- EVENTS ------------------ |
297 -------------- EVENTS ------------------ |
278 |
298 |
279 function onHeroBeforeTreePosition(gear) |
299 function onHeroBeforeTreePosition(gear) |
280 if GetHealth(hero.gear) and GetX(gear) > 2350 then |
300 if GetHealth(hero.gear) and GetX(gear) > 2350 then |
281 return true |
|
282 end |
|
283 return false |
|
284 end |
|
285 |
|
286 function onHeroAtSaucerPosition(gear) |
|
287 if GetHealth(hero.gear) and GetX(gear) >= saucerX-25 and GetX(gear) <= saucerX+32 and GetY(gear) >= saucerY-32 and GetY(gear) <= saucerY+32 then |
|
288 saucerAcquired = true |
|
289 end |
|
290 if saucerAcquired and GetHealth(hero.gear) and StoppedGear(gear) then |
|
291 return true |
301 return true |
292 end |
302 end |
293 return false |
303 return false |
294 end |
304 end |
295 |
305 |
376 function heroBeforeTreePosition(gear) |
386 function heroBeforeTreePosition(gear) |
377 AnimSay(gear,loc("Now I have to climb these trees"), SAY_SAY, 4000) |
387 AnimSay(gear,loc("Now I have to climb these trees"), SAY_SAY, 4000) |
378 AnimCaption(hero.gear, loc("Use the rope to get to the crate"), 4000) |
388 AnimCaption(hero.gear, loc("Use the rope to get to the crate"), 4000) |
379 end |
389 end |
380 |
390 |
381 function heroAtSaucerPosition(gear) |
391 function prepareDialog02(gear) |
382 if not saucerAcquired then |
392 if StoppedGear(gear) and guard1.keepTurning and checkPointReached < 2 then |
383 EndTurn(true) |
393 EndTurn(true) |
384 -- save check point |
394 -- save check point |
385 SaveCampaignVar("CosmosCheckPoint", "2") |
395 SaveCampaignVar("CosmosCheckPoint", "2") |
386 checkPointReached = 2 |
396 checkPointReached = 2 |
387 AddAnim(dialog02) |
397 AddAnim(dialog02) |
388 -- check if he was spotted by the guard |
398 end |
389 if guard1.turn and GetX(hero.gear) > saucerX-150 then |
399 end |
390 guard1.keepTurning = false |
400 |
391 AddAnim(dialog03) |
401 function heroAcquiredSaucer(gear) |
392 end |
402 SetGearMessage(hero.gear, 0) |
393 saucerAcquired = true |
403 -- check if he was spotted by the guard |
394 end |
404 if guard1.turn and guard1.keepTurning and GetX(hero.gear) > saucerX-150 then |
|
405 guard1.keepTurning = false |
|
406 SetGearVelocity(gear, 0, 0) |
|
407 AddAnim(dialog03) |
|
408 end |
|
409 |
|
410 prepareDialog02(gear) |
|
411 end |
|
412 |
|
413 function onHeroAcquiredSaucer(gear) |
|
414 return saucerAcquired |
395 end |
415 end |
396 |
416 |
397 function heroOutOfGuardSight(gear) |
417 function heroOutOfGuardSight(gear) |
|
418 SetGearMessage(hero.gear, 0) |
398 guard1.keepTurning = true |
419 guard1.keepTurning = true |
399 AddAnim(dialog04) |
420 AddAnim(dialog04) |
|
421 |
|
422 if onHeroAcquiredSaucer(gear) then |
|
423 prepareDialog02(gear) |
|
424 end |
400 end |
425 end |
401 |
426 |
402 function moonLanding(gear) |
427 function moonLanding(gear) |
403 if checkPointReached == 1 then |
428 if checkPointReached == 1 and not ropeDestroyed then |
404 -- player climbed the moon with rope |
429 -- player climbed the moon with rope |
405 FollowGear(doctor.gear) |
430 FollowGear(doctor.gear) |
406 AnimSay(doctor.gear, loc("One does not simply rope to the moon!"), SAY_SHOUT, 4000) |
431 AnimSay(doctor.gear, loc("One does not simply rope to the moon!"), SAY_SHOUT, 4000) |
407 SendStat(siGameResult, loc("This is the wrong way!")) |
432 SendStat(siGameResult, loc("This is the wrong way!")) |
408 SendStat(siCustomAchievement, loc("Collect the crate with the flying saucer!")) |
433 SendStat(siCustomAchievement, loc("Collect the crate with the flying saucer!")) |
557 -------------- ANIMATIONS ------------------ |
582 -------------- ANIMATIONS ------------------ |
558 |
583 |
559 function Skipanim(anim) |
584 function Skipanim(anim) |
560 if goals[anim] ~= nil then |
585 if goals[anim] ~= nil then |
561 ShowMission(unpack(goals[anim])) |
586 ShowMission(unpack(goals[anim])) |
562 end |
587 end |
563 if CurrentHedgehog ~= hero.gear and anim ~= dialog03 then |
588 if CurrentHedgehog ~= hero.gear and anim ~= dialog03 then |
564 AnimSwitchHog(hero.gear) |
589 AnimSwitchHog(hero.gear) |
565 elseif anim == dialog03 then |
590 elseif anim == dialog03 then |
566 startCombat() |
591 startCombat() |
567 elseif anim == dialog05 or anim == dialog06 then |
592 elseif anim == dialog05 or anim == dialog06 then |
568 sendStatsOnRetry() |
593 sendStatsOnRetry() |
594 table.insert(dialog02, {func = AnimSay, args = {director.gear, loc("Nice!"), SAY_SHOUT, 1000}}) |
619 table.insert(dialog02, {func = AnimSay, args = {director.gear, loc("Nice!"), SAY_SHOUT, 1000}}) |
595 table.insert(dialog02, {func = AnimSay, args = {director.gear, loc("Now use it and go to the moon PAotH station to get more fuel!"), SAY_SHOUT, 5000}}) |
620 table.insert(dialog02, {func = AnimSay, args = {director.gear, loc("Now use it and go to the moon PAotH station to get more fuel!"), SAY_SHOUT, 5000}}) |
596 table.insert(dialog02, {func = AnimGearWait, args = {hero.gear, 500}}) |
621 table.insert(dialog02, {func = AnimGearWait, args = {hero.gear, 500}}) |
597 -- DIALOG 03 - Hero got spotted by guard |
622 -- DIALOG 03 - Hero got spotted by guard |
598 AddSkipFunction(dialog03, Skipanim, {dialog03}) |
623 AddSkipFunction(dialog03, Skipanim, {dialog03}) |
599 table.insert(dialog03, {func = AnimWait, args = {guard1.gear, 4000}}) |
624 table.insert(dialog03, {func = AnimWait, args = {guard1.gear, 500}}) |
600 table.insert(dialog03, {func = AnimCaption, args = {guard1.gear, loc("Prepare to flee!"), 4000}}) |
625 table.insert(dialog03, {func = AnimCaption, args = {guard1.gear, loc("Prepare to flee!"), 1000}}) |
601 table.insert(dialog03, {func = AnimSay, args = {guard1.gear, string.format(loc("Hey, %s! Look, someone is stealing the saucer!"), guard2.name), SAY_SHOUT, 4000}}) |
626 table.insert(dialog03, {func = AnimSay, args = {guard1.gear, string.format(loc("Hey, %s! Look, someone is stealing the saucer!"), guard2.name), SAY_SHOUT, 4000}}) |
602 table.insert(dialog03, {func = AnimSay, args = {guard2.gear, loc("I'll get him!"), SAY_SAY, 4000}}) |
627 table.insert(dialog03, {func = AnimSay, args = {guard2.gear, loc("I'll get him!"), SAY_SAY, 4000}}) |
603 table.insert(dialog03, {func = startCombat, args = {guard1.gear}}) |
628 table.insert(dialog03, {func = startCombat, args = {guard1.gear}}) |
604 -- DIALOG 04 - Hero out of sight |
629 -- DIALOG 04 - Hero out of sight |
605 AddSkipFunction(dialog04, Skipanim, {dialog04}) |
630 AddSkipFunction(dialog04, Skipanim, {dialog04}) |
638 end |
663 end |
639 |
664 |
640 ------------------- custom "animation" functions -------------------------- |
665 ------------------- custom "animation" functions -------------------------- |
641 |
666 |
642 function startCombat() |
667 function startCombat() |
643 -- use this so guard2 will gain control |
668 -- Use this so guard2 gains control |
644 AnimSwitchHog(hero.gear) |
|
645 EndTurn(true) |
669 EndTurn(true) |
|
670 getReadyForRumble = true |
646 end |
671 end |
647 |
672 |
648 function sendStats(planetMsg) |
673 function sendStats(planetMsg) |
649 SendStat(siGameResult, planetMsg) |
674 SendStat(siGameResult, planetMsg) |
650 SendStat(siCustomAchievement, loc("Return to the mission menu by pressing the \"Go back\" button.")) |
675 SendStat(siCustomAchievement, loc("Return to the mission menu by pressing the \"Go back\" button.")) |