The Daily Click ::. Forums ::. Klik Coding Help ::. Item Drop
 

Post Reply  Post Oekaki 
 

Posted By Message

Jon C-B

I create vaporware

Registered
  23/04/2008
Points
  237

I'm an alien!VIP MemberWii OwnerI donated an open source project Santa Hat
4th August, 2009 at 18:45:14 -

How would you make it so that an enemy has a 1 out of 5 chance of dropping an item?

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
4th August, 2009 at 18:59:21 -

Well what I'm doing now is to always have a counter set a random # from 1 to 100.

Then, when the enemy is killed, there's a condition after it like this:

If "enemyHP" < 0
+ "RandomNum" is >= 80
+ Enemy animation "disappearing" is NOT playing
+ run event once per loop (or whatever it is)

-->

Create the item at a position on the enemy and destroy the enemy.

--

This is pretty simple but you can have other events like this afterwards to give an enemy different chances to drop different items. I used 100 so that I could say an enemy had a 14% chance to drop a potion for example.

Hope this helps!

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Jon C-B

I create vaporware

Registered
  23/04/2008
Points
  237

I'm an alien!VIP MemberWii OwnerI donated an open source project Santa Hat
4th August, 2009 at 19:25:16 -

That works great thanks!

 
n/a

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
5th August, 2009 at 04:41:18 -

The way Del Duio said it will work, but it only goes to 99 (not that big of a deal, but if you're nitpicky like me, it is).

Any time you deal with random numbers in which you want to be 1-x (ex 1-100), always do this.

Set X to random(100)+1 instead of set X to random(100)

IF you set a value to random(100) it sets the number to 0, 99, or any numbers between those two so adding one would mean it picks 1,100, or any number between.



 
n/a
   

Post Reply



 



Advertisement

Worth A Click