Random drop

0 favourites
  • 6 posts
From the Asset Store
320 high-quality cinematic sound effects for trailers and game scenes.
  • 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

  • What's not effective about it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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...

  • 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

  • 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...

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

    You can download the .capx there.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)