GameDev 2019 Week 20: Roguelike
Reward/Wave Selection, Elemental Damage02.06.2019 - 21:46
One of the ideas I had from the beginning was to add some roguelike elements to the game like choosing from a few different rewards after completing a wave or even choosing between different waves depending on your current towers. Rewards could be unlocking new towers, new tower upgrades, items, money, lifes, etc. Last weeks refactoring was needed to add support for the additional game states these new features require. Also the server needed to change to add the functionality of waiting for all players to choose a reward or a wave. As I hinted to in last weeks blogpost, I started to work on some of the new features last week. I added items to the game, which are basically anything the player can choose from when completing a wave, like new towers or money as mentioned above. The first item category I implemented were the items that unlock new towers. Items can be unique, which means they can only picked up once per player. Tower unlocking items are obviously unique, because unlocking a tower that is already unlocked doesn't make sense. But items which give gold or lifes can be picked up multiple times. I made some very rudimentary uis for the selections and I also added a timer that limits the time a player has to choose an item. Now we are at the state at the beginning of this week.
After writing the very short blog post for last week I had some time left and I made icons for the gold bag and life potion in three different sizes, small, medium and big. Then I changed the tower button texture creation tool so that it not only creates the textures for the buttons, but also automatically creates an icon for the item that unlocks the tower. I also had to move around the directories for the images so it doesn't produce complicated nested paths.
I started the day by implementing support for custom item images so I could use the icons from yesterday. Then I fixed a bug so items that unlock a tower upgrade will not show up if the player doesn't have the base tower unlocked and added a sound effect when selecting a reward. To clean up the building class and add support for items that can change stats I refactored the stats into their own component and also added another class for stat buffs. Every player has a list of buffs that are applied to all of his buildings. To try this out I added a test item that increases the damage by 100%. Then I had to make sure the building window updates properly when a new buff is applied or an upgrade is unlocked while the window of the base tower is open. Finally I changed the aura system so auras also use the same stat buff, but only to the tower in range. For now the multiplicative buffs are only calculated from the base stats, because having the 100% test buff stack multiple times on top of itself was kinda broken, and even though there won't be a +100% damage buff (probably), having different smaller buffs stack up may be too strong.
I added max lifes, so the player cannot buy or restore unlimited lifes anymore. Also this allows me to add items that increase the max lifes of a player. Then I changed the hardcoded number of item choices to a variable so there can also be items that add another option to the reward selections. This required some changes to the reward selection ui, so it updates properly when the number of choice has increased. In afternoon I started with a new combat system that includes elemental types and elemental damage. However, trying to figure out a good way of elemental strengths and weaknesses turned out to be really complicated, because I wanted to make sure that it is fair and at least somewhat self-explanatory, so water extinguishes fire and fire burns nature, etc. Initially I tried with 6 different elemental types, but I couldn't find a good solution.
Reward selection ui (work in progress):
By adding a 7th elemental type "earth" I was able to get to a decent solution, at least for now. I may tweak this a little bit more later on. Anyway, I implemented the strengths and weaknesses into the combat system and changed some of the damage calculations over to the new system. Then I made some (probably only temporary) icons for the elemental types.
To be able to select between a few options for a wave I needed an algorithm that produces some kind of node/path system. Every node has at least one connection in and one connection out with a chance for multiple connections. This makes sure that there is no way to get stuck. In the end all paths lead to the same boss wave. Below there is a debug image of how the general structure looks like. So far it only creates the structure, but doesn't randomize the number of enemies, how strong they are, whether they are flying or not, how much gold they give, how many lifes they take, etc, because I still need to figure out a good way of scaling the difficulty up, so that it gets harder, but not impossible or too easy.
With the algorithm to create some choices in place, I worked on the wave selection ui some more and added buttons to choose between the options for the current wave. It shows the elemental type and some stats for the wave (just hardcoded strings at the moment, as mentioned these stats are not generated yet) and also which options are available in the next wave when the player selects the option. Then I implemented the network and game code to broadcast and handle every players choices and finally added an icon to the game state ui to show the elemental type of the current wave. In the future I am also going to add a button there to show some more detailed stats about the wave.
Wave selection ui (work in progress):
by Christian - 02.06.2019 - 21:46