author | sheepluva |
Thu, 12 Jun 2014 20:47:11 +0200 | |
changeset 10289 | c3a77ff02a23 |
parent 10228 | 947cadb40bc5 |
child 10292 | 1c6639b49afc |
permissions | -rw-r--r-- |
10044 | 1 |
|
2 |
------------------------------------------ |
|
3 |
-- RACER 0.6 |
|
4 |
-- map-independant racing script |
|
5 |
-- by mikade |
|
6 |
----------------------------------------- |
|
7 |
||
8 |
----------------------------------- |
|
9 |
--0.1: took all the code from crazy racer and scrapped most of it |
|
10 |
----------------------------------- |
|
11 |
||
12 |
-- Removed tumbler system |
|
13 |
-- Removed extra adds like boosters etc |
|
14 |
-- Added experimental waypoint placement system |
|
15 |
-- More user feedback |
|
16 |
-- Reduced race complexity limit to 5 waypoints |
|
17 |
-- stop placement at complexity limit reached and end turn |
|
18 |
-- guys dont keep racing after dying |
|
19 |
-- invulnerable feasibility |
|
20 |
-- reverted time keeping method |
|
21 |
-- reduced feedback display time |
|
22 |
-- colour-coded addcaptions |
|
23 |
-- cleaned up code |
|
24 |
-- support for more players properly added |
|
25 |
-- tardis fix |
|
26 |
-- remove airstrikes |
|
27 |
||
28 |
-- i think the remainder 0 .456 sec of the tracktime isnt getting reset on newturn |
|
29 |
||
30 |
-- update feedback |
|
31 |
||
32 |
------- |
|
33 |
-- 0.2 |
|
34 |
------- |
|
35 |
||
36 |
-- allow gameflags |
|
37 |
-- extend time to 90s |
|
38 |
-- remove other air-attack based weps |
|
39 |
-- turn off water rise for sd |
|
40 |
||
41 |
------- |
|
42 |
-- 0.3 |
|
43 |
------- |
|
44 |
||
45 |
-- prevent WP being placed in land |
|
46 |
-- prevent waypoints being placed outside border |
|
47 |
||
48 |
------- |
|
49 |
-- 0.4 |
|
50 |
------- |
|
51 |
||
52 |
-- update user feedback |
|
53 |
-- add more sounds |
|
54 |
||
55 |
------- |
|
56 |
-- 0.5 |
|
57 |
------- |
|
58 |
||
59 |
-- fix ghost disappearing if hog falls in water or somehow dies |
|
60 |
-- lengthen ghost tracking interval to improve performance on slower machines |
|
61 |
-- increase waypoint limit to 8 |
|
62 |
-- allow for persistent showmission information |
|
63 |
||
64 |
------- |
|
65 |
-- 0.6 |
|
66 |
------- |
|
67 |
||
68 |
-- remove hogs from racing area as per request |
|
69 |
||
70 |
----------------------------- |
|
71 |
-- SCRIPT BEGINS |
|
72 |
----------------------------- |
|
73 |
||
74 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
75 |
HedgewarsScriptLoad("/Scripts/OfficialChallenges.lua") |
|
76 |
||
77 |
------------------ |
|
78 |
-- Got Variables? |
|
79 |
------------------ |
|
80 |
||
81 |
local fMod = 1000000 -- 1 |
|
82 |
local roundLimit = 3 |
|
83 |
local roundNumber = 0 |
|
84 |
local firstClan = 10 |
|
85 |
||
86 |
local fastX = {} |
|
87 |
local fastY = {} |
|
88 |
local fastCount = 0 |
|
89 |
local fastIndex = 0 |
|
90 |
local fastColour |
|
91 |
||
92 |
local currX = {} |
|
93 |
local currY = {} |
|
94 |
local currCount = 0 |
|
95 |
||
96 |
local specialPointsX = {} |
|
97 |
local specialPointsY = {} |
|
98 |
local specialPointsCount = 0 |
|
99 |
||
100 |
-------------------------- |
|
101 |
-- hog and team tracking variales |
|
102 |
-------------------------- |
|
103 |
||
104 |
local numhhs = 0 -- store number of hedgehogs |
|
105 |
local hhs = {} -- store hedgehog gears |
|
106 |
||
107 |
local numTeams -- store the number of teams in the game |
|
108 |
local teamNameArr = {} -- store the list of teams |
|
109 |
local teamClan = {} |
|
110 |
local teamSize = {} -- store how many hogs per team |
|
111 |
local teamIndex = {} -- at what point in the hhs{} does each team begin |
|
112 |
||
113 |
local teamComment = {} |
|
114 |
local teamScore = {} |
|
115 |
||
116 |
------- |
|
117 |
-- racer vars |
|
118 |
-------- |
|
119 |
||
120 |
local cGear = nil |
|
121 |
||
122 |
local bestClan = nil |
|
123 |
local bestTime = nil |
|
124 |
||
125 |
local gameBegun = false |
|
126 |
local gameOver = false |
|
127 |
local racerActive = false |
|
128 |
local trackTime = 0 |
|
129 |
||
130 |
local wpCirc = {} |
|
131 |
local wpX = {} |
|
132 |
local wpY = {} |
|
133 |
local wpCol = {} |
|
134 |
local wpActive = {} |
|
135 |
local wpRad = 450 --75 |
|
136 |
local wpCount = 0 |
|
137 |
local wpLimit = 8 |
|
138 |
||
10228 | 139 |
local usedWeapons = {} |
140 |
||
10044 | 141 |
local roundN |
142 |
local lastRound |
|
143 |
local RoundHasChanged |
|
144 |
||
145 |
------------------- |
|
146 |
-- general methods |
|
147 |
------------------- |
|
148 |
||
149 |
function RebuildTeamInfo() |
|
150 |
||
151 |
||
152 |
-- make a list of individual team names |
|
153 |
for i = 0, (TeamsCount-1) do |
|
154 |
teamNameArr[i] = " " -- = i |
|
155 |
teamSize[i] = 0 |
|
156 |
teamIndex[i] = 0 |
|
157 |
teamScore[i] = 100000 |
|
158 |
end |
|
159 |
numTeams = 0 |
|
160 |
||
161 |
for i = 0, (numhhs-1) do |
|
162 |
||
163 |
z = 0 |
|
164 |
unfinished = true |
|
165 |
while(unfinished == true) do |
|
166 |
||
167 |
newTeam = true |
|
168 |
tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name |
|
169 |
||
170 |
if tempHogTeamName == teamNameArr[z] then |
|
171 |
newTeam = false |
|
172 |
unfinished = false |
|
173 |
end |
|
174 |
||
175 |
z = z + 1 |
|
176 |
||
177 |
if z == TeamsCount then |
|
178 |
unfinished = false |
|
179 |
if newTeam == true then |
|
180 |
teamNameArr[numTeams] = tempHogTeamName |
|
181 |
numTeams = numTeams + 1 |
|
182 |
end |
|
183 |
end |
|
184 |
||
185 |
end |
|
186 |
||
187 |
end |
|
188 |
||
189 |
-- find out how many hogs per team, and the index of the first hog in hhs |
|
190 |
for i = 0, (numTeams-1) do |
|
191 |
for z = 0, (numhhs-1) do |
|
192 |
if GetHogTeamName(hhs[z]) == teamNameArr[i] then |
|
193 |
teamClan[i] = GetHogClan(hhs[z]) |
|
194 |
if teamSize[i] == 0 then |
|
195 |
teamIndex[i] = z -- should give starting index |
|
196 |
end |
|
197 |
teamSize[i] = teamSize[i] + 1 |
|
198 |
--add a pointer so this hog appears at i in hhs |
|
199 |
end |
|
200 |
end |
|
201 |
||
202 |
end |
|
203 |
||
204 |
end |
|
205 |
||
206 |
||
207 |
----------------- |
|
208 |
-- RACER METHODS |
|
209 |
----------------- |
|
210 |
||
211 |
function CheckWaypoints() |
|
212 |
||
213 |
trackFinished = true |
|
214 |
||
215 |
for i = 0, (wpCount-1) do |
|
216 |
||
217 |
g1X, g1Y = GetGearPosition(CurrentHedgehog) |
|
218 |
g2X, g2Y = wpX[i], wpY[i] |
|
219 |
||
220 |
g1X = g1X - g2X |
|
221 |
g1Y = g1Y - g2Y |
|
222 |
dist = (g1X*g1X) + (g1Y*g1Y) |
|
223 |
||
224 |
--if i == 0 then |
|
225 |
-- AddCaption(dist .. "/" .. (wpRad*wpRad) ) |
|
226 |
--end |
|
227 |
||
228 |
NR = (48/100*wpRad)/2 |
|
229 |
||
230 |
if dist < (NR*NR) then |
|
231 |
--if dist < (wpRad*wpRad) then |
|
232 |
--AddCaption("howdy") |
|
233 |
wpActive[i] = true |
|
234 |
wpCol[i] = GetClanColor(GetHogClan(CurrentHedgehog)) -- new --GetClanColor(1) |
|
235 |
SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 1, 10, 0, wpRad, 5, wpCol[i]) |
|
236 |
||
237 |
wpRem = 0 |
|
238 |
for k = 0, (wpCount-1) do |
|
239 |
if wpActive[k] == false then |
|
240 |
wpRem = wpRem + 1 |
|
241 |
end |
|
242 |
end |
|
243 |
||
244 |
AddCaption(loc("Way-Points Remaining") .. ": " .. wpRem,0xffba00ff,capgrpAmmoinfo) |
|
245 |
||
246 |
end |
|
247 |
||
248 |
if wpActive[i] == false then |
|
249 |
trackFinished = false |
|
250 |
end |
|
251 |
||
252 |
end |
|
253 |
||
254 |
return(trackFinished) |
|
255 |
||
256 |
end |
|
257 |
||
258 |
function AdjustScores() |
|
259 |
||
260 |
if bestTime == nil then |
|
261 |
bestTime = 100000 |
|
262 |
bestClan = 10 |
|
263 |
bestTimeComment = "N/A" |
|
264 |
end |
|
265 |
||
266 |
newScore = false |
|
267 |
||
268 |
-- update this clan's time if the new track is better |
|
269 |
for i = 0, (numTeams-1) do |
|
270 |
if teamClan[i] == GetHogClan(CurrentHedgehog) then |
|
271 |
if trackTime < teamScore[i] then |
|
272 |
teamScore[i] = trackTime |
|
273 |
newScore = true |
|
274 |
else |
|
275 |
newScore = false |
|
276 |
end |
|
277 |
end |
|
278 |
end |
|
279 |
||
280 |
--bestTime = 100000 |
|
281 |
--bestClan = 10 |
|
282 |
||
283 |
-- find the best time out of those so far |
|
284 |
for i = 0, (numTeams-1) do |
|
285 |
if teamScore[i] < bestTime then |
|
286 |
bestTime = teamScore[i] |
|
287 |
bestClan = teamClan[i] |
|
288 |
end |
|
289 |
end |
|
290 |
||
291 |
if bestTime ~= 100000 then |
|
292 |
bestTimeComment = (bestTime/1000) ..loc("s") |
|
293 |
end |
|
294 |
||
295 |
if newScore == true then |
|
296 |
if trackTime == bestTime then -- best time of the race |
|
297 |
ShowMission(loc("RACER"), |
|
298 |
loc("TRACK COMPLETED"), |
|
299 |
loc("NEW RACE RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" .. |
|
300 |
loc("WINNING TIME: ") .. bestTimeComment, 0, 4000) |
|
301 |
PlaySound(sndHomerun) |
|
302 |
else -- best time for the clan |
|
303 |
ShowMission(loc("RACER"), |
|
304 |
loc("TRACK COMPLETED"), |
|
305 |
loc("NEW CLAN RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" .. |
|
306 |
loc("WINNING TIME: ") .. bestTimeComment, 4, 4000) |
|
307 |
end |
|
308 |
else -- not any kind of new score |
|
309 |
ShowMission(loc("RACER"), |
|
310 |
loc("TRACK COMPLETED"), |
|
311 |
loc("TIME: ") .. (trackTime/1000) ..loc("s") .. "|" .. |
|
312 |
loc("WINNING TIME: ") .. bestTimeComment, -amSkip, 4000) |
|
313 |
PlaySound(sndHellish) |
|
314 |
end |
|
315 |
||
316 |
||
317 |
-------- |
|
318 |
--new |
|
319 |
-------- |
|
320 |
||
321 |
if bestTime == trackTime then |
|
322 |
--AddCaption("wooooooooooooooooooooooooooooo") |
|
323 |
||
324 |
fastColour = GetClanColor(GetHogClan(CurrentHedgehog)) |
|
325 |
||
326 |
for i = 0, (currCount-1) do |
|
327 |
fastX[i] = currX[i] |
|
328 |
fastY[i] = currY[i] |
|
329 |
end |
|
330 |
||
331 |
fastCount = currCount |
|
332 |
fastIndex = 0 |
|
333 |
||
334 |
--currCount = 0 -- is this needed? |
|
335 |
||
336 |
else |
|
337 |
currCount = 0 |
|
338 |
fastIndex = 0 |
|
339 |
end |
|
340 |
||
341 |
||
342 |
end |
|
343 |
||
344 |
function onNewRound() |
|
345 |
||
346 |
roundNumber = roundNumber + 1 |
|
347 |
||
348 |
totalComment = "" |
|
349 |
for i = 0, (TeamsCount-1) do |
|
350 |
if teamNameArr[i] ~= " " then -- teamScore[teamClan[i]] |
|
351 |
teamComment[i] = teamNameArr[i] .. ": " .. (teamScore[i]/1000) .. loc("s|") |
|
352 |
totalComment = totalComment .. teamComment[i] |
|
353 |
elseif teamNameArr[i] == " " then |
|
354 |
teamComment[i] = "|" |
|
355 |
end |
|
356 |
end |
|
357 |
||
358 |
ShowMission( loc("RACER"), |
|
359 |
loc("STATUS UPDATE"), |
|
360 |
loc("Rounds Complete: ") .. roundNumber .. "/" .. roundLimit .. "|" .. " " .. "|" .. |
|
361 |
loc("Best Team Times: ") .. "|" .. totalComment, 0, 4000) |
|
362 |
||
363 |
-- end game if its at round limit |
|
10227
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
364 |
if roundNumber >= roundLimit then |
10044 | 365 |
for i = 0, (numhhs-1) do |
366 |
if GetHogClan(hhs[i]) ~= bestClan then |
|
367 |
SetEffect(hhs[i], heResurrectable, 0) |
|
368 |
SetHealth(hhs[i],0) |
|
369 |
end |
|
370 |
end |
|
371 |
gameOver = true |
|
372 |
TurnTimeLeft = 1 |
|
373 |
end |
|
374 |
||
375 |
end |
|
376 |
||
377 |
function CheckForNewRound() |
|
378 |
||
379 |
------------- |
|
380 |
------ new |
|
381 |
------------- |
|
382 |
||
383 |
--[[turnN = turnN + 1 |
|
384 |
if gameBegun == false then |
|
385 |
if turnN == 2 then |
|
386 |
for i = 0, (numhhs-1) do |
|
387 |
if hhs[i] ~= nil then |
|
388 |
SetEffect(hhs[i], heResurrectable, 0) |
|
389 |
SetHealth(hhs[i],0) |
|
390 |
end |
|
391 |
end |
|
392 |
gameOver = true |
|
393 |
TurnTimeLeft = 1 |
|
394 |
end |
|
395 |
else |
|
396 |
||
397 |
||
398 |
end]] |
|
399 |
||
400 |
--[[if roundBegun == true then |
|
401 |
||
402 |
if RoundHasChanged == true then |
|
403 |
roundN = roundN + 1 |
|
404 |
RoundHasChanged = false |
|
405 |
onNewRound() |
|
406 |
end |
|
407 |
||
408 |
if lastRound ~= TotalRounds then -- new round, but not really |
|
409 |
||
410 |
if RoundHasChanged == false then |
|
411 |
RoundHasChanged = true |
|
412 |
end |
|
413 |
||
414 |
end |
|
415 |
||
416 |
AddCaption("RoundN:" .. roundN .. "; " .. "TR: " .. TotalRounds) |
|
417 |
||
418 |
lastRound = TotalRounds |
|
419 |
||
420 |
end]] |
|
421 |
||
422 |
------------ |
|
423 |
----- old |
|
424 |
------------ |
|
425 |
||
426 |
if GetHogClan(CurrentHedgehog) == firstClan then |
|
427 |
onNewRound() |
|
428 |
end |
|
429 |
||
430 |
end |
|
431 |
||
432 |
function DisableTumbler() |
|
433 |
currCount = 0 |
|
434 |
fastIndex = 0 |
|
435 |
TurnTimeLeft = 0 |
|
436 |
racerActive = false -- newadd |
|
437 |
end |
|
438 |
||
439 |
function HandleGhost() |
|
440 |
||
441 |
-- get the current xy of the racer at this point |
|
442 |
currX[currCount] = GetX(CurrentHedgehog) |
|
443 |
currY[currCount] = GetY(CurrentHedgehog) |
|
444 |
currCount = currCount + 1 |
|
445 |
||
446 |
-- draw a ping of smoke where the fastest player was at this point |
|
447 |
if (fastCount ~= 0) and (fastIndex < fastCount) then |
|
448 |
||
449 |
fastIndex = fastIndex + 1 |
|
450 |
||
451 |
tempE = AddVisualGear(fastX[fastIndex], fastY[fastIndex], vgtSmoke, 0, false) |
|
452 |
g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) |
|
453 |
SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, fastColour ) |
|
454 |
||
455 |
--AddCaption("fC: " .. fastIndex .. " / " .. fastCount) |
|
456 |
||
457 |
else |
|
458 |
||
459 |
--AddCaption("excep fC: " .. fastIndex .. " / " .. fastCount) |
|
460 |
||
461 |
end |
|
462 |
||
463 |
||
464 |
||
465 |
end |
|
466 |
||
467 |
function TryRepositionHogs() |
|
468 |
||
469 |
if MapHasBorder() == true then |
|
470 |
||
471 |
for i = 0, (numhhs-1) do |
|
472 |
if hhs[i] ~= nil then |
|
473 |
SetGearPosition(hhs[i],GetX(hhs[i]), TopY-10) |
|
474 |
end |
|
475 |
end |
|
476 |
||
477 |
end |
|
478 |
||
479 |
end |
|
480 |
||
481 |
---------------------------------- |
|
482 |
-- GAME METHODS / EVENT HANDLERS |
|
483 |
---------------------------------- |
|
484 |
||
485 |
function onGameInit() |
|
486 |
EnableGameFlags(gfInfAttack, gfInvulnerable) |
|
487 |
CaseFreq = 0 |
|
488 |
TurnTime = 90000 |
|
489 |
WaterRise = 0 |
|
490 |
end |
|
491 |
||
492 |
||
493 |
function onGameStart() |
|
494 |
||
495 |
roundN = 0 |
|
496 |
lastRound = TotalRounds |
|
497 |
RoundHasChanged = false -- true |
|
498 |
||
499 |
for i = 0, (specialPointsCount-1) do |
|
500 |
PlaceWayPoint(specialPointsX[i], specialPointsY[i]) |
|
501 |
end |
|
502 |
||
503 |
RebuildTeamInfo() |
|
504 |
||
505 |
ShowMission ( |
|
506 |
loc("RACER"), |
|
507 |
loc("a Hedgewars mini-game"), |
|
508 |
||
509 |
loc("Build a track and race.") .. "|" .. |
|
510 |
loc("Round Limit:") .. " " .. roundLimit .. "|" .. |
|
511 |
||
512 |
"", 4, 4000 |
|
513 |
) |
|
514 |
||
515 |
TryRepositionHogs() |
|
516 |
||
517 |
end |
|
518 |
||
519 |
function PlaceWayPoint(x,y) |
|
10227
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
520 |
if not racerActive then |
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
521 |
if wpCount == 0 or wpX[wpCount - 1] ~= x or wpY[wpCount - 1] ~= y then |
10044 | 522 |
|
10227
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
523 |
wpX[wpCount] = x |
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
524 |
wpY[wpCount] = y |
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
525 |
wpCol[wpCount] = 0xffffffff |
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
526 |
wpCirc[wpCount] = AddVisualGear(wpX[wpCount],wpY[wpCount],vgtCircle,0,true) |
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
527 |
|
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
528 |
SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], 20, 100, 1, 10, 0, wpRad, 5, wpCol[wpCount]) |
10044 | 529 |
|
10227
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
530 |
wpCount = wpCount + 1 |
10044 | 531 |
|
10227
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
532 |
AddCaption(loc("Waypoint placed.") .. " " .. loc("Available points remaining: ") .. (wpLimit-wpCount)) |
10044 | 533 |
end |
10227
0b848d595f22
- Fix bug with infinite rounds in racer when a team quits mid-game
unc0rr
parents:
10044
diff
changeset
|
534 |
end |
10044 | 535 |
end |
536 |
||
537 |
function onSpecialPoint(x,y,flag) |
|
538 |
specialPointsX[specialPointsCount] = x |
|
539 |
specialPointsY[specialPointsCount] = y |
|
540 |
specialPointsCount = specialPointsCount + 1 |
|
541 |
end |
|
542 |
||
543 |
function onNewTurn() |
|
544 |
||
545 |
CheckForNewRound() |
|
546 |
TryRepositionHogs() |
|
547 |
||
548 |
racerActive = false |
|
549 |
||
550 |
trackTime = 0 |
|
551 |
||
552 |
currCount = 0 -- hopefully this solves problem |
|
553 |
AddAmmo(CurrentHedgehog, amAirAttack, 0) |
|
554 |
gTimer = 0 |
|
555 |
||
556 |
-- Set the waypoints to unactive on new round |
|
557 |
for i = 0,(wpCount-1) do |
|
558 |
wpActive[i] = false |
|
559 |
wpCol[i] = 0xffffffff |
|
560 |
SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 1, 10, 0, wpRad, 5, wpCol[i]) |
|
561 |
end |
|
562 |
||
563 |
-- Handle Starting Stage of Game |
|
564 |
if (gameOver == false) and (gameBegun == false) then |
|
565 |
if wpCount >= 3 then |
|
566 |
gameBegun = true |
|
567 |
roundNumber = 0 |
|
568 |
firstClan = GetHogClan(CurrentHedgehog) |
|
569 |
ShowMission(loc("RACER"), |
|
570 |
loc("GAME BEGUN!!!"), |
|
571 |
loc("Complete the track as fast as you can!"), 2, 4000) |
|
572 |
else |
|
573 |
ShowMission(loc("RACER"), |
|
574 |
loc("NOT ENOUGH WAYPOINTS"), |
|
575 |
loc("Place more waypoints using the 'Air Attack' weapon."), 2, 4000) |
|
576 |
AddAmmo(CurrentHedgehog, amAirAttack, 4000) |
|
10289 | 577 |
SetWeapon(amAirAttack) |
10044 | 578 |
end |
579 |
end |
|
580 |
||
581 |
if gameOver == true then |
|
582 |
gameBegun = false |
|
583 |
racerActive = false -- newadd |
|
584 |
end |
|
585 |
||
586 |
AddAmmo(CurrentHedgehog, amTardis, 0) |
|
587 |
AddAmmo(CurrentHedgehog, amDrillStrike, 0) |
|
588 |
AddAmmo(CurrentHedgehog, amMineStrike, 0) |
|
589 |
AddAmmo(CurrentHedgehog, amNapalm, 0) |
|
590 |
AddAmmo(CurrentHedgehog, amPiano, 0) |
|
591 |
||
592 |
end |
|
593 |
||
594 |
function onGameTick20() |
|
595 |
||
596 |
-- airstrike detected, convert this into a potential waypoint spot |
|
597 |
if cGear ~= nil then |
|
598 |
x,y = GetGearPosition(cGear) |
|
599 |
if x > -9000 then |
|
600 |
x,y = GetGearTarget(cGear) |
|
601 |
||
602 |
||
603 |
if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then |
|
604 |
AddCaption(loc("Please place the way-point in the open, within the map boundaries.")) |
|
605 |
PlaySound(sndDenied) |
|
606 |
elseif (y > WaterLine-50) then |
|
607 |
AddCaption(loc("Please place the way-point further from the waterline.")) |
|
608 |
PlaySound(sndDenied) |
|
609 |
else |
|
610 |
PlaceWayPoint(x, y) |
|
611 |
if wpCount == wpLimit then |
|
612 |
AddCaption(loc("Race complexity limit reached.")) |
|
613 |
DisableTumbler() |
|
614 |
end |
|
615 |
end |
|
616 |
else |
|
617 |
DeleteGear(cGear) |
|
618 |
end |
|
619 |
SetGearPosition(cGear, -10000, 0) |
|
620 |
end |
|
621 |
||
622 |
||
623 |
-- start the player tumbling with a boom once their turn has actually begun |
|
624 |
if racerActive == false then |
|
625 |
||
626 |
if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then |
|
627 |
||
628 |
-- if the gamehas started put the player in the middle of the first |
|
629 |
--waypoint that was placed |
|
630 |
if gameBegun == true then |
|
631 |
AddCaption(loc("Good to go!")) |
|
632 |
racerActive = true |
|
633 |
trackTime = 0 |
|
634 |
||
635 |
SetGearPosition(CurrentHedgehog, wpX[0], wpY[0]) |
|
636 |
AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1) |
|
637 |
FollowGear(CurrentHedgehog) |
|
638 |
||
639 |
HideMission() |
|
640 |
||
641 |
else |
|
642 |
-- still in placement mode |
|
643 |
end |
|
644 |
||
645 |
end |
|
646 |
end |
|
647 |
||
648 |
||
649 |
||
650 |
-- has the player started his tumbling spree? |
|
651 |
if (CurrentHedgehog ~= nil) then |
|
652 |
||
653 |
--airstrike conversion used to be here |
|
654 |
||
655 |
-- if the RACE has started, show tracktimes and keep tabs on waypoints |
|
656 |
if (racerActive == true) and (gameBegun == true) then |
|
657 |
||
658 |
--ghost |
|
659 |
if GameTime%40 == 0 then |
|
660 |
HandleGhost() |
|
661 |
end |
|
662 |
||
663 |
trackTime = trackTime + 20 |
|
664 |
||
665 |
if GameTime%100 == 0 then |
|
666 |
||
667 |
if trackTime%1000 == 0 then |
|
668 |
AddCaption((trackTime/1000)..'.0',GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2) |
|
669 |
else |
|
670 |
AddCaption(trackTime/1000,GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2) |
|
671 |
end |
|
672 |
||
673 |
if (CheckWaypoints() == true) then |
|
674 |
AdjustScores() |
|
675 |
DisableTumbler() |
|
676 |
end |
|
677 |
||
678 |
end |
|
679 |
||
680 |
end |
|
681 |
||
682 |
-- if the player has expended his tunbling time, stop him tumbling |
|
683 |
if TurnTimeLeft <= 20 then |
|
684 |
DisableTumbler() |
|
685 |
end |
|
686 |
||
687 |
end |
|
688 |
||
689 |
end |
|
690 |
||
691 |
function onGearResurrect(gear) |
|
692 |
||
693 |
AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
|
694 |
||
695 |
if gear == CurrentHedgehog then |
|
696 |
DisableTumbler() |
|
697 |
end |
|
698 |
||
699 |
end |
|
700 |
||
701 |
function onGearAdd(gear) |
|
702 |
||
703 |
if GetGearType(gear) == gtHedgehog then |
|
704 |
hhs[numhhs] = gear |
|
705 |
numhhs = numhhs + 1 |
|
706 |
SetEffect(gear, heResurrectable, 1) |
|
707 |
end |
|
708 |
||
709 |
if GetGearType(gear) == gtAirAttack then |
|
710 |
cGear = gear |
|
711 |
end |
|
712 |
||
713 |
end |
|
714 |
||
715 |
function onGearDelete(gear) |
|
716 |
||
717 |
if GetGearType(gear) == gtAirAttack then |
|
718 |
cGear = nil |
|
719 |
end |
|
720 |
||
721 |
end |
|
722 |
||
10228 | 723 |
function onAttack() |
724 |
at = GetCurAmmoType() |
|
725 |
||
726 |
usedWeapons[at] = 0 |
|
727 |
end |
|
10044 | 728 |
|
729 |
function onAchievementsDeclaration() |
|
10228 | 730 |
usedWeapons[amSkip] = nil |
731 |
||
732 |
usedRope = usedWeapons[amRope] ~= nil |
|
733 |
usedPortal = usedWeapons[amPortalGun] ~= nil |
|
734 |
usedSaucer = usedWeapons[amJetpack] ~= nil |
|
735 |
||
736 |
usedWeapons[amRope] = nil |
|
737 |
usedWeapons[amPortalGun] = nil |
|
738 |
usedWeapons[amJetpack] = nil |
|
739 |
||
740 |
usedOther = next(usedWeapons) ~= nil |
|
741 |
||
742 |
if usedOther then -- smth besides skip, rope, portal or saucer used |
|
743 |
raceType = "unknown race" |
|
744 |
elseif usedRope and not usedPortal and not usedSaucer then |
|
745 |
raceType = "rope race" |
|
746 |
elseif not usedRope and usedPortal and not usedSaucer then |
|
747 |
raceType = "portal race" |
|
748 |
elseif not usedRope and not usedPortal and usedSaucer then |
|
749 |
raceType = "saucer race" |
|
750 |
elseif (usedRope or usedPortal or usedSaucer or usedOther) == false then -- no weapons used at all? |
|
751 |
raceType = "no tools race" |
|
752 |
else -- at least two of rope, portal and saucer used |
|
753 |
raceType = "mixed race" |
|
754 |
end |
|
755 |
||
10044 | 756 |
map = detectMap() |
757 |
||
758 |
for i = 0, (numTeams-1) do |
|
759 |
if teamScore[i] < 100000 then |
|
10228 | 760 |
DeclareAchievement(raceType, teamNameArr[i], map, teamScore[i]) |
10044 | 761 |
end |
762 |
end |
|
763 |
end |