Access variable name

Hi all, so I set up a whole status effect system for a turn based game using integer variables (duration) to track who has what status. It checks on turn start if duration > 0 and does something, with me hard coding the effect name as a function input for each (poison, burn, etc…) to direct it to the right path.

Problem is, I now need a function which gets a random active effect. So I would make an array with any status integer variables >0 and pull one at random, but then it needs to know which status it is for any subsequent effect. I see how I could make a hacky workaround using a ton of local string variables, but surely there’s a way to tell UE “If this integer variable name (as a string/name) = X, do this, if it is Y, do that” etc… I just can’t for the life of me find it via Google.

Any advice would be appreciated!

1 Like

I can see you’ve had a good attempt at explaining this, but I’m still not quite clear.

Let’s say someone is poisoned. Each turn, the integer ( for the turn ) goes down 1.

And the poison effect is, say, a random number between 0 and 1?

Something like that?

Apologies for the comically slow response, some irl things got in my way. I’m circling back to this.

To take another stab at explaining it: I have a bunch of status effects. To determine whether a status is applied I run a function which takes a name (the status to be applied) and does various things to see if the status application was successful. If it succeeds it flips a bool variable. The variable has the name of the status (Burn = TRUE etc…)

I want to then return TRUE if it succeeded. I could go and stick a return node on every single switch item, but what would be easier (and this has come up in other contexts for me as well, hence my wanting to figure this out) would be to say “I have this NAME. Find the variable whose variable name = NAME. If that variable is a bool and is TRUE, then return TRUE.”

Basically the bool variable is a bool, but it also has a name. I want to access the name part of the variable and compare it to a name object.

1 Like

I think, from what you’re saying, that map would do the trick for this. You can map any name to a bool

You can add one value like this

This means burn is false right now. I can check burn with

or generally in a function to find any name

If I want to set burn to true, it’s just

Notice, it’s not like an array. If Burn is in the map, it will be set to true. If it’s not there, it will be added as true.

1 Like

Just to add to this I would suggest looking into gameplay tags for status effects.

They are more robust in their implementation.

2 Likes