1 HedgewarsScriptLoad("/Scripts/Utils.lua") |
|
2 HedgewarsScriptLoad("/Scripts/Locale.lua") |
1 HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
2 HedgewarsScriptLoad("/Scripts/RopeKnocking.lua") |
3 |
3 |
4 local hhs = {} |
4 -- In this mission, the names of the enemy hogs are chosen randomly from this list. |
5 local missionWon = nil |
5 -- As a nod to the community, this list contains names of actual users/players; |
6 local missionEndHandled = false |
6 -- Mostly developers, contributors, high-ranking players in a shoppa tournament, |
7 local endTimer = 1000 |
7 -- highly active forum users. |
8 local hogsKilled = 0 |
|
9 local finishTime |
|
10 local ouchies = false |
|
11 local valkyriesTimer = -1 |
|
12 |
8 |
13 local HogData = { |
9 -- NOTE: These names are intentionally not translated. |
14 {"amn", "NinjaFull",false}, |
10 local hogData = { |
15 {"alfadur", "NoHat",false}, |
11 {"amn", "NinjaFull"}, |
16 {"Anachron", "war_americanww2helmet",false}, |
12 {"alfadur", "NoHat"}, |
17 {"Bufon", "ShaggyYeti",false}, |
13 {"Anachron", "war_americanww2helmet"}, |
18 {"burp", "lambda",false}, |
14 {"Bufon", "ShaggyYeti"}, |
19 {"Blue", "cap_blue",false}, |
15 {"burp", "lambda"}, |
20 {"bender", "NoHat",false}, |
16 {"Blue", "cap_blue"}, |
21 {"Castell", "NoHat",false}, |
17 {"bender", "NoHat"}, |
22 {"cekoto", "NoHat",false}, |
18 {"Castell", "NoHat"}, |
23 {"CheezeMonkey", "NoHat",false}, |
19 {"cekoto", "NoHat"}, |
24 {"claymore", "NoHat",false}, |
20 {"CheezeMonkey", "NoHat"}, |
25 {"CIA-144", "cyborg1",false}, |
21 {"claymore", "NoHat"}, |
26 {"cri.the.grinch", "sf_blanka",false}, |
22 {"CIA-144", "cyborg1"}, |
27 {"eldiablo", "Evil",false}, |
23 {"cri.the.grinch", "sf_blanka"}, |
28 {"Displacer", "fr_lemon",false}, |
24 {"eldiablo", "Evil"}, |
29 {"doomy", "NoHat",false}, |
25 {"Displacer", "fr_lemon"}, |
30 {"Falkenauge", "NoHat",false}, |
26 {"doomy", "NoHat"}, |
31 {"FadeOne", "NoHat",false}, |
27 {"Falkenauge", "NoHat"}, |
32 {"hayaa", "NoHat",false}, |
28 {"FadeOne", "NoHat"}, |
33 {"Hermes", "laurel",false}, |
29 {"hayaa", "NoHat"}, |
34 {"Henek", "WizardHat",false}, |
30 {"Hermes", "laurel"}, |
35 {"HedgeKing", "NoHat",false}, |
31 {"Henek", "WizardHat"}, |
36 {"Izack1535", "NoHat",false}, |
32 {"HedgeKing", "NoHat"}, |
37 {"Kiofspa", "NoHat",false}, |
33 {"Izack1535", "NoHat"}, |
38 {"KoBeWi", "NoHat",false}, |
34 {"Kiofspa", "NoHat"}, |
39 {"Komplex", "NoHat",false}, |
35 {"KoBeWi", "NoHat"}, |
40 {"koda", "poke_mudkip",false}, |
36 {"Komplex", "NoHat"}, |
41 {"Lalo", "NoHat",false}, |
37 {"koda", "poke_mudkip"}, |
42 {"Logan", "NoHat",false}, |
38 {"Lalo", "NoHat"}, |
43 {"lollkiller", "NoHat",false}, |
39 {"Logan", "NoHat"}, |
44 {"Luelle", "NoHat",false}, |
40 {"lollkiller", "NoHat"}, |
45 {"mikade", "Skull",false}, |
41 {"Luelle", "NoHat"}, |
46 {"Mushi", "sm_daisy",false}, |
42 {"mikade", "Skull"}, |
47 {"Naboo", "NoHat",false}, |
43 {"Mushi", "sm_daisy"}, |
48 {"nemo", "bb_bub",false}, |
44 {"Naboo", "NoHat"}, |
49 {"practice", "NoHat",false}, |
45 {"nemo", "bb_bub"}, |
50 {"Prof. Panic", "NoHat",false}, |
46 {"practice", "NoHat"}, |
51 {"Randy", "zoo_Sheep",false}, |
47 {"Prof. Panic", "NoHat"}, |
52 {"rhino", "NinjaTriangle",false}, |
48 {"Randy", "zoo_Sheep"}, |
53 {"Radissthor", "NoHat",false}, |
49 {"rhino", "NinjaTriangle"}, |
54 {"Sami", "sm_peach",false}, |
50 {"Radissthor", "NoHat"}, |
55 {"soreau", "NoHat",false}, |
51 {"Sami", "sm_peach"}, |
56 {"Solar", "pinksunhat",false}, |
52 {"soreau", "NoHat"}, |
57 {"sparkle", "NoHat",false}, |
53 {"Solar", "pinksunhat"}, |
58 {"szczur", "mp3",false}, |
54 {"sparkle", "NoHat"}, |
59 {"sdw195", "NoHat",false}, |
55 {"szczur", "mp3"}, |
60 {"sphrix", "TeamTopHat",false}, |
56 {"sdw195", "NoHat"}, |
61 {"sheepluva", "zoo_Sheep",false}, |
57 {"sphrix", "TeamTopHat"}, |
62 {"Smaxx", "NoHat",false}, |
58 {"sheepluva", "zoo_Sheep"}, |
63 {"shadowzero", "NoHat",false}, |
59 {"Smaxx", "NoHat"}, |
64 {"Star and Moon", "SparkleSuperFun",false}, |
60 {"shadowzero", "NoHat"}, |
65 {"The 24", "NoHat",false}, |
61 {"Star and Moon", "SparkleSuperFun"}, |
66 {"TLD", "NoHat",false}, |
62 {"The 24", "NoHat"}, |
67 {"Tiyuri", "sf_ryu",false}, |
63 {"TLD", "NoHat"}, |
68 {"unC0Rr", "cyborg1",false}, |
64 {"Tiyuri", "sf_ryu"}, |
69 {"Waldsau", "cyborg1",false}, |
65 {"unC0Rr", "cyborg1"}, |
70 {"wolfmarc", "knight",false}, |
66 {"Waldsau", "cyborg1"}, |
71 {"Wuzzy", "fr_orange",false}, |
67 {"wolfmarc", "knight"}, |
72 {"Xeli", "android",false} |
68 {"Wuzzy", "fr_orange"}, |
|
69 {"Xeli", "android"} |
|
70 } |
73 |
71 |
74 } |
72 local function assignNamesAndHats(team) |
75 |
73 for t=1, #team do |
76 local playerTeamName |
74 local d = 1 + GetRandom(#hogData) |
77 |
75 team[t].name = hogData[d][1] |
78 function GetKillScore() |
76 team[t].hat = hogData[d][2] |
79 return math.ceil((hogsKilled / 16)*6000) |
77 table.remove(hogData, d) |
80 end |
|
81 |
|
82 function ProtectEnemies() |
|
83 for i=1, 16 do |
|
84 if hhs[i] and GetHealth(hhs[i]) then |
|
85 SetEffect(hhs[i], heInvulnerable, 1) |
|
86 end |
|
87 end |
78 end |
88 end |
79 end |
89 |
80 |
90 function GameOverMan() |
|
91 StopMusicSound(sndRideOfTheValkyries) |
|
92 valkyriesTimer = -1 |
|
93 missionWon = false |
|
94 ProtectEnemies() |
|
95 SendStat(siGameResult, loc("Challenge over!")) |
|
96 local score = GetKillScore() |
|
97 SendStat(siCustomAchievement, string.format(loc("You have killed %d of 16 hedgehogs (+%d points)."), hogsKilled, score)) |
|
98 SendStat(siPointType, "!POINTS") |
|
99 SendStat(siPlayerKills, tostring(score), playerTeamName) |
|
100 |
81 |
101 -- Update highscore |
82 local enemyTeam1 = { |
102 updateChallengeRecord("Highscore", score) |
83 { x = 3350, y = 570 }, |
|
84 { x = 3039, y = 1300 }, |
|
85 { x = 2909, y = 430 }, |
|
86 { x = 2150, y = 879 }, |
|
87 { x = 1735, y = 1136 }, |
|
88 { x = 1563, y = 553 }, |
|
89 { x = 679, y = 859 }, |
|
90 { x = 1034, y = 251 }, |
|
91 } |
|
92 local enemyTeam2 = { |
|
93 { x = 255, y = 91 }, |
|
94 { x = 2671, y = 7 }, |
|
95 { x = 2929, y = 244 }, |
|
96 { x = 1946, y = 221 }, |
|
97 { x = 3849, y = 1067 }, |
|
98 { x = 3360, y = 659 }, |
|
99 { x = 3885, y = 285 }, |
|
100 { x = 935, y = 1160 }, |
|
101 } |
103 |
102 |
104 EndGame() |
103 assignNamesAndHats(enemyTeam1) |
105 end |
104 assignNamesAndHats(enemyTeam2) |
106 |
105 |
107 function GG() |
106 RopeKnocking({ |
108 missionWon = true |
107 missionName = loc("Rope-knocking Challenge"), |
109 local completeTime = (TurnTime - finishTime) / 1000 |
108 map = "Ropes", |
110 ShowMission(loc("Rope-knocking Challenge"), loc("Challenge completed!"), loc("Congratulations!") .. "|" .. string.format(loc("Completion time: %.2fs"), completeTime), 0, 0) |
109 theme = "Eyes", |
111 PlaySound(sndHomerun) |
110 turnTime = 180000, |
112 SendStat(siGameResult, loc("Challenge completed!")) |
111 valkyries = true, |
113 local hogScore = GetKillScore() |
112 playerTeam = { |
114 local timeScore = math.ceil((finishTime/TurnTime)*6000) |
113 x = 2419, |
115 local score = hogScore + timeScore |
114 y = 1769, |
|
115 faceLeft = true, |
|
116 }, |
|
117 enemyTeams = { |
|
118 { |
|
119 name = loc("Unsuspecting Louts"), |
|
120 flag = "cm_face", |
|
121 hogs = enemyTeam1, |
|
122 }, |
|
123 { |
|
124 name = loc("Unlucky Sods"), |
|
125 flag = "cm_balrog", |
|
126 hogs = enemyTeam2, |
|
127 }, |
|
128 }, |
|
129 onGameStart = function() |
|
130 PlaceGirder(46,1783, 0) |
|
131 end, |
|
132 }) |
116 |
133 |
117 SendStat(siCustomAchievement, string.format(loc("You have killed %d of 16 hedgehogs (+%d points)."), hogsKilled, hogScore)) |
|
118 SendStat(siCustomAchievement, string.format(loc("You have completed this challenge in %.2f s (+%d points)."), completeTime, timeScore)) |
|
119 SendStat(siPointType, "!POINTS") |
|
120 SendStat(siPlayerKills, tostring(score), playerTeamName) |
|
121 SetTeamLabel(playerTeamName, tostring(score)) |
|
122 |
|
123 -- Update highscore |
|
124 updateChallengeRecord("Highscore", score) |
|
125 |
|
126 if hhs[0] and GetHealth(hhs[0]) then |
|
127 SetEffect(hhs[0], heInvulnerable, 1) |
|
128 end |
|
129 SetTurnTimeLeft(MAX_TURN_TIME) |
|
130 end |
|
131 |
|
132 function AssignCharacter(p) |
|
133 |
|
134 done = false |
|
135 sanityCheck = 0 |
|
136 |
|
137 while(done == false) do |
|
138 |
|
139 i = 1+ GetRandom(#HogData) |
|
140 if HogData[i][3] == false then |
|
141 HogData[i][3] = true |
|
142 done = true |
|
143 SetHogName(hhs[p], HogData[i][1]) |
|
144 SetHogHat(hhs[p], HogData[i][2]) |
|
145 elseif HogData[i][3] == true then |
|
146 sanityCheck = sanityCheck +1 |
|
147 if sanityCheck == 100 then |
|
148 done = true |
|
149 SetHogName(hhs[p], "Newbie") |
|
150 SetHogHat(hhs[p], "NoHat") |
|
151 end |
|
152 end |
|
153 |
|
154 end |
|
155 |
|
156 end |
|
157 |
|
158 function onGameInit() |
|
159 |
|
160 --Seed = 1 |
|
161 GameFlags = gfBorder + gfSolidLand |
|
162 |
|
163 TurnTime = 180 * 1000 |
|
164 Map = "Ropes" |
|
165 Theme = "Eyes" |
|
166 |
|
167 -- Disable Sudden Death |
|
168 WaterRise = 0 |
|
169 HealthDecrease = 0 |
|
170 |
|
171 CaseFreq = 0 |
|
172 MinesNum = 0 |
|
173 Explosives = 0 |
|
174 |
|
175 playerTeamName = AddMissionTeam(-1) |
|
176 hhs[0] = AddMissionHog(1) |
|
177 |
|
178 AddTeam(loc("Unsuspecting Louts"), -2, "Simple", "Island", "Default", "cm_face") |
|
179 for i = 1, 8 do |
|
180 -- The name "generic" is a placeholder and will be replaced in AssignCharacter |
|
181 hhs[i] = AddHog("generic", 0, 1, "NoHat") |
|
182 end |
|
183 |
|
184 AddTeam(loc("Unlucky Sods"), -2, "Simple", "Island", "Default", "cm_balrog") |
|
185 for i = 9, 16 do |
|
186 hhs[i] = AddHog("generic", 0, 1, "NoHat") |
|
187 end |
|
188 |
|
189 end |
|
190 |
|
191 |
|
192 |
|
193 function onGameStart() |
|
194 SendHealthStatsOff() |
|
195 |
|
196 local recordInfo = getReadableChallengeRecord("Highscore") |
|
197 if recordInfo == nil then |
|
198 recordInfo = "" |
|
199 else |
|
200 recordInfo = "|" .. recordInfo |
|
201 end |
|
202 ShowMission ( |
|
203 loc("Rope-knocking Challenge"), |
|
204 loc("Challenge"), |
|
205 loc("Use the rope to knock your enemies to their doom.") .. "|" .. |
|
206 loc("Finish this challenge as fast as possible to earn bonus points.").. recordInfo, |
|
207 -amRope, 4000) |
|
208 SetTeamLabel(playerTeamName, "0") |
|
209 |
|
210 PlaceGirder(46,1783, 0) |
|
211 |
|
212 SetGearPosition(hhs[0], 2419, 1769) |
|
213 SetGearPosition(hhs[1], 3350, 570) |
|
214 SetGearPosition(hhs[2], 3039, 1300) |
|
215 SetGearPosition(hhs[3], 2909, 430) |
|
216 SetGearPosition(hhs[4], 2150, 879) |
|
217 SetGearPosition(hhs[5], 1735, 1136) |
|
218 SetGearPosition(hhs[6], 1563, 553) |
|
219 SetGearPosition(hhs[7], 679, 859) |
|
220 SetGearPosition(hhs[8], 1034, 251) |
|
221 SetGearPosition(hhs[9], 255, 67) |
|
222 SetGearPosition(hhs[10], 2671, 7) |
|
223 SetGearPosition(hhs[11], 2929, 244) |
|
224 SetGearPosition(hhs[12], 1946, 221) |
|
225 SetGearPosition(hhs[13], 3849, 1067) |
|
226 SetGearPosition(hhs[14], 3360, 659) |
|
227 SetGearPosition(hhs[15], 3885, 285) |
|
228 SetGearPosition(hhs[16], 935, 1160) |
|
229 HogTurnLeft(hhs[0], true) |
|
230 |
|
231 for i = 1, 16 do |
|
232 AssignCharacter(i) |
|
233 end |
|
234 |
|
235 end |
|
236 |
|
237 function onGameTick() |
|
238 |
|
239 if (TurnTimeLeft == 1) and (missionWon == nil) then |
|
240 GameOverMan() |
|
241 end |
|
242 |
|
243 if missionWon ~= nil then |
|
244 |
|
245 endTimer = endTimer - 1 |
|
246 if endTimer == 1 then |
|
247 EndGame() |
|
248 end |
|
249 |
|
250 if not missionEndHandled then |
|
251 if missionWon == true then |
|
252 SaveMissionVar("Won", "true") |
|
253 AddCaption(loc("Victory!"), capcolDefault, capgrpGameState) |
|
254 end |
|
255 missionEndHandled = true |
|
256 end |
|
257 |
|
258 end |
|
259 |
|
260 end |
|
261 |
|
262 function onGameTick20() |
|
263 if (valkyriesTimer > 0) then |
|
264 valkyriesTimer = valkyriesTimer - 20 |
|
265 if valkyriesTimer <= 0 then |
|
266 StopMusicSound(sndRideOfTheValkyries) |
|
267 end |
|
268 end |
|
269 end |
|
270 |
|
271 function onGearDamage(gear, damage) |
|
272 |
|
273 if gear == hhs[0] then |
|
274 ouchies = true |
|
275 StopMusicSound(sndRideOfTheValkyries) |
|
276 valkyriesTimer = -1 |
|
277 ProtectEnemies() |
|
278 end |
|
279 |
|
280 if gear ~= hhs[0] and GetGearType(gear) == gtHedgehog and missionWon == nil and ouchies == false then |
|
281 |
|
282 AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
|
283 DeleteGear(gear) |
|
284 PlaySound(sndExplosion) |
|
285 AddCaption(string.format(knockTaunt(), GetHogName(gear)), capcolDefault, capgrpMessage) |
|
286 |
|
287 hogsKilled = hogsKilled +1 |
|
288 SetTeamLabel(playerTeamName, tostring(GetKillScore())) |
|
289 |
|
290 if hogsKilled == 15 then |
|
291 PlayMusicSound(sndRideOfTheValkyries) |
|
292 -- Time in ms after which to return to normal music |
|
293 valkyriesTimer = 20000 |
|
294 elseif hogsKilled == 16 then |
|
295 finishTime = TurnTimeLeft |
|
296 GG() |
|
297 end |
|
298 |
|
299 end |
|
300 |
|
301 end |
|
302 |
|
303 function knockTaunt() |
|
304 local r = math.random(0,23) |
|
305 local taunt |
|
306 if r == 0 then taunt = loc("%s has been knocked out.") |
|
307 elseif r == 1 then taunt = loc("%s hit the ground.") |
|
308 elseif r == 2 then taunt = loc("%s splatted.") |
|
309 elseif r == 3 then taunt = loc("%s was smashed.") |
|
310 elseif r == 4 then taunt = loc("%s felt unstable.") |
|
311 elseif r == 5 then taunt = loc("%s exploded.") |
|
312 elseif r == 6 then taunt = loc("%s fell from a high cliff.") |
|
313 elseif r == 7 then taunt = loc("%s goes the way of the lemming.") |
|
314 elseif r == 8 then taunt = loc("%s was knocked away.") |
|
315 elseif r == 9 then taunt = loc("%s was really unlucky.") |
|
316 elseif r == 10 then taunt = loc("%s felt victim to rope-knocking.") |
|
317 elseif r == 11 then taunt = loc("%s had no chance.") |
|
318 elseif r == 12 then taunt = loc("%s was a good target.") |
|
319 elseif r == 13 then taunt = loc("%s spawned at a really bad position.") |
|
320 elseif r == 14 then taunt = loc("%s was doomed from the beginning.") |
|
321 elseif r == 15 then taunt = loc("%s has fallen victim to gravity.") |
|
322 elseif r == 16 then taunt = loc("%s hates Newton.") -- Isaac Newton |
|
323 elseif r == 17 then taunt = loc("%s had it coming.") |
|
324 elseif r == 18 then taunt = loc("%s is eliminated!") |
|
325 elseif r == 19 then taunt = loc("%s fell too fast.") |
|
326 elseif r == 20 then taunt = loc("%s flew like a rock.") |
|
327 elseif r == 21 then taunt = loc("%s stumbled.") |
|
328 elseif r == 22 then taunt = loc("%s was shoved away.") |
|
329 elseif r == 23 then taunt = loc("%s didn't expect that.") |
|
330 end |
|
331 return taunt |
|
332 end |
|
333 |
|
334 function onGearDelete(gear) |
|
335 |
|
336 if (gear == hhs[0]) and (missionWon == nil) then |
|
337 GameOverMan() |
|
338 end |
|
339 |
|
340 end |
|
341 |
|
342 function onAmmoStoreInit() |
|
343 SetAmmo(amRope, 9, 0, 0, 0) |
|
344 end |
|
345 |
|
346 function onNewTurn() |
|
347 SetWeapon(amRope) |
|
348 end |
|