share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
changeset 9746 64abf9862562
parent 9642 8a691e0f117a
child 9747 abe0c8a2d573
equal deleted inserted replaced
9745:258c320256dc 9746:64abf9862562
    12 local missionName = loc("Getting to the device")
    12 local missionName = loc("Getting to the device")
    13 local inBattle = false
    13 local inBattle = false
    14 local tookPartInBattle = false
    14 local tookPartInBattle = false
    15 local previousHog = -1
    15 local previousHog = -1
    16 local checkPointReached = 1 -- 1 is normal spawn
    16 local checkPointReached = 1 -- 1 is normal spawn
       
    17 local permitCaptainLimeDeath = false
    17 -- dialogs
    18 -- dialogs
    18 local dialog01 = {}
    19 local dialog01 = {}
    19 local dialog02 = {}
    20 local dialog02 = {}
    20 local dialog03 = {}
    21 local dialog03 = {}
    21 local dialog04 = {}
    22 local dialog04 = {}
   264 	end
   265 	end
   265 	ExecuteAfterAnimations()
   266 	ExecuteAfterAnimations()
   266 	CheckEvents()
   267 	CheckEvents()
   267 end
   268 end
   268 
   269 
       
   270 function onGameTick20()
       
   271 	if not permitCaptainLimeDeath and not GetHealth(green1.gear) then
       
   272 		-- game ends with the according stat messages
       
   273 		heroDeath()
       
   274 		permitCaptainLimeDeath = true
       
   275 	end
       
   276 end
       
   277 
   269 function onGearDelete(gear)
   278 function onGearDelete(gear)
   270 	if gear == hero.gear then
   279 	if gear == hero.gear then
   271 		hero.dead = true
   280 		hero.dead = true
   272 	elseif gear == green1.bot then
   281 	elseif gear == green1.bot then
   273 		green1.dead = true
   282 		green1.dead = true
       
   283 	end
       
   284 end
       
   285 
       
   286 function onGearDamage(gear, damage)
       
   287 	if GetGearType(gear) == gtCase then
       
   288 		-- in this mode every crate is essential in order to complete the mission
       
   289 		-- destroying a crate ends the game
       
   290 		heroDeath()
   274 	end
   291 	end
   275 end
   292 end
   276 
   293 
   277 function onAmmoStoreInit()
   294 function onAmmoStoreInit()
   278 	SetAmmo(amDEagle, 0, 0, 0, 6)
   295 	SetAmmo(amDEagle, 0, 0, 0, 6)
   376 
   393 
   377 function heroDeath(gear)
   394 function heroDeath(gear)
   378 	SendStat(siGameResult, loc("Hog Solo lost, try again!"))
   395 	SendStat(siGameResult, loc("Hog Solo lost, try again!"))
   379 	SendStat(siCustomAchievement, loc("To win the game Hog Solo has to get the bottom crates and come back to the surface"))
   396 	SendStat(siCustomAchievement, loc("To win the game Hog Solo has to get the bottom crates and come back to the surface"))
   380 	SendStat(siCustomAchievement, loc("You can use the other 2 hogs to assist you"))
   397 	SendStat(siCustomAchievement, loc("You can use the other 2 hogs to assist you"))
       
   398 	SendStat(siCustomAchievement, loc("Do not destroy the crates"))
   381 	if tookPartInBattle then
   399 	if tookPartInBattle then
   382 		SendStat(siCustomAchievement, loc("You'll have to eliminate the Strawberry Assasins at the end"))
   400 		SendStat(siCustomAchievement, loc("You'll have to eliminate the Strawberry Assasins at the end"))
   383 	else
   401 	else
   384 		SendStat(siCustomAchievement, loc("You'll have to eliminate Captain Lime at the end"))	
   402 		SendStat(siCustomAchievement, loc("You'll have to eliminate Captain Lime at the end"))
       
   403 	SendStat(siCustomAchievement, loc("Don't eliminate Captain Lime before collecting the last crate!"))		
   385 	end
   404 	end
   386 	SendStat(siPlayerKills,'0',teamA.name)
   405 	SendStat(siPlayerKills,'0',teamA.name)
   387 	EndGame()
   406 	EndGame()
   388 end
   407 end
   389 
   408 
   395 		for i=1,table.getn(redHedgehogs) do
   414 		for i=1,table.getn(redHedgehogs) do
   396 			RestoreHog(redHedgehogs[i].gear)
   415 			RestoreHog(redHedgehogs[i].gear)
   397 		end
   416 		end
   398 		AddAnim(dialog04)
   417 		AddAnim(dialog04)
   399 	end
   418 	end
       
   419 	-- needs to be set to true for both plots
       
   420 	permitCaptainLimeDeath = true
   400 	AddAmmo(hero.gear, amSwitch, 0)
   421 	AddAmmo(hero.gear, amSwitch, 0)
   401 	AddEvent(onSurface, {hero.gear}, surface, {hero.gear}, 0)
   422 	AddEvent(onSurface, {hero.gear}, surface, {hero.gear}, 0)
   402 end
   423 end
   403 
   424 
   404 function surface(gear)
   425 function surface(gear)
   531 function saveHogsPositions()
   552 function saveHogsPositions()
   532 	local positions;
   553 	local positions;
   533 	positions = GetX(hero.gear)..","..GetY(hero.gear)
   554 	positions = GetX(hero.gear)..","..GetY(hero.gear)
   534 	if GetHealth(green2.gear) then
   555 	if GetHealth(green2.gear) then
   535 		positions = positions..","..GetX(green2.gear)..","..GetY(green2.gear)
   556 		positions = positions..","..GetX(green2.gear)..","..GetY(green2.gear)
       
   557 	else
       
   558 		positions = positions..",1,1"
   536 	end
   559 	end
   537 	if GetHealth(green3.gear) then
   560 	if GetHealth(green3.gear) then
   538 		positions = positions..","..GetX(green3.gear)..","..GetY(green3.gear)
   561 		positions = positions..","..GetX(green3.gear)..","..GetY(green3.gear)
       
   562 	else
       
   563 		positions = positions..",1,1"
   539 	end
   564 	end
   540 	SaveCampaignVar("HogsPosition", positions)
   565 	SaveCampaignVar("HogsPosition", positions)
   541 end
   566 end
   542 
   567 
   543 function loadHogsPositions()
   568 function loadHogsPositions()