51 { x = 324, y = 1400}, |
51 { x = 324, y = 1400}, |
52 { x = 660, y = 1310}, |
52 { x = 660, y = 1310}, |
53 { x = 1200, y = 1310}, |
53 { x = 1200, y = 1310}, |
54 { x = 1700, y = 1310}, |
54 { x = 1700, y = 1310}, |
55 } |
55 } |
|
56 local targetsDead = {} |
56 local flameCounter = 0 |
57 local flameCounter = 0 |
57 |
58 |
58 -------------- LuaAPI EVENT HANDLERS ------------------ |
59 -------------- LuaAPI EVENT HANDLERS ------------------ |
59 |
60 |
60 function onGameInit() |
61 function onGameInit() |
133 |
134 |
134 function onGearDelete(gear) |
135 function onGearDelete(gear) |
135 if GetGearType(gear) == gtFlame then |
136 if GetGearType(gear) == gtFlame then |
136 flameCounter = flameCounter - 1 |
137 flameCounter = flameCounter - 1 |
137 end |
138 end |
|
139 for t=1, #targets do |
|
140 if gear == targets[t].gear then |
|
141 targetsDead[t] = true |
|
142 break |
|
143 end |
|
144 end |
138 end |
145 end |
139 |
146 |
140 -------------- EVENTS ------------------ |
147 -------------- EVENTS ------------------ |
141 |
148 |
142 function onHeroDeath(gear) |
149 function onHeroDeath(gear) |
186 |
193 |
187 ----------------- Other Functions ----------------- |
194 ----------------- Other Functions ----------------- |
188 |
195 |
189 function checkTargetsDestroyed() |
196 function checkTargetsDestroyed() |
190 if currentTarget == 1 then |
197 if currentTarget == 1 then |
191 if not GetHealth(targets[1].gear) then |
198 if targetsDead[1] then |
192 AddCaption(loc("Level 1 clear!")) |
199 AddCaption(loc("Level 1 clear!")) |
193 SetGearPosition(hero.gear, 3590, 90) |
200 SetGearPosition(hero.gear, 3590, 90) |
194 currentTarget = 2 |
201 currentTarget = 2 |
195 setTargets(currentTarget) |
202 setTargets(currentTarget) |
196 end |
203 end |
197 elseif currentTarget == 2 then |
204 elseif currentTarget == 2 then |
198 if not (GetHealth(targets[2].gear) or GetHealth(targets[3].gear)) then |
205 if targetsDead[2] and targetsDead[3] then |
199 AddCaption(loc("Level 2 clear!")) |
206 AddCaption(loc("Level 2 clear!")) |
200 SetGearPosition(hero.gear, 1110, 580) |
207 SetGearPosition(hero.gear, 1110, 580) |
201 currentTarget = 3 |
208 currentTarget = 3 |
202 setTargets(currentTarget) |
209 setTargets(currentTarget) |
203 end |
210 end |
204 elseif currentTarget == 3 then |
211 elseif currentTarget == 3 then |
205 |
212 local allDead = true |
206 else |
213 for t=3, #targets do |
207 win() |
214 if targetsDead[t] ~= true then |
|
215 allDead = false |
|
216 end |
|
217 end |
|
218 if allDead then |
|
219 currentTarget = 4 |
|
220 win() |
|
221 end |
208 end |
222 end |
209 end |
223 end |
210 |
224 |
211 function setTargets(ct) |
225 function setTargets(ct) |
212 if ct == 2 then |
226 if ct == 2 then |
222 end |
236 end |
223 end |
237 end |
224 end |
238 end |
225 |
239 |
226 function win() |
240 function win() |
|
241 AddCaption(loc("Victory!")) |
|
242 PlaySound(sndVictory, hero.gear) |
227 saveBonus(1, 1) |
243 saveBonus(1, 1) |
228 SendStat(siGameResult, loc("Congratulations, you are the best!")) |
244 SendStat(siGameResult, loc("Congratulations, you are the best!")) |
229 SendStat(siCustomAchievement, loc("You have destroyed all the targets.")) |
245 SendStat(siCustomAchievement, loc("You have destroyed all the targets.")) |
230 SendStat(siCustomAchievement, loc("You are indeed the best PAotH pilot.")) |
246 SendStat(siCustomAchievement, loc("You are indeed the best PAotH pilot.")) |
231 SendStat(siCustomAchievement, loc("Next time you play \"Searching in the dust\" you'll have an RC plane available.")) |
247 SendStat(siCustomAchievement, loc("Next time you play \"Searching in the dust\" you'll have an RC plane available.")) |