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