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