|
1 ------------------- ABOUT ---------------------- |
|
2 -- |
|
3 -- This map works as a menu for the hero hog to |
|
4 -- navigate through planets. It portrays the hogs |
|
5 -- planet and above the planets that he'll later |
|
6 -- visit. |
|
7 |
|
8 -- TODO |
|
9 -- Save and Load All Check Points |
|
10 -- Save hero health |
|
11 -- Decide and implement if hero will use gas bombs... |
|
12 |
|
13 HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
14 HedgewarsScriptLoad("/Scripts/Animate.lua") |
|
15 |
|
16 ----------------- VARIABLES -------------------- |
|
17 -- globals |
|
18 local campaignName = loc("A Space Adventure") |
|
19 local missionName = loc("Cosmos") |
|
20 local timeForGuard1ToTurn = 1000 * 5 -- 5 sec |
|
21 local timeForGuard1ToTurnLeft = timeForGuard1ToTurn |
|
22 local saucerAcquired = false |
|
23 local checkPointReached = 1 -- 1 is start of the game |
|
24 -- dialogs |
|
25 local dialog01 = {} |
|
26 local dialog02 = {} |
|
27 local dialog03 = {} |
|
28 local dialog04 = {} |
|
29 -- mission objectives |
|
30 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}, |
|
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}, |
|
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} |
|
34 } |
|
35 -- crates |
|
36 local saucerX = 3270 |
|
37 local saucerY = 1500 |
|
38 -- hogs |
|
39 local hero = {} |
|
40 local director = {} |
|
41 local doctor = {} |
|
42 local guard1 = {} |
|
43 local guard2 = {} |
|
44 -- teams |
|
45 local teamA = {} |
|
46 local teamB = {} |
|
47 local teamC = {} |
|
48 -- hedgehogs values |
|
49 hero.name = loc("Hog Solo") |
|
50 hero.x = 1450 |
|
51 hero.y = 1550 |
|
52 director.name = loc("H") |
|
53 director.x = 1350 |
|
54 director.y = 1550 |
|
55 doctor.name = loc("Dr.Cornelius") |
|
56 doctor.x = 1300 |
|
57 doctor.y = 1550 |
|
58 guard1.name = loc("Bob") |
|
59 guard1.x = 3350 |
|
60 guard1.y = 1800 |
|
61 guard1.turn = false |
|
62 guard1.keepTurning = true |
|
63 guard2.name = loc("Sam") |
|
64 guard2.x = 3400 |
|
65 guard2.y = 1800 |
|
66 teamA.name = loc("PAoTH") |
|
67 teamA.color = tonumber("FF0000",16) -- red |
|
68 teamB.name = loc("Guards") |
|
69 teamB.color = tonumber("0033FF",16) -- blue |
|
70 teamC.name = loc("Hog Solo") |
|
71 teamC.color = tonumber("38D61C",16) -- green |
|
72 |
|
73 -------------- LuaAPI EVENT HANDLERS ------------------ |
|
74 function onGameInit() |
|
75 Seed = 35 |
|
76 GameFlags = gfSolidLand + gfDisableWind |
|
77 TurnTime = 40000 |
|
78 CaseFreq = 0 |
|
79 MinesNum = 0 |
|
80 Explosives = 0 |
|
81 Delay = 5 |
|
82 Map = "cosmos_map" -- custom map included in file |
|
83 Theme = "Nature" |
|
84 -- I had originally hero in PAoTH team and changed it, may reconsider though |
|
85 -- PAoTH |
|
86 AddTeam(teamC.name, teamC.color, "Bone", "Island", "HillBilly", "cm_birdy") |
|
87 hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1") |
|
88 AnimSetGearPosition(hero.gear, hero.x, hero.y) |
|
89 HogTurnLeft(hero.gear, true) |
|
90 AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy") |
|
91 director.gear = AddHog(director.name, 0, 100, "hair_yellow") |
|
92 AnimSetGearPosition(director.gear, director.x, director.y) |
|
93 doctor.gear = AddHog(doctor.name, 0, 100, "Glasses") |
|
94 AnimSetGearPosition(doctor.gear, doctor.x, doctor.y) |
|
95 -- Guards |
|
96 AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy") |
|
97 guard1.gear = AddHog(guard1.name, 1, 100, "policecap") |
|
98 AnimSetGearPosition(guard1.gear, guard1.x, guard1.y) |
|
99 guard2.gear = AddHog(guard2.name, 1, 100, "policecap") |
|
100 AnimSetGearPosition(guard2.gear, guard2.x, guard2.y) |
|
101 |
|
102 -- get the check point |
|
103 if tonumber(GetCampaignVar("CosmosCheckPoint")) then |
|
104 checkPointReached = tonumber(GetCampaignVar("CosmosCheckPoint")) |
|
105 end |
|
106 -- do checkpoint stuff needed before game starts |
|
107 if checkPointReached == 1 then |
|
108 -- do nothing |
|
109 elseif checkPointReached == 2 then |
|
110 AnimSetGearPosition(hero.gear, saucerX, saucerY) |
|
111 end |
|
112 |
|
113 AnimInit() |
|
114 AnimationSetup() |
|
115 end |
|
116 |
|
117 function onGameStart() |
|
118 -- wait for the first turn to start |
|
119 AnimWait(hero.gear, 3000) |
|
120 |
|
121 FollowGear(hero.gear) |
|
122 ShowMission(loc("A Space Adventure"), loc("Cosmos"), loc("Help Hog Solo to find all the parts of the anti-gravity device.").. |
|
123 "|"..loc("Travel to all the neighbor planets and collect all the pieces"), -amSkip, 0) |
|
124 |
|
125 -- do checkpoint stuff needed after game starts |
|
126 if checkPointReached == 1 then |
|
127 AddAnim(dialog01) |
|
128 AddAmmo(hero.gear, amGasBomb, 5) |
|
129 AddAmmo(hero.gear, amRope, 2) |
|
130 -- Added for dev/debug purposes, remove before release |
|
131 AddAmmo(hero.gear, amJetpack, 2) |
|
132 AddAmmo(guard1.gear, amDEagle, 2) |
|
133 AddAmmo(guard2.gear, amDEagle, 2) |
|
134 SpawnAmmoCrate(saucerX, saucerY, amJetpack) |
|
135 -- EVENT HANDLERS |
|
136 AddEvent(onHeroBeforeTreePosition, {hero.gear}, heroBeforeTreePosition, {hero.gear}, 0) |
|
137 AddEvent(onHeroAtSaucerPosition, {hero.gear}, heroAtSaucerPosition, {hero.gear}, 0) |
|
138 AddEvent(onHeroOutOfGuardSight, {hero.gear}, heroOutOfGuardSight, {hero.gear}, 0) |
|
139 elseif checkPointReached == 2 then |
|
140 AddAmmo(hero.gear, amJetpack, 1) |
|
141 AddAnim(dialog02) |
|
142 end |
|
143 end |
|
144 |
|
145 function onGameTick() |
|
146 -- maybe alert this to avoid timeForGuard1ToTurnLeft overflow |
|
147 if timeForGuard1ToTurnLeft == 0 and guard1.keepTurning then |
|
148 guard1.turn = not guard1.turn |
|
149 HogTurnLeft(guard1.gear, guard1.turn) |
|
150 timeForGuard1ToTurnLeft = timeForGuard1ToTurn |
|
151 end |
|
152 timeForGuard1ToTurnLeft = timeForGuard1ToTurnLeft - 1 |
|
153 AnimUnWait() |
|
154 if ShowAnimation() == false then |
|
155 return |
|
156 end |
|
157 ExecuteAfterAnimations() |
|
158 CheckEvents() |
|
159 end |
|
160 |
|
161 function onPrecise() |
|
162 if GameTime > 3000 then |
|
163 SetAnimSkip(true) |
|
164 end |
|
165 end |
|
166 |
|
167 function onAmmoStoreInit() |
|
168 SetAmmo(amJetpack, 0, 0, 0, 1) |
|
169 end |
|
170 |
|
171 function onNewTurn() |
|
172 if CurrentHedgehog == director.gear or CurrentHedgehog == doctor.gear then |
|
173 TurnTimeLeft = 0 |
|
174 end |
|
175 if guard1.keepTurning then |
|
176 AnimSwitchHog(hero.gear) |
|
177 TurnTimeLeft = -1 |
|
178 end |
|
179 end |
|
180 |
|
181 -------------- EVENTS ------------------ |
|
182 |
|
183 function onHeroBeforeTreePosition(gear) |
|
184 if GetX(gear) > 2444 then |
|
185 return true |
|
186 end |
|
187 return false |
|
188 end |
|
189 |
|
190 function onHeroAtSaucerPosition(gear) |
|
191 if GetX(gear) >= saucerX-32 and GetX(gear) <= saucerX+32 and GetY(gear) >= saucerY-32 and GetY(gear) <= saucerY+32 then |
|
192 saucerAcquired = true |
|
193 end |
|
194 if saucerAcquired and StoppedGear(gear) then |
|
195 return true |
|
196 end |
|
197 return false |
|
198 end |
|
199 |
|
200 function onHeroOutOfGuardSight(gear) |
|
201 if GetX(gear) < 3100 and GetY(gear) > saucerY-25 and StoppedGear(gear) and not guard1.keepTurning then |
|
202 return true |
|
203 end |
|
204 return false |
|
205 end |
|
206 |
|
207 -------------- OUTCOMES ------------------ |
|
208 |
|
209 function heroBeforeTreePosition(gear) |
|
210 AnimSay(gear,loc("Now I have to climb the trees"), SAY_SAY, 4000) |
|
211 AnimCaption(hero.gear, loc("Use the rope to get to the crate"), 4000) |
|
212 end |
|
213 |
|
214 function heroAtSaucerPosition(gear) |
|
215 TurnTimeLeft = 0 |
|
216 -- save check point |
|
217 SaveCampaignVar("CosmosCheckPoint", "2") |
|
218 AddAnim(dialog02) |
|
219 -- check if he was spotted by the guard |
|
220 if guard1.turn then |
|
221 guard1.keepTurning = false |
|
222 AddAnim(dialog03) |
|
223 end |
|
224 end |
|
225 |
|
226 function heroOutOfGuardSight(gear) |
|
227 guard1.keepTurning = true |
|
228 AddAnim(dialog04) |
|
229 end |
|
230 |
|
231 -------------- ANIMATIONS ------------------ |
|
232 |
|
233 function Skipanim(anim) |
|
234 if goals[anim] ~= nil then |
|
235 ShowMission(unpack(goals[anim])) |
|
236 end |
|
237 if CurrentHedgehog ~= hero.gear and anim ~= dialog03 then |
|
238 AnimSwitchHog(hero.gear) |
|
239 elseif anim == dialog03 then |
|
240 startCombat() |
|
241 end |
|
242 end |
|
243 |
|
244 function AnimationSetup() |
|
245 -- DIALOG 01 - Start |
|
246 AddSkipFunction(dialog01, Skipanim, {dialog01}) |
|
247 table.insert(dialog01, {func = AnimWait, args = {doctor.gear, 3000}}) |
|
248 --table.insert(dialog01, {func = AnimWait, args = {hero.gear, 2500}, skipFunc = Skipanim, skipArgs = dialog01}) |
|
249 table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Near secret base 17 of PAoTH in the rural Hogland..."), 4000}}) |
|
250 table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("So Hog Solo, here we are..."), SAY_SAY, 2000}}) |
|
251 table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("Behind these trees on the East there is secret base 17"), SAY_SAY, 4000}}) |
|
252 table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("You have to continue alone from now on."), SAY_SAY, 3000}}) |
|
253 table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("Be careful, the future of Hogera is in your hands!"), SAY_SAY, 7200}}) |
|
254 table.insert(dialog01, {func = AnimSay, args = {doctor.gear, loc("We'll use our communicators to contact you"), SAY_SAY, 2600}}) |
|
255 table.insert(dialog01, {func = AnimSay, args = {doctor.gear, loc("In am also entrusting you with a rope and a sleep gas bomb"), SAY_SAY, 5000}}) |
|
256 table.insert(dialog01, {func = AnimSay, args = {doctor.gear, loc("You may find them handy"), SAY_SAY, 2300}}) |
|
257 table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Thank you Dr.Cornelius"), SAY_SAY, 1600}}) |
|
258 table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("I'll make good use of them"), SAY_SAY, 4500}}) |
|
259 table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("It would be wiser to steal the space ship while PAoTH guards are taking a brake!"), SAY_SAY, 7000}}) |
|
260 table.insert(dialog01, {func = AnimSay, args = {director.gear, loc("Remember! Many will seek the anti-gravity device! Now go, hurry up!"), SAY_SAY, 4000}}) |
|
261 table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}}) |
|
262 -- DIALOG 02 - Hero got the saucer |
|
263 AddSkipFunction(dialog02, Skipanim, {dialog02}) |
|
264 table.insert(dialog02, {func = AnimWait, args = {hero.gear, 500}}) |
|
265 table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("CheckPoint reached!"), 4000}}) |
|
266 table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("Got the saucer!"), SAY_SHOUT, 2000}}) |
|
267 table.insert(dialog02, {func = AnimSay, args = {director.gear, loc("Nice!"), SAY_SHOUT, 1000}}) |
|
268 table.insert(dialog02, {func = AnimSay, args = {director.gear, loc("Now use it and go to the moon PAoTH station to get more fuels!"), SAY_SHOUT, 5000}}) |
|
269 table.insert(dialog02, {func = AnimGearWait, args = {hero.gear, 500}}) |
|
270 -- DIALOG 03 - Hero got spotted by guard |
|
271 AddSkipFunction(dialog03, Skipanim, {dialog03}) |
|
272 table.insert(dialog03, {func = AnimWait, args = {guard1.gear, 4000}}) |
|
273 table.insert(dialog03, {func = AnimCaption, args = {guard1.gear, loc("Prepare to battle or flee!"), 4000}}) |
|
274 table.insert(dialog03, {func = AnimSay, args = {guard1.gear, loc("Hey").." "..guard2.name.."! "..loc("Look, someone is stealing the saucer!"), SAY_SHOUT, 4000}}) |
|
275 table.insert(dialog03, {func = AnimSay, args = {guard2.gear, loc("I'll get him!"), SAY_SAY, 4000}}) |
|
276 table.insert(dialog03, {func = startCombat, args = {guard1.gear}}) |
|
277 -- DIALOG 04 - Hero out of sight |
|
278 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}}) |
|
280 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}}) |
|
282 table.insert(dialog04, {func = AnimSwitchHog, args = {hero.gear}}) |
|
283 end |
|
284 |
|
285 ------------------- custom animation functions -------------------------- |
|
286 |
|
287 function startCombat() |
|
288 -- use this so guard2 will gain control |
|
289 AnimSwitchHog(hero.gear) |
|
290 TurnTimeLeft = 0 |
|
291 end |