Gameplay Tags - Item Quantities

Nope, like this!

A string would be used to determine which version of said struct to use:

A map would be a container for the structs. Then the struct is a container for the variables. That way your variables are still grouped the way you need them, but your structs are organized and can be called upon. :slight_smile:

I have somewhat of an idea on what you’re talking about. Still, would you know of any good step-by-step tutorials that cover something like this? I’ll see what I can figure out in UE5, but I’m one of those guys who learns by following directions.

Something like this?

This will be under a “Dialogue Cutscene” map BP since that map has a blank screen to allow for widgets with various comic-style images. It will also check for variables within the map structure. Though there are more items than the ones I’ve listed on the right, the dialogue BP will check those certain variables and the text to appear will depend on whether or not certain conditions are met. Anyway, would this look right?

Yes, then you can use a GET node dragged off of the map (it might be “Find”?) then you pass in the “Key” (that’s the first part, so a string/name/text whatever you’re using.) then it will return the “Value” (which would be the matching struct) then you can use the struct as needed! :slight_smile:

Something like this? I’m not totally sure, since I still get the False condition even when I set the default statistics to a variable within the struct.

You have no key input! :slight_smile:
image

With no input you are getting NULL so the “==Battery AND ==1” will never confirm. :slight_smile:

1 Like

More like this, then?

(Though weirdly enough, the Map Find is really the node in the included screenshot.)

So what you’re doing here is you need to use one of your keys EXACTLY.

This is the list of keys; they return the specific inventoryStruct.

So your options to go into the FIND box are:
C2046Battery
BottledWater
GreenTea
OxygenTank
StrawberrySake

Everything else will return nothing. :slight_smile: Hope that helps!

1 Like

Okay, so after making the suggested changes I found out how to get the game to determine certain conditions based on the inventory struct.

To be thorough and certain, I added the C2046Battery name to the Map Find node so it would check for the item by name and by quantity.

Now, if I wanted to update the quantity of some item, what would I need to do? Just use the same as in the script except use an increment or Add node for the quantity, instead of a branch?

Scratch that. I did figure something out when it comes to having the player obtain some item.

But, I’m not sure how to get an item’s quantity to increase each time the player touches the trigger box, assuming I would want the number to go up and up. Every time I pass that same box, the program adds once and only once and I have “1” print on the screen every time, even when the program is supposed to add one more to the quantity.

Also, I’ve moved the map variable to the Game Instance since every bit of information is more permanent; I just put it on a level map’s BP so I could test it with a trigger box when it is touched. So now, I have set the level map to cast to the Game Instance and look for the copied-and-pasted map variable there.

So you need to use “Set Members…” to set the members of a struct, then set the struct, then set the value of the struct in the map (it seems like a lot of steps but imagine this for EVERY item you have in the game, this is a one-time setup).

Here’s a good tutorial explaining maps, it even uses an inventory as the example:

Disclaimer: This link is not associated with Unreal Engine, Epic Games, or their partners.

1 Like

I think I have it now. At least, how to add the quantity number. After watching the part of the video I needed most, I set the blueprint like so.

But this was just a test, so I’ll know what to do when the player buys an object or picks it up or receives it as a prize. Though I had to set the Quantity’s Default Value to -1, since the BP skips from 0 to 2. But is there a better way to fix that, if the Quantity skips to 2 when its Default Value is 0, even though the BP is supposed to add 1 for each time the trigger box is touched?

1 Like

If it’s increasing the quantity by two, it’s being increased twice. There really isn’t a way to prevent that because the engine thinks you are doing it on purpose. You just have to find out where and why it’s happening twice!

Is the object being destroyed/deactivated on collision in some way? That would be the way to go!

I think I’ve got it now.

I also have a version that subtracts when an item is consumed or sold or discarded, though I haven’t made those particular functions yet. Booleans will be used for, like, item/treasure boxes so they can be opened only once; while integers are used to keep the quantity from going over the max count and from increasing if the currency is less than 0 or less than the price. I will post a new thread later on how to make a shop widget that will let players choose some number of a desired item and calculate the money and quantity accordingly.

1 Like

I’m sorry. Here it is: Shopping Widget

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.