21 |
21 |
22 ----------------- VARIABLES -------------------- |
22 ----------------- VARIABLES -------------------- |
23 -- globals |
23 -- globals |
24 local missionName = loc("Bad timing") |
24 local missionName = loc("Bad timing") |
25 local chooseToBattle = false |
25 local chooseToBattle = false |
|
26 local awaitingInput = false |
26 local previousHog = 0 |
27 local previousHog = 0 |
27 local heroPlayedFirstTurn = false |
28 local heroPlayedFirstTurn = false |
28 local startBattleCalled = false |
29 local startBattleCalled = false |
29 -- dialogs |
30 -- dialogs |
30 local dialog01 = {} |
31 local dialog01 = {} |
31 local dialog02 = {} |
32 local dialog02 = {} |
32 local dialog03 = {} |
33 local dialog03 = {} |
|
34 |
33 -- mission objectives |
35 -- mission objectives |
34 local goals = { |
36 local goals = { |
35 [dialog01] = {missionName, loc("Ready for Battle?"), loc("Walk left if you want to join Captain Lime or right if you want to decline his offer."), 1, 7000}, |
37 [dialog01] = {missionName, loc("Ready for Battle?"), |
36 [dialog02] = {missionName, loc("Battle Starts Now!"), loc("You have chosen to fight! Lead the Green Bananas to battle and eliminate all the enemies!"), 1, 7000}, |
38 loc("Captain Lime offered his help if you assist him in battle.").."|".. |
37 [dialog03] = {missionName, loc("Time to run!"), loc("You have chosen to flee ... Unfortunately, the only place where you can launch your saucer is the left-most place on the map."), 1, 7000}, |
39 loc("What do you want to do?").."| |".. |
|
40 loc("Fight: Press [Left]").."|".. |
|
41 loc("Flee: Press [Right]"), 1, 9999000}, |
|
42 [dialog02] = {missionName, loc("Battle Starts Now!"), loc("You have chosen to fight!").."|"..loc("Lead the Green Bananas to battle and eliminate all the enemies!"), 1, 7000}, |
|
43 [dialog03] = {missionName, loc("Time to run!"), loc("You have chosen to flee.").."|"..loc("You have to reach the left-most place on the map."), 1, 7000}, |
|
44 ["fight"] = {missionName, loc("Ready for Battle?"), loc("You have chosen to fight!"), 1, 1500}, |
|
45 ["flee"] = {missionName, loc("Ready for Battle?"), loc("You have chosen to flee."), 1, 1500}, |
38 } |
46 } |
39 -- crates |
47 -- crates |
40 local crateWMX = 2170 |
48 local crateWMX = 2170 |
41 local crateWMY = 1950 |
49 local crateWMY = 1950 |
42 local health1X = 2680 |
50 local health1X = 2680 |
150 AnimInit(true) |
158 AnimInit(true) |
151 AnimationSetup() |
159 AnimationSetup() |
152 end |
160 end |
153 |
161 |
154 function onGameStart() |
162 function onGameStart() |
|
163 AnimSetInputMask(0) |
155 AnimWait(hero.gear, 3000) |
164 AnimWait(hero.gear, 3000) |
156 FollowGear(hero.gear) |
165 FollowGear(hero.gear) |
157 |
166 |
158 AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) |
167 AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) |
159 AddEvent(onHeroSelect, {hero.gear}, heroSelect, {hero.gear}, 0) |
|
160 |
168 |
161 -- Green team weapons |
169 -- Green team weapons |
162 local greenArmy = { green1, green2 } |
170 local greenArmy = { green1, green2 } |
163 for i=1,2 do |
171 for i=1,2 do |
164 AddAmmo(greenArmy[i].gear, amBlowTorch, 5) |
172 AddAmmo(greenArmy[i].gear, amBlowTorch, 5) |
342 SendStat(siCustomAchievement, loc("You have reached the take-off area successfully!")) |
343 SendStat(siCustomAchievement, loc("You have reached the take-off area successfully!")) |
343 sendSimpleTeamRankings({teamA.name, teamD.name, teamB.name, teamC.name}) |
344 sendSimpleTeamRankings({teamA.name, teamD.name, teamB.name, teamC.name}) |
344 EndGame() |
345 EndGame() |
345 end |
346 end |
346 |
347 |
347 function heroSelect(gear) |
348 function heroSelect() |
348 EndTurn(true) |
349 awaitingInput = false |
349 FollowGear(hero.gear) |
350 FollowGear(hero.gear) |
350 if GetX(hero.gear) < hero.x then |
351 if chooseToBattle == true then |
351 chooseToBattle = true |
352 chooseToBattle = true |
|
353 ShowMission(unpack(goals["fight"])) |
352 AddEvent(onGreen1Death, {green1.gear}, green1Death, {green1.gear}, 0) |
354 AddEvent(onGreen1Death, {green1.gear}, green1Death, {green1.gear}, 0) |
353 AddEvent(onBattleWin, {hero.gear}, battleWin, {hero.gear}, 0) |
355 AddEvent(onBattleWin, {hero.gear}, battleWin, {hero.gear}, 0) |
354 AddAnim(dialog02) |
356 AddAnim(dialog02) |
355 elseif GetX(hero.gear) > hero.x then |
357 else |
356 HogTurnLeft(hero.gear, true) |
358 ShowMission(unpack(goals["flee"])) |
357 AddAmmo(green1.gear, amSwitch, 100) |
359 AddAmmo(green1.gear, amSwitch, 100) |
358 AddEvent(onEscapeWin, {hero.gear}, escapeWin, {hero.gear}, 0) |
360 AddEvent(onEscapeWin, {hero.gear}, escapeWin, {hero.gear}, 0) |
359 local greenTeam = { green2, green3, green4, green5 } |
361 local greenTeam = { green2, green3, green4, green5 } |
360 for i=1,4 do |
362 for i=1,4 do |
361 SetHogLevel(greenTeam[i].gear, 1) |
363 SetHogLevel(greenTeam[i].gear, 1) |
364 end |
366 end |
365 end |
367 end |
366 |
368 |
367 -------------- ANIMATIONS ------------------ |
369 -------------- ANIMATIONS ------------------ |
368 |
370 |
|
371 function AfterDialog01() |
|
372 AnimSwitchHog(hero.gear) |
|
373 awaitingInput = true |
|
374 end |
|
375 |
369 function Skipanim(anim) |
376 function Skipanim(anim) |
370 if goals[anim] ~= nil then |
377 if goals[anim] ~= nil then |
371 ShowMission(unpack(goals[anim])) |
378 ShowMission(unpack(goals[anim])) |
372 end |
379 end |
373 if anim == dialog01 then |
380 if anim == dialog01 then |
374 AnimSwitchHog(hero.gear) |
381 AfterDialog01() |
375 elseif anim == dialog02 or anim == dialog03 then |
382 elseif anim == dialog02 or anim == dialog03 then |
376 startBattle() |
383 startBattle() |
377 end |
384 end |
378 end |
385 end |
379 |
386 |
380 function AnimationSetup() |
387 function AnimationSetup() |
381 -- DIALOG 01 - Start, Captain Lime talks explains to Hog Solo |
388 -- DIALOG 01 - Start, Captain Lime talks explains to Hog Solo |
382 AddSkipFunction(dialog01, Skipanim, {dialog01}) |
389 AddSkipFunction(dialog01, Skipanim, {dialog01}) |
383 table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}}) |
390 table.insert(dialog01, {func = AnimWait, args = {hero.gear, 1000}}) |
384 table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Somewhere on the Planet of Fruits a terrible war is about to begin ..."), 5000}}) |
391 table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Somewhere on the Planet of Fruits a terrible war is about to begin ..."), 5000}}) |
385 table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("I was told that as the leader of the king's guard, no one knows this world better than you!"), SAY_SAY, 5000}}) |
392 table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("I was told that as the leader of the king's guard, no one knows this world better than you!"), SAY_SAY, 5000}}) |
386 table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("So, I kindly ask for your help."), SAY_SAY, 3000}}) |
393 table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("So, I kindly ask for your help."), SAY_SAY, 3000}}) |
387 table.insert(dialog01, {func = AnimWait, args = {green1.gear, 2000}}) |
394 table.insert(dialog01, {func = AnimWait, args = {green1.gear, 2000}}) |
388 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("You couldn't have come to a worse time, Hog Solo!"), SAY_SAY, 3000}}) |
395 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("You couldn't have come to a worse time, Hog Solo!"), SAY_SAY, 3000}}) |
391 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("However, the army of Yellow Watermelons is about to attack any moment now."), SAY_SAY, 4000}}) |
398 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("However, the army of Yellow Watermelons is about to attack any moment now."), SAY_SAY, 4000}}) |
392 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("I would gladly help you if we won this battle but under these circumstances I'll only help you if you fight for our side."), SAY_SAY, 6000}}) |
399 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("I would gladly help you if we won this battle but under these circumstances I'll only help you if you fight for our side."), SAY_SAY, 6000}}) |
393 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("What do you say? Will you fight for us?"), SAY_SAY, 3000}}) |
400 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("What do you say? Will you fight for us?"), SAY_SAY, 3000}}) |
394 table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}}) |
401 table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}}) |
395 table.insert(dialog01, {func = ShowMission, args = goals[dialog01]}) |
402 table.insert(dialog01, {func = ShowMission, args = goals[dialog01]}) |
396 table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}}) |
403 table.insert(dialog01, {func = AfterDialog01, args = {}}) |
397 -- DIALOG 02 - Hero selects to fight |
404 -- DIALOG 02 - Hero selects to fight |
398 AddSkipFunction(dialog02, Skipanim, {dialog02}) |
405 AddSkipFunction(dialog02, Skipanim, {dialog02}) |
399 table.insert(dialog02, {func = AnimWait, args = {green1.gear, 3000}}) |
406 table.insert(dialog02, {func = AnimWait, args = {green1.gear, 400}}) |
400 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("You choose well, Hog Solo!"), SAY_SAY, 3000}}) |
407 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("You choose well, Hog Solo!"), SAY_SAY, 3000}}) |
401 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("I have only 3 hogs available and they are all cadets."), SAY_SAY, 4000}}) |
408 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("I have only 3 hogs available and they are all cadets."), SAY_SAY, 4000}}) |
402 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("As you are more experienced, I want you to lead them to battle."), SAY_SAY, 4000}}) |
409 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("As you are more experienced, I want you to lead them to battle."), SAY_SAY, 4000}}) |
403 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("Of course, I will observe the battle and intervene if necessary."), SAY_SAY, 5000}}) |
410 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("Of course, I will observe the battle and intervene if necessary."), SAY_SAY, 5000}}) |
404 table.insert(dialog02, {func = AnimWait, args = {hero.gear, 4500}}) |
411 table.insert(dialog02, {func = AnimWait, args = {hero.gear, 4500}}) |
410 table.insert(dialog02, {func = AnimWait, args = {hero.gear, 5000}}) |
417 table.insert(dialog02, {func = AnimWait, args = {hero.gear, 5000}}) |
411 table.insert(dialog02, {func = ShowMission, args = goals[dialog02]}) |
418 table.insert(dialog02, {func = ShowMission, args = goals[dialog02]}) |
412 table.insert(dialog02, {func = startBattle, args = {hero.gear}}) |
419 table.insert(dialog02, {func = startBattle, args = {hero.gear}}) |
413 -- DIALOG 03 - Hero selects to flee |
420 -- DIALOG 03 - Hero selects to flee |
414 AddSkipFunction(dialog03, Skipanim, {dialog03}) |
421 AddSkipFunction(dialog03, Skipanim, {dialog03}) |
415 table.insert(dialog03, {func = AnimWait, args = {green1.gear, 3000}}) |
422 table.insert(dialog03, {func = AnimWait, args = {green1.gear, 400}}) |
416 table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("Too bad! Then you should really leave!"), SAY_SAY, 3000}}) |
423 table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("Too bad! Then you should really leave!"), SAY_SAY, 3000}}) |
417 table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("Things are going to get messy around here."), SAY_SAY, 3000}}) |
424 table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("Things are going to get messy around here."), SAY_SAY, 3000}}) |
418 table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("Also, you should know that the only place where you can fly is the left-most part of this area."), SAY_SAY, 5000}}) |
425 table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("Also, you should know that the only place where you can fly is the left-most part of this area."), SAY_SAY, 5000}}) |
419 table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("All the other places are protected by our flight-inhibiting weapons."), SAY_SAY, 4000}}) |
426 table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("All the other places are protected by our flight-inhibiting weapons."), SAY_SAY, 4000}}) |
420 table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("Now go and don't waste more of my time, you coward!"), SAY_SAY, 4000}}) |
427 table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("Now go and don't waste more of my time, you coward!"), SAY_SAY, 4000}}) |
424 end |
431 end |
425 |
432 |
426 ------------- OTHER FUNCTIONS --------------- |
433 ------------- OTHER FUNCTIONS --------------- |
427 |
434 |
428 function startBattle() |
435 function startBattle() |
|
436 AnimSetInputMask(0xFFFFFFFF) |
429 -- Hog Solo weapons |
437 -- Hog Solo weapons |
430 AddAmmo(hero.gear, amRope, 2) |
438 AddAmmo(hero.gear, amRope, 2) |
431 AddAmmo(hero.gear, amBazooka, 3) |
439 AddAmmo(hero.gear, amBazooka, 3) |
432 AddAmmo(hero.gear, amParachute, 1) |
440 AddAmmo(hero.gear, amParachute, 1) |
433 AddAmmo(hero.gear, amGrenade, 6) |
441 AddAmmo(hero.gear, amGrenade, 6) |