Random drop

Get help using Construct 2

Post » Tue May 21, 2013 3:58 am

what better way to make a "monster" or "chest" drop a random item?

I'm doing this:

monster HP <= 0
monster set Drop int(random(1,10))
monster destroy

-------     monster Drop <= 4
          monster spawn coin

-------     monster Drop >= 5
-------     monster Drop <= 7
          monster spawn key
     
-------     monster Drop >= 5
------------ monster spawn red potion

But I'm not finding it effective. Anyone have a hint?

Tnks
B
21
S
4
G
2
Posts: 96
Reputation: 2,392

Post » Tue May 21, 2013 4:20 am

What's not effective about it?

B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993

Post » Tue May 21, 2013 4:20 am

Any reason you using random (10) for 3 items?...why not random (3)?...

yes, that will get kinda messy...and you would only be able to have 10 drop items max, with your example...

If you have the paid version you can use a family

and the command spawn "name of family" will create a random item from that family...

if using free version, its probably better to use one sprite, call it drops, and put each drop item into that as a seperate animation frame, set animation speed to 0.

Then in game

>monster spawn drops sprite, set frame number to int(random(10)) if you have ten items...


Pixel perfick2013-05-21 04:22:42
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Tue May 21, 2013 4:33 am

I use the version "personal" the construct.I want some items will be easier to drop than others. For example, I want drop more coins than keys. But do not believe the way I did it is the best.

Tnks
B
21
S
4
G
2
Posts: 96
Reputation: 2,392

Post » Tue May 21, 2013 5:00 am

Oh i didn't realise you wanted a weighted drop...

well a family will give an even random drop

or the way with one drop item you could change the chance percentage by having more than one frame of certain items giving a better chance of a hit...

The way your doing it would be fine also, there is no right or wrong way if it's working for you...
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Tue May 21, 2013 7:01 am

I uploaded an example to the arcade, using functions and one array:

You can download the .capx there.
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 32 guests