411 teamName = GetHogTeamName(CurrentHedgehog), |
401 teamName = GetHogTeamName(CurrentHedgehog), |
412 distance = distanceFromWater |
402 distance = distanceFromWater |
413 } |
403 } |
414 end |
404 end |
415 end |
405 end |
416 local finishTime = (GameTime-startTime)/1000 |
406 |
417 local roundedFinishTime = math.ceil(math.floor(finishTime+0.5)) |
407 local finishTime = (GameTime-startTime)/1000 |
418 if isSinglePlayer then |
408 local roundedFinishTime = math.ceil(math.floor(finishTime+0.5)) |
419 if distanceFromWater < 0 and not YouLost and not YouWon then |
409 if isSinglePlayer then |
420 makeSinglePlayerLoserStats() |
410 if distanceFromWater < 0 and not YouLost and not YouWon then |
421 YouLost = true |
411 makeSinglePlayerLoserStats() |
422 ready = false |
412 YouLost = true |
423 end |
413 end |
424 -- FIXME: Hog is also in winning box if it just walks into the chair from the left, touching it. Intentional? |
414 -- FIXME: Hog is also in winning box if it just walks into the chair from the left, touching it. Intentional? |
425 if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then |
415 if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then |
426 AddCaption(loc("Victory!")) |
416 AddCaption(loc("Victory!")) |
427 ShowMission(loc("Climb Home"), |
417 ShowMission(loc("Climb Home"), |
428 loc("Made it!"), |
418 loc("Made it!"), |
429 string.format(loc("Ahhh, home, sweet home. Made it in %d seconds."), roundedFinishTime), |
419 string.format(loc("Ahhh, home, sweet home. Made it in %d seconds."), roundedFinishTime), |
430 -amRope, 0) |
420 -amRope, 0) |
431 PlaySound(sndVictory,CurrentHedgehog) |
421 PlaySound(sndVictory,CurrentHedgehog) |
432 SetState(CurrentHedgehog, gstWinner) |
422 SetState(CurrentHedgehog, gstWinner) |
433 SendStat(siGameResult, loc("You have beaten the challenge!")) |
423 SendStat(siGameResult, loc("You have beaten the challenge!")) |
434 SendStat(siGraphTitle, loc("Your height over time")) |
424 SendStat(siGraphTitle, loc("Your height over time")) |
435 SendStat(siCustomAchievement, string.format(loc("%s reached home in %.3f seconds. Congratulations!"), GetHogName(CurrentHedgehog), finishTime)) |
425 SendStat(siCustomAchievement, string.format(loc("%s reached home in %.3f seconds. Congratulations!"), GetHogName(CurrentHedgehog), finishTime)) |
436 SendStat(siCustomAchievement, string.format(loc("%s bravely climbed up to a dizzy height of %d to reach home."), GetHogName(CurrentHedgehog), getActualHeight(RecordHeight))) |
426 SendStat(siCustomAchievement, string.format(loc("%s bravely climbed up to a dizzy height of %d to reach home."), GetHogName(CurrentHedgehog), getActualHeight(RecordHeight))) |
437 SendStat(siPointType, loc("seconds")) |
427 SendStat(siPointType, loc("seconds")) |
438 SendStat(siPlayerKills, tostring(roundedFinishTime), GetHogTeamName(CurrentHedgehog)) |
428 SendStat(siPlayerKills, tostring(roundedFinishTime), GetHogTeamName(CurrentHedgehog)) |
439 |
429 |
|
430 EndGame() |
|
431 onAchievementsDeclaration() |
|
432 YouWon = true |
|
433 end |
|
434 else |
|
435 if distanceFromWater < 0 and not YouLost and not YouWon then |
|
436 makeMultiPlayerLoserStat(CurrentHedgehog) |
|
437 deadHedgehogs = deadHedgehogs + 1 |
|
438 YouLost = true |
|
439 if deadHedgehogs >= totalHedgehogs then |
|
440 makeFinalMultiPlayerStats() |
440 EndGame() |
441 EndGame() |
441 onAchievementsDeclaration() |
442 onAchievementsDeclaration() |
442 YouWon = true |
443 end |
443 ready = false |
444 end |
444 end |
445 -- Check victory |
445 else |
446 if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) and |
446 if distanceFromWater < 0 and not YouLost and not YouWon then |
447 -- Delay victory if MrMine is triggered |
447 makeMultiPlayerLoserStat(CurrentHedgehog) |
448 (not MrMine or (MrMine and band(GetState(MrMine), gstAttacking) == 0)) then |
448 deadHedgehogs = deadHedgehogs + 1 |
449 -- Player managed to reach home in multiplayer. |
449 YouLost = true |
450 -- Stop hog, disable controls, celebrate victory and continue the game after 4 seconds. |
450 ready = false |
451 AddCaption(string.format(loc("%s climbed home in %d seconds!"), GetHogName(CurrentHedgehog), roundedFinishTime)) |
451 if deadHedgehogs >= totalHedgehogs then |
452 SendStat(siCustomAchievement, string.format(loc("%s (%s) reached home in %.3f seconds."), GetHogName(CurrentHedgehog), GetHogTeamName(CurrentHedgehog), finishTime)) |
452 makeFinalMultiPlayerStats() |
453 makeMultiPlayerWinnerStat(CurrentHedgehog) |
453 EndGame() |
454 PlaySound(sndVictory, CurrentHedgehog) |
454 onAchievementsDeclaration() |
455 -- TODO: Unselect weapon. |
455 end |
456 -- Note: SetWeapon(amNothing) does not work. :-( |
456 end |
457 SetGearMessage(CurrentHedgehog, band(GetGearMessage(CurrentHedgehog), bnot(gmLeft+gmRight+gmUp+gmDown+gmHJump+gmLJump+gmPrecise))) |
457 -- Check victory |
458 SetInputMask(0x00) |
458 if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) and |
459 -- TODO: Add stupid winner grin. |
459 -- Delay victory if MrMine is triggered |
460 multiplayerVictoryDelay = 4000 |
460 (not MrMine or (MrMine and band(GetState(MrMine), gstAttacking) == 0)) then |
461 YouWon = true |
461 -- Player managed to reach home in multiplayer. |
462 end |
462 -- Stop hog, disable controls, celebrate victory and continue the game after 4 seconds. |
463 end |
463 AddCaption(string.format(loc("%s climbed home in %d seconds!"), GetHogName(CurrentHedgehog), roundedFinishTime)) |
|
464 SendStat(siCustomAchievement, string.format(loc("%s (%s) reached home in %.3f seconds."), GetHogName(CurrentHedgehog), GetHogTeamName(CurrentHedgehog), finishTime)) |
|
465 makeMultiPlayerWinnerStat(CurrentHedgehog) |
|
466 PlaySound(sndVictory, CurrentHedgehog) |
|
467 -- TODO: Unselect weapon. |
|
468 -- Note: SetWeapon(amNothing) does not work. :-( |
|
469 SetGearMessage(CurrentHedgehog, band(GetGearMessage(CurrentHedgehog), bnot(gmLeft+gmRight+gmUp+gmDown+gmHJump+gmLJump+gmPrecise))) |
|
470 SetInputMask(0x00) |
|
471 -- TODO: Add stupid winner grin. |
|
472 multiplayerVictoryDelay = 4000 |
|
473 YouWon = true |
|
474 ready = false |
|
475 end |
|
476 end |
|
477 |
464 |
478 if GameTime % 500 == 0 then |
465 if GameTime % 500 == 0 then |
479 if not isSinglePlayer then |
466 if not isSinglePlayer then |
480 for t,i in pairs(teams) do |
467 for t,i in pairs(teams) do |
481 if currTeam == t then |
468 if currTeam == t then |
482 SendStat(siClanHealth, tostring(getActualHeight(y)), t) |
469 SendStat(siClanHealth, tostring(getActualHeight(y)), t) |
483 else |
470 else |
484 SendStat(siClanHealth, '0', t) |
471 SendStat(siClanHealth, '0', t) |
485 end |
472 end |
486 end |
473 end |
487 elseif CurrentHedgehog ~= nil then |
474 else |
488 SendStat(siClanHealth, tostring(getActualHeight(y)), GetHogTeamName(CurrentHedgehog)) |
475 SendStat(siClanHealth, tostring(getActualHeight(y)), GetHogTeamName(CurrentHedgehog)) |
489 end |
476 end |
490 |
477 |
491 -- play taunts |
478 -- play taunts |
492 if not YouWon and not YouLost then |
479 if not YouWon and not YouLost then |