share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua
changeset 12970 dc35a79c6ef9
parent 12940 39b7b3ed619e
child 13092 422e20b577e2
equal deleted inserted replaced
12969:2fee2ee717eb 12970:dc35a79c6ef9
    31 	firepunchAmmo = 1,
    31 	firepunchAmmo = 1,
    32 	deagleAmmo = 4,
    32 	deagleAmmo = 4,
    33 	bazookaAmmo = 2,
    33 	bazookaAmmo = 2,
    34 	grenadeAmmo = 4,
    34 	grenadeAmmo = 4,
    35 }
    35 }
       
    36 local heroTurns = 0
    36 local enemies = {
    37 local enemies = {
    37 	{ name = GetAmmoName(amMortar), x = 1890, y = 520, weapon = amMortar, additionalWeapons = {}},
    38 	{ name = GetAmmoName(amMortar), x = 1890, y = 520, weapon = amMortar, additionalWeapons = {}},
    38 	{ name = GetAmmoName(amDEagle), x = 1390, y = 790, weapon = amDEagle, additionalWeapons = {}},
    39 	{ name = GetAmmoName(amDEagle), x = 1390, y = 790, weapon = amDEagle, additionalWeapons = {}},
    39 	{ name = GetAmmoName(amGrenade), x = 186, y = 48, weapon = amGrenade, additionalWeapons = {}},
    40 	{ name = GetAmmoName(amGrenade), x = 186, y = 48, weapon = amGrenade, additionalWeapons = {}},
    40 	{ name = GetAmmoName(amFirePunch), x = 330, y = 270, weapon = amFirePunch, additionalWeapons = {}},
    41 	{ name = GetAmmoName(amFirePunch), x = 330, y = 270, weapon = amFirePunch, additionalWeapons = {}},
   109 		ReadyTimeLeft = 35000
   110 		ReadyTimeLeft = 35000
   110 		firstTurn = false
   111 		firstTurn = false
   111 	end
   112 	end
   112 	if CurrentHedgehog ~= hero.gear then
   113 	if CurrentHedgehog ~= hero.gear then
   113 		enemyWeapons()
   114 		enemyWeapons()
       
   115 	else
       
   116 		heroTurns = heroTurns + 1
   114 	end
   117 	end
   115 end
   118 end
   116 
   119 
   117 function onGearDelete(gear)
   120 function onGearDelete(gear)
   118 	if isHog(gear) then
   121 	if isHog(gear) then
   213 end
   216 end
   214 
   217 
   215 function heroWin(gear)
   218 function heroWin(gear)
   216 	saveBonus(3, 4)
   219 	saveBonus(3, 4)
   217 	SendStat(siGameResult, loc("Congratulations, you won!"))
   220 	SendStat(siGameResult, loc("Congratulations, you won!"))
   218 	SendStat(siCustomAchievement, string.format(loc("You completed the mission in %d rounds."), TotalRounds))
   221 	SendStat(siCustomAchievement, string.format(loc("You completed the mission in %d rounds."), heroTurns))
   219 	local record = tonumber(GetCampaignVar("FastestSpecialistsKill"))
   222 	local record = tonumber(GetCampaignVar("FastestSpecialistsWin"))
   220 	if record ~= nil and TotalRounds >= record then
   223 	if record ~= nil and heroTurns >= record then
   221 		SendStat(siCustomAchievement, string.format(loc("Your fastest victory so far: %d rounds"), record))
   224 		SendStat(siCustomAchievement, string.format(loc("Your fastest victory so far: %d rounds"), record))
   222 	end
   225 	end
   223 	if record == nil or TotalRounds < record then
   226 	if record == nil or heroTurns < record then
   224 		SaveCampaignVar("FastestSpecialistsKill", tostring(TotalRounds))
   227 		SaveCampaignVar("FastestSpecialistsWin", tostring(heroTurns))
   225 		if record ~= nil then
   228 		if record ~= nil then
   226 			SendStat(siCustomAchievement, loc("This is a new personal best, congratulations!"))
   229 			SendStat(siCustomAchievement, loc("This is a new personal best, congratulations!"))
   227 		end
   230 		end
   228 	end
   231 	end
       
   232 	-- An old version of this mission was buggy and stored a turn record WAY too low.
       
   233 	-- Let's clear the broken variable (FastestSpecialistsKill) here.
       
   234 	SaveCampaignVar("FastestSpecialistsKill", "")
   229 	SendStat(siCustomAchievement, loc("The next 4 times you play the \"The last encounter\" mission you'll get 20 more hit points and a laser sight."))
   235 	SendStat(siCustomAchievement, loc("The next 4 times you play the \"The last encounter\" mission you'll get 20 more hit points and a laser sight."))
   230 	sendSimpleTeamRankings({teamA.name, teamB.name})
   236 	sendSimpleTeamRankings({teamA.name, teamB.name})
   231 	SaveCampaignVar("Mission11Won", "true")
   237 	SaveCampaignVar("Mission11Won", "true")
   232 	checkAllMissionsCompleted()
   238 	checkAllMissionsCompleted()
   233 	EndGame()
   239 	EndGame()