top of page

DEV BLOG 05

Inventory System

This week I started to implement the inventory system functionality as well as start to work on my project report.

INVENTORY SYSTEM

To begin with i started adding functionality with no visual aid (that will come later). so I started with setting up functions that, create inventory slots, check if they are empty and then add items to them if they are free. If they are not then it will look for the next available slot in the index.

After that I added the functionality to stack items. I can set the pick up amount of an item in it's blueprint class. For now the default max stack value is set to 99. I plan to add the ability to stack individual items instead of all of them stacking to 99. I have however added the ability to not allow items to stack. In doing so, if you pick up say 2 maps for example that are not able to stack, It will assign 1 of them to the first free slot and then the other to the next free slot.

If you picked up 2 of the healthpack blueprints that are stackable but each one is set to the amount of 50.

You will pick the first one up. That will = 50 so it will quite happily sit in slot 1. I have added a debug so that when i press the "1" key on my keyboard it will display the contents of slot 1 in the top left corner as a print string.

Similar to when i press the "2" key. It will show the contents of whatever is in slot 2 as shown below.

Print strings push the previous string down so the bottom one is my "1" key pressed and the top one is the "2" key pressed. you can see that it has worked like it is intended to. 50 health packs were added to 50 that were already in slot 1 (to make 99) and then the remainder that was left over after the 99 max stack value which = 1 was added to slot 2.

Here is an example i mentioned earlier with the items not being able to stack.

As you can see the default amount for this blueprint is 2. However it can not stack so the theory is that it will add 1 to the next available slot (slot 1 in this case) and then the remainder (1) will be added to the next available slot (slot 2 in this case). Here is an image showing that it is working.

I then added this functionality to the inventory section of my main player menu. Instead of print string text in the top left. They are now represented with both an icon so that the player knows what it is as well as how much of that item there is. I picked up a first aid kit to begin with that gives me 50 of them followed by a map which gives me 2 but they are not stackable and then another first aid kit giving me another 50 of them. As I can stack to a max of 99 the functionality should add 50 first aid kits to slot one, then add 2 maps but as they are not stackable add 1 to slot 2 and 1 to slot 3 and then for the other 50 first aid kits, stack up slot 1 to 99 so 49 of them and the remaining 1 should go to slot 4. here is an image of it after i have picked them up in that order.

AS you can see the functionality is working just like it is intended to.

USE/SWAP/SPLIT/THROW Functionality

Next I started off by creating the functionality for use/swap/split/and Throw. I set up debugging to see the functionality working first and then I will add it to the widget.

For use, when the 1 button is pressed it will subtract 1 (as long as there is at least 1 to subtract) from the total amount in slot 1.

For swap, when the 2 button is pressed it will swap slot 1 with slot 2. (Again only if there are items to swap).

For split, when the 3 button is pressed it will (for Now) subtract 25 from slot 1 (plan to make it half whatever amount is in the slot at the time)

for remove, when the 4 button is pressed it will subtract 50 (which is just for test purposes again) from slot 1. I plan to have it remove everything from that slot.

Here is a video showing them being used.

I then got the functionality to work with the inventory using an action bar.

When the right mouse is clicked over a slot, the index is saved and the available buttons are shown in the action bar. You may notice i got rid of the weapons section above as it didn't really work with the idea i have in mind and also i need an area for different bits of information such as the action bar, item name and description.

Here is a video of it below.

(Quick note, i changed the name of the throw button to drop as i think it suits better)

Next I worked at furthering the functionality of the drop feature. It currently dropped everything from the selected slot. I implemented a scroll bar and spin box that work together in setting a value. When an item is selected and the drop button is pressed, it brings up a drop menu.

if 50 is inputted into the spin box then the slider changes accordingly and vice versa. This allows players to either just move the slider or input the amount they want to drop, then when they are happy with the amount they press the tick and that amount of items is dropped. I am working on changing the sliders range so that when an item is clicked I can set the max to the items current amount and then i would like to default the slider to the middle which will be half of the amount. Currently I can default it to half but the sliders range is from 1 to 100. I will try and fix this at a later date. but it works fine as it is, just me being a perfectionist i guess.

Dragging & Dropping

I then started on the drag and drop functionality which allowed me to do a few different things such as:

Swapping

Currently to swap an item i would press the 1 key and it would swap slot 1 and 2 around. However that is not very good when trying to swap slot 1 with say slot 8. I would need to many different keys to swap all the slots.

By dragging and dropping I can then grab an item in a slot, save a reference to the slot index and then move it to a slot with an item in that i wish to swap, get its reference and swap them both. If it is the same item then it will attempt to stack the slot.

stacking

If an item is dragged onto another one it will first check if it is stackable. If not it will fail and nothing will stack. If it is stackable then it will stack the item amount all the way up to the max stack amount which is 99. Then if there is any remaining it will add that to the next available slot.

Splitting

When a player holds shift and drags an item to a free slot it will check that the value is greater than 1. If so it will then split the stack by half.

Dropping

When an item is dragged outside of the inventory it will drop all the items in that slot.

Moving

I can now move items to where i want them so my inventory can be layed out exactly how i want it.

Here is a video showcasing the action bar drop widget and the drag and drop feature.

ONE FEATURE I FORGOT TO MENTION IS THE "USE" FUNCTION. IT SIMPLY TAKES 1 FROM THE TOTAL AMOUNT ON AN ITEM WHEN DOUBLE CLICKING ON IT. iF THE ITEM IS NOT USABLE NOTHING WILL HAPPEN.

Inventory transition and Sounds

I made the inventory have a slight transition in opacity when it is opened instead of just appearing. I always think that the attention to detail is something that should never overlooked and little things like this make games look that little bit better. I left the closing of the inventory to the normal style as it really helps the player distinguish an inventory opening and one closing. I also added sound effects to the open and closed states.

Drag & Drop Sounds

I also added sound effects to when an item is being dragged and dropped. I made it so that each item can store its own sound effect and when the drag or drop function is called it will reference the items sounds and play the corresponding one. I also have a default so that if a new item is implemented and has yet any drag and drop sound effects it will still play a default sound so that every item has a sound effect.

Here is a video below showing both the inventory transition/sound effects and the drag and drop sound effects.

Project Report

I also submitted my progress report today. this is a chance to reflect on how my progress is getting on and to see if my scope has changed at all.

Here is the .PDF that I submitted below.

(Note if you click the link in the PDF you can see everything I have done up to this point.)


Featured Posts
Recent Posts
Archive
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page