Modding Help Reducing the Randomness of Harvest TreasurePools?

Discussion in 'Starbound Modding' started by Mackinz, Feb 3, 2015.

  1. Mackinz

    Mackinz The Waste of Time

    I am in the process of updating my Rattan mod, still. I have virtually worked out all possible kinks, aside from some misc "learnblueprintsonpickup" stuff. There is one other thing I have struggled with, though, and that is balancing the drops from the Rattan crop.

    You see, as best I can tell, HarvestPools are completely randomized based on the values you have put in. In my case, it looks like this:

    Code:
    [ 
    { "op": "add", "path": "/rattanHarvest", "value": 
     [
        [0, {
          "pool" : [
            {"weight" : 0.59, "item" : "rattanfiber"},
            {"weight" : 0.39, "item" : "rattannut"},
            {"weight" : 0.02, "item" : "plantfibre"}
          ],
          "poolRounds": [
            [0.55, 25],
            [0.3, 33],
            [0.15, 40]
          ]
        } ]
      ]
    }
    ]
    
    My goal was to emulate my original balance of the Rattan crop from Enraged Koala, but the results are not as I hoped.

    Original drop coding snippet:

    Code:
          "dropOptions" : [
            0.3,
            [
              {
                "name" : "rattannut",
                "count" : 6
              },
              {
                "name" : "rattanfiber",
                "count" : 19
              },
              {
                "name" : "plantfibre",
                "count" : 2
              }
            ],
            [
              {
                "name" : "rattannut",
                "count" : 9
              },
              {
                "name" : "rattanfiber",
                "count" : 16
              },
              {
                "name" : "plantfibre",
                "count" : 2
              }
            ],
            [
              {
                "name" : "rattannut",
                "count" : 12
              },
              {
                "name" : "rattanfiber",
                "count" : 13
              },
              {
                "name" : "plantfibre",
                "count" : 2
              }
            ]
          ],
    
    As you can see, I had set values for each item, with an increase of "rattannut" as the amount of "rattanfiber" decreased. I do not have time to really fiddle with my mods today (or until Friday, basically), so can I ask for some help balancing out my update to my Rattan mod?
     
  2. The | Suit

    The | Suit Agent S. Forum Moderator

    Best Answer
    You should be able to mix and match accordingly

    Code:
    "instrument" : [
        [0, {
          "pool" : [
            {"weight" : 0.0007, "item" : [ "accordion", 1]},
            {"weight" : 0.0008, "item" : [ "acousticguitar", 1]},
            {"weight" : 0.0007, "item" : [ "banjo", 1]},
            {"weight" : 0.0007, "item" : [ "bassguitar", 1]}
          ],
         "poolRounds" : [
            [0.3, 1],
            [0.4, 2],
            [0.3, 3]
          ],
         "fill" : [
                    {"item" : [ "bananahead", 10]} ]
        }]
    ]
     
    Xordaii and Mackinz like this.
  3. Mackinz

    Mackinz The Waste of Time

    So I tried fiddling with the values I originally listed. Found something interesting.

    With this coding:

    Code:
    [ 
    { "op": "add", "path": "/rattanHarvest", "value": 
     [
        [0, {
          "pool" : [
            {"weight" : 1.00, "item" : "rattanfiber" },
            {"weight" : 1.00, "item" : "rattannut"}
          ],
          "poolRounds": [
            [0.34, 300],
            [0.33, 200],
            [0.33, 100]
          ]
        } ]
      ]
    }
    ]
    
    By my understanding of the system, I thought that it would either give me an Error in the log or give me 1 of each object. Neither happened.

    The drops ended up totaling up to the total amount of rolls done.

    See:

    [​IMG]

    This was a 300 roll. Other rolls I got were 47/53 and 98/102, among many others. This result surprised me.

    Does anyone have a better understanding of this system?
     
  4. The | Suit

    The | Suit Agent S. Forum Moderator

    What I understood is

    Weight is chance
    pool round is number of loops / quantity

    so weight object a = 0.5 = 50% chance
    Weight of object b = 0.5 = 50% chance

    with 33% chance of # of pool rounds
    So first it will see if the pool round will occur. If it does it will then give object A a spin. If it drops then goes to B and then C etc. Until it runs out.
    Then once the list is exhausted it will see if a 2nd pool round exists if it does it will repeat the process over again

    The 2nd number in poolround is # of pool rounds 152 + 148 = 300
    You can use Sub pools to balance out the numbers better.
     
    Last edited: Feb 4, 2015
    Mackinz likes this.
  5. Mackinz

    Mackinz The Waste of Time

    What is a "Sub pool"?
     
  6. The | Suit

    The | Suit Agent S. Forum Moderator

    When you look at the treasure files you will notice 2 different types

    Code:
    {"weight" : 0.025, "item" : "flare" }
    {"weight" : 0.04, "pool" : "shield"}
    
    So it referencing the "shield" pool.
    You will notice these sub pools have no pool rounds
     
    Mackinz likes this.
  7. Mackinz

    Mackinz The Waste of Time

    Right. Okay.

    Now are there any ways to reduce the absolute randomness of the "pools" system? I want to guarantee a certain number of each item upon harvest, at the very least. I tried using "count" in the following code to no avail:

    Code:
    [
    { "op": "add", "path": "/rattanHarvest", "value": 
    [
        [0, {
          "pool" : [
            {"weight" : 1.00, "item" : "rattanfiber", "count" : 10},
            {"weight" : 1.00, "item" : "rattannut", "count" : 10}
          ],
          "poolRounds": [
            [0.34, 300],
            [0.33, 200],
            [0.33, 100]
          ]
        } ]
      ]
    }
    ]
    
     
  8. The | Suit

    The | Suit Agent S. Forum Moderator

    If you want to gauntee use fill

    Code:
    {
          "fill" : [
            {"item" : [ "bananahead", 10]}
          ]
        }
    oh I made a mistake the 2nd number is how many rounds in pool rounds
    So 300 = 300 rounds/
     
    Mackinz likes this.
  9. Mackinz

    Mackinz The Waste of Time

    Okay, noted. Wouldn't it be more like this, though:

    Code:
    [
    { "op": "add", "path": "/rattanHarvest", "value":
    [
        [0, {
          "fill" : [
            {"item" : [ "bananahead", 10]}
          ]]
      ]
    }
    ]
    
    Also, how could I add randomness on top of that?
     
  10. The | Suit

    The | Suit Agent S. Forum Moderator

    Best Answer
    You should be able to mix and match accordingly

    Code:
    "instrument" : [
        [0, {
          "pool" : [
            {"weight" : 0.0007, "item" : [ "accordion", 1]},
            {"weight" : 0.0008, "item" : [ "acousticguitar", 1]},
            {"weight" : 0.0007, "item" : [ "banjo", 1]},
            {"weight" : 0.0007, "item" : [ "bassguitar", 1]}
          ],
         "poolRounds" : [
            [0.3, 1],
            [0.4, 2],
            [0.3, 3]
          ],
         "fill" : [
                    {"item" : [ "bananahead", 10]} ]
        }]
    ]
     
    Xordaii and Mackinz like this.
  11. Mackinz

    Mackinz The Waste of Time

    Thank you sooo much! I'll be back after I do some testing.[DOUBLEPOST=1423039695][/DOUBLEPOST]Okay, I tried the following configuration:

    Code:
    [
    { "op": "add", "path": "/rattanHarvest", "value":
      [
        [0, {
         "pool" : [
            {"weight" : 0.66, "item" : [ "rattanfiber", 3]},
            {"weight" : 0.66, "item" : [ "rattannut", 3]},
         ],
         "poolRounds" : [
            [0.3, 1],
            [0.4, 2],
            [0.3, 3]
         ],
         "fill" : [
            {"item" : [ "rattanfiber", 13]},
            {"item" : [ "rattannut", 6]},
            {"item" : [ "plantfibre", 2]}
          ]
        } ]
      ]
    }
    ]
    
    And got the following series of errors in the log, before the game crashed:


    [00:44:16.313] Error: Exception caught loading asset: /treasure/harvest.treasurepools, (AssetException) Could not read variant asset /treasure/harvest.treasurepools
    StarException::StarException(string, exception)
    AssetException::AssetException(string, exception)
    _Function_handler<shared_ptr<Assets::AssetData> (), Assets::loadVariant(String)::{lambda()#1}>::(_Any_data)
    Assets::processAssetData(function<shared_ptr<Assets::AssetData> ()>)
    Assets::loadVariant(String)
    Assets::loadAsset(Assets::AssetId)
    Assets::doLoad(Assets::AssetId)
    Assets::workerMain()
    ThreadImpl::runThread(void*)
    BaseThreadInitThunk
    RtlInitializeExceptionChain
    RtlInitializeExceptionChain

    Caused by: (JsonParsingException) Cannot parse json file: /treasure/harvest.treasurepools
    StarException::StarException(string, exception)
    Assets::readVariant(String)
    _Function_handler<shared_ptr<Assets::AssetData> (), Assets::loadVariant(String)::{lambda()#1}>::(_Any_data)
    Assets::processAssetData(function<shared_ptr<Assets::AssetData> ()>)
    Assets::loadVariant(String)
    Assets::loadAsset(Assets::AssetId)
    Assets::doLoad(Assets::AssetId)
    Assets::workerMain()
    ThreadImpl::runThread(void*)
    BaseThreadInitThunk
    RtlInitializeExceptionChain
    RtlInitializeExceptionChain

    Caused by: (JsonParsingException) Error parsing json: unexpected character parsing word at 8:4
    JsonParsingException::JsonParsingException(string)
    Variant inputUtf8Json<char*>(char*, char*, bool)
    Assets::readVariant(String)
    _Function_handler<shared_ptr<Assets::AssetData> (), Assets::loadVariant(String)::{lambda()#1}>::(_Any_data)
    Assets::processAssetData(function<shared_ptr<Assets::AssetData> ()>)
    Assets::loadVariant(String)
    Assets::loadAsset(Assets::AssetId)
    Assets::doLoad(Assets::AssetId)
    Assets::workerMain()
    ThreadImpl::runThread(void*)
    BaseThreadInitThunk
    RtlInitializeExceptionChain
    RtlInitializeExceptionChain

    [00:44:16.432] Info: Renderer initialized
    [00:44:16.484] Error: Exception raised during Root finishLoad: (AssetException) Error loading asset /treasure/harvest.treasurepools
    AssetException::AssetException(string)
    Assets::getAsset(Assets::AssetId)
    Assets::variant(String)
    TreasureDatabase::TreasureDatabase()
    Root::load(bool)
    Root::finishLoad()
    _Function_handler<void (), _Bind<ClientApplication::preSplashInitialization()::{lambda()#1} ()> >::(_Any_data)
    ThreadImpl::runThread(void*)
    BaseThreadInitThunk
    RtlInitializeExceptionChain
    RtlInitializeExceptionChain

    [00:44:16.816] Info: Writing Star::Configuration to '.\../giraffe_storage\starbound.config'
    [00:44:20.096] Info: Renderer destroyed
    [00:44:20.193] Info: Shutting down Star::Root
    [00:44:20.531] Error: Fatal Exception Caught: (StarException) An error occurred during loading: (AssetException) Error loading asset /treasure/harvest.treasurepools
    ClientApplication::postSplashInitialization()
    ClientApplication::update()
    StarApplicationBase::run()
    _SDL_main
    _console_main


    Any idea why? I checked the code at 8:4 and only found a comma...

    EDIT: I am so stupid. I missed a comma, so it expected a value instead of a bracket. Testing once more...

    EDIT 2: YEP, working fantastically now. Thank you so much @xxswatelitexx !
     
    Last edited: Feb 4, 2015
  12. The | Suit

    The | Suit Agent S. Forum Moderator

    No problem
     
    Mackinz likes this.

Share This Page