function introduction()
	msnMgr:addHeader("Although your mission isn't a scientific one, there are a number of stellar and interstellar phenomenon you have been programmed to observe and study should the opportunity arise.")
	msnMgr:addHeader(" ")
	msnMgr:addHeader("Possible benefits range from expanding the boundaries of human knowledge to discoveries that may lead to improvement of ship systems. Keeping the crew entertained never hurt either.")
	msnMgr:addHeader(" ")

	if (msnMgr:hasQuestItem("starvation_cryo_active") == true) then
		msnMgr:addMessage("Long range sensors didn't pick it up. The first indication you had was when it became visible on the ship's external cameras. You wake the crew and call them into the shuttle to discuss.")
		msnMgr:addMessage(" ")
	else
		discoveryType = msnMgr:random() % 4
		if (discoveryType == 0) then
			--Spotted by you on long range sensors
			msnMgr:addMessage("Long range sensors picked it up a day ago, and you have been monitoring its progess since to see how closely its trajectory aligns with the ship's. You call the crew into the shuttle to discuss.")
			msnMgr:addMessage(" ")
		elseif (discoveryType == 1) then
			--Spotted by you through visual observation
				msnMgr:addMessage("Long range sensors didn't pick it up. The first indication you had was when it came into view on the ship's external cameras. You call the crew into the shuttle to discuss.")
				msnMgr:addMessage(" ")
		elseif (discoveryType == 2) then
			--Spotted by crew on long range sensors
			discoveryCrew = charMgr:randomCrew()
			discoveryCrewName = charMgr:getCharColoredName(discoveryCrew)
			if (charMgr:depCrewLeft() > 1) then
				msnMgr:addMessage("Long range sensors picked it up a day ago, but it took " .. discoveryCrewName .. "'s curiosity to notice that there was something worth investigating. You call the crew into the shuttle to discuss.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("Long range sensors picked it up a day ago, but it took " .. discoveryCrewName .. "'s curiosity to notice that there was something worth investigating.")
				msnMgr:addMessage(" ")
			end
		elseif (discoveryType == 3) then
			--Spotted by crew through visual observation
			discoveryCrew = charMgr:randomCrew()
			discoveryCrewName = charMgr:getCharColoredName(discoveryCrew)
			if (charMgr:depCrewLeft() > 1) then
				msnMgr:addMessage("Long range sensors didn't pick it up. The first indication you had was " .. discoveryCrewName .. " calling the rest of the crew into the shuttle to see it.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("Long range sensors didn't pick it up. The first indication you had was " .. discoveryCrewName .. " watching from the shuttle's main viewport.")
				msnMgr:addMessage(" ")
			end
		else
			msnMgr:addMessage("Long range sensors didn't pick it up. The first indication you had was when it became visible on the ship's external cameras. You call the crew into the shuttle to discuss.")
			msnMgr:addMessage(" ")
		end
	end

	phenomenonType = getPhenomenonType()
	phenomenonName = getPhenomenonName()
	if (phenomenonType == -1) then
		-- false alarm, there's nothing in our phenomenon list, so we should leave. Getting here shouldn't be possible
		msnMgr:addMessage("When you look though, you see nothing, and are confused about how this side-mission ended up in this state.")
		msnMgr:addMessage(" ")
	elseif (phenomenonType == 0) then
		-- black hole
		if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1])) then
			msnMgr:addMessage("Faintly visible in the distance is the faint lensing effect of another small black hole.")
			msnMgr:addMessage(" ")
		else
			msnMgr:addMessage("Faintly visible in the distance is the faint lensing effect of a small black hole.")
			msnMgr:addMessage(" ")
		end
	elseif (phenomenonType == 1) then
		-- Neutron star
		msnMgr:addMessage("In the distance is an almost intensely blue-white neutron star surrounded by the fading remnants of a past supernova.")
		msnMgr:addMessage(" ")
	elseif (phenomenonType == 2) then
		-- Unusual coronal mass ejection
		msnMgr:addMessage("In the distance is an increasingly active star, spitting plasma off into space.")
		msnMgr:addMessage(" ")
	elseif (phenomenonType == 3) then
		-- transsolar object
		if (phenomenonTypeType == 0) then
			msnMgr:addMessage("In the distance is the illuminated trail of a comet.")
			msnMgr:addMessage(" ")
		elseif (phenomenonTypeType == 1) then
			msnMgr:addMessage("In the distance is an asteroid tumbling through space.")
			msnMgr:addMessage(" ")
		elseif (phenomenonTypeType == 2) then
			msnMgr:addMessage("In the distance is an oddly shaped object tumbling through space.")
			msnMgr:addMessage(" ")
		elseif (phenomenonTypeType == 3) then
			msnMgr:addMessage("In the distance is an oddly shaped object tumbling through space.")
			msnMgr:addMessage(" ")
		end
	else
		-- unknown mystery stuff (shouldn't be possible, handling unhandled stuff)
		msnMgr:addMessage("The object matches no known stellar or interstellar phenomena or events. Both you and the crew are at a loss to explain what it could be.")
		msnMgr:addMessage(" ")
	end

	waitUserResponse("Perform a cursory inspection")
	msnMgr:addMessage(" ")
end

function getPhenomenonType()
	availablePhenomena = {}
	phenomenaCount = 0

	-- Turns out that Lua doesn't have a reliable getSize() for tables. Hooray
	for key, value in pairs(phenomenonList) do
		phenomenaCount = phenomenaCount + 1
	end
	if (phenomenaCount > 0) then
		return msnMgr:random() % phenomenaCount
	else
		return -1
	end
end

function investigateOrNot()
	if (phenomenonType == 0) then
		-- black hole
		if (msnMgr:random() % 10 > 3) then
			if (phenomenonTypeType == 0) then
				msnMgr:addMessage("Black holes with smaller than stellar mass have been theorised about since the late 1900s, but detecting and observing them in the wild has proven difficult for humans. This particular specimen is small enough to not represent a gravitational threat to the ship.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("Black holes with smaller than stellar mass have been theorised about since the late 1900s, but detecting and observing them in the wild has proven difficult for humans. This particular specimen is large, but observations should be possible from a distance that does not represent a threat to the ship.")
				msnMgr:addMessage(" ")
			end
			fuelCost = 2 + (msnMgr:random() % 8)
			if (ship:getFuel() > fuelCost + 2) then
				msnMgr:addMessage("Gravitational forces will require a degree of fuel expenditure though.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("Gravitational forces will require a degree of fuel expenditure in excess of current reserves.")
				msnMgr:addMessage(" ")
				investigation = -1
			end
		else
			msnMgr:addMessage("Upon closer inspection, it appears that the lensing was caused by a combination of light refraction through stellar gas pockets and a mirrored pattern of star formations. While it is certainly an unexpected curiosity, there is nothing to learn here.")
			msnMgr:addMessage(" ")
			investigation = -2
		end
	elseif (phenomenonType == 1) then
		-- Neutron star
		if (msnMgr:random() % 10 > 3) then
			msnMgr:addMessage("Neutron stars being formed by the gravitational collapse of the cores of massive stars following supernova explosions have been observed from great distances since the mid 1900s, but intense gravity and radiation have made opportunities for close study rare. The ship is capable of withstanding more of both than most of the probes humans sent out.")
			msnMgr:addMessage(" ")

			fuelCost = 2 + (msnMgr:random() % 6)
			if (ship:getFuel() > fuelCost + 2) then
				msnMgr:addMessage("Gravitational forces will require a degree of fuel expenditure though.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("Gravitational forces will require a degree of fuel expenditure in excess of current reserves.")
				msnMgr:addMessage(" ")
				investigation = -1
			end
		else
			msnMgr:addMessage("Upon closer inspection, the fading supernova remnants are what they appear to be, but the neutron star turns out to be an unexpectedly parabolic surface made of reflective material that happens to be focusing radiation from a number of sources on the ship. While it is certainly an unexpected curiosity, there is nothing to learn here.")
			msnMgr:addMessage(" ")
			investigation = -2
		end
	elseif (phenomenonType == 2) then
		-- Unusual coronal mass ejection
		if (msnMgr:random() % 10 > 3) then
			msnMgr:addMessage("Coronal mass ejection events and associated flares have been observed as far back as the 1800s, but nothing as intense as what appears to be brewing here. You calculate that the star will soon generate events in excess of both Carrington class and Frederikson class storms by several orders of magnitude.")
			msnMgr:addMessage(" ")
		else
			msnMgr:addMessage("Upon closer inspection, the sunspots begin to fade and mass ejection events subside to typical levels for solar minima activity. You're uncertain of what triggered this, and further observations reveal nothing. While it is certainly an unexpected curiosity, there is nothing to learn here.")
			msnMgr:addMessage(" ")
			investigation = -2
		end
	elseif (phenomenonType == 3) then
		-- transsolar object
		if (phenomenonTypeType == 0) then
			msnMgr:addMessage("Comets have proven tricky to interact with directly, as the thermal processes that release the comets' coma and jets are also likely to lead to structural instability. After a series of unfortunate missions, Humans eventually discovered that harvesting matter from tails was a safer approach.")
			msnMgr:addMessage(" ")
		elseif (phenomenonTypeType == 1) then
			msnMgr:addMessage("Humans have long observed asteroids, and even had successful mining operations on a number of larger asteroids in the Sol system. Determining their composition and whether they contain anything useful has always been difficult, however this asteroid appears to have been involved in some kind of collision and is dragging a trail of debris.")
			msnMgr:addMessage(" ")
		elseif (phenomenonTypeType == 2) then
			msnMgr:addMessage("The object's nature is difficult to identify. Its trajectory indicates that its origins lie well beyond the local solar system, and is likely trans-galactic.")
			msnMgr:addMessage(" ")
		elseif (phenomenonTypeType == 3) then
			msnMgr:addMessage("The object's nature is difficult to identify. Its trajectory indicates that its origins lie well beyond the local solar system, and is likely trans-galactic.")
			msnMgr:addMessage(" ")
		end
		fuelCost = 2 + (msnMgr:random() % 4)
		if (ship:getFuel() > fuelCost + 2) then
			msnMgr:addMessage("The object is moving at significant speeds. Catching up will require a degree of fuel expenditure.")
			msnMgr:addMessage(" ")
		else
			msnMgr:addMessage("The object is moving at significant speeds. Catching up will require a degree of fuel expenditure in excess of current reserves.")
			msnMgr:addMessage(" ")
			investigation = -1
		end
	else
		-- unknown mystery stuff (shouldn't be possible, handling unhandled stuff)
		msnMgr:addMessage("The object appears stationary, but its nature is still unclear.")
		msnMgr:addMessage(" ")
	end

	if (investigation >= 0) then
		tempString = charMgr:getCharColoredName(charMgr:randomCrew())
		if (charMgr:depCrewLeft() > 1) then
			tempString = "the crew"
		end

		-- is the crew's general attitude excited or disinterested?
		excited = 0
		if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1])) then
			if (msnMgr:random() % 10 >= 5) then
				excited = 1
				msnMgr:addMessage("Even though this isn't their first encounter with something like this, " .. tempString .. " still seems enthusiastic about the idea of taking time out for research.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("Whether it's because they feel like they've seen this before, or because they're keen to keep moving, " .. tempString .. " seems less enthusiastic about the idea of taking time out for research.")
				msnMgr:addMessage(" ")
			end
		else
			excited = 1
			msnMgr:addMessage("The prospects of taking time out to research something new seem to excite " .. tempString .. ". \"I've never seen anything like this,\" says " .. charMgr:getCharColoredName(charMgr:randomCrew()) .. ".")
			msnMgr:addMessage(" ")
		end

		-- Pick two crewmembers to speak and have them comment
		firstCommenter = charMgr:randomCrew()
		secondCommenter = -1
		if (charMgr:depCrewLeft() > 1) then
			secondCommenter = charMgr:randomCrewIgnoringCrew(firstCommenter)
		end

		firstCommenterRole = crewComment(firstCommenter, excited, "")
		secondCommenterRole = ""
		if (secondCommenter ~= -1 and secondCommenter ~= discoveryCrew) then
			-- if there's a second person, make sure they don't say the same thing
			secondCommenterRole = crewComment(secondCommenter, excited, firstCommenterRole)
		end

		if (discoveryCrew ~= -1) then
			-- discovered by crew
			discoveryCrewName = charMgr:getCharColoredName(discoveryCrew)
			if (namedByCrew) then
				if (charMgr:depCrewLeft() > 1 and msnMgr:random() % 10 >= 5 and excited == 1) then
					msnMgr:addMessage(discoveryCrewName .. " makes a point of telling everybody that they discovered it and have \"naming rights.\"")
					msnMgr:addMessage(" ")
				else
					if (excited == 1) then
						msnMgr:addMessage("\"Dibs on naming it,\" says " .. discoveryCrewName .. ".")
						msnMgr:addMessage(" ")
					else
						msnMgr:addMessage("\"I'm naming it, I guess\" says " .. discoveryCrewName .. ".")
						msnMgr:addMessage(" ")
					end
				end
			end
		else
			-- discovered by you
		end

		msnMgr:buildChoice("Investigate")
		msnMgr:buildChoice("Ignore")

		msnMgr:finalizeChoice()
		if (not waitUserInput(choices)) then
			return
		end

		investigation = msnMgr:getChoiceResponse(choices)
		choices = choices + 1

		msnMgr:addMessage(" ")
	else

	end
end

function approach()
	if (fuelCost > 0) then
		ship:adjustFuel(fuelCost * -1)
	end

	if (phenomenonType == 0) then
		-- Black hole
		msnMgr:addMessage("You plot a course into an orbit a safe distance out from the black hole.")
		msnMgr:addMessage(" ")
		-- Describe its mass a bit, describe initial impressions
		studyFoodCost = 3 + (msnMgr:random() % 5)
		if (ship:getFood() > studyFoodCost + 2) then
			msnMgr:addMessage("A more detailed study is possible, but it'll take time--time during which the crew will need to eat.")
			msnMgr:addMessage(" ")
		else
			msnMgr:addMessage("A more detailed study would be possible, but it'd take time--time that adds up to more food than the ship's reserves currently hold.")
			msnMgr:addMessage(" ")
			studyOrNot = -1
		end
	elseif (phenomenonType == 1) then
		-- Neutron star
		msnMgr:addMessage("You plot a course into an orbit a safe distance out from the neutron star.")
		msnMgr:addMessage(" ")
		-- Describe its mass a bit, describe initial impressions
		studyFoodCost = 1 + (msnMgr:random() % 3)
		if (ship:getFood() > studyFoodCost + 2) then
			msnMgr:addMessage("A more detailed study is possible, but it'll take a few days--time during which the crew will need to eat.")
			msnMgr:addMessage(" ")
		else
			msnMgr:addMessage("A more detailed study would be possible, but it'd take a few days--time that adds up to more food than the ship's reserves currently hold.")
			msnMgr:addMessage(" ")
			studyOrNot = -1
		end
	elseif (phenomenonType == 2) then
		-- Unusual coronal mass ejection
		msnMgr:addMessage("You plot a course into a synchronous orbit that keeps the most active sunspots visible without putting the ship directly in the path of the predicted CMEs and flares.")
		msnMgr:addMessage(" ")
		studySensorCost = 0.25
		if (ship:getSensors() >= 2.25) then
			msnMgr:addMessage("A more detailed study is possible, but it will require modification to some of the ship's sensors, which will reduce their general efficiency for normal operation.")
			msnMgr:addMessage(" ")
		else
			msnMgr:addMessage("A more detailed study would possible, but it'd require destructive modification to some of the ship's sensors, which would leave the ship incapable of normal operation.")
			msnMgr:addMessage(" ")
			studyOrNot = -1
		end
	elseif (phenomenonType == 3) then
		-- transsolar object
		if (msnMgr:random() % 10 >= 3) then
			studyEngineCost = 0.0125
			if (ship:getEngineSpeed() >= .05) then
				if (phenomenonTypeType == 0) then
					msnMgr:addMessage("A more detailed study could be conducted by maneuvering the ship into the comet's coma and alongside its tail, close enough for external drones to capture samples as outgassing releases ice and debris from the comet nucleus.")
					msnMgr:addMessage(" ")
				elseif (phenomenonTypeType == 1) then
					msnMgr:addMessage("A more detailed study could be conducted by maneuvering the ship alongside the asteroid, close enough for external drones to capture samples of debris trailing it.")
					msnMgr:addMessage(" ")
				elseif (phenomenonTypeType == 2) then
					msnMgr:addMessage("A more detailed study could be conducted by maneuvering the ship alongside the object, close enough for external drones to drill core samples.")
					msnMgr:addMessage(" ")
				elseif (phenomenonTypeType == 3) then
					msnMgr:addMessage("A more detailed study could be conducted by maneuvering the ship alongside the object, close enough for external drones to inspect the surface.")
					msnMgr:addMessage(" ")
				end
				msnMgr:addMessage("The fuel expended so far isn't enough to catch up to the object, but you could reach it by burning the engines above maximum capacity for a short period, risking possible damage to the engines.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("A more detailed study would be possible, but it'd require running the engines harder than they could handle in their current condition.")
				msnMgr:addMessage(" ")
				studyOrNot = -1
			end
		else
			msnMgr:addMessage("A more detailed study should be possible without expending further resources.")
			msnMgr:addMessage(" ")
		end
	else
		-- unknown mystery stuff (shouldn't be possible, handling unhandled stuff)
		msnMgr:addMessage("A continued observations should be possible without expending further resources, but you find it hard to imagine what kind of observations might shed light on what this is.")
		msnMgr:addMessage(" ")
	end

	if (studyOrNot >= 0) then
		msnMgr:buildChoice("Study")
		msnMgr:buildChoice("Abandon")

		msnMgr:finalizeChoice()
		if (not waitUserInput(choices)) then
			return
		end

		studyOrNot = msnMgr:getChoiceResponse(choices)
		choices = choices + 1

		msnMgr:addMessage(" ")
	end
end

function study()
	-- Resolve out study costs
	if (studyFuelCost > 0) then
		ship:adjustFuel(studyFuelCost * -1)
	end
	if (studyFoodCost > 0) then
		ship:adjustFood(studyFoodCost * -1)
	end
	if (studySensorCost > 0.0) then
		if (phenomenonType == 0) then
			-- black hole
			ship:adjustSensors(studySensorCost * -1, "While studying black hole " .. phenomenonName .. ", sensor damage was sustained.")
		elseif (phenomenonType == 1) then
			-- Neutron star
			ship:adjustSensors(studySensorCost * -1, "While studying neutron star " .. phenomenonName .. ", sensor damage was sustained.")
		elseif (phenomenonType == 2) then
			-- Unusual coronal mass ejection
			ship:adjustSensors(studySensorCost * -1, "While studying unusual coronal mass ejection events from " .. phenomenonName .. ", sensor damage was sustained.")
		elseif (phenomenonType == 3) then
			-- transsolar object
			--TODO: Add more detailed descriptions for different phenomenonTypeTypes
			ship:adjustSensors(studySensorCost * -1, "While studying interstellar object " .. phenomenonName .. ", sensor damage was sustained.")
		else
			-- unknown mystery stuff (shouldn't be possible, handling unhandled stuff)
			ship:adjustSensors(studySensorCost * -1, "While studying stellar phenomenon " .. phenomenonName .. ", sensor damage was sustained.")
		end
	end
	if (studyEngineCost > 0.0) then
		if (phenomenonType == 0) then
			-- black hole
			ship:adjustEngineSpeed(studyEngineCost * -1, "While studying black hole " .. phenomenonName .. ", engine damage was sustained.")
		elseif (phenomenonType == 1) then
			-- Neutron star
			ship:adjustEngineSpeed(studyEngineCost * -1, "While studying neutron star " .. phenomenonName .. ", engine damage was sustained.")
		elseif (phenomenonType == 2) then
			-- Unusual coronal mass ejection
			ship:adjustEngineSpeed(studyEngineCost * -1, "While studying unusual coronal mass ejection events from " .. phenomenonName .. ", engine damage was sustained.")
		elseif (phenomenonType == 3) then
			-- transsolar object
			--TODO: Add more detailed descriptions for different phenomenonTypeTypes
			ship:adjustEngineSpeed(studyEngineCost * -1, "While studying interstellar object " .. phenomenonName .. ", engine damage was sustained.")
		else
			-- unknown mystery stuff (shouldn't be possible, handling unhandled stuff)
			ship:adjustEngineSpeed(studyEngineCost * -1, "While studying stellar phenomenon " .. phenomenonName .. ", engine damage was sustained.")
		end
	end

	if (phenomenonType == 0) then
		-- black hole
		if (phenomenonTypeType == 0) then
			msnMgr:addMessage("You train the ship's sensors on the event horizon of the black hole, and study Hawking radiation emissions over a period of weeks, observing its evaporation. You calculate it to be very close to the end of its lifespan.")
			msnMgr:addMessage(" ")
		else
			msnMgr:addMessage("You train the ship's sensors on the event horizon of the black hole, and study Hawking radiation emissions over a period of weeks, observing its growth. You calculate it to be over 10 billion years old.")
			msnMgr:addMessage(" ")
		end

		--TODO: Crew reactions

		if (phenomenonTypeType == 0) then
			msnMgr:addMessage("Eventually, the black hole completes its evaporation in a burst of gamma rays.")
			msnMgr:addMessage(" ")
		else
			msnMgr:addMessage("Eventually, the black hole consumes all the nearby matter that doesn't have a stable enough orbit to avoid being consumed within the crew's lifetime.")
			msnMgr:addMessage(" ")
		end
	elseif (phenomenonType == 1) then
		-- Neutron star
		msnMgr:addMessage("You train the ship's sensors on the neutron star for several days, observing its spin and pulses. You calculate it to have been formed from a star with a mass in excess of ten times Sol.")
		msnMgr:addMessage(" ")

		msnMgr:addMessage("Eventually, you exhaust the meaningful observations that you expect to make.")
		msnMgr:addMessage(" ")
	elseif (phenomenonType == 2) then
		-- Unusual coronal mass ejection
		msnMgr:addMessage("You train the ship's sensors on the sunspots for several days, observing plumes of plasma as they are ejected into space. Accompanying flares, shifts in the star's magnetic field, and cosmic rays exceed any previous events recorded in your databases.")
		msnMgr:addMessage(" ")

		msnMgr:addMessage("Eventually, solar activity begins to subside.")
		msnMgr:addMessage(" ")
	elseif (phenomenonType == 3) then
		-- transsolar object
		if (phenomenonTypeType == 0) then
			msnMgr:addMessage("Eventually, the drones have collected enough material from the comet's tail for reasonable study.")
			msnMgr:addMessage(" ")
		elseif (phenomenonTypeType == 1) then
			msnMgr:addMessage("Eventually, the drones have collected enough asteroidal debris for reasonable study.")
			msnMgr:addMessage(" ")
		elseif (phenomenonTypeType == 2) then
			msnMgr:addMessage("Eventually, the drones have collected enough material from beneath the object's surface for reasonable study.")
			msnMgr:addMessage(" ")
		elseif (phenomenonTypeType == 3) then
			msnMgr:addMessage("Eventually, the drones clear enough dust and debris away to reveal some kind of ancient probe beneath, complete with sensors, engines, and transmitters.")
			msnMgr:addMessage(" ")
		end
	else
		-- unknown mystery stuff (shouldn't be possible, handling unhandled stuff)
		msnMgr:addMessage("Eventually, you give up.")
		msnMgr:addMessage(" ")
	end

end

function analysis()

	--TODO: Adjust outcomes based on difficulty

	waitUserResponse("Analyse the collected data")
	msnMgr:addMessage(" ")

	if (phenomenonType == 0) then
		-- black hole
		if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1]) ~= true) then
			msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1])
		end


		temp = msnMgr:random() % 10
		if (temp > 7) then
			if (phenomenonTypeType == 0) then
				msnMgr:addMessage("The data collected is revealing, but not practically usable. The remains of the black hole include a small amount of dark matter that you are able to collect to use as fuel and replenish reserves.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("The data collected is revealing, but not practically usable. Fortunately, you locate small amounts of dark matter in the vicinity that you are able to collect to use as fuel and replenish reserves.")
				msnMgr:addMessage(" ")
			end
			ship:adjustFuel(2 + msnMgr:random() % 8)
		elseif (temp > 5) then
			msnMgr:addMessage("The data collected is revealing, and provides some possible means of improving ships' sensor efficiency by a small amount.")
			msnMgr:addMessage(" ")
			ship:adjustSensors(0.25, "Analysis of research gathered from black hole " .. phenomenonName .. " allowed sensor range to be increased.")

			luaMgr:unlockAchievement("researcher1");
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_0") ~= true) then
				msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_0")
			end

		elseif (temp > 3) then
			msnMgr:addMessage("The data collected is revealing, and provides some possible means of improving ships' engine output by a small amount.")
			msnMgr:addMessage(" ")
			ship:adjustEngineSpeed(0.0125, "Analysis of research gathered from black hole " .. phenomenonName .. " allowed engine speed to be increased.")

			luaMgr:unlockAchievement("researcher1");
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_1") ~= true) then
				msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_1")
			end

		else
			msnMgr:addMessage("The data collected is revealing, but not practically usable.")
			msnMgr:addMessage(" ")
		end

		--TODO: Describe putting the research to practical use?

	elseif (phenomenonType == 1) then
		-- Neutron star
		if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1]) ~= true) then
			msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1])
		end

		temp = msnMgr:random() % 10
		if (temp > 7) then
			msnMgr:addMessage("The data collected is revealing, but not practically usable. Before departing, a dense cloud of organic matter in an extreme orbit passes close enough by to collect, which you are able to use to replenish food stores.")
			msnMgr:addMessage(" ")
			ship:adjustFood(2 + msnMgr:random() % 6)
		elseif (temp > 5) then
			msnMgr:addMessage("The data collected is revealing, and provides some possible means of improving ships' sensor efficiency by a small amount.")
			msnMgr:addMessage(" ")
			ship:adjustSensors(0.25, "Analysis of research gathered from neutron star " .. phenomenonName .. " allowed sensor range to be increased.")

			luaMgr:unlockAchievement("researcher1");
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_0") ~= true) then
				msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_0")
			end

		elseif (temp > 3) then
			msnMgr:addMessage("The data collected is revealing, and provides some possible means of improving ships' engine output by a small amount.")
			msnMgr:addMessage(" ")
			ship:adjustEngineSpeed(0.0125, "Analysis of research gathered from neutron star " .. phenomenonName .. " allowed engine speed to be increased.")

			luaMgr:unlockAchievement("researcher1");
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_1") ~= true) then
				msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_1")
			end

		else
			msnMgr:addMessage("The data collected is revealing, but not practically usable.")
			msnMgr:addMessage(" ")
		end

		--TODO: Describe putting the research to practical use?



	elseif (phenomenonType == 2) then
		-- Unusual coronal mass ejection
		if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1]) ~= true) then
			msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1])
		end

		temp = msnMgr:random() % 10
		if (temp > 7) then
			msnMgr:addMessage("The data collected is revealing, and provides some possible means of improving ships' sensor efficiency by a moderate amount.")
			msnMgr:addMessage(" ")
			ship:adjustSensors(0.75, "Analysis of research gathered on coronal mass ejections from " .. phenomenonName .. " allowed sensor range to be increased beyond reductions caused by previous damage.") -- We've already spend 0.25, so this is an effective increase of 0.5

			luaMgr:unlockAchievement("researcher1");
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_0") ~= true) then
				msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_0")
			end

		elseif (temp > 5) then
			msnMgr:addMessage("The data collected is revealing, but not practically usable. Before departing, you use some of the solar radiation to power a fuel gathering process that is only possible when so close to a star.")
			msnMgr:addMessage(" ")
			ship:adjustFuel(6 + msnMgr:random() % 12)
		elseif (temp > 3) then
			msnMgr:addMessage("The data collected is revealing, and provides some possible means of improving ships' engine output by a small amount.")
			msnMgr:addMessage(" ")
			ship:adjustEngineSpeed(0.0125, "Analysis of research gathered on coronal mass ejections from " .. phenomenonName .. " allowed engine speed to be increased.")

			luaMgr:unlockAchievement("researcher1");
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_1") ~= true) then
				msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_1")
			end

		else
			msnMgr:addMessage("The data collected is revealing, but not practically usable.")
			msnMgr:addMessage(" ")
		end

		--TODO: Describe putting the research to practical use?
	elseif (phenomenonType == 3) then
		-- transsolar object
		if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1]) ~= true) then
			msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1])
		end

		temp = msnMgr:random() % 10
		if (temp > 7) then
			if (phenomenonTypeType == 0) then
				msnMgr:addMessage("The data collected is revealing, and analysis of the comet's unusual interaction with local gravity provides some possible means of improving ships' engine output by a moderate amount.")
				msnMgr:addMessage(" ")
				ship:adjustEngineSpeed(0.025, "Analysis of research gathered from comet " .. phenomenonName .. " allowed engine speed to be increased.")

				luaMgr:unlockAchievement("researcher1");
				if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_0") ~= true) then
					msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_0")
				end

			elseif (phenomenonTypeType == 1) then
				msnMgr:addMessage("The data collected is revealing, and analysis of the asteroid's unusual interaction with local gravity provides some possible means of improving ships' engine output by a moderate amount.")
				msnMgr:addMessage(" ")
				ship:adjustEngineSpeed(0.025, "Analysis of research gathered from asteroid " .. phenomenonName .. " allowed engine speed to be increased.")

				luaMgr:unlockAchievement("researcher1");
				if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_1") ~= true) then
					msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_1")
				end

			elseif (phenomenonTypeType == 2) then
				msnMgr:addMessage("The data collected is revealing, and analysis of the object's unusual interaction with local gravity provides some possible means of improving ships' engine output by a moderate amount.")
				msnMgr:addMessage(" ")
				ship:adjustEngineSpeed(0.025, "Analysis of research gathered from object " .. phenomenonName .. " allowed engine speed to be increased.")

				luaMgr:unlockAchievement("researcher1");
				if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_2") ~= true) then
					msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_2")
				end

			else--if (phenomenonTypeType == 3) then
				msnMgr:addMessage("The observational data collected is revealing, but not practically usable. Although the probe's engines stopped functioning long ago, you are able to use components to boost engine output dramatically.")
				msnMgr:addMessage(" ")
				ship:adjustEngineSpeed(0.05, "Components salvaged from ancient probe " .. phenomenonName .. " allowed engine speed to be increased.")

				luaMgr:unlockAchievement("researcher1");
				if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_3") ~= true) then
					msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_3")
				end

			end
		elseif (temp > 5) then
			if (phenomenonTypeType == 0) then
				msnMgr:addMessage("The data collected is revealing, but not practically usable. After analysis, you are able to convert samples taken from debris within the comet's tail into a small amount of fuel.")
				msnMgr:addMessage(" ")
				ship:adjustFuel(2 + msnMgr:random() % 4)
			elseif (phenomenonTypeType == 1) then
				msnMgr:addMessage("The data collected is revealing, but not practically usable. After analysis, you are able to convert samples taken from debris trailing the asteroid into a small amount of fuel.")
				msnMgr:addMessage(" ")
				ship:adjustFuel(2 + msnMgr:random() % 4)
			elseif (phenomenonTypeType == 2) then
				msnMgr:addMessage("The data collected is revealing, but not practically usable. After analysis, you are able to convert samples taken from the object into a small amount of fuel.")
				msnMgr:addMessage(" ")
				ship:adjustFuel(2 + msnMgr:random() % 4)
			else--if (phenomenonTypeType == 3)
				msnMgr:addMessage("The data collected is revealing, but not practically usable.")
				msnMgr:addMessage(" ")
			end
		elseif (temp > 3) then
			if (phenomenonTypeType == 3) then

				luaMgr:unlockAchievement("researcher1");
				if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_4") ~= true) then
					msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_research_4")
				end

				if (msnMgr:random() % 10 >= 5) then
					msnMgr:addMessage("The observational data collected is revealing but not practically usable. Although the probe's sensors stopped functioning long ago, you are able to use its components to boost sensor range dramatically.")
					msnMgr:addMessage(" ")
					ship:adjustSensors(0.5, "Components salvaged from ancient probe " .. phenomenonName .. " allowed sensor range to be increased.")
				else
					msnMgr:addMessage("The observational data collected is revealing but not practically usable. Although the probe's sensors stopped functioning long ago, you are able to cannibalize components to improve sensor performance dramatically.")
					msnMgr:addMessage(" ")
					ship:adjustSensors(0.5, "Components salvaged from ancient probe " .. phenomenonName .. " allowed sensor range to be increased.")
				end
			else
				msnMgr:addMessage("The data collected is revealing, but not practically usable.")
				msnMgr:addMessage(" ")
			end
		else
			msnMgr:addMessage("The data collected is revealing, but not practically usable.")
			msnMgr:addMessage(" ")
		end

		--TODO: Describe putting the research to practical use?
	else
		-- unknown mystery stuff (shouldn't be possible, handling unhandled stuff)
		msnMgr:addMessage("The data collected is confusing, and not practically usable. In spite of your and the crew's best observations, you are still unable to determine exactly what it is.")
		msnMgr:addMessage(" ")
	end


	msnMgr:addMessage("Scientific curiosity satisfied, you plot a course away from " .. phenomenonName .. ".")
	msnMgr:addMessage(" ")
end

function abandon()
	--TODO: Expand on crew disappointment a bit more?

	if (discoveryCrew ~= -1 and namedByCrew and msnMgr:random() % 6 > 3) then
		-- discovered by crew
		discoveryCrewName = charMgr:getCharColoredName(discoveryCrew)
		msnMgr:addMessage(discoveryCrewName .. " is disappointed, and asks if it can still be named after them.")
		msnMgr:addMessage(" ")
	else
		-- discovered by you
		if (charMgr:depCrewLeft() > 1) then
			msnMgr:addMessage("The crew is disappointed, but the brief excitement seems to have been a welcome distraction.")
			msnMgr:addMessage(" ")
		else
			msnMgr:addMessage(charMgr:getCharColoredName(charMgr:randomCrew()) .. " is disappointed, but the brief excitement seems to have been a welcome distraction.")
			msnMgr:addMessage(" ")
		end
	end

	msnMgr:addMessage("Initial observations of " .. phenomenonName .. " reveal some data, but nothing dramatic enough to warrant pursuing given the current state of the mission. You return the ship to its original course.")
	msnMgr:addMessage(" ")
end

function ignore()
	if (discoveryCrew ~= -1 and namedByCrew) then
		-- discovered by crew
		discoveryCrewName = charMgr:getCharColoredName(discoveryCrew)
		msnMgr:addMessage(discoveryCrewName .. " is disappointed, and asks if it can still be named after them.")
		msnMgr:addMessage(" ")
	else
		-- discovered by you
		if (charMgr:depCrewLeft() > 1) then
			msnMgr:addMessage("The crew is disappointed, but the brief excitement seems to have been a welcome distraction.")
			msnMgr:addMessage(" ")
		else
			msnMgr:addMessage(charMgr:getCharColoredName(charMgr:randomCrew()) .. " is disappointed, but the brief excitement seems to have been a welcome distraction.")
			msnMgr:addMessage(" ")
		end
	end

	if (investigation ~= -2) then
		msnMgr:addMessage("As exciting as the prospects for scientific discovery are, limited resources make it hard to justify deviating from the primary mission. You note what observations you can of " .. phenomenonName .. " from this distance and resume course.")
		msnMgr:addMessage(" ")
	else
		msnMgr:addMessage("Even though there is nothing of interest here, you note the observations made of " .. phenomenonName .. " and resume course.")
		msnMgr:addMessage(" ")
	end
end

function getPhenomenonName()
	-- Let's make a cool name and define variants if needed

	designation = ""
	if (phenomenonType == 0) then
		-- No real conventions for black holes. Typically they're named for the galaxies/constellations they're found in, so let's just make stuff up
		letters = {}
		table.insert(letters, "B")
		table.insert(letters, "N")
		table.insert(letters, "D")
		table.insert(letters, "W")
		table.insert(letters, "K")
		table.insert(letters, "G")
		designation = designation .. letters[1 + msnMgr:random() % 6] .. (100 + msnMgr:random() % 899) .. "-" .. (100 + msnMgr:random() % 899)

		-- Is the black hole evaporating or growing
		phenomenonTypeType = msnMgr:random() % 2
	elseif (phenomenonType == 1) then
		-- No real conventions for neutron stars. Typically they seem to be named for the observatories/telescopes that discovered them, and coordinates they're discovered at so let's just make something up
		letters = {}
		table.insert(letters, "J")
		table.insert(letters, "M")
		table.insert(letters, "E")
		table.insert(letters, "Z")
		table.insert(letters, "F")
		table.insert(letters, "V")
		designation = designation .. letters[1 + msnMgr:random() % 6] .. letters[1 + msnMgr:random() % 6] .. (100 + msnMgr:random() % 899) .. "-" .. (1000 + msnMgr:random() % 8999)
	elseif (phenomenonType == 2) then
		-- Unusual coronal mass ejection
		-- These are going to be naming the star itself rather than the event, so let's use what we're using for neutron stars
		letters = {}
		table.insert(letters, "L")
		table.insert(letters, "C")
		table.insert(letters, "U")
		table.insert(letters, "V")
		table.insert(letters, "H")
		table.insert(letters, "S")
		designation = designation .. letters[1 + msnMgr:random() % 6] .. letters[1 + msnMgr:random() % 6] .. (100 + msnMgr:random() % 899) .. "-" .. (1000 + msnMgr:random() % 8999)
	elseif (phenomenonType == 3) then
		-- transsolar object naming conventions seem to be one of several prefixes indicating th enature of the object (P for periodic comet, C for non-period comet, X for incalculable orbit, etc.) followed by year and alphanumeric indicator of month/discovery order. Taking some additional liberties so that we're not explicitly implying dates.

		-- Is object a comet, asteroid, unknown or probe
		phenomenonTypeType = msnMgr:random() % 3
		if (msnMgr:random() % 10 > 7) then
			-- Probes should be really rare
			phenomenonTypeType = 3
		end


		if (phenomenonTypeType == 0) then
			letters = {}
			table.insert(letters, "P")
			table.insert(letters, "C")
			table.insert(letters, "X")

			designation = designation .. letters[1 + msnMgr:random() % 3] .. "/" .. (1000 + msnMgr:random() % 8999) .. "-" .. (10 + msnMgr:random() % 89) .. "A" .. msnMgr:random() % 10
		elseif (phenomenonTypeType == 1) then
			letters = {}
			table.insert(letters, "V")
			table.insert(letters, "C")
			table.insert(letters, "A")
			table.insert(letters, "G")
			table.insert(letters, "L")
			table.insert(letters, "S")
			designation = designation .. "A/" .. (1000 + msnMgr:random() % 8999) .. "-" .. (10 + msnMgr:random() % 89) .. letters[1 + msnMgr:random() % 6] .. "M" .. msnMgr:random() % 10
		elseif (phenomenonTypeType == 2) then
			letters = {}
			table.insert(letters, "I")
			table.insert(letters, "X")

			designation = designation .. letters[1 + msnMgr:random() % 2] .. "/" .. (1000 + msnMgr:random() % 8999) .. "-" .. (10 + msnMgr:random() % 89) .. "D" .. msnMgr:random() % 10
		else --if (phenomenonTypeType == 3) then
			designation = designation .. "Z/" .. (1000 + msnMgr:random() % 8999) .. "-" .. (10 + msnMgr:random() % 89) .. "F" .. msnMgr:random() % 10
		end
	else
		-- unknown mystery stuff (shouldn't be possible, handling unhandled stuff)
		designation = designation .. "??/" .. (100 + msnMgr:random() % 899) .. "-" .. (100 + msnMgr:random() % 899)
	end

	name = ""
	if (discoveryCrew ~= -1) then
		discoveryCrewName = charMgr:getCharName(discoveryCrew)
		discoveryCrewName = discoveryCrewName:match("%s*(%S+)$")
		if (discoveryCrewName == nil or discoveryCrewName == '') then
			-- If we can't find a good name, just use AR
			discoveryCrewName = "AR"
		end
		if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_name_" .. discoveryCrewName) ~= true) then
			name = discoveryCrewName
			namedByCrew = true
		else
			--TODO: Add chance to name it after another crewmember?
			discoveryCrew = -1
			name = "AR"
		end
	else
		name = "AR"
	end

	--TODO: Check for existing AR name? Chances of getting the exact same designation are super low though
	msnMgr:addQuestItem("argon_" .. phenomenonList[phenomenonType + 1] .. "_name_" .. name)
	if (designation ~= "") then
		ship:addMissionMarker(name .. " " .. designation)
	end
	return name .. " " .. designation
end

function crewComment(crew, positive, excluding)

	--TODO: Do we want phenomenon specific responses here? Could be nice, but role specific feels more valuable and maybe role specific * phenomenon specific is getting to be too many
	--TODO: More roles? Confident, Competitive, COMEDIAN!!!, Mechanic?, Politician?

	crewName = charMgr:getCharColoredName(crew)
	if (positive) then
		if (charMgr:getCharTrait(crew, "Observant") and excluding ~= "Observant") then
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1])) then
				msnMgr:addMessage("\"I know we've seen this kind of thing before,\" acknowledges " .. crewName .. " before diving into a list of what differentiates this particular example.")
				msnMgr:addMessage(" ")
			else
				if (charMgr:depCrewLeft() > 1) then
					msnMgr:addMessage("\"Look at that!\" says " .. crewName .. ", pointing out details to the rest of the crew. Clearly, they are eager to study further.")
					msnMgr:addMessage(" ")
				else
					msnMgr:addMessage("\"Look at that!\" says " .. crewName .. ", pointing out details. You've noticed them yourself, but in the interests of supporting morale, you humor them and respond positively. Clearly, they are eager to study further.")
					msnMgr:addMessage(" ")
				end
			end
			return "Observant"
		elseif (charMgr:getCharTrait(crew, "Scientist") and excluding ~= "Scientist") then
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1])) then
				msnMgr:addMessage("\"I'm looking forward to seeing how this compares to the ones we've previously studied,\" says " .. crewName .. ". \"How many humans can say they've personally witnessed *multiple* celestial phenomena like this? I'm almost itching to write a paper!\"")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("\"Studying this is the chance of a lifetime,\" says " .. crewName .. ", showing their scientific background. \"How many humans can say they've personally witnessed celestial phenomena like this? Imagine the papers we could write!\"")
				msnMgr:addMessage(" ")
			end
			return "Scientist"
		elseif (charMgr:getCharTrait(crew, "Soldier") and excluding ~= "Soldier") then
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1])) then
				msnMgr:addMessage("\"Anything that gives us an edge in the mission seems worthwhile,\" says " .. crewName .. ". \"But I sure hope we learn more than last time.\"")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("\"There are practical benefits we can draw from researching this, right?\" asks " .. crewName .. ". \"Anything that gives us an edge in the mission seems worthwhile.\"")
				msnMgr:addMessage(" ")
			end
			return "Soldier"
		elseif (charMgr:getCharTrait(crew, "Reckless") and excluding ~= "Reckless") then
			recklessLine = msnMgr:random() % 10
			if (recklessLine > 7) then
				msnMgr:addMessage("\"Let's get in there!\" says " .. crewName .. ", displaying a typical ratio of forethought to enthusiasm.")
				msnMgr:addMessage(" ")
			elseif (recklessLine > 3) then
				msnMgr:addMessage("\"Let's gooooooooooooooo!\" says " .. crewName .. ", displaying a typical ratio of forethought to enthusiasm.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("\"FOR SCIENCE!\" shouts " .. crewName .. ". You have no idea why.")
				msnMgr:addMessage(" ")
			end
			return "Reckless"
		elseif (charMgr:getCharTrait(crew, "Cautious") and excluding ~= "Cautious") then
			msnMgr:addMessage("\"So long as we study it safely,\" says " .. crewName .. ", \"It's probably a good idea.\"")
			msnMgr:addMessage(" ")
			return "Cautious"
		elseif (charMgr:getCharTrait(crew, "Distracted") and excluding ~= "Distracted") then
			msnMgr:addMessage(crewName .. " initially seems like they have something to say, but gets distracted by a flashing light before they get a chance to speak.")
			msnMgr:addMessage(" ")
			return "Distracted"
		elseif (charMgr:getCharTrait(crew, "Xenophobic") and excluding ~= "Xenophobic") then
			msnMgr:addMessage(crewName .. " seems wary, but after some mumbling about what's natural and what's not, says that it's probably better to know more than less.")
			msnMgr:addMessage(" ")
			return "Xenophobic"
		elseif (excluding ~= "Generic") then
			genericLine = msnMgr:random() % 10
			if (genericLine > 7) then
				msnMgr:addMessage(crewName .. " seems too awed to speak, but their mouth makes a \"Wow\" shape.")
				msnMgr:addMessage(" ")
			elseif (genericLine > 3) then
				msnMgr:addMessage(crewName .. " seems content to just stare through the shuttle's main viewport.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage(crewName .. " lets out a long whistle and murmurs, \"Would you look at that.\"")
				msnMgr:addMessage(" ")
			end
			return "Generic"
		elseif (excluding ~= "Generic2") then
			genericLine = msnMgr:random() % 10
			if (genericLine > 7) then
				msnMgr:addMessage("\"It's just so exciting!\" says " .. crewName .. " with a grin.")
				msnMgr:addMessage(" ")
			elseif (genericLine > 3) then
				msnMgr:addMessage("\"So cool!\" says " .. crewName .. " enthusiastically.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("\"I love this stuff!\" says " .. crewName .. " happily.")
				msnMgr:addMessage(" ")
			end

			return "Generic2"
		end
	else
		if (charMgr:getCharTrait(crew, "Soldier") and excluding ~= "Soldier") then
			msnMgr:addMessage(crewName " expresses some misgivings about wasting time on things that don't benefit the mission, but says they will follow your orders.")
			msnMgr:addMessage(" ")
			return "Soldier"
		elseif (charMgr:getCharTrait(crew, "Xenophobic") and excluding ~= "Xenophobic") then
			msnMgr:addMessage("\"It's probably a probe sent by some aliens or something that wants to kill us. I say we steer clear,\" says " .. crewName .. ".")
			msnMgr:addMessage(" ")
			return "Xenophobic"
		elseif (charMgr:getCharTrait(crew, "Comedian") and excluding ~= "Comedian") then
			comedianLine = msnMgr:random() % 10
			if (comedianLine > 7) then
				msnMgr:addMessage("\"Oh, good,\" says " .. crewName .. " sardonically. \"This would definitely be a great use of our time.")
				msnMgr:addMessage(" ")
			elseif (comedianLine > 3) then
				msnMgr:addMessage("\"I have a great idea,\" says " .. crewName .. ", voice dripping with sarcasm. \"Why don't we take the last humans in existence and make them stare at some space stuff for a while instead of trying to find a new home.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("\"Fantastic,\" says " .. crewName .. " sarcastically. \"Boring space stuff. My favourite.")
				msnMgr:addMessage(" ")
			end
			return "Comedian"
		elseif (charMgr:getCharTrait(crew, "Reckless") and excluding ~= "Reckless") then
			msnMgr:addMessage("\"Let's just get out of here,\" says " .. crewName .. ". \"It's not like we're going to find anything exciting anyway.")
			msnMgr:addMessage(" ")
			return "Reckless"
		elseif (charMgr:getCharTrait(crew, "Cautious") and excluding ~= "Cautious") then
			msnMgr:addMessage("\"We really shouldn't be messing around with stuff like this,\" says " .. crewName .. ". \"Who knows what could go wrong.\"")
			msnMgr:addMessage(" ")
			return "Cautious"
		elseif (charMgr:getCharTrait(crew, "Distracted") and excluding ~= "Distracted") then
			msnMgr:addMessage(crewName .. " initially seems like they have something to say, but loses interest before they get a chance to speak.")
			msnMgr:addMessage(" ")
			return "Distracted"
		elseif (charMgr:getCharTrait(crew, "Scientist") and excluding ~= "Scientist") then
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1])) then
				msnMgr:addMessage("\"I'm just not sure how much we can learn from this that we don't already know from prior study,\" says " .. crewName .. ".")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("\"I'm just not sure how much we can learn from this that we don't already know,\" says " .. crewName .. ".")
				msnMgr:addMessage(" ")
			end
			return "Scientist"
		elseif (charMgr:getCharTrait(crew, "Observant") and excluding ~= "Observant") then
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1])) then
				msnMgr:addMessage("\"It really doesn't look much different from the last time we encoutnered something like this,\" says " .. crewName .. ".")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("\"The chances of us learning something of more value than the time and effort we could spend here feel low,\" says " .. crewName .. ".")
				msnMgr:addMessage(" ")
			end
			return "Observant"
		elseif (excluding ~= "Generic2") then
			if (msnMgr:hasQuestItem("argon_" .. phenomenonList[phenomenonType + 1])) then
				msnMgr:addMessage("\"Meh,\" says " .. crewName .. ", sighing with disinterest. \"It's not like we haven't seem this stuff before.\"")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("\"Meh,\" says " .. crewName .. ", sighing with disinterest. \"What good is looking at a bunch of space stuff going to do us?\"")
				msnMgr:addMessage(" ")
			end
			return "Generic2"
		elseif (excluding ~= "Generic") then
			genericLine = msnMgr:random() % 10
			if (genericLine > 7) then
				msnMgr:addMessage("\"Are we really going to stop for every floating piece of space garbage and flashing light we come across?\" asks " .. crewName .. " impatiently.")
				msnMgr:addMessage(" ")
			elseif (genericLine > 3) then
				msnMgr:addMessage("\"Are we really going to spend our time on this?\" asks " .. crewName .. " impatiently.")
				msnMgr:addMessage(" ")
			else
				msnMgr:addMessage("\"Is this really happening?\" asks " .. crewName .. " impatiently. \".\"")
				msnMgr:addMessage(" ")
			end
			return "Generic"
		end
	end
end

-- Set Hidden Flags and other items

choices = 0;
investigation = 0;
studyOrNot = 0;
fuelCost = 0;
studyFuelCost = 0;
studyFoodCost = 0;
studySensorCost = 0;
studyEngineCost = 0;
phenomenonType = 0; -- the type of the phenomenon from the phenomenonList
phenomenonTypeType = 0; -- phenomena specific variants (eg: big black hole, evaporating black hole)
phenomenaCount = -1;
phenomenonName = "" -- generated name for the thing based on who found it and what it is (loosely adhering to real-world naming conventions where applicable)
discoveryType = -1; -- was it found by you or the crew, long range sensors or visual identification
discoveryCrew = -1; -- crew member who discovered the thing (if any)
namedByCrew = false;

phenomenonList = {"blackhole", "neutronstar", "coronalmassejection", "transsolarobject"}--, "unusualring", "nova", "asteroidcollision", "lostsatellite", "unusualradiation", "solarcollision"}

crewTraits()

missionStart()


introduction()
investigateOrNot()
if (investigation == 0) then
	approach()
	if (studyOrNot == 0) then
		study()
		analysis()
	else
		abandon()
	end
else
	ignore()
end

missionOverview()

msnMgr:endMission(false)
