How do I use advanced random to limit duplicate loot drops? (SOLVED)

0 favourites
  • 3 posts
From the Asset Store
Inventory & Loot
$2 USD
80% off
Perfect, complete, easy to use to use, out-of-the-box inventory system
  • Hey C3. Using the advanced random with a permutation table, random skills/loot drop. However I don't want to duplicate the drops.

    Essentially, random character is generated. Chance of 0-3 skills assigned via choose(0,1,2,3). That number is how many times a random skill or loot should drop but not the SAME skill or loot.

    I checked through the forum for previous questions about this and found one with a suggestion by dop2000 that was close but didn't answer my particular situation (https://www.construct.net/en/forum/construct-3/how-do-i-8/choose-randomly-set-strings-165573?kws=choose%2bwithout%2brepeat).

    Any help would be appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Maybe I worded it in a complicated manner.

    Does Construct 3 have the ability, through advanced random, so that out of a list of 5 numbers, if 3 are randomly picked, the coding would prevent a duplicate draw?

    I can’t be the first to run into a situation where this would benefit the software (app or game) being designed with C3.

    Thanks.

  • Didn't think I was asking that complicated of a question but appears it was just outside the normal reach of the forum. Luckily I was able to find the solution on my own and I hope it can help anyone else that runs into this limitation in C3. Fair warning, it isn't the most streamlined option but it surely gets the job done.

    Essentially, this creates a probability table called Perks. You can overlook the "create permutation with tok..." as I didn't remove it after last test but it's not needed. Repeat_Times sets how many times to run the script. [Perk_Drop] determines what loot drops and [Clear_Flags] sets the variables used in Perk_Drop back to 0.

    Also, in the [Clear_Flags] function, ignore the "npc_sprite" and flags that are set. Artifacts from testing that aren't used in the final solution.

    [Perk_Drop] function looks through the loot table and won't pick the same item twice due to the **_flag2 being set. When an item is selected, the flag is set to 1 meaning it can't be picked again during that loot drop. Turns is a global variable and as an item is selected, 1 is added to Turns. When Turns equals Repeat_Times, the script (loot drops) end. The Turns value is reset to 0, along with the **_flags2 and ready for the next loop drop.

    Again, not the most clean, streamlined option but it got the job done. Hope it helps, ping me if you need some help.

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