How to make an enemy that drops Random Items

Started by jayje, July 26, 2010, 01:29:57 pm

Previous topic - Next topic


July 26, 2010, 01:29:57 pm Last Edit: August 02, 2010, 01:56:11 pm by jayje
Hey folks! I'm not sure if anyone something similar to this or not, but here goes anyway.

Have you ever wanted to make an enemy drop random items after you beat them WITHOUT;

A. Looking for a script?

B. Requesting a script?

C. Learning to script?

This is how! It's so easy, you wonder why no one thought of this first!

Step 1. Creating an Item Giver(IG) (monster that will be giving the random item).

Go through the standard steps used to make your other enemies. Choose the battler, set the stats, etc. But don't, DO NOT, give it an item. (This will be cover later). make sure to remember the IG's ID

Step 2. The Setup.

Here's where things get interesting. Go to the Monster Group(Troops) tab in the editor, expand the array by one and create a new Troop containing you IG (call it whatever you want). Next, in the Battle Event editor, click the "Trigger" menu. Select where is says "turn" and leave it as is(which is 0 x 0) and set the frequency to "Battle Turn"

Step 3. The System.

Now the easy part. First set up a variable(we'll call it 'treasure') and set it to a random number between 0 and 3. Make four Conditional Branches, one for each number(0-3). The first one you leave blank, you get nothing. The second one is where you'll need to do a bit of light scripting.

Select the Call Script function in your event editor(its the last item on the Page 3) and type in this little code snippet
Code: text
$data_enemies[enemy id].item_id = 

Where it says enemy id, put in the IG's ID and at the right of the equal sign, put in the ID number of the item you want to give(we'll make it '1' for a potion). Repeat this step for the other number branches while changing the item ID's to whatever you choose. Try it out.

And VIOLA! Congratulations, you've just made yourself a monster that gives different items when you beat it.


The good news is, you can set another monster to give away random items as well. So you can two different monsters give in two different items.

I'll see if I can come up with a way for two of the same monster to give different random items. Unless someone beats me to it.

I have a link to the demo showing how it works. If used, credit would be nice. Any questions feel free to hit me up. Any critiques welcome.



This is actually a really cool little tip. However, I don't think it really belongs on the Event System Troubleshooting board. In any case, I wonder if this could somehow be combined parts from Blizzard's Creation System to create a Diablo II style loot system.


ehehehehehehe!  :shy: yeah i noticed that i put it here just after i posted it. could a mod please move to event systems?


Couldn't you calculate the number of same-type enemies defeated, and then loop for the number of same-type enemies in the battle to calculate the drop? You'd create a separate method to check for same-type IDs, then store an integer that has the number, then loop for as many are in it.


Good job. I would haven't thought ot use an event for this, but it does seem simple.  :)
Lvl ++
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.


thanks for the complements folks. i'll be upload a system i'm using for my gaem soon too.
@dragoon. i did make a simple script that kind do that(actually its a mod of a script that was made for me) i'll post it up later


This can be done without calling script.

In the events commands, make a variable do a random number between # and #.

Then set a conditional branch equal to each number you have.

Then in each conditional branch have it give you a different item. This makes many random drops.

You could even make it so you do a random number between 0 and 100, and if the number is between 30 and 50, you get some junk.


Yes, but I think the point of having the script was to force it to pop up a "You got _______!" window. If you just had it add items to your inventory, you'd never know what you got unless you manually put that in with a text box.

Click on my eggs and I can make all of your wildest dreams come true >.>