share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
changeset 13838 bf8c454a9f93
parent 13837 25de751feb02
child 13894 4608300bc2fc
equal deleted inserted replaced
13837:25de751feb02 13838:bf8c454a9f93
    11 ----------------- VARIABLES --------------------
    11 ----------------- VARIABLES --------------------
    12 -- globals
    12 -- globals
    13 local missionName = loc("Hard flying")
    13 local missionName = loc("Hard flying")
    14 local challengeStarted = false
    14 local challengeStarted = false
    15 local currentWaypoint = 1
    15 local currentWaypoint = 1
    16 local radius = 75
    16 local radius = 75 -- Ring radius. Will become smaller and smaller
    17 local totalTime = 15000
    17 local totalTime = 15000 -- Total available time. Initial value is start time; is added to later when player wins extra time
    18 local totalSaucers = 3
    18 local totalSaucers = 3
    19 local gameEnded = false
    19 local gameEnded = false
       
    20 local heroTurn = false
    20 local RED = 0xff0000ff
    21 local RED = 0xff0000ff
    21 local GREEN = 0x00ff00ff
    22 local GREEN = 0x00ff00ff
    22 local challengeObjectives = loc("To win the game you have to pass into the rings in time.")..
    23 local challengeObjectives = loc("To win the game you have to pass into the rings in time.")..
    23 	"|"..loc("You'll get extra time in case you need it when you pass a ring.").."|"..
    24 	"|"..loc("You'll get extra time in case you need it when you pass a ring.").."|"..
    24 	loc("Green double rings also give you a new flying saucer.").."|"..
    25 	loc("Green double rings also give you a new flying saucer.").."|"..
    43 teamA.name = loc("Hog Solo")
    44 teamA.name = loc("Hog Solo")
    44 teamA.color = -6
    45 teamA.color = -6
    45 teamB.name = loc("Allies")
    46 teamB.name = loc("Allies")
    46 teamB.color = -6
    47 teamB.color = -6
    47 -- way points
    48 -- way points
    48 local current waypoint = 1
       
    49 local waypoints = {
    49 local waypoints = {
    50 	[1] = {x=1450, y=140},
    50 	[1] = {x=1450, y=140},
    51 	[2] = {x=990, y=580},
    51 	[2] = {x=990, y=580},
    52 	[3] = {x=1650, y=950},
    52 	[3] = {x=1650, y=950},
    53 	[4] = {x=620, y=630},
    53 	[4] = {x=620, y=630},
    67 -------------- LuaAPI EVENT HANDLERS ------------------
    67 -------------- LuaAPI EVENT HANDLERS ------------------
    68 
    68 
    69 function onGameInit()
    69 function onGameInit()
    70 	GameFlags = gfInvulnerable + gfOneClanMode
    70 	GameFlags = gfInvulnerable + gfOneClanMode
    71 	Seed = 1
    71 	Seed = 1
    72 	TurnTime = 15000
    72 	TurnTime = totalTime
    73 	Ready = 25000
    73 	Ready = 25000
    74 	CaseFreq = 0
    74 	CaseFreq = 0
    75 	MinesNum = 0
    75 	MinesNum = 0
    76 	MinesTime = 1
    76 	MinesTime = 1
    77 	Explosives = 0
    77 	Explosives = 0
   130 	if not hero.dead and CurrentHedgehog == ally.gear and challengeStarted then
   130 	if not hero.dead and CurrentHedgehog == ally.gear and challengeStarted then
   131 		heroLost()
   131 		heroLost()
   132 	elseif not hero.dead and CurrentHedgehog == hero.gear and challengeStarted then
   132 	elseif not hero.dead and CurrentHedgehog == hero.gear and challengeStarted then
   133 		SetWeapon(amJetpack)
   133 		SetWeapon(amJetpack)
   134 	end
   134 	end
       
   135 	heroTurn = CurrentHedgehog == hero.gear
   135 end
   136 end
   136 
   137 
   137 function onGameTick()
   138 function onGameTick()
   138 	AnimUnWait()
   139 	AnimUnWait()
   139 	if ShowAnimation() == false then
   140 	if ShowAnimation() == false then
   150 			-- GAME OVER, WIN!
   151 			-- GAME OVER, WIN!
   151 			totalTime = totalTime - TurnTimeLeft
   152 			totalTime = totalTime - TurnTimeLeft
   152 			local totalTimePrinted  = totalTime / 1000
   153 			local totalTimePrinted  = totalTime / 1000
   153 			local saucersLeft = GetAmmoCount(hero.gear, amJetpack)
   154 			local saucersLeft = GetAmmoCount(hero.gear, amJetpack)
   154 			local saucersUsed = totalSaucers - saucersLeft
   155 			local saucersUsed = totalSaucers - saucersLeft
       
   156 			SetTeamLabel(teamA.name, string.format(loc("%.3f s"), totalTimePrinted))
   155 			SendStat(siGameResult, loc("Hooray! You are a champion!"))
   157 			SendStat(siGameResult, loc("Hooray! You are a champion!"))
   156 			SendStat(siCustomAchievement, string.format(loc("You completed the mission in %.3f seconds."), totalTimePrinted))
   158 			SendStat(siCustomAchievement, string.format(loc("You completed the mission in %.3f seconds."), totalTimePrinted))
   157 			if timeRecord ~= nil and totalTime >= timeRecord then
   159 			if timeRecord ~= nil and totalTime >= timeRecord then
   158 				SendStat(siCustomAchievement, string.format(loc("Your personal best time so far: %.3f seconds"), timeRecord/1000))
   160 				SendStat(siCustomAchievement, string.format(loc("Your personal best time so far: %.3f seconds"), timeRecord/1000))
   159 			end
   161 			end
   173 
   175 
   174 			SendStat(siPointType, loc("milliseconds"))
   176 			SendStat(siPointType, loc("milliseconds"))
   175 			SendStat(siPlayerKills, totalTime, GetHogTeamName(hero.gear))
   177 			SendStat(siPlayerKills, totalTime, GetHogTeamName(hero.gear))
   176 			SaveCampaignVar("Mission6Won", "true")
   178 			SaveCampaignVar("Mission6Won", "true")
   177 			checkAllMissionsCompleted()
   179 			checkAllMissionsCompleted()
       
   180 			SetTurnTimeLeft(MAX_TURN_TIME)
   178 			EndGame()
   181 			EndGame()
   179 		end
   182 		end
       
   183 	end
       
   184 	if heroTurn and challengeStarted and not gameEnded and not hero.dead and ReadyTimeLeft == 0 then
       
   185 		local time = totalTime - TurnTimeLeft
       
   186 		local timePrinted  = time / 1000
       
   187 		SetTeamLabel(teamA.name, string.format(loc("%.1f s"), timePrinted))
   180 	end
   188 	end
   181 end
   189 end
   182 
   190 
   183 function onGearDelete(gear)
   191 function onGearDelete(gear)
   184 	if gear == hero.gear then
   192 	if gear == hero.gear then