|
1 ------------------- ABOUT ---------------------- |
|
2 -- |
|
3 -- Hog Solo has to catch the other hog in order |
|
4 -- to get infoormations about the origin of Pr. Hogevil |
|
5 |
|
6 HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
7 HedgewarsScriptLoad("/Scripts/Animate.lua") |
|
8 HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua") |
|
9 |
|
10 ----------------- VARIABLES -------------------- |
|
11 -- globals |
|
12 local missionName = loc("Chasing ghosts in moon") |
|
13 local challengeObjectives = loc("Use your available weapons in order to catch the other hog").."|".. |
|
14 loc("You have to stand very close to him") |
|
15 local currentPosition = 1 |
|
16 local previousTimeLeft = 0 |
|
17 -- dialogs |
|
18 local dialog01 = {} |
|
19 -- mission objectives |
|
20 local goals = { |
|
21 [dialog01] = {missionName, loc("Challenge Objectives"), challengeObjectives, 1, 4500}, |
|
22 } |
|
23 -- hogs |
|
24 local hero = { |
|
25 name = loc("Hog Solo"), |
|
26 x = 1300, |
|
27 y = 850 |
|
28 } |
|
29 local runner = { |
|
30 name = loc("Crazy Runner"), |
|
31 places = { |
|
32 {x = 1400,y = 850, turnTime = 0}, |
|
33 {x = 3880,y = 33, turnTime = 30000}, |
|
34 {x = 250,y = 1780, turnTime = 25000}, |
|
35 {x = 3850,y = 1940, turnTime = 20000}, |
|
36 } |
|
37 } |
|
38 -- teams |
|
39 local teamA = { |
|
40 name = loc("Hog Solo"), |
|
41 color = tonumber("38D61C",16) -- green |
|
42 } |
|
43 local teamB = { |
|
44 name = loc("Crazy Runner"), |
|
45 color = tonumber("FF0000",16) -- red |
|
46 } |
|
47 |
|
48 -------------- LuaAPI EVENT HANDLERS ------------------ |
|
49 |
|
50 function onGameInit() |
|
51 GameFlags = gfDisableWind |
|
52 Seed = 1 |
|
53 TurnTime = 25000 |
|
54 CaseFreq = 0 |
|
55 MinesNum = 0 |
|
56 MinesTime = 1 |
|
57 Explosives = 0 |
|
58 Map = "moon02_map" |
|
59 Theme = "Cheese" |
|
60 |
|
61 -- Hog Solo |
|
62 AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy") |
|
63 hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1") |
|
64 AnimSetGearPosition(hero.gear, hero.x, hero.y) |
|
65 -- Crazy Runner |
|
66 AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy") |
|
67 runner.gear = AddHog(runner.name, 0, 100, "war_desertgrenadier1") |
|
68 AnimSetGearPosition(runner.gear, runner.places[1].x, runner.places[1].y) |
|
69 HogTurnLeft(runner.gear, true) |
|
70 |
|
71 initCheckpoint("moon02") |
|
72 |
|
73 AnimInit() |
|
74 AnimationSetup() |
|
75 end |
|
76 |
|
77 function onGameStart() |
|
78 AnimWait(hero.gear, 3000) |
|
79 FollowGear(hero.gear) |
|
80 ShowMission(missionName, loc("Challenge Objectives"), challengeObjectives, -amSkip, 0) |
|
81 |
|
82 AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) |
|
83 AddEvent(onLose, {hero.gear}, lose, {hero.gear}, 0) |
|
84 |
|
85 AddAmmo(hero.gear, amRope, 1) |
|
86 AddAmmo(hero.gear, amTeleport, 100) |
|
87 |
|
88 SendHealthStatsOff() |
|
89 hogTurn = runner.gear |
|
90 AddAnim(dialog01) |
|
91 end |
|
92 |
|
93 function onNewTurn() |
|
94 WriteLnToConsole("NEW TURN "..CurrentHedgehog) |
|
95 if CurrentHedgehog == hero.gear then |
|
96 TurnTimeLeft = runner.places[currentPosition].turnTime + previousTimeLeft |
|
97 WriteLnToConsole("Turn Time is "..TurnTimeLeft) |
|
98 previousTimeLeft = 0 |
|
99 WriteLnToConsole("STILL HERE AND "..TurnTimeLeft.." prev hog = "..hogTurn) |
|
100 else |
|
101 TurnTimeLeft = 0 |
|
102 end |
|
103 end |
|
104 |
|
105 function onGameTick() |
|
106 AnimUnWait() |
|
107 if ShowAnimation() == false then |
|
108 return |
|
109 end |
|
110 ExecuteAfterAnimations() |
|
111 CheckEvents() |
|
112 end |
|
113 |
|
114 function onGameTick20() |
|
115 if isHeroNextToRunner() then |
|
116 moveRunner() |
|
117 end |
|
118 end |
|
119 |
|
120 function onPrecise() |
|
121 if GameTime > 3000 then |
|
122 SetAnimSkip(true) |
|
123 end |
|
124 end |
|
125 |
|
126 -------------- EVENTS ------------------ |
|
127 |
|
128 function onHeroDeath(gear) |
|
129 if not GetHealth(hero.gear) then |
|
130 return true |
|
131 end |
|
132 return false |
|
133 end |
|
134 |
|
135 function onLose(gear) |
|
136 if (GetAmmoCount(hero.gear, amRope) == 0 and previousTimeLeft == 0) or (CurrentHedgehog == hero.gear and TurnTimeLeft == 0)then |
|
137 return true |
|
138 end |
|
139 return false |
|
140 end |
|
141 |
|
142 -------------- ACTIONS ------------------ |
|
143 |
|
144 function heroDeath(gear) |
|
145 -- game over |
|
146 WriteLnToConsole("END GAME 1") |
|
147 EndGame() |
|
148 end |
|
149 |
|
150 function lose(gear) |
|
151 -- game over |
|
152 WriteLnToConsole("END GAME 2") |
|
153 EndGame() |
|
154 end |
|
155 |
|
156 -------------- ANIMATIONS ------------------ |
|
157 |
|
158 function Skipanim(anim) |
|
159 if goals[anim] ~= nil then |
|
160 ShowMission(unpack(goals[anim])) |
|
161 end |
|
162 if anim == dialog01 then |
|
163 moveRunner() |
|
164 end |
|
165 end |
|
166 |
|
167 function AnimationSetup() |
|
168 -- DIALOG 01 - Start, game instructions |
|
169 AddSkipFunction(dialog01, Skipanim, {dialog01}) |
|
170 table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3200}}) |
|
171 table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("In the other side of the moon..."), 5000}}) |
|
172 table.insert(dialog01, {func = AnimSay, args = {runner.gear, loc("So you are interested in Pr. Hogevil"), SAY_SAY, 3000}}) |
|
173 table.insert(dialog01, {func = AnimSay, args = {runner.gear, loc("We'll play a game first"), SAY_SAY, 3000}}) |
|
174 table.insert(dialog01, {func = AnimSay, args = {runner.gear, loc("I'll let you know whatever I know about him if you manage to catch me 3 times"), SAY_SAY, 4000}}) |
|
175 table.insert(dialog01, {func = AnimSay, args = {runner.gear, loc("Let's go!"), SAY_SAY, 2000}}) |
|
176 table.insert(dialog01, {func = moveRunner, args = {}}) |
|
177 end |
|
178 |
|
179 ------------- other functions --------------- |
|
180 |
|
181 function isHeroNextToRunner() |
|
182 if GetHealth(hero.gear) and math.abs(GetX(hero.gear) - GetX(runner.gear)) < 75 and |
|
183 math.abs(GetY(hero.gear) - GetY(runner.gear)) < 75 and StoppedGear(hero.gear) then |
|
184 return true |
|
185 end |
|
186 return false |
|
187 end |
|
188 |
|
189 function moveRunner() |
|
190 AddAmmo(hero.gear, amRope, 1) |
|
191 -- add anim dialogs here |
|
192 if currentPosition ~= 1 then |
|
193 PlaySound(sndVictory) |
|
194 AnimSay(runner.gear, loc("You got me"), SAY_SAY, 3000) |
|
195 previousTimeLeft = TurnTimeLeft |
|
196 end |
|
197 currentPosition = currentPosition + 1 |
|
198 SetGearPosition(runner.gear, runner.places[currentPosition].x, runner.places[currentPosition].y) |
|
199 WriteLnToConsole("HERE 1") |
|
200 AnimSwitchHog(runner.gear) |
|
201 TurnTimeLeft = 0 |
|
202 WriteLnToConsole("HERE 2") |
|
203 end |