Modding Help smashDropOptions

Discussion in 'Starbound Modding' started by Denesta, Dec 30, 2013.

  1. Denesta

    Denesta Subatomic Cosmonaut

    I wanted to make a little gambling type game. You buy a pod, place it on the ground, then mash it to see what comes out. You my get your money back, you may get nothing at all or you may even get a jackpot.

    I am a little confused how these smashDropOptions for those little capsules you find scattered all over planets works.

    Code:
      "smashDropOptions" : [
        [
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ]
        ]
    It looks like every option is for it drop one gold coin but in game these things clearly drop more than one gold at a time. What am I missing here?

    Also is there anyway to add a drop chance like on crops?
     
  2. Synit

    Synit Subatomic Cosmonaut

    I am not sure I am completely correct about this, but I think that what you are looking at is the "goldcoin" item it only determines how many of those items you will see come out of the pot, NOT the value of the pixel itself. I am however not sure what determines the value of the "goldcoin" pixel.
     
  3. Denesta

    Denesta Subatomic Cosmonaut

    Hmm, perhaps I should instead make an item like the holiday monster boxes. So instead of placing an object to break the player would be placing a killable entity that can drop items from a loot pool?
     
  4. Synit

    Synit Subatomic Cosmonaut

    I just tested it for you by changing the code myself, it seems that each smash drops exactly 6 coins. So if you were to for an example do

    Code:
      "smashDropOptions" : [
        [
            [ "goldcoin", 100, { } ]
    
        ]
    It would drop 1 coin with the value of 100 pixels.

    If you did

    Code:
      "smashDropOptions" : [
        [
            [ "goldcoin", 10, { } ],
            [ "goldcoin", 10, { } ],
            [ "goldcoin", 10, { } ]
    
        ]
    It would drop 3 coins with a value of 10 each, for a total of 30 pixels.

    Basically the code you linked drops 6 coins with a value of 1 pixel each, for a total value of 6 pixels.

    Get it now? :)
     
  5. Denesta

    Denesta Subatomic Cosmonaut

    Oh, wow. I always though they dropped a random range of coins. I guess I never payed close enough attention to them. This was a silly question then. >.<

    Now to poke around and see if I can add a drop percentage too it.

    Thanks for the help. :)
     
  6. Synit

    Synit Subatomic Cosmonaut

    Your welcome ;)
     
  7. Denesta

    Denesta Subatomic Cosmonaut

    Alrighty, so I am still poking around at this and I found you can add more drop sets to the list.

    This would sometimes drop 6 coins like normal and sometimes drop 3. It looks to just be a 50/50 chance for both. (There was also one instance were it said 9 pixels at the bottom but I may have just not waited long enough in between picking them up and it added the 6 and 3 together.)
    Code:
      "smashDropOptions" : [
        [
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ]
        ],
        [
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ]
        ]
      ],
    But if I try something like this it doesn't work.
    Code:
      "smashDropOptions" : [
        0.3,
        [
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ]
        ],
        [
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ]
        ]
      ],
    So I can get multiple seemingly random drops from the item but I can't set drop chances. Am I doing it wrong or is that just impossible with this function?
     
  8. Corazoor

    Corazoor Void-Bound Voyager

    Well, the code reminds me strongly of the way FTL does its randomization:
    Each entry in the list simply has the same probability. To increase the probability, list it multiple times...

    So, in your case, you might look for this:
    Code:
      "smashDropOptions" : [
        [
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ]
        ],
        [
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ]
        ],
        [
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ],
            [ "goldcoin", 1, { } ]
        ]
      ],
    I didn't test this, but i suspect it would select each one with the same probability, which is 1/3.
    And since the last two options are really the same, you should get a distribution of 1/3 to 2/3.
    I have to go now, but try it out, i definitely think that this works.
     
  9. Denesta

    Denesta Subatomic Cosmonaut

    I am sure that will work. I was just hoping there was a cleaner way to do it. If you want something like a 1% chance to drop 10000 pixels and the rest of the time it drops dirt you have to put dirt as an option 99 times. If you want it to drop nothing sometimes you are out of luck.

    All the other types of drop lists seems to have a way to have a way to and a change percent to the drops. I guess they just didn't think this one needed it or I am putting it in the wrong place.
     

Share This Page