Random Loot Through Tags/Pools

Discussion in 'RPG Maker MV' started by Inamortus, Jan 3, 2017.

Thread Status:
Not open for further replies.
  1. Inamortus

    Inamortus The Eternal One Veteran

    Messages:
    33
    Likes Received:
    2
    First Language:
    English
    In the game I'm currently building, I want to award loot at random from a pool of items based on the type of chest opened. Put simply, there are Common, Uncommon, Rare, Boss and Demon chests. I wanted to know if there's a way to do this with some plugin I can't find. I'm aware I can achieve it through conditional branches, but we're talking A LOT of items, here. So, while that's an option, it's my last resort due to the amount of time it would require to event all of it.


    In short, I need a plugin that will randomly award loot chosen from all items with a specific tag: items tagged with 'Common' from Common Chests, 'Uncommon' from Uncommon Chests, and so forth. Any help would be greatly appreciated. Also, if I'm missing some way to event it more simply, without using control variable, conditional branch for all the items, that'd be just as good.


    Thanks.
     
    #1
  2. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,667
    Likes Received:
    7,536
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    Here's my incomplete thought process. You have, say an uncommon chest. All uncommon items are in the database, say, #20-30. So for an uncommon chest you would set a variable equal to a random number from 20-30. Then, in my ideal scenario here, you could use the script call for adding items, and set the itemId equal to the value of the variable. I'm just not certain at this point the best way to go about that, and maybe someone could enlighten us on that? Because if so, you could avoid a plugin. But, not sure if that's possible.


    $gameParty.gainItem($dataItems[itemId], n);
     
    #2
  3. Inamortus

    Inamortus The Eternal One Veteran

    Messages:
    33
    Likes Received:
    2
    First Language:
    English
    Interesting idea. I should've said that some items come under multiple rarities, which might be an issue with that.
     
    #3
  4. LadyBaskerville

    LadyBaskerville Hell-poodle Veteran

    Messages:
    645
    Likes Received:
    483
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    There might be a (more or less) simple way if you have set up your items in such a way that all the items from one tier are directly underneath each other in the database. If that is the case, set a variable to a random number between the IDs of the first and the last item of the tier (I'll assume variable #12, but you can change that) and then use this script call:


    $gameParty.gainItem($dataItems[$gameVariables.value(12)], 1);


    This will give the player one item with the ID that is contained in variable #12. It you're using Yanfly's Message Core, you can use something like "Found1 \ni[\V[12]]!" in a message window afterwards if you want to tell the player what they got.
     
    #4
  5. Inamortus

    Inamortus The Eternal One Veteran

    Messages:
    33
    Likes Received:
    2
    First Language:
    English
    Thank you, I'll give this a go. I haven't actually implemented a lot of the items yet, so a little rearranging won't be too bad.


    Also, I've just realised I can just have multiple entries of the same item if it's multiple rarities, shouldn't cause any issues, should it?
     
    #5
  6. Inamortus

    Inamortus The Eternal One Veteran

    Messages:
    33
    Likes Received:
    2
    First Language:
    English
    Okay, that works, except for the text; it just shows the number of the variable ie, "You recieved [74]".


    EDIT: I was about 110% sure I had Message Core, but apparently not, Just downloaded it and now it works. Thank you so much for your help, you've saved me a lot of time!
     
    Last edited by a moderator: Jan 3, 2017
    #6
  7. LadyBaskerville

    LadyBaskerville Hell-poodle Veteran

    Messages:
    645
    Likes Received:
    483
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    I didn't see the two posts above mine when I wrote my answer, so I didn't take the rarities into account...


    Making multiple entries would cause the game to treat them as different items, so they wouldn't stack in the invertory, for example, which would be a bit weird. I would rather sort them again inside the tier, so that it looks like this:


    items #1-20: 'Common' tier, normal rarity


    items #21-40: 'Common' tier, rare


    items #41-50: 'Common' tier, very rare


    and wrap a random variable - conditional branches setup around those three groups of items to give e.g. the 'normal' items a 5/10 chance, the 'rare' items a 3/10 chance and the 'very rare' items a 2/10 chance. That would give you one conditional branch per rarity, which may or may not be practical depending on the number of rarities you want.


    For the text: Do you have Yanfly's Message Core installed in your project? That's where the \ni textcode comes from.
     
    #7
  8. Inamortus

    Inamortus The Eternal One Veteran

    Messages:
    33
    Likes Received:
    2
    First Language:
    English
    I'm not too bothered about this. The game's a dungeon crawler, all items are removed after each run, and with the amount of items there are, it's extremely unlikely you'll get two of the same thing.
     
    #8
  9. LadyBaskerville

    LadyBaskerville Hell-poodle Veteran

    Messages:
    645
    Likes Received:
    483
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    In that case, you're probably fine with multiple entries, if it doesn't become too impractical for you to handle multiple copies of the same item in the database. (That's what I'd be worried about if I did this in my project, because I'm the kind of person that will always miss one of the Potions when changing their properties for balancing :D )
     
    #9
  10. Inamortus

    Inamortus The Eternal One Veteran

    Messages:
    33
    Likes Received:
    2
    First Language:
    English
    That's a good point now I think of it... Hmm, I'll have to do some thinking on it. Also, another quick question, if I were to do the same thing for weapons and armour, would I just need to do the same but change the script call to:


    $gameParty.gainWeapons($dataWeapons[$gameVariables.value(12)], 1);




    And obviously the same for amours.
     
    #10
  11. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,667
    Likes Received:
    7,536
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    @Inamortus, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


    Next time, just edit your post to add more info. Thanks.


    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
     
    #11
Thread Status:
Not open for further replies.

Share This Page