Preyte's Forum Posts

  • 9 posts
  • Yeah, sorry this is my first game, very new to this. Unfortunately, this entire inventory system is based on a YouTube Tutorial. I've been trying what you outlined for a while now and I'm still very stuck. Mainly because I can't seem to find any way to differentiate between instances of the obj_itens_spells_inventory object.

    My plan was to do what you said and eliminate the logic that deletes the instances from the inventory, and instead have a global variable that keeps track of the last instance clicked so that it knows what is selected. Then have logic indicating that while the global variable houses a particular spells animation name, all scrolls picked up with that name will automatically be added to the quantity within the active box.

    Any scrolls that do not match the name will be added to the inventory.

    I would then want to add logic that when a player clicks on a new scroll already within the inventory, that scroll's animation name will become the active spell variable, and it will be moved to the active box.

    I would then need to add logic that would somehow move the spell already in the active box back to the inventory.

    However, I can't even get close to that step because there is no way I can find that allows me to pick an instance of an object based on clicking. Is there a way around this, or should I just scrap this inventory system and rework it?

  • sorry not arrow keys to move it is actually wasd.

  • Yes of course, You open the inventory with "I" on your keyboard. There you will see all of the available slots and active slots.

    Use the arrow keys to get within 300 pixels of an item sprite you wish to pick up, you'll know it can be picked up because its name will appear when you hover your mouse over it. To pick up an item, right click it while in range.

    Now the item should be in your inventory when you click "I." In order to use the item, middle mouse click on the item sprite in your inventory. For firebottles, this should move the item to your active item slots, for mana and health potions this should increase either your mana or your health. Once a firebottle is in your active slot, you can use "Q" to throw them in the direction of your mouse.

    I'd like for the spell scrolls to do the same as the firebottles only instead of active item slot, they go to the active spell slot. (I will code the actual functionality of the spells later).

    Firebottles were easy because that is the only potion animation that requires a position change, as you can see each category of item is separated by game sprites and inventory sprites (what you see in game vs what spawns in your inventory), with each item in that category being represented by its own animation.

    The trouble comes with spells in which every animation has to have the functionality of moving to the active slot, and replacing the current active scroll, moving that scroll back into the inventory.

    To find the exact code that handles all of this functionality, it is all under the "Main" event sheet, under the "Inventory System" group. There you will find a bunch of groups; most you can ignore.

    "Inventory Tooltips" houses the text that represents the amount of an item in a particular slot.

    "Inventory Action" and "Inventory Functions" are really the only ones I'm working with at the moment.

    "Inventory Action" houses the code to loot and drop items, as well as code to use items, which is still in progress for spells, but the rest of the items in that group are complete.

    "Inventory Functions" house all the functions of the inventory system that you may see sprinkled throughout the code.

    To reproduce the issue: Pick up all three spell scrolls from the starting area, and attempt to middle mouse click more than one, instead of the new spell replacing the old one, they simply overlap each other or destroy each other.

    dop2000 Please let me know if that was not clear, and I will try to be more concise and clearer.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • drive.google.com/file/d/1b8fAfKoj6AEOg7IzsdJcq3lyyH0C32DA/view

    Here is the link to a copied version of the project file, the code in here is exactly What I have currently.

    dop2000 I did have logic to delete the tag but was having trouble getting it to work so I deleted it in an attempt to find a new way. In the project file I share here, "ActiveSpell" gets set, but there is no logic to clear the tag. I debated on eliminating that global variable entirely.

  • Hello, I have created a functioning inventory system for my RPG, and all of my items work except for my spells.

    Each item type (potions, spells, weapons, and game items) has their own category in the inventory.

    Obj_item_Potions_Inventory represents the items under the potion category in the inventory, each animation (ID_ManaPotion, Id_HealthPotion, ID_FireBottle) represent each type of of potion.

    Obj_item_Potions_Game, is set up the same way but represents items in the game world before they are picked up and placed in the inventory.

    All items are set up this way including spells (obj_item_spells_inventory & obj_item_spells_game)

    Currently Potions work exactly how I want them to, and so I mimicked the code for the spells, but it has not been working.

    Essentially the fireBottle potion under the potions category when middle mouse clicked in the inventory is equipped inside of the "Active Item" slot. While there, the player can click "Q" to throw fire bottles until he/she runs out.

    I would like the same to happen with spells only with the "Active spell" slot. I want the player to be able to middle mouse click a spell in their inventory, have the spell move into that slot, and while it is there be able to press a button on the keyboard to activate the spell until he/she runs out.

    My issue comes with switching out spells before use. Say I have an invisibility spell equipped and I'd like to switch it out for a monster spell without using the currently equipped spell. With my current code you are unable to do this, if you click on a different spell with one already equipped one of the spells is either destroyed or overlaps the equipped spell.

    I will post the code I have thus far, is there any way to fix this code so that when the player equips a new spell, the old one is simply returned to the inventory, and the inventory sort updates?

    Any help would be greatly appreciated!

    Example of the issues in game: youtu.be/dF2Y-eqA118

  • That worked! Thank you so much. Yes obj_potions_inventory was a member of that family, I did not know construct treated those separately.

    Adding the code, you provided right before comparing animations did exactly what I needed. Thank you so much!

  • Hello, I am crhttps://www.construct.neteating an RPG and have finished creating a loot drop and inventory system that works. I am now working on making the items in my inventory actually usable. First, I'm working on potions.

    I have two objects to achieve this: Obj_item_potions_game and obj_item_potions_inventory. Once of these represents the dropped sprites in game, the other represents the smaller versions that appear in the inventory once they are picked up.

    Both objects have the same three animations: ID_ManaPotion, ID_FireBottle, and ID_HealthPotion. These animations represent the three types of potions.

    I have managed to allow the player to pick up and drop potions at will and have made it to where a middle mouse click on a health potion will heal the player by two which is what I want.

    My issue comes with adding more potions. I'm trying to make it to where the fire bottle potion gets placed in an active items slot when clicked while maintaining the quantity the player has.

    I've successfully made this happen, but it happens to all potion types. For example, I click on a fire bottle in the inventory, and it moves to the active slot, but ALSO heals the player, while when I click on a health potion it heals the player, but ALSO, moves a fire bottle into the active slot.

    Is there a better way for me to differentiate between my potions so I can make sure they are all doing their own respective things when my player tries to use them?

    (Also, I plan on figuring out how the fire bottle will actually be used once this problem is taken care of).

    Any help would be greatly appreciated!

    youtu.be/pZyvF4SmsHQ Video example of what is happening.

  • You do not have permission to view this post

  • dop2000 had the right answer! Thank you! The player sprite had the correct collision polygon, but the player CONTROL, did not. The play control collision polygon was about double.

    My problem is solved, thank you all again!

  • I can't find a tutorial anywhere for this. I am making a top-down game, and every time I create a sprite and set it to solid, no matter what size or what I set the collision polygon too, the player character hits the solid well before it gets anywhere close. My goal is to make invisible walls that prevent players from running through water or houses. I've been at this for hours and don't know what I am doing wrong.

    For some reason when I make a sprite a solid its hitbox/Collison radius is huge, and idk how to fix it!

    Any help would be a lifesaver!

    I attached a video to skip through so you can see exactly what I am dealing with. https://youtu.be/AcAtNXgJD64

  • 9 posts