share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua
branchspacecampaign
changeset 9634 8032df67a249
parent 9632 9dd1c36d8b54
child 9642 8a691e0f117a
equal deleted inserted replaced
9633:ec72756e7079 9634:8032df67a249
    11 
    11 
    12 ----------------- VARIABLES --------------------
    12 ----------------- VARIABLES --------------------
    13 -- globals
    13 -- globals
    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 
    16 local explosives = {}
       
    17 local currentHealth = 1
       
    18 local currentDamage = 0
    17 -- hogs
    19 -- hogs
    18 local hero = {
    20 local hero = {
    19 	name = loc("Hog Solo"),
    21 	name = loc("Hog Solo"),
    20 	x = 790,
    22 	x = 790,
    21 	y = 70
    23 	y = 70
    46 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
    48 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
    47 	
    49 	
    48 	initCheckpoint("final")
    50 	initCheckpoint("final")
    49 	
    51 	
    50 	AnimInit()
    52 	AnimInit()
    51 	--AnimationSetup()
       
    52 end
    53 end
    53 
    54 
    54 function onGameStart()
    55 function onGameStart()
    55 	AnimWait(hero.gear, 3000)
    56 	AnimWait(hero.gear, 3000)
    56 	FollowGear(hero.gear)
    57 	FollowGear(hero.gear)
    57 	ShowMission(missionName, loc("Challenge Objectives"), challengeObjectives, -amSkip, 0)
    58 	ShowMission(missionName, loc("Challenge Objectives"), challengeObjectives, -amSkip, 0)
    58 	
    59 	
    59 	-- explosives
    60 	-- explosives
    60 	x = 400
    61 	x = 400
    61 	while x < 815 do
    62 	while x < 815 do
    62 		AddGear(x, 500, gtExplosives, 0, 0, 0, 0)
    63 		local gear = AddGear(x, 500, gtExplosives, 0, 0, 0, 0)
    63 		x = x + math.random(15,40)
    64 		x = x + math.random(15,40)
       
    65 		table.insert(explosives, gear)
    64 	end
    66 	end
    65 	-- mines
    67 	-- mines
    66 	local x = 360
    68 	local x = 360
    67 	while x < 815 do
    69 	while x < 815 do
    68 		AddGear(x, 480, gtMine, 0, 0, 0, 0)
    70 		AddGear(x, 480, gtMine, 0, 0, 0, 0)
    75 	SpawnAmmoCrate(1220, 672,amPickHammer)
    77 	SpawnAmmoCrate(1220, 672,amPickHammer)
    76 	SpawnAmmoCrate(1220, 672,amGirder)
    78 	SpawnAmmoCrate(1220, 672,amGirder)
    77 	
    79 	
    78 	-- ammo
    80 	-- ammo
    79 	AddAmmo(hero.gear, amPortalGun, 1)	
    81 	AddAmmo(hero.gear, amPortalGun, 1)	
    80 	AddAmmo(hero.gear, amFirePunch, 1)	
    82 	AddAmmo(hero.gear, amFirePunch, 1)
       
    83 	
       
    84 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
       
    85 	AddEvent(onHeroWin, {hero.gear}, heroWin, {hero.gear}, 0)
    81 	
    86 	
    82 	SendHealthStatsOff()
    87 	SendHealthStatsOff()
       
    88 end
       
    89 
       
    90 function onGameTick()
       
    91 	AnimUnWait()
       
    92 	if ShowAnimation() == false then
       
    93 		return
       
    94 	end
       
    95 	ExecuteAfterAnimations()
       
    96 	CheckEvents()
    83 end
    97 end
    84 
    98 
    85 function onAmmoStoreInit()
    99 function onAmmoStoreInit()
    86 	SetAmmo(amRCPlane, 0, 0, 0, 1)
   100 	SetAmmo(amRCPlane, 0, 0, 0, 1)
    87 	SetAmmo(amPickHammer, 0, 0, 0, 2)
   101 	SetAmmo(amPickHammer, 0, 0, 0, 2)
    88 	SetAmmo(amGirder, 0, 0, 0, 1)
   102 	SetAmmo(amGirder, 0, 0, 0, 1)
    89 end
   103 end
       
   104 
       
   105 function onNewTurn()
       
   106 	currentDamage = 0
       
   107 	currentHealth = GetHealth(hero.gear)
       
   108 end
       
   109 
       
   110 function onGearDamage(gear, damage)
       
   111 	if gear == hero.gear then
       
   112 		currentDamage = currentDamage + damage
       
   113 	end
       
   114 end
       
   115 
       
   116 -------------- EVENTS ------------------
       
   117 
       
   118 function onHeroDeath(gear)
       
   119 	if not GetHealth(hero.gear) then
       
   120 		return true
       
   121 	end
       
   122 	return false
       
   123 end
       
   124 
       
   125 function onHeroWin(gear)
       
   126 	local win = true
       
   127 	for i=1,table.getn(explosives) do
       
   128 		if GetHealth(explosives[i]) then
       
   129 			win = false
       
   130 			break
       
   131 		end
       
   132 	end
       
   133 	if currentHealth <= currentDamage then
       
   134 		win = false
       
   135 	end
       
   136 	return win
       
   137 end
       
   138 
       
   139 -------------- ACTIONS ------------------
       
   140 
       
   141 function heroDeath(gear)
       
   142 	SendStat('siGameResult', loc("Hog Solo lost, try again!")) --1
       
   143 	SendStat('siCustomAchievement', loc("You have to destroy all the explosives without dying!")) --11
       
   144 	SendStat('siPlayerKills','0',teamA.name)
       
   145 	EndGame()
       
   146 end
       
   147 
       
   148 function heroWin(gear)
       
   149 	SendStat('siGameResult', loc("Congratulations, you have saved Hogera!")) --1
       
   150 	SendStat('siCustomAchievement', loc("Hogera is safe!")) --11
       
   151 	SendStat('siPlayerKills','1',teamA.name)
       
   152 	EndGame()
       
   153 end