share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua
changeset 12599 d8adae379d3c
parent 12592 0b27d8b4f8e7
child 12938 e65aa3c3d4e6
equal deleted inserted replaced
12595:b4b5484be651 12599:d8adae379d3c
    14 local missionName = loc("The big bang")
    14 local missionName = loc("The big bang")
    15 local challengeObjectives = loc("Find a way to detonate all the explosives and stay alive!").."|"..
    15 local challengeObjectives = loc("Find a way to detonate all the explosives and stay alive!").."|"..
    16 							loc("Red areas are indestructible.").."|"..
    16 							loc("Red areas are indestructible.").."|"..
    17 							loc("Green areas are portal-proof.").."|"..
    17 							loc("Green areas are portal-proof.").."|"..
    18 							loc("Mines time: 0 seconds")
    18 							loc("Mines time: 0 seconds")
       
    19 
       
    20 local dialog01 = {}
    19 local explosives = {}
    21 local explosives = {}
    20 local currentHealth = 1
    22 local currentHealth = 1
    21 local currentDamage = 0
    23 local currentDamage = 0
    22 -- hogs
    24 -- hogs
    23 local hero = {
    25 local hero = {
    86 	-- ammo
    88 	-- ammo
    87 	AddAmmo(hero.gear, amPortalGun, 1)
    89 	AddAmmo(hero.gear, amPortalGun, 1)
    88 	AddAmmo(hero.gear, amFirePunch, 1)
    90 	AddAmmo(hero.gear, amFirePunch, 1)
    89 
    91 
    90 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
    92 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
    91 	AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 0)
    93 	AddEvent(onBoom, {hero.gear}, heroBoomReaction, {hero.gear}, 0)
       
    94 	AnimationSetup()
    92 
    95 
    93 	SendHealthStatsOff()
    96 	SendHealthStatsOff()
    94 end
    97 end
    95 
    98 
    96 function onGameTick()
    99 function onGameTick()
   109 end
   112 end
   110 
   113 
   111 function onNewTurn()
   114 function onNewTurn()
   112 	currentDamage = 0
   115 	currentDamage = 0
   113 	currentHealth = GetHealth(hero.gear)
   116 	currentHealth = GetHealth(hero.gear)
       
   117 	if onBoom(hero.gear) then
       
   118 		heroWin(hero.gear)
       
   119 	end
   114 end
   120 end
   115 
   121 
   116 function onGearDamage(gear, damage)
   122 function onGearDamage(gear, damage)
   117 	if gear == hero.gear then
   123 	if gear == hero.gear then
   118 		currentDamage = currentDamage + damage
   124 		currentDamage = currentDamage + damage
   126 		return true
   132 		return true
   127 	end
   133 	end
   128 	return false
   134 	return false
   129 end
   135 end
   130 
   136 
   131 function onHeroWin(gear)
   137 function onBoom(gear)
   132 	local win = true
   138 	local win = true
   133 	for i=1,table.getn(explosives) do
   139 	for i=1,table.getn(explosives) do
   134 		if GetHealth(explosives[i]) then
   140 		if GetHealth(explosives[i]) then
   135 			win = false
   141 			win = false
   136 			break
   142 			break
   151 	SendStat(siCustomAchievement, loc("Green areas are portal-proof and repel portals."))
   157 	SendStat(siCustomAchievement, loc("Green areas are portal-proof and repel portals."))
   152 	sendSimpleTeamRankings({teamA.name})
   158 	sendSimpleTeamRankings({teamA.name})
   153 	EndGame()
   159 	EndGame()
   154 end
   160 end
   155 
   161 
       
   162 function heroBoomReaction(gear)
       
   163 	if GetHealth(gear) and GetHealth(gear) > 0 then
       
   164 		HogSay(gear, loc("Kaboom! Hahahaha! Take this, stupid meteorite!"), SAY_SHOUT, 2)
       
   165 	end
       
   166 end
       
   167 
   156 function heroWin(gear)
   168 function heroWin(gear)
       
   169 	AddAnim(dialog01)
       
   170 end
       
   171 
       
   172 function win()
       
   173 	SetWeapon(amNothing)
       
   174 	AnimSetInputMask(0)
   157 	saveCompletedStatus(7)
   175 	saveCompletedStatus(7)
   158 	SaveCampaignVar("Won", "true")
   176 	SaveCampaignVar("Won", "true")
   159 	checkAllMissionsCompleted()
   177 	checkAllMissionsCompleted()
   160 	SendStat(siGameResult, loc("Congratulations, you have saved Hogera!"))
   178 	SendStat(siGameResult, loc("Congratulations, you have saved Hogera!"))
   161 	SendStat(siCustomAchievement, loc("Hogera is safe!"))
   179 	SendStat(siCustomAchievement, loc("Hogera is safe!"))
   162 	sendSimpleTeamRankings({teamA.name})
   180 	sendSimpleTeamRankings({teamA.name})
   163 	EndGame()
   181 	EndGame()
   164 end
   182 end
       
   183 
       
   184 ------------ ANIMATION STUFF ------------
       
   185 
       
   186 function Skipanim(anim)
       
   187 	if anim == dialog01 then
       
   188 		win()
       
   189 	end
       
   190 end
       
   191 
       
   192 function onPrecise()
       
   193 	if GameTime > 3000 then
       
   194 		SetAnimSkip(true)
       
   195 	end
       
   196 end
       
   197 
       
   198 function AnimationSetup()
       
   199 	-- DIALOG 01 - Start, welcome to moon
       
   200 	AddSkipFunction(dialog01, Skipanim, {dialog01})
       
   201 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 100}})
       
   202 	table.insert(dialog01, {func = FollowGear, args = {hero.gear}})
       
   203 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Hooray! I actually did it! Hogera is safe!"), SAY_SHOUT, 3000}})
       
   204 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("I'm so glad this is finally over!"), SAY_SAY, 3000}})
       
   205 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 4000}})
       
   206 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Wait a moment …"), SAY_THINK, 2000}})
       
   207 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("If some good old explosives were enough to save Hogera …"), SAY_THINK, 5000}})
       
   208 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("… why did I risk my life to collect all the parts of the anti-gravity device?"), SAY_THINK, 6000}})
       
   209 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("It was completely useless!"), SAY_THINK, 3000}})
       
   210 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("We could just have blown up the meteorite from the the beginning!"), SAY_THINK, 5000}})
       
   211         -- Hogerian =  Inhabitant of the planet Hogera
       
   212 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Stupid, stupid Hogerians!"), SAY_SAY, 5000}})
       
   213 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Or maybe this was all part of an evil plan, so evil that even Prof. Hogevil can't think of it!"), SAY_THINK, 9000}})
       
   214 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Nah, probably everyone was just stupid."), SAY_THINK, 4000}})
       
   215 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Except me, of course! I just saved a whole planet!"), SAY_THINK, 5000}})
       
   216 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("But one thing's for sure:"), SAY_THINK, 4000}})
       
   217 	table.insert(dialog01, {func = AnimSay, args = {hero.gear, loc("Hogera is definitely the last planet I saved!"), SAY_THINK, 4000}})
       
   218 	table.insert(dialog01, {func = win, args = {hero.gear}})
       
   219 end
       
   220