share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua
branchspacecampaign
changeset 9441 00f07e32313a
parent 9438 77dde6234fec
child 9443 3fd77bcdd725
equal deleted inserted replaced
9438:77dde6234fec 9441:00f07e32313a
    19 -- globals
    19 -- globals
    20 local campaignName = loc("A Space Adventure")
    20 local campaignName = loc("A Space Adventure")
    21 local missionName = loc("Desert planet, lost in sand!")
    21 local missionName = loc("Desert planet, lost in sand!")
    22 local heroIsInBattle = false
    22 local heroIsInBattle = false
    23 local ongoingBattle = 0
    23 local ongoingBattle = 0
       
    24 local cratesFound = 0
    24 local checkPointReached = 1 -- 1 is normal spawn
    25 local checkPointReached = 1 -- 1 is normal spawn
    25 -- dialogs
    26 -- dialogs
    26 local dialog01 = {}
    27 local dialog01 = {}
    27 -- mission objectives
    28 -- mission objectives
    28 local goals = {
    29 local goals = {
    29 	[dialog01] = {missionName, loc("Getting ready"), loc("The part is hidden in one of the crates! Go and get it!"), 1, 4500},
    30 	[dialog01] = {missionName, loc("Getting ready"), loc("The part is hidden in one of the crates! Go and get it!"), 1, 4500},
    30 }
    31 }
    31 -- crates
    32 -- crates
    32 local btorch1Y = 60
    33 local btorch1Y = 60
    33 local btorch1X = 2700
    34 local btorch1X = 2700
    34 local btorch2Y = 1800
    35 local btorch2Y = 1900
    35 local btorch2X = 1010
    36 local btorch2X = 2150
    36 local btorch3Y = 980
    37 local btorch3Y = 980
    37 local btorch3X = 3260
    38 local btorch3X = 3260
    38 local rope1Y = 970
    39 local rope1Y = 970
    39 local rope1X = 3200
    40 local rope1X = 3200
    40 local rope2Y = 1900
    41 local rope2Y = 1900
    41 local rope2X = 680
    42 local rope2X = 680
    42 local rope3Y = 1850
    43 local rope3Y = 1850
    43 local rope3X = 2460
    44 local rope3X = 2460
    44 local portalY = 480
    45 local portalY = 480
    45 local portalX = 1465
    46 local portalX = 1465
    46 local constructY = 1630
    47 local girderY = 1630
    47 local constructX = 3350
    48 local girderX = 3350
    48 -- hogs
    49 -- hogs
    49 local hero = {}
    50 local hero = {}
    50 local ally = {}
    51 local ally = {}
    51 local smuggler1 = {}
    52 local smuggler1 = {}
    52 local smuggler2 = {}
    53 local smuggler2 = {}
   144 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   145 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   145 	AddEvent(onHeroAtFirstBattle, {hero.gear}, heroAtFirstBattle, {hero.gear}, 1)
   146 	AddEvent(onHeroAtFirstBattle, {hero.gear}, heroAtFirstBattle, {hero.gear}, 1)
   146 	AddEvent(onHeroFleeFirstBattle, {hero.gear}, heroFleeFirstBattle, {hero.gear}, 1)
   147 	AddEvent(onHeroFleeFirstBattle, {hero.gear}, heroFleeFirstBattle, {hero.gear}, 1)
   147 	AddEvent(onHeroAtCheckpoint4, {hero.gear}, heroAtCheckpoint4, {hero.gear}, 0)
   148 	AddEvent(onHeroAtCheckpoint4, {hero.gear}, heroAtCheckpoint4, {hero.gear}, 0)
   148 	AddEvent(onHeroAtThirdBattle, {hero.gear}, heroAtThirdBattle, {hero.gear}, 0)
   149 	AddEvent(onHeroAtThirdBattle, {hero.gear}, heroAtThirdBattle, {hero.gear}, 0)
       
   150 	AddEvent(onCheckForWin1, {hero.gear}, checkForWin1, {hero.gear}, 0)
       
   151 	AddEvent(onCheckForWin2, {hero.gear}, checkForWin2, {hero.gear}, 0)
   149 	
   152 	
   150 	-- smugglers ammo
   153 	-- smugglers ammo
   151 	AddAmmo(smuggler1.gear, amBazooka, 2)
   154 	AddAmmo(smuggler1.gear, amBazooka, 2)
   152 	AddAmmo(smuggler1.gear, amGrenade, 2)
   155 	AddAmmo(smuggler1.gear, amGrenade, 2)
   153 	AddAmmo(smuggler1.gear, amDEagle, 2)
   156 	AddAmmo(smuggler1.gear, amDEagle, 2)	
       
   157 	AddAmmo(smuggler3.gear, amRope, 2)
   154 	
   158 	
   155 	-- spawn crates	
   159 	-- spawn crates	
   156 	SpawnAmmoCrate(btorch1X, btorch1Y, amBlowTorch)
   160 	SpawnAmmoCrate(btorch1X, btorch1Y, amBlowTorch)
   157 	SpawnAmmoCrate(btorch2X, btorch2Y, amBlowTorch)
   161 	SpawnAmmoCrate(btorch2X, btorch2Y, amBlowTorch)
   158 	SpawnAmmoCrate(btorch3X, btorch3Y, amBlowTorch)
   162 	SpawnAmmoCrate(btorch3X, btorch3Y, amBlowTorch)
   159 	SpawnAmmoCrate(rope1X, rope1Y, amRope)
   163 	SpawnAmmoCrate(rope1X, rope1Y, amRope)
   160 	SpawnAmmoCrate(rope2X, rope2Y, amRope)
   164 	SpawnAmmoCrate(rope2X, rope2Y, amRope)
   161 	SpawnAmmoCrate(rope3X, rope3Y, amRope)
   165 	SpawnAmmoCrate(rope3X, rope3Y, amRope)
   162 	SpawnAmmoCrate(portalX, portalY, amPortalGun)
   166 	SpawnAmmoCrate(portalX, portalY, amPortalGun)	
   163 	SpawnAmmoCrate(constructX, constructY, amConstruction)
   167 	SpawnAmmoCrate(girderX, girderY, amGirder)
   164 	
   168 	
   165 	SpawnHealthCrate(3300, 970)
   169 	SpawnHealthCrate(3300, 970)
   166 	SpawnHealthCrate(680, 460)
   170 	SpawnHealthCrate(680, 460)
   167 	
   171 	
   168 	-- adding mines - BOOM!
   172 	-- adding mines - BOOM!
   181 	x = 1890
   185 	x = 1890
   182 	while x < 2988 do
   186 	while x < 2988 do
   183 		AddGear(x, 760, gtMine, 0, 0, 0, 0)
   187 		AddGear(x, 760, gtMine, 0, 0, 0, 0)
   184 		x = x + math.random(8,20)
   188 		x = x + math.random(8,20)
   185 	end
   189 	end
   186 	x = 2480
   190 	x = 2500
   187 	while x < 3300 do
   191 	while x < 3300 do
   188 		AddGear(x, 1450, gtMine, 0, 0, 0, 0)
   192 		AddGear(x, 1450, gtMine, 0, 0, 0, 0)
   189 		x = x + math.random(8,20)
   193 		x = x + math.random(8,20)
   190 	end
   194 	end
   191 	x = 1570
   195 	x = 1570
   192 	while x < 2900 do
   196 	while x < 2900 do
   193 		AddGear(x, 470, gtMine, 0, 0, 0, 0)
   197 		AddGear(x, 470, gtMine, 0, 0, 0, 0)
   194 		x = x + math.random(8,20)
   198 		x = x + math.random(8,20)
   195 	end
   199 	end
   196 	
   200 	
       
   201 	AddAmmo(hero.gear, amTeleport, 4)
   197 	if checkPointReached == 1 then	
   202 	if checkPointReached == 1 then	
   198 		AddEvent(onHeroAtCheckpoint2, {hero.gear}, heroAtCheckpoint2, {hero.gear}, 0)
   203 		AddEvent(onHeroAtCheckpoint2, {hero.gear}, heroAtCheckpoint2, {hero.gear}, 0)
   199 		AddEvent(onHeroAtCheckpoint3, {hero.gear}, heroAtCheckpoint3, {hero.gear}, 0)
   204 		AddEvent(onHeroAtCheckpoint3, {hero.gear}, heroAtCheckpoint3, {hero.gear}, 0)
   200 		-- hero ammo
   205 		-- hero ammo
   201 		AddAmmo(hero.gear, amRope, 2)
   206 		AddAmmo(hero.gear, amRope, 2)
   249 
   254 
   250 function onAmmoStoreInit()
   255 function onAmmoStoreInit()
   251 	SetAmmo(amBlowTorch, 0, 0, 0, 1)
   256 	SetAmmo(amBlowTorch, 0, 0, 0, 1)
   252 	SetAmmo(amRope, 0, 0, 0, 1)
   257 	SetAmmo(amRope, 0, 0, 0, 1)
   253 	SetAmmo(amPortalGun, 0, 0, 0, 1)	
   258 	SetAmmo(amPortalGun, 0, 0, 0, 1)	
   254 	SetAmmo(amConstruction, 0, 0, 0, 1)
   259 	SetAmmo(amGirder, 0, 0, 0, 3)
   255 end
   260 end
   256 
   261 
   257 function onGearDelete(gear)
   262 function onGearDelete(gear)
   258 	if gear == hero.gear then
   263 	if gear == hero.gear then
   259 		hero.dead = true
   264 		hero.dead = true
   320 end
   325 end
   321 
   326 
   322 function onHeroAtThirdBattle(gear)
   327 function onHeroAtThirdBattle(gear)
   323 	if not hero.dead and GetX(hero.gear) > 2000 and GetX(hero.gear) < 2200
   328 	if not hero.dead and GetX(hero.gear) > 2000 and GetX(hero.gear) < 2200
   324 			and GetY(hero.gear) > 1430 and GetY(hero.gear) < 1670 then
   329 			and GetY(hero.gear) > 1430 and GetY(hero.gear) < 1670 then
       
   330 		return true
       
   331 	end
       
   332 	return false
       
   333 end
       
   334 
       
   335 function onCheckForWin1(gear)
       
   336 	if not hero.dead and GetX(hero.gear) > btorch2X-30 and GetX(hero.gear) < btorch2X+30
       
   337 			and GetY(hero.gear) > btorch2Y-30 and GetY(hero.gear) < btorch2Y+30 then
       
   338 		return true
       
   339 	end
       
   340 	return false
       
   341 end
       
   342 
       
   343 function onCheckForWin2(gear)
       
   344 	if not hero.dead and GetX(hero.gear) > girderX-30 and GetX(hero.gear) < girderX+30
       
   345 			and GetY(hero.gear) > girderY-30 and GetY(hero.gear) < girderY+30 then
   325 		return true
   346 		return true
   326 	end
   347 	end
   327 	return false
   348 	return false
   328 end
   349 end
   329 
   350 
   373 	heroIsInBattle = true
   394 	heroIsInBattle = true
   374 	ongoingBattle = 3
   395 	ongoingBattle = 3
   375 	AnimSay(smuggler3.gear, loc("Who's there! I'll get you..."), SAY_SHOUT, 5000)	
   396 	AnimSay(smuggler3.gear, loc("Who's there! I'll get you..."), SAY_SHOUT, 5000)	
   376 	AnimSwitchHog(smuggler3.gear)
   397 	AnimSwitchHog(smuggler3.gear)
   377 	TurnTimeLeft = 0
   398 	TurnTimeLeft = 0
       
   399 end
       
   400 
       
   401 function checkForWin1(gear)
       
   402 	checkForWin()
       
   403 end
       
   404 
       
   405 function checkForWin2(gear)
       
   406 	checkForWin()
   378 end
   407 end
   379 
   408 
   380 -------------- ANIMATIONS ------------------
   409 -------------- ANIMATIONS ------------------
   381 
   410 
   382 function Skipanim(anim)
   411 function Skipanim(anim)
   446 	if tonumber(ammo:sub(7,7)) > 0 then
   475 	if tonumber(ammo:sub(7,7)) > 0 then
   447 		AddAmmo(hero.gear, amConstruction, tonumber(ammo:sub(7,7)))
   476 		AddAmmo(hero.gear, amConstruction, tonumber(ammo:sub(7,7)))
   448 	end
   477 	end
   449 	AddAmmo(hero.gear, amPortalGun, tonumber(ammo:sub(8,8)))
   478 	AddAmmo(hero.gear, amPortalGun, tonumber(ammo:sub(8,8)))
   450 end
   479 end
       
   480 
       
   481 function checkForWin()
       
   482 	if cratesFound ==  0 then
       
   483 		-- have to look more		
       
   484 		AnimSay(hero.gear, loc("Haven't found it yet..."), SAY_THINK, 5000)
       
   485 		cratesFound = cratesFound + 1
       
   486 	elseif cratesFound == 1 then
       
   487 		-- end game
       
   488 		AnimSay(hero.gear, loc("Hoo Ray!!!"), SAY_SHOUT, 5000)
       
   489 		-- do stats etc
       
   490 		EndGame()
       
   491 	end
       
   492 end