Gameplay Tags - Item Quantities

As part of a demo I have been working on for an RPG, I have made gameplay tags for particular items needed for one of five tasks in that demo. Though I’ve made a data table for each item, I am unsure as to how to set a quantity for each item. This is so the game will know how many of each listed item the player has, and it will also be used as a condition to determine if the task is done successfully.

Is it possible to add quantities to items listed as gameplay tags?

Hey @CurleeD85!

Kind of. You need to get their inventory as an array and then for each, if “has Tag” then add it to another array. If array LEN > your specified number, then you have a True or false bool! :slight_smile:
Hope that helps!

1 Like

I did consider using arrays, actually. I wasn’t sure if it was the correct approach. But okay, I’ll try that. Though how do I add an array attribute to a preexisting gameplay tag?

Id recommend a map variable, of item object references or names, to quantities

There will be a dialogue widget that will show text based on whether or not the player has the correct items and needed numbers. If I used a map variable, I wouldn’t be able to cast to it, since one can’t cast to any variables within a level BP.

Got it I was thinking like a map variable in an inventory system, maybe I’m not quite understanding what exactly you need

In simplest terms, how do I add an array to a preexisting Gameplay Tag for the player’s inventory to give each item on the list a quantity?

you could use a Struct with variables Tag/Quantity

Are you talking about a variable deriving from Gameplay Tag? Or integers associated with it, or…what?

a struct is a group of variables so you can add what you want

So would a struct be a group of variables suitable for any and all items and equipment to be found or purchased in an RPG, as well as the quantity of each? Can you also point me to any straightforward tutorials if you know of any, please?

After some feedback I’ve received, here is a struct that contains variables relating to the inventory in the RPG demo.

Now I have one last question: what’s the best way to put in a quantity (number of items currently held by the player)? Should I use an integer or a float? Or something else?

likely an Integer as you cant have a fraction of an Item, however your cost/sale might be floats

1 Like

I’m not likely to use decimal numbers, so I’ll just use integers for each.

Another thing you could use is a map! Look into those!

You could have the object as the first half (key) and the int as the second half (value) then any time you need you call the key and it returns the value! :slight_smile:

I don’t know if you saw the screenshot I posted earlier of the structure I made, but I made a struct then a data table based on it. So now, I’m at one last impasse: how do I cast to a variable within the struct variable? Like, say, I want the game to detect whether or not the player not only has a certain item but also the correct number of items? (Which would be, in this case, the ItemName (Name) and Quantity (Integer) variables.)

Yes, it looks like here you need a map.

The first half of the map would be a Name, the second half (value) would be a struct based on that name. Then the struct would hold all of the data related to that name. The map puts them into a searchable list (you would use “Find” to get the one you need with a name input).

Would you happen to know of any good tutorials on how to make structs work with BPs that cast to their individual variables within a struct? That is, one that works with UE5?

Sorry, that’s what I’m trying to tell you.

You NEED a map. This will not work unless you use one. :frowning:
Unless each item has its own struct, you can’t search through a bunch of structs for the one you need, you have to specify. The map would allow you to specify which one you need by passing in a string, name, or text variable (or other kinds but for this stick to one of those three).

Otherwise, you can just use “Set Members” and then “Set Struct” to save values,
and “Get” then break the output pin on the struct to Get a value- but you have to have already specified the struct, as I stated.

Also, casting doesn’t do what I think you think it does… It’s not a “Get” node, it’s a reshaping node. You cannot cast to variables (though you can cast a struct to another struct). What that means is you can make struct A BEHAVE AS struct B. Another word for cast is mold, if that helps?

1 Like

Are you referring to a map container type for the variables within the struct?