share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua
branchspacecampaign
changeset 9432 6b1c42e10957
parent 9430 ab809b0be800
child 9434 b472a2f7b65b
equal deleted inserted replaced
9430:ab809b0be800 9432:6b1c42e10957
   122 	if checkPointReached == 1 then
   122 	if checkPointReached == 1 then
   123 		-- Start of the game
   123 		-- Start of the game
   124 	elseif checkPointReached == 2 then
   124 	elseif checkPointReached == 2 then
   125 		AnimSetGearPosition(hero.gear, 1050, 615)
   125 		AnimSetGearPosition(hero.gear, 1050, 615)
   126 		HogTurnLeft(hero.gear, true)
   126 		HogTurnLeft(hero.gear, true)
       
   127 	elseif checkPointReached == 3 then
       
   128 		AnimSetGearPosition(hero.gear, 1680, 920)
       
   129 		HogTurnLeft(hero.gear, true)
   127 	end
   130 	end
   128 	
   131 	
   129 	AnimInit()
   132 	AnimInit()
   130 	AnimationSetup()	
   133 	AnimationSetup()	
   131 end
   134 end
   136 	
   139 	
   137 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   140 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   138 	AddEvent(onHeroAtFirstBattle, {hero.gear}, heroAtFirstBattle, {hero.gear}, 1)
   141 	AddEvent(onHeroAtFirstBattle, {hero.gear}, heroAtFirstBattle, {hero.gear}, 1)
   139 	AddEvent(onHeroFleeFirstBattle, {hero.gear}, heroFleeFirstBattle, {hero.gear}, 1)
   142 	AddEvent(onHeroFleeFirstBattle, {hero.gear}, heroFleeFirstBattle, {hero.gear}, 1)
   140 	AddEvent(onHeroAtCheckpoint2, {hero.gear}, heroAtCheckpoint2, {hero.gear}, 0)
   143 	AddEvent(onHeroAtCheckpoint2, {hero.gear}, heroAtCheckpoint2, {hero.gear}, 0)
       
   144 	AddEvent(onHeroAtCheckpoint3, {hero.gear}, heroAtCheckpoint3, {hero.gear}, 0)
   141 	
   145 	
   142 	-- smugglers ammo
   146 	-- smugglers ammo
   143 	AddAmmo(smuggler1.gear, amBazooka, 2)
   147 	AddAmmo(smuggler1.gear, amBazooka, 2)
   144 	AddAmmo(smuggler1.gear, amGrenade, 2)
   148 	AddAmmo(smuggler1.gear, amGrenade, 2)
   145 	AddAmmo(smuggler1.gear, amDEagle, 2)
   149 	AddAmmo(smuggler1.gear, amDEagle, 2)
   164 	AddGear(3500, 240, gtMine, 0, 0, 0, 0)
   168 	AddGear(3500, 240, gtMine, 0, 0, 0, 0)
   165 	AddGear(3410, 670, gtMine, 0, 0, 0, 0)
   169 	AddGear(3410, 670, gtMine, 0, 0, 0, 0)
   166 	AddGear(3450, 720, gtMine, 0, 0, 0, 0)
   170 	AddGear(3450, 720, gtMine, 0, 0, 0, 0)
   167 	
   171 	
   168 	local x = 800
   172 	local x = 800
   169 	while x < 1650 do
   173 	while x < 1630 do
   170 		AddGear(x, 900, gtMine, 0, 0, 0, 0)
   174 		AddGear(x, 900, gtMine, 0, 0, 0, 0)
   171 		x = x + math.random(8,20)
   175 		x = x + math.random(8,20)
   172 	end
   176 	end
   173 	x = 1890
   177 	x = 1890
   174 	while x < 2988 do
   178 	while x < 2988 do
   193 		AddAmmo(hero.gear, amParachute, 1)
   197 		AddAmmo(hero.gear, amParachute, 1)
   194 		AddAmmo(hero.gear, amGrenade, 6)
   198 		AddAmmo(hero.gear, amGrenade, 6)
   195 		AddAmmo(hero.gear, amDEagle, 4)
   199 		AddAmmo(hero.gear, amDEagle, 4)
   196 	
   200 	
   197 		AddAnim(dialog01)
   201 		AddAnim(dialog01)
   198 	elseif checkPointReached == 2 then
   202 	elseif checkPointReached == 2 or checkPointReached == 3 then
   199 		ShowMission(campaignName, missionName, loc("The part is hidden in one of the crates! Go and get it!"), -amSkip, 0)
   203 		ShowMission(campaignName, missionName, loc("The part is hidden in one of the crates! Go and get it!"), -amSkip, 0)
   200 		-- hero ammo
   204 		-- hero ammo
   201 		local ammo = GetCampaignVar("HeroAmmo")
   205 		local ammo = GetCampaignVar("HeroAmmo")
   202 		AddAmmo(hero.gear, amRope, tonumber(ammo:sub(3,3)))
   206 		AddAmmo(hero.gear, amRope, tonumber(ammo:sub(3,3)))
   203 		AddAmmo(hero.gear, amBazooka, tonumber(ammo:sub(1,1)))
   207 		AddAmmo(hero.gear, amBazooka, tonumber(ammo:sub(1,1)))
   209 		if tonumber(ammo:sub(7,7)) > 0 then
   213 		if tonumber(ammo:sub(7,7)) > 0 then
   210 			AddAmmo(hero.gear, amConstruction, tonumber(ammo:sub(7,7)))
   214 			AddAmmo(hero.gear, amConstruction, tonumber(ammo:sub(7,7)))
   211 		end
   215 		end
   212 		AddAmmo(hero.gear, amPortalGun, tonumber(ammo:sub(8,8)))
   216 		AddAmmo(hero.gear, amPortalGun, tonumber(ammo:sub(8,8)))
   213 		
   217 		
   214 		-- second battle
   218 		secondBattle()
   215 		heroIsInBattle = true
       
   216 		ongoingBattle = 2
       
   217 	end
   219 	end
   218 	
   220 	
   219 	SendHealthStatsOff()
   221 	SendHealthStatsOff()
   220 end
   222 end
   221 
   223 
   293 end
   295 end
   294 
   296 
   295 -- saves the location of the hero and prompts him for the second battle
   297 -- saves the location of the hero and prompts him for the second battle
   296 function onHeroAtCheckpoint2(gear)
   298 function onHeroAtCheckpoint2(gear)
   297 	if not hero.dead and GetX(hero.gear) > 1000 and GetX(hero.gear) < 1100
   299 	if not hero.dead and GetX(hero.gear) > 1000 and GetX(hero.gear) < 1100
   298 			and GetY(hero.gear) > 590 then
   300 			and GetY(hero.gear) > 590 and GetY(hero.gear) < 700 then
       
   301 		return true
       
   302 	end
       
   303 	return false
       
   304 end
       
   305 
       
   306 function onHeroAtCheckpoint3(gear)
       
   307 	if not hero.dead and GetX(hero.gear) > 1610 and GetX(hero.gear) < 1680
       
   308 			and GetY(hero.gear) > 850 and GetY(hero.gear) < 1000 then
   299 		return true
   309 		return true
   300 	end
   310 	end
   301 	return false
   311 	return false
   302 end
   312 end
   303 
   313 
   339 	SaveCampaignVar("HeroAmmo", GetAmmoCount(hero.gear, amBazooka)..GetAmmoCount(hero.gear, amGrenade)..
   349 	SaveCampaignVar("HeroAmmo", GetAmmoCount(hero.gear, amBazooka)..GetAmmoCount(hero.gear, amGrenade)..
   340 			GetAmmoCount(hero.gear, amRope)..GetAmmoCount(hero.gear, amParachute)..GetAmmoCount(hero.gear, amDEagle)..
   350 			GetAmmoCount(hero.gear, amRope)..GetAmmoCount(hero.gear, amParachute)..GetAmmoCount(hero.gear, amDEagle)..
   341 			GetAmmoCount(hero.gear, amBlowTorch)..GetAmmoCount(hero.gear, amConstruction)..GetAmmoCount(hero.gear, amPortalGun))
   351 			GetAmmoCount(hero.gear, amBlowTorch)..GetAmmoCount(hero.gear, amConstruction)..GetAmmoCount(hero.gear, amPortalGun))
   342 	AnimCaption(hero.gear, loc("Checkpoint reached!"), 5000)
   352 	AnimCaption(hero.gear, loc("Checkpoint reached!"), 5000)
   343 	
   353 	
   344 	-- second battle
   354 	secondBattle()
   345 	heroIsInBattle = true
   355 end
   346 	ongoingBattle = 2
   356 
   347 	AnimSay(smuggler2.gear, loc("This is seems like a wealthy hedgehog, nice..."), SAY_THINK, 5000)
   357 function heroAtCheckpoint3(gear)
       
   358 	-- save checkpoint
       
   359 	SaveCampaignVar("Desert01CheckPoint", "3")	
       
   360 	SaveCampaignVar("HeroHealth", GetHealth(hero.gear))
       
   361 	-- bazooka - grenade - rope - parachute - deagle - btorch - construct - portal
       
   362 	SaveCampaignVar("HeroAmmo", GetAmmoCount(hero.gear, amBazooka)..GetAmmoCount(hero.gear, amGrenade)..
       
   363 			GetAmmoCount(hero.gear, amRope)..GetAmmoCount(hero.gear, amParachute)..GetAmmoCount(hero.gear, amDEagle)..
       
   364 			GetAmmoCount(hero.gear, amBlowTorch)..GetAmmoCount(hero.gear, amConstruction)..GetAmmoCount(hero.gear, amPortalGun))
       
   365 	AnimCaption(hero.gear, loc("Checkpoint reached!"), 5000)
       
   366 	
       
   367 	secondBattle()
   348 end
   368 end
   349 
   369 
   350 -------------- ANIMATIONS ------------------
   370 -------------- ANIMATIONS ------------------
   351 
   371 
   352 function Skipanim(anim)
   372 function Skipanim(anim)
   378 	table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("There is the tunnel entrance"), SAY_SAY, 3000}})
   398 	table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("There is the tunnel entrance"), SAY_SAY, 3000}})
   379 	table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("Good luck!"), SAY_SAY, 3000}})
   399 	table.insert(dialog01, {func = AnimSay, args = {ally.gear, loc("Good luck!"), SAY_SAY, 3000}})
   380 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}})
   400 	table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}})
   381 	table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}})	
   401 	table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}})	
   382 end
   402 end
       
   403 
       
   404 --------------- OTHER FUNCTIONS ------------------
       
   405 
       
   406 function secondBattle()
       
   407 	-- second battle
       
   408 	heroIsInBattle = true
       
   409 	ongoingBattle = 2
       
   410 	AnimSay(smuggler2.gear, loc("This is seems like a wealthy hedgehog, nice..."), SAY_THINK, 5000)	
       
   411 	AnimSwitchHog(smuggler2.gear)
       
   412 	TurnTimeLeft = 0
       
   413 end