Choose from Random Range + Unlock Specific Items

0 favourites
  • 3 posts
From the Asset Store
Unlock Levels, Worlds & skin plus add coins by watching ads
  • Hello All,

    As I'm working on my game I will add more items, for start and easy testing I made 3 Items.

    When the character pickup the "Randomizer" (sprite) it will choose randomly from 1 to 3 of the items.

    The Items built from 1 Sprite, each Animation = Different Item. 3 Animations in total (for now)

    This is the current code I'm using (which works perfectly fine):

    i.imgur.com/g6tKv9v.png [/img]

    The Items are supposed to be divided to 3 types, means 3 Sprites:

    - Items_Common (which is the current Item with the 3 Animations)

    - Items_Rare (I still didn't add it)

    - Items_Legendary (same, still didn't add it)

    My first approach is to make ALL the items (animations) in 1 Item: Common, Rare, Legendary but it's much easier visually for me to see 3 actual 3 items and import the animations for each instead of one Item with everything.

    Now for the Questions:

    Based on the code I show on the image above, How can I make the % of what item type will be spawned? for example:

    70% Chance = Common, 20% Chance = Rare, 10% Chance = Legendary.

    1 - How can I get this Chances to work to my decision based on these 3 different Item types (actual 3 sprites) ?

    The next issue: UNLOCK specific "ANIMATION" on specific sprite (Common, Rare, Legendary)

    This is probably much more complicated because I didn't make any Saving Data options for the game since I'm not sure which one to use for such thing.

    How can I make some Animations LOCKED (no chance to get them) UNTIL the player unlock it?

    And what if the player QUIT the game, will the Item stays unlocked or reset to LOCKED again?

    I'm sorry for the complicated explanations and my bad English, I hope that you can help me out here with these 2 questions, based on my information.

    Thanks ahead for your help, I can't wait to see your advice, suggestions and solutions, the more visual the easier for me to follow and understand since I'm still new to C3.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For the 70, 20, 10 chance, you could do the following: create a local variable (for this example I'll call it ItemClassSelector).

    In the event you currently have, set ItemClassSelector to int(random(1,11))

    Then use 3 sub event, 1: if ItemClassSelector <=7 then pick from common ; if <=9 & >7 pick from rare ; if =10 pick legendary.

    For the animation selection use more sub events. If common set animation to "common", If rare set animation to "rare", If legendary set animation to "legendary".

    Nothing will stay unlocked until you start saving, here is a tutorial:

    https://www.scirra.com/tutorials/1461/how-to-use-the-localstorage-plugin

    I assure you saving will seem really wired and complicated at first but it is really simple once you get a feel for it.

    The data structure you will want to use to save variables is a dictionary.

  • Thank you for the example and the link, I will try follow them.

    I hope it won't be confusing as I think it is, but I'll have to try as soon as I'll get a chance. :)

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