1
------------------- ABOUT ----------------------
3
-- In this cold planet hero seeks for a part of the
4
-- antigravity device. He has to capture Thanta who
5
-- knows where the device is hidden. Hero will be
6
-- able to use only the ice gun for this mission.
8
HedgewarsScriptLoad("/Scripts/Locale.lua")
9
HedgewarsScriptLoad("/Scripts/Animate.lua")
10
HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
12
----------------- VARIABLES --------------------
14
local missionName = loc("A frozen adventure")
15
local heroAtAntiFlyArea = false
16
local heroVisitedAntiFlyArea = false
17
local heroAtFinalStep = false
18
local iceGunTaken = false
19
local checkPointReached = 1 -- 1 is normal spawn
20
local heroDamageAtCurrentTurn = 0
26
[dialog01] = {missionName, loc("Getting ready"), loc("Collect the icegun and get the device part from Thanta"), 1, 4500},
27
[dialog02] = {missionName, loc("Win"), loc("Congratulations, you collected the device part!"), 1, 3500},
45
hero.name = loc("Hog Solo")
49
ally.name = loc("Paul McHoggy")
52
bandit1.name = loc("Thanta")
56
bandit1.frozen = false
57
bandit1.roundsToUnfreeze = 0
58
bandit2.name = loc("Billy Frost")
61
bandit3.name = loc("Ice Jake")
64
bandit4.name = loc("John Snow")
67
bandit4.frozen = false
68
bandit4.roundsToUnfreeze = 0
69
bandit5.name = loc("White Tee")
72
bandit5.frozen = false
73
bandit5.roundsToUnfreeze = 0
74
teamA.name = loc("Allies")
75
teamA.color = tonumber("FF0000",16) -- red
76
teamB.name = loc("Frozen Bandits")
77
teamB.color = tonumber("0033FF",16) -- blues
78
teamC.name = loc("Hog Solo")
79
teamC.color = tonumber("38D61C",16) -- green
81
-------------- LuaAPI EVENT HANDLERS ------------------
94
-- get the check point
95
checkPointReached = initCheckpoint("ice01")
97
local heroHealth = 100
98
if tonumber(GetCampaignVar("HeroHealth")) then
99
heroHealth = tonumber(GetCampaignVar("HeroHealth"))
102
if heroHealth ~= 100 then
103
heroHealth = heroHealth + 5
104
if heroHealth > 100 then
107
SaveCampaignVar("HeroHealth", heroHealth)
111
AddTeam(teamC.name, teamC.color, "Bone", "Island", "HillBilly", "cm_birdy")
112
hero.gear = AddHog(hero.name, 0, heroHealth, "war_desertgrenadier1")
113
AnimSetGearPosition(hero.gear, hero.x, hero.y)
114
HogTurnLeft(hero.gear, true)
116
AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
117
ally.gear = AddHog(ally.name, 0, 100, "war_airwarden02")
118
AnimSetGearPosition(ally.gear, ally.x, ally.y)
120
AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
121
bandit1.gear = AddHog(bandit1.name, 1, 120, "Santa")
122
AnimSetGearPosition(bandit1.gear, bandit1.x, bandit1.y)
123
HogTurnLeft(bandit1.gear, true)
124
bandit2.gear = AddHog(bandit2.name, 1, 100, "ushanka")
125
AnimSetGearPosition(bandit2.gear, bandit2.x, bandit2.y)
126
bandit3.gear = AddHog(bandit3.name, 1, 100, "thug")
127
AnimSetGearPosition(bandit3.gear, bandit3.x, bandit3.y)
128
bandit4.gear = AddHog(bandit4.name, 1, 40, "tophats")
129
AnimSetGearPosition(bandit4.gear, bandit4.x, bandit4.y)
130
HogTurnLeft(bandit4.gear, true)
131
bandit5.gear = AddHog(bandit5.name, 1, 40, "Sniper")
132
AnimSetGearPosition(bandit5.gear, bandit5.x, bandit5.y)
133
HogTurnLeft(bandit5.gear, true)
135
if checkPointReached == 1 then
137
elseif checkPointReached == 2 then
139
AnimSetGearPosition(hero.gear, 840, 1650)
140
elseif checkPointReached == 3 then
142
heroAtFinalStep = true
143
heroVisitedAntiFlyArea = true
144
AnimSetGearPosition(hero.gear, 1450, 910)
151
function onGameStart()
152
AnimWait(hero.gear, 3000)
153
FollowGear(hero.gear)
156
AddGear(1612, 940, gtMine, 0, 0, 0, 0)
157
AddGear(1622, 945, gtMine, 0, 0, 0, 0)
158
AddGear(1645, 950, gtMine, 0, 0, 0, 0)
159
AddGear(1655, 960, gtMine, 0, 0, 0, 0)
160
AddGear(1665, 965, gtMine, 0, 0, 0, 0)
162
AddGear(1800, 1000, gtMine, 0, 0, 0, 0)
163
AddGear(1810, 1005, gtMine, 0, 0, 0, 0)
164
AddGear(1820, 1010, gtMine, 0, 0, 0, 0)
165
AddGear(1830, 1015, gtMine, 0, 0, 0, 0)
166
AddGear(1840, 1020, gtMine, 0, 0, 0, 0)
168
AddGear(1900, 1020, gtMine, 0, 0, 0, 0)
169
AddGear(1910, 1020, gtMine, 0, 0, 0, 0)
170
AddGear(1920, 1020, gtMine, 0, 0, 0, 0)
171
AddGear(1930, 1030, gtMine, 0, 0, 0, 0)
172
AddGear(1940, 1040, gtMine, 0, 0, 0, 0)
174
AddGear(2130, 1110, gtMine, 0, 0, 0, 0)
175
AddGear(2140, 1120, gtMine, 0, 0, 0, 0)
176
AddGear(2180, 1120, gtMine, 0, 0, 0, 0)
177
AddGear(2200, 1130, gtMine, 0, 0, 0, 0)
178
AddGear(2210, 1130, gtMine, 0, 0, 0, 0)
183
AddGear(x, 1150, gtMine, 0, 0, 0, 0)
187
x = x + GetRandom(201)+100
189
x = x + GetRandom(21)+10
193
AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
194
AddEvent(onHeroFinalStep, {hero.gear}, heroFinalStep, {hero.gear}, 0)
195
AddEvent(onAntiFlyArea, {hero.gear}, antiFlyArea, {hero.gear}, 1)
196
AddEvent(onAntiFlyAreaVelocity, {hero.gear}, antiFlyAreaVelocity, {hero.gear}, 1)
197
AddEvent(onNonAntiFlyArea, {hero.gear}, nonAntiFlyArea, {hero.gear}, 1)
198
AddEvent(onThantaDeath, {bandit1.gear}, thantaDeath, {bandit1.gear}, 0)
199
AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 0)
201
AddAmmo(hero.gear, amJetpack, 99)
202
AddAmmo(bandit1.gear, amBazooka, 5)
203
AddAmmo(bandit2.gear, amBazooka, 4)
204
AddAmmo(bandit3.gear, amMine, 2)
205
AddAmmo(bandit3.gear, amGrenade, 3)
206
AddAmmo(bandit4.gear, amBazooka, 5)
207
AddAmmo(bandit5.gear, amBazooka, 5)
209
goToThantaString = loc("Go to Thanta and get the device part!")
211
if checkPointReached == 1 then
212
AddAmmo(hero.gear, amBazooka, 1)
213
SpawnAmmoCrate(icegunX, icegunY, amIceGun)
214
AddEvent(onColumnCheckPoint, {hero.gear}, columnCheckPoint, {hero.gear}, 0)
215
AddEvent(onHeroAtIceGun, {hero.gear}, heroAtIceGun, {hero.gear}, 0)
217
elseif checkPointReached == 2 then
218
AddAmmo(hero.gear, amIceGun, 8)
219
AnimCaption(hero.gear, goToThantaString, 5000)
220
elseif checkPointReached == 3 then
221
AddAmmo(hero.gear, amIceGun, 6)
222
AnimCaption(hero.gear, goToThantaString, 5000)
229
heroDamageAtCurrentTurn = 0
230
-- round has to start if hero goes near the column
231
if not heroVisitedAntiFlyArea and CurrentHedgehog ~= hero.gear then
233
elseif not heroVisitedAntiFlyArea and CurrentHedgehog == hero.gear then
235
elseif not heroAtFinalStep and (CurrentHedgehog == bandit1.gear or CurrentHedgehog == bandit4.gear or CurrentHedgehog == bandit5.gear) then
236
AnimSwitchHog(hero.gear)
238
elseif heroAtFinalStep and (CurrentHedgehog == bandit2.gear or CurrentHedgehog == bandit3.gear) then
239
if (GetHealth(bandit1.gear) and GetEffect(bandit1.gear,heFrozen) > 256) and
240
((GetHealth(bandit4.gear) and GetEffect(bandit4.gear,heFrozen) > 256) or not GetHealth(bandit4.gear)) and
241
((GetHealth(bandit5.gear) and GetEffect(bandit5.gear,heFrozen) > 256) or not GetHealth(bandit5.gear)) then
244
AnimSwitchHog(hero.gear)
247
elseif CurrentHedgehog == ally.gear then
250
-- frozen hogs accounting
251
if CurrentHedgehog == hero.gear and heroAtFinalStep and TurnTimeLeft > 0 then
252
if bandit1.frozen then
253
if bandit1.roundsToUnfreeze == 0 then
254
SetEffect(bandit1.gear, heFrozen, 255)
255
bandit1.frozen = false
257
bandit1.roundsToUnfreeze = bandit1.roundsToUnfreeze - 1
260
if bandit4.frozen then
261
if bandit4.roundsToUnfreeze == 0 then
262
SetEffect(bandit4.gear, heFrozen, 255)
263
bandit4.frozen = false
265
bandit4.roundsToUnfreeze = bandit4.roundsToUnfreeze - 1
268
if bandit5.frozen then
269
if bandit5.roundsToUnfreeze == 0 then
270
SetEffect(bandit5.gear, heFrozen, 255)
271
bandit5.frozen = false
273
bandit5.roundsToUnfreeze = bandit5.roundsToUnfreeze - 1
277
if bandit1.frozen then
278
SetEffect(bandit1.gear, heFrozen, 9999999999)
280
if bandit4.frozen then
281
SetEffect(bandit4.gear, heFrozen, 9999999999)
283
if bandit5.frozen then
284
SetEffect(bandit5.gear, heFrozen, 9999999999)
289
function onGameTick()
291
if ShowAnimation() == false then
294
ExecuteAfterAnimations()
297
if GetEffect(bandit1.gear, heFrozen) > 256 and not bandit1.frozen then
298
bandit1.frozen = true
299
SetEffect(bandit1.gear, heFrozen, 9999999999)
300
bandit1.roundsToUnfreeze = 1
302
if GetEffect(bandit4.gear, heFrozen) > 256 and not bandit4.frozen then
303
bandit4.frozen = true
304
SetEffect(bandit4.gear, heFrozen, 9999999999)
305
bandit4.roundsToUnfreeze = 2
307
if GetEffect(bandit5.gear, heFrozen) > 256 and not bandit5.frozen then
308
bandit5.frozen = true
309
SetEffect(bandit5.gear, heFrozen, 9999999999)
310
bandit5.roundsToUnfreeze = 2
314
function onAmmoStoreInit()
315
SetAmmo(amIceGun, 0, 0, 0, 8)
318
function onGearDelete(gear)
319
if gear == hero.gear then
321
elseif gear == bandit1.gear then
327
if GameTime > 3000 then
332
function onGearDamage(gear, damage)
333
if gear == hero.gear then
334
heroDamageAtCurrentTurn = heroDamageAtCurrentTurn + damage
338
-------------- EVENTS ------------------
340
function onAntiFlyArea(gear)
341
if not hero.dead and (GetX(gear) > 860 or GetY(gear) < 1400) and not heroAtAntiFlyArea then
347
function onAntiFlyAreaVelocity(gear)
348
if not hero.dead and GetY(gear) < 1300 and GetX(gear) < 1190 then
354
function onNonAntiFlyArea(gear)
355
if not hero.dead and (GetX(gear) < 860 and GetY(gear) > 1400) and heroAtAntiFlyArea then
361
function onHeroDeath(gear)
368
function onHeroFinalStep(gear)
369
if not hero.dead and GetY(gear) < 960 and GetX(gear) > 1400 then
375
function onColumnCheckPoint(gear)
376
if not hero.dead and iceGunTaken and GetX(gear) < 870 and GetX(gear) > 850 and GetY(gear) > 1500 and StoppedGear(gear) then
382
function onHeroAtIceGun(gear)
383
if not hero.dead and GetX(gear) < icegunX+15 and GetX(gear) > icegunX-15 and GetY(gear) > icegunY-15 and GetY(gear) < icegunY+15 then
389
function onThantaDeath(gear)
396
function onHeroWin(gear)
397
if (not hero.dead and not bandit1.dead) and heroDamageAtCurrentTurn == 0 and (GetX(hero.gear)>=GetX(bandit1.gear)-80
398
and GetX(hero.gear)<=GetX(bandit1.gear)+80) and (GetY(hero.gear)>=GetY(bandit1.gear)-30 and GetY(hero.gear)<=GetY(bandit1.gear)+30) then
404
-------------- ACTIONS ------------------
406
function antiFlyArea(gear)
407
heroAtAntiFlyArea = true
408
if not heroVisitedAntiFlyArea then
410
FollowGear(hero.gear)
411
AnimSwitchHog(bandit1.gear)
412
FollowGear(hero.gear)
415
AddAmmo(hero.gear, amJetpack, 0)
416
heroVisitedAntiFlyArea = true
419
function antiFlyAreaVelocity(gear)
420
dx, dy = GetGearVelocity(hero.gear)
421
SetGearVelocity(hero.gear, dx, math.max(dy, 0))
424
function nonAntiFlyArea(gear)
425
heroAtAntiFlyArea = false
426
AddAmmo(hero.gear, amJetpack, 99)
429
function heroDeath(gear)
430
SendStat(siGameResult, loc("Hog Solo lost, try again!"))
431
SendStat(siCustomAchievement, loc("To win the game you have to go next to Thanta"))
432
SendStat(siCustomAchievement, loc("Most of the time you'll be able to use only the icegun"))
433
SendStat(siCustomAchievement, loc("Use the bazooka and the flying saucer to get the icegun"))
434
SendStat(siPlayerKills,'1',teamB.name)
435
SendStat(siPlayerKills,'0',teamC.name)
439
function heroFinalStep(gear)
440
heroAtFinalStep = true
442
SaveCampaignVar("HeroHealth", GetHealth(hero.gear))
445
function columnCheckPoint(gear)
447
SaveCampaignVar("HeroHealth", GetHealth(hero.gear))
448
AnimCaption(hero.gear, loc("Checkpoint reached!"), 5000)
451
function heroAtIceGun(gear)
455
function thantaDeath(gear)
456
SendStat(siGameResult, loc("Hog Solo lost, try again!"))
457
SendStat(siCustomAchievement, loc("Noooo, Thanta has to stay alive!"))
458
SendStat(siCustomAchievement, loc("To win the game you have to go next to Thanta"))
459
SendStat(siCustomAchievement, loc("Most of the time you'll be able to use only the icegun"))
460
SendStat(siCustomAchievement, loc("Use the bazooka and the flying saucer to get the icegun"))
461
SendStat(siPlayerKills,'1',teamB.name)
462
SendStat(siPlayerKills,'0',teamC.name)
466
function heroWin(gear)
468
if GetX(hero.gear) < GetX(bandit1.gear) then
469
HogTurnLeft(bandit1.gear, true)
471
HogTurnLeft(bandit1.gear, false)
476
-------------- ANIMATIONS ------------------
478
function Skipanim(anim)
479
if goals[anim] ~= nil then
480
ShowMission(unpack(goals[anim]))
482
if anim == dialog02 then
485
AnimSwitchHog(hero.gear)
489
function AnimationSetup()
490
-- DIALOG 01 - Start, welcome to moon
491
AddSkipFunction(dialog01, Skipanim, {dialog01})
492
table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}})
493
table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("On the Ice Planet, where ice rules..."), 5000}})
494
table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("Finally you are here..."), SAY_SAY, 2000}})
495
table.insert(dialog01, {func = AnimWait, args = {hero.gear, 2000}})
496
table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Hi! Nice to meet you"), SAY_SAY, 3000}})
497
table.insert(dialog01, {func = AnimWait, args = {ally.gear, 2000}})
498
table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("Listen carefully! The bandit leader, Thanta, has recently found a very strange device"), SAY_SAY, 4000}})
499
table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("He doesn't know it but this device is a part of the anti-gravity device"), SAY_SAY, 2500}})
500
table.insert(dialog01, {func = AnimWait, args = {hero.gear, 8000}})
501
table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Nice, then I should get the part as soon as possible!"), SAY_SAY, 4000}})
502
table.insert(dialog01, {func = AnimWait, args = {ally.gear, 4000}})
503
table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("Be careful, your gadgets won't work in the bandit area. You should get an ice gun"), SAY_SAY, 7000}})
504
table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("There is one below us!"), SAY_SAY, 4000}})
505
table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}})
506
table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}})
507
-- DIALOG 02 - Hero got to Thant2
508
AddSkipFunction(dialog02, Skipanim, {dialog02})
509
table.insert(dialog02, {func = AnimWait, args = {hero.gear, 3000}})
510
table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("Congratulations, now you can take Thanta's device part..."), 5000}})
511
table.insert(dialog02, {func = AnimSay, args = {bandit1.gear, loc("Oh! Please spare me. You can take all my treasures!"), SAY_SAY, 3000}})
512
table.insert(dialog02, {func = AnimWait, args = {hero.gear, 5000}})
513
table.insert(dialog02, {func = AnimSay, args = {hero.gear, loc("I just want the strange device you found!"), SAY_SAY, 3000}})
514
table.insert(dialog02, {func = AnimWait, args = {bandit1.gear, 4000}})
515
table.insert(dialog02, {func = AnimSay, args = {bandit1.gear, loc("Here! Take it..."), SAY_SAY, 3000}})
516
table.insert(dialog02, {func = actionsOnWin, args = {}})
519
-------------- Other Functions -------------------
521
function actionsOnWin()
522
saveCompletedStatus(4)
523
SendStat(siGameResult, loc("Congratulations, you acquired the device part!"))
524
SendStat(siCustomAchievement, loc("At the end of the game your health was ")..GetHealth(hero.gear))
525
-- maybe add number of tries for each part?
526
SendStat(siPlayerKills,'1',teamC.name)
527
SendStat(siPlayerKills,'0',teamB.name)