80 Delay = 3 |
80 Delay = 3 |
81 SuddenDeathTurns = 200 |
81 SuddenDeathTurns = 200 |
82 Map = "fruit02_map" |
82 Map = "fruit02_map" |
83 Theme = "Fruit" |
83 Theme = "Fruit" |
84 |
84 |
|
85 -- load checkpoints, problem getting the campaign variable |
|
86 --local h = GetCampaignVar("Desert01CheckPoint") |
|
87 --WriteLnToCosnole("HERE "..h) |
|
88 if GetCampaignVar("Fruit02CheckPoint") then |
|
89 if tonumber(GetCampaignVar("Fruit02CheckPoint")) == 2 then |
|
90 WriteLnToConsole("++++++++++++++HEEEEEEEREEEEEEEEEEEEE") |
|
91 loadHogsPositions() |
|
92 end |
|
93 end |
|
94 |
85 -- Hog Solo and Green Bananas |
95 -- Hog Solo and Green Bananas |
86 AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy") |
96 AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy") |
87 hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1") |
97 hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1") |
88 AnimSetGearPosition(hero.gear, hero.x, hero.y) |
98 AnimSetGearPosition(hero.gear, hero.x, hero.y) |
89 HogTurnLeft(hero.gear, true) |
99 HogTurnLeft(hero.gear, true) |
119 tookPartInBattle = true |
129 tookPartInBattle = true |
120 end |
130 end |
121 |
131 |
122 AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) |
132 AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) |
123 AddEvent(onDeviceCrates, {hero.gear}, deviceCrates, {hero.gear}, 0) |
133 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) |
124 |
136 |
125 -- Hog Solo and GB weapons |
137 -- Hog Solo and GB weapons |
126 AddAmmo(hero.gear, amFirePunch, 3) |
138 AddAmmo(hero.gear, amFirePunch, 3) |
127 AddAmmo(hero.gear, amSwitch, 100) |
139 AddAmmo(hero.gear, amSwitch, 100) |
128 AddAmmo(hero.gear, amTeleport, 100) |
140 AddAmmo(hero.gear, amTeleport, 100) |
288 end |
300 end |
289 end |
301 end |
290 return redDead |
302 return redDead |
291 end |
303 end |
292 |
304 |
|
305 function onCheckPoint1(gear) |
|
306 -- 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 |
|
308 return true |
|
309 end |
|
310 return false |
|
311 end |
|
312 |
|
313 function onCheckPoint2(gear) |
|
314 -- before barrel jump |
|
315 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 |
|
317 return true |
|
318 end |
|
319 return false |
|
320 end |
|
321 |
293 -------------- ACTIONS ------------------ |
322 -------------- ACTIONS ------------------ |
294 |
323 |
295 function heroDeath(gear) |
324 function heroDeath(gear) |
296 SendStat('siGameResult', loc("Hog Solo lost, try again!")) --1 |
325 SendStat('siGameResult', loc("Hog Solo lost, try again!")) --1 |
297 SendStat('siCustomAchievement', loc("To win the game you have to get the bottom crates and come back to the surface")) --11 |
326 SendStat('siCustomAchievement', loc("To win the game Hog Solo has to get the bottom crates and come back to the surface")) --11 |
298 SendStat('siCustomAchievement', loc("You can use the other 2 hogs to assist you")) --11 |
327 SendStat('siCustomAchievement', loc("You can use the other 2 hogs to assist you")) --11 |
299 if tookPartInBattle then |
328 if tookPartInBattle then |
300 SendStat('siCustomAchievement', loc("You'll have to eliminate the Strawberry Assasins at the end")) --11 |
329 SendStat('siCustomAchievement', loc("You'll have to eliminate the Strawberry Assasins at the end")) --11 |
301 else |
330 else |
302 SendStat('siCustomAchievement', loc("You'll have to eliminate Captain Lime at the end")) --11 |
331 SendStat('siCustomAchievement', loc("You'll have to eliminate Captain Lime at the end")) --11 |
357 SendStat('siCustomAchievement', loc("You retrieved the lost part")) --11 |
386 SendStat('siCustomAchievement', loc("You retrieved the lost part")) --11 |
358 SendStat('siCustomAchievement', loc("You defended yourself against Strawberry Assasins")) --11 |
387 SendStat('siCustomAchievement', loc("You defended yourself against Strawberry Assasins")) --11 |
359 SendStat('siPlayerKills','1',teamA.name) |
388 SendStat('siPlayerKills','1',teamA.name) |
360 SendStat('siPlayerKills','0',teamC.name) |
389 SendStat('siPlayerKills','0',teamC.name) |
361 EndGame() |
390 EndGame() |
|
391 end |
|
392 |
|
393 function checkPoint1(gear) |
|
394 AnimCaption(hero.gear, loc("Checkpoint reached!"), 3000) |
|
395 SaveCampaignVar("Fruit02CheckPoint", 2) |
|
396 saveHogsPositions() |
|
397 end |
|
398 |
|
399 function checkPoint2(gear) |
|
400 AnimCaption(hero.gear, loc("Checkpoint reached!"), 3000) |
|
401 SaveCampaignVar("Fruit02CheckPoint", 2) |
|
402 saveHogsPositions() |
362 end |
403 end |
363 |
404 |
364 -------------- ANIMATIONS ------------------ |
405 -------------- ANIMATIONS ------------------ |
365 |
406 |
366 function Skipanim(anim) |
407 function Skipanim(anim) |
427 SetWind(math.random(-100,100)) |
468 SetWind(math.random(-100,100)) |
428 end |
469 end |
429 end |
470 end |
430 |
471 |
431 function saveHogsPositions() |
472 function saveHogsPositions() |
432 local positions = "" |
473 local positions; |
433 positions = GetX(hero.gear)..","..GetY(hero.gear) |
474 positions = GetX(hero.gear)..","..GetY(hero.gear) |
434 if GetHealth(green2.gear) then |
475 if GetHealth(green2.gear) then |
435 positions = positions..","..GetX(green2.gear)..","..GetY(green2.gear) |
476 positions = positions..","..GetX(green2.gear)..","..GetY(green2.gear) |
436 end |
477 end |
437 if GetHealth(green3.gear) then |
478 if GetHealth(green3.gear) then |
439 end |
480 end |
440 SaveCampaignVar("HogsPosition", positions) |
481 SaveCampaignVar("HogsPosition", positions) |
441 end |
482 end |
442 |
483 |
443 function loadHogsPositions() |
484 function loadHogsPositions() |
|
485 WriteLnToConsole("load hogs positions") |
444 local positions; |
486 local positions; |
445 if GetCampaignVar("HogsPosition") then |
487 if GetCampaignVar("HogsPosition") then |
446 positions = GetCampaignVar("HogsPosition") |
488 positions = GetCampaignVar("HogsPosition") |
447 else |
489 else |
448 return |
490 return |
449 end |
491 end |
|
492 WriteLnToConsole("positions : "..positions) |
450 positions = split(positions,",") |
493 positions = split(positions,",") |
|
494 WriteLnToConsole("--------------- "..hero.x) |
451 if positions[1] then |
495 if positions[1] then |
452 hero.x = positions[1] |
496 hero.x = positions[1] |
453 hero.y = positions[2] |
497 hero.y = positions[2] |
454 end |
498 end |
455 if positions[3] then |
499 if positions[3] then |
456 green2.x = positions[3] |
500 green2.x = tonumber(positions[3]) |
457 green2.y = positions[4] |
501 green2.y = tonumber(positions[4]) |
458 end |
502 end |
459 if positions[5] then |
503 if positions[5] then |
460 green3.x = positions[5] |
504 green3.x = tonumber(positions[5]) |
461 green3.y = positions[6] |
505 green3.y = tonumber(positions[6]) |
462 end |
506 end |
463 end |
507 end |
|
508 |
|
509 function isHeroAtWrongPlace() |
|
510 if GetX(hero.gear) > 1480 and GetX(hero.gear) < 1892 and GetY(hero.gear) > 1000 and GetY(hero.gear) < 1220 then |
|
511 return true |
|
512 end |
|
513 return false |
|
514 end |
|
515 |
|
516 function split(s, delimiter) |
|
517 local res = {} |
|
518 local first = "" |
|
519 for i=1,s:len() do |
|
520 if s:sub(1,1) == delimiter then |
|
521 table.insert(res, tonumber(first)) |
|
522 first = "" |
|
523 else |
|
524 first = first..s:sub(1,1) |
|
525 end |
|
526 s = s:sub(2) |
|
527 end |
|
528 return res |
|
529 end |