share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua
changeset 15098 a2d09a597fbb
parent 15089 6f51c75994a4
child 15102 3a561db2a71c
equal deleted inserted replaced
15097:527a7414bb44 15098:a2d09a597fbb
   313 		win = false
   313 		win = false
   314 	end
   314 	end
   315 	return win
   315 	return win
   316 end
   316 end
   317 
   317 
       
   318 function onEscapeWinByKill(gear)
       
   319 	local win = true
       
   320 	for i=1,7 do
       
   321 		if GetHealth(yellowArmy[i].gear) or yellowArmy[i].hidden then
       
   322 			win = false
       
   323 		end
       
   324 	end
       
   325 	if GetHealth(yellow1.gear) then
       
   326 		win = false
       
   327 	end
       
   328 	return win
       
   329 end
       
   330 
   318 function isHeroOnLaunchPad()
   331 function isHeroOnLaunchPad()
   319 	if not hero.dead and GetX(hero.gear) < 170 and GetY(hero.gear) > 1980 and StoppedGear(hero.gear) then
   332 	if not hero.dead and GetX(hero.gear) < 170 and GetY(hero.gear) > 1980 and StoppedGear(hero.gear) then
   320 		return true
   333 		return true
   321 	end
   334 	end
   322 	return false
   335 	return false
   371 	RemoveEventFunc(heroOnLaunchPadWithEnemies)
   384 	RemoveEventFunc(heroOnLaunchPadWithEnemies)
   372 	-- add stats
   385 	-- add stats
   373 	saveVariables()
   386 	saveVariables()
   374 	SendStat(siGameResult, string.format(loc("%s escaped successfully!"), hero.name))
   387 	SendStat(siGameResult, string.format(loc("%s escaped successfully!"), hero.name))
   375 	SendStat(siCustomAchievement, loc("You have reached the take-off area successfully!"))
   388 	SendStat(siCustomAchievement, loc("You have reached the take-off area successfully!"))
       
   389 	sendSimpleTeamRankings({teamA.name, teamD.name, teamB.name, teamC.name})
       
   390 	EndGame()
       
   391 end
       
   392 
       
   393 function escapeWinByKill(gear)
       
   394 	RemoveEventFunc(heroOnLaunchPadWithEnemies)
       
   395 	-- add stats
       
   396 	saveVariables()
       
   397 	SendStat(siGameResult, string.format(loc("%s won!"), teamB.name))
   376 	sendSimpleTeamRankings({teamA.name, teamD.name, teamB.name, teamC.name})
   398 	sendSimpleTeamRankings({teamA.name, teamD.name, teamB.name, teamC.name})
   377 	EndGame()
   399 	EndGame()
   378 end
   400 end
   379 
   401 
   380 function heroSelect()
   402 function heroSelect()
   389 	else
   411 	else
   390 		ShowMission(unpack(goals["flee"]))
   412 		ShowMission(unpack(goals["flee"]))
   391 		AddAmmo(green1.gear, amSwitch, 100)
   413 		AddAmmo(green1.gear, amSwitch, 100)
   392 		AddEvent(onHeroOnLaunchPadWithEnemies, {hero.gear}, heroOnLaunchPadWithEnemies, {hero.gear}, 0)
   414 		AddEvent(onHeroOnLaunchPadWithEnemies, {hero.gear}, heroOnLaunchPadWithEnemies, {hero.gear}, 0)
   393 		AddEvent(onEscapeWin, {hero.gear}, escapeWin, {hero.gear}, 0)
   415 		AddEvent(onEscapeWin, {hero.gear}, escapeWin, {hero.gear}, 0)
       
   416 		-- Alternative victory in the "flee" mission: ALL yellow hedgehogs killed
       
   417 		AddEvent(onEscapeWinByKill, {hero.gear}, escapeWinByKill, {hero.gear}, 0)
   394 		local greenTeam = { green2, green3, green4, green5 }
   418 		local greenTeam = { green2, green3, green4, green5 }
   395 		for i=1,4 do
   419 		for i=1,4 do
   396 			SetHogLevel(greenTeam[i].gear, 1)
   420 			SetHogLevel(greenTeam[i].gear, 1)
   397 		end
   421 		end
   398 		AddAnim(dialog03)
   422 		AddAnim(dialog03)