diff --git a/dat/event.xml b/dat/event.xml
index d52c92fda2..f340ca6984 100644
--- a/dat/event.xml
+++ b/dat/event.xml
@@ -194,4 +194,13 @@
15
player.misnDone("Kidnapped") == false and var.peek("traffic_00_active") == nil and system.cur():name() == "Arcturus"
+
+ neutral/insanebusinessman
+
+
+
+ enter
+ 50
+ player.misnDone("Insane Businessman Part 3") == true and system.cur():name() == "Mason"
+
diff --git a/dat/events/neutral/insanebusinessman.lua b/dat/events/neutral/insanebusinessman.lua
new file mode 100644
index 0000000000..937d322611
--- /dev/null
+++ b/dat/events/neutral/insanebusinessman.lua
@@ -0,0 +1,64 @@
+--[[Insane Businessman ]]--
+
+
+
+-- For Translations
+lang = naev.lang()
+if lang == "es" then
+elseif lang == "de" then
+else
+
+--[[Text of event]]--
+
+title = "Mr. Crumb's Ship"
+msg = [[You board Crumb's ship and overpower his defenses. As you search the ship you uncover a locked safe. Using your trusty blaster, you shoot the safe open and find one million credits. "Not a bad day's work," you say. It seems it pays to associate with billionaires. ]]
+
+end
+
+function create ()
+
+ startsys = system.cur()
+
+ if not evt.claim ( {startsys} ) then
+ evt.finish()
+ end
+
+ spawn_pilot()
+
+ hook.land("land")
+ hook.jumpout("jumpout")
+end
+
+function land()
+ evt.finish()
+end
+
+function jumpout()
+ evt.finish()
+end
+
+function spawn_pilot()
+ pilot = pilot.addRaw( "Gawain", "mercenary" , true, "Dummy")[1]
+ pilot:rename("Mr. Crumb")
+ pilot:control()
+ pilot:runaway( player.pilot(), false )
+ pilot:setHilight( true )
+ hook.pilot( pilot, "jump", "pilot_jump" )
+ hook.pilot( pilot, "death", "pilot_death" )
+ hook.pilot( pilot, "board", "pilot_board")
+end
+
+function pilot_jump()
+ evt.finish()
+end
+
+function pilot_death()
+ evt.finish(true)
+end
+
+function pilot_board()
+ player.unboard()
+ tk.msg(title, msg)
+ player.pay(1000000)
+ evt.finish(true)
+end
diff --git a/dat/mission.xml b/dat/mission.xml
index 7435c2d5e3..0faf60a8cf 100644
--- a/dat/mission.xml
+++ b/dat/mission.xml
@@ -1314,4 +1314,39 @@
Za'lek
+
+ neutral/insanebusinessman/insanebusinessman
+
+
+
+
+ 100
+ Bar
+ Vault
+
+
+
+ neutral/insanebusinessman/insanebusinessman2
+
+
+
+
+ 100
+ Bar
+ Vault
+ Insane Businessman
+
+
+
+ neutral/insanebusinessman/insanebusinessman3
+
+
+
+
+ 100
+ Bar
+ Vault
+ Insane Businessman Part 2
+
+
diff --git a/dat/missions/neutral/insanebusinessman/insanebusinessman.lua b/dat/missions/neutral/insanebusinessman/insanebusinessman.lua
new file mode 100644
index 0000000000..45febffbbc
--- /dev/null
+++ b/dat/missions/neutral/insanebusinessman/insanebusinessman.lua
@@ -0,0 +1,148 @@
+--[[Insane Businessman ]]--
+
+
+
+-- For Translations
+lang = naev.lang()
+if lang == "es" then
+elseif lang == "de" then
+else
+
+--[[Text of mission]]--
+
+npc_name = "A Businessman"
+bar_desc = "An unkempt familiar looking businessman."
+title = "Insane Businessman"
+pre_accept = {}
+
+pre_accept[1] = [[You see an unfastidious man sitting in a dark corner booth. You can't help but think he looks familiar as you watch him throw back drink after drink. Wondering where you might have seen him before, it finally hits you. It's the notorious, well known, and very rich businessman named Daniel Crumb.
+
+You tell the bartender you work as a freelancer and would like to meet Crumb. He sends a busboy over who whispers something to Crumb and subsequently Crumb signals you to come over to the booth. As you approach the booth, you reach out your arm to shake his hand.
+
+"So, you want to work for old Mr. Crumb?" He says, almost mockingly.
+
+"Well, I have a pretty good ship and I can do just about anything."
+
+"Ok. Let's try something easy."
+]]
+
+pre_accept[2] = [["I own some property out in the %s system. I need someone to fly over there to, well, "investigate" some people. Is this something you would be interested in doing?"
+
+"Sure," you reply, then ask "What are the details?"]]
+
+pre_accept[3] = [["Oh, nothing too dangerous. Just some protesters planning a sit in at a house I foreclosed on."
+
+"Protesters? Foreclosure?"
+
+"Yes, like I said, I own property over there. Real nice houses and hotels. I sold a house to an old lady but I guess she couldn't afford her mortgage anymore, so when she stopped paying, I kicked her out. Some protesters got involved and now they don't want to leave. All I need you to do is fly over to the property and get me some information on the what they're up to. Let's see if you can do that, then maybe I'll send you on a more interesting mission. There will be compensation, of course. So what do you say, you still want to work for Crumb?" ]]
+
+decline = [["Ah, well the offers open for you whenever you want. Just look for me here."]]
+
+misn_desc = "Investigate protesters in %s in the %s system"
+reward_desc = "%s credits on completion."
+post_accept = {}
+post_accept[1] = [["Great. Fly over to %s and investigate the protesters."]]
+
+misn_investigate = [[Upon arrival, first thing you do is check the house. It seems to be vacant. Not a soul in sight. You ask some people in the neighborhood and nobody knows anything about any protesters. All they know is that the old lady in the house was evicted over a month ago. She left quietly. This is truly strange. Could Crumb have been misinformed about the protesters?]]
+
+misn_accomplished = [[Crumb awaits you at the spaceport. As you exit your ship, he eagerly rushes up and asks what you found. You frown and take a deep breath before admitting that you uncovered nothing. The property was vacant, the old woman had left.
+
+"Well, no matter, I'll pay you anyway." He says. "I have another lead about the people trying to ruin me."
+
+"Ruin you?" You ask.
+
+"Yes, ruin me. I'll tell you more in a bit. Meet me at the bar."
+]]
+
+
+-- OSD
+
+OSDtitle = "Investigate Protesters"
+OSDdesc1 = "Go to %s in the %s system and investigate protesters on Crumb's property."
+OSDdesc2 = "Return to %s in the %s system and report what you found to Crumb."
+OSDtable = {}
+
+end
+
+function create ()
+
+ startworld, startworld_sys = planet.cur()
+
+ targetworld_sys = system.get("Cygnus")
+ targetworld = planet.get("Jaan")
+
+ if not misn.claim ( {targetworld_sys} ) then
+ abort(false)
+ end
+
+ reward = 10000
+
+ misn.setNPC( npc_name, "neutral/unique/shifty_merchant" )
+ misn.setDesc( bar_desc )
+end
+
+
+function accept ()
+
+ tk.msg( title, pre_accept[1] )
+ tk.msg( title, string.format( pre_accept[2], targetworld_sys:name() ) )
+
+ if not tk.yesno( title, string.format( pre_accept[3], targetworld:name(), targetworld_sys:name() ) ) then
+ tk.msg( title, decline )
+ abort(false)
+ end
+
+ misn.setTitle( title )
+ misn.setReward( string.format( reward_desc, reward ) )
+ misn.setDesc( string.format( misn_desc, targetworld:name(), targetworld_sys:name() ) )
+
+ landmarker = misn.markerAdd( targetworld_sys, "low")
+
+ misn.accept()
+
+ tk.msg( title, string.format( post_accept[1], targetworld:name() ) )
+
+ OSDtable[1] = OSDdesc1:format( targetworld:name(), targetworld_sys:name() )
+ OSDtable[2] = OSDdesc2:format( startworld:name(), startworld_sys:name() )
+ misn.osdCreate( OSDtitle, OSDtable )
+
+ landhook = hook.land("land")
+ takeoffhook = hook.takeoff("takeoff")
+end
+
+function land()
+
+ -- Are we back home and have we landed on target planet at least once?
+ if planet.cur() == startworld and finished then
+ player.pay( reward )
+ tk.msg( title, string.format(misn_accomplished, reward) )
+ abort(true)
+
+ end
+
+ -- Checks to see if at target planet but has not landed there already.
+ if planet.cur() == targetworld and not finished then
+ tk.msg( title, string.format(misn_investigate) )
+ finished = true
+ misn.markerMove(landmarker, startworld_sys)
+ end
+
+
+end
+
+function takeoff ()
+ if finished then
+ misn.osdActive(2)
+ end
+end
+
+function abort(status)
+ hooks = { landhook, takeoffhook }
+ for _, j in ipairs( hooks ) do
+ if j ~= nil then
+ hook.rm(j)
+ end
+ end
+ misn.finish(status)
+ misn.osdDestroy()
+end
diff --git a/dat/missions/neutral/insanebusinessman/insanebusinessman2.lua b/dat/missions/neutral/insanebusinessman/insanebusinessman2.lua
new file mode 100644
index 0000000000..df5bedf472
--- /dev/null
+++ b/dat/missions/neutral/insanebusinessman/insanebusinessman2.lua
@@ -0,0 +1,258 @@
+--[[Insane Businessman Part 2]]--
+
+lang = naev.lang()
+if lang == "es" then
+elseif lang == "de" then
+else
+
+--[[Mission Text]]--
+
+npc_name = "Mr. Crumb"
+bar_desc = "Mr. Crumb, the notorious businessman."
+title = "Insane Businessman Part 2"
+pre_accept = {}
+
+pre_accept[1] = [["Glad you could join me again,"says Crumb. "I'm gonna need you to do some more poking around."]]
+
+pre_accept[2] = [["A former associate of mine, Phillip Samson, has been hanging around the %s system. I don't know what planet, that's something for you to find out. Find him and get him to talk. I know he's involved in the plots against me. Oh, and be sure to equip your ship with disabling weapons. He might get the drop on you and try to run. Samson knows I'm looking for him. But whatever you do, don't kill him, at least until he's talked he, he, he."]]
+
+pre_accept[3] = [["Does this sound like something you could do?" Accept the mission?]]
+
+decline = [["Ah, well some other time maybe..."]]
+
+misn_desc = "Fly to the %s system and find Samson. Once you find him, interrogate him and get him to talk."
+reward_desc = "%s credits on completion."
+post_accept = {}
+post_accept[1] = [["Good, then find Samson in the %s system and get him to talk. I don't care how, just get me some real information."]]
+
+misn_investigate = [[You check out all the local hangouts but turn up nothing. You think you're completely out of luck when at last fortune shines upon you. You're talking to one of your contacts when a man in a suit overhears you.
+
+"Excuse me," he interrupts, "I know Mr. Samson. We ran a hedgefund together some years ago. Just had lunch with him as a matter of fact."
+
+"You do? You did?" The words escape you before you can control yourself. Regaining your composure, you continue,"Tell me, where can I find him?"
+
+"Oh, you can't. He's leaving the planet. Told me someone was looking for him. What a character." The man chuckles not realizing you represent Mr. Crumb, and you both surely know Mr. Crumb means business.
+
+You rush over to the spaceport where you come accross some more good luck. You see a ship take off that matches the description of Samson's ship. You run the identification number through the database and confirm it is Samson. Catch Samson before he escapes!]]
+
+misn_accomplished = [[Once again, Crumb impatiently waits for you at the spaceport. "Well, what did you find out?" He asks, practically the moment you step off your ship.
+
+"Nothing," you say, "Apparently Samson knew nothing of a plot against you."
+
+"Nothing?! Did you talk to him? What did he say?"
+
+"Well," you think twice about telling him what Samson said, but Crumb implores you.
+
+"Tell me! I'm not paying you for nothing." It is true, Crumb is paying you to report on Samson. You may as well tell him the truth.
+
+"Samson said there probably are no plots against you. He said you are paranoid."
+
+"Paranoid! That good for nothing, worthless, son of a...well whatever. Here are your credits. Meet me at the bar if you're interested in helping me uncover this plot to kill me."
+]]
+
+board_title = [[Samson's Ship]]
+board_msg = [[You board Samson's ship and find him cowering in a corner, fumbling with a blaster gun. "Please don't hurt me!" Samson pleads as he drops the blaster and raises his hands.
+
+"I'm not going to hurt you," you reply, "I just want information."
+
+"You want information? For Crumb? What can I say, I don't know anything. Crumb is crazy, he's paranoid!"
+
+"Go on," you demand.
+
+"Well, we used to be partners, friends even. Everything changed when an electrical fire killed three people in one of his hotels. After that, Crumb got paranoid and untrusting. It got even worse when the Empire investigated him for negligence. Now he sends people out to intimidate former associates, no offense."
+
+"None taken," you reply and for some reason, you feel Samson's story is credible, at least if not more credible than Crumb's own conspiracies. Concluding that there is not much else to gain from this conversation you return to your ship wondering what it is you are going to tell Crumb.]]
+
+-- OSD
+
+OSDtitle1 = "Find Samson."
+OSDdesc1 = "Go to the %s system."
+OSDdesc2 = "Find Samson."
+OSDdesc3 = "Catch Samson before he gets away."
+OSDdesc4 = "Return to %s and report to Crumb."
+
+OSDtitle2 = "Catch Samson before he gets away."
+OSDtable1 = {}
+OSDtable2 = {}
+
+OSDtitle3 = "Report to Crumb."
+OSDtable3 = {}
+
+-- Messages
+
+msg = {}
+msg[1] = "MISSION FAILURE! Samson got away."
+msg[2] = "MISSION FAILURE! You killed Samson."
+
+end
+
+function create ()
+
+ startworld, startworld_sys = planet.cur()
+
+ -- Set our target system and planet. Picks a random planet target system
+ targetworld_sys = system.get("Delta Pavonis")
+ targetworlds = {}
+ i = 0
+ for key, planet in ipairs( targetworld_sys:planets() ) do
+ if planet:canLand() then
+ i = i + 1
+ targetworlds[i] = planet
+ end
+ end
+
+ targetworld_number = rnd.rnd(1,i)
+ targetworld = targetworlds[targetworld_number]
+
+ if not misn.claim ( {targetworld_sys} ) then
+ misn.finish()
+ end
+
+ reward = 10000
+
+ misn.setNPC( npc_name, "neutral/unique/shifty_merchant" )
+ misn.setDesc( bar_desc )
+end
+
+
+function accept ()
+
+ -- Some background mission text
+ tk.msg( title, pre_accept[1] )
+ tk.msg( title, string.format( pre_accept[2], targetworld_sys:name() ) )
+
+ if not tk.yesno( title, string.format( pre_accept[3], targetworld:name() ) ) then
+
+ tk.msg( title, decline )
+
+ misn.finish()
+ end
+
+ -- Onboard Computer
+ misn.setTitle( title )
+ misn.setReward( string.format( reward_desc, reward ) )
+ misn.setDesc( string.format( misn_desc, targetworld_sys:name() ) )
+
+ -- Marker
+ landmarker = misn.markerAdd( targetworld_sys, "low")
+
+ misn.accept()
+
+ tk.msg( title, string.format( post_accept[1], targetworld_sys:name() ) )
+
+ -- Set OSD after mission accept
+ OSDtable1[1] = OSDdesc1:format( targetworld_sys:name() )
+ OSDtable1[2] = OSDdesc2
+ misn.osdCreate( OSDtitle1, OSDtable1 )
+ misn.osdActive(1)
+
+
+-- Uncomment this line to reveal the planet Samson is in.
+-- tk.msg( title, targetworld:name() )
+
+ landhook = hook.land("land")
+ takeoffhook = hook.takeoff("takeoff")
+ jumpinhook = hook.jumpin("jumpin")
+end
+
+function land ()
+ -- Are we at our destination and did we find Samson?
+ if planet.cur() == startworld and interrogated then
+ player.pay( reward )
+ tk.msg( title, string.format(misn_accomplished) )
+ abort(true,nil)
+ end
+
+ -- First time we land on secret planet. Samson escapes..
+ if planet.cur() == targetworld and not found then
+ tk.msg( title, string.format(misn_investigate) )
+ found = true
+ player.takeoff()
+ end
+
+ -- If the pilot has spawned and the player lands on a planet before boarding it, the mission fails.
+ if found and spawned and not interrogated then
+ abort(true,1)
+ end
+
+end
+
+function takeoff ()
+ -- Make sure player landed on planet but pilot has not spawned yet. Set OSD. Spawn pilot.
+ if system.cur() == targetworld_sys and found and not spawned then
+ OSDtable2[1] = OSDdesc3
+ misn.osdDestroy()
+ misn.osdCreate( OSDtitle2, OSDtable2 )
+ spawn_pilot()
+ spawned = true
+ hook.rm(takeoffhook)
+ end
+end
+
+-- Moves to the next point on OSD upon jumping into target system
+function jumpin ()
+ if system.cur() == targetworld_sys and not found then
+ misn.osdActive(2)
+ end
+
+ -- Player has landed on planet and pilot has spawned. If player leaves system, mission fails.
+ if found and spawned and not interrogated then
+ abort(false,1)
+ end
+
+end
+
+-- Spawn pilot Samson function
+function spawn_pilot()
+ samson = pilot.addRaw( "Gawain", "mercenary" , targetworld , "Dummy")[1]
+ samson:rename("Samson")
+ samson:control()
+ samson:runaway( player.pilot(), false )
+ samson:setHilight( true )
+ pilotjumphook = hook.pilot( samson, "jump", "pilot_jump" )
+ pilotdeathhook = hook.pilot( samson, "death", "pilot_death" )
+ pilotboardhook = hook.pilot( samson, "board", "pilot_board")
+end
+
+
+--Executes when you disable and board the ship
+function pilot_board()
+ player.unboard()
+ tk.msg(board_title, board_msg)
+ OSDtable3[1] = OSDdesc4:format( startworld_sys:name() )
+ misn.osdCreate( OSDtitle3, OSDtable3 )
+ interrogated = true
+ misn.markerMove(landmarker, startworld_sys)
+ hook.rm(pilotboardhook)
+end
+
+--Executes if pilot jumps out of system
+function pilot_jump ()
+ if not interrogated then
+ abort(false,1)
+ end
+end
+
+--Executes if you kill him before boarding
+function pilot_death()
+ if not interrogated then
+ abort(false,2)
+ end
+end
+
+--Mission fail function.
+function abort(status,param)
+
+ hooks = { landhook, takeoffhook, jumpinhook, pilotjumphook, pilotdeathhook, pilotboardhook }
+ for _, j in ipairs( hooks ) do
+ if j ~= nil then
+ hook.rm(j)
+ end
+ end
+
+ if param then
+ player.msg( msg[param] )
+ end
+ misn.finish( status)
+ misn.osdDestroy()
+end
diff --git a/dat/missions/neutral/insanebusinessman/insanebusinessman3.lua b/dat/missions/neutral/insanebusinessman/insanebusinessman3.lua
new file mode 100644
index 0000000000..24113e0c56
--- /dev/null
+++ b/dat/missions/neutral/insanebusinessman/insanebusinessman3.lua
@@ -0,0 +1,278 @@
+--[[Insane Businessman Part 2]]--
+
+
+
+-- localization stuff.
+lang = naev.lang()
+if lang == "es" then
+elseif lang == "de" then
+else
+
+--[[Mission text.]]--
+
+npc_name = "Mr. Crumb"
+bar_desc = "Mr. Crumb, the notorious businessman."
+title = "Insane Businessman Part 3"
+pre_accept = {}
+
+pre_accept[1] = [["Thank you for speaking to me again,"says Crumb. "Don't feel bad you haven't discovered anything. Not all of us can be great pilots." With a stern look on his face, Crumb continues, "Another pilot has achieved what you could not, %s, he has gotten me information about a plot to kill me. That's ok. Your job now is to rendezvous with this pilot and his two associates in the uninhabited %s system. From there all four of you will travel to %s and await further instructions. Look for your rendezvous near the planet %s."]]
+
+pre_accept[2] = [[You think to yourself that you usually work alone.
+
+Do you take the mission anyway?]]
+
+decline = [["Ah, well some other time maybe..."]]
+
+misn_desc = "Fly to the %s system and find the rendezvous. Once you find him, fly to the %s system and await further instructions."
+reward_desc = "%s credits on completion."
+post_accept = {}
+post_accept[1] = [["Rendezvous with your contact in %s then fly to the %s system and await further instructions."]]
+
+misn_accomplished = [[You land back in %s but Crumb is a difficult person to find. He must have fled knowing that you defeated his mercenaries. However he couldn't have gone far...]]
+
+rendezvous_title = [[Rendezvous]]
+rendezvous_msg = [["%s! We've been waiting for you." says the voice over the comm.
+
+"Great. Let's get going."
+
+"In a minute. There's been a slight change of plans. Mr Crumb has decided that your services are no longer necessary. Sorry about this, pal, it's just business"
+
+click!
+]]
+
+-- OSD
+
+OSDtitle1 = "Find your Rendezvous"
+OSDdesc11 = "Go to the %s system."
+OSDdesc12 = "Find rendezvous."
+OSDdesc13 = "Go to the %s system and await orders."
+
+OSDtitle2 = "Confront Crumb"
+OSDdesc21 = "Return to the %s system and confront Crumb."
+
+OSDtable1 = {}
+OSDtable2 = {}
+
+end
+
+
+-- Messages
+msg = {}
+msg[1] = "MISSION FAILED!!!! Don't attack your rendezvous!"
+msg[2] = "BUG: Could not claim system."
+
+function create ()
+
+ -- Get the planet and system at which we currently are.
+ startworld, startworld_sys = planet.cur()
+
+ -- Set our target system and planet.
+ targetworld_sys = system.get("Haven")
+ targetworld = planet.get("Haven")
+ fake_targetworld_sys = system.get("Alteris")
+
+ if not misn.claim ( {targetworld_sys} ) then
+ abort(false,2)
+ end
+
+ reward = 10000
+
+ -- Used later to determine all mercenaries were killed
+ dead_pilots = 0
+
+ misn.setNPC( npc_name, "neutral/unique/shifty_merchant" )
+ misn.setDesc( bar_desc )
+end
+
+
+function accept ()
+
+ tk.msg( title, string.format( pre_accept[1], player.name(), targetworld_sys:name(), fake_targetworld_sys:name(), targetworld:name() ) )
+
+ if not tk.yesno( title, pre_accept[2] ) then
+
+ tk.msg( title, decline )
+
+ abort(false,nil)
+ end
+
+ misn.setTitle( title )
+ misn.setReward( string.format( reward_desc, reward ) )
+ misn.setDesc( string.format( misn_desc, targetworld_sys:name(), fake_targetworld_sys:name() ) )
+
+ landmarker = misn.markerAdd( targetworld_sys, "low")
+
+ misn.accept()
+
+ tk.msg( title, string.format( post_accept[1], targetworld_sys:name(), fake_targetworld_sys:name() ) )
+
+ OSDtable1[1] = OSDdesc11:format( targetworld_sys:name() )
+ OSDtable1[2] = OSDdesc12
+ OSDtable1[3] = OSDdesc13:format( fake_targetworld_sys:name() )
+ misn.osdCreate( OSDtitle1, OSDtable1 )
+ misn.osdActive(1)
+
+
+ landhook = hook.land("land")
+ jumpouthook = hook.jumpout("jumpout")
+ jumpinhook = hook.jumpin("jumpin")
+end
+
+function land ()
+
+ -- If you land on start planet and have defeated mercenaries
+ if planet.cur() == startworld and victorious then
+
+ tk.msg( title, string.format(misn_accomplished, startworld:name() ) )
+ abort(true,nil)
+ end
+
+end
+
+function jumpout()
+
+ -- If you manage to escape you still win.
+ if system.cur() == targetworld_sys and hailed then
+ victorious = true
+ end
+
+ -- If you jump out before accepting hail, osd returns to first point.
+ if system.cur() == targetworld_sys and not hailed then
+ misn.osdActive(1)
+ end
+
+end
+
+-- Moves to the next point on OSD upon jumping into target system
+function jumpin ()
+ if system.cur() == targetworld_sys and not hailed then
+ misn.osdActive(2)
+ pilot.clear()
+ pilot.toggleSpawn(false)
+ spawn_pilots()
+ timerhook = hook.timer(3000, "timer")
+ end
+end
+
+function timer()
+ pilot1_pos = pilot1:pos()
+ player_pos = player.pilot():pos()
+ distance = player_pos:dist(pilot1_pos)
+ if distance < 3500 then
+ pilot1:hailPlayer()
+ hook.rm(timerhook)
+ hailing = hook.pilot(pilot1, "hail","hailme")
+ else timerhook = hook.timer(3000, "timer")
+ end
+end
+
+-- Spawn pilots function
+function spawn_pilots()
+
+ from_planet = planet.get("Haven")
+
+ pilot1 = pilot.addRaw( "Admonisher", "mercenary" , from_planet , "Dummy")[1]
+ pilot1:rename("Rendezvous")
+ pilot1:setHilight( true )
+ pilot1:control()
+ deathhook1 = hook.pilot( pilot1, "death", "pilot_death" )
+ attackhook1 = hook.pilot( pilot1, "attacked", "pilot_attacked")
+
+ pilot2 = pilot.addRaw( "Admonisher", "mercenary" , from_planet , "Dummy")[1]
+ pilot2:rename("Rendezvous")
+ pilot2:setHilight( true )
+ pilot2:control()
+ deathhook2 = hook.pilot( pilot2, "death", "pilot_death" )
+ attackhook2 = hook.pilot( pilot2, "attacked", "pilot_attacked")
+
+ pilot3 = pilot.addRaw( "Admonisher", "mercenary" , from_planet , "Dummy")[1]
+ pilot3:rename("Rendezvous")
+ pilot3:setHilight( true )
+ pilot3:control()
+ deathhook3 = hook.pilot( pilots, "death", "pilot_death" )
+ attackhook3 = hook.pilot( pilots, "attacked", "pilot_attacked")
+
+end
+
+--If you attack the pilots before answering the hail, they will defend themselves.
+--This is also the function that executes after the hail, setting the pilots hostile.
+function pilot_attacked()
+ if not pilot1:hostile() then
+
+ if pilot1:exists() then
+ pilot1:control()
+ pilot1:setHostile(true)
+ pilot1:attack(player.pilot())
+ pilot1:hailPlayer(false)
+ end
+
+ if pilot2:exists() then
+ pilot2:control()
+ pilot2:setHostile(true)
+ pilot2:attack(player.pilot())
+ end
+
+ if pilot3:exists() then
+ pilot3:control()
+ pilot3:setHostile(true)
+ pilot3:attack(player.pilot())
+ end
+
+ hook.rm(attackhook1)
+ hook.rm(attackhook2)
+ hook.rm(attackhook3)
+
+ if not hailed then
+ abort(false,1)
+ end
+ end
+end
+
+function hailme()
+ player.commClose()
+ tk.msg(rendezvous_title, string.format(rendezvous_msg, player.name()))
+ hook.rm(hailing)
+ hailed = true
+ pilot_attacked()
+ completeOSDSet()
+end
+
+function pilot_death()
+ -- Counts how many pilots have been killed
+ if dead_pilots < 3 then
+ dead_pilots = dead_pilots + 1
+ end
+
+ -- If all three pilots killed, you succeed.
+ if hailed and dead_pilots == 3 then
+ victorious = true
+ hook.rm(deathhook1)
+ hook.rm(deathhook2)
+ hook.rm(deathhook3)
+ end
+end
+
+--This function handles moving the OSD and map marker.
+function completeOSDSet()
+ misn.osdDestroy ()
+ OSDtable2[1] = OSDdesc21:format( startworld_sys:name() )
+ misn.osdCreate( OSDtitle2, OSDtable2 )
+ misn.markerMove(landmarker, startworld_sys)
+end
+
+--Mission fail function
+function abort(status,param)
+ if param then
+ player.msg( msg[param] )
+ end
+
+ hooks = { landhook, jumpouthook, jumpinhook, timerhook, hailing, attackhook1, attackhook2, attackhook3, deathhook1, deathhook2, deathhook3 }
+ for _, j in ipairs( hooks ) do
+ if j ~= nil then
+ hook.rm(j)
+ end
+ end
+
+ misn.finish( status )
+ misn.osdDestroy()
+end