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