| 1 |
--[[ |
| 2 |
<?xml version='1.0' encoding='utf8'?> |
| 3 |
<mission name="The one with the Runaway"> |
| 4 |
<flags> |
| 5 |
<unique /> |
| 6 |
</flags> |
| 7 |
<avail> |
| 8 |
<priority>4</priority> |
| 9 |
<done>The one with the Visit</done> |
| 10 |
<chance>100</chance> |
| 11 |
<location>Bar</location> |
| 12 |
<planet>Gastan</planet> |
| 13 |
</avail> |
| 14 |
</mission> |
| 15 |
--]] |
| 16 |
--[[ |
| 17 |
Mission: The one with the Runaway |
| 18 |
Description: A prototype drone runs away and needs to be caught by the player |
| 19 |
How to make this more interesting than just go to a system and shoot down the drone w ion or medusa? The ship has to have enough cargo for the drone to be transported back. |
| 20 |
So the player has to hail the drone bc the scientist wants to patch the software which fails and the drone causes other drones to attack. |
| 21 |
I was thinking of player having to use electronic warfare. But is there a way to check that? |
| 22 |
Difficulty: relatively easy? |
| 23 |
|
| 24 |
Author: fart but based on Mission Ideas in wiki: wiki.naev.org/wiki/Mission_Ideas |
| 25 |
--]] |
| 26 |
|
| 27 |
require "fleethelper.lua" |
| 28 |
require "missions/zalek/common.lua" |
| 29 |
|
| 30 |
|
| 31 |
-- set text variables |
| 32 |
title = {} |
| 33 |
text = {} |
| 34 |
osd_msg = {} |
| 35 |
-- system with the drone and the return to start |
| 36 |
t_sys = {} |
| 37 |
t_pla = {} |
| 38 |
-- Mission details |
| 39 |
reward = 2000000 |
| 40 |
-- amount of jumps the drone did to escape. Each jump reduces it's speed |
| 41 |
fled = false |
| 42 |
jumps = 0 |
| 43 |
t_sys[1] = "Xavier" |
| 44 |
t_pla[1] = system.get(t_sys[1]):planets()[1] |
| 45 |
t_sys[2] = "Seiben" |
| 46 |
t_pla[2] = "Gastan" |
| 47 |
misn_title = _("The one with the Runaway") |
| 48 |
misn_reward = _("A peek at the new prototype and some compensation for your efforts") |
| 49 |
misn_desc = _("You've been hired by Dr. Geller to retrieve his prototype that ran away.") |
| 50 |
bar_desc = _("You see Dr. Geller going from one person to the next, seemingly asking for something.") |
| 51 |
|
| 52 |
title[1] = _([[In the bar]]) |
| 53 |
title[2] = _([[On the intercom]]) |
| 54 |
title[3] = _([[On your ship]]) |
| 55 |
title[4] = _([[Back on %s]]) |
| 56 |
text[1] = _([["Hey there again! I need your help. I was finishing up my prototype, you see. It's ingenious. But you see, there was a minor hiccup. It's nothing major, it is just, well, that I lost it. But I would not be Dr. Geller if I had not put a tracking mechanism into it! So I want you to catch it and bring it back, OK? You can do that, right?"]]) |
| 57 |
text[2] = _([["Excellent! I will join you this time. Let's go."]]) |
| 58 |
text[3] = _([["There! The tracker shows it must be here! It is right next to %s! If you hail it I might be able to patch the software. That should give me control again. But you have to be close so the data transfer is as stable as possible."]]) |
| 59 |
text[4] = _([["Huh, I don't understand. This should not be happening. Hold on. I can't get access."]]) |
| 60 |
text[5] = _([["Um, there seems to be a glitch. Well, sort of. Um, if I deciphered this correctly, the drone just hijacked the unused drones on %s and ordered them to attack us. I never should have tampered with that weird chip those pirates sold me!"]]) |
| 61 |
text[6] = _([["If you can disable the prototype, do it, but I'd prefer not to die at any rate!"]]) |
| 62 |
text[7] = _([["Excellent work! Now load it up and let's get out of here!"]]) |
| 63 |
text[8] = _([["Interesting, the other drones are running away..."]]) |
| 64 |
-- is that the way to go? get person to jump and try again? that sounds a bit annoying maybe to play through |
| 65 |
text[9] = _([["The drone has disappeared from my radar! It must have jumped to the %s system. Let's find it!"]]) |
| 66 |
text[10] = _([["The scanner shows me that the drone has slowed down. It must have lost power. Go! Go! It should now be much easier to catch it!"]]) |
| 67 |
|
| 68 |
text[11] = _([["It seems the drone has found a way to shield itself from the EM pulses. I think I can adjust to that, give me a second."]]) |
| 69 |
text[12] = _([["There you go! Get it!"]]) |
| 70 |
text[13] = _([["This is strange, the engines are starting to heat up... oh, shit, if they continue like this the drone will explode in about 20 seconds! You'd better hurry!"]]) |
| 71 |
text[14] = _([["NOOOOOOOOO! My drone! You imbecile! You failed me!"]]) |
| 72 |
-- final message when returning to Gastan |
| 73 |
text[15] = _([["The things I do for science! Now let me go back to my lab and analyze the drone. I need to figure out exactly what happened and what went wrong. Once I know more I might need you again. Oh, and here, for your service!" A small bag containing a credit chip and a tiny toy drone is tossed your way.]]) |
| 74 |
|
| 75 |
-- text if the mission is failed |
| 76 |
fail_text = _([["NOOOOOO! What have you done!? My prototype! It's going to take me weeks to rebuild it! You incompetent nincompoop!"]]) |
| 77 |
-- osd_msg |
| 78 |
osd_msg[1] = _("Go to the %s system and hail the prototype") |
| 79 |
osd_msg[2] = _("Disable the prototype") |
| 80 |
osd_msg[3] = _("Return the prototype to %s in the %s system") |
| 81 |
-- refuestext |
| 82 |
refusetitle = _("No Science Today") |
| 83 |
refusetext = _("Don't you care about science?...") |
| 84 |
|
| 85 |
log_text = _([[You helped Dr. Geller retrieve his lost prototype drone.]]) |
| 86 |
|
| 87 |
|
| 88 |
function create () |
| 89 |
-- Spaceport bar stuff |
| 90 |
misn.setNPC( _("Dr. Geller"), "zalek/unique/geller") |
| 91 |
misn.setDesc( bar_desc ) |
| 92 |
end |
| 93 |
function accept() |
| 94 |
-- Mission details: |
| 95 |
if not tk.yesno( title[1], text[1] ) then |
| 96 |
tk.msg(refusetitle, refusetext) |
| 97 |
misn.finish() |
| 98 |
end |
| 99 |
tk.msg( title[1], text[2] ) |
| 100 |
misn.accept() |
| 101 |
misn.osdCreate(misn_title, {osd_msg[1]:format(t_sys[1]),osd_msg[2],osd_msg[3]:format(t_pla[2],t_sys[2])}) |
| 102 |
misn.setDesc(misn_desc) |
| 103 |
misn.setTitle(misn_title) |
| 104 |
misn.setReward(misn_reward) |
| 105 |
misn.osdActive(1) |
| 106 |
mmarker = misn.markerAdd(system.get(t_sys[1]), "high") |
| 107 |
hook.jumpin("sys_enter") |
| 108 |
end |
| 109 |
|
| 110 |
function sys_enter () |
| 111 |
-- Check to see if reaching target system |
| 112 |
if system.cur() == system.get(t_sys[1]) and not captured then |
| 113 |
-- wait til stars have settled and do stuff |
| 114 |
--pilot.clear() |
| 115 |
--pilot.toggleSpawn(false) |
| 116 |
hook.timer( 2000,"game_of_drones") |
| 117 |
end |
| 118 |
if jumps ~= 0 then |
| 119 |
if system.cur() == system.get(t_sys[3]) then |
| 120 |
-- do something else |
| 121 |
hook.timer(2000,"chase_of_drones") |
| 122 |
end |
| 123 |
end |
| 124 |
|
| 125 |
end |
| 126 |
|
| 127 |
function game_of_drones () |
| 128 |
tk.msg(title[2], text[3]:format(t_pla[1]:name())) |
| 129 |
-- spawn drones |
| 130 |
|
| 131 |
t_drone = pilot.add("Za'lek Scout Drone", "trader",t_pla[1] )[1] -- prototype is a scout drone |
| 132 |
t_drone:addOutfit("Tricon Zephyr II Engine") |
| 133 |
-- add something so it is not insta-disabled with one shot? |
| 134 |
--t_drone:addOutfit("Tricon Zephyr II Engine") |
| 135 |
t_drone:setFaction("Civilian") |
| 136 |
t_drone:rename(_("Prototype Drone")) |
| 137 |
t_drone:setInvincible(true) |
| 138 |
t_drone:control() |
| 139 |
t_drone:setHilight(true) |
| 140 |
t_drone:setVisplayer(true) |
| 141 |
t_drone:goto(t_drone:pos() + vec2.new( 400, -400), false) |
| 142 |
-- just some moving around, stolen from baron missions ;D |
| 143 |
idlehook = hook.pilot(t_drone, "idle", "targetIdle") |
| 144 |
misn.osdActive(2) |
| 145 |
-- wait for the drone to be hailed |
| 146 |
dist = 200 |
| 147 |
sp = t_pla[1] |
| 148 |
-- + vec2.new(dist*math.cos(math.pi*2*rnd.rnd()),dist*math.sin(2*math.pi*rnd.rnd())) |
| 149 |
--pilot.toggleSpawn(true) |
| 150 |
hailhook = hook.pilot(t_drone,"hail","got_hailed",t_drone,badguys) |
| 151 |
end |
| 152 |
|
| 153 |
function got_hailed() |
| 154 |
if vec2.dist(player.pos(),t_drone:pos()) > 1000 then |
| 155 |
player.msg(_("Target out of range")) |
| 156 |
return |
| 157 |
end |
| 158 |
hook.rm(hailhook) |
| 159 |
hook.rm(idlehook) |
| 160 |
tk.msg(title[3], text[4]) |
| 161 |
tk.msg(title[3], text[5]:format(t_pla[1]:name())) |
| 162 |
tk.msg(title[3], text[6]) |
| 163 |
t_drone:setInvincible(false) |
| 164 |
t_drone:setHostile(true) |
| 165 |
t_drone:setHilight(true) |
| 166 |
t_drone:setVisplayer(true) |
| 167 |
spawnhook = hook.timer(3000, "sp_baddies") |
| 168 |
hook.pilot(t_drone, "death", "failed") |
| 169 |
hook.pilot(t_drone, "board", "targetBoard") |
| 170 |
hook.pilot(t_drone, "jump", "drone_jumped") |
| 171 |
|
| 172 |
end |
| 173 |
|
| 174 |
function sp_baddies() |
| 175 |
hook.rm(spawnhook) |
| 176 |
badguys = {} |
| 177 |
badguys = spawn_baddies(t_pla[1]) |
| 178 |
for i=1,#badguys do |
| 179 |
badguys[i]:setHostile(true) |
| 180 |
end |
| 181 |
bghook = {} |
| 182 |
for i=1,#badguys do |
| 183 |
bghook[i] = hook.pilot(badguys[i], "exploded", "dead_drone",i) |
| 184 |
end |
| 185 |
jps = system.cur():jumps() |
| 186 |
t_drone:taskClear() |
| 187 |
t_sys[3] = jps[1]:dest():nameRaw() |
| 188 |
t_drone:hyperspace(jps[1]:dest()) |
| 189 |
end |
| 190 |
|
| 191 |
function failed () |
| 192 |
tk.msg(title[2],fail_text) |
| 193 |
misn.finish(false) |
| 194 |
end |
| 195 |
|
| 196 |
function targetBoard() |
| 197 |
player.unboard() |
| 198 |
tk.msg(title[3], text[7]) |
| 199 |
t_drone:setHilight(false) |
| 200 |
t_drone:setVisplayer(false) |
| 201 |
captured = true |
| 202 |
t_drone:rm() |
| 203 |
cargoID = misn.cargoAdd("Prototype",10) |
| 204 |
misn.osdActive(3) |
| 205 |
misn.markerRm(mmarker) |
| 206 |
mmarker = misn.markerAdd(system.get(t_sys[2]),"high") |
| 207 |
if jumps == 0 then |
| 208 |
hook.timer(2000, "drones_flee") |
| 209 |
end |
| 210 |
hook.land("land_home") |
| 211 |
end |
| 212 |
|
| 213 |
function drone_jumped () |
| 214 |
--begin the chase: |
| 215 |
tk.msg(title[3], text[9]:format(_(t_sys[3]))) |
| 216 |
misn.markerRm(mmarker) |
| 217 |
if (jumps==0) then |
| 218 |
mmarker = misn.markerAdd(system.get(t_sys[3]),"high") |
| 219 |
for i=1,#badguys do |
| 220 |
badguys[i]:control() |
| 221 |
badguys[i]:hyperspace() |
| 222 |
hook.rm(bghook[i]) |
| 223 |
end |
| 224 |
if not fled then |
| 225 |
tk.msg(title[3],text[8]) |
| 226 |
end |
| 227 |
fled = false |
| 228 |
elseif jumps == 2 then |
| 229 |
t_drone:setHealth(0,0) |
| 230 |
tk.msg(title[3],text[14]) |
| 231 |
misn.finish(false) |
| 232 |
else |
| 233 |
mmarker = misn.markerAdd(system.get(t_sys[3]),"high") |
| 234 |
end |
| 235 |
jumps = jumps + 1 |
| 236 |
end |
| 237 |
|
| 238 |
-- the drone behaves differently depending on through how many systems it has been chased so far |
| 239 |
function chase_of_drones () |
| 240 |
tk.msg(title[3],text[10]) |
| 241 |
t_drone = pilot.add("Za'lek Scout Drone", "dummy",vec2.newP(rnd.rnd(0,system.cur():radius()/5),rnd.rnd(0,359)))[1] -- prototype is a scout drone |
| 242 |
t_drone:addOutfit("Tricon Zephyr II Engine") |
| 243 |
-- add something so it is not insta-disabled with one shot? |
| 244 |
t_drone:setFaction("Civilian") |
| 245 |
t_drone:rename(_("Prototype Drone")) |
| 246 |
t_drone:control() |
| 247 |
t_drone:setHilight(true) |
| 248 |
t_drone:setVisplayer(true) |
| 249 |
t_drone:goto(t_drone:pos() + vec2.new( 400, -400), false) |
| 250 |
t_stats = t_drone:stats() |
| 251 |
t_drone:setHealth(50,100) |
| 252 |
t_drone:setNoDisable() |
| 253 |
dr_a_hook = hook.pilot(t_drone, "attacked", "drone_attacked") |
| 254 |
dr_d_hook = hook.pilot(t_drone, "death", "failed") |
| 255 |
hook.pilot(t_drone, "board", "targetBoard") |
| 256 |
hook.pilot(t_drone, "jump", "drone_jumped") |
| 257 |
if jumps == 1 then |
| 258 |
t_drone:setSpeedLimit(t_stats.speed_max*2/3) |
| 259 |
elseif jumps == 2 then |
| 260 |
t_drone:setSpeedLimit(t_stats.speed_max*1/3) |
| 261 |
elseif jumps > 2 then |
| 262 |
player.msg(_("Something went terribly wrong here! If you see this message please reload and report a bug in this mission. Thank you!")) |
| 263 |
end |
| 264 |
-- just some moving around, stolen from baron missions ;D |
| 265 |
idlehook = hook.pilot(t_drone, "idle", "targetIdle") |
| 266 |
|
| 267 |
end |
| 268 |
|
| 269 |
function drone_attacked() |
| 270 |
hook.rm(dr_a_hook) |
| 271 |
tk.msg(title[3],text[11]) |
| 272 |
t_drone:setHostile(true) |
| 273 |
t_drone:setHilight(true) |
| 274 |
t_drone:setVisplayer(true) |
| 275 |
jps = system.cur():jumps() |
| 276 |
t_drone:taskClear() |
| 277 |
t_sys[3] = jps[1]:dest():nameRaw() |
| 278 |
t_drone:hyperspace(jps[1]:dest()) |
| 279 |
hook.timer(4000,"drone_disableable") |
| 280 |
end |
| 281 |
|
| 282 |
function drone_selfdestruct() |
| 283 |
hook.rm(dr_d_hook) |
| 284 |
t_drone:setHealth(0,0) |
| 285 |
tk.msg(title[3],text[14]) |
| 286 |
misn.finish(false) |
| 287 |
end |
| 288 |
|
| 289 |
function drone_disableable() |
| 290 |
tk.msg(title[3],text[12]) |
| 291 |
t_drone:setNoDisable(false) |
| 292 |
if jumps == 2 then |
| 293 |
tk.msg(title[3],text[13]) |
| 294 |
hook.timer(18000+rnd.rnd(1,4000),"drone_selfdestruct") |
| 295 |
end |
| 296 |
end |
| 297 |
-- last hook |
| 298 |
function land_home() |
| 299 |
if planet.cur() == planet.get(t_pla[2]) then |
| 300 |
tk.msg(title[4]:format(t_pla[2]),text[15]) |
| 301 |
player.pay(reward) |
| 302 |
player.addOutfit("Toy Drone") |
| 303 |
zlk_addSciWrongLog( log_text ) |
| 304 |
misn.finish(true) |
| 305 |
end |
| 306 |
end |
| 307 |
|
| 308 |
-- tell drones to spread and flee |
| 309 |
function drones_flee () |
| 310 |
tk.msg(title[3],text[8]) |
| 311 |
fled = true |
| 312 |
for i=1,#badguys do |
| 313 |
pilot.taskClear(badguys[i]) |
| 314 |
badguys[i]:control(true) |
| 315 |
--badguys[i]:changeAI("flee") |
| 316 |
badguys[i]:hyperspace() |
| 317 |
end |
| 318 |
for i=1,#bghook do |
| 319 |
hook.rm(bghook[i]) |
| 320 |
end |
| 321 |
end |
| 322 |
|
| 323 |
-- check how man drones are left, tell them to leave if <=2 |
| 324 |
function dead_drone () |
| 325 |
-- remove dead drones |
| 326 |
for i=1,#badguys do |
| 327 |
if not badguys[i]:exists() then |
| 328 |
-- player.msg("If close worked") |
| 329 |
table.remove(badguys,i) |
| 330 |
break |
| 331 |
end |
| 332 |
end |
| 333 |
if(#badguys<=2) then |
| 334 |
-- if it is the last attacking drone, make it run away from the player |
| 335 |
badguys[1]:control() |
| 336 |
t_drone:control() |
| 337 |
badguys[2]:control() |
| 338 |
jpt = get_nearest_jump(badguys[1]) |
| 339 |
jpt2 = jpt |
| 340 |
jpts = system.cur():jumps() |
| 341 |
for i,j_pt in ipairs(jpts) do |
| 342 |
if j_pt ~= jpt2 then |
| 343 |
jpt2 = j_pt |
| 344 |
break |
| 345 |
end |
| 346 |
end |
| 347 |
badguys[1]:hyperspace(jpt2:dest()) |
| 348 |
t_drone:hyperspace(jpt:dest()) |
| 349 |
badguys[2]:hyperspace() |
| 350 |
tk.msg(title[3],text[8]) |
| 351 |
fled = true |
| 352 |
for i=1,#bghook do |
| 353 |
hook.rm(bghook[i]) |
| 354 |
end |
| 355 |
end |
| 356 |
end |
| 357 |
|
| 358 |
-- general functions |
| 359 |
|
| 360 |
-- keep drone moving |
| 361 |
function targetIdle() |
| 362 |
t_drone:goto(t_drone:pos() + vec2.new( 400, 400), false) |
| 363 |
t_drone:goto(t_drone:pos() + vec2.new(-400, 400), false) |
| 364 |
t_drone:goto(t_drone:pos() + vec2.new(-400, -400), false) |
| 365 |
t_drone:goto(t_drone:pos() + vec2.new( 400, -400), false) |
| 366 |
hook.rm(idlehook) |
| 367 |
idlehook = hook.timer(5000, "targetIdle") |
| 368 |
end |
| 369 |
|
| 370 |
-- get nearest jumppoint |
| 371 |
|
| 372 |
function get_nearest_jump(pil) |
| 373 |
jpts = system.cur():jumps() |
| 374 |
-- basically the distance that the map can have at |
| 375 |
dist = 2*system.cur():radius() |
| 376 |
index = 0 |
| 377 |
for i,jpt in ipairs(jpts) do |
| 378 |
dist1 = vec2.dist(jpt:pos(),pil:pos()) |
| 379 |
if dist1 < dist then |
| 380 |
dist = dist1 |
| 381 |
index = i |
| 382 |
end |
| 383 |
end |
| 384 |
return jpts[index] |
| 385 |
end |
| 386 |
--- create enemy ships |
| 387 |
function spawn_baddies(sp) |
| 388 |
-- light drones |
| 389 |
local scom = {} |
| 390 |
-- has eventually to be trimmed |
| 391 |
-- so weird: ai does not work properly apparently? WTF is going on.. switching to dummy and switched from pilot.add to pilot.addRaw |
| 392 |
-- disabling some ships since this way it is really hard to win the mission |
| 393 |
scom[1] = pilot.addRaw("Za'lek Light Drone","mercenary", sp, "Mercenary" ) |
| 394 |
scom[2] = pilot.addRaw("Za'lek Light Drone","mercenary", sp, "Mercenary" ) |
| 395 |
scom[3] = pilot.addRaw("Za'lek Heavy Drone","mercenary", sp, "Mercenary" ) |
| 396 |
scom[4] = pilot.addRaw("Za'lek Heavy Drone","mercenary", sp, "Mercenary" ) |
| 397 |
-- scom[5] = pilot.addRaw("Za'lek Heavy Drone","mercenary", sp, "Mercenary" ) |
| 398 |
-- scom[6] = pilot.addRaw("Za'lek Light Drone","mercenary", sp, "Mercenary" ) |
| 399 |
-- scom[7] = pilot.addRaw("Za'lek Light Drone","mercenary", sp, "Mercenary" ) |
| 400 |
for i=1,#scom do |
| 401 |
scom[i]:setHostile(false) |
| 402 |
end |
| 403 |
|
| 404 |
return scom |
| 405 |
end |