36 -- allow gameflags |
36 -- allow gameflags |
37 -- extend time to 90s |
37 -- extend time to 90s |
38 -- remove other air-attack based weps |
38 -- remove other air-attack based weps |
39 -- turn off water rise for sd |
39 -- turn off water rise for sd |
40 |
40 |
|
41 ------- |
|
42 -- 0.3 |
|
43 ------- |
|
44 |
|
45 -- prevent WP being placed in land |
|
46 -- prevent waypoints being placed outside border |
|
47 |
41 ----------------------------- |
48 ----------------------------- |
42 -- SCRIPT BEGINS |
49 -- SCRIPT BEGINS |
43 ----------------------------- |
50 ----------------------------- |
44 |
51 |
45 loadfile(GetDataPath() .. "Scripts/Locale.lua")() |
52 loadfile(GetDataPath() .. "Scripts/Locale.lua")() |
171 ----------------- |
178 ----------------- |
172 |
179 |
173 function CheckWaypoints() |
180 function CheckWaypoints() |
174 |
181 |
175 trackFinished = true |
182 trackFinished = true |
176 |
183 |
177 for i = 0, (wpCount-1) do |
184 for i = 0, (wpCount-1) do |
178 |
185 |
179 g1X, g1Y = GetGearPosition(CurrentHedgehog) |
186 g1X, g1Y = GetGearPosition(CurrentHedgehog) |
180 g2X, g2Y = wpX[i], wpY[i] |
187 g2X, g2Y = wpX[i], wpY[i] |
181 |
188 |
185 |
192 |
186 --if i == 0 then |
193 --if i == 0 then |
187 -- AddCaption(dist .. "/" .. (wpRad*wpRad) ) |
194 -- AddCaption(dist .. "/" .. (wpRad*wpRad) ) |
188 --end |
195 --end |
189 |
196 |
190 NR = (48/100*wpRad)/2 |
197 NR = (48/100*wpRad)/2 |
191 |
198 |
192 if dist < (NR*NR) then |
199 if dist < (NR*NR) then |
193 --if dist < (wpRad*wpRad) then |
200 --if dist < (wpRad*wpRad) then |
194 --AddCaption("howdy") |
201 --AddCaption("howdy") |
195 wpActive[i] = true |
202 wpActive[i] = true |
196 wpCol[i] = GetClanColor(GetHogClan(CurrentHedgehog)) -- new --GetClanColor(1) |
203 wpCol[i] = GetClanColor(GetHogClan(CurrentHedgehog)) -- new --GetClanColor(1) |
197 SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 1, 10, 0, wpRad, 5, wpCol[i]) |
204 SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 1, 10, 0, wpRad, 5, wpCol[i]) |
198 |
205 |
199 wpRem = 0 |
206 wpRem = 0 |
200 for k = 0, (wpCount-1) do |
207 for k = 0, (wpCount-1) do |
201 if wpActive[k] == false then |
208 if wpActive[k] == false then |
202 wpRem = wpRem + 1 |
209 wpRem = wpRem + 1 |
203 end |
210 end |
204 end |
211 end |
205 |
212 |
206 AddCaption(loc("Way-Points Remaining") .. ": " .. wpRem,0xffba00ff,capgrpAmmoinfo) |
213 AddCaption(loc("Way-Points Remaining") .. ": " .. wpRem,0xffba00ff,capgrpAmmoinfo) |
207 |
214 |
254 bestTimeComment = (bestTime/1000) ..loc("s") |
261 bestTimeComment = (bestTime/1000) ..loc("s") |
255 end |
262 end |
256 |
263 |
257 if newScore == true then |
264 if newScore == true then |
258 if trackTime == bestTime then -- best time of the race |
265 if trackTime == bestTime then -- best time of the race |
259 ShowMission(loc("RACER"), |
266 ShowMission(loc("RACER"), |
260 loc("TRACK COMPLETED"), |
267 loc("TRACK COMPLETED"), |
261 loc("NEW RACE RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" .. |
268 loc("NEW RACE RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" .. |
262 loc("WINNING TIME: ") .. bestTimeComment, 0, 4000) |
269 loc("WINNING TIME: ") .. bestTimeComment, 0, 4000) |
263 else -- best time for the clan |
270 else -- best time for the clan |
264 ShowMission(loc("RACER"), |
271 ShowMission(loc("RACER"), |
265 loc("TRACK COMPLETED"), |
272 loc("TRACK COMPLETED"), |
266 loc("NEW CLAN RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" .. |
273 loc("NEW CLAN RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" .. |
267 loc("WINNING TIME: ") .. bestTimeComment, 4, 4000) |
274 loc("WINNING TIME: ") .. bestTimeComment, 4, 4000) |
268 end |
275 end |
269 else -- not any kind of new score |
276 else -- not any kind of new score |
270 ShowMission(loc("RACER"), |
277 ShowMission(loc("RACER"), |
271 loc("TRACK COMPLETED"), |
278 loc("TRACK COMPLETED"), |
272 loc("TIME: ") .. (trackTime/1000) ..loc("s") .. "|" .. |
279 loc("TIME: ") .. (trackTime/1000) ..loc("s") .. "|" .. |
273 loc("WINNING TIME: ") .. bestTimeComment, -amSkip, 4000) |
280 loc("WINNING TIME: ") .. bestTimeComment, -amSkip, 4000) |
274 end |
281 end |
275 |
282 |
276 |
283 |
277 -------- |
284 -------- |
305 |
312 |
306 if GetHogClan(CurrentHedgehog) == firstClan then |
313 if GetHogClan(CurrentHedgehog) == firstClan then |
307 |
314 |
308 roundNumber = roundNumber + 1 |
315 roundNumber = roundNumber + 1 |
309 |
316 |
310 totalComment = "" |
317 totalComment = "" |
311 for i = 0, (TeamsCount-1) do |
318 for i = 0, (TeamsCount-1) do |
312 if teamNameArr[i] ~= " " then -- teamScore[teamClan[i]] |
319 if teamNameArr[i] ~= " " then -- teamScore[teamClan[i]] |
313 teamComment[i] = teamNameArr[i] .. ": " .. (teamScore[i]/1000) .. loc("s|") |
320 teamComment[i] = teamNameArr[i] .. ": " .. (teamScore[i]/1000) .. loc("s|") |
314 totalComment = totalComment .. teamComment[i] |
321 totalComment = totalComment .. teamComment[i] |
315 elseif teamNameArr[i] == " " then |
322 elseif teamNameArr[i] == " " then |
316 teamComment[i] = "|" |
323 teamComment[i] = "|" |
317 end |
324 end |
318 end |
325 end |
319 |
326 |
320 ShowMission( loc("RACER"), |
327 ShowMission( loc("RACER"), |
321 loc("STATUS UPDATE"), |
328 loc("STATUS UPDATE"), |
322 loc("Rounds Complete: ") .. roundNumber .. "/" .. roundLimit .. "|" .. " " .. "|" .. |
329 loc("Rounds Complete: ") .. roundNumber .. "/" .. roundLimit .. "|" .. " " .. "|" .. |
323 loc("Best Team Times: ") .. "|" .. totalComment, 0, 4000) |
330 loc("Best Team Times: ") .. "|" .. totalComment, 0, 4000) |
324 |
331 |
325 -- end game if its at round limit |
332 -- end game if its at round limit |
326 if roundNumber == roundLimit then |
333 if roundNumber == roundLimit then |
327 for i = 0, (numhhs-1) do |
334 for i = 0, (numhhs-1) do |
407 |
414 |
408 wpX[wpCount] = x |
415 wpX[wpCount] = x |
409 wpY[wpCount] = y |
416 wpY[wpCount] = y |
410 wpCol[wpCount] = 0xffffffff |
417 wpCol[wpCount] = 0xffffffff |
411 wpCirc[wpCount] = AddVisualGear(wpX[wpCount],wpY[wpCount],vgtCircle,0,true) |
418 wpCirc[wpCount] = AddVisualGear(wpX[wpCount],wpY[wpCount],vgtCircle,0,true) |
412 --100 |
419 --100 |
413 SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], 20, 100, 1, 10, 0, wpRad, 5, wpCol[wpCount]) |
420 SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], 20, 100, 1, 10, 0, wpRad, 5, wpCol[wpCount]) |
414 |
421 |
415 wpCount = wpCount + 1 |
422 wpCount = wpCount + 1 |
416 |
423 |
417 AddCaption(loc("Waypoint placed.") .. " " .. loc("Available points remaining: ") .. (wpLimit-wpCount)) |
424 AddCaption(loc("Waypoint placed.") .. " " .. loc("Available points remaining: ") .. (wpLimit-wpCount)) |
418 |
425 |
419 -- for some reason the code doesnt function if placed here |
|
420 --[[if wpCount == wpLimit then |
|
421 AddCaption(loc("Race complexity limit reached.")) |
|
422 --DisableTumbler() |
|
423 end]] |
|
424 |
|
425 end |
426 end |
426 |
427 |
427 end |
428 end |
428 |
429 |
429 function onNewTurn() |
430 function onNewTurn() |
430 |
431 |
431 CheckForNewRound() |
432 CheckForNewRound() |
432 |
433 |
433 racerActive = false |
434 racerActive = false |
434 |
435 |
435 trackTime = 0 |
436 trackTime = 0 |
436 |
437 |
437 currCount = 0 -- hopefully this solves problem |
438 currCount = 0 -- hopefully this solves problem |
438 AddAmmo(CurrentHedgehog, amAirAttack, 0) |
439 AddAmmo(CurrentHedgehog, amAirAttack, 0) |
439 gTimer = 0 |
440 gTimer = 0 |
447 |
448 |
448 -- Handle Starting Stage of Game |
449 -- Handle Starting Stage of Game |
449 if (gameOver == false) and (gameBegun == false) then |
450 if (gameOver == false) and (gameBegun == false) then |
450 if wpCount >= 3 then |
451 if wpCount >= 3 then |
451 gameBegun = true |
452 gameBegun = true |
452 roundNumber = 0 |
453 roundNumber = 0 |
453 firstClan = GetHogClan(CurrentHedgehog) |
454 firstClan = GetHogClan(CurrentHedgehog) |
454 ShowMission(loc("RACER"), |
455 ShowMission(loc("RACER"), |
455 loc("GAME BEGUN!!!"), |
456 loc("GAME BEGUN!!!"), |
456 loc("Complete the track as fast as you can!"), 2, 4000) |
457 loc("Complete the track as fast as you can!"), 2, 4000) |
457 else |
458 else |
458 ShowMission(loc("RACER"), |
459 ShowMission(loc("RACER"), |
459 loc("NOT ENOUGH WAYPOINTS"), |
460 loc("NOT ENOUGH WAYPOINTS"), |
460 loc("Place more waypoints using the 'Air Attack' weapon."), 2, 4000) |
461 loc("Place more waypoints using the 'Air Attack' weapon."), 2, 4000) |
461 AddAmmo(CurrentHedgehog, amAirAttack, 4000) |
462 AddAmmo(CurrentHedgehog, amAirAttack, 4000) |
462 end |
463 end |
463 end |
464 end |
464 |
465 |
475 |
476 |
476 end |
477 end |
477 |
478 |
478 function onGameTick() |
479 function onGameTick() |
479 |
480 |
480 -- convert airstrikes into waypoints |
481 -- airstrike detected, convert this into a potential waypoint spot |
481 if cGear ~= nil then |
482 if cGear ~= nil then |
482 x,y = GetGearTarget(cGear) |
483 x,y = GetGearTarget(cGear) |
483 PlaceWayPoint(x, y) |
484 |
484 DeleteGear(cGear) |
485 DeleteGear(cGear) |
485 if wpCount == wpLimit then |
486 |
486 AddCaption(loc("Race complexity limit reached.")) |
487 if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then |
487 DisableTumbler() |
488 AddCaption(loc("Please place the way-point in the open.")) |
488 end |
489 else |
489 end |
490 PlaceWayPoint(x, y) |
490 |
491 if wpCount == wpLimit then |
|
492 AddCaption(loc("Race complexity limit reached.")) |
|
493 DisableTumbler() |
|
494 end |
|
495 end |
|
496 |
|
497 end |
491 |
498 |
492 |
499 |
493 -- start the player tumbling with a boom once their turn has actually begun |
500 -- start the player tumbling with a boom once their turn has actually begun |
494 if racerActive == false then |
501 if racerActive == false then |
495 |
502 |
496 if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then |
503 if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then |
497 |
504 |
498 -- if the gamehas started put the player in the middle of the first |
505 -- if the gamehas started put the player in the middle of the first |
499 --waypoint that was placed |
506 --waypoint that was placed |
500 if gameBegun == true then |
507 if gameBegun == true then |
501 |
|
502 AddCaption(loc("Good to go!")) |
508 AddCaption(loc("Good to go!")) |
503 racerActive = true |
509 racerActive = true |
504 trackTime = 0 |
510 trackTime = 0 |
505 |
511 |
506 SetGearPosition(CurrentHedgehog, wpX[0], wpY[0]) |
512 SetGearPosition(CurrentHedgehog, wpX[0], wpY[0]) |
507 AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1) |
513 AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1) |
508 FollowGear(CurrentHedgehog) |
514 FollowGear(CurrentHedgehog) |
509 ShowMission("...", "...", "...", 2, 1) |
515 ShowMission("...", "...", "...", 2, 1) |
510 |
516 |
511 else |
517 else |
512 -- still in placement mode |
518 -- still in placement mode |
513 end |
519 end |
514 |
520 |
515 end |
521 end |
516 end |
522 end |
521 if (CurrentHedgehog ~= nil) then |
527 if (CurrentHedgehog ~= nil) then |
522 |
528 |
523 --airstrike conversion used to be here |
529 --airstrike conversion used to be here |
524 |
530 |
525 -- if the RACE has started, show tracktimes and keep tabs on waypoints |
531 -- if the RACE has started, show tracktimes and keep tabs on waypoints |
526 if (racerActive == true) and (gameBegun == true) then |
532 if (racerActive == true) and (gameBegun == true) then |
527 |
533 |
528 --ghost |
534 --ghost |
529 gTimer = gTimer + 1 |
535 gTimer = gTimer + 1 |
530 if gTimer == 15 then |
536 if gTimer == 15 then |
531 gTimer = 0 |
537 gTimer = 0 |
532 HandleGhost() |
538 HandleGhost() |
533 end |
539 end |
534 |
540 |
535 trackTime = trackTime + 1 |
541 trackTime = trackTime + 1 |
536 |
542 |
537 wpCheckCounter = wpCheckCounter + 1 |
543 wpCheckCounter = wpCheckCounter + 1 |
538 if (wpCheckCounter == 100) then |
544 if (wpCheckCounter == 100) then |
539 |
545 |
540 wpCheckCounter = 0 |
546 wpCheckCounter = 0 |
541 AddCaption(trackTime/1000,GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2) |
547 AddCaption(trackTime/1000,GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2) |
542 |
548 |
543 if (CheckWaypoints() == true) then |
549 if (CheckWaypoints() == true) then |
544 AdjustScores() |
550 AdjustScores() |
545 racerActive = false |
551 racerActive = false |
546 DisableTumbler() |
552 DisableTumbler() |
547 end |
553 end |
548 |
554 |
549 end |
555 end |
550 |
556 |
551 end |
557 end |
552 |
558 |
553 |
559 |
554 |
560 |
555 -- if the player has expended his tunbling time, stop him tumbling |
561 -- if the player has expended his tunbling time, stop him tumbling |
556 if TurnTimeLeft <= 1 then |
562 if TurnTimeLeft <= 1 then |
557 DisableTumbler() |
563 DisableTumbler() |
558 end |
564 end |
566 AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
572 AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false) |
567 |
573 |
568 -- if the player stops and "dies" or flies into water, stop him racing |
574 -- if the player stops and "dies" or flies into water, stop him racing |
569 --[[if gear == CurrentHedgehog then |
575 --[[if gear == CurrentHedgehog then |
570 DisableTumbler() |
576 DisableTumbler() |
571 ShowMission(loc("RACER"), |
577 ShowMission(loc("RACER"), |
572 loc("TRACK FAILED!"), |
578 loc("TRACK FAILED!"), |
573 loc("WINNING TIME: ") .. bestTimeComment, -amSkip, 4000) |
579 loc("WINNING TIME: ") .. bestTimeComment, -amSkip, 4000) |
574 end]] |
580 end]] |
575 |
581 |
576 end |
582 end |
577 |
583 |
594 if CurrentHedgehog ~= nil then |
600 if CurrentHedgehog ~= nil then |
595 FollowGear(CurrentHedgehog) |
601 FollowGear(CurrentHedgehog) |
596 end |
602 end |
597 |
603 |
598 if GetGearType(gear) == gtAirAttack then |
604 if GetGearType(gear) == gtAirAttack then |
599 cGear = nil |
605 cGear = nil |
600 end |
606 end |
601 |
607 |
602 end |
608 end |
603 |
609 |
604 --[[function onAmmoStoreInit() |
610 --[[function onAmmoStoreInit() |
605 SetAmmo(amRope, 9, 0, 0, 0) |
611 SetAmmo(amRope, 9, 0, 0, 0) |
606 SetAmmo(amJetpack, 9, 0, 0, 0) |
612 SetAmmo(amJetpack, 9, 0, 0, 0) |
607 SetAmmo(amSkip, 9, 0, 0, 0) |
613 SetAmmo(amSkip, 9, 0, 0, 0) |
608 end]] |
614 end]] |
609 |
615 |
610 |
616 |