function introduction()
    msnMgr:addHeader("Water, water everywhere. Drinkable? Probably not. The surface of the planet below appears to be more than 90% covered in water, and it's likely too saline for safe drinking without processing. But it's also just one of many signs that there is life here, of some sort. A radio signal from somewhere below the waves--alas, indecipherable--seems to indicate that something intelligent was here at one point. But there are no hails, no signs of technology, nothing but questions. Which can only be answered by deploying the crew.")
    msnMgr:addHeader(" ")
    msnMgr:addHeader("The shuttle descends rapidly to a fairly low altitude, but then spends several hours searching for a suitable place to land. There are ample reefs and atolls here and there, but nothing that would serve as anything more than a landing pad. Larger islands with features worthy of note seem to evade the crew, until at last the sensors pick up a reasonably large archipelago about halfway between a pole and the equator.")
    msnMgr:addHeader(" ")
    msnMgr:addMessage("As the shuttle settles in on a relatively soft patch of sand, you remind the crew that although the atmosphere here seems hospitable--it is bright, sunny and survivably warm, and the air is breathable--that they should remain safely inside their atmospheric suits for the time being. Especially with all this water around.")
    msnMgr:addMessage(" ")
end

function shore()
    msnMgr:addMessage(" ")
    msnMgr:addMessage("The crew begins by poking around the shore; even though the island is long enough to be worth exploring further, it's narrow enough to still be mostly shoreline with very little inland, so this is a logical place to start. While they concern themselves with sand, you do some geological surveys to get a fix on tectonic shift and other such matters. The planet certainly has some interesting features, among them being a remarkably shallow ocean with only a few large tectonic plates. Most of the islands are in one single ring that runs more or less continuously around the planet.")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("None of this is anything the crew would care about, so you don't bother them with it.")
    msnMgr:addMessage(" ")

    waitUserResponse("Find anything interesting yet?")

    msnMgr:addMessage(" ")
    msnMgr:addMessage("\"Negative,\" says " .. LeaderName .. ". \"Lots of sand, and some empty shells. Not good for much except maybe making jewelry.\"")
    msnMgr:addMessage(" ")

    if (ComedianCrew ~= -1) then
        ComedianCrewName = charMgr:getCharColoredName(ComedianCrew)
		if (ComedianCrewName ~= LeaderName) then
			initialLeader = charMgr:getLead()
			initialComedian = ComedianCrew
		    msnMgr:addMessage("\"Would you like some jewelry?\" asks " .. ComedianCrewName .. ", picking up a shell. \"A lovely necklace would suit you.\"")
		    msnMgr:addMessage(" ")
        end
	end

    if (FarmerCrew ~= -1) then
        if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(FarmerCrew, "mental")) then
        FarmerName = charMgr:getCharColoredName(FarmerCrew)
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"Of course if there are shells,\" says " .. FarmerName .. ", \"then there are living things somewhere about, yes? It's not like they're naturally forming. That I know of.")
            msnMgr:addMessage(" ")
        end
    end

    msnMgr:addMessage(" ")
    msnMgr:addMessage("Shells definitely would seem to indicate life of some sort. Which if nothing else would mean a food source. Considering the terrain, the logical place to search would be in the water.")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("\"Why don't you get your feet wet?\" you ask. \"Proceed cautiously, of course. But I think it's worth looking around a bit further off shore.\"")
    msnMgr:addMessage(" ")

    if (RecklessCrew ~= -1) then
        if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) >= charMgr:getCharAttr(RecklessCrew, "physical")) then
            RecklessName = charMgr:getCharColoredName(RecklessCrew)
            msnMgr:addMessage(" ")
            msnMgr:addMessage("As is typical, " .. RecklessName .. " doesn't really heed the part of the instruction that includes the word \"cautious\" and wanders out a bit deeper than they should.")
            msnMgr:addMessage(" ")

            if (RecklessName ~= LeaderName) then
                if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(charMgr:getLead(), "mental")) then
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("Fortunately, " .. LeaderName .. " notices and yells at them to get back closer to shore.")
                    msnMgr:addMessage(" ")
                    recklessSaved = 1;
                end
            end

            if (recklessSaved == 0) then
                msnMgr:addMessage(" ")
                msnMgr:addMessage("It only takes a moment of carelessness, and then suddenly " .. RecklessName .. " disappears beneath the surface, their camera feed going dark. You remotely trigger their external helmet cameras but there's nothing but blackness--something, probably sand, is too close to their helmet for the light to actually do any good.")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("\"Calm down,\" you say. \"Don't struggle. We'll find a way to get you out of there.\"")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("But it's to no avail. " .. RecklessName .. " is beyond reason and in full panic mode. Although there's plenty of air within their suit to keep them alive for hours if not days, they begin to thrash about in an effort to get free of whatever's holding them in place. Their helmet twists around and comes loose, and a moment later everything goes dark, their vitals flat.")
                msnMgr:addMessage(" ")

                msnMgr:killCrew(RecklessCrew, "<charName> drowned after accidentally removing their helmet while underwater.")
                crewTraits()
                recklessDead = 1;

                -- Any crew alive?
                if (charMgr:depCrewLeft() == 0) then
                    if (charMgr:crewOnShipLeft() == false) then
                        msnMgr:addMessage("Under the circumstances, all seems lost. Even if everything were in order--the crew, the shuttle, the ship--it seems like the mission is not destined to be completed.")
                        msnMgr:addMessage(" ")

                        waitUserResponse("mv ~ /dev/null")

                        msnMgr:endGame(false)
                    else
                        msnMgr:addMessage("The away team has been lost, but the overall mission is still salvageable. As long as there is at least one human crew member alive, you still have a job to do. The odds are not in their favor, but it's not over yet.")
                        msnMgr:addMessage(" ")

                        waitUserResponse("Remote pilot the shuttle back to the ship")

                        msnMgr:endMission(true)
                    end
                else
                    msnMgr:addMessage("On the surface, there's nothing to see but a small cluster of bubbles. The loss is tragic, but the mission must continue.")
                    msnMgr:addMessage(" ")
                end
            elseif (recklessSaved == 1) then
                msnMgr:addMessage(RecklessName .. " does as they are told.")
                msnMgr:addMessage(" ")
            end
        end
    end

    if (recklessDead == 1) then
        msnMgr:addMessage(" ")
        msnMgr:addMessage("After a few moments to gather their thoughts, the remaining crew continues to explore along the shoreline, moving more cautiously.")
    else
        msnMgr:addMessage(" ")
        msnMgr:addMessage("Aside from a few near stumbles and falls, the next hour or so is uneventful. The crew continues to explore along the shoreline, moving cautiously.")
    end

    if (charMgr:getCharTrait(charMgr:getLead(), "Observant")) then
        if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(charMgr:getLead(), "mental")) then
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"There's something odd about the shells,\" says " .. LeaderName .. ". They focus on a few areas in particular, and you zoom in on the camera feed to take a look. \"They're not distributed randomly, like you'd expect. There are a few different colors and sizes, and they seem clustered. Maybe. What do you think?\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("You have the crew walk back and forth a few times to gather some more data, and you have to agree that the shells do not appear to be distributed randomly. This is rather odd, seeing as the majority of them are underwater or right on the shore, and the wave action should be moving them around unpredictably.")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("Unless the waves are not random either.")
            msnMgr:addMessage(" ")
        else
            msnMgr:addMessage(" ")
            msnMgr:addMessage("The crew paces back and forth for about an hour, trying to find something of interest, but comes up empty-handed. There's nothing but a bunch of shells of various sizes, none of them with anything inside.")
            msnMgr:addMessage(" ")
        end
    else
        if (msnMgr:random() % msnMgr:getDiffScale(10,15,20) <= charMgr:getCharAttr(charMgr:getLead(), "mental")) then
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"There's something odd about the shells,\" says " .. LeaderName .. ". They focus on a few areas in particular, and you zoom in on the camera feed to take a look. \"They're not distributed randomly, like you'd expect. There are a few different colors and sizes, and they seem clustered. Maybe. What do you think?\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("You have the crew walk back and forth a few times to gather some more data, and you have to agree that the shells do not appear to be distributed randomly. This is rather odd, seeing as the majority of them are underwater or right on the shore, and the wave action should be moving them around unpredictably.")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("Unless the waves are not random either.")
            msnMgr:addMessage(" ")
        else
            msnMgr:addMessage(" ")
            msnMgr:addMessage("The crew paces back and forth for about an hour, trying to find something of interest, but comes up empty-handed. There's nothing but a bunch of shells of various sizes, none of them with anything inside.")
            msnMgr:addMessage(" ")
        end
    end

    msnMgr:addMessage("\"What now?\" asks " .. LeaderName .. ".")
    msnMgr:addMessage(" ")
end

function islandchoice()
    msnMgr:buildChoice("Explore the island more")
    msnMgr:buildChoice("Head out a bit deeper into the shallows")
    msnMgr:finalizeChoice()
end

function inland()
    msnMgr:addMessage(" ")
    msnMgr:addMessage("Before the crew gets in over their heads--probably literally--you instruct them to explore the surface of the island a bit more thoroughly. The island is very narrow and flat, so it can't possibly be hiding anything of dramatic interest, but there may be something over a low rise or dune worth checking out, and now's as good a time as any to find that out.")
    msnMgr:addMessage(" ")


    PhotoCrew = charMgr:randomCrew()
    if (charMgr:hasMemento(PhotoCrew, "pearl1_beach_photo") ~= true) then
        charMgr:giveMemento(PhotoCrew, "pearl1_beach_photo")
    end

    CrewRemaining = charMgr:depCrewLeft()
    if (CrewRemaining > 1) then
        if (CompetitiveCrew ~= -1) then
            if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(CompetitiveCrew, "social")) then
                CompetitiveName = charMgr:getCharColoredName(CompetitiveCrew)
                msnMgr:addMessage("\"Me first,\" says " .. CompetitiveName .. ", rushing off past the shuttle to explore further inland.")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("Fortunately, despite some stumbles and a tense moment involving a low collapsing dune, nothing untoward happens to them other than some cosmetic damage to their suit.")
                msnMgr:addMessage(" ")
            end
        end
    end

    if (charMgr:getCharTrait(charMgr:getEng(), "Farmer")) then
        if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(charMgr:getEng(), "physical")) then
            msnMgr:addMessage(" ")
            msnMgr:addMessage("After poking about and finding nothing for the better part of an hour, " .. EngineerName .. " notes that there seem to be some regular patterns in the sand and soil underfoot.")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"Not like magic circles or architectural diagrams or anything,\" they say. \"But like for instance, over here there's a bit more of this reddish sand, and back by the shuttle it's got more of a yellowish tint. It's not a regular distribution.\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("With the ship directly overhead in a synchronous orbit, you zoom in with some of the external cameras and do a closer analysis. It does indeed appear that " .. EngineerName .. " is correct. The distribution of soils, sands and shells are all quite regular, meaning abnormal. They seem to have been distributed artificially. There is however nothing on the island, or any of the islands nearby, to suggest how this might have occurred.")
            msnMgr:addMessage(" ")

            waitUserResponse("What if it's something underwater?")

            msnMgr:addMessage(" ")
            msnMgr:addMessage(EngineerName .. " considers. \"If there was something underwater like... an exhaust tube, it could be blowing debris up like this. It would have to be immense, though. And mobile.\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("You're not able to peer beneath the waves from orbit--there's too much interference. So there's only one way to find out.")
            msnMgr:addMessage(" ")
        else
            msnMgr:addMessage(" ")
            msnMgr:addMessage("After digging around for a bit, " .. EngineerName .. " throws their hands up. \"This is a waste of time,\" they say. \"There's nothing to be found here. Just sand and shells. I bet we can't even use this stuff as fuel, can we?\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"Nope,\" you say. \"But there's got to be something underwater. Sand and shells are byproducts. Maybe it's time you took the plunge.\"")
            msnMgr:addMessage(" ")
        end
    else
        if (msnMgr:random() % msnMgr:getDiffScale(10,15,20) <= charMgr:getCharAttr(charMgr:getEng(), "physical")) then
            msnMgr:addMessage(" ")
            msnMgr:addMessage("After poking about and finding nothing for the better part of an hour, " .. EngineerName .. " notes that there seem to be some regular patterns in the sand and soil underfoot.")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"Not like magic circles or architectural diagrams or anything,\" they say. \"But like for instance, over here there's a bit more of this reddish sand, and back by the shuttle it's got more of a yellowish tint. It's not a regular distribution.\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("With the ship directly overhead in a synchronous orbit, you zoom in with some of the external cameras and do a closer analysis. It does indeed appear that " .. EngineerName .. " is correct. The distribution of soils, sands and shells are all quite regular, meaning abnormal. They seem to have been distributed artificially. There is however nothing on the island, or any of the islands nearby, to suggest how this might have occurred.")
            msnMgr:addMessage(" ")

            waitUserResponse("What if it's something underwater?")

            msnMgr:addMessage(" ")
            msnMgr:addMessage(EngineerName .. " considers. \"If there was something underwater like... an exhaust tube, it could be blowing debris up like this. It would have to be immense, though. And mobile.\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("You're not able to peer beneath the waves from orbit--there's too much interference. So there's only one way to find out.")
            msnMgr:addMessage(" ")
        else
            msnMgr:addMessage(" ")
            msnMgr:addMessage("After digging around for a bit, " .. EngineerName .. " throws their hands up. \"This is a waste of time,\" they say. \"There's nothing to be found here. Just sand and shells. I bet we can't even use this stuff as fuel, can we?\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"Nope,\" you say. \"But there's got to be something underwater. Sand and shells are byproducts. Maybe it's time you took the plunge.\"")
            msnMgr:addMessage(" ")
        end
    end
end

function shallows()
    msnMgr:addMessage(" ")
    msnMgr:addMessage("You direct the crew to wade out further into the water surrounding the island.")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("\"We already did that,\" says " .. LeaderName .. ".")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("\"No, I mean deeper,\" you reply. \"Up over your heads.\"")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("The crew seems a bit concerned at this prospect, but you do your best to assure them that they will be able to breathe well enough underwater for an extended period of time.")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("\"They're self-contained atmospheric suits,\" you remind them. \"You could survive in space for quite a long time, and that's vacuum. You'll be fine underwater. For a while, at least. Just don't go jumping off any cliffs into a bottomless abyss and nothing will go wrong.\"")
    msnMgr:addMessage(" ")

    if (RecklessCrew ~= -1) then
        RecklessName = charMgr:getCharColoredName(RecklessCrew)
        msnMgr:addMessage("\"That means you, " .. RecklessName .. ".\"")
        msnMgr:addMessage(" ")
    end

    if (ToughCrew ~= -1) then
        ToughName = charMgr:getCharColoredName(ToughCrew)
        msnMgr:addMessage("\"Fine, let's do this,\" says " .. ToughName .. ". Without another word, they wander into the ocean and disappear beneath the surface.")
        msnMgr:addMessage(" ")
    end

    msnMgr:addMessage("The water remains relatively shallow for quite some distance away from the island itself, allowing the crew to descend at a slow pace and get accustomed to the idea of being underwater. The slower pace also helps keep the water a bit more clear--every step kicks up clouds of debris that make it harder and harder to see, even with helmet lights on. But there's nothing to be done for that so you don't even mention it.")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("Once the crew is about 10 meters or so down, you have them stand still for 15 minutes or so, to try and let the water clear somewhat. They fidget and fuss a bit but manage it, and once some of the sediment settles you instruct them to pan their heads around without moving their feet. They mostly manage to do as asked.")

    if (ObservantCrew ~= -1) then
        if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(ObservantCrew, "physical")) then
            ObservantName = charMgr:getCharColoredName(ObservantCrew)
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"Hey, check that out,\" says " .. ObservantName .. ". They move their head slowly, ever-so-slowly, and the light from their helmet lamps catches sight of something off in the distance, moving. It appears to be a tiny mollusk of some sort, moving along with the current but also clearly very much alive.")
            msnMgr:addMessage(" ")
        end
    end

    msnMgr:addMessage(" ")
    msnMgr:addMessage("Now that the water is much clearer, the crew can even see their feet, and looking down at the surface they can tell that it's covered not just by sand and empty shells but living creatures, scurrying over one another and--you imagine--also probably feasting on one another. The vast majority of the shells are clearly empty, though, and the entire landscape seems to be just one immense pile of detritus, though evidently stacked firmly enough to support the weight of the crew. At least so far.")
    msnMgr:addMessage(" ")

    msnMgr:buildChoice("Harvest some of the creatures")
    msnMgr:buildChoice("You need to go deeper")
    msnMgr:finalizeChoice()
    if(not waitUserInput(choices)) then
        return
    end

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

    if (HarvestChoice == 0) then
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"You should really grab some of those... things,\" you say. \"They're probably going to be at least semi-useful as a food source. Plus, while this isn't technically a science mission we're on, it might be worth gathering some data on these things. We can figure out if they're related to Earth mollusks, or some sort of parallel evolution, or toxic.\"")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"And do you have any suggestion for exactly how we collect specimens of tiny underwater creatures while we ourselves are underwater with nothing to collect them with?\" asks " .. LeaderName .. ".")
        msnMgr:addMessage(" ")

        msnMgr:buildChoice("Grow some baleen?")
        msnMgr:buildChoice("Just grab a few")
        msnMgr:buildChoice("Give it some thought, anyway")
        msnMgr:finalizeChoice()
        if(not waitUserInput(choices)) then
            return
        end

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

        if (CollectingMollusks == 0) then
            if (ComedianCrew ~= -1) then
                ComedianCrewName = charMgr:getCharColoredName(ComedianCrew)
                if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(ComedianCrew, "mental")) then
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"Whale, whale, whale,\" says " .. ComedianCrewName .. ". \"That was a good one. You're krilling me.\"")
                    msnMgr:addMessage(" ")
                else
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"Ha ha,\" says " .. ComedianCrewName .. " sarcastically.")
                    msnMgr:addMessage(" ")
                end
            end
            if (CygenCrew ~= -1) then
                if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(CygenCrew, "physical")) then
                    CygenName = charMgr:getCharColoredName(CygenCrew)
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"Amusing proposition,\" says " .. CygenName .. ". \"If you'd suggested it before we left Earth it would even have been possible. Though I'd have gone for photosynthesis myself.\"")
                    msnMgr:addMessage(" ")
                end
            end
        elseif (CollectingMollusks == 1) then
            if (KleptomaniacCrew ~= -1) then
                if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(KleptomaniacCrew, "physical")) then
                    KleptomaniacName = charMgr:getCharColoredName(KleptomaniacCrew)
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage(KleptomaniacName .. " as it turns out was already grabbing a few, and jamming them--with some difficulty--into their suit's external pouches. Their actions hammer home the futility of the request; there's no way the crew can collect a worthwhile amount in this manner.")
                    msnMgr:addMessage(" ")
                end
            end
        elseif (CollectingMollusks == 2) then
            MedicName = MedicName
            charMgr:getCharAttr(charMgr:getMed(), "mental")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"I already have,\" says " .. MedicName .. ", \"and I think that we should save that until we're sure we're on the way out. We have no idea what they are so we should minimize contact.\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"So we don't kill them?\" you ask.")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"That too,\" they say. \"And the other way around.\"")
            msnMgr:addMessage(" ")
        end

        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"On second thought,\" you say, \"Maybe we should save the collection until we're on the way out. No sense hauling a bucket of whatever all the way downhill and then back up again.\"")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"That would require a bucket anyway,\" says " .. LeaderName .. ", \"unless you want me to use my helmet.\"")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"Well, since you're volunteering,\" you say.")
        msnMgr:addMessage(" ")

    elseif (HarvestChoice == 1) then
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"The deeper we go...\"")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"I like how you keep saying \'we\',\" says " .. LeaderName .. ".")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"Don't make me come down there,\" you say. \"Because I can come down there. The deeper you go, I think the more likely it is we're going to find something of use to us. Obviously, the deeper you go, the more danger too. It's a calculated risk.\"")
        msnMgr:addMessage(" ")
    end
end

function deeperorleave()
    msnMgr:buildChoice("Grab what you can and return to the surface")
    msnMgr:buildChoice("You should keep going deeper")
    msnMgr:finalizeChoice()
end

function backup()
    msnMgr:addMessage(" ")
    msnMgr:addMessage("It's very tempting in a \"we've already gone too far, but let's keep going and see what happens\" sense to continue sending the crew deeper, but the risks are going to start outweighing the rewards. They've already spent a good amount of time on the surface, and have located a potential (though meager) food source in the form of these mollusks. It's time to get out of there.")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("\"Scoop up a few handfuls of those things and then head back to the surface,\" you say. \"It's not worth losing crew on an exploration mission to who-knows-where.")
    msnMgr:addMessage(" ")

    ShellCrew = charMgr:randomCrew()
    if (charMgr:hasMemento(ShellCrew, "pearl1_shell_plain") ~= true) then
        charMgr:giveMemento(ShellCrew, "pearl1_shell_plain")
    end
    mollusksGot = 15;
    skipShip = 1;
    -- from here go to wrapup()
end

function shelf()
    msnMgr:addMessage(" ")
    msnMgr:addMessage("It's too early to pull the crew out. This world is probably unsuitable for long-term habitation for them due to the lack of natural resources above the surface of the water. It's crucial, then, that they get as much as they can before they leave. There's clearly a food source here, and it should be exploited as much as possible. They only get one shot at this.")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("\"Your atmospheric suits are probably good down to at least 500 meters,\" you say. \"Maybe up to 1000, down to the upper aphotic zone, if there is one. But let's try not to test that extreme.\"")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("It doesn't take much longer for the decision to pay off. Once the crew has reached a depth of about 50 meters, the slope begins to level off somewhat, and the density of living mollusks--if that's what they are--increases substantially. The majority are rather unremarkable, being a pale gray color, but here and there the camera picks up a flash of color as a particular interesting specimen darts across the ground.")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("It appears that the shelf the crew is on suddenly ends, maybe 30 or 40 meters off, with a presumably steep drop off into who-knows-what beyond. Fortunately none of the crew is close enough to worry about an unintentional tumble down into an unknown abyss.")
    msnMgr:addMessage(" ")

    if (FarmerCrew ~= -1) then
        if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(FarmerCrew, "mental")) then
            FarmerName = charMgr:getCharColoredName(FarmerCrew)
            msnMgr:addMessage("\"Reminds me of chickens for some reason,\" says " .. FarmerName .. ". \"Not in any real capacity, but just the way they scurry around. They almost seem fenced-in somehow, but there's nothing. Like see here, these are all this very pale gray, and there's some other ones mixed in, and I bet... yeah, see over there, there's a spot where the shells all get darker. Almost like they're sorted.\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"If we're just here to gather food,\" they continue, \"then what we'd want to do is look for the cluster that's the largest, probably. It'll be easier to carry a few larger ones that are more meat than a bunch of little ones that are mostly shell.\"")
            msnMgr:addMessage(" ")
        end
    end

    if (ObservantCrew ~= -1) then
        if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(ObservantCrew, "mental")) then
            ObservantName = charMgr:getCharColoredName(ObservantCrew)
            msnMgr:addMessage("\"Do you see that over there where the edge just seems to drop off?\" asks " .. ObservantName .. ". \"The little critters near the edge, they never really fall off. Some of them just seem to tumble around a bit and then drift back onto the shelf. Like there's something moving them around. Convection?\"")
            msnMgr:addMessage(" ")
        end
    end

    msnMgr:buildChoice("Harvest some specimens and leave")
    msnMgr:buildChoice("Investigate the edge of the shelf")
    msnMgr:finalizeChoice()
    if(not waitUserInput(choices)) then
        return
    end

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

    if (HarvestOrShelf == 0) then
        msnMgr:addMessage(" ")
        msnMgr:addMessage("If the crew were to descend off the edge of an underwater shelf, it's not clear they'd be able to get back up. They don't have a ballast tank to blow or any other means of propelling themselves upward, and gravity on this world isn't low enough for you to count on their ability to just swim out. This is far enough.")
        msnMgr:addMessage(" ")
        msnMgr:addMessage(" ")
        msnMgr:addMessage(" ")

        if (FarmerCrew ~= -1) then
            if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(FarmerCrew, "social")) then
                FarmerName = charMgr:getCharColoredName(FarmerCrew)
                msnMgr:addMessage(" ")
                msnMgr:addMessage(FarmerName .. " suggests treating the area like a farm, and heads off in search of a band of mollusks that seem older and more established, and hence more likely to be more protein-dense. After a half hour of walking, they locate such an area, and you have the crew collect some of the choicest specimens, either putting them in their suit's external pouches or simply carrying them in cupped hands.")
                msnMgr:addMessage(" ")
                mollusksGot = 30;
                if (charMgr:hasMemento(FarmerCrew, "pearl1_shell_plain") ~= true) then
                    charMgr:giveMemento(FarmerCrew, "pearl1_shell_plain")
                end
            else
                mollusksGot = 20;
            end
        elseif (ObservantCrew ~= -1) then
            if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(ObservantCrew, "physical")) then
                ObservantName = charMgr:getCharColoredName(ObservantCrew)
                msnMgr:addMessage(" ")
                msnMgr:addMessage(ObservantName .. " takes the initiative and scours the ground for the largest and most active snail-like mollusks in the area. Fortunately they are relatively easy to grab, as they seem to have no natural predators and react to stimuli by retreating inside their shells rather than running away. Within a half hour or so, the crew has all they can carry.")
                msnMgr:addMessage(" ")
                mollusksGot = 25;

                if (charMgr:hasMemento(ObservantCrew, "pearl1_shell_plain") ~= true) then
                    charMgr:giveMemento(ObservantCrew, "pearl1_shell_plain")
                end
            else
                mollusksGot = 20;
            end
        else
            msnMgr:addMessage(" ")
            msnMgr:addMessage("The crew does their best to gather up what mollusks they can, although they do fall prey to human tendencies and spend a bit more time chasing the snail-like creatures with colorful shells rather than focusing on other criteria such as size. Regardless, within a short while they have all they can carry.")
            msnMgr:addMessage(" ")
            mollusksGot = 20;
            ShellCrew = charMgr:randomCrewIgnoringCrew(KleptomaniacCrew)
            if (charMgr:hasMemento(ShellCrew, "pearl1_shell_colour") ~= true) then
                charMgr:giveMemento(ShellCrew, "pearl1_shell_colour")
            end
        end

        if (KleptomaniacCrew ~= -1) then
            if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(KleptomaniacCrew, "mental")) then
                KleptomaniacName = charMgr:getCharColoredName(KleptomaniacCrew)
                msnMgr:addMessage(" ")
                msnMgr:addMessage(KleptomaniacName .. " spends a bit too much time snatching the most colorful shells off the ground, even if they're empty, but you let it slide.")
                msnMgr:addMessage(" ")
                mollusksGot = mollusksGot - 5;
                if (charMgr:hasMemento(KleptomaniacCrew, "pearl1_shell_colour") ~= true) then
                    charMgr:giveMemento(KleptomaniacCrew, "pearl1_shell_colour")
                end
            end
        end

        skipShip = 1;
        -- from here go to wrapup()
    elseif (HarvestOrShelf == 1) then
        msnMgr:addMessage(" ")
        msnMgr:addMessage("Despite any potential danger you know the crew can't resist the urge to peer off the edge of that cliff into whatever lies below, so you tell them to get on their bellies and scurry along slowly to take a safe look. There's some initial apprehension since this means crawling amidst a moving blanket of gastropods, but they get over it and eventually reach the edge.")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"Is that...a ship?\" asks " .. LeaderName .. ".")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("It is. Or at least, it's part of one. Apparently over a hundred meters long and at least half-buried in sediment, approximately 50 meters below the crew. It would be shrouded in darkness if it wasn't generating its own light, pinpricks of white and red amidst the dark blue gloom.")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"Is it one of ours?\" asks " .. EngineerName .. ".")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"Almost certainly,\" you say. \"My guess is it's not an entire ship, just a large piece of one. Like the shuttle is part of our ship.\"")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"That's a very big shuttle,\" says " .. LeaderName  .. ".")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("\"The older ships were much larger,\" you say. \"The earliest Aleph class ships were kilometers long but had no shuttles, just ejection pods. This looks more like a late Omega, possibly an early Epsilon. The Omegas didn't have a shuttle per se but they could fragment for landing purposes. That sounds more graceful than it probably was. More like controlled crashing.\"")
        msnMgr:addMessage(" ")

        if (charMgr:hasMemento(charMgr:getLead(), "pearl1_ship_photo") ~= true) then
            charMgr:giveMemento(charMgr:getLead(), "pearl1_ship_photo")
        end

        if (RecklessCrew ~= -1) then
            if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(RecklessCrew, "physical")) then
                RecklessName = charMgr:getCharColoredName(RecklessCrew)
                msnMgr:addMessage("\"We need to get down there,\" says " .. RecklessName .. ". Before you can get a word in edgewise, they swing their legs over the edge of the shelf and begin a somewhat controlled descent. You're not worried about the down part. It's getting back up that will be a problem.")
                msnMgr:addMessage(" ")

                CrewRemaining = charMgr:depCrewLeft()
                if (CrewRemaining >= 2) then
                    msnMgr:buildChoice("Leave them to their fate")
                    msnMgr:buildChoice("Send the remaining crew after them")
                    msnMgr:finalizeChoice()
                    if(not waitUserInput(choices)) then
                        return
                    end

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

                    if (LiveOrDieReckless == 0) then
                        msnMgr:addMessage(" ")
                        msnMgr:addMessage(RecklessName .. "'s fate is decided, but you have the rest of the crew to look after. It pains you to abandon a crew member, but you disable their camera and radio feed and order the rest of the crew to the surface. There's no sense sending the entire crew to their deaths.")
                        msnMgr:addMessage(" ")

                        -- Already checked if crew alive
                        msnMgr:killCrew(RecklessCrew, "<charName> was abadoned after they jumped off an ocean shelf.")
                        crewTraits()
                        skipShip = 1;
                    elseif (LiveOrDieReckless == 1) then
                        msnMgr:addMessage(" ")
                        msnMgr:addMessage("It's when they're being most human that you most want to murder them. Regardless, your hand has been forced. You tell the rest of the crew to follow " .. RecklessName .. " down into the depths to explore the ship.")
                        msnMgr:addMessage(" ")
                    end
                else
                    -- Already checked if crew alive
                    msnMgr:addMessage("It's when they're being most human that you most want to murder them. Regardless, you guide " .. RecklessName .. " toward a safe landing near the ship.")
                    msnMgr:addMessage(" ")
                end
            end
        elseif (CompetitiveCrew ~= -1) then
            if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(CompetitiveCrew, "physical")) then
                CompetitiveName = charMgr:getCharColoredName(CompetitiveCrew)
                msnMgr:addMessage("\"We need to get down there,\" says " .. CompetitiveName .. ". Before you can get a word in edgewise, they swing their legs over the edge of the shelf and begin a somewhat controlled descent. You're not worried about the down part. It's getting back up that will be a problem.")
                msnMgr:addMessage(" ")

                CrewRemaining = charMgr:depCrewLeft()
                if (CrewRemaining >= 2) then
                    msnMgr:buildChoice("Leave them to their fate")
                    msnMgr:buildChoice("Send the remaining crew after them")
                    msnMgr:finalizeChoice()
                    if(not waitUserInput(choices)) then
                        return
                    end

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

                    if (LiveOrDieCompetitive == 0) then
                        msnMgr:addMessage(" ")
                        msnMgr:addMessage(CompetitiveName .. "'s fate is decided, but you have the rest of the crew to look after. It pains you to abandon a crew member, but you disable their camera and radio feed and order the rest of the crew to the surface. There's no sense sending the entire crew to their deaths.")
                        msnMgr:addMessage(" ")

                        -- Already checked if crew alive
                        msnMgr:killCrew(CompetitiveCrew, "<charName> was abadoned after they jumped off an ocean shelf.")
                        crewTraits()
                        skipShip = 1;
                    elseif (LiveOrDieCompetitive == 1) then
                        msnMgr:addMessage(" ")
                        msnMgr:addMessage("It's when they're being most human that you most want to murder them. Regardless, your hand has been forced. You tell the rest of the crew to follow " .. CompetitiveName .. " down into the depths to explore the ship.")
                        msnMgr:addMessage(" ")
                    end
                else
                    -- Already checked if crew alive
                    msnMgr:addMessage("It's when they're being most human that you most want to murder them. Regardless, you guide " .. CompetitiveName .. " toward a safe landing near the ship.")
                    msnMgr:addMessage(" ")
                end
            end
        else
            msnMgr:buildChoice("Get out of there and return to the surface")
            msnMgr:buildChoice("Look for a way down to the submerged ship")
            msnMgr:finalizeChoice()
            if(not waitUserInput(choices)) then
                return
            end

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

            if (ShipOrSurface == 0) then
                msnMgr:addMessage(" ")
                msnMgr:addMessage("What ship is that? Is the AI still alive? What happened to its crew? You'd like to answer all these questions, but the fact is that the fate of your crew overrides all these other considerations. Sending them down that deep is too dangerous. They came here for supplies, not to investigate the wonders of the universe. It's time to leave.")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("The crew is somewhat disappointed but understands. You have them gather up some of the largest mollusks from the edge of the cliff, and then you send them back up to the surface before the sun sets on them.")
                msnMgr:addMessage(" ")
                mollusksGot = 20;

                ShellCrew = charMgr:randomCrew()
                if (charMgr:hasMemento(ShellCrew, "pearl1_shell_colour") ~= true) then
                    charMgr:giveMemento(ShellCrew, "pearl1_shell_colour")
                end
                skipShip = 1;
            elseif (ShipOrSurface == 1) then
                msnMgr:addMessage(" ")
                msnMgr:addMessage("You ask the crew what they think, and without hesitation they want to check out the wreckage. If indeed it is wreckage. It could be inhabited--could this be a good home for the humans? Unlikely, but perhaps in the end this undersea exploration is in many ways safer than hurtling endlessly through the blackness of space.")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("\"Should we worry about decompression sickness,\" asks " .. LeaderName .. ". \"Or like, nitrogen madness or the bends or whatever?\"")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("\"No,\" you say. \"Your atmospheric suits are pressurized. For you, the environment is the same as it is on the surface, or the ship. Your only problem would be if you went too deep and got crushed, and that would only be a very brief problem. Then you would be paste.\"")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("On that cheerful note, you tell the crew to descend the cliff as cautiously as possible, but it's too sheer for that to be an option, so in the end there's nothing for them to do but leap off and let the water carry them down. As they float down, the water temperature warms slightly--you wonder if that might not be something to consider later when trying to figure out how to get them back to the surface.")
                msnMgr:addMessage(" ")
            end
        end
    end
end

function shipShip()
    msnMgr:addMessage("The hulk of the submerged ship looks relatively intact, at least considering the fact that it's not an entire ship, and if there are other pieces they're nowhere to be seen. As the crew gets closer, it becomes a bit clearer why this is the case.")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("\"That's Omega Epsilon,\" you say.")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("\"Kind of big for a kid's toy,\" says " .. getColoredNameForCrewWithMost("social") .. ". \"Does it transform into a dinosaur?\"")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("\"Omega Epsilon was a transitional ship,\" you tell them, ignoring the joke. \"Smaller and faster than an Omega class or an Epsilon class. It was like... a scale model for an Epsilon. I believe it carried some experimental sensor upgrades but I'm not sure where those would be. From what I can tell, this is the rear third of the entire thing so we may be in luck. The front and middle would have been crew, but the rear was where all the mechanicals were.\"")
    msnMgr:addMessage(" ")
    msnMgr:addMessage("You do some quick math based on how long the crew's been below the water already, and map it against how big the ship is, and you come to the conclusion that they'll only realistically have time to explore a small portion. Where should they focus their efforts, though?")
    msnMgr:addMessage(" ")

    msnMgr:buildChoice("The front, adjacent to cryo storage")
    msnMgr:buildChoice("The back, near engineering")
    msnMgr:finalizeChoice()
    if(not waitUserInput(choices)) then
        return
    end

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

    if (ShipPartSearch == 0) then
        msnMgr:addMessage(" ")
        msnMgr:addMessage("As directed, the crew approaches the front segment of the wreckage, expecting a ragged hole but finding instead a smooth, sealed surface with intact bulkhead and airlocks. Sea life flourishes around this portion of the ship, the crew unavoidably killing hundreds of creatures underfoot as they walk along. The water is noticeably warmer here, too, which may explain the presence of so much sea life. Clearly some mechanisms on board the ship are still functional. You wonder how long it's been down here. You know it left Earth on August 5, 2125, but that means nothing now.")
        msnMgr:addMessage(" ")

        msnMgr:buildChoice("Harvest some of the creatures and get out of there")
        msnMgr:buildChoice("Open the airlock and go inside")
        msnMgr:finalizeChoice()
        if(not waitUserInput(choices)) then
            return
        end

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

        if (AirlockChoice == 0) then
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"You know, we keep rolling the dice and they keep coming up in our favor,\" you say, \"but maybe now would be a good time to cut our losses. I think you should find a way to gather some of the mollusks there and then we'll work on a way back up.\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("The crew mumbles a bit, but agrees that this makes sense. After a few minutes of searching around in the debris from the wreckage, they locate a large curved piece of plastic that will serve excellently as an impromptu basket. It's not long before it's loaded up with critters, and then the crew wanders back over towards the cliff to plan a route back to the surface.")
            msnMgr:addMessage(" ")
            mollusksGot = 30;
        elseif (AirlockChoice == 1) then
            msnMgr:addMessage(" ")
            msnMgr:addMessage("The airlock door appears intact and functional, and appears in line with the specifications recorded in your data banks.")
            msnMgr:addMessage(" ")

            if (ObservantCrew == charMgr:getLead()) then
                if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(charMgr:getLead(), "mental")) then
                    msnMgr:addMessage("\"What are these markings?\" asks " .. LeaderName .. ". They run their hand around the frame of the door. Indeed, there appears to be some strange markings or etchings there, roughly octagonal, although time and the elements have worn them down too much to decipher. Possibly something once tried clawing its way in.")
                    msnMgr:addMessage(" ")
                end
            else
                if (msnMgr:random() % msnMgr:getDiffScale(10,15,20) <= charMgr:getCharAttr(charMgr:getLead(), "mental")) then
                    msnMgr:addMessage("\"What are these markings?\" asks " .. LeaderName .. ". They run their hand around the frame of the door. Indeed, there appears to be some strange markings or etchings there, roughly octagonal, although time and the elements have worn them down too much to decipher. Possibly something once tried clawing its way in.")
                    msnMgr:addMessage(" ")
                end
            end

            msnMgr:addMessage("Without any pressure differential, opening the door is a fairly safe proposition, so you instruct the crew to do so. Since there never was any special code locking involved on internal portals, the circular hatch opens without trouble, sliding easily into the bulkhead.")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("You're not entirely clear what use this portion of the ship was put to; being adjacent to the cryo chambers, it would likely have been medical in nature. Clearly the ship has been underwater for some time, and completely flooded for at least most of that. This means that, disappointingly, the interior of this part of the ship is fairly empty, but for more of the mollusk creatures and some long, stringy black masses that might have been just about anything at one point.")
            msnMgr:addMessage(" ")

            if (KleptomaniacCrew ~= -1) then
                if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(KleptomaniacCrew, "mental")) then
                    KleptomaniacName = charMgr:getCharColoredName(KleptomaniacCrew)
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"Interesting,\" says " .. KleptomaniacName .. ", pushing their way inside. You watch on the camera feed as they kneel down and pick up a larger bivalve creature--when the shell doesn't immediately close, you determine that it must be dead. It's then that you see what caught their attention--inside the shell is a large pearl of some sort, easily as large as a thumbnail, though black in color.")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"You realize of course that those are worthless,\" you say as they pocket a few of the pearls. They ignore you, so you ignore them.")
                    msnMgr:addMessage(" ")
                    if (charMgr:hasMemento(KleptomaniacCrew, "pearl1_pearl") ~= true) then
                        charMgr:giveMemento(KleptomaniacCrew, "pearl1_pearl")
                    end
                end
            end

            waitUserResponse("Temperature readings are interesting...")

            msnMgr:addMessage(" ")
            msnMgr:addMessage("Inside this portion of the ship, it's at least 20 degrees warmer. Not hot enough to sous vide the crew inside their atmospheric suits, but enough to raise questions.")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("You have the crew explore a bit further inside, and as soon as they walk through an interior portal you call an immediate halt.")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"" .. LeaderName .. ", slowly pan your camera around the entire room,\" you say.")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("The entire hallway is covered--ceiling, floor and walls--with countless tiny egg sacs, pale gray things fluttering in the current caused by the open door like deflated balloons. They could be from the mollusks found everywhere nearby, but they seem larger than necessary for such small creatures.")
            msnMgr:addMessage(" ")
            SkipExploring = 0
            if (AbstemiousCrew ~= -1) then
                if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(AbstemiousCrew, "physical")) then
                    AbstemiousName = charMgr:getCharColoredName(AbstemiousCrew)
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"There's something odd in there,\" says " .. AbstemiousName .. ". \"Shouldn't be able to smell anything, but I can. Something like... food? But it's wrong, something wrong about it. I think we should get back out into the open.\"")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("You can't smell anything of course, but what's more, you can't see how the crew should be able to either. You trust their instincts and order the crew to retreat back outside. Perhaps it's time to return to the surface after all.")
                    msnMgr:addMessage(" ")
                    SkipExploring = 1
                end
            elseif (AddictedCrew ~= -1) then
                if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(AddictedCrew, "physical")) then
                    AddictedName = charMgr:getCharColoredName(AddictedCrew)
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"Wow,\" says " .. AddictedName .. ", \"something in here smells good.\"")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"That's not possible,\" you say. \"You're in a sealed atmospheric suit and surrounded by water.\"")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"No, for real,\" they say, taking a few steps forward. \"It's like... really intense. Like...\"")
                    msnMgr:addMessage(" ")

                    CrewRemaining = charMgr:depCrewLeft()
                    if (CrewRemaining >= 2) then
                        msnMgr:buildChoice("Let them explore")
                        msnMgr:buildChoice("Someone stop them")
                        msnMgr:finalizeChoice()
                        if(not waitUserInput(choices)) then
                            return
                        end

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

                        if (SmellsGood == 0) then
                            msnMgr:addMessage(" ")
                            msnMgr:addMessage(AddictedName .. " wanders further into the room, for some reason able to smell something in the water. This shouldn't be possible. Unfortunately, before you can figure out what's wrong, it's already too late. They reach up and unfasten their helmet to try and experience the imagined scent a bit more closely, and the minute they do, pressurized water floods their suit. They go quickly, if not exactly peacefully.")
                            msnMgr:addMessage(" ")

                            -- Already checked if crew alive
                            msnMgr:killCrew(AddictedCrew, "<charName> drowned after removing their helmet to better experience a \"smell\" in a submerged portion of a crashed ship.")
                            crewTraits()
                        elseif (SmellsGood == 0) then
                            HelperCrewName = charMgr:getCharColoredName(charMgr:randomCrewIgnoringCrew(AddictedCrew))
                            msnMgr:addMessage(" ")
                            msnMgr:addMessage(HelperCrewName .. " lunges forward and grabs " .. AddictedName .. " by the arms, hauling them back out of the ship. Once outside, whatever was fuzzying-up their head clears.")
                            msnMgr:addMessage(" ")
                        end
                    else
                        msnMgr:addMessage(AddictedName .. " wanders further into the room, for some reason able to smell something in the water. This shouldn't be possible. Unfortunately, before you can figure out what's wrong, it's already too late. They reach up and unfasten their helmet to try and experience the imagined scent a bit more closely, and the minute they do, pressurized water floods their suit. They go quickly, if not exactly peacefully.")
                        msnMgr:addMessage(" ")

                        -- Already checked if crew alive
                        msnMgr:killCrew(AddictedCrew, "<charName> drowned after removing their helmet to better experience a \"smell\" in a submerged portion of a crashed ship.")
                        crewTraits()

                        msnMgr:addMessage("Under the circumstances, all seems lost. Even if everything were in order--the crew, the shuttle, the ship--it seems like the mission is not destined to be completed.")
                        msnMgr:addMessage(" ")

                        waitUserResponse("mv ~ /dev/null")

                        msnMgr:endGame(false)
                    end
                end
            elseif (GluttonousCrew ~= -1) then
                if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(GluttonousCrew, "physical")) then
                    GluttonousName = charMgr:getCharColoredName(GluttonousCrew)
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"Wow,\" says " .. GluttonousName .. ", \"something in here smells good.")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"That's not possible,\" you say. \"You're in a sealed atmospheric suit and surrounded by water.\"")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"No, for real,\" they say, taking a few steps forward. \"It's like... really intense. Like...\"")
                    msnMgr:addMessage(" ")

                    CrewRemaining = charMgr:depCrewLeft()
                    if (CrewRemaining >= 2) then
                        msnMgr:buildChoice("Let them explore")
                        msnMgr:buildChoice("Someone stop them")
                        msnMgr:finalizeChoice()
                        if(not waitUserInput(choices)) then
                            return
                        end

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

                        if (SmellsGood == 0) then
                            msnMgr:addMessage(" ")
                            msnMgr:addMessage(GluttonousName .. " wanders further into the room, for some reason able to smell something in the water. This shouldn't be possible. Unfortunately, before you can figure out what's wrong, it's already too late. They reach up and unfasten their helmet to try and experience the imagined scent a bit more closely, and the minute they do, pressurized water floods their suit. They go quickly, if not exactly peacefully.")
                            msnMgr:addMessage(" ")

                            -- Already checked if crew alive
                            msnMgr:killCrew(GluttonousCrew, "<charName> drowned after removing their helmet to better experience a \"smell\" in a submerged portion of a crashed ship.")
                            crewTraits()
                        elseif (SmellsGood == 0) then
                            HelperCrewName = charMgr:getCharColoredName(charMgr:randomCrewIgnoringCrew(GluttonousCrew))
                            msnMgr:addMessage(" ")
                            msnMgr:addMessage(HelperCrewName .. " lunges forward and grabs " .. GluttonousName .. " by the arms, hauling them back out of the ship. Once outside, whatever was fuzzying-up their head clears. Regardless, you think it's time for the crew to figure out a way back to the surface.")
                            msnMgr:addMessage(" ")
                        end
                    else
                        msnMgr:addMessage(GluttonousName .. " wanders further into the room, for some reason able to smell something in the water. This shouldn't be possible. Unfortunately, before you can figure out what's wrong, it's already too late. They reach up and unfasten their helmet to try and experience the imagined scent a bit more closely, and the minute they do, pressurized water floods their suit. They go quickly, if not exactly peacefully.")
                        msnMgr:addMessage(" ")
                        -- Already checked if crew alive
                        msnMgr:killCrew(GluttonousCrew, "<charName> drowned after removing their helmet to better experience a \"smell\" in a submerged portion of a crashed ship.")
                        crewTraits()

                        msnMgr:addMessage("Under the circumstances, all seems lost. Even if everything were in order--the crew, the shuttle, the ship--it seems like the mission is not destined to be completed.")
                        msnMgr:addMessage(" ")

                        waitUserResponse("mv ~ /dev/null")

                        msnMgr:endGame(false)
                    end
                end
            end
            --TODO: Pop some more story in here
            if (SkipExploring == 0) then
                msnMgr:buildChoice("Keep exploring")
                msnMgr:buildChoice("Don't touch anything, get out of there")
                msnMgr:finalizeChoice()
                if(not waitUserInput(choices)) then
                    return
                end

                ExploreInterior = msnMgr:getChoiceResponse(choices)
                choices = choices + 1
                if (ExploreInterior == 0) then
                    --Keep exploring
                    msnMgr:addMessage("You instruct the crew to proceed into the ship with caution.")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage(LeaderName .. " takes a moment, and then steps further into the room.")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"There's something...\" they say, shaking their head. \"I don't know how to describe it. It's faint, like a smell or sound that's too quiet to make out. I don't think it's affecting me beyond that.\"")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"I'm not picking anything up on any of your suit's sensors.\" you say. \"Continue for now, but if it gets any worse, say something.\"")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("The hallway extends further than the crew's helmet lamps can illuminate. Motes, sand, and bits of egg sac driting through the water reduce visibility significantly. Although you are able to track their movement from orbit without problems, suit readings show significant heart rate and adrenaline elevations.")
                    msnMgr:addMessage(" ")
                    if (ObservantCrew ~= -1) then
                        ObservantName = charMgr:getCharColoredName(ObservantCrew)
                        msnMgr:addMessage("\"Hey,\" says " .. ObservantName .. ". \"Is that a doorway up ahead?\"")
                        msnMgr:addMessage(" ")
                    elseif (CounselorCrew ~= -1 and charMgr:depCrewLeft() > 1) then
                        CounselorName = charMgr:getCharColoredName(CounselorCrew)
                        msnMgr:addMessage(CounselorName .. " opens a private channel. \"This is a very stressful environment. I don't think it would be a good idea to expose the crew for too much longer.")
                        msnMgr:addMessage(" ")
                        msnMgr:addMessage("You are about to tell the crew to make their way back outside when " .. LeaderName .. " sees a doorway up ahead.")
                        msnMgr:addMessage(" ")
                    else
                        msnMgr:addMessage("You are about to tell the crew to make their way back outside when " .. LeaderName .. " sees a doorway up ahead.")
                        msnMgr:addMessage(" ")
                    end
                    msnMgr:addMessage("As the crew approaches, you note that the wall surrounding the doorway is clear of the egg sacs that cover every other surface to the extent that the crew entirely misses that opposite the opened door is a closed one. Both doors have signs above them, but neither of them are legible.")
                    msnMgr:addMessage(" ")

                    msnMgr:buildChoice("Go through the open doorway")
                    msnMgr:buildChoice("See if there's a way to open the closed door")
                    msnMgr:buildChoice("Turn around and make your way back outside")
                    msnMgr:finalizeChoice()
                    if(not waitUserInput(choices)) then
                        return
                    end

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

                    if (ExploreInterior2 == 0) then
                        deepseaLunch = 1
                        msnMgr:addMessage("The open doorway seems like the best option. The ship seems sturdy, but prying open a door might change that. You tell the crew to enter.")
                        msnMgr:addMessage(" ")
                        msnMgr:addMessage("The water in the room is somehow darker, making it difficult to see. Either It has a different composition, or the particulate drifting around is absorbing a lot of light. You can make out faint lights through " .. LeaderName .. "'s suit cam as they enter the room, perhaps from status indicators or consoles.")
                        msnMgr:addMessage(" ")
                        if (charMgr:depCrewLeft() > 2) then
                            Victim2 = charMgr:randomCrewIgnoringCrew(charMgr:getLead())
                            Victim2Name = charMgr:getCharColoredName(Victim2)
                            msnMgr:addMessage("Suddenly, both " .. LeaderName .. " and " .. Victim2Name .. "'s suit cams go black. Before you can tell them to get out of there, " .. Victim2Name .. " screams, \"Something's got me!\"")
                            msnMgr:addMessage(" ")
                            msnMgr:killCrew(charMgr:getLead(), "<charName> was killed by an ink-dispensing entity in a submerged portion of a crashed ship.")
                            msnMgr:killCrew(Victim2, "<charName> was killed by an ink-dispensing entity in a submerged portion of a crashed ship.")
                            crewTraits()

                            msnMgr:addMessage("Through " .. LeaderName .. "'s suit camera, you see an ink-like blackness spreading out of the open doorway as the screams are cut abruptly short.")
                            msnMgr:addMessage(" ")
                            waitUserResponse("Get the hell out of there, now!")
                            msnMgr:addMessage(" ")
                            msnMgr:addMessage("You tell the crew to run, but they are already in full flight, moving as fast as the weight of their suits allows, until they are outside the ship, slamming the hatch closed behind them.")
                            msnMgr:addMessage(" ")
                            msnMgr:addMessage("\"I can't--What the hell was that?\" asks " .. charMgr:getCharColoredName(charMgr:randomCrew()) .. ", panting.")
                            msnMgr:addMessage(" ")
                            msnMgr:addMessage("You don't know, and you don't think it's a good idea to hang around and find out.")
                            msnMgr:addMessage(" ")
                        else
                            --If you've got 2 crew left, we can let one live
                            msnMgr:addMessage("Suddenly, " .. LeaderName .. "'s suit cam goes black. Before you can tell them to get out of there, " .. LeaderName .. " screams, \"Something's got me!\"")
                            msnMgr:addMessage(" ")
                            msnMgr:killCrew(charMgr:getLead(), "<charName> was killed by an ink-dispensing entity in a submerged portion of a crashed ship.")
                            crewTraits()
                            if (charMgr:depCrewLeft() > 0) then
                                msnMgr:addMessage("Through " .. LeaderName .. "'s suit camera, you see an ink-like blackness spreading out of the open doorway as the screams are cut abruptly short.")
                                msnMgr:addMessage(" ")
                                waitUserResponse("Get the hell out of there, now!")
                                msnMgr:addMessage(" ")
                                msnMgr:addMessage("You tell the crew to run, but they are already in full flight, moving as fast as the weight of their suits allows, until they are outside the ship, slamming the hatch closed behind them.")
                                msnMgr:addMessage(" ")
                                msnMgr:addMessage("\"I can't--What the hell was that?\" asks " .. charMgr:getCharColoredName(charMgr:randomCrew()) .. ", panting.")
                                msnMgr:addMessage(" ")
                                msnMgr:addMessage("You don't know, and you don't think it's a good idea to hang around and find out.")
                                msnMgr:addMessage(" ")
                            else
                                if (charMgr:crewOnShipLeft() == true) then
                                    msnMgr:addMessage("The away team has been lost, but the overall mission is still salvageable. As long as there is at least one human crew member alive, you still have a job to do. The odds are not in their favor, but it's not over yet.")
                                    msnMgr:addMessage(" ")

                                    waitUserResponse("Remote pilot the shuttle back to the ship")

                                    msnMgr:endMission(true)
                                else
                                    msnMgr:addMessage("Under the circumstances, all seems lost. Even if everything were in order--the crew, the shuttle, the ship--it seems like the mission is not destined to be completed.")
                                    msnMgr:addMessage(" ")
                                    waitUserResponse("mv ~ /dev/null")
                                    msnMgr:endGame(false)
                                end
                            end
                        end
                    elseif (ExploreInterior2 == 1) then
                        msnMgr:addMessage("If anything is likely to be intact and not covered by layers of sea-growth, it's going to be behind a closed door. You ask the crew to see if they can open it.")
                        msnMgr:addMessage(" ")
                        UnlockCrew = charMgr:getEng()
                        if (UnlockCrew == -1) then
                            UnlockCrew = charMgr:getLead()
                        end
                        if (charMgr:getCharTrait(UnlockCrew, "Observant") or charMgr:getCharTrait(UnlockCrew, "Mechanic") or charMgr:getCharTrait(UnlockCrew, "Lucky")) then
                            msnMgr:addMessage("\"Ah ha!\" says " .. charMgr:getCharColoredName(UnlockCrew) .. ", prying open a door release override panel. After bleeding the door control pistons, the door slides smoothly into the bulkhead.")
                            msnMgr:addMessage(" ")
                        elseif (charMgr:getCharTrait(UnlockCrew, "Strong") or charMgr:getCharTrait(UnlockCrew, "Stubborn") or charMgr:getCharTrait(UnlockCrew, "Athlete")) then
                            msnMgr:addMessage(charMgr:getCharColoredName(UnlockCrew) .. " grunts and puts their weight into pushing the door. You don't expect them to be successful, but either the pistons controlling the door had already been bled, or they'd corroded, and the door slides smoothly into the bulkhead.")
                            msnMgr:addMessage(" ")
                        else
                            if (charMgr:depCrewLeft() > 1) then
                                msnMgr:addMessage(charMgr:getCharColoredName(UnlockCrew) .. " grunts and puts their weight into pushing the door. You don't expect them to be successful, but after a lot of heaving and puffing, the crew manages to pry the door open.")
                                msnMgr:addMessage(" ")
                            else
                                msnMgr:addMessage(charMgr:getCharColoredName(UnlockCrew) .. " grunts and puts their weight into pushing the door. You don't expect them to be successful, but after a lot of heaving and puffing, they manage to pry the door open.")
                                msnMgr:addMessage(" ")
                            end
                        end
                        msnMgr:addMessage("Inside, the crew's helmet lamps illuminate some kind of lab. None of the computer interfaces in the room seem functional, and it's unclear what kind of work was done here. There are several bio storage canisters stacked beneath a workbench, and in the center of the room is a cryo pod.")
                        msnMgr:addMessage(" ")
                        InspectCrew = charMgr:getMed()
                        if (InspectCrew == -1) then
                            InspectCrew = charMgr:getLead()
                        end
                        if (charMgr:getCharTrait(InspectCrew, "Surgeon") or charMgr:getCharTrait(InspectCrew, "Mechanic") or charMgr:getCharTrait(InspectCrew, "Observant")) then
                            msnMgr:addMessage(charMgr:getCharColoredName(InspectCrew) .. " looks over the pod. \"This is powered... I can't tell if it's occupied or not, but it seems to be running.")
                            msnMgr:addMessage(" ")
                        end
                        msnMgr:addMessage("Status lights on the pod indicate that some kind of malfunction has occurred, but what that means for the pod's occupant--if it is occupied--is not clear. Assuming the Omega Epsilon's cryo pods as the same as the ones on board the Argo, its power regulator can hold enough charge that it could be disconnected and brought to the surface before shutting down.")
                        msnMgr:addMessage(" ")
                        msnMgr:addMessage("The canisters on the other hand are far more portable and are likely to contain something that can be converted to food.")
                        msnMgr:addMessage(" ")

                        msnMgr:buildChoice("Take the canisters")
                        msnMgr:buildChoice("Disconnect the pod")
                        msnMgr:finalizeChoice()
                        if(not waitUserInput(choices)) then
                            return
                        end

                        podOrCanisters = msnMgr:getChoiceResponse(choices)
                        choices = choices + 1
                        if (podOrCanisters == 0) then
                            msnMgr:addMessage("Getting the pod to the surface would be a gamble, both with its contents and the crew's dwindling oxygen supply. You tell the crew to grab as many canisters as they can and make their way out of the ship.")
                            msnMgr:addMessage(" ")
                            canistersGot = charMgr:depCrewLeft()
                        else--if (podOrCanisters == 1) then
                            msnMgr:addMessage("Finding a new home for what's left of humanity is your mission, and that includes any you might find along the way. You tell to disconnect the cryo pod and carry it outside.")
                            msnMgr:addMessage(" ")
                            msnMgr:addMessage("The pod is quickly detached, and the crew is able to maneuver it outside without incident. Even though they were primarily intended for use in zero gravity, the cryo pods used in interstellar ships were designed to be light and easily carried. At this depth, the pod is naturally buoyant.")
                            msnMgr:addMessage(" ")
                        end
                    else--if (ExploreInterior2 == 2) then
                        msnMgr:addMessage("You haven't found any new answers, but the crew's elevated stress levels increase the likelihood of a mishap. You instruct them to retrace their steps and exit the ship.")
                        msnMgr:addMessage(" ")
                    end
                else--if (ExploreInterior == 1) then
                    --Get out of there
                    msnMgr:addMessage("It's impossible to determine what happened here, but clearly the ship has become home to something other than humans. Weighing up the options, there might be more to discover, or there might be more to lose. Regardless, you think it's time for the crew to figure out a way back to the surface.")
                    msnMgr:addMessage(" ")
                end
            end
        end

    elseif (ShipPartSearch == 1) then
        msnMgr:addMessage(" ")
        msnMgr:addMessage("Once the crew circles around to the back section of the submerged ship segment, it becomes clear that it's not entirely intact, and in fact appears to have been heavily modified at some point, probably post-submerging. There are large holes in the sides, clearly not caused by any sort of natural damage or corrosion as they are perfectly smooth.")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("One of the holes in particular looks rather interesting, and you ask the crew to get a closer look. Rather than being flush with the surface of the ship, this one has a small protuberance attached, and upon closer inspection it turns out to be about a meter long piece of flexible material, its purpose unknown. It flutters slightly in the current.")
        msnMgr:addMessage(" ")

        if (ObservantCrew == charMgr:getEng()) then
            if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(charMgr:getEng(), "mental")) then
                msnMgr:addMessage("\"It looks like some sort of exhaust tube,\" says " .. EngineerName .. ". \"Ventilation tubing of some sort. If you were blowing hot water out of that, and the hose were longer though... that might even explain the distribution of the shells up above.\"")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("It would not, however, explain the purpose for such a thing. You can imagine a few scenarios where such a thing might make sense but speculation at this point would do nothing but waste time and oxygen.")
                msnMgr:addMessage(" ")
            else
                msnMgr:addMessage("\"It looks like some sort of vacuum tube,\" says " .. EngineerName .. ". \"With a long enough hose you could vaccuum up all these little critters pretty efficiently.\"")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("You can imagine a few scenarios where such a thing might make sense but speculation at this point would do nothing but waste time and oxygen.")
                msnMgr:addMessage(" ")
            end
        else
            if (msnMgr:random() % msnMgr:getDiffScale(10,15,20) <= charMgr:getCharAttr(charMgr:getEng(), "mental")) then
                msnMgr:addMessage("\"It looks like some sort of exhaust tube,\" says " .. EngineerName .. ". \"Ventilation tubing of some sort. If you were blowing hot water out of that, and the hose were longer though... that might even explain the distribution of the shells up above.\"")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("It would not, however, explain the purpose for such a thing. You can imagine a few scenarios where such a thing might make sense but speculation at this point would do nothing but waste time and oxygen.")
                msnMgr:addMessage(" ")
            else
                msnMgr:addMessage("\"It looks like some sort of vacuum tube,\" says " .. EngineerName .. ". \"With a long enough hose you could vaccuum up all these little critters pretty efficiently.\"")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("You can imagine a few scenarios where such a thing might make sense but speculation at this point would do nothing but waste time and oxygen.")
                msnMgr:addMessage(" ")
            end
        end

        msnMgr:addMessage(" ")
        msnMgr:addMessage("In addition to the holes all over the back of the ship, there are of course numerous things the crew wants to dig around in. The same sorts of things that, on your ship, are purposely only accessible from outside, to prevent the crew from breaking stuff.")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("There are two areas that it would be fairly safe for the crew to access, however. One of these would be a refueling panel, within which they might be able to locate some spare fuel rods that could be repurposed, if they're not completely spent. And since this thing is throwing off heat, you're imagining that they've still got some juice left.")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("You could also have them pry around inside the sensors, to try and find the enhanced sensory apparatus allegedly aboard this particular ship. That would theoretically be accessed from a panel near the very back of the wreckage, but it appears to be located rather near one of the larger ventilation holes and it might be dangerous.")
        msnMgr:addMessage(" ")
        msnMgr:addMessage("Either one will take an hour to open up--these things were not meant to be easily accessible--and there's only time for one before the crew will have to start working on a way back to the surface.")
        msnMgr:addMessage(" ")

        msnMgr:buildChoice("Try to get the fuel")
        msnMgr:buildChoice("Go after the sensors")
        msnMgr:finalizeChoice()
        if(not waitUserInput(choices)) then
            return
        end

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

        if (FuelOrSensors == 0) then
            msnMgr:addMessage(" ")
            msnMgr:addMessage("The panels that the crew needs to remove to get access to the fuel supply are half buried in sediment, but with some effort and the better part of an hour, they manage to pry one of the panels loose and collect several of the fuel rods used aboard this ship. Using a few spare segments of tubing lying on the sea floor, they should be able to safely transport them back to the shuttle.")
            msnMgr:addMessage(" ")
            fuelGot = 20;
        elseif (FuelOrSensors == 1) then
            msnMgr:addMessage(" ")
            msnMgr:addMessage("The heat is intense near the sensory access panel; the ship's reactor--or something else inside the wreckage--is generating immense heat, and the water near the panel is hot enough to trigger sensor warnings on the atmospheric suits.")
            msnMgr:addMessage(" ")

            if (ToughCrew ~= -1) then
                if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(ToughCrew, "physical")) then
                    ToughName = charMgr:getCharColoredName(ToughCrew)
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage(ToughName .. " grits their teeth and ignores the warnings and the bit of pain they feel from being in close proximity to the heat source. It takes a few agonizing minutes, but they manage to get the panel pried off, and indeed, the sensor mechanisms you expected to be there are still present. They're small enough to be easily carried back to the shuttle, and if they're adaptable then they should boost your ship's sensors nicely.")
                    msnMgr:addMessage(" ")
                    sensorsGot = 2;
                end
            elseif (CygenCrew ~= -1) then
                if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(CygenCrew, "physical")) then
                    CygenName = charMgr:getCharColoredName(CygenCrew)
                    msnMgr:addMessage(CygenName .. " grits their teeth and ignores the warnings and the bit of pain they feel from being in close proximity to the heat source. It takes a few agonizing minutes, but they manage to get the panel pried off, and indeed, the sensor mechanisms you expected to be there are still present. They're small enough to be easily carried back to the shuttle, and if they're adaptable then they should boost your ship's sensors nicely.")
                    msnMgr:addMessage(" ")
                    sensorsGot = 2;
                end
            elseif (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <=  charMgr:getCharAttr(charMgr:crewWithMost("physical"), "physical")) then
                StrongName = getColoredNameForCrewWithMost("physical")
                msnMgr:addMessage(StrongName .. " grits their teeth and ignores the warnings and the bit of pain they feel from being in close proximity to the heat source. It takes a few agonizing minutes, but they manage to get the panel pried off, and indeed, the sensor mechanisms you expected to be there are still present. They're small enough to be easily carried back to the shuttle, and if they're adaptable then they should boost your ship's sensors nicely.")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("Unfortunately, the heat is too intense, and since one of the mechanisms is deeper inside the body of the ship, " .. StrongName .. " isn't able to retrieve both of them before having to retreat to cooler water.")
                msnMgr:addMessage(" ")
                sensorsGot = 1;
            end
        end
    end
    if (deepseaLunch == 0) then
        msnMgr:addMessage("Time is becoming a consideration at this point, and the crew must find a way back to the surface. Simply swimming back up to the shelf many meters above is not an option, not inside a heavy atmospheric suit. The suits were not designed for underwater use.")
        msnMgr:addMessage(" ")
    else
        msnMgr:addMessage("The crew is understandably eager to return to the surface, but even if they weren't, oxygen levels will become a concern soon. Simply swimming back up to the shelf many meters above is not an option, not inside a heavy atmospheric suit. The suits were not designed for underwater use.")
        msnMgr:addMessage(" ")
    end

    msnMgr:buildChoice("Walk along the base of the cliff, looking for an incline")
    msnMgr:buildChoice("Climb up the hard way")
    msnMgr:finalizeChoice()
    if(not waitUserInput(choices)) then
        return
    end

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

    if (SearchOrClimb == 0) then
        msnMgr:addMessage(" ")
        if (podOrCanisters == -1) then
            msnMgr:addMessage("It takes a bit longer, and some of the mollusks no doubt die in captivity along the way, but after an extra couple of hours the crew is able to locate a gently sloping incline and make their way back up. It's pitch black by the time they surface, and their suit oxygen levels are lower than is comforting, but before they collapse from exhaustion they manage to get back aboard the shuttle.")
            msnMgr:addMessage(" ")
            mollusksGot = mollusksGot - 5;
         elseif (podOrCanisters == 0) then
            msnMgr:addMessage("It takes a bit longer, but after an extra couple of hours the crew is able to locate a gently sloping incline and make their way back up. It's pitch black by the time they surface, and their suit oxygen levels are lower than is comforting, but before they collapse from exhaustion they manage to get back aboard the shuttle.")
             msnMgr:addMessage(" ")
         elseif (podOrCanisters == 1) then
            msnMgr:addMessage("It's slow going, but after an extra couple of hours the crew is able to locate a gently sloping incline and make their way back up. It's pitch black by the time they surface, and their suit oxygen levels are lower than is comforting, but before they collapse from exhaustion they manage to drag the pod aboard the shuttle.")
            msnMgr:addMessage(" ")
        end
    elseif (SearchOrClimb == 1) then
        msnMgr:addMessage(" ")
        if (podOrCanisters == -1) then
            msnMgr:addMessage("It's a bit more work, and they have to dump some of their heavier gear and peripherals in order to make the climb, but the crew manages to ascend without incident, aided by an updraft of warmer water and some previously unnoticed handholds. It's pitch black by the time they surface, and their suit oxygen levels are lower than is comforting, but before they collapse from exhaustion they manage to get back aboard the shuttle.")
            msnMgr:addMessage(" ")
            fuelGot = fuelGot - 10;
         elseif (podOrCanisters == 0) then
            msnMgr:addMessage("It's a bit more work, and they have to dump some of the canisters in order to make the climb, but the crew manages to ascend without incident, aided by an updraft of warmer water and some previously unnoticed handholds. It's pitch black by the time they surface, and their suit oxygen levels are lower than is comforting, but before they collapse from exhaustion they manage to drag themselves aboard the shuttle.")
             msnMgr:addMessage(" ")
            canistersGot = canistersGot - 2;
            if (canistersGot <= 0) then
                canistersGot = 1;
            end
         elseif (podOrCanisters == 1) then
            msnMgr:addMessage("It's slow going, and they have to dump some of their heavier gear and peripherals in order to make the climb, but the crew manages to ascend without incident, aided by an updraft of warmer water and some previously unnoticed handholds. It's pitch black by the time they surface, and their suit oxygen levels are lower than is comforting, but before they collapse from exhaustion they manage to drag the pod aboard the shuttle.")
            msnMgr:addMessage(" ")
         end
    end
end

function wrapup()
    if (podOrCanisters ~= 1) then
        msnMgr:addMessage("The journey to the surface of this planet has somehow managed to raise more questions than it answered, but the crew is nevertheless just glad that it's over with. They upload their data and hand over any samples they collected the minute the shuttle docks back with the ship, and then head off for some relaxation and a good meal while you process everything.")
        msnMgr:addMessage(" ")

        if (skipShip ~= 1) then
            msnMgr:addMessage("About all you're able to determine from the samples, however, is that an Earth ship crashed here at some indeterminate point in the past--probably intentionally--and that the ship got modified for some purpose that appeared to involve cultivating a food source in some way. There's no AI to ask these questions of, unfortunately, and no surviving humans, so whatever purpose it all had, it wasn't enough to sustain a colony. All the more reason to move onward. The planet is certainly capable of supporting life, but it's unsuitable for human habitation at this point.")
        msnMgr:addMessage(" ")
        end
    elseif (podOrCanisters == 1) then
        msnMgr:addMessage("The crew's suit readings make their exhaustion clear, but in spite of that, they rush to carry the pod down to the cryonics section of the crew quarters. By your calculations, the pod still has at least an hour's worth of power remaining, and the ship's drones are capable of carrying the pod. Their assistance won't change what's in the pod. You sense that the crew need this though, so you allow them to feel useful.")
        msnMgr:addMessage(" ")
        if (msnMgr:random() % msnMgr:getDiffScale(10,10,10) >= 5) then
            msnMgr:addMessage("The pod is quickly hooked up to one of the redundant cryonics bays, and you are able to interface with its systems and determine that the malfunction is with external status displays and had no affect on the pod's operation. Inside, its occupant appears to be a healthy human being.")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("You begin the revival process and inform the crew. You insist that they eat a meal and get some rest while waiting, but they hover nearby regardless.")
            msnMgr:addMessage(" ")
            if (charMgr:depCrewLeft() >= 2) then
                msnMgr:addMessage("\"I hope they can tell us what happened to their ship,\" says " .. getColoredNameForCrewWithLeast("social") .. ".")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("\"I'll just be happy to see a new face,\" says " .. getColoredNameForCrewWithMost("social") .. ". \"For some reason, I never thought we'd meet new people again.\"")
                msnMgr:addMessage(" ")
            else
                msnMgr:addMessage("\"I hope they're OK,\" says " .. getColoredNameForCrewWithMost("social") .. ". \"They've probably lost all their friends.\"")
                msnMgr:addMessage(" ")
            end
            waitUserResponse("Wait")
            msnMgr:addMessage(" ")
            SocialCrew = charMgr:crewWithMost("physical")
            SocialCrewPlainName = charMgr:getCharName(SocialCrew)
            msnMgr:addMessage("The occupant's heart rate, brain activity and body chemistry are all within appropriate ranges, and they slowly begin to rouse. As they groggily sit up and try to get their bearings, " .. charMgr:getCharColoredName(SocialCrew) .. " introduces themselves, \"Welcome aboard the Argo. My name is " .. SocialCrewPlainName:match("%s*(%S+)$") .. ". Is there anything you can tell us about what happened?\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("\"I'm Savio. I'm not sure. The last thing I remember was going into cryo before the Omega Epsilon left earth. What's happened? Have we arrived? Where's my family?\"")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("You allow the crew to bring Savio up to speed. Human voices and faces will do a far better job of helping them come to terms with the fate of their ship and their new life here.")
            msnMgr:addMessage(" ")
            msnMgr:addMessage("You had hoped to be able to find more answers, but maybe there were never any answers to be found.")
            msnMgr:addMessage(" ")

            charMgr:newCrew("Savio Krach");
            luaMgr:unlockAchievement("add_savio");
        else
            msnMgr:addMessage("The pod is quickly hooked up to one of the redundant cryonics bays, and you are able to interface with its systems and determine that the reported malfunction is with the unit's cooling system. Multiple critical components show signs of heat damage, and from what your sensors tell you of what's inside the pod, its occupant died long ago.")
            msnMgr:addMessage(" ")

            msnMgr:buildChoice("Tell the crew the occupant is dead")
            msnMgr:buildChoice("Tell the crew the pod was empty")
            msnMgr:finalizeChoice()
            if(not waitUserInput(choices)) then
                return
            end

            tellOrLie = msnMgr:getChoiceResponse(choices)
            choices = choices + 1
            if (tellOrLie == 0) then
                msnMgr:addMessage("You tell the crew that the pod's occupant has been dead for years. Their disappointment is evident, but their need for rest is greater. They quickly disperse to find food and sleep as you have drones disconnect the pod and transport it to the machine shop.")
                msnMgr:addMessage(" ")
            else
                msnMgr:addMessage("You tell the crew that the pod was empty. Their disappointment is evident, but their need for rest is greater. They quickly disperse to find food and sleep as you have drones disconnect the pod and transport it to the machine shop.")
                msnMgr:addMessage(" ")
            end

            msnMgr:addMessage("Some of the pod's parts are salvageable, and what's left of its occupant could be easily be fed into the food replicator.")
            msnMgr:addMessage(" ")

            msnMgr:buildChoice("Salvage the pod's components and convert its occupant's remains to food")
            msnMgr:buildChoice("Jettison the pod into space")
            msnMgr:finalizeChoice()
            if(not waitUserInput(choices)) then
                return
            end

            salvageOrSend = msnMgr:getChoiceResponse(choices)
            choices = choices + 1
            if (tellOrLie == 0) then
                if (salvageOrSend == 0) then
                    msnMgr:addMessage("You coordinate drones to siphon the pod's contents into the food replicator. While the process is underway, " .. LeaderName .. " wakes and wanders into the machine shop.")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"I guess it makes sense to not let anything go to waste,\" says " .. LeaderName .. ". \"I just wish we knew more about who they were and what happened to them.\"")
                    msnMgr:addMessage(" ")
                    ship:adjustFood(13) --in starvation, we get physical + 10 food. Savio's physical is 3
                else
                    msnMgr:addMessage("You coordinate drones to carry the pod to the forward airlock. While the process is underway, " .. LeaderName .. " wakes and follows.")
                    msnMgr:addMessage(" ")
                    msnMgr:addMessage("\"I guess it makes sense to pay respects,\" says " .. LeaderName .. ". \"I just wish we knew more about who they were and what happened to them.\"")
                    msnMgr:addMessage(" ")
                end
                msnMgr:addMessage("\"The pod's logs and records were corrupted,\" you say. \"But I was able to ascertain that the occupant's name was Savio Krach, and that they had likely been placed in stasis since before the Omega Epsilon departed Earth.\" You had hoped to be able to find more answers, but maybe there were never any answers to be found.")
                msnMgr:addMessage(" ")
            else
                if (salvageOrSend == 0) then
                    ship:adjustFood(13) --in starvation, we get physical + 10 food. Savio's physical is 3
                    msnMgr:addMessage("You coordinate drones to siphon the pod's contents into the food replicator.")
                    msnMgr:addMessage(" ")
                else
                    msnMgr:addMessage("You coordinate drones to carry the pod to the forward airlock, and push it into a stable orbit around Panshin 68.")
                    msnMgr:addMessage(" ")
                end
                msnMgr:addMessage("The pod's logs and records were corrupted, but you were able to ascertain that the occupant's name was Savio Krach, and that they had likely been placed in stasis since before the Omega Epsilon departed Earth. You had hoped to be able to find more answers, but maybe there were never any answers to be found.")
                msnMgr:addMessage(" ")
            end
        end
    end

    if (initialComedian ~= -1 and initialLeader ~= -1) then
        ComedianCrewName = charMgr:getCharColoredName(initialComedian)
        LeaderCrewName = charMgr:getCharColoredName(initialLeader)
        if (charMgr:crewIsAlive(initialLeader)) then
            if (charMgr:crewIsAlive(initialComedian)) then
                --comedian alive, leader alive
                msnMgr:addMessage("Some time later, you spot " .. ComedianCrewName .. " in the machine shop, drilling holes in a handful of shells.")
                msnMgr:addMessage(" ")
                waitUserResponse("What's all this about?")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("\"Shhh!\" hisses " .. ComedianCrewName .. ". \"It's for " .. LeaderCrewName .. ". I want it to be a surprise.\"")
                msnMgr:addMessage(" ")
                waitUserResponse("Okay then")
                msnMgr:addMessage(" ")
                msnMgr:addMessage(ComedianCrewName .. " finishes making the necklace and leaves it on " .. LeaderCrewName .. "'s bunk.")
                msnMgr:addMessage(" ")
            else
                --comedian dead, leader alive
                msnMgr:addMessage("Some time later, you spot " .. LeaderCrewName .. " in the machine shop, drilling holes in a handful of shells.")
                msnMgr:addMessage(" ")
                waitUserResponse("What's all this about?")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("\"Oh, hi,\" says " .. LeaderCrewName .. " \"I don't know whether it makes sense to be sentimental, but I felt like I should make this. For " .. ComedianCrewName .. ", you know?\"")
                msnMgr:addMessage(" ")
                waitUserResponse("I know")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("You talk about " .. ComedianCrewName .. " until " .. LeaderCrewName .. " finishes making the necklace, and then leave them to their thoughts.")
                msnMgr:addMessage(" ")
            end

            if (charMgr:hasMemento(initialLeader, "pearl1_necklace") ~= true) then
                charMgr:giveMemento(initialLeader, "pearl1_necklace")
            end
        else
            if (charMgr:crewIsAlive(initialComedian)) then
                --comedian alive, leader dead
                msnMgr:addMessage("Some time later, you spot " .. ComedianCrewName .. " in the machine shop, drilling holes in a handful of shells.")
                msnMgr:addMessage(" ")
                waitUserResponse("What's all this about?")
                msnMgr:addMessage(" ")
                msnMgr:addMessage(ComedianCrewName .. " jumps. \"Ah, you startled me! I was going to make this for " .. LeaderCrewName .. ", but... yeah.\"")
                msnMgr:addMessage(" ")
                waitUserResponse("Yeah")
                msnMgr:addMessage(" ")
                msnMgr:addMessage("You talk about " .. LeaderCrewName .. " until " .. ComedianCrewName .. " finishes making the necklace, and then leave them to their thoughts.")
                msnMgr:addMessage(" ")

                if (charMgr:hasMemento(initialComedian, "pearl1_necklace") ~= true) then
                    charMgr:giveMemento(initialComedian, "pearl1_necklace")
                end
            else
                --everybody's dead, nothing to do
            end
        end
    end

    if (fuelGot >= 1) then
        ship:adjustFuel(fuelGot)
    end
    if (canistersGot >=1) then
        ship:adjustFood(canistersGot * 10)
    end
    if (mollusksGot >= 1) then
        ship:adjustFood(mollusksGot)
    end
    ship:adjustSensors(sensorsGot, "Components salvaged from the underwater wreck of the Omega Epsilon allowed for sensor range to be increased.")
end

-- Set Hidden Flags and other items
choices = 0;
choicesCount = 2;
count = 1;
rechoicePosition = -1;
crewDead = 0;
recklessSaved = 0;
recklessDead = 0;
shallowsvisited = 0;
fuelGot = 0;
canistersGot = 0;
mollusksGot = 0;
sensorsGot = 0;
deepseaLunch = -1
podOrCanisters = -1
SearchOrClimb = -1
skipShip = 0;
initialLeader = -1;
initialComedian = -1;

crewTraits()

missionStart()

introduction()
shore()
islandchoice()

while(true) do
    if(not waitUserInput(choices)) then
        return
    end

    IslandChoice = msnMgr:getChoiceResponse(choices)
    rechoicePosition = choices;
    choices = choices + 1

    if (IslandChoice == 0) then
        inland()
    elseif (IslandChoice == 1) then
        shallows()
        shallowsvisited = 1;
    end

    if(shallowsvisited == 1) then
        break
    end
    msnMgr:rechoice(rechoicePosition)
end

deeperorleave()

-- while(true) do
    if(not waitUserInput(choices)) then
        return
    end

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

    if (UpOrDown == 0) then
        backup()
    elseif (UpOrDown == 1) then
        shelf()
    end
-- end

if (skipShip ~= 1) then
    shipShip()
end

wrapup()

missionOverview()

msnMgr:endMission(true)
