Yawgmoth

Veteran
Veteran
Joined
Jan 9, 2018
Messages
138
Reaction score
11
First Language
English
Primarily Uses
RMMV
Hi all,

I have a fairly complete database of weapons, armors, and items. I am using Yanfly's augment plugin to add sockets to armors and weapons which considerably increases both weapons and armors. I am looking for a fast and easy way to generate random loot. I think I would like this to be in the form of a common event so it can be used easily.

I have three variables so far :

1) Variable #99 named "Loot Type" which chooses between weapon, armor, or item. This could be increased to add gold as a random option but I have no clue how to award gold as a random number.

2) Variable #98 named "Sockets (Yes or No)" which will allow the items to be chosen from the socket list or the non socket list.

3) Variable #100 named "Loot Roller" which selects the rolled items ID. Socketed Weapons: 109-227, Non Socketed weapons 2-33, and 91. Socketed Armor: 112-240, Non Socketed 1-31 and 52-69, 90, 105-107, and 110. Items: 1-21, 43-48, 90-100.

Unfortunately I have hundreds of items and an event of this magnitude will most likely have errors on my part. I would like to hear some options from the community. How do you all go about random loot? So far I only have eventing experience and even variables are relatively new to me. The thought of eventing something like using conditional branches makes me cringe. I'm looking forward to everyone's opinions and helpful advice. Thanks in advance.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,782
Reaction score
14,015
First Language
English
Primarily Uses
RMMV
I think it would be fairly easy to do, but the problem you haven't discussed is how to avoid giving the player an end-game type of item when they're just starting. If you were to add gold, would you want a player who was 10 minutes into the game getting 10,000 gold?

You could actually do all of that using just one variable.
 

Yawgmoth

Veteran
Veteran
Joined
Jan 9, 2018
Messages
138
Reaction score
11
First Language
English
Primarily Uses
RMMV
@Shaz thanks for your quick reply. I excluded quest items and boss loot from the random roll. That's one reason there is some gaps in my database as far as IDs are concerned. If gold was chosen it could be a minor problem but honestly my game is small and everything is centered around one hub town. I would personally keep the gold amounts small, as the purchase price of items, weapons and armor are very low in my game compared to others. Also that is if I chose to use gold which I am not sure I want to for the same reason you mentioned. I would also be careful with the placement of chests, and even thought about the player finding lock boxes that have been magically sealed and need a mage to open them, the mage then wants a fee to open the lock box. I am however more concerned with how other people have implemented random loot into their games and how they did it? Thanks for your reply and I did not know I could use just one variable thanks for that info.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,800
Reaction score
5,358
First Language
English
Primarily Uses
RMVXA
Script lines are your friend here.

To gain an Item, Weapon, or Armor, the script line is: $gameParty.gainItem(loot, quantity, include_equip);

loot is the thing that the player will receive, for example $dataWeapons[12] for Weapon ID #12 in your database. $dataItems[n] and $dataArmors[n] are how you would reference Items or Armors instead, with n being the ID in your database.

quantity is the number of that thing you'll gain, usually 1.

include_equip is mostly used for when weapons or armor are being removed from the party's inventory and therefore is irrelevant to your purpose, so just set it to false.

Therefore, instead of having a hundred different branches of your code based on a random variable roll, you can do something like roll 1-5, and if the result is 1-3, you give the player a random item, 4 a random weapon, 5 a random armor. Then roll a second time, 1-50 or whatever. Plug the result of that roll as "n" into $dataItems[n] to give the player a random item. The value of a Variable can be fetched using the code $gameVariables.value(x). For example, if you've decided to give the player an item and you use Variable #108 to roll the Item the player is getting, the script line would be:

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

This looks terribly complex, but the good news is that this one line substitutes for ALL of the conditional branches you'd need to give the player different random items.

You can balance this system better by having different "tiers" of battle difficulty in your game (designated based on the area where the chest is found, or some other criterion), and equate those with "tiers" of items you can receive from chests. Arrange the items/weapons/armors in your database accordingly, for example 1 is the weakest item (a simple potion, a wooden sword) and 50 is the strongest item (a party-wide full heal elixir, Excalibur). In the treasure event, first designate the tier to draw from, and then randomize the result within that tier. For example, if Tier 2 treasures should give you something with an ID from 20 to 39, then draw a random result from 20 to 39 (instead of from the full list of 1 to 50), and then plug that random selection into the script lines above, just like you would if it were a fully random selection from 1 to 50.
 

Yawgmoth

Veteran
Veteran
Joined
Jan 9, 2018
Messages
138
Reaction score
11
First Language
English
Primarily Uses
RMMV
@Wavelength Thanks for your reply, It looks like script is definitely the way to go. I have no experience using script other than copy and pasting it into events. I understood some of what you said, I think. Instead of conditional branches in the event I would use one line of script for each time I would need to roll? Also do I need a separate variable for each line of script or can it be the same variable each time? I may need walked through this process a little further once I start working on this event, I hope that will be alright? I am sure more questions will arise.

Thank you for your time.

UPDATE: I started working on the event. This is what I have so far. Screenshots below.
 

Attachments

  • Screenshot (26).png
    Screenshot (26).png
    293.6 KB · Views: 24
  • Screenshot (28).png
    Screenshot (28).png
    287.2 KB · Views: 22
Last edited:

mobiusclimber

Veteran
Veteran
Joined
May 3, 2018
Messages
265
Reaction score
150
First Language
english
Primarily Uses
RMMV
For some games, I use a prefix/suffix plugin that allows random prefixes and suffixes on items. Then I use small stat gains for early weapons/armor, and larger ones for later ones. This works for certain types of games. For other types, I don't let random enemies drop weapons or armor. Either it's a boss, and I don't randomize what they drop, or it's a treasure chest, and I do a handful of random possibilities (by doing a random number as a variable and then whatever that number is determines the item).
 

Yawgmoth

Veteran
Veteran
Joined
Jan 9, 2018
Messages
138
Reaction score
11
First Language
English
Primarily Uses
RMMV
@mobiusclimber I also have a random prefix and suffix plugin, courteous of DreamX but I want to give out random rewards from a list and then have random prefix and suffix added via the plugin. Also I am using Yanfly's augment plugin that allows socketed items from games like Diablo. I just needed a way to distribute these items to the player so the game can be played many times over and is a little different each time. Thanks for your input though.
 

mobiusclimber

Veteran
Veteran
Joined
May 3, 2018
Messages
265
Reaction score
150
First Language
english
Primarily Uses
RMMV
I haven't used it, but Yanfly has a plugin to give enemies more random drops and set up conditions for certain random drops: http://yanfly.moe/2015/12/19/yep-47-extra-enemy-drops/

[edit: another thing you can do is have enemies drop treasure boxes that are items with a common event that randomizes the loot.]
 

Yawgmoth

Veteran
Veteran
Joined
Jan 9, 2018
Messages
138
Reaction score
11
First Language
English
Primarily Uses
RMMV
@mobiusclimber That plugin could work but I would have to input notetags on all my enemies and create a list of hundreds of IDs to create the note tags. Even with copy and paste functions this does not sound fun. Thanks for the link though.

@Wavelength My event and script does not seem to be working. Can you steer me in the correct direction? I posted a couple of screenshots in a prior post. Any help will be appreciated.
 
Last edited:

Grumphlu

Veteran
Veteran
Joined
Mar 25, 2015
Messages
34
Reaction score
7
First Language
Français
Primarily Uses
EDIT : FIND IT ALONE WAZAA
For people who want to know how to put a message to know what item was dropped
the line to add to this script code is :

var reward = $dataArmors[$gameVariables.value(IDVariable)];
$gameMessage.add("Obtened " + reward.name + "!");

Hi Everyone,

I was also trying to find how to do a random chest with a script call because my game is based on that and my random chest goes between a huge amount of armors (Fom ID 29 to ID 220).

The script call is really good but the problem is that now the player don't really know what was in that chest.
I use Mog_Hunter TreasurePopup in my game but sadly it seems that it doesn't work with this script call...

Do you know how i can had a line for this Popup ? or if i have to add a message text which can say what the player have looted ?
(Then me too i am bad at coding so i really don't know how i can add a text with the name of this armor...)

Thanks in advance
 
Last edited:

druv1k

Warper
Member
Joined
Jan 9, 2019
Messages
1
Reaction score
0
First Language
Portuguese
Primarily Uses
RMMV
EDIT : FIND IT ALONE WAZAA
For people who want to know how to put a message to know what item was dropped
the line to add to this script code is :

var reward = $dataArmors[$gameVariables.value(IDVariable)];
$gameMessage.add("Obtened " + reward.name + "!");

Is it possible to color code the text reward.name on the messagebox?

EDIT: It seems to work with automessagecolor plugin by Irina.
 
Last edited:

xabileug

Veteran
Veteran
Joined
Jul 1, 2014
Messages
120
Reaction score
29
var reward = $dataArmors[$gameVariables.value(IDVariable)];
$gameMessage.add("Obtained \\c[x]" + reward.name + "\\c[0]!");

where x is the color in the pallet, 0 is the first color in the window pallet. check you window png file for color
 

Latest Threads

Latest Posts

Latest Profile Posts

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.
The honeymoon period is over with Cyberpunk 2077, It sadly doesnt live up to the hype, pretty graphics arent everything (especially when I cant even do something as simple as changing the radio station over!). Replaying Breath of the wild has reminded me what a good game really looks like, plus that one has good glitches!....
Ami


Maybe...a Drinkable Water Plant or something?
Who would have thought making interesting birds would be so difficult/fun?

Randomly spawning anywhere on map (sometimes even flying), having a chance of landing on a different spot on map when flying. Also chance of flying off screen if spooked/sees the player

I think I got it!

Forum statistics

Threads
107,681
Messages
1,031,397
Members
139,801
Latest member
IsaacRPG
Top