share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua
branchspacecampaign
changeset 9606 1d088cc31ff8
parent 9605 66cd14e5bdad
child 9608 e2d4c2198e55
equal deleted inserted replaced
9605:66cd14e5bdad 9606:1d088cc31ff8
    27 }
    27 }
    28 -- creates & targets
    28 -- creates & targets
    29 local rcCrates = {
    29 local rcCrates = {
    30 	{ x = 1680, y = 240},
    30 	{ x = 1680, y = 240},
    31 	{ x = 2810, y = 720},
    31 	{ x = 2810, y = 720},
       
    32 	{ x = 2440, y = 660},
       
    33 	{ x = 256, y = 1090},
    32 }
    34 }
    33 local targets = {
    35 local targets = {
    34 	{ x = 2070, y = 410},
    36 	{ x = 2070, y = 410},
    35 	{ x = 3880, y = 1430},
    37 	{ x = 3880, y = 1430},
    36 	{ x = 4030, y = 1430},
    38 	{ x = 4000, y = 1430},
       
    39 	{ x = 2190, y = 1160},
       
    40 	{ x = 2190, y = 1460},
       
    41 	{ x = 2110, y = 1700},
       
    42 	{ x = 2260, y = 1700},
       
    43 	{ x = 2085, y = 1330},
       
    44 	{ x = 156, y = 1400},
       
    45 	{ x = 324, y = 1400},
       
    46 	{ x = 660, y = 1310},
       
    47 	{ x = 1200, y = 1310},
       
    48 	{ x = 1700, y = 1310},
    37 }
    49 }
    38 
    50 
    39 -------------- LuaAPI EVENT HANDLERS ------------------
    51 -------------- LuaAPI EVENT HANDLERS ------------------
    40 
    52 
    41 function onGameInit()
    53 function onGameInit()
    49 	Map = "desert03_map"
    61 	Map = "desert03_map"
    50 	Theme = "Desert"
    62 	Theme = "Desert"
    51 	
    63 	
    52 	-- Hog Solo
    64 	-- Hog Solo
    53 	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
    65 	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
    54 	hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1")
    66 	hero.gear = AddHog(hero.name, 0, 1, "war_desertgrenadier1")
    55 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
    67 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
    56 	
    68 	
    57 	initCheckpoint("desert03")
    69 	initCheckpoint("desert03")
    58 	
    70 	
    59 	AnimInit()
    71 	AnimInit()
    64 	AnimWait(hero.gear, 3000)
    76 	AnimWait(hero.gear, 3000)
    65 	FollowGear(hero.gear)
    77 	FollowGear(hero.gear)
    66 	ShowMission(missionName, loc("Challenge Objectives"), challengeObjectives, -amSkip, 0)
    78 	ShowMission(missionName, loc("Challenge Objectives"), challengeObjectives, -amSkip, 0)
    67 
    79 
    68 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
    80 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
       
    81 	AddEvent(onLose, {hero.gear}, lose, {hero.gear}, 0)
    69 
    82 
    70 	-- original crates and targets
    83 	-- original crates and targets
    71 	SpawnAmmoCrate(rcCrates[1].x, rcCrates[1].y, amRCPlane)
    84 	SpawnAmmoCrate(rcCrates[1].x, rcCrates[1].y, amRCPlane)
    72 	targets[1].gear = AddGear(targets[1].x, targets[1].y, gtTarget, 0, 0, 0, 0)
    85 	targets[1].gear = AddGear(targets[1].x, targets[1].y, gtTarget, 0, 0, 0, 0)
    73 	
    86 	
    75 	AddAmmo(hero.gear, amRCPlane, 1)
    88 	AddAmmo(hero.gear, amRCPlane, 1)
    76 
    89 
    77 	SendHealthStatsOff()
    90 	SendHealthStatsOff()
    78 end
    91 end
    79 
    92 
       
    93 function onGameTick()
       
    94 	AnimUnWait()
       
    95 	if ShowAnimation() == false then
       
    96 		return
       
    97 	end
       
    98 	ExecuteAfterAnimations()
       
    99 	CheckEvents()
       
   100 end
       
   101 
    80 function onGameTick20()
   102 function onGameTick20()
    81 	checkTargetsDestroied()
   103 	checkTargetsDestroied()
    82 end
   104 end
    83 
   105 
    84 function onAmmoStoreInit()
   106 function onAmmoStoreInit()
    85 	if currentTarget == 1 then
   107 	SetAmmo(amNothing, 0, 0, 0, 0)
    86 		SetAmmo(amRCPlane, 0, 0, 0, 1)
   108 	SetAmmo(amRCPlane, 0, 0, 0, 1)
       
   109 end
       
   110 
       
   111 function onPrecise()
       
   112 	if GameTime > 3000 then
       
   113 		SetAnimSkip(true)   
    87 	end
   114 	end
    88 end
   115 end
    89 
   116 
    90 -------------- EVENTS ------------------
   117 -------------- EVENTS ------------------
    91 
   118 
    94 		return true
   121 		return true
    95 	end
   122 	end
    96 	return false
   123 	return false
    97 end
   124 end
    98 
   125 
       
   126 function onLose(gear)
       
   127 	if GetHealth(hero.gear) and currentTarget < 4 and GetAmmoCount(hero.gear, amRCPlane) == 0 then
       
   128 		return true
       
   129 	end
       
   130 	return false
       
   131 end
       
   132 
    99 -------------- ACTIONS ------------------
   133 -------------- ACTIONS ------------------
   100 
   134 
   101 function heroDeath(gear)
   135 function heroDeath(gear)
   102 	SendStat('siGameResult', loc("Hog Solo lost, try again!")) --1
   136 	gameOver()
   103 	SendStat('siCustomAchievement', loc("You have to destroy all the targets")) --11			
   137 end
   104 	SendStat('siCustomAchievement', loc("Read the Challenge Objectives from within the mission for more details")) --11		
   138 
   105 	SendStat('siPlayerKills','1',teamB.name)
   139 function lose(gear)
   106 	SendStat('siPlayerKills','0',teamA.name)
   140 	gameOver()
   107 	EndGame()
       
   108 end
   141 end
   109 
   142 
   110 ----------------- Other Functions -----------------
   143 ----------------- Other Functions -----------------
   111 
   144 
   112 function checkTargetsDestroied()
   145 function checkTargetsDestroied()
   116 			SetGearPosition(hero.gear, 3590, 90)
   149 			SetGearPosition(hero.gear, 3590, 90)
   117 			currentTarget = 2
   150 			currentTarget = 2
   118 			setTargets(currentTarget)
   151 			setTargets(currentTarget)
   119 		end
   152 		end
   120 	elseif currentTarget == 2 then
   153 	elseif currentTarget == 2 then
       
   154 		if not (GetHealth(targets[2].gear) or GetHealth(targets[3].gear))  then
       
   155 			AddCaption(loc("Level 2 clear!"))
       
   156 			SetGearPosition(hero.gear, 1110, 580)
       
   157 			currentTarget = 3
       
   158 			setTargets(currentTarget)
       
   159 		end
       
   160 	elseif currentTarget == 3 then
   121 		
   161 		
   122 	else
   162 	else
   123 		win()
   163 		win()
   124 	end
   164 	end
   125 end
   165 end
   128 	if ct == 2 then
   168 	if ct == 2 then
   129 		SpawnAmmoCrate(rcCrates[2].x, rcCrates[2].y, amRCPlane)
   169 		SpawnAmmoCrate(rcCrates[2].x, rcCrates[2].y, amRCPlane)
   130 		for i=2,3 do
   170 		for i=2,3 do
   131 			targets[i].gear = AddGear(targets[i].x, targets[i].y, gtTarget, 0, 0, 0, 0)
   171 			targets[i].gear = AddGear(targets[i].x, targets[i].y, gtTarget, 0, 0, 0, 0)
   132 		end
   172 		end
       
   173 	elseif ct == 3 then
       
   174 		SpawnAmmoCrate(rcCrates[3].x, rcCrates[3].y, amRCPlane)
       
   175 		SpawnAmmoCrate(rcCrates[3].x, rcCrates[3].y, amRCPlane)
       
   176 		SpawnAmmoCrate(rcCrates[4].x, rcCrates[4].y, amNothing)
       
   177 		for i=4,13 do
       
   178 			targets[i].gear = AddGear(targets[i].x, targets[i].y, gtTarget, 0, 0, 0, 0)
       
   179 		end
   133 	end
   180 	end
   134 end
   181 end
   135 
   182 
   136 function win()
   183 function win()
   137 	EndGame()
   184 	EndGame()
   138 end
   185 end
       
   186 
       
   187 function gameOver()
       
   188 	SendStat('siGameResult', loc("Hog Solo lost, try again!")) --1
       
   189 	SendStat('siCustomAchievement', loc("You have to destroy all the targets")) --11		
       
   190 	SendStat('siCustomAchievement', loc("You will fail if you run out of ammo and there are still targets available")) --11		
       
   191 	SendStat('siCustomAchievement', loc("Read the Challenge Objectives from within the mission for more details")) --11		
       
   192 	SendStat('siPlayerKills','0',teamA.name)
       
   193 	EndGame()
       
   194 end