|
1 ------------------- ABOUT ---------------------- |
|
2 -- |
|
3 -- Hero has to pass as fast as possible inside the |
|
4 -- rings as in the racer mode |
|
5 |
|
6 HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
7 HedgewarsScriptLoad("/Scripts/Animate.lua") |
|
8 |
|
9 ----------------- VARIABLES -------------------- |
|
10 -- globals |
|
11 local campaignName = loc("A Space Adventure") |
|
12 local missionName = loc("Desert planet, Journey down below!") |
|
13 local challengeStarted = false |
|
14 local currentWaypoint = 1 |
|
15 local radius = 75 |
|
16 local totalTime = 15000 |
|
17 local totalSaucers = 3 |
|
18 local gameEnded = false |
|
19 -- dialogs |
|
20 local dialog01 = {} |
|
21 -- mission objectives |
|
22 local goals = { |
|
23 [dialog01] = {missionName, loc("Getting ready"), loc("Use your saucer and pass from the rings!"), 1, 4500}, |
|
24 } |
|
25 -- hogs |
|
26 local hero = {} |
|
27 local ally = {} |
|
28 -- teams |
|
29 local teamA = {} |
|
30 -- hedgehogs values |
|
31 hero.name = "Hog Solo" |
|
32 hero.x = 1600 |
|
33 hero.y = 1950 |
|
34 hero.dead = false |
|
35 teamA.name = loc("Hog Solo") |
|
36 teamA.color = tonumber("38D61C",16) -- green |
|
37 -- way points |
|
38 local current waypoint = 1 |
|
39 local waypoints = { |
|
40 [1] = {x=1450, y=140}, |
|
41 [2] = {x=990, y=580}, |
|
42 [3] = {x=1650, y=950}, |
|
43 [4] = {x=620, y=630}, |
|
44 [5] = {x=1470, y=540}, |
|
45 [6] = {x=1960, y=60}, |
|
46 [7] = {x=1600, y=400}, |
|
47 [8] = {x=240, y=940}, |
|
48 [9] = {x=200, y=530}, |
|
49 [10] = {x=1180, y=120}, |
|
50 [11] = {x=1950, y=660}, |
|
51 [12] = {x=1280, y=980}, |
|
52 [13] = {x=590, y=1100}, |
|
53 [14] = {x=20, y=620}, |
|
54 [15] = {x=hero.x, y=hero.y} |
|
55 } |
|
56 |
|
57 -------------- LuaAPI EVENT HANDLERS ------------------ |
|
58 |
|
59 function onGameInit() |
|
60 GameFlags = gfOneClanMode |
|
61 Seed = 1 |
|
62 TurnTime = 6000 |
|
63 Delay = 2 |
|
64 CaseFreq = 0 |
|
65 MinesNum = 0 |
|
66 MinesTime = 1 |
|
67 Explosives = 0 |
|
68 SuddenDeathTurns = 1 |
|
69 WaterRise = 150 |
|
70 Map = "desert02_map" |
|
71 Theme = "Desert" |
|
72 |
|
73 -- Hog Solo |
|
74 AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy") |
|
75 hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1") |
|
76 AnimSetGearPosition(hero.gear, hero.x, hero.y) |
|
77 HogTurnLeft(hero.gear, true) |
|
78 |
|
79 AnimInit() |
|
80 AnimationSetup() |
|
81 end |
|
82 |
|
83 function onGameStart() |
|
84 AnimWait(hero.gear, 3000) |
|
85 FollowGear(hero.gear) |
|
86 |
|
87 AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) |
|
88 |
|
89 AddAmmo(hero.gear, amRope, 99) |
|
90 |
|
91 SendHealthStatsOff() |
|
92 AddAnim(dialog01) |
|
93 end |
|
94 |
|
95 function onNewTurn() |
|
96 if not hero.dead and CurrentHedgehog == ally.gear and challengeStarted then |
|
97 heroLost() |
|
98 end |
|
99 end |
|
100 |
|
101 function onGameTick() |
|
102 AnimUnWait() |
|
103 if ShowAnimation() == false then |
|
104 return |
|
105 end |
|
106 ExecuteAfterAnimations() |
|
107 CheckEvents() |
|
108 end |
|
109 |
|
110 function onGearDelete(gear) |
|
111 if gear == hero.gear then |
|
112 hero.dead = true |
|
113 end |
|
114 end |
|
115 |
|
116 function onPrecise() |
|
117 if GameTime > 3000 then |
|
118 SetAnimSkip(true) |
|
119 end |
|
120 end |
|
121 |
|
122 -------------- EVENTS ------------------ |
|
123 |
|
124 function onHeroDeath(gear) |
|
125 if hero.dead then |
|
126 return true |
|
127 end |
|
128 return false |
|
129 end |
|
130 |
|
131 -------------- OUTCOMES ------------------ |
|
132 |
|
133 function heroDeath(gear) |
|
134 heroLost() |
|
135 end |
|
136 |
|
137 -------------- ANIMATIONS ------------------ |
|
138 |
|
139 function Skipanim(anim) |
|
140 if goals[anim] ~= nil then |
|
141 ShowMission(unpack(goals[anim])) |
|
142 end |
|
143 end |
|
144 |
|
145 function AnimationSetup() |
|
146 -- DIALOG 01 - Start |
|
147 AddSkipFunction(dialog01, Skipanim, {dialog01}) |
|
148 table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}}) |
|
149 table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Many meters below the surface..."), 5000}}) |
|
150 table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("The tunnel is about to get flooded..."), SAY_THINK, 4000}}) |
|
151 table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("I have to reach the surface asap..."), SAY_THINK, 4000}}) |
|
152 table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}}) |
|
153 table.insert(dialog01, {func = challengeStart, args = {hero.gear}}) |
|
154 end |
|
155 |
|
156 ------------------ Other Functions ------------------- |
|
157 |
|
158 function challengeStart() |
|
159 TurnTimeLeft = 0 |
|
160 end |