share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua
changeset 12561 250a10a48388
parent 12560 2f7274e5e090
child 12562 68dd14766445
equal deleted inserted replaced
12560:2f7274e5e090 12561:250a10a48388
    16 local timeForGuard1ToTurnLeft = timeForGuard1ToTurn
    16 local timeForGuard1ToTurnLeft = timeForGuard1ToTurn
    17 local saucerAcquired = false
    17 local saucerAcquired = false
    18 local status
    18 local status
    19 local getReadyForRumble = false -- guards wake up
    19 local getReadyForRumble = false -- guards wake up
    20 local ropeDestroyed = false -- for detecting if player roped to the moon
    20 local ropeDestroyed = false -- for detecting if player roped to the moon
       
    21 local ropedToMoon = 0
    21 local checkPointReached = 1 -- 1 is start of the game
    22 local checkPointReached = 1 -- 1 is start of the game
    22 local objectives = loc("Go to the moon by using the flying saucer and complete the main mission").."|"..
    23 local objectives = loc("Go to the moon by using the flying saucer and complete the main mission").."|"..
    23 loc("Come back to this mission and visit the other planets to collect the crates").."|"..
    24 loc("Come back to this mission and visit the other planets to collect the crates").."|"..
    24 loc("Visit the Death Planet after completing all the other planets' main missions").."|"..
    25 loc("Visit the Death Planet after completing all the other planets' main missions").."|"..
    25 loc("Come back to this mission after collecting all the device parts")
    26 loc("Come back to this mission after collecting all the device parts")
    30 local dialog04 = {}
    31 local dialog04 = {}
    31 local dialog05 = {}
    32 local dialog05 = {}
    32 local dialog06 = {}
    33 local dialog06 = {}
    33 local dialog07 = {}
    34 local dialog07 = {}
    34 local dialog08 = {}
    35 local dialog08 = {}
       
    36 local dialog09 = {}
    35 -- mission objectives
    37 -- mission objectives
    36 local goals = {
    38 local goals = {
    37 	[dialog01] = {missionName, loc("Getting ready"), loc("Go and collect the crate").."|"..loc("Try not to get spotted by the guards!"), 1, 4500},
    39 	[dialog01] = {missionName, loc("Getting ready"), loc("Go and collect the crate").."|"..loc("Try not to get spotted by the guards!"), 1, 4500},
    38 	[dialog02] = {missionName, loc("The adventure begins!"), loc("Use the saucer and fly to the moon").."|"..loc("Travel carefully as your fuel is limited"), 1, 4500},
    40 	[dialog02] = {missionName, loc("The adventure begins!"), loc("Use the saucer and fly to the moon").."|"..loc("Travel carefully as your fuel is limited"), 1, 4500},
    39 	[dialog03] = {missionName, loc("An unexpected event!"), loc("Use the saucer and fly away").."|"..loc("Beware, any damage taken will stay until you complete the moon's main mission"), 1, 7000},
    41 	[dialog03] = {missionName, loc("An unexpected event!"), loc("Use the saucer and fly away").."|"..loc("Beware, any damage taken will stay until you complete the moon's main mission"), 1, 7000},
   263 end
   265 end
   264 
   266 
   265 local abandonCheck = false
   267 local abandonCheck = false
   266 
   268 
   267 function onNewTurn()
   269 function onNewTurn()
       
   270 	if ropedToMoon == 1 then
       
   271 		SetInputMask(0)
       
   272 		sendStatsOnRopedToMoon()
       
   273 		return
       
   274 	end
   268 	if saucerAcquired then
   275 	if saucerAcquired then
   269 		-- The only way for the player to have a saucer at turn start is by having used the rope
   276 		-- The only way for the player to have a saucer at turn start is by having used the rope
   270 		-- before; there's no other way to get it. We can therefore conclude the rope has been
   277 		-- before; there's no other way to get it. We can therefore conclude the rope has been
   271 		-- used.
   278 		-- used.
   272 		ropeDestroyed = true
   279 		ropeDestroyed = true
   384 end
   391 end
   385 
   392 
   386 -------------- ACTIONS ------------------
   393 -------------- ACTIONS ------------------
   387 
   394 
   388 function heroBeforeTreePosition(gear)
   395 function heroBeforeTreePosition(gear)
   389 	AnimSay(gear,loc("Now I have to climb these trees"), SAY_SAY, 4000)
   396 	if band(GetState(gear), gstHHDriven) ~= 0 then
   390 	AnimCaption(hero.gear, loc("Use the rope to get to the crate"),  4000)
   397 		AnimSay(gear,loc("Now I have to climb these trees"), SAY_SAY, 4000)
       
   398 		AnimCaption(hero.gear, loc("Use the rope to get to the crate"),  4000)
       
   399 	end
   391 end
   400 end
   392 
   401 
   393 function prepareDialog02(gear)
   402 function prepareDialog02(gear)
   394 	if StoppedGear(gear) and guard1.keepTurning and checkPointReached < 2 then
   403 	if StoppedGear(gear) and guard1.keepTurning and checkPointReached < 2 then
   395 		SetGearMessage(gear, 0)
   404 		SetGearMessage(gear, 0)
   428 	end
   437 	end
   429 end
   438 end
   430 
   439 
   431 function moonLanding(gear)
   440 function moonLanding(gear)
   432 	if checkPointReached == 1 and not ropeDestroyed then
   441 	if checkPointReached == 1 and not ropeDestroyed then
   433 		-- player climbed the moon with rope
   442 		-- Player climbed the moon with rope.
   434 		FollowGear(doctor.gear)
   443 		-- THIS IS A CRIMINAL OFFENSE AND WILL BE PUNISHED!
   435 		AnimSay(doctor.gear, loc("One does not simply rope to the moon!"), SAY_SHOUT, 4000)
   444 		ropedToMoon = 1
   436 		SendStat(siGameResult, loc("This is the wrong way!"))
   445 		SetGearVelocity(gear, 0, 0)
   437 		SendStat(siCustomAchievement, loc("Collect the crate with the flying saucer!"))
   446 		SetGearMessage(gear, 0)
   438 		SendStat(siCustomAchievement, loc("Fly to the moon."))
   447 		SetInputMask(0)
   439 		sendSimpleTeamRankings({teamC.name})
   448 		AddAnim(dialog09)
   440 		EndGame()
       
   441 	else
   449 	else
   442 		if checkPointReached ~= 5 then
   450 		if checkPointReached ~= 5 then
   443 			SaveCampaignVar("CosmosCheckPoint", "4")
   451 			SaveCampaignVar("CosmosCheckPoint", "4")
   444 			SaveCampaignVar("HeroHealth",GetHealth(hero.gear))
   452 			SaveCampaignVar("HeroHealth",GetHealth(hero.gear))
   445 		end
   453 		end
   450 		SaveCampaignVar("Mission1", "2")
   458 		SaveCampaignVar("Mission1", "2")
   451 		SaveCampaignVar("Mission2", "13")
   459 		SaveCampaignVar("Mission2", "13")
   452 		SaveCampaignVar("Mission3", "1")
   460 		SaveCampaignVar("Mission3", "1")
   453 		sendStats(loc("Hog Solo arrived at the moon!"))
   461 		sendStats(loc("Hog Solo arrived at the moon!"))
   454 	end
   462 	end
       
   463 end
       
   464 
       
   465 function punishHeroForRopingToMoon(gear)
       
   466 	-- Initiate the secret PAotH anti-rope defense system (5 bazookas dropped from sky)
       
   467 	AddGear(GetX(gear), 100, gtShell, 0, 0, 0, 0)
       
   468 	AddGear(GetX(gear), 0, gtShell, 0, 0, 0, 0)
       
   469 	AddGear(GetX(gear), -100, gtShell, 0, 0, 0, 0)
       
   470 	AddGear(GetX(gear), -200, gtShell, 0, 0, 0, 0)
       
   471 	AddGear(GetX(gear), -300, gtShell, 0, 0, 0, 0)
       
   472 	FollowGear(hero.gear)
       
   473 	SetInputMask(0)
   455 end
   474 end
   456 
   475 
   457 function fruitPlanetLanding(gear)
   476 function fruitPlanetLanding(gear)
   458 	if checkPointReached < 5 then
   477 	if checkPointReached < 5 then
   459 		AddAnim(dialog06)
   478 		AddAnim(dialog06)
   540 function noFuelAtLand(gear)
   559 function noFuelAtLand(gear)
   541 	AddAnim(dialog06)
   560 	AddAnim(dialog06)
   542 end
   561 end
   543 
   562 
   544 function heroDeath(gear)
   563 function heroDeath(gear)
   545 	sendStatsOnRetry()
   564 	if ropedToMoon == 1 then
       
   565 		sendStatsOnRopedToMoon()
       
   566 	elseif ropedToMoon == 0 then
       
   567 		sendStatsOnRetry()
       
   568 	end
   546 end
   569 end
   547 
   570 
   548 function setFoundDeviceVisual()
   571 function setFoundDeviceVisual()
   549 	--WriteLnToConsole("status: "..status.fruit01.." - "..status.fruit02)
   572 	--WriteLnToConsole("status: "..status.fruit01.." - "..status.fruit02)
   550 	if status.moon01 then
   573 	if status.moon01 then
   587 
   610 
   588 function Skipanim(anim)
   611 function Skipanim(anim)
   589 	if goals[anim] ~= nil then
   612 	if goals[anim] ~= nil then
   590 		ShowMission(unpack(goals[anim]))
   613 		ShowMission(unpack(goals[anim]))
   591 	end
   614 	end
   592 	if CurrentHedgehog ~= hero.gear and anim ~= dialog03 then
   615 	if anim == dialog09 then
       
   616 		SetInputMask(0)
       
   617 		-- Quick punishment for the impatient
       
   618 		AddGear(GetX(hero.gear)-1, GetY(hero.gear)+1, gtDynamite, 0, 0, 0, 1)
       
   619 		sendStatsOnRopedToMoon()
       
   620 	elseif anim == dialog05 or anim == dialog06 then
       
   621 		sendStatsOnStuckOnMoon()
       
   622 	elseif CurrentHedgehog ~= hero.gear and anim ~= dialog03 then
   593 		AnimSwitchHog(hero.gear)
   623 		AnimSwitchHog(hero.gear)
   594 	elseif anim == dialog03 then
   624 	elseif anim == dialog03 then
   595 		startCombat()
   625 		startCombat()
   596 	elseif anim == dialog05 or anim == dialog06 then
       
   597 		sendStatsOnStuckOnMoon()
       
   598 	end
   626 	end
   599 end
   627 end
   600 
   628 
   601 function AnimationSetup()
   629 function AnimationSetup()
   602 	-- DIALOG 01 - Start
   630 	-- DIALOG 01 - Start
   664 	table.insert(dialog08, {func = AnimSay, args = {doctor.gear, loc("We need it to get split into at least two parts."), SAY_SHOUT, 3000}})
   692 	table.insert(dialog08, {func = AnimSay, args = {doctor.gear, loc("We need it to get split into at least two parts."), SAY_SHOUT, 3000}})
   665 	table.insert(dialog08, {func = AnimSay, args = {doctor.gear, loc("PAotH has sent explosives but unfortunately the trigger mechanism seems to be faulty!"), SAY_SHOUT, 5000}})
   693 	table.insert(dialog08, {func = AnimSay, args = {doctor.gear, loc("PAotH has sent explosives but unfortunately the trigger mechanism seems to be faulty!"), SAY_SHOUT, 5000}})
   666 	table.insert(dialog08, {func = AnimSay, args = {doctor.gear, loc("We need you to go there and detonate them yourself! Good luck!"), SAY_SHOUT, 500}})
   694 	table.insert(dialog08, {func = AnimSay, args = {doctor.gear, loc("We need you to go there and detonate them yourself! Good luck!"), SAY_SHOUT, 500}})
   667 	table.insert(dialog08, {func = AnimWait, args = {doctor.gear, 3000}})
   695 	table.insert(dialog08, {func = AnimWait, args = {doctor.gear, 3000}})
   668 	table.insert(dialog08, {func = AnimSwitchHog, args = {hero.gear}})
   696 	table.insert(dialog08, {func = AnimSwitchHog, args = {hero.gear}})
   669 	table.insert(dialog08, {func = ShowMission, args = unpack(goals[dialog08])})
   697 	table.insert(dialog08, {func = ShowMission, args = goals[dialog08]})
       
   698 	-- DIALOG 09 - Hero roped to the moon (how naughty!)
       
   699 	AddSkipFunction(dialog09, Skipanim, {dialog09})
       
   700 	table.insert(dialog09, {func = AnimSay, args = {doctor.gear, loc("One does not simply rope to the moon!"), SAY_SHOUT, 4500}})
       
   701 	table.insert(dialog09, {func = punishHeroForRopingToMoon, args = {hero.gear}})
       
   702 	table.insert(dialog09, {func = AnimWait, args = {hero.gear, 5000}})
       
   703 	table.insert(dialog09, {func = sendStatsOnRopedToMoon, args = {hero.gear}})
   670 end
   704 end
   671 
   705 
   672 ------------------- custom "animation" functions --------------------------
   706 ------------------- custom "animation" functions --------------------------
   673 
   707 
   674 function startCombat()
   708 function startCombat()
   702 	SendStat(siGameResult, loc("You have to go back to the moon!"))
   736 	SendStat(siGameResult, loc("You have to go back to the moon!"))
   703 	SendStat(siCustomAchievement, loc("You have to complete the main mission on moon in order to travel to other planets."))
   737 	SendStat(siCustomAchievement, loc("You have to complete the main mission on moon in order to travel to other planets."))
   704 	sendSimpleTeamRankings({teamC.name})
   738 	sendSimpleTeamRankings({teamC.name})
   705 	EndGame()
   739 	EndGame()
   706 end
   740 end
       
   741 
       
   742 function sendStatsOnRopedToMoon()
       
   743 	if ropedToMoon ~= 2 then
       
   744 		ropedToMoon = 2
       
   745 		SendStat(siGameResult, loc("This is the wrong way!"))
       
   746 		SendStat(siCustomAchievement, loc("Collect the crate with the flying saucer!"))
       
   747 		SendStat(siCustomAchievement, loc("Fly to the moon."))
       
   748 		sendSimpleTeamRankings({teamC.name})
       
   749 		EndGame()
       
   750 	end
       
   751 end