function reticulatingsplines()
    RandomOne = msnMgr:random() % msnMgr:getDiffScale(3,3,3)
    if (RandomOne == 0) then
        prefix = "arctic";
        foodgathered = foodgathered + 2;
    elseif (RandomOne == 1) then
        prefix = "temperate";
        foodgathered = foodgathered + 4;
    elseif (RandomOne == 2) then
        prefix = "equatorial";
        foodgathered = foodgathered + 6;
    elseif (RandomOne == 3) then
        prefix = "tropical";
        foodgathered = foodgathered + 8;
    end

    RandomTwo = msnMgr:random() % msnMgr:getDiffScale(3,3,3)
    if (RandomTwo == 0) then
        suffix = " desert";
        foodgathered = foodgathered + 1;
    elseif (RandomTwo == 1) then
        suffix = " grassland";
        foodgathered = foodgathered + 3;
    elseif (RandomTwo == 2) then
        suffix = " forest";
        foodgathered = foodgathered + 5;
    elseif (RandomTwo == 3) then
        suffix = " ocean";
        foodgathered = foodgathered + 7;
    end

    RandomThree = msnMgr:random() % msnMgr:getDiffScale(3,3,3)
    if (RandomThree == 0) then
        prefix2 = "arctic";
        foodgathered2 = foodgathered2 + 2;
    elseif (RandomThree == 1) then
        prefix2 = "temperate";
        foodgathered2 = foodgathered2 + 4;
    elseif (RandomThree == 2) then
        prefix2 = "equatorial";
        foodgathered2 = foodgathered2 + 6;
    elseif (RandomThree == 3) then
        prefix2 = "tropical";
        foodgathered2 = foodgathered2 + 8;
    end

    RandomFour = msnMgr:random() % msnMgr:getDiffScale(3,3,3)
    if (RandomFour == 0) then
        suffix2 = " swamp";
        foodgathered2 = foodgathered2 + 1;
    elseif (RandomFour == 1) then
        suffix2 = " savanna";
        foodgathered2 = foodgathered2 + 3;
    elseif (RandomFour == 2) then
        suffix2 = " jungle";
        foodgathered2 = foodgathered2 + 5;
    elseif (RandomFour == 3) then
        suffix2 = " sea";
        foodgathered2 = foodgathered2 + 7;
    end

    RandomFive = msnMgr:random() % msnMgr:getDiffScale(5,10,15)
    if (RandomFive == 0) then
        prefixsuffix = "coastal estuary";
        foodgathered3 = foodgathered3 + msnMgr:random() % msnMgr:getDiffScale(20,15,10);
    elseif (RandomFive == 1) then
        prefixsuffix = "inland sea";
        foodgathered3 = foodgathered3 + msnMgr:random() % msnMgr:getDiffScale(25,20,15);
    end
end

function piloting()
    pilotCrew = charMgr:randomCrew()
    pilotName = charMgr:getCharColoredName(pilotCrew)

    pilotTrait = "None"
    for key, trait in pairs(traitList) do
        if (charMgr:getCharTrait(pilotCrew, trait)) then
            pilotTrait = trait
        end
        if (pilotTrait ~= "None") then
            break
        end
    end

    if (msnMgr:random() % msnMgr:getDiffScale(5,10,15) <= charMgr:getCharAttr(pilotCrew, "physical")) then
        if (pilotTrait == "Athlete") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They do an admirable job, and pull off some impressive maneuvers.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Disabled") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They do a manageable job, although they lack a bit of finesse.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Empathic") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They do an admirable job, and seem to have an innate sense of what areas to focus on.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Gluttonous") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They do a manageable job, although they seem more focused on the most obvious food sources rather than those which are most nutrient-dense.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Comedian") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They crack jokes the entire time, but manage to do a good job nevertheless.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Kleptomaniac") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They do a manageable job, although they do seem hesitant to maneuver freely while being watched.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Polite") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They take criticism well, and make adjustments when you ask them to.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Loner") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They don't listen to piloting advice, however, and so you let them make mistakes on their own.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Stealthy") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They somehow manage to bring the shuttle right up behind a flock of birdlike creatures without being noticed.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Stubborn") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They make a few mistakes, and unfortunately when you try to correct them they insist on simply plowing on ahead.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Strong") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They hit some turbulence but are able to power through it and stay on course.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Weak") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They have a hard time keeping the shuttle on course due to some unexpected turbulence.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Tough") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They run into some bad weather on the way down, but manage to tough it out.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Abstemious") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They aren't distracted by flashy, shiny flowers and fruits, and focus on seeking out more nutrient-dense material.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Counselor") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. Their cool demeanor allows them to select the proper course of action and then follow through.")
            msnMgr:addMessage(" ")
        elseif (pilotTrait == "Politician") then
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They show excellent leadership qualities, even when the only one they're leading is themself.")
            msnMgr:addMessage(" ")
        else
            msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They perform capably.")
            msnMgr:addMessage(" ")
        end
    else
        msnMgr:addMessage("Back on the ship, " .. pilotName .. " volunteers to remote pilot the shuttle. They perform capably.")
        msnMgr:addMessage(" ")
    end

    positiveTrait = false
    for key, trait in pairs(traitListPositive) do
        if (pilotTrait == trait) then
            positiveTrait = true
            break
        end
    end

    if (positiveTrait) then
        foodgathered = foodgathered + 5;
        foodgathered2 = foodgathered2 + 5;
        foodgathered3 = foodgathered3 + 5;
    else
        foodgathered = foodgathered - 5;
        foodgathered2 = foodgathered2 - 5;
        foodgathered3 = foodgathered3 - 5;
    end
end

function mission()
    msnMgr:addHeader("Sensors are not getting a good reading on this planet, so it's unwise to send the crew down. You instruct the crew to remain on the ship, and detach the shuttle for a quick excursion to scoop up some raw materials.")
    msnMgr:addHeader(" ")
    msnMgr:addHeader("There are two spots where it seems like you might have a good chance at harvesting food. You only have time for one of them, however, and in either case it's going to be a very quick pass.")
    msnMgr:addHeader(" ")

    if (RandomFive <= 1) then
        msnMgr:buildChoice("Collection site 1: " .. prefixsuffix)
    else
        msnMgr:buildChoice("Collection site 1: " .. prefix .. suffix)
    end
    msnMgr:buildChoice("Collection site 2: " .. prefix2 .. suffix2)
    msnMgr:finalizeChoice()
    if(not waitUserInput(choices)) then
        return
    end

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

    msnMgr:addMessage(" ")

    piloting()

    msnMgr:addMessage("With the airlock open, the shuttle dips down low and collects a sample of organic matter, then heads quickly back to the ship. By the time it docks, the onboard drones have sorted through the collected material and purged anything harmful.")
    msnMgr:addMessage(" ")

    if (FoodChoice == 0) then
        if (RandomFive <= 1) then
            foodgatheredfinal = foodgathered3;
        else
            foodgatheredfinal = foodgathered;
        end
    elseif (FoodChoice == 1) then
        foodgatheredfinal = foodgathered2;
    end

    if (foodgatheredfinal >= 1) then
        ship:adjustFood(foodgatheredfinal)
    else
        ship:adjustFood(1)
    end

end

-- Set Hidden Flags and other items

choices = 0;
prefix = 0;
prefix2 = 0;
suffix = 0;
suffix2 = 0;
prefixsuffix = 0;
foodgathered = 0;
foodgathered2 = 0;
foodgathered3 = 0;
foodgatheredfinal = 0;
pilotCrew = -1
pilotTrait = ""
traitList = {"Athlete", "Disabled", "Empathic", "Gluttonous", "Comedian", "Kleptomaniac", "Polite", "Loner", "Stealthy", "Stubborn", "Strong", "Tough", "Weak", "Abstemious", "Counselor", "Politician"}
traitListPositive = {"Athlete", "Empathic", "Abstemious", "Comedian", "Polite", "Stealthy", "Strong", "Tough", "Counselor", "Politician"}
traitList = shuffleList(traitList)

crewTraits()

missionStart()

reticulatingsplines()
mission()

missionOverview()

msnMgr:endMission(true)
