How do you modify the default values in a map in game?

Hi All

I’m trying to make a weighted table for random level selection. I’m using a map to populate an array.

The problem I have is once the random level is called I want to reduce the chance of that level occurring again.

I can’t find any answer on how to reduce the default values within a map, so that the next time the array is populated, the value for the level that had just been called is reduced by 1.

This is my current blueprint

Unfortunately the commented sections don’t work as intended and the chance of the map appearing never changes.

Any help would be greatly appreciated.

As you may know, a key can only appear once. When we load another key with the same value, it just replaces the old key. So, the way to reduce your weighting by 1, is:

LoginId:ae2651284db12148a4d920b659670407
EpicAccountId:

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION 0x00000000

Mir4G
Mir4G
Mir4G
Mir4G
Mir4G
Mir4G
Mir4G
kernel32
ntdll

LoginId:ae2651284db12148a4d920b659670407
EpicAccountId:

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION 0x00000000

Mir4G
Mir4G
Mir4G
Mir4G
Mir4G
Mir4G
Mir4G
kernel32
ntdll

Thank you for this original bit of code previously and your reply this time. This is actually how I tried to sold the problem originally, but it doesn’t work either. If I set all levels to a value of 1, they all can re-appear infinitely and never reduce to 0. I have some code at the end of this to print out the contents of the array to prove what I’m seeing and it verifies the array remain unchanged.

I just tested it with this:

The output:

348890-screenshot-3.jpg

The 1 is printed, then the 0.

EDIT: This won’t work:

348901-screenshot-4.jpg

Cheers, but I can’t see how this bit solves the problem.

Below is the check I use, which counts the number of “levels” in the array and prints them out. It works as it shows the correct number of levels based on what I set the level’s weighting in the map:

I’m not so concerned about the “debug” showing the correct number of levels in array and more so concerned about actually being able to adjust the values in the map once a level is chosen.

I’ve tried every permutation I can think, but nothing so far works and no amount of googling will tell me why it’s not and how to modify the map values appropriately so it will.

Thanks for your continued replies.

For what it’s worth I still can’t solve this. I can get (and prove through debugging) that the map value is reduced by one, however it isn’t a permanent change as each time I go to the next level and use the “item” again to run the code, the maps values reset back to their unadjusted defaults.

So, one thing I didn’t realise is that when you change levels the variables reset.

When I moved the code over to GameInstance and cast to it, then it worked as intended.

I put a check in just before the “set level to load” to see if the array is empty and if so, return to the first level.

If not then it continues on to reduce the value of the chosen level by 1 until every level value is 0 where upon the check catches it and it bounces to the first level.

Thanks for your help Clockwork, I think you overestimated my abilities and knowledge which is why I still had trouble.