|
1 ------------------- ABOUT ---------------------- |
|
2 -- |
|
3 -- Hero has get into an Red Strawberies ambush |
|
4 -- He has to eliminate the enemies by using limited |
|
5 -- ammo of sniper rifle and watermelon |
|
6 |
|
7 HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
8 HedgewarsScriptLoad("/Scripts/Animate.lua") |
|
9 HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua") |
|
10 |
|
11 ----------------- VARIABLES -------------------- |
|
12 -- globals |
|
13 local missionName = loc("Precise shooting") |
|
14 -- hogs |
|
15 local hero = { |
|
16 name = loc("Hog Solo"), |
|
17 x = 1830, |
|
18 y = 560, |
|
19 dead = false |
|
20 } |
|
21 local enemiesOdd = { |
|
22 {name = "Hog 1", x = 3670 , y = 175}, |
|
23 {name = "Hog 3", x = 3795 , y = 1110}, |
|
24 {name = "Hog 5", x = 1950 , y = 1480}, |
|
25 {name = "Hog 7", x = 400 , y = 920}, |
|
26 {name = "Hog 9", x = 1100 , y = 1950}, |
|
27 {name = "Hog 11", x = 1200 , y = 1950}, |
|
28 {name = "Hog 13", x = 2300 , y = 1950}, |
|
29 {name = "Hog 15", x = 2400 , y = 1950}, |
|
30 } |
|
31 local enemiesEven = { |
|
32 {name = "Hog 2", x = 660, y = 170}, |
|
33 {name = "Hog 4", x = 1900, y = 1320}, |
|
34 {name = "Hog 6", x = 2030, y = 1335}, |
|
35 {name = "Hog 8", x = 1300, y = 1950}, |
|
36 {name = "Hog 10", x = 1400, y = 1950}, |
|
37 {name = "Hog 12", x = 2500, y = 1950}, |
|
38 {name = "Hog 14", x = 2600, y = 1950}, |
|
39 {name = "Hog 16", x = 1850, y = 560}, |
|
40 } |
|
41 -- teams |
|
42 local teamA = { |
|
43 name = loc("Hog Solo"), |
|
44 color = tonumber("38D61C",16) -- green |
|
45 } |
|
46 local teamB = { |
|
47 name = loc("RS1"), |
|
48 color = tonumber("FF0000",16) -- red |
|
49 } |
|
50 local teamC = { |
|
51 name = loc("RS2"), |
|
52 color = tonumber("FF0000",16) -- red |
|
53 } |
|
54 |
|
55 -------------- LuaAPI EVENT HANDLERS ------------------ |
|
56 |
|
57 function onGameInit() |
|
58 GameFlags = gfDisableWind + gfInfAttack |
|
59 Seed = 1 |
|
60 TurnTime = 25000 |
|
61 CaseFreq = 0 |
|
62 MinesNum = 0 |
|
63 MinesTime = 1 |
|
64 Explosives = 0 |
|
65 Map = "fruit03_map" |
|
66 Theme = "Fruit" |
|
67 |
|
68 -- Hog Solo |
|
69 AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy") |
|
70 hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1") |
|
71 AnimSetGearPosition(hero.gear, hero.x, hero.y) |
|
72 -- enemies |
|
73 AddTeam(teamC.name, teamC.color, "Bone", "Island", "HillBilly", "cm_birdy") |
|
74 for i=1,table.getn(enemiesEven) do |
|
75 enemiesEven[i].gear = AddHog(enemiesEven[i].name, 1, 100, "war_desertgrenadier1") |
|
76 AnimSetGearPosition(enemiesEven[i].gear, enemiesEven[i].x, enemiesEven[i].y) |
|
77 end |
|
78 AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy") |
|
79 for i=1,table.getn(enemiesOdd) do |
|
80 enemiesOdd[i].gear = AddHog(enemiesOdd[i].name, 1, 100, "war_desertgrenadier1") |
|
81 AnimSetGearPosition(enemiesOdd[i].gear, enemiesOdd[i].x, enemiesOdd[i].y) |
|
82 end |
|
83 |
|
84 initCheckpoint("fruit03") |
|
85 |
|
86 AnimInit() |
|
87 --AnimationSetup() |
|
88 end |
|
89 |
|
90 function onGameStart() |
|
91 AnimWait(hero.gear, 3000) |
|
92 FollowGear(hero.gear) |
|
93 |
|
94 AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) |
|
95 |
|
96 --hero ammo |
|
97 AddAmmo(hero.gear, amTeleport, 2) |
|
98 AddAmmo(hero.gear, amSniperRifle, 2) |
|
99 AddAmmo(hero.gear, amWatermelon, 2) |
|
100 --enemies ammo |
|
101 AddAmmo(enemiesOdd[1].gear, amSniperRifle, 100) |
|
102 AddAmmo(enemiesOdd[1].gear, amWatermelon, 1) |
|
103 AddAmmo(enemiesEven[1].gear, amSniperRifle, 100) |
|
104 AddAmmo(enemiesEven[1].gear, amWatermelon, 1) |
|
105 |
|
106 SendHealthStatsOff() |
|
107 end |
|
108 |
|
109 function onGameTick20() |
|
110 turnHogs() |
|
111 end |
|
112 |
|
113 function onGearDelete(gear) |
|
114 if gear == hero.gear then |
|
115 hero.dead = true |
|
116 end |
|
117 end |
|
118 |
|
119 -------------- EVENTS ------------------ |
|
120 |
|
121 function onHeroDeath(gear) |
|
122 if hero.dead then |
|
123 return true |
|
124 end |
|
125 return false |
|
126 end |
|
127 |
|
128 -------------- ACTIONS ------------------ |
|
129 |
|
130 -- game ends anyway but I want to sent custom stats probably... |
|
131 function heroDeath(gear) |
|
132 heroLost() |
|
133 end |
|
134 |
|
135 ------------------ Other Functions ------------------- |
|
136 |
|
137 function turnHogs() |
|
138 for i=1,table.getn(enemiesEven) do |
|
139 if GetHealth(enemiesEven[i].gear) then |
|
140 if GetX(enemiesEven[i].gear) < GetX(hero.gear) then |
|
141 HogTurnLeft(enemiesEven[i].gear, false) |
|
142 elseif GetX(enemiesEven[i].gear) > GetX(hero.gear) then |
|
143 HogTurnLeft(enemiesEven[i].gear, true) |
|
144 end |
|
145 end |
|
146 end |
|
147 for i=1,table.getn(enemiesOdd) do |
|
148 if GetHealth(enemiesOdd[i].gear) then |
|
149 if GetX(enemiesOdd[i].gear) < GetX(hero.gear) then |
|
150 HogTurnLeft(enemiesOdd[i].gear, false) |
|
151 elseif GetX(enemiesOdd[i].gear) > GetX(hero.gear) then |
|
152 HogTurnLeft(enemiesOdd[i].gear, true) |
|
153 end |
|
154 end |
|
155 end |
|
156 end |