| 1 |
--[[ |
| 2 |
<?xml version='1.0' encoding='utf8'?> |
| 3 |
<mission name="Advanced Nebula Research"> |
| 4 |
<flags> |
| 5 |
<unique /> |
| 6 |
</flags> |
| 7 |
<avail> |
| 8 |
<priority>4</priority> |
| 9 |
<done>Novice Nebula Research</done> |
| 10 |
<chance>100</chance> |
| 11 |
<location>Bar</location> |
| 12 |
<planet>Vilati Vilata</planet> |
| 13 |
</avail> |
| 14 |
<notes> |
| 15 |
<campaign>Nebula Research</campaign> |
| 16 |
</notes> |
| 17 |
</mission> |
| 18 |
--]] |
| 19 |
--[[ |
| 20 |
|
| 21 |
Mission: Advanced Nebula Research |
| 22 |
|
| 23 |
Description: This time the postdoc asks the player for help. Reference data of further nebula are needed to understand the Sol nebula. The player has to escort a refitted transport ship through Pirate and Dvaered space. |
| 24 |
|
| 25 |
Difficulty: Medium |
| 26 |
|
| 27 |
]]-- |
| 28 |
|
| 29 |
require "scripts/nextjump.lua" |
| 30 |
require "scripts/numstring.lua" |
| 31 |
require "missions/zalek/common.lua" |
| 32 |
|
| 33 |
|
| 34 |
bar_desc = _("You see a scientist who is apparently looking for someone.") |
| 35 |
mtitle = _("Advanced Nebula Research") |
| 36 |
misn_reward = _("%s") |
| 37 |
mdesc = _("Escort the transport ship to the %s in the %s system. Make sure to stay close to the transport ship and wait until they jumped out of the system safely.") |
| 38 |
title = {} |
| 39 |
title[1] = _("Bar") |
| 40 |
title[2] = _("Departure") |
| 41 |
title[3] = _("Trouble inbound") |
| 42 |
title[4] = _("Scans complete") |
| 43 |
title[5] = _("Mission accomplished") |
| 44 |
text = {} |
| 45 |
text[1] = _([["Captain %s if I'm not mistaken? Well met. I heard you recently helped one of our students. My name is Dr. Mensing and I am working for professor Voges as well. |
| 46 |
Your timing is just perfect. You see, we planed an expedition but the captain we hired to escort our transport ship backed out in the last minute. It's quite bothersome being stranded right in Dvaered space. Would you be willing to assist us instead?"]]) |
| 47 |
text[2] = _([["While the data recorded by Robert is of good quality he seems to have completely forgotten that we need reference data of similarly dense nebulae. We have already installed his sensors on a transport ship. The nearby PSO nebula should be a good candidate but there are the pirate systems in between. Also the target systems are controled by the Dvaered. Hard to say whether the Dvaered or the pirates are more dangerous. So this is why we need an escort. |
| 48 |
We will travel through %s, %s, and %s. Just passing through the systems should be sufficient. Also, I want to visit the %s station before returning back to %s. You have to make sure no one shoots us down during our expedition."]]) |
| 49 |
text[3] = _([["Please follow us, %s. Make sure to jump to the next system after we jumped out. We'll have to land on some planets on our way to refuel."]]) |
| 50 |
text[4] = _([[Suddenly your comm system turns on, receiving a conversation between the ship you are escorting and a Dvaered patrol ship. |
| 51 |
"I assure you, we mean no harm. We are just a convoy of scientists passing through Dvaered space." says Dr. Mensing. |
| 52 |
The response sounds harsh. "Do you think we're naïve? You're obviously a spy scouting our systems' defences." |
| 53 |
"Please calm down. I'm sure there is a diplomatic solution for our misunderstanding." |
| 54 |
The Dvaered officer replies "We can see that your ship is stuffed with sensors. Your intentions are obvious. Prepare for your ship being boarded."]]) |
| 55 |
text[5] = _([[Dr. Mensing pauses, apparently choosing her words with care. |
| 56 |
"Fine, do whatever you want. Our reasoning is obviously beyond the imagination of your degenerate intellect." With this answer the comm shuts off. Your sensors show that a Dvaered patrol changed their course and is heading straight towards the transporter.]]) |
| 57 |
text[6] = _([["The situation would have escalated anyway." argues Dr. Mensing, this time directly speaking towards you. |
| 58 |
"I must admit, it is suspicious for a refitted transport ship with such advanced sensor suits to show up in Dvaered space. I hadn't considered this point. |
| 59 |
I'm counting on you, %s. Please help us."]]) |
| 60 |
text[7] = _([[After leaving the ship you meet up with Dr. Mensing who hands you over a chip worth %s and thanks you for your help. |
| 61 |
"We'll be able to return to Jorla safely from here on. You did science a great favor today. I'm sure the data we collected will help us to understand the cause for the Sol nebula's volatility."]]) |
| 62 |
|
| 63 |
refueltitle = _("A short break") |
| 64 |
refueltext = _([[Once you are done with the refuel operations, you meet Dr. Mensing on her way back to the transport ship. |
| 65 |
"I just met up with another 'scientist' working on this station. The purpose of this station is to collect data about the PSO nebula, but their scans are absolute garbage. Apparently the station is being run by an independent university. They couldn't possible keep up with the Za'lek standards in terms of proper scientific methods." |
| 66 |
She is visibly upset about the apparent lack of dedication to science. "Let's head back to %s. Our own measurements are completed by now."]]) |
| 67 |
|
| 68 |
transporterdeathtitle = _("The transporter was destroyed!") |
| 69 |
transporterdeathtext = _("The transporter was destroyed and all scientists died! Even worse, you failed science!") |
| 70 |
landfailtitle = _("You abandoned your mission!") |
| 71 |
landfailtext = _("You have landed, abandoning your mission to escort the transport ship. You failed science miserably!") |
| 72 |
transporterdistress = _("We're under attack!") |
| 73 |
|
| 74 |
-- Mission info stuff |
| 75 |
osd_msg = {} |
| 76 |
osd_title = _("Advanced Nebula Research") |
| 77 |
osd_msg[1] = _("Escort the transport ship to %s in the %s system.") |
| 78 |
osd_msg[2] = _("Land on %s in the %s system.") |
| 79 |
osd_msg[3] = _("Fly back to %s in the %s system.") |
| 80 |
|
| 81 |
log_text = _([[You helped Dr. Mensing to collect sensor data of the PSO nebula.]]) |
| 82 |
|
| 83 |
|
| 84 |
function create() |
| 85 |
station = "PSO Monitor" |
| 86 |
homeworld = "Bastion Station" |
| 87 |
ambush = false |
| 88 |
stage = 0 |
| 89 |
credits = 800000 -- 800K |
| 90 |
|
| 91 |
-- Spaceport bar stuff |
| 92 |
misn.setNPC(_("A scientist"), "zalek/unique/mensing") |
| 93 |
misn.setDesc(bar_desc) |
| 94 |
end |
| 95 |
|
| 96 |
function accept() |
| 97 |
if not tk.yesno(title[1], string.format(text[1], player:name())) then |
| 98 |
misn.finish() |
| 99 |
end |
| 100 |
|
| 101 |
stage = 1 |
| 102 |
exited = false |
| 103 |
firstTakeOff = true |
| 104 |
origin = planet.cur() |
| 105 |
t_sys = {} |
| 106 |
t_sys[1] = system.get("Ksher") |
| 107 |
t_sys[2] = system.get("Sultan") |
| 108 |
t_sys[3] = system.get("Faust") |
| 109 |
t_sys[4] = system.get("PSO") |
| 110 |
t_sys[5] = system.get("Amaroq") |
| 111 |
t_sys[6] = system.get("Ksher") |
| 112 |
t_sys[7] = system.get("Daravon") |
| 113 |
t_sys[8] = system.get("Pultatis") |
| 114 |
t_planet = {} |
| 115 |
t_planet[1] = planet.get("Qoman") |
| 116 |
t_planet[5] = planet.get(station) |
| 117 |
t_planet[6] = t_planet[1] |
| 118 |
t_planet[7] = planet.get("Vilati Vilata") |
| 119 |
t_planet[8] = planet.get(homeworld) |
| 120 |
|
| 121 |
tk.msg(title[1], string.format(text[2], t_sys[2]:name(), t_sys[3]:name(), t_sys[4]:name(), _(station), _(homeworld))) |
| 122 |
|
| 123 |
-- Set up mission information |
| 124 |
destsys = t_sys[1] |
| 125 |
misn.setTitle(mtitle) |
| 126 |
misn.setReward(string.format(misn_reward, creditstring(credits))) |
| 127 |
misn.setDesc(string.format(mdesc, _(station), t_sys[5]:name())) |
| 128 |
nextsys = getNextSystem(system.cur(), destsys) -- This variable holds the system the player is supposed to jump to NEXT. |
| 129 |
|
| 130 |
misn.accept() |
| 131 |
misn_marker = misn.markerAdd(nextsys, "low") |
| 132 |
updateGoalDisplay() |
| 133 |
|
| 134 |
hook.takeoff("takeoff") |
| 135 |
hook.jumpin("jumpin") |
| 136 |
hook.jumpout("jumpout") |
| 137 |
hook.land("land") |
| 138 |
end |
| 139 |
|
| 140 |
function updateGoalDisplay() |
| 141 |
local s, i, osd_index, osd_active, omsg |
| 142 |
osd_index = {1, 0, 0, 0, 2, 2, 2, 3} |
| 143 |
omsg = {} |
| 144 |
osd_active = 1 |
| 145 |
for s, i in ipairs(osd_index) do |
| 146 |
if i > 0 then |
| 147 |
omsg[#omsg+1] = osd_msg[i]:format(t_planet[s]:name(), t_sys[s]:name()) |
| 148 |
if stage > s and (stage > s+1 or destplanet == nil) then |
| 149 |
osd_active = #omsg + 1 |
| 150 |
end |
| 151 |
end |
| 152 |
end |
| 153 |
misn.osdCreate(osd_title, omsg) |
| 154 |
misn.osdActive(osd_active) |
| 155 |
end |
| 156 |
|
| 157 |
function takeoff() |
| 158 |
if firstTakeOff then |
| 159 |
tk.msg(title[2], string.format(text[3], player:name())) |
| 160 |
firstTakeOff = false |
| 161 |
end |
| 162 |
destplanet = nil |
| 163 |
spawnTransporter() |
| 164 |
updateGoalDisplay() |
| 165 |
end |
| 166 |
|
| 167 |
function jumpin() |
| 168 |
if system.cur() ~= nextsys then |
| 169 |
fail(_("MISSION FAILED! You jumped into the wrong system. You failed science miserably!")) |
| 170 |
else |
| 171 |
nextsys = getNextSystem(system.cur(), destsys) |
| 172 |
updateGoalDisplay() |
| 173 |
spawnTransporter() |
| 174 |
if not ambush and system.cur():faction() == faction.get("Dvaered") and system.cur():jumpDist(t_sys[5]) < 5 then |
| 175 |
hook.timer(2000, "startAmbush") |
| 176 |
elseif system.cur()==system.get("Daan") or system.cur()==system.get("Provectus Nova") then |
| 177 |
ambush = pilot.add("Trader Ambush 2", "baddie_norun", vec2.new(0,0)) |
| 178 |
for i, j in ipairs(ambush) do |
| 179 |
j:setHostile() |
| 180 |
j:control(true) |
| 181 |
j:attack(transporter) |
| 182 |
end |
| 183 |
end |
| 184 |
end |
| 185 |
end |
| 186 |
|
| 187 |
function jumpout() |
| 188 |
if not exited then |
| 189 |
fail(_("MISSION FAILED! You jumped before the transport ship you were escorting.")) |
| 190 |
end |
| 191 |
origin = system.cur() |
| 192 |
if nextsys == t_sys[stage] then |
| 193 |
if t_planet[stage] ~= nil then |
| 194 |
destplanet = t_planet[stage] |
| 195 |
else |
| 196 |
destplanet = nil |
| 197 |
end |
| 198 |
stage = stage+1 |
| 199 |
destsys = t_sys[stage] |
| 200 |
end |
| 201 |
end |
| 202 |
|
| 203 |
function land() |
| 204 |
if not exited then |
| 205 |
tk.msg(landfailtitle, landfailtext) |
| 206 |
misn.finish(false) |
| 207 |
elseif planet.cur() == planet.get(station) and not station_visited then |
| 208 |
tk.msg(refueltitle, string.format(refueltext, _(homeworld))) |
| 209 |
station_visited = true |
| 210 |
elseif planet.cur() == planet.get(homeworld) then |
| 211 |
tk.msg(title[5], string.format(text[7], creditstring(credits))) |
| 212 |
player.pay(credits) |
| 213 |
zlk_addNebuResearchLog(log_text) |
| 214 |
misn.finish(true) |
| 215 |
end |
| 216 |
origin = planet.cur() |
| 217 |
end |
| 218 |
|
| 219 |
function continueToDest(pilot) |
| 220 |
t_sys = {} |
| 221 |
t_sys[1] = system.get("Ksher") |
| 222 |
t_sys[2] = system.get("Sultan") |
| 223 |
t_sys[3] = system.get("Faust") |
| 224 |
t_sys[4] = system.get("PSO") |
| 225 |
t_sys[5] = system.get("Amaroq") |
| 226 |
t_sys[6] = system.get("Ksher") |
| 227 |
t_sys[7] = system.get("Daravon") |
| 228 |
t_sys[8] = system.get("Pultatis") |
| 229 |
t_planet = {} |
| 230 |
t_planet[1] = planet.get("Qoman") |
| 231 |
t_planet[5] = planet.get(station) |
| 232 |
t_planet[6] = t_planet[1] |
| 233 |
t_planet[7] = planet.get("Vilati Vilata") |
| 234 |
t_planet[8] = planet.get(homeworld) |
| 235 |
if pilot ~= nil and pilot:exists() then |
| 236 |
pilot:control(true) |
| 237 |
pilot:setNoJump(false) |
| 238 |
pilot:setNoLand(false) |
| 239 |
if destplanet ~= nil then |
| 240 |
pilot:land(destplanet, true) |
| 241 |
misn.markerMove(misn_marker, destplanet:system()) |
| 242 |
else |
| 243 |
pilot:hyperspace(nextsys, true) |
| 244 |
misn.markerMove(misn_marker, nextsys) |
| 245 |
end |
| 246 |
end |
| 247 |
end |
| 248 |
|
| 249 |
function transporterJump(p, j) |
| 250 |
exited = true |
| 251 |
if p:exists() then |
| 252 |
player.msg(string.format( |
| 253 |
_("%s has jumped to %s."), p:name(), j:dest():name())) |
| 254 |
end |
| 255 |
end |
| 256 |
|
| 257 |
function transporterLand(p, j) |
| 258 |
exited = true |
| 259 |
if p:exists() then |
| 260 |
player.msg(string.format( |
| 261 |
_("%s has landed on %s."), p:name(), destplanet:name())) |
| 262 |
end |
| 263 |
end |
| 264 |
|
| 265 |
function transporterAttacked(p, attacker) |
| 266 |
unsafe = true |
| 267 |
p:control(true) |
| 268 |
p:setNoJump(true) |
| 269 |
p:setNoLand(true) |
| 270 |
p:attack(attacker) |
| 271 |
p:control(false) |
| 272 |
|
| 273 |
if not shuttingup then |
| 274 |
shuttingup = true |
| 275 |
p:comm(player.pilot(), transporterdistress) |
| 276 |
hook.timer(5000, "transporterShutup") -- Shuts him up for at least 5s. |
| 277 |
end |
| 278 |
end |
| 279 |
|
| 280 |
function transporterShutup() |
| 281 |
shuttingup = false |
| 282 |
end |
| 283 |
|
| 284 |
function timer_transporterSafe() |
| 285 |
hook.timer(2000, "timer_transporterSafe") |
| 286 |
|
| 287 |
if unsafe then |
| 288 |
unsafe = false |
| 289 |
continueToDest(transporter) |
| 290 |
end |
| 291 |
end |
| 292 |
|
| 293 |
function spawnTransporter() |
| 294 |
transporter = pilot.add("Nebula Research Shuttle", nil, origin)[1] |
| 295 |
hook.pilot(transporter, "death", "transporterDeath") |
| 296 |
hook.pilot(transporter, "jump", "transporterJump") |
| 297 |
hook.pilot(transporter, "land", "transporterLand") |
| 298 |
hook.pilot(transporter, "attacked", "transporterAttacked", transporter) |
| 299 |
transporter:control() |
| 300 |
transporter:setInvincPlayer() |
| 301 |
transporter:setHilight(true) |
| 302 |
transporter:setVisplayer() |
| 303 |
transporter:setVisible() -- Hack to make ambushes more reliable. |
| 304 |
transporter:setFriendly() |
| 305 |
transporter:rename( _("Research Shuttle") ) |
| 306 |
continueToDest(transporter) |
| 307 |
hook.timer( 2000, "timer_transporterSafe" ) |
| 308 |
end |
| 309 |
|
| 310 |
function startAmbush() |
| 311 |
ships = pilot.add("Dvaered Small Patrol", "dvaered_norun", vec2.new(-1000,0)) |
| 312 |
for i, j in ipairs(ships) do |
| 313 |
j:control(true) |
| 314 |
j:goto(vec2.new(-8000,0)) |
| 315 |
end |
| 316 |
ambush = true |
| 317 |
hook.timer(15000, "ambushHail") |
| 318 |
end |
| 319 |
|
| 320 |
function ambushHail() |
| 321 |
for i, j in ipairs(ships) do |
| 322 |
j:setHostile() |
| 323 |
j:setHilight() |
| 324 |
j:control(true) |
| 325 |
j:attack(transporter) |
| 326 |
j:setVisible() |
| 327 |
j:setVisplayer() |
| 328 |
end |
| 329 |
tk.msg(title[3], text[4]) |
| 330 |
tk.msg(title[3], text[5]) |
| 331 |
tk.msg(title[3], string.format(text[6], player:name())) |
| 332 |
end |
| 333 |
|
| 334 |
-- Handle the destruction of the transporter. Abort the mission. |
| 335 |
function transporterDeath() |
| 336 |
tk.msg(transporterdeathtitle, transporterdeathtext) |
| 337 |
misn.finish(false) |
| 338 |
end |
| 339 |
|
| 340 |
-- Fail the mission, showing message to the player. |
| 341 |
function fail( message ) |
| 342 |
if message ~= nil then |
| 343 |
-- Pre-colourized, do nothing. |
| 344 |
if message:find("\a") then |
| 345 |
player.msg( message ) |
| 346 |
-- Colourize in red. |
| 347 |
else |
| 348 |
player.msg( "\ar" .. message .. "\a0" ) |
| 349 |
end |
| 350 |
end |
| 351 |
misn.finish( false ) |
| 352 |
end |