share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
changeset 12412 8cc070640fd1
parent 12411 cd53f1bf52ff
child 12967 52c12029c7bd
equal deleted inserted replaced
12411:cd53f1bf52ff 12412:8cc070640fd1
   158 local usedWeapons = {}
   158 local usedWeapons = {}
   159 
   159 
   160 local roundN
   160 local roundN
   161 local lastRound
   161 local lastRound
   162 local RoundHasChanged
   162 local RoundHasChanged
       
   163 local turnSkipped = false
   163 
   164 
   164 local boostX = 0
   165 local boostX = 0
   165 local boostY = 0
   166 local boostY = 0
   166 local boostValue = 1
   167 local boostValue = 1
   167 
   168 
   568                 loc("Build a track and race.") .. "|" ..
   569                 loc("Build a track and race.") .. "|" ..
   569                 string.format(loc("Round limit: %d"), roundLimit),
   570                 string.format(loc("Round limit: %d"), roundLimit),
   570                 4, 4000)
   571                 4, 4000)
   571 end
   572 end
   572 
   573 
   573 function InstructionsRace(time)
   574 function InstructionsRace()
   574         ShowMission(loc("Racer"),
   575         ShowMission(loc("Racer"),
   575         	loc("A Hedgewars mini-game"),
   576         	loc("A Hedgewars mini-game"),
   576         	loc("Touch all waypoints as fast as you can!"),
   577         	loc("Touch all waypoints as fast as you can!"),
   577 		2, time)
   578 		2, 4000)
   578 end
   579 end
   579 
   580 
   580 function onGameStart()
   581 function onGameStart()
   581 	SendGameResultOff()
   582 	SendGameResultOff()
   582 	SendRankingStatsOff()
   583 	SendRankingStatsOff()
   678 
   679 
   679         CheckForNewRound()
   680         CheckForNewRound()
   680         TryRepositionHogs()
   681         TryRepositionHogs()
   681 
   682 
   682         racerActive = false
   683         racerActive = false
       
   684         turnSkipped = false
   683 
   685 
   684         trackTime = 0
   686         trackTime = 0
   685 
   687 
   686         currCount = 0 -- hopefully this solves problem
   688         currCount = 0 -- hopefully this solves problem
   687         AddAmmo(CurrentHedgehog, amAirAttack, 0)
   689         AddAmmo(CurrentHedgehog, amAirAttack, 0)
   818                         end
   820                         end
   819 
   821 
   820                 end
   822                 end
   821 
   823 
   822                 -- if the player has expended his tunbling time, stop him tumbling
   824                 -- if the player has expended his tunbling time, stop him tumbling
   823                 if TurnTimeLeft <= 20 then
   825                 if TurnTimeLeft <= 20 and not turnSkipped then
   824                         DisableTumbler()
   826                         DisableTumbler()
   825                 end
   827                 end
   826 
   828 
   827         end
   829         end
   828 
   830 
   864 
   866 
   865 function onAttack()
   867 function onAttack()
   866     at = GetCurAmmoType()
   868     at = GetCurAmmoType()
   867 
   869 
   868     usedWeapons[at] = 0
   870     usedWeapons[at] = 0
       
   871 end
       
   872 
       
   873 function onHogAttack(ammoType)
       
   874     if ammoType == amSkip then
       
   875         turnSkipped = true
       
   876     end
   869 end
   877 end
   870 
   878 
   871 function onAchievementsDeclaration()
   879 function onAchievementsDeclaration()
   872     usedWeapons[amSkip] = nil
   880     usedWeapons[amSkip] = nil
   873     usedWeapons[amExtraTime] = nil
   881     usedWeapons[amExtraTime] = nil