Discover + Unlock NEW Items?

  • Hi All,

    This is going to be hard for me to explain because of my bad English, but I'll do my best:

    First of all, I'll try to explain what I already use on my current game and hopefully you'll be able to help me with what I'm trying to do:

    1. I have X number of Items. (I keep adding more and more as I work on my game)

    2. Once the player pickup a specific object: Only 1 RANDOM Item appears.

    3. I split the items into GROUPS: "Common", "Rare", "Legendary"

    So far, it's working exactly as I want and I'm very happy with it.

    Note:

    After many tries, For the items I chose NOT to use Arrays / Array Editor because it confused me and slowed me down a lot. So I code all the items I need individual, each item have it's own groups that contain the "rules" I need. For me it's very organized, very easy to follow, change, tweak and add more items that way.

    The reason I explain this is because I know smart people would choose Arrays for such thing, but... it's too "SMART" for my brain, I can only follow the way I just described and I'm happy with it, oh.. and it's working great!

    Current Situation:

    When the player playing for the first time "A RUN" the player will discover NEW items every time since I made the object to choose RANDOMLY from ALL the items.

    WHAT I'M TRYING TO DO:

    Once the player Died, he can try again from the very first level of the game, so far so good.

    1) - I want to LOCK all the items in the "Legendary" group ahead (in the code) and let the player UNLOCK and DISCOVER NEW RANDOM ITEM from that specific group.

    2) - Once the Player UNLOCKED an item, ONLY THEN The specific item can appear in a future "RUN" randomly like the rest of the items.

    The rest of the items could appear at anytime normally, while Items from the "Legendary" group can ONLY appear IF the player discovered them before. (in older RUN).

    3) - How do I make the game "REMEMBER" that the player already discovered: "Item 41" and "Item 381" so they will appear on the next time he will run the game (even after he quit the game and didn't for a few days).

    I understand that #3 is related to SAVE SLOTS or something like that which I didn't got into yet because I don't know which of the save slots will work best for my game since there are different saving options on C3.

    But question #3 is just in case I want the game to remember the discovered items, before I'll get to #3 I would love to understand how to do the #1 and #2 of course.

    I hope it's not too complicated to help me here, any related video tutorial or visual example will be much better for me to understand.

    Sorry about my bad English and thanks ahead! :)

  • It's true you will need save logic to remember after the game has closed but what you're talking about is simply remembering items unlocked on restarting the game after dying, right? I'm making a rogue at the moment and can help you, although I did use arrays oops..

    All you need is a global variable in condition to toggle whether the item can be found. So all items in the game that exist at the start are variable=1. Any legendary items not yet seen are variable=0. When you see it in the game you set this variable to 1 for that item. You will obviously need to adjust this to how you have set it up with the groups.

    Anything to do with closing the entire game and remembering is related to save slots which will save the global variable and remember what it was set to.

  • Thanks plinkie! this is very helpful!

    So if I understood correctly: I can make a global variable call it something like "UNLOCK" and I can easily apply it to any item that I want.

    And the next step is to make WHEN a new item will be discovered.

    So, I'm trying to run this in my head to see if I can make it work:

    At the start of the game, ALL these specific items are unlocked: UNLOCK = 0

    and once the Player did something specific (I have many ideas of course) I will make a specific item to change to: UNLOCK = 1 (or just true/false using Boolean, same idea).

    Did I follow you correctly so far?

    If not please feel free to correct me, I do have much more to learn.

    If I'm close to the idea, can you help me out with the SAVE SLOT part?

    I know it's a bit "off topic" but I'm very confused even after reading about the different options I have in C3 to save.

    Is there a good C3 video tutorial about this that you can recommend me? or in general can you explain how do I even start?

    The reason I'm confused is because there are things I may NOT want the game to "remember" when saving other things such as the "UNLOCK" status of each item that already discovered.

    I'm thinking about have 3 SLOTS and an option to RESET them, but I'm afraid it is too complicated.

    Maybe I should do just 1 slot and a Reset for start.

    Sorry for the confusion, I'm still scratching my head to complete these 2 tasks: UNLOCK + SAVE SLOT

    Your advice is very appreciated!

    Thanks ahead! :)

  • In my game when you unlock a rare item that can now randomly appear in game, it is added to the array of items. Just realised from the way you've set it up you may need variables for each item, so item1=0 or 1, item2=0 or 1. That way you can save the variables. You may have a long list of variables though if there are lots of items, that's why an array is useful.

    Saving, you can use system save action that saves the 'state' of the game kind of like a restore of the game at that exact point. Or you can use local storage which stores data and variables, seen here construct.net/make-games/manuals/construct-3/plugin-reference/local-storage

  • Thanks again plinkie! :)

    Yes, I understood how Arrays basically are the right and easiest way to manage items but as I explained before for me it's much easier to have each item and put it's own "rules" since it's not sharing the same rules of the others all the time anyway. also it's MUCH easier for me to find using that dedicated ITEMS event sheet split into groups.

    Anyway, I don't mind add instance variable to each Item if that will help me to make it work, so far I have few items because it is much easier to test the game, but I'm planning to add so many (I already have a huge list with the descriptions and such).

    I will check out the local-storage, it seems like it's what I'm looking for if it will save or let me RESET specific data and not just everything at once. I'll have a look.

    Thank you!

  • Dear plinkie,

    I would like to test your suggestion but I'm a bit confused, wonder if you can guide me threw this:

    Since I only have only few items at the moment it's easy for me to test (since I'm not using array as I mentioned before) Anyway, I'm trying to following your suggestion:

    1 - Created a new Global Variable: "Item_Found" (Initial 1 = found, 0 = not found yet)

    2 - For every Item I set Item_Found to 0 but only 1 of the items will = 1

    I wasn't sure where to put the new "Item_Found" global variable, feel free to correct me here.

    Now the part I'm stuck on:

    In order to found an Item my game have an object called: "Randomizer" whenever the player's collecting it, a RANDOM Item will appear.

    So far ALL ITEMS are available (can be found) because it works with the "random()" command:

    THE QUESTION:

    Now with the new "Item_Found" variable on every item, How do I make the "Randomizer" to choose randomly ONLY from the Items that are found (Item_Found = 1) ?

    What do I need to tweak on the random action so it will search ONLY items which are: "Item_Found = 1" ?

    Thanks ahead!

  • This looks very convoluted now and I'm not sure item_found global variable can apply to a specific item. This is the time to move onto the array, but i'll guide you through it.

    Set the array size to 1,1,1.

    At start of game push to the back of X all items in your game, so it will look like this :

    push back "helmet" on x axis

    push back "sword" on x axis

    push back "shield" on x axis

    Now you have a list of items where helmet is 1,0. Sword is 2,0. Shield is 3,0. Do not think of arrays as scary, look in debug mode and you will see it as simply a list of items.

    To pick at random you run the action to set a variable to floor(random(1,array.width)), this will pick a number from 1 to 3 including 3.

    The number that is returned you can then grab the data by setting a text variable to array at (variable,0). So if it is 2,0 you can now reference the "sword" at variable,0 of the array.

    Delete x,y (variable,0) from the array. This deletes the item at 2,0.

    Now next time you come to pick a random item, sword is not there. Helmet is at 1,0. Shield is at 2,0. When you run the random command it will pick either 1 or 2. This is all visible in debug mode, you can see the items as they are removed.

    I would play around with that. Obviously as well as removing you can reference the item so 'variable' from the random command is "sword". You can use this to compare, i.e. if variable=sword then create sword in the level or equip sword.

    Let me know if you have any problems.

  • dear plinkie thank you very much for your time and trying to help me here!

    So... it's not that I'm scared of Array I just tried it few times, with the Editor, ajax, etc.. and instead of make everything easy and visual as it looked (visual spreadsheet) it was super complicated for me to setup and I didn't even understand how to play with all the numbers around.

    Now, I'm trying again because I guess I have no other choice using a random comment to just ignore or look only on specific items (which is bad news for me) and I'm trying following your instructions but I also try to implement it to my current game... and it is still very confusing:

    From your very first explanation, I did understand the X on Y and I'm not even sure if I need z for depth on my case because I believe 2D Array will do the job) but anyway, as you can see from my understanding I made 0,1,1 because I want 0 = No Item (default).

    It looks just like a nice list on the debug, it was easy to follow and most important to understand that that order I put them on the event sheet is the same order that they will count, so far so good!

    Now the confusing part begins, and I don't even know if I should go there and waste your time since it's probably hard for me to not get how Array works (not the X,Y for 2D array use... but in general).

    Originally I have this: "Items_Common" which is a sprite that contain 5 animations, you can see their names on the image above as I named them exactly on the Array.

    So far everything make sense with the names and the order which is the same on the Array and the Animations.

    So I tried to keep follow you on the part you explain: "To Pick at random you run the action.."

    I do understand that floor (will get the closer to 0) and the random range I guess this is new to me with the 1,array.width so if I got the idea it supposed to pick from:

    1 = the X of the array, "array" is the name of my array, width = the amount of the x (6 total in my case including 0) and it will start from 1 to 6 since we didn't count 0.

    Am I close to understand it so far? I'm not sure that's why I'm asking.

    Once you start explaining: "The number that is returned you can then grab.." is where I got lost.

    I'm starting to scratch my head, OK but where are the properties of each item? how do I control them? how do I see every item's name and property visually on the event sheet and how do I tweak anyone at anytime easily like I did so far without the array... so many questions and confusion just because Array is not visual to me (and I don't like the Array Editor setup, it was hell for me) so I'm trying the good old fashion Array as you suggested, what I see from the array are these items names in a list, so the (variable.0) is ("Item_Number".0) what am I doing with this and how do they connect with my "Item_Number" and I'm not following since there.

    As you can see, Arrays are probably not for my simple visual brain.

    I gave up on Arrays many times because of the same reasons, and once again.. I got lost easily after reading your post few times.

    Please don't get me wrong, I believe that your example and explanation are amazing and 99.9% will understand and follow it easily... unfortunately I'm not that smart and that's why I can't get it and even if I would, it will be so hard to work with such system since it's not visual at all.

    I guess I will have to try some other visual ways, maybe spreading the item instances like the other suggestions since I already have a dedicated layout for items, so it will be the most visual on both the Layout and the event sheet (not sure how to do it yet but I must find a way).

    Once again, thank you for your time I appreciate it a lot!

  • Sure I can break down a few more of the ideas i was trying to put across.

    Firstly, 0 will be present in the array always unless you change 0,0 and pushing 'adds' to the array, so you do not need to push an empty item, 0,0 is just 0.

    floor(random(1,array.width)) is to choose an item.

    When you push those items to a 1,1 array you will notice that the first item is at 1, because 0 is populated by 0, that's why I choose to start from 1, however the 0 still counts towards the width.

    array.width is indeed the number of X or items in the array however random does not include the second number, it is up to but not including the high range value (see manual). So if you pushed 3 items to the array, the width is 4 but the items are at 1,2,3. Because it would now pick from 1-4 not including 4 then random(1, array.width) works fine for any number of items. random(1,4) picks from 1 - 3.9. floor rounds whole numbers down hence 1-3. This is an explanation of why I used this however you can just assume floor(random(1,array.width)) will always work if you want.

    As for grabbing the item since it's important i'll have to explain it more in depth. When you choose an item you are setting an int variable, lets call it 'int' to floor(random(1,array.width)). Let's say the result is 2.

    Now you set a TEXT variable, lets call it 'pickedItem' to array.at(int,0).

    This means according to your example. TEXT would now be (assuming you have removed redundant NO_ITEM as mentioned above) "Rock_Helmet". Now you have this text variable to play with.

    You now say delete array.at(int,0) which will remove "Rock_Helmet" i.e. it cannot be picked again, resolving that you wanted to remove an item from being picked again.

    Remember the array is only for storing what items are to be picked, anything else for the item can be on the event sheet. So you could now say if pickedItem=Rock_Helmet then equip it. Or set currentItem to pickedItem. Whatever you want to do. If it was to appear in the level as a pick up you could say set pick up type to pickedItem. If it was to set an anim you could say set animation to pickedItem and it would appear as a Rock_Helmet. To summarise, all this is doing is replacing your ITEM_NUMBER with a text variable called pickedItem which = the name of the item, but has also allowed for picking a random item.

    Edit: I just saw that you wanted NO_ITEM to be a default weapon, well it won't be picked right so i'm not sure why it would be in the array, but if you want to pick it then set 0,0 to NO_ITEM, do not push.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks once again for your mighty patience with me plinkie it's so kind of you!

    I didn't read it yet, I will do it carefully and will try to follow of course.

    Just a quick notice about the "NO_ITEM" as 0 on the ARRAY:

    The reason is not just because the game starts with 0 but also sometimes when you lose or have no ITEM, I need to point it to something with default properties, that's how I made it on the none-array way and it worked great... not sure how it will in the Array.

    I will do my best to read and understand it soon, I must give my stupid visual brain another chance with Arrays... since I have the feeling that for what I'm trying to do there is no other "magic" option using a just a random action (I wish there was, it could be so much simple for me to understand and handle).

  • The issue may be the scope of your game. What you're describing in the original post requires a certain initial approach and a certain expected knowledge of what you're doing in code. There is a significant difference between making a mobile game or infinite runner where you tap the screen and an RPG with an inventory system where you randomly unlock items during a game and need to store these values. Usually you would need to know how to use arrays for this type of game. As you move into save slots and storing this data you may find that you have too many things going on and too many variables just because of the initial approach you took.

    Before you can do this :

    2) - Once the Player UNLOCKED an item, ONLY THEN The specific item can appear in a future "RUN" randomly like the rest of the items.

    You need to push unlocked items to an array of all available items. They can then be picked from an array in future runs like with my examples above. You look at the array or list of items and pick one.

    Your function for changing item was picking a random number.

    This should become picking a random number which relates to an item in an array.

    Arrays will give you more control over what items are available in the game if you are doing something such as 'runs' where things unlock and applying stats to the item that was chosen, but that's partly just my opinion on how to approach this.

  • Dear plinkie and anyone else who's willing to help.

    Since I'm lost in the Arrays Land after many tried I decided to Re-Create from scratch a VERY simplistic version of what I'm trying to do on my game which it's code is so much complex compare to this example file.

    With this file, as you can see it is VERY organized so I can follow and of course anybody else who will explore it, including comments, and dedicated Events and Layouts to separate things like in my actual game.

    Graphics are super basic I made it quick for nice visuals please forgive me.

    Notice:

    If you'll RUN the example file right away, you will notice for the current way I'm using my actual game to get a RANDOM item is very simple, it works visually, it's sticking to the animated character and MOST IMPORTANT: Once an Item is picked up, it will affect the player's properties based on the item's properties on it's dedicated Event Sheet.

    If you'll look carefully on the Global Variables under the Items event sheet, you will notice few Variables that are NOT in use yet: "P1_Poweup_1", "P1_Poweup_2" and "Item_Found"

    The reason I put them there is to put extra options to each item if I want, also to show you that the properties of each Item and future Items can be expand with their own specific rules that may not appear for other items.

    PLEASE IGNORE my Array stuff, I just put it there while have no idea what I'm doing and how to use it from that point so you can ignore it completely as it's useless on the current example file anyway.

    BEFORE YOU START WITH ARRAYS:

    Please, if you can have a look and maybe find an EASY SOLUTION for my original problem which is:

    Spawn ONLY Items that are found (play with the the "Item_Found" if it helps).

    IF YOU CAN FIND A SOLUTION without the Arrays based on the example file I will be extremely happy to see what you came up with, because the current example file isn't super complicated compare to my current game code.

    Thanks ahead, I appreciate your time and kind help!

    Example File:

    Click to Download

  • I can take a look but I can't find a download link, just lots of adverts and nowhere to download from.

  • Sorry about that plinkie, I didn't see any option to attach to a reply in the new forums.

    The link should work now, can you please try again?

  • I can see why you had a problem with arrays. You are filling the array on start of layout as I mentioned but you have something in your game that restarts the layout and fills the array again, that's not great but I see it's 'debug'.

    Check out : dropbox.com/s/z52yhok12qd4b3c/arraytest.c3p

    You can see how I've done the following :

    - Got rid of item_number, used a local variable to pick something random from the array and set it to equippedItem

    - Set animation to equippedItem, this takes out a chunk of code

    - Remove the equippedItem from the array so it can't be picked again

    - Added an arrayblock variable so you only fill the array once (the F5 thing mentioned above)

    Hopefully you can view that file and see how it works. All you would need to do now is add more stuff to the array and add more equippedItem = blocks like you have already. It is better if you understand it and know what is going on.

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