# Percentage & Randomization

Get help using Construct 2

### » Sat Apr 07, 2012 6:34 pm

Hi~
I wanted to create a percentage & random event~
For example, there are 4 items~ (I1, I2, I3, I4)
And 3 objects~ (O1, O2, O3)

Questions example~
01 >
When O1 is destroyed, 20% spawn I1~

02 >
When O2 is destroyed, 10% spawn I2 & 25% spawn I3~
But will only spawn 1 item at a time~
Which means randomly pick I2 or I3 then detect the %~

03 >
If O3 is destroyed 4, 8, 12, 16, 20... times~ (Multiply of 4)
50% spawn I4~

Maybe it's too many~
But hope someone will help~
Really appreciated~ ^^AkiraWong2012-04-07 18:36:06
B
13
S
5
G
3
Posts: 63
Reputation: 3,989

### » Sat Apr 07, 2012 9:16 pm

Hey

So I think this is what you are looking for. I imagine this is not how the enemies will behave in your game.

Just for testing purposes if an item is not spawned the System will wait 2 seconds and Spawn a new guy. If an Item is spawned the system will wait for you to collect it before it spawns a new guy.

I hope this helps and good luck.

Game File
http://dl.dropbox.com/u/64691866/RandomSpawns.capx
B
5
S
1
Posts: 16
Reputation: 759

### » Sun Apr 08, 2012 5:07 am

Yes it is~
Ah, so we can type "random(10)" something like that~
This is great, I didn't know about this yet~

So the concept is if the drop rate is 20%~
We firstly set random(5) to give the object hold 5 numbers~
then, if the number is 0, spawn the item, else, destroy the object~

Another example, if the drop rate is 15%~
We firstly set random(20) to give the object hold 20 numbers~
then, if the number is 0/1/2, spawn item, else, destory the object~

And the concept of multiply of 4 is adding a variable~
Each time player destroys the object will +1 to the value~
If the value = 4, start the random event, then set value back to 0~

I get it now~
Thank you very much, Mr427~
Really appreciated~ ^^
B
13
S
5
G
3
Posts: 63
Reputation: 3,989

Return to How do I....?

### Who is online

Users browsing this forum: facecrime, oosyrag and 11 guests