Modding Help Spawn randomly generated items?

Discussion in 'Starbound Modding' started by DeathofaStar, Dec 10, 2013.

  1. DeathofaStar

    DeathofaStar Tentacle Wrangler

    So I tried to spawn them...and I keep getting cubes of sadness (Perfectly Generic Items, aka the green cubes, but I call them cubes of sadness because they make me sad when I see them =c). What is wrong with my code?

    {
    "id" : "hylotltutorial.gearup",
    "title" : "^#9be3d6;Fish Out Of Water",
    "text" : "You have been drifting in space for some time, unable to choose a planet to explore. Finally your ship has run out of fuel in orbit of an unknown planet, making your choice for you. Before setting out in search of fuel, ^green;search your ship's storage for a ^pink;matter manipulator^white;. Press ^green;E ^white;to interact with objects.",
    "completionText" : "Well done! The matter manipulator allows you to manipulate almost anything in the gameworld.",
    "conditions" : [
    { "kind" : "gather", "item" : [ "beamaxe", 1] }
    ],
    "moneyRange" : [10, 10],
    "rewards" : [
    [ "generatedgun", 1, { "definition" : "legendarysniperrifle" } ],
    [ "generatedgun", 1, { "definition" : "legendaryassaultrifle" } ],
    [ "generatedgun", 1, { "definition" : "legendaryflamethrower" } ],
    [ "generatedgun", 1, { "definition" : "rareplasmaassaultrifle" } ],
    [ "generatedgun", 1, { "definition" : "rareplasmasniperrifle" } ],
    [ "generatedgun", 1, { "definition" : "legendaryrocketlauncher" } ]
    ],
    "planetMode" : "none",
    "questDungeons" : [ ],
    "followUp" : "tutorial2.gearup"
    }


    Edit1: updated code to reflect changes from suggestions in posts
     
    Last edited: Dec 10, 2013
  2. Supergeek

    Supergeek Scruffy Nerf-Herder

    I think we should call them Cones of Shame. I feel ashamed when I see them because I know I messed up.

    Sorry, no idea about your quest problem. I haven't done any quest work yet.
     
  3. Matterialize

    Matterialize Scruffy Nerf-Herder

    You've got two left brackets after "rewards": line. Remove one and see if it works.
     
  4. DeathofaStar

    DeathofaStar Tentacle Wrangler

    No dice, I have tried it with other items and they spawn fine (non generated ones).
     
  5. Aigis

    Aigis Tentacle Wrangler

    You can't spawn randomly generated items. You can add them to treasure pools, however.

    For instance, navigate to assets\treasure and open hunting.treasurepools. A sample entry will look like this:

    Code:
    "pool" : [
              [0.11, [ "generatedgun", 1, { "definition" : "legendarygrenadelauncher" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "legendaryassaultrifle" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "rareplasmashotgun" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "legendaryflamethrower" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "legendarypistol" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "legendarymachinepistol" } ] ],
              [0.11, [ "generatedsword", 1, { "definition" : "teslastaff" } ] ],
              [0.11, [ "generatedsword", 1, { "definition" : "watersword" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "legendaryrocketlauncher" } ] ]
            ],
    
    Obviously you can just add your entries in, but the value at the start needs to be there. As far as I'm aware it's how likely an item is to drop, out of 1. Also, this is the treasure pool used for hunting, if it isn't clear...

    You can also add it to the default treasure given to new characters in default.treasurepools, which would look like this, I think:

    Code:
    "avianStarterTreasure" : [
        [0, {
            "fill" : [
               [ "generatedgun", 1, { "definition" : "legendaryrocketlauncher" } ],
               [ "generatedgun", 1, { "definition" : "legendarymachinepistol" } ],
               [ "generatedsword", 1, { "definition" : "teslastaff" } ],
               [ "generatedsword", 1, { "definition" : "watersword" } ]
            ],   
    
     
    Last edited: Dec 10, 2013
  6. Slenderkid

    Slenderkid Tentacle Wrangler

    Check your code for comas in every line.
     
  7. Sloan

    Sloan Master Chief

    It worked ok however came with very bad damage
     
  8. Aigis

    Aigis Tentacle Wrangler

    You can change the levelVariance entry to spawn better guns. By default, the starter treasure and hunting rewards are the lowest level.
     
  9. Sloan

    Sloan Master Chief

    How can I change this level?
    And the max level is 10?

    I can try
    Code:
      [ "generatedgun", 1, { "definition" : "legendaryrocketlauncher", "level" : 10 } ]
    Edit:
    this code did not work kept the same.
     
    Last edited: Dec 14, 2013
  10. Aigis

    Aigis Tentacle Wrangler

    Take this for an example:

    Code:
    {
      "hunting" : [
        [1, {
            "pool" : [
              [0.11, [ "generatedgun", 1, { "definition" : "legendarygrenadelauncher" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "legendaryassaultrifle" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "rareplasmashotgun" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "legendaryflamethrower" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "legendarypistol" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "legendarymachinepistol" } ] ],
              [0.11, [ "generatedsword", 1, { "definition" : "teslastaff" } ] ],
              [0.11, [ "generatedsword", 1, { "definition" : "watersword" } ] ],
              [0.11, [ "generatedgun", 1, { "definition" : "legendaryrocketlauncher" } ] ]
            ],
            "poolRounds" : [
              [0.10, 0],
              [0.90, 1]
            ],
            "levelVariance" : [592, 600],
            "allowDuplication" : false
          } ]
      ]
    }
    
    Change the 592, 600 to the desired level range. As far as I'm aware it means it'll randomly roll between the two.

    The field is the same in other files; "levelVariance" like I said in my first post.
     
    Sloan likes this.
  11. Sloan

    Sloan Master Chief

    thx :p wroked
     
    Aigis likes this.
  12. Supergeek

    Supergeek Scruffy Nerf-Herder

    Sure you can.

    Code:
    world.spawnItem("generatedgun", object.toAbsolutePosition({ 0.0, 6.0 }), 1, { level = 5} )
     
  13. kik4444

    kik4444 Existential Complex

    Where do you write that???
     
  14. Aigis

    Aigis Tentacle Wrangler

    That comment was in reference to people trying to add randomly generated guns to quests the same as everything else.
     
  15. NerArth

    NerArth Pangalactic Porcupine

    So far the only way I know that works is through treasure drops. Look at this modified basicmonstertreasure.treasurepools

    Code:
    {
      "basicMonsterTreasure" : [
        [1, {
            "pool" : [
              [0.25, [ "generatedgun", 1, { "definition" : "congloomerateassaultrifle" } ] ],
              [0.25, [ "generatedgun", 1, { "definition" : "congloomeratepistol" } ] ],
              [0.25, [ "generatedgun", 1, { "definition" : "congloomerateteb" } ] ],
              [0.25, [ "generatedsword", 1, { "definition" : "congloomerateenergyblade" } ] ]
            ],
            "poolRounds" : [
              [0.20, 0],
              [0.80, 1]
            ],
            "levelVariance" : [0, 0],
            "allowDuplication" : false
          } ],
    I've tried many other ways that I was even trying to come up with at some point, I've got none to work. Things would be so MUCH simpler if only we could know all the valid arguments/values for fields.

    Edit: Actually, look here.
     
    Last edited: Dec 26, 2013

Share This Page