Setting drop spawn chance of random items

Get help using Construct 2

Post » Tue Feb 04, 2014 3:24 am

How would I set the percentage chance for a defeated enemy to drop an item and how could I make it a random item from a set of, say, 6 objects?
Image
B
20
S
4
Posts: 382
Reputation: 2,974

Post » Tue Feb 04, 2014 5:02 am

for me i have a enemy ON created event that have an action that puts a random number in a instance variable between 1 and zero [action would be set variable round(random(0,1)) ] then a on destroyed event that and the condition that if the IV=1 spaw n Family from a family i made that has all the object i want it to pick from ....when u create a family object it spawns a random thing from that family ...
that's how i do it there might be i different way but this way is really easy to set upvolkiller7302014-02-04 05:04:20
B
42
S
17
G
2
Posts: 850
Reputation: 6,209

Post » Tue Feb 04, 2014 8:55 am

One way to do it is with the choose() expression.

on enemy destroyed - set variable to choose(0,0,0,0,0,1,1,1,2,2)
- if variable = 0 : don't spawn
- if variable = 1 : spawn object 1
- if variable = 2 : spawn object 2

the chance of this being 0 = 0.5
the chance of this being 1 = 0.3
the cahnce of this being 2 = 0.2

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jul 23, 2014 6:45 pm

I hope this won't be considered necroposting but thanks @LittleStain and @volkiller730 - I just used these ideas!
Image
B
20
S
4
Posts: 382
Reputation: 2,974


Return to How do I....?

Who is online

Users browsing this forum: David181 and 8 guests