18 local campaignName = loc("A Space Adventure") |
18 local campaignName = loc("A Space Adventure") |
19 local missionName = loc("Searching in the dust") |
19 local missionName = loc("Searching in the dust") |
20 local heroIsInBattle = false |
20 local heroIsInBattle = false |
21 local ongoingBattle = 0 |
21 local ongoingBattle = 0 |
22 local cratesFound = 0 |
22 local cratesFound = 0 |
|
23 local ropeGear = nil |
23 -- dialogs |
24 -- dialogs |
24 local dialog01 = {} |
25 local dialog01 = {} |
25 -- mission objectives |
26 -- mission objectives |
26 local goals = { |
27 local goals = { |
27 [dialog01] = {missionName, loc("Getting ready"), loc("The device part is hidden in one of the crates! Go and get it!").."|".. |
28 [dialog01] = {missionName, loc("Getting ready"), loc("The device part is hidden in one of the crates! Go and get it!").."|".. |
234 SetAmmo(amPortalGun, 0, 0, 0, 1) |
235 SetAmmo(amPortalGun, 0, 0, 0, 1) |
235 SetAmmo(amGirder, 0, 0, 0, 3) |
236 SetAmmo(amGirder, 0, 0, 0, 3) |
236 SetAmmo(amSkip, 9, 0, 0, 1) |
237 SetAmmo(amSkip, 9, 0, 0, 1) |
237 end |
238 end |
238 |
239 |
|
240 function onGearAdd(gear) |
|
241 if GetGearType(gear) == gtRope then |
|
242 ropeGear = gear |
|
243 end |
|
244 end |
|
245 |
239 function onGearDelete(gear) |
246 function onGearDelete(gear) |
|
247 if GetGearType(gear) == gtRope then |
|
248 ropeGear = nil |
|
249 end |
240 local foundDeviceCrateCandidate = function(candidate_crate_table, other_crate_table) |
250 local foundDeviceCrateCandidate = function(candidate_crate_table, other_crate_table) |
241 candidate_crate_table.deleted = true |
251 candidate_crate_table.deleted = true |
242 -- Evaluates to false if crate has been collected |
252 -- Evaluates to false if crate has been collected |
243 if (band(GetGearMessage(candidate_crate_table.gear), gmDestroy) == 0) then |
253 if (band(GetGearMessage(candidate_crate_table.gear), gmDestroy) == 0) then |
244 candidate_crate_table.destroyed = true |
254 candidate_crate_table.destroyed = true |
358 lose() |
368 lose() |
359 end |
369 end |
360 |
370 |
361 function heroAtFirstBattle(gear) |
371 function heroAtFirstBattle(gear) |
362 AnimCaption(hero.gear, loc("A smuggler! Prepare for battle"), 5000) |
372 AnimCaption(hero.gear, loc("A smuggler! Prepare for battle"), 5000) |
363 -- Hog gets scared if on rope |
|
364 if GetGearElasticity(hero.gear) ~= 0 then |
|
365 HogSay(hero.gear, loc("Gasp! A smuggler!"), SAY_SHOUT) |
|
366 end |
|
367 -- Remember velocity to restore it later |
373 -- Remember velocity to restore it later |
368 local dx, dy = GetGearVelocity(hero.gear) |
374 local dx, dy = GetGearVelocity(hero.gear) |
|
375 -- Hog gets scared if on rope |
|
376 if isOnRope() then |
|
377 PlaySound(sndRopeRelease) |
|
378 HogSay(hero.gear, loc("Gasp! A smuggler!"), SAY_SHOUT) |
|
379 dx = div(dx, 3) |
|
380 dy = div(dy, 3) |
|
381 end |
369 EndTurn(true) |
382 EndTurn(true) |
370 heroIsInBattle = true |
383 heroIsInBattle = true |
371 ongoingBattle = 1 |
384 ongoingBattle = 1 |
372 AnimSwitchHog(smuggler1.gear) |
385 AnimSwitchHog(smuggler1.gear) |
373 EndTurn(true) |
386 EndTurn(true) |
391 |
404 |
392 function heroAtThirdBattle(gear) |
405 function heroAtThirdBattle(gear) |
393 heroIsInBattle = true |
406 heroIsInBattle = true |
394 ongoingBattle = 3 |
407 ongoingBattle = 3 |
395 AnimSay(smuggler3.gear, loc("Who's there?! I'll get you!"), SAY_SHOUT, 5000) |
408 AnimSay(smuggler3.gear, loc("Who's there?! I'll get you!"), SAY_SHOUT, 5000) |
|
409 local dx, dy = GetGearVelocity(hero.gear) |
396 -- Hog gets scared and falls from rope |
410 -- Hog gets scared and falls from rope |
397 if GetGearElasticity(hero.gear) ~= 0 then |
411 if isOnRope() then |
|
412 PlaySound(sndRopeRelease) |
398 HogSay(hero.gear, loc("Yikes!"), SAY_SHOUT) |
413 HogSay(hero.gear, loc("Yikes!"), SAY_SHOUT) |
399 end |
414 dx = div(dx, 3) |
400 local dx, dy = GetGearVelocity(hero.gear) |
415 dy = div(dy, 3) |
|
416 end |
401 AnimSwitchHog(smuggler3.gear) |
417 AnimSwitchHog(smuggler3.gear) |
402 EndTurn(true) |
418 EndTurn(true) |
403 SetGearVelocity(hero.gear, dx, dy) |
419 SetGearVelocity(hero.gear, dx, dy) |
404 end |
420 end |
405 |
421 |
454 table.insert(dialog01, {func = startMission, args = {hero.gear}}) |
470 table.insert(dialog01, {func = startMission, args = {hero.gear}}) |
455 end |
471 end |
456 |
472 |
457 --------------- OTHER FUNCTIONS ------------------ |
473 --------------- OTHER FUNCTIONS ------------------ |
458 |
474 |
|
475 function isOnRope() |
|
476 if ropeGear then |
|
477 return true |
|
478 end |
|
479 return false |
|
480 end |
|
481 |
459 function startMission() |
482 function startMission() |
460 AnimSwitchHog(ally.gear) |
483 AnimSwitchHog(ally.gear) |
461 EndTurn(true) |
484 EndTurn(true) |
462 end |
485 end |
463 |
486 |
464 function secondBattle() |
487 function secondBattle() |
465 -- second battle |
488 -- second battle |
466 if heroIsInBattle and ongoingBattle == 1 then |
489 if heroIsInBattle and ongoingBattle == 1 then |
467 AnimSay(smuggler1.gear, loc("Get him, Spike!"), SAY_SHOUT, 4000) |
490 AnimSay(smuggler1.gear, loc("Get him, Spike!"), SAY_SHOUT, 4000) |
468 end |
491 end |
|
492 local dx, dy = GetGearVelocity(hero.gear) |
469 -- Hog gets scared if on rope |
493 -- Hog gets scared if on rope |
470 if GetGearElasticity(hero.gear) ~= 0 then |
494 if isOnRope() then |
|
495 PlaySound(sndRopeRelease) |
471 HogSay(hero.gear, loc("Gasp!"), SAY_SHOUT) |
496 HogSay(hero.gear, loc("Gasp!"), SAY_SHOUT) |
472 end |
497 dx = div(dx, 3) |
473 local dx, dy = GetGearVelocity(hero.gear) |
498 dy = div(dy, 3) |
|
499 end |
474 heroIsInBattle = true |
500 heroIsInBattle = true |
475 ongoingBattle = 2 |
501 ongoingBattle = 2 |
476 AnimSay(smuggler2.gear, loc("This is seems like a wealthy hedgehog, nice ..."), SAY_THINK, 5000) |
502 AnimSay(smuggler2.gear, loc("This is seems like a wealthy hedgehog, nice ..."), SAY_THINK, 5000) |
477 AnimSwitchHog(smuggler2.gear) |
503 AnimSwitchHog(smuggler2.gear) |
478 EndTurn(true) |
504 EndTurn(true) |