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