Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How to make an enemy that drops Random Items

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:
$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.

NOTE: THIS WILL ONLY WORK ONCE PER BATTLE!!! IF YOU HAVE TWO OR MORE OF THE SAME MONSTER IN THE TROOP, YOU WILL ONLY GET TWO OF THE SAME ITEM!!!


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.

http://www.4shared.com/file/Wc1aBM0H/Random_Item_Drop.html

TTFN
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top