# How do I have an enemy randomly drop an item upon death?

0 favourites
• 6 posts
From the Asset Store
A fantastic package of 117 high-quality & game-ready sound effects for User Interface, Items, Power-Ups, and more!
• Hi all,

I've been playing around with the Ghost Shooter demo game from the Beginner's guide to Construct 2, adding features as I learn more. I added limited ammunition which was easy enough, but one thing I can't figure out how to implement is to have ghosts randomly drop more bullets when they die. I was thinking something along the lines of there being a 1 in 5 chance of more ammo being left behind whenever a ghost is destroyed.

I would very much appreciate any help, and I apologize if I have missed the answer in searching the forums and manual.

• For the random drops:

1. Create new instance variable of "random" with initial value "0" on the monsters

2. On Monster Health < 0, set value of random with: floor(random(0,6))

3. Create sub-event inside "On Monster Health < 0":

if Monster.random = 5 {

Monster spawn another object: Bullet

}

Here's a pic:

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• I finally had a chance to sit down and try this, and it works like a charm! Thank you very much for the help!

• jourdan Hi! I was curious what floor means, is it the same as round?

• floor(x) Round down x e.g. floor(5.9) = 5

round(x) Round x to the nearest whole number e.g. round(5.6) = 6

• floor(x) Round down x e.g. floor(5.9) = 5

round(x) Round x to the nearest whole number e.g. round(5.6) = 6

( )

Ahh thanks!

• 6 posts