Adding the Upgrade Pool


For the 6th week of this project, I've started working on one of the biggest features of our game: The upgrade pool system

Prior to this week, we had a system in place to give out an upgrade to the player when they interacted with the pickup, however these upgrades had a few problems that needed solving. The previous upgrades had been hardcoded into the upgrade pool, which made it very difficult to add new upgrades. To get around this, I made an Upgrade class that I could add to an array in the upgrade pool via blueprints. Once I had the upgrade class, I made a Blueprint of it as a template, that I could then make a child of for all of the upgrades in the game.

The upgrade blueprints made it much easier to create new upgrades with their own unique stats and abilities. Each upgrade had an easily editable Name, a Description, an Icon to display in the menus, among other variables that will be used in the future. From this template, I created a total of 14 upgrades, each with their own unique stat upgrades and/or movement abilities. Each upgrade was also given a weight so that some upgrades are rarer than others. Trevor already had a working weight system for the procedural generation, so I copied that functionality over into the upgrade pool and its upgrades.

On top of all that, I needed a way to give the player a choice of upgrades instead of one random one. Alex helped by creating the menu widget that holds the upgrades, but for it to work we needed to pull an array of upgrades from the pool. I created a function that could pull three upgrades from the pool, but I had to do some janky manipulation to prevent the pool from grabbing multiples of the same upgrade. To do this, I manually and temporarily lowered the weight of the full pool , as well as setting the weight of the upgrade to 0 every time an upgrade was pulled, before the next one was pulled. After pulling all three upgrades, the weight of the upgrade and the pool was set back to their original weights.

My initial implementation of this was broken, and I didn't find out until Alex started creating the menu, since I didn't have a means to test the method before that point. Additionally, the function is currently not thread safe, since it manipulates the pool's weights directly, so we also ran into problems when multiple upgrades tried to pull from the pool. We got around this by having the upgrades only be pulled when the object was interacted with, which should mean that only one instance of the function be running at any time. If this becomes a problem in the future, I will need to figure out a way to make it thread safe.

The upgrade system is looking very promising so far, but there are a lot of things I want to do with it still, and I've got a long road ahead of me.

Leave a comment

Log in with itch.io to leave a comment.