11 local campaignName = loc("A Space Adventure") |
11 local campaignName = loc("A Space Adventure") |
12 local missionName = loc("Fruit planet, Searching the Device!") |
12 local missionName = loc("Fruit planet, Searching the Device!") |
13 local inBattle = false |
13 local inBattle = false |
14 local tookPartInBattle = false |
14 local tookPartInBattle = false |
15 local previousHog = -1 |
15 local previousHog = -1 |
|
16 local checkPointReached = 1 -- 1 is normal spawn |
16 -- dialogs |
17 -- dialogs |
17 local dialog01 = {} |
18 local dialog01 = {} |
18 local dialog02 = {} |
19 local dialog02 = {} |
19 local dialog03 = {} |
20 local dialog03 = {} |
20 local dialog04 = {} |
21 local dialog04 = {} |
80 Delay = 3 |
81 Delay = 3 |
81 SuddenDeathTurns = 200 |
82 SuddenDeathTurns = 200 |
82 Map = "fruit02_map" |
83 Map = "fruit02_map" |
83 Theme = "Fruit" |
84 Theme = "Fruit" |
84 |
85 |
|
86 WriteLnToConsole("CHECKPOINT IS "..checkPointReached) |
85 -- load checkpoints, problem getting the campaign variable |
87 -- load checkpoints, problem getting the campaign variable |
86 --local h = GetCampaignVar("Desert01CheckPoint") |
88 --local h = GetCampaignVar("Desert01CheckPoint") |
87 --WriteLnToCosnole("HERE "..h) |
89 --WriteLnToCosnole("HERE "..GetCampaignVar("Fruit02CheckPoint")) |
88 if GetCampaignVar("Fruit02CheckPoint") then |
90 if tonumber(GetCampaignVar("Fruit02CheckPoint")) then |
89 if tonumber(GetCampaignVar("Fruit02CheckPoint")) == 2 then |
91 WriteLnToConsole("**TRUE**") |
|
92 checkPointReached = tonumber(GetCampaignVar("Fruit02CheckPoint")) |
|
93 if checkPointReached == 2 or checkPointReached == 3 then |
90 WriteLnToConsole("++++++++++++++HEEEEEEEREEEEEEEEEEEEE") |
94 WriteLnToConsole("++++++++++++++HEEEEEEEREEEEEEEEEEEEE") |
91 loadHogsPositions() |
95 loadHogsPositions() |
92 end |
96 end |
93 end |
97 end |
94 |
98 |
|
99 WriteLnToConsole("CHECKPOINT IS "..checkPointReached) |
95 -- Hog Solo and Green Bananas |
100 -- Hog Solo and Green Bananas |
96 AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy") |
101 AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy") |
97 hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1") |
102 hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1") |
98 AnimSetGearPosition(hero.gear, hero.x, hero.y) |
103 AnimSetGearPosition(hero.gear, hero.x, hero.y) |
99 HogTurnLeft(hero.gear, true) |
104 HogTurnLeft(hero.gear, true) |
129 tookPartInBattle = true |
134 tookPartInBattle = true |
130 end |
135 end |
131 |
136 |
132 AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) |
137 AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) |
133 AddEvent(onDeviceCrates, {hero.gear}, deviceCrates, {hero.gear}, 0) |
138 AddEvent(onDeviceCrates, {hero.gear}, deviceCrates, {hero.gear}, 0) |
134 --AddEvent(onCheckPoint1, {hero.gear}, checkPoint1, {hero.gear}, 0) |
|
135 --AddEvent(onCheckPoint2, {hero.gear}, checkPoint2, {hero.gear}, 0) |
|
136 |
139 |
137 -- Hog Solo and GB weapons |
140 -- Hog Solo and GB weapons |
138 AddAmmo(hero.gear, amFirePunch, 3) |
|
139 AddAmmo(hero.gear, amSwitch, 100) |
141 AddAmmo(hero.gear, amSwitch, 100) |
140 AddAmmo(hero.gear, amTeleport, 100) |
142 AddAmmo(hero.gear, amTeleport, 100) |
141 -- Captain Lime weapons |
143 -- Captain Lime weapons |
142 AddAmmo(green1.bot, amBazooka, 6) |
144 AddAmmo(green1.bot, amBazooka, 6) |
143 AddAmmo(green1.bot, amGrenade, 6) |
145 AddAmmo(green1.bot, amGrenade, 6) |
197 if tookPartInBattle then |
199 if tookPartInBattle then |
198 AddAnim(dialog01) |
200 AddAnim(dialog01) |
199 else |
201 else |
200 AddAnim(dialog02) |
202 AddAnim(dialog02) |
201 end |
203 end |
|
204 WriteLnToConsole("CHECKPOINT IS "..checkPointReached) |
|
205 if checkPointReached == 1 then |
|
206 AddAmmo(hero.gear, amFirePunch, 3) |
|
207 AddEvent(onCheckPoint1, {hero.gear}, checkPoint1, {hero.gear}, 0) |
|
208 AddEvent(onCheckPoint2, {hero.gear}, checkPoint2, {hero.gear}, 0) |
|
209 elseif checkPointReached == 2 then |
|
210 loadWeapons() |
|
211 AddEvent(onCheckPoint2, {hero.gear}, checkPoint2, {hero.gear}, 0) |
|
212 elseif checkPointReached == 3 then |
|
213 loadWeapons() |
|
214 AddEvent(onCheckPoint1, {hero.gear}, checkPoint1, {hero.gear}, 0) |
|
215 end |
202 |
216 |
203 SendHealthStatsOff() |
217 SendHealthStatsOff() |
204 end |
218 end |
205 |
219 |
206 function onNewTurn() |
220 function onNewTurn() |
302 return redDead |
316 return redDead |
303 end |
317 end |
304 |
318 |
305 function onCheckPoint1(gear) |
319 function onCheckPoint1(gear) |
306 -- before barrel jump |
320 -- before barrel jump |
307 if GetX(hero.gear) > 2850 and GetX(hero.gear) < 2945 and GetY(hero.gear) > 808 and GetY(hero.gear) < 852 then |
321 if GetX(hero.gear) > 2850 and GetX(hero.gear) < 2945 and GetY(hero.gear) > 808 and GetY(hero.gear) < 852 |
|
322 and not isHeroAtWrongPlace() then |
308 return true |
323 return true |
309 end |
324 end |
310 return false |
325 return false |
311 end |
326 end |
312 |
327 |
313 function onCheckPoint2(gear) |
328 function onCheckPoint2(gear) |
314 -- before barrel jump |
329 -- before barrel jump |
315 if (GetX(green2.gear) > 2850 and GetX(green2.gear) < 2945 and GetY(green2.gear) > 808 and GetY(green2.gear) < 852) |
330 if ((GetX(green2.gear) > 2850 and GetX(green2.gear) < 2945 and GetY(green2.gear) > 808 and GetY(green2.gear) < 852) |
316 or (GetX(green3.gear) > 2850 and GetX(green3.gear) < 2945 and GetY(green3.gear) > 808 and GetY(green3.gear) < 852) then |
331 or (GetX(green3.gear) > 2850 and GetX(green3.gear) < 2945 and GetY(green3.gear) > 808 and GetY(green3.gear) < 852)) |
|
332 and not isHeroAtWrongPlace() then |
317 return true |
333 return true |
318 end |
334 end |
319 return false |
335 return false |
320 end |
336 end |
321 |
337 |
392 |
408 |
393 function checkPoint1(gear) |
409 function checkPoint1(gear) |
394 AnimCaption(hero.gear, loc("Checkpoint reached!"), 3000) |
410 AnimCaption(hero.gear, loc("Checkpoint reached!"), 3000) |
395 SaveCampaignVar("Fruit02CheckPoint", 2) |
411 SaveCampaignVar("Fruit02CheckPoint", 2) |
396 saveHogsPositions() |
412 saveHogsPositions() |
|
413 saveWeapons() |
397 end |
414 end |
398 |
415 |
399 function checkPoint2(gear) |
416 function checkPoint2(gear) |
400 AnimCaption(hero.gear, loc("Checkpoint reached!"), 3000) |
417 AnimCaption(hero.gear, loc("Checkpoint reached!"), 3000) |
401 SaveCampaignVar("Fruit02CheckPoint", 2) |
418 SaveCampaignVar("Fruit02CheckPoint", 3) |
402 saveHogsPositions() |
419 saveHogsPositions() |
|
420 saveWeapons() |
403 end |
421 end |
404 |
422 |
405 -------------- ANIMATIONS ------------------ |
423 -------------- ANIMATIONS ------------------ |
406 |
424 |
407 function Skipanim(anim) |
425 function Skipanim(anim) |
504 green3.x = tonumber(positions[5]) |
522 green3.x = tonumber(positions[5]) |
505 green3.y = tonumber(positions[6]) |
523 green3.y = tonumber(positions[6]) |
506 end |
524 end |
507 end |
525 end |
508 |
526 |
|
527 function saveWeapons() |
|
528 -- firepunch - gilder - deagle - watermelon - sniper |
|
529 SaveCampaignVar("HeroAmmo", GetAmmoCount(hero.gear, amFirepunch)..GetAmmoCount(hero.gear, amGilder).. |
|
530 GetAmmoCount(hero.gear, amDEagle)..GetAmmoCount(hero.gear, amWatermelon)..GetAmmoCount(hero.gear, amSniperRifle)) |
|
531 end |
|
532 |
|
533 function loadWeapons() |
|
534 local ammo = GetCampaignVar("HeroAmmo") |
|
535 AddAmmo(hero.gear, amFirepunch, tonumber(ammo:sub(1,1))) |
|
536 AddAmmo(hero.gear, amGilder, tonumber(ammo:sub(2,2))) |
|
537 AddAmmo(hero.gear, amDEagle, tonumber(ammo:sub(3,3))) |
|
538 AddAmmo(hero.gear, amWatermelon, tonumber(ammo:sub(4,4))) |
|
539 AddAmmo(hero.gear, amSniperRifle, tonumber(ammo:sub(5,5))) |
|
540 end |
|
541 |
509 function isHeroAtWrongPlace() |
542 function isHeroAtWrongPlace() |
510 if GetX(hero.gear) > 1480 and GetX(hero.gear) < 1892 and GetY(hero.gear) > 1000 and GetY(hero.gear) < 1220 then |
543 if GetX(hero.gear) > 1480 and GetX(hero.gear) < 1892 and GetY(hero.gear) > 1000 and GetY(hero.gear) < 1220 then |
511 return true |
544 return true |
512 end |
545 end |
513 return false |
546 return false |
514 end |
547 end |
515 |
548 |
|
549 -- splits number by delimiter |
516 function split(s, delimiter) |
550 function split(s, delimiter) |
517 local res = {} |
551 local res = {} |
518 local first = "" |
552 local first = "" |
519 for i=1,s:len() do |
553 for i=1,s:len() do |
520 if s:sub(1,1) == delimiter then |
554 if s:sub(1,1) == delimiter then |