Random Loot

Discussion in 'JS Plugin Releases (RMMV)' started by Astfgl66, Dec 3, 2016.

  1. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    649
    Likes Received:
    494
    First Language:
    French

    Astfgl's Random loot
    Hi everyone! This simple plugin was made to handle random loot and its display.

    I've seen the request for such a system pop up a few times and, although this can be evented to a certain degree, I thought a plugin could help.

    Features:
    • From user defined loot tables, give random loot.
    • Use items as bags of loot via notetags, without using a common event.
    • Handles weapons, armors, items and gold.
    • Use the parameters to automate the item gain message via variables.
    • V1.2: Trigger monster encounters. Only tested on the map screen. Use at your own risk for items in menu or during battle.
    • V1.2: Return the loot table, deleting the item the player just got. This allows you to remove randomly gained items from the loot table so that your player doesn't get the same possibility twice from the same loot table. You'll have to store the loot table in a variable beforehand.
    • V1.3: Loot bags are now purchasable and can instantly open upon purchase, just add <LTPurchase> to your item.
    • V1.4: Items can now have several loot tables, just add more loot tables like this: <lootTable:>, <lootTable2:>, <lootTable3:>,... Please note that the variables defined in parameters will only contain info for the last obtained item.
    • V1.5: Loot tables can now roll for other loot tables

    Download:


    Terms of use: Find them in the plugin file for reference. Pasted below:

    Code:
    // Free to use both commercially and non commercially.
    // Edits allowed, but the product must be released with the same license.
    // Credits required: any of Astfgl/Pierre MATEO/Pierre MATEO (Astfgl)
    // Reposts allowed.
    
    Setup:
    • Download the plugin, name the file AstfglLT save it as a .js .
    • Setup parameters as you see fit.
    Usage: Refer to the plugin's help file.

    Example:
    Excuse the MS Paint editing:
    [​IMG]

    Known Bugs:
    • None
    Credits:
    • Astfgl66
     
    Last edited: Oct 8, 2017
    #1
    zarasrage, Raths Rants, MMMm and 2 others like this.
  2. Isabella Ava

    Isabella Ava Veteran Veteran

    Messages:
    636
    Likes Received:
    751
    First Language:
    English
    awesome, this is really helpful with my current project
     
    #2
  3. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    649
    Likes Received:
    494
    First Language:
    French
    It's been a while since I last posted in that thread, but there has been multiple updates now. You can find the updated feature list in the original post.

    I'm posting now to let users know that a bug introduced in 1.4 that prevented items to be consumed upon use is fixed.
    Thanks to @Allerka for catching it and sending a bug report!

    Have a nice day, and happy making!
     
    #3
  4. Aeonhart

    Aeonhart Villager Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Spanish
    EDIT* easier question

    can this plugin call a plugin command instead of delivering an item?
     
    Last edited: Oct 8, 2017
    #4
  5. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    649
    Likes Received:
    494
    First Language:
    French
    Unless I misunderstood something, just call for random loot three times: first on the normal, then on the uncommon and finally on the rare loot table.

    Loot tables are just arrays, so if you want to make an array from selected elements of a loot table, you'll have to do a bit of array manipulation. It's very simple javascript that a bit of googleing will solve.

    If you are unable: just do it by hand.
     
    #5
  6. Aeonhart

    Aeonhart Villager Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Spanish
    My apologies for not explaining myself.

    Basically instead of having a single item as a table item, i want to have a rarity, then if I get that rarity get a random item from that array.

    ex: <lootTable:[[1,common,1,100],[1,uncommon,1,70],[1,rare,1,30],[3,superrare,1,5]>

    So lets say I script on common event

    var common = [0, 1, 2]
    $gameVariables.setValue(0001, common);

    var uncommon = [3, 4, 5]
    $gameVariables.setValue(0002, uncommon);

    How do I integrate it ? will this work?

    $gameMap.loot([[2,$gameVariables.value(0001),100, ],[2,$gameVariables.value(0002),1,20]])

    If so, how can I make it so it will only give me 1 item and not the full array?
     
    #6
  7. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    649
    Likes Received:
    494
    First Language:
    French
    Okay, that wasn't possible, but it was an easy addition.
    I've made an update to the plugin, allowing for what you asked.

    So following your example, you'd do:
    Code:
    var common = lootTable1;
    var rare = lootTable2;
    var legendary = lootTable3;
    var lootTable = [[5,common,0,75],[5,rare,0,20],[5,legendary,0,5]]
    $gameMap.loot(lootTable)
    
    For a 75% chance to roll on the common loot table, 20% for a rare roll, and 5% for a legendary roll.

    By the way: no leading zeros on numbers: $gameVariables.value(1) and not 0001.
     
    #7
  8. Aeonhart

    Aeonhart Villager Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Spanish
    holly crap this is amazing thank you!
     
    #8

Share This Page