20 local dialog03 = {} |
20 local dialog03 = {} |
21 local dialog04 = {} |
21 local dialog04 = {} |
22 local dialog05 = {} |
22 local dialog05 = {} |
23 -- mission objectives |
23 -- mission objectives |
24 local minesTimeText = loc("Mines time: 0 seconds") |
24 local minesTimeText = loc("Mines time: 0 seconds") |
25 local goals = { |
25 local goals |
26 [dialog01] = {missionName, loc("Exploring the tunnel"), loc("Search for the device with the help of the other hedgehogs ").."|"..loc("Hog Solo has to reach the last crates") .. "|" .. minesTimeText, 1, 4000}, |
|
27 [dialog02] = {missionName, loc("Exploring the tunnel"), loc("Explore the tunnel with the other hedgehogs and search for the device").."|"..loc("Hog Solo has to reach the last crates") .. "|" .. minesTimeText, 1, 4000}, |
|
28 [dialog03] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack Captain Lime before he attacks back").."|"..minesTimeText, 1, 4000}, |
|
29 [dialog04] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack the assassins before they attack back").."|"..minesTimeText, 1, 4000}, |
|
30 } |
|
31 -- crates |
26 -- crates |
32 local girderCrate = {name = amGirder, x = 1680, y = 1160} |
27 local girderCrate = {name = amGirder, x = 1680, y = 1160} |
33 |
28 |
34 local eagleCrate = {name = amDEagle, x = 1680, y = 1650} |
29 local eagleCrate = {name = amDEagle, x = 1680, y = 1650} |
35 |
30 |
99 -- Fruit Assassins |
97 -- Fruit Assassins |
100 local assasinsHats = { "NinjaFull", "NinjaStraight", "NinjaTriangle" } |
98 local assasinsHats = { "NinjaFull", "NinjaStraight", "NinjaTriangle" } |
101 AddTeam(teamC.name, teamC.color, "bp2", "Island", "Default", "cm_scout") |
99 AddTeam(teamC.name, teamC.color, "bp2", "Island", "Default", "cm_scout") |
102 for i=1,table.getn(redHedgehogs) do |
100 for i=1,table.getn(redHedgehogs) do |
103 redHedgehogs[i].gear = AddHog(redHedgehogs[i].name, 1, 100, assasinsHats[GetRandom(3)+1]) |
101 redHedgehogs[i].gear = AddHog(redHedgehogs[i].name, 1, 100, assasinsHats[GetRandom(3)+1]) |
104 AnimSetGearPosition(redHedgehogs[i].gear, 2010 + 50*i, 630) |
102 SetGearPosition(redHedgehogs[i].gear, 2010 + 50*i, 630) |
105 end |
103 end |
106 local assassinsColor = div(GetClanColor(GetHogClan(redHedgehogs[1].gear)), 0x100) |
104 local assassinsColor = div(GetClanColor(GetHogClan(redHedgehogs[1].gear)), 0x100) |
107 |
105 |
108 -- Hog Solo and Green Bananas |
106 -- Hero and Green Bananas |
109 AddTeam(teamA.name, teamA.color, "Simple", "Island", "Default", "hedgehog") |
107 teamA.name = AddMissionTeam(teamA.color) |
110 hero.gear = AddHog(hero.name, 0, health, "war_desertgrenadier1") |
108 hero.gear = AddMissionHog(health) |
111 AnimSetGearPosition(hero.gear, hero.x, hero.y) |
109 hero.name = GetHogName(hero.gear) |
|
110 SetHogTeamName(hero.gear, string.format(loc("%s and GB"), teamA.name)) |
|
111 teamA.name = GetHogTeamName(hero.gear) |
|
112 SetGearPosition(hero.gear, hero.x, hero.y) |
112 HogTurnLeft(hero.gear, true) |
113 HogTurnLeft(hero.gear, true) |
113 green2.gear = AddHog(green2.name, 0, 100, "war_britmedic") |
114 local heroColor = div(GetClanColor(GetHogClan(hero.gear)), 0x100) |
114 AnimSetGearPosition(green2.gear, green2.x, green2.y) |
115 |
|
116 -- companions |
|
117 -- Change companion identity if they have same name as hero |
|
118 -- to avoid confusion. |
|
119 if green2.name == hero.name then |
|
120 green2.name = loc("Green Hog Grape") |
|
121 green2.hat = "war_desertsapper1" |
|
122 elseif green3.name == hero.name then |
|
123 green3.name = loc("Green Hog Grape") |
|
124 green3.hat = "war_desertsapper1" |
|
125 end |
|
126 green2.gear = AddHog(green2.name, 0, 100, green2.hat) |
|
127 SetGearPosition(green2.gear, green2.x, green2.y) |
115 HogTurnLeft(green2.gear, true) |
128 HogTurnLeft(green2.gear, true) |
116 green3.gear = AddHog(green3.name, 0, 100, "hair_red") |
129 |
117 AnimSetGearPosition(green3.gear, green3.x, green3.y) |
130 green3.gear = AddHog(green3.name, 0, 100, green3.hat) |
|
131 SetGearPosition(green3.gear, green3.x, green3.y) |
118 HogTurnLeft(green3.gear, true) |
132 HogTurnLeft(green3.gear, true) |
119 local heroColor = div(GetClanColor(GetHogClan(hero.gear)), 0x100) |
|
120 |
133 |
121 -- Captain Lime |
134 -- Captain Lime |
122 -- Returns a color that is as close as possible to the color argument |
135 -- Returns a color that is as close as possible to the color argument |
123 -- but does not equal color and otherCollision. |
136 -- but does not equal color and otherCollision. |
124 local getSimilarColor = function(color, otherCollision) |
137 local getSimilarColor = function(color, otherCollision) |
138 end |
151 end |
139 -- Captain Lime gets a fake color clore to hero's clan color. |
152 -- Captain Lime gets a fake color clore to hero's clan color. |
140 -- This is a hack, but it works. See explanation at top of file |
153 -- This is a hack, but it works. See explanation at top of file |
141 local cptnColor = getSimilarColor(heroColor, assassinsColor) |
154 local cptnColor = getSimilarColor(heroColor, assassinsColor) |
142 AddTeam(teamB.name, cptnColor, "Cherry", "Island", "Default", "congo-brazzaville") |
155 AddTeam(teamB.name, cptnColor, "Cherry", "Island", "Default", "congo-brazzaville") |
143 green1.gear= AddHog(green1.name, 0, 100, "war_desertofficer") |
156 green1.gear= AddHog(green1.name, 0, 100, green1.hat) |
144 AnimSetGearPosition(green1.gear, green1.x, green1.y) |
157 SetGearPosition(green1.gear, green1.x, green1.y) |
|
158 |
|
159 -- Populate goals table |
|
160 goals = { |
|
161 [dialog01] = {missionName, loc("Exploring the tunnel"), loc("Search for the device with the help of the other hedgehogs.").."|"..string.format(loc("%s must collect the final crates."), hero.name) .. "|" .. minesTimeText, 1, 4000}, |
|
162 [dialog02] = {missionName, loc("Exploring the tunnel"), loc("Explore the tunnel with the other hedgehogs and search for the device.").."|"..string.format(loc("%s must collect the final crates."), hero.name) .. "|" .. minesTimeText, 1, 4000}, |
|
163 [dialog03] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack Captain Lime before he attacks back.").."|"..minesTimeText, 1, 4000}, |
|
164 [dialog04] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack the assassins before they attack back.").."|"..minesTimeText, 1, 4000}, |
|
165 } |
145 |
166 |
146 AnimInit(true) |
167 AnimInit(true) |
147 AnimationSetup() |
168 AnimationSetup() |
148 end |
169 end |
149 |
170 |
156 end |
177 end |
157 |
178 |
158 AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) |
179 AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) |
159 AddEvent(onDeviceCrates, {hero.gear}, deviceCrateEvent, {hero.gear}, 0) |
180 AddEvent(onDeviceCrates, {hero.gear}, deviceCrateEvent, {hero.gear}, 0) |
160 |
181 |
161 -- Hog Solo and GB weapons |
182 -- Hero and Green Bananas weapons |
162 AddAmmo(hero.gear, amSwitch, 100) |
183 AddAmmo(hero.gear, amSwitch, 100) |
163 -- Assassins weapons |
184 -- Assassins weapons |
164 AddAmmo(redHedgehogs[1].gear, amBazooka, 6) |
185 AddAmmo(redHedgehogs[1].gear, amBazooka, 6) |
165 AddAmmo(redHedgehogs[1].gear, amGrenade, 6) |
186 AddAmmo(redHedgehogs[1].gear, amGrenade, 6) |
166 AddAmmo(redHedgehogs[1].bot, amDEagle, 6) |
187 AddAmmo(redHedgehogs[1].bot, amDEagle, 6) |
361 -------------- ACTIONS ------------------ |
382 -------------- ACTIONS ------------------ |
362 ended = false |
383 ended = false |
363 |
384 |
364 function heroDeath(gear) |
385 function heroDeath(gear) |
365 if not ended then |
386 if not ended then |
366 SendStat(siGameResult, loc("Hog Solo lost, try again!")) |
387 SendStat(siGameResult, string.format(loc("%s lost, try again!"), hero.name)) |
367 SendStat(siCustomAchievement, loc("To win the game, Hog Solo has to get the bottom crates and come back to the surface.")) |
388 SendStat(siCustomAchievement, string.format(loc("To win the game, %s has to get the bottom crates and come back to the surface."), hero.name)) |
368 SendStat(siCustomAchievement, loc("You can use the other 2 hogs to assist you.")) |
389 SendStat(siCustomAchievement, loc("You can use the other 2 hogs to assist you.")) |
369 SendStat(siCustomAchievement, loc("Do not destroy the crates!")) |
390 SendStat(siCustomAchievement, loc("Do not destroy the crates!")) |
370 if tookPartInBattle then |
391 if tookPartInBattle then |
371 if permitCaptainLimeDeath then |
392 if permitCaptainLimeDeath then |
372 SendStat(siCustomAchievement, loc("You'll have to eliminate the Fruit Assassins at the end.")) |
393 SendStat(siCustomAchievement, string.format(loc("You'll have to eliminate %s at the end."), teamC.name)) |
373 sendSimpleTeamRankings({teamC.name, teamA.name}) |
394 sendSimpleTeamRankings({teamC.name, teamA.name}) |
374 else |
395 else |
375 sendSimpleTeamRankings({teamA.name}) |
396 sendSimpleTeamRankings({teamA.name}) |
376 end |
397 end |
377 else |
398 else |
471 EndTurn(true) |
492 EndTurn(true) |
472 end |
493 end |
473 end |
494 end |
474 |
495 |
475 function AnimationSetup() |
496 function AnimationSetup() |
476 -- DIALOG 01 - Start, Captain Lime helps Hog Solo because he took part in the battle |
497 -- DIALOG 01 - Start, Captain Lime helps the hero because he took part in the battle |
477 AddSkipFunction(dialog01, Skipanim, {dialog01}) |
498 AddSkipFunction(dialog01, Skipanim, {dialog01}) |
478 table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}}) |
499 table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}}) |
479 table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Somewhere else on the planet of fruits, Captain Lime helps Hog Solo"), 5000}}) |
500 table.insert(dialog01, {func = AnimCaption, args = {hero.gear, string.format(loc("Somewhere else on the planet of fruits, Captain Lime helps %s"), hero.name), 5000}}) |
480 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("You fought bravely and you helped us win this battle!"), SAY_SAY, 5000}}) |
501 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("You fought bravely and you helped us win this battle!"), SAY_SAY, 5000}}) |
481 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("So, as promised I have brought you where I think that the device you are looking for is hidden."), SAY_SAY, 7000}}) |
502 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("So, as promised I have brought you where I think that the device you are looking for is hidden."), SAY_SAY, 7000}}) |
482 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("I know that your resources are low due to the battle but I'll send two of my best hogs to assist you."), SAY_SAY, 7000}}) |
503 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("I know that your resources are low due to the battle but I'll send two of my best hogs to assist you."), SAY_SAY, 7000}}) |
483 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("Good luck!"), SAY_SAY, 2000}}) |
504 table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("Good luck!"), SAY_SAY, 2000}}) |
484 table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}}) |
505 table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}}) |
485 table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}}) |
506 table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}}) |
486 table.insert(dialog01, {func = ShowMission, args = goals[dialog01]}) |
507 table.insert(dialog01, {func = ShowMission, args = goals[dialog01]}) |
487 -- DIALOG02 - Start, Hog Solo escaped from the previous battle |
508 -- DIALOG02 - Start, hero escaped from the previous battle |
488 AddSkipFunction(dialog02, Skipanim, {dialog02}) |
509 AddSkipFunction(dialog02, Skipanim, {dialog02}) |
489 table.insert(dialog02, {func = AnimWait, args = {hero.gear, 3000}}) |
510 table.insert(dialog02, {func = AnimWait, args = {hero.gear, 3000}}) |
490 table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("Somewhere else on the planet of fruits Hog Solo gets closer to the device"), 5000}}) |
511 table.insert(dialog02, {func = AnimCaption, args = {hero.gear, string.format(loc("Somewhere else on the planet of fruits, %s gets closer to the device"), hero.name), 5000}}) |
491 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("You are the one who fled! So, you are alive."), SAY_SAY, 4000}}) |
512 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("You are the one who fled! So, you are alive."), SAY_SAY, 4000}}) |
492 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("I'm still low on hogs. If you are not afraid I could use a set of extra hands."), SAY_SAY, 4000}}) |
513 table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("I'm still low on hogs. If you are not afraid I could use a set of extra hands."), SAY_SAY, 4000}}) |
493 table.insert(dialog02, {func = AnimWait, args = {hero.gear, 8000}}) |
514 table.insert(dialog02, {func = AnimWait, args = {hero.gear, 8000}}) |
494 table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("I am sorry but I was looking for a device that may be hidden somewhere around here."), SAY_SAY, 4500}}) |
515 table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("I am sorry but I was looking for a device that may be hidden somewhere around here."), SAY_SAY, 4500}}) |
495 table.insert(dialog02, {func = AnimWait, args = {green1.gear, 12500}}) |
516 table.insert(dialog02, {func = AnimWait, args = {green1.gear, 12500}}) |
504 AddSkipFunction(dialog03, Skipanim, {dialog03}) |
525 AddSkipFunction(dialog03, Skipanim, {dialog03}) |
505 table.insert(dialog03, {func = AnimWait, args = {hero.gear, 2000}}) |
526 table.insert(dialog03, {func = AnimWait, args = {hero.gear, 2000}}) |
506 table.insert(dialog03, {func = FollowGear, args = {hero.gear}}) |
527 table.insert(dialog03, {func = FollowGear, args = {hero.gear}}) |
507 table.insert(dialog03, {func = AnimSay, args = {hero.gear, loc("Hooray! I've found it, now I have to get back to Captain Lime!"), SAY_SAY, 4000}}) |
528 table.insert(dialog03, {func = AnimSay, args = {hero.gear, loc("Hooray! I've found it, now I have to get back to Captain Lime!"), SAY_SAY, 4000}}) |
508 table.insert(dialog03, {func = AnimWait, args = {green1.gear, 4000}}) |
529 table.insert(dialog03, {func = AnimWait, args = {green1.gear, 4000}}) |
509 table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("This Hog Solo is so naive! When he returns I'll shoot him and keep that device for myself!"), SAY_THINK, 4000}}) |
530 table.insert(dialog03, {func = AnimSay, args = {green1.gear, string.format(loc("This %s is so naive! I'm going to shoot this fool so I can keep that device for myself!"), hero.name), SAY_THINK, 4000}}) |
510 table.insert(dialog03, {func = ShowMission, args = goals[dialog03]}) |
531 table.insert(dialog03, {func = ShowMission, args = goals[dialog03]}) |
511 table.insert(dialog03, {func = makeCptLimeEvil, args = {hero.gear}}) |
532 table.insert(dialog03, {func = makeCptLimeEvil, args = {hero.gear}}) |
512 -- DIALOG04 - At crates, hero learns about the Assassins ambush |
533 -- DIALOG04 - At crates, hero learns about the Assassins ambush |
513 AddSkipFunction(dialog04, Skipanim, {dialog04}) |
534 AddSkipFunction(dialog04, Skipanim, {dialog04}) |
514 table.insert(dialog04, {func = AnimWait, args = {hero.gear, 2000}}) |
535 table.insert(dialog04, {func = AnimWait, args = {hero.gear, 2000}}) |