7 |
7 |
8 -- TODO |
8 -- TODO |
9 -- Save and Load All Check Points |
9 -- Save and Load All Check Points |
10 -- Save hero health |
10 -- Save hero health |
11 -- Decide and implement if hero will use gas bombs... |
11 -- Decide and implement if hero will use gas bombs... |
|
12 -- ofc add custom stats page |
|
13 -- PROBLEM : What if one makes a bad choice and wants to replay it map, how to reset? |
|
14 -- POSSIBLE SOLUTIONS: In game function keys, frontend button... |
12 |
15 |
13 HedgewarsScriptLoad("/Scripts/Locale.lua") |
16 HedgewarsScriptLoad("/Scripts/Locale.lua") |
14 HedgewarsScriptLoad("/Scripts/Animate.lua") |
17 HedgewarsScriptLoad("/Scripts/Animate.lua") |
15 |
18 |
16 ----------------- VARIABLES -------------------- |
19 ----------------- VARIABLES -------------------- |
24 -- dialogs |
27 -- dialogs |
25 local dialog01 = {} |
28 local dialog01 = {} |
26 local dialog02 = {} |
29 local dialog02 = {} |
27 local dialog03 = {} |
30 local dialog03 = {} |
28 local dialog04 = {} |
31 local dialog04 = {} |
|
32 local dialog05 = {} |
|
33 local dialog06 = {} |
29 -- mission objectives |
34 -- mission objectives |
30 local goals = { |
35 local goals = { |
31 [dialog01] = {missionName, loc("Getting ready"), loc("Go and collect the crate on top of the column").."|"..loc("Use the sleep gas bomb if the guards spot you!"), 1, 4500}, |
36 [dialog01] = {missionName, loc("Getting ready"), loc("Go and collect the crate on top of the column").."|"..loc("Use the sleep gas bomb if the guards spot you!"), 1, 4500}, |
32 [dialog02] = {missionName, loc("The adventure begins!"), loc("Use the saucer and fly to the moon").."|"..loc("Drive carefully as your fuels are limited"), 1, 4500}, |
37 [dialog02] = {missionName, loc("The adventure begins!"), loc("Use the saucer and fly to the moon").."|"..loc("Drive carefully as your fuels are limited"), 1, 4500}, |
33 [dialog03] = {missionName, loc("An unexpected event!"), loc("Use the saucer and fly away or use the gas bomb to neutralize the guards").."|"..loc("Beware, any damage taken will stay until you take some medicine or visit moon"), 1, 7000} |
38 [dialog03] = {missionName, loc("An unexpected event!"), loc("Use the saucer and fly away or use the gas bomb to neutralize the guards").."|"..loc("Beware, any damage taken will stay until you take some medicine or visit moon"), 1, 7000} |
103 if tonumber(GetCampaignVar("CosmosCheckPoint")) then |
108 if tonumber(GetCampaignVar("CosmosCheckPoint")) then |
104 checkPointReached = tonumber(GetCampaignVar("CosmosCheckPoint")) |
109 checkPointReached = tonumber(GetCampaignVar("CosmosCheckPoint")) |
105 end |
110 end |
106 -- do checkpoint stuff needed before game starts |
111 -- do checkpoint stuff needed before game starts |
107 if checkPointReached == 1 then |
112 if checkPointReached == 1 then |
108 -- do nothing |
113 -- Start of the game |
109 elseif checkPointReached == 2 then |
114 elseif checkPointReached == 2 then |
110 AnimSetGearPosition(hero.gear, saucerX, saucerY) |
115 -- Hero on the column, just took space ship unnoticed |
|
116 AnimSetGearPosition(hero.gear, saucerX, saucerY) |
|
117 elseif checkPointReached == 3 then |
|
118 -- Hero near column, without space ship unnoticed |
|
119 elseif checkPointReached == 4 then |
|
120 -- Hero visited moon for fuels |
|
121 AnimSetGearPosition(hero.gear, 1110, 850) |
|
122 elseif checkPointReached == 5 then |
|
123 -- Hero has visited a planet, he has plenty of fuels and can change planet |
111 end |
124 end |
112 |
125 |
113 AnimInit() |
126 AnimInit() |
114 AnimationSetup() |
127 AnimationSetup() |
115 end |
128 end |
137 AddEvent(onHeroAtSaucerPosition, {hero.gear}, heroAtSaucerPosition, {hero.gear}, 0) |
150 AddEvent(onHeroAtSaucerPosition, {hero.gear}, heroAtSaucerPosition, {hero.gear}, 0) |
138 AddEvent(onHeroOutOfGuardSight, {hero.gear}, heroOutOfGuardSight, {hero.gear}, 0) |
151 AddEvent(onHeroOutOfGuardSight, {hero.gear}, heroOutOfGuardSight, {hero.gear}, 0) |
139 elseif checkPointReached == 2 then |
152 elseif checkPointReached == 2 then |
140 AddAmmo(hero.gear, amJetpack, 1) |
153 AddAmmo(hero.gear, amJetpack, 1) |
141 AddAnim(dialog02) |
154 AddAnim(dialog02) |
|
155 elseif checkPointReached == 3 then |
|
156 -- Hero near column, without space ship unnoticed |
|
157 elseif checkPointReached == 4 then |
|
158 -- Hero visited moon for fuels |
|
159 AddAnim(dialog05) |
|
160 elseif checkPointReached == 5 then |
|
161 -- Hero has visited a planet, he has plenty of fuels and can change planet |
|
162 end |
|
163 -- always check for landings |
|
164 if GetCampaignVar("Planet") ~= "moon" then |
|
165 AddEvent(onMoonLanding, {hero.gear}, moonLanding, {hero.gear}, 0) |
|
166 end |
|
167 if GetCampaignVar("Planet") ~= "desertPlanet" then |
|
168 AddEvent(onDesertPlanetLanding, {hero.gear}, desertPlanetLanding, {hero.gear}, 0) |
|
169 end |
|
170 if GetCampaignVar("Planet") ~= "fruitPlanet" then |
|
171 AddEvent(onFruitPlanetLanding, {hero.gear}, fruitPlanetLanding, {hero.gear}, 0) |
|
172 end |
|
173 if GetCampaignVar("Planet") ~= "icePlanet" then |
|
174 AddEvent(onIcePlanetLanding, {hero.gear}, icePlanetLanding, {hero.gear}, 0) |
142 end |
175 end |
143 end |
176 end |
144 |
177 |
145 function onGameTick() |
178 function onGameTick() |
146 -- maybe alert this to avoid timeForGuard1ToTurnLeft overflow |
179 -- maybe alert this to avoid timeForGuard1ToTurnLeft overflow |
197 return false |
230 return false |
198 end |
231 end |
199 |
232 |
200 function onHeroOutOfGuardSight(gear) |
233 function onHeroOutOfGuardSight(gear) |
201 if GetX(gear) < 3100 and GetY(gear) > saucerY-25 and StoppedGear(gear) and not guard1.keepTurning then |
234 if GetX(gear) < 3100 and GetY(gear) > saucerY-25 and StoppedGear(gear) and not guard1.keepTurning then |
|
235 return true |
|
236 end |
|
237 return false |
|
238 end |
|
239 -- |
|
240 function onMoonLanding(gear) |
|
241 if GetX(gear) > 1010 and GetX(gear) < 1220 and GetY(gear) < 1300 and StoppedGear(gear) then |
|
242 return true |
|
243 end |
|
244 return false |
|
245 end |
|
246 |
|
247 function onFruitPlanetLanding(gear) |
|
248 if GetX(gear) > 2240 and GetX(gear) < 2540 and GetY(gear) < 1100 and StoppedGear(gear) then |
|
249 return true |
|
250 end |
|
251 return false |
|
252 end |
|
253 |
|
254 function onDesertPlanetLanding(gear) |
|
255 if GetX(gear) > 3568 and GetX(gear) < 4052 and GetY(gear) < 500 and StoppedGear(gear) then |
|
256 return true |
|
257 end |
|
258 return false |
|
259 end |
|
260 |
|
261 function onIcePlanetLanding(gear) |
|
262 if GetX(gear) > 1330 and GetX(gear) < 1650 and GetY(gear) < 500 and StoppedGear(gear) then |
202 return true |
263 return true |
203 end |
264 end |
204 return false |
265 return false |
205 end |
266 end |
206 |
267 |
226 function heroOutOfGuardSight(gear) |
287 function heroOutOfGuardSight(gear) |
227 guard1.keepTurning = true |
288 guard1.keepTurning = true |
228 AddAnim(dialog04) |
289 AddAnim(dialog04) |
229 end |
290 end |
230 |
291 |
|
292 function moonLanding(gear) |
|
293 WriteLnToConsole("MOON LANDING, HOORAY!") |
|
294 AnimCaption(hero.gear,loc("Welcome to the moon!")) |
|
295 SaveCampaignVar("CosmosCheckPoint", "4") |
|
296 SaveCampaignVar("Planet", "moon") |
|
297 EndGame() |
|
298 end |
|
299 |
|
300 function fruitPlanetLanding(gear) |
|
301 if checkPointReached < 5 then |
|
302 AddAnim(dialog06) |
|
303 end |
|
304 end |
|
305 |
|
306 function desertPlanetLanding(gear) |
|
307 if checkPointReached < 5 then |
|
308 AddAnim(dialog06) |
|
309 end |
|
310 end |
|
311 |
|
312 function icePlanetLanding(gear) |
|
313 if checkPointReached < 5 then |
|
314 AddAnim(dialog06) |
|
315 end |
|
316 end |
|
317 |
231 -------------- ANIMATIONS ------------------ |
318 -------------- ANIMATIONS ------------------ |
232 |
319 |
233 function Skipanim(anim) |
320 function Skipanim(anim) |
234 if goals[anim] ~= nil then |
321 if goals[anim] ~= nil then |
235 ShowMission(unpack(goals[anim])) |
322 ShowMission(unpack(goals[anim])) |
236 end |
323 end |
237 if CurrentHedgehog ~= hero.gear and anim ~= dialog03 then |
324 if CurrentHedgehog ~= hero.gear and anim ~= dialog03 then |
238 AnimSwitchHog(hero.gear) |
325 AnimSwitchHog(hero.gear) |
239 elseif anim == dialog03 then |
326 elseif anim == dialog03 then |
240 startCombat() |
327 startCombat() |
|
328 elseif anim == dialog05 or anim == dialog06 then |
|
329 EndGame() |
241 end |
330 end |
242 end |
331 end |
243 |
332 |
244 function AnimationSetup() |
333 function AnimationSetup() |
245 -- DIALOG 01 - Start |
334 -- DIALOG 01 - Start |
277 -- DIALOG 04 - Hero out of sight |
366 -- DIALOG 04 - Hero out of sight |
278 AddSkipFunction(dialog04, Skipanim, {dialog04}) |
367 AddSkipFunction(dialog04, Skipanim, {dialog04}) |
279 table.insert(dialog04, {func = AnimCaption, args = {guard1.gear, loc("You are out of danger, time to go to the moon!"), 4000}}) |
368 table.insert(dialog04, {func = AnimCaption, args = {guard1.gear, loc("You are out of danger, time to go to the moon!"), 4000}}) |
280 table.insert(dialog04, {func = AnimSay, args = {guard1.gear, loc("I guess we lost him!"), SAY_SAY, 3000}}) |
369 table.insert(dialog04, {func = AnimSay, args = {guard1.gear, loc("I guess we lost him!"), SAY_SAY, 3000}}) |
281 table.insert(dialog04, {func = AnimSay, args = {guard2.gear, loc("We should better report this and continue our watch!"), SAY_SAY, 5000}}) |
370 table.insert(dialog04, {func = AnimSay, args = {guard2.gear, loc("We should better report this and continue our watch!"), SAY_SAY, 5000}}) |
282 table.insert(dialog04, {func = AnimSwitchHog, args = {hero.gear}}) |
371 table.insert(dialog04, {func = AnimSwitchHog, args = {hero.gear}}) |
283 end |
372 -- DIALOG 05 - Hero returned from moon without fuels |
284 |
373 AddSkipFunction(dialog05, Skipanim, {dialog05}) |
285 ------------------- custom animation functions -------------------------- |
374 table.insert(dialog05, {func = AnimSay, args = {hero.gear, loc("I guess I can't go far without fuels!"), SAY_THINK, 6000}}) |
|
375 table.insert(dialog05, {func = AnimSay, args = {hero.gear, loc("Go to go back"), SAY_THINK, 2000}}) |
|
376 table.insert(dialog05, {func = EndGame, args = {hero.gear}}) |
|
377 -- DIALOG 06 - Landing on wrong planet or on earth if not enough fuels |
|
378 AddSkipFunction(dialog06, Skipanim, {dialog06}) |
|
379 table.insert(dialog06, {func = AnimCaption, args = {hero.gear, loc("You have to try again!"), 5000}}) |
|
380 table.insert(dialog06, {func = AnimSay, args = {hero.gear, loc("Hm... Now I run out of fuels..."), SAY_THINK, 3000}}) |
|
381 table.insert(dialog06, {func = EndGame, args = {hero.gear}}) |
|
382 end |
|
383 |
|
384 ------------------- custom "animation" functions -------------------------- |
286 |
385 |
287 function startCombat() |
386 function startCombat() |
288 -- use this so guard2 will gain control |
387 -- use this so guard2 will gain control |
289 AnimSwitchHog(hero.gear) |
388 AnimSwitchHog(hero.gear) |
290 TurnTimeLeft = 0 |
389 TurnTimeLeft = 0 |