Random Loot Through Tags/Pools

Status
Not open for further replies.

Inamortus

The Eternal One
Veteran
Joined
Oct 21, 2012
Messages
33
Reaction score
2
First Language
English
Primarily Uses
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.
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,570
Reaction score
8,640
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);
 

Inamortus

The Eternal One
Veteran
Joined
Oct 21, 2012
Messages
33
Reaction score
2
First Language
English
Primarily Uses
Interesting idea. I should've said that some items come under multiple rarities, which might be an issue with that.
 

LadyBaskerville

Hell-poodle
Veteran
Joined
Sep 12, 2016
Messages
645
Reaction score
529
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.
 

Inamortus

The Eternal One
Veteran
Joined
Oct 21, 2012
Messages
33
Reaction score
2
First Language
English
Primarily Uses
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.

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?
 

Inamortus

The Eternal One
Veteran
Joined
Oct 21, 2012
Messages
33
Reaction score
2
First Language
English
Primarily Uses
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:

LadyBaskerville

Hell-poodle
Veteran
Joined
Sep 12, 2016
Messages
645
Reaction score
529
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.
 

Inamortus

The Eternal One
Veteran
Joined
Oct 21, 2012
Messages
33
Reaction score
2
First Language
English
Primarily Uses
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'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.
 

LadyBaskerville

Hell-poodle
Veteran
Joined
Sep 12, 2016
Messages
645
Reaction score
529
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 )
 

Inamortus

The Eternal One
Veteran
Joined
Oct 21, 2012
Messages
33
Reaction score
2
First Language
English
Primarily Uses
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.
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,570
Reaction score
8,640
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.
 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Bendyizzt wrote on staggqueen's profile.
Hello Newcomer...
I haven't make anything new yet, but I'm back addicted to writing some MZ plugins. Man, I wish I have more free time like I did 5 years ago.
Holy cow... work is demanding and I'm back in college. I'm kind of scared of my dad right now after the incident, but at least I don't live with him all the time. Anyway, working on Fandom Scouts and my FNAF character set. The FNAF sprites are actually going to be used in the game... unfortunately the enemy sprites are FNAF World traces, so no sharing those.

Forum statistics

Threads
107,690
Messages
1,031,475
Members
139,813
Latest member
Jeffery_Liu
Top