Modding Help Defining item + reward pools in generated fetch quests?

Discussion in 'Starbound Modding' started by Marinebeast, Aug 14, 2017.

  1. Marinebeast

    Marinebeast Existential Complex

    So I'm working on a custom fetch quest for my mod-- a hungry squid wants specific food, and he'll give you something interesting stuff for your time. Cute, repeatable quest that encourages the player to make food from the mod. I've been able to figure it out mostly through reverse-engineering the vanilla assets, but some things aren't explicitly spelled out.

    1. How do you define the item that is asked for? I'm assuming this has to do with the quests/generated/pools/ files. For instance, a baking quest uses "cake" as its example under "itemList", so can it pull from anything in the cookedfood.config, which contains "cake"? I want to make a custom .config that uses food from my mod.

    2. Is it possible to define a treasurepool that can randomly be selected from for rewards? I'd like to add some randomness to the rewards if possible, but I'm not quite sure how to figure that out just yet -- when I tried to reference specific treasurepools in the rewards array, it spat errors at me until I emptied the array out. I know there's an outpost NPC that gives randomly-generated weapons, though.
    2b. Alternatively, does the "itemList" also work here, such as with the "extraRewards" seen in some quests? Because that would work just as well.

    Thank you in advance, I really appreciate the help!
  2. AngleWyrm

    AngleWyrm Scruffy Nerf-Herder

    Creating a random loot drop curve
    Let's say we wish to pull treasure from a set of items from several lists, {common, uncommon, rare, ... }. We'd like to roll a single random number and have it return some sort of reference to one of those sets according to a reasonable assessment of what the terms common, uncommon, rare, ... mean. So how can we do that?

    Let's start by looking at a bell curve that has been set to have a peak of 1
    y = e^(-x^2/2)
    The x range goes from -infinity to +infinity, so it isn't possible to roll a dice on x and get a y. But the y range goes from 0 to 1, which would work out quite nicely for rolling an random number. So lets take a look at rotating the graph sideways:

    y = sqrt(2) * sqrt( log(1/x) )
    Now there's a range that we can roll a random number on, that returns a z score from 0 (most common) to +infinity (least common).

    // returns a category index, where 0=common, 1=uncommon, 2=rare, ...
    int getCategory{
        float roll= 0;
        while(roll == 0){ // don't want the RNG rolling 0 (infinitely rare)
          roll = Random.nextFloat();
        return (int) sqrt(2) * sqrt( log(1/roll) );
    It could be further modified to pass a maximumCategory paramenter that modifies the roll test to be while(roll < minRoll), where minRoll is calculated from the maximum desired category.
    Last edited: Aug 17, 2017
    xaliber and The Avelon like this.
  3. The Avelon

    The Avelon Phantasmal Quasar

    Exceedingly useful! Deceptively informative!
    This is layman's terms for some simple (ish) mathematics that anyone could learn but few do because of when this technique is most often taught.
    This should be enshrined in a wiki how-to page somewhere.


    AngelWyrm answered part 2, so, for the first part:

    You're gonna want to create item pools, it sounds like. I'm getting into this myself and I'm reverse engineering "Pay Up - Rent" to figure out how. I would attempt to explain but I don't want to risk talking out my rear - but it does seem relatively straightforward. Each pool is a list of possible items, and you can op add items to pools directly or remotely through a secondary config file (for scripting).

    Good luck! Looking forward to seeing a release. =)
  4. Marinebeast

    Marinebeast Existential Complex

    That's a frightening post with math and I am trying my best to understand it!
    And I'm not entirely sure it answers the questions I was looking at-- I do already have a grasp of treasurepools and how to make/patch/modify them. I was more looking at if there was a way to have quests select a treasure pool to give rewards from, since specifying quest rewards seems somewhat vague outside of making them give specific items.

    As for the other thing-- alright, cool. Yeah, it seems about right given the nature of generated quests and the way they use examples and lists containing those examples, so I'll have to go do that.
  5. AngleWyrm

    AngleWyrm Scruffy Nerf-Herder

    So this mod converts the infinite resource food into another form. The nice thing about food is that it's a wide stream of stuff that can be produced in abundance. There are other streams of stuff that are more of a trickle; still infinite but much less of them per day spent playing the game.

    Needful Things
    Hunger is easy to satisfy because the stream of food that a player can make happen is greater than how fast they eat it; the player has a surplus of production. Wood is also a resource that the player needs lots of and can make lots of. A big supply for a big demand.

    What about those streams of stuff that aren't in balance? Does the player need more plant fiber than is usually available? Where does the game stall out waiting on resources? These places are an opportunity to supply unmet demand, the job of the merchant transferring from excess to shortage.
    Last edited: Aug 22, 2017

Share This Page