| 1 |
--[[ |
| 2 |
<?xml version='1.0' encoding='utf8'?> |
| 3 |
<mission name="Moving Up"> |
| 4 |
<flags> |
| 5 |
<unique /> |
| 6 |
</flags> |
| 7 |
<avail> |
| 8 |
<priority>2</priority> |
| 9 |
<done>Garbage Person</done> |
| 10 |
<chance>30</chance> |
| 11 |
<location>Bar</location> |
| 12 |
<faction>Soromid</faction> |
| 13 |
<cond>var.peek("comingout_time") == nil or time.get() >= time.fromnumber(var.peek("comingout_time")) + time.create(0, 20, 0)</cond> |
| 14 |
</avail> |
| 15 |
<notes> |
| 16 |
<campaign>Coming Out</campaign> |
| 17 |
</notes> |
| 18 |
</mission> |
| 19 |
--]] |
| 20 |
--[[ |
| 21 |
|
| 22 |
Moving Up |
| 23 |
|
| 24 |
This program is free software: you can redistribute it and/or modify |
| 25 |
it under the terms of the GNU General Public License as published by |
| 26 |
the Free Software Foundation, either version 3 of the License, or |
| 27 |
(at your option) any later version. |
| 28 |
|
| 29 |
This program is distributed in the hope that it will be useful, |
| 30 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 31 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 32 |
GNU General Public License for more details. |
| 33 |
|
| 34 |
You should have received a copy of the GNU General Public License |
| 35 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 36 |
|
| 37 |
--]] |
| 38 |
|
| 39 |
require "numstring.lua" |
| 40 |
require "jumpdist.lua" |
| 41 |
require "pilot/pirate.lua" |
| 42 |
require "missions/soromid/common.lua" |
| 43 |
|
| 44 |
|
| 45 |
title = {} |
| 46 |
text = {} |
| 47 |
|
| 48 |
title[1] = _("A Great Opportunity") |
| 49 |
text[1] = _([[You greet Chelsea as usual and have a friendly chat with them. You learn that they had a close call recently with another thug, but they managed to shake the thug off with their new ship. |
| 50 |
"It's a lot better than before. The work is tough though. I've been picking off small pirates with bounties on their heads, doing relatively safe system patrols, that sort of thing. I'm supposed to be getting a better ship soon, but it's going to be difficult." You ask them why that is. "Well, I came across someone who's offering me a bargain on a new ship! Well, not new exactly. It's used, but in much better condition than that rust bucket I got before. Supposedly this guy used to be a Dvaered warlord and is offering me his old Vigilance if I just take care of this one pirate known as %s. Trouble is they're piloting a ship that's stronger than my own...." |
| 51 |
Chelsea pauses in contemplation for a moment. "Say, do you think you could help me out on this one? I just need you to help me kill the pirate in %s. I'll give you %s for the trouble. How about it?"]]) |
| 52 |
|
| 53 |
text[2] = _([["Fantastic! Thank you for the help! I'll meet you in %s and we can take the pirate out. Let's do this!"]]) |
| 54 |
|
| 55 |
text[3] = _([["Ah, you're busy, eh? Oh well. Let me know if you change your mind, OK?"]]) |
| 56 |
|
| 57 |
text[4] = _([["Hey, %s! Any chance you could reconsider? I could use your help."]]) |
| 58 |
|
| 59 |
title[5] = _("Death Of A Pirate") |
| 60 |
text[5] = _([[Chelsea pops up on your viewscreen and grins. "We did it!" they say. "Thanks for all the help, %s. I've transferred the money into your account. See you next time with my new ship!" You say your goodbyes and go back to your own adventures.]]) |
| 61 |
|
| 62 |
misn_title = _("Moving Up") |
| 63 |
misn_desc = _("Chelsea needs you help them kill a wanted pirate in %s.") |
| 64 |
|
| 65 |
npc_name = _("Chelsea") |
| 66 |
npc_desc = _("Oh, it's Chelsea! You feel an urge to say hello.") |
| 67 |
|
| 68 |
osd_desc = {} |
| 69 |
osd_desc[1] = _("Fly to the %s system") |
| 70 |
osd_desc[2] = _("Protect Chelsea and help them kill or capture %s") |
| 71 |
|
| 72 |
chelkill_msg = _("MISSION FAILED: A rift in the space-time continuum causes you to have never met Chelsea in that bar.") |
| 73 |
chelflee_msg = _("MISSION FAILED: Chelsea has abandoned the mission.") |
| 74 |
plflee_msg = _("MISSION FAILED: You have abandoned the mission.") |
| 75 |
|
| 76 |
log_text = _([[You helped Chelsea hunt down a wanted pirate, earning a bounty for both of you and allowing Chelsea to acquire a retired Dvaered warlord's old Vigilance.]]) |
| 77 |
|
| 78 |
|
| 79 |
function create () |
| 80 |
local systems = getsysatdistance( system.cur(), 1, 3, |
| 81 |
function(s) |
| 82 |
local p = s:presences()["Pirate"] |
| 83 |
return p ~= nil and p > 0 |
| 84 |
end ) |
| 85 |
|
| 86 |
if #systems == 0 then |
| 87 |
-- No pirates nearby |
| 88 |
misn.finish( false ) |
| 89 |
end |
| 90 |
|
| 91 |
missys = systems[ rnd.rnd( 1, #systems ) ] |
| 92 |
if not misn.claim( missys ) then misn.finish( false ) end |
| 93 |
|
| 94 |
pirname = pirate_name() |
| 95 |
credits = 300000 |
| 96 |
started = false |
| 97 |
|
| 98 |
misn.setNPC( npc_name, "soromid/unique/chelsea" ) |
| 99 |
misn.setDesc( npc_desc ) |
| 100 |
end |
| 101 |
|
| 102 |
|
| 103 |
function accept () |
| 104 |
local txt |
| 105 |
if started then |
| 106 |
txt = text[4]:format( player.name() ) |
| 107 |
else |
| 108 |
txt = text[1]:format( pirname, missys:name(), creditstring( credits ) ) |
| 109 |
end |
| 110 |
started = true |
| 111 |
|
| 112 |
if tk.yesno( title[1], txt ) then |
| 113 |
tk.msg( title[1], text[2]:format( missys:name() ) ) |
| 114 |
misn.accept() |
| 115 |
|
| 116 |
misn.setTitle( misn_title ) |
| 117 |
misn.setDesc( misn_desc:format( missys:name() ) ) |
| 118 |
misn.setReward( creditstring( credits ) ) |
| 119 |
marker = misn.markerAdd( missys, "high" ) |
| 120 |
|
| 121 |
hook.enter( "enter" ) |
| 122 |
hook.jumpout( "leave" ) |
| 123 |
hook.land( "leave" ) |
| 124 |
else |
| 125 |
tk.msg( title[1], text[3] ) |
| 126 |
misn.finish() |
| 127 |
end |
| 128 |
end |
| 129 |
|
| 130 |
|
| 131 |
function enter () |
| 132 |
if system.cur() == missys then |
| 133 |
spawn() |
| 134 |
end |
| 135 |
end |
| 136 |
|
| 137 |
|
| 138 |
function spawn () |
| 139 |
pilot.clear() |
| 140 |
pilot.toggleSpawn( false ) |
| 141 |
player.pilot():setVisible( true ) |
| 142 |
|
| 143 |
-- Spawn pirate |
| 144 |
local r = system.cur():radius() |
| 145 |
local x = rnd.rnd( -r, r ) |
| 146 |
local y = rnd.rnd( -r, r ) |
| 147 |
local p = pilot.add( "Pirate Phalanx", "pirate", vec2.new( x, y ) )[1] |
| 148 |
|
| 149 |
hook.pilot( p, "death", "pirate_death" ) |
| 150 |
p:setHostile() |
| 151 |
p:setVisible( true ) |
| 152 |
p:setHilight( true ) |
| 153 |
|
| 154 |
-- Spawn Chelsea |
| 155 |
chelsea = pilot.addRaw( "Lancelot", "mercenary", lastsys, "Comingout_associates" ) |
| 156 |
chelsea:rmOutfit( "all" ) |
| 157 |
chelsea:rmOutfit( "cores" ) |
| 158 |
chelsea:addOutfit( "Milspec Orion 3701 Core System" ) |
| 159 |
chelsea:addOutfit( "S&K Light Stealth Plating" ) |
| 160 |
chelsea:addOutfit( "Tricon Zephyr II Engine" ) |
| 161 |
chelsea:addOutfit( "TeraCom Fury Launcher" ) |
| 162 |
chelsea:addOutfit( "Fury Missile", 25 ) |
| 163 |
chelsea:addOutfit( "Plasma Blaster MK3", 3 ) |
| 164 |
chelsea:addOutfit( "Reactor Class I", 2 ) |
| 165 |
chelsea:addOutfit( "Milspec Scrambler" ) |
| 166 |
chelsea:addOutfit( "Engine Reroute" ) |
| 167 |
chelsea:addOutfit( "Steering Thrusters" ) |
| 168 |
|
| 169 |
chelsea:setHealth( 100, 100 ) |
| 170 |
chelsea:setEnergy( 100 ) |
| 171 |
chelsea:setTemp( 0 ) |
| 172 |
chelsea:setFuel( true ) |
| 173 |
|
| 174 |
chelsea:setFriendly() |
| 175 |
chelsea:setHilight() |
| 176 |
chelsea:setVisible() |
| 177 |
chelsea:setInvincPlayer() |
| 178 |
chelsea:rename( "Chelsea" ) |
| 179 |
|
| 180 |
hook.pilot( chelsea, "death", "chelsea_death" ) |
| 181 |
hook.pilot( chelsea, "jump", "chelsea_leave" ) |
| 182 |
hook.pilot( chelsea, "land", "chelsea_leave" ) |
| 183 |
end |
| 184 |
|
| 185 |
|
| 186 |
function leave () |
| 187 |
lastsys = system.cur() |
| 188 |
if lastsys == missys then |
| 189 |
fail( plflee_msg ) |
| 190 |
end |
| 191 |
end |
| 192 |
|
| 193 |
|
| 194 |
function chelsea_death () |
| 195 |
fail( chelkill_msg ) |
| 196 |
end |
| 197 |
|
| 198 |
|
| 199 |
function chelsea_leave () |
| 200 |
fail( chelflee_msg ) |
| 201 |
end |
| 202 |
|
| 203 |
|
| 204 |
function pirate_death () |
| 205 |
chelsea:setNoDeath( true ) |
| 206 |
pilot.toggleSpawn( true ) |
| 207 |
hook.timer( 1000, "win_timer" ) |
| 208 |
end |
| 209 |
|
| 210 |
|
| 211 |
function win_timer () |
| 212 |
tk.msg( title[5], text[5]:format( player.name() ) ) |
| 213 |
player.pay( credits ) |
| 214 |
|
| 215 |
local t = time.get():tonumber() |
| 216 |
var.push( "comingout_time", t ) |
| 217 |
|
| 218 |
srm_addComingOutLog( log_text ) |
| 219 |
|
| 220 |
misn.finish( true ) |
| 221 |
end |
| 222 |
|
| 223 |
|
| 224 |
-- Fail the mission, showing message to the player. |
| 225 |
function fail( message ) |
| 226 |
if message ~= nil then |
| 227 |
-- Pre-colourized, do nothing. |
| 228 |
if message:find("\a") then |
| 229 |
player.msg( message ) |
| 230 |
-- Colourize in red. |
| 231 |
else |
| 232 |
player.msg( "\ar" .. message .. "\a0" ) |
| 233 |
end |
| 234 |
end |
| 235 |
misn.finish( false ) |
| 236 |
end |