Project RBH Devlog 0039 (Patreon)
Content
Got a lot done last week!
As you might recall, there were three big things I wanted to get done: improving the enemy spawning system, improving the enemy AI, at least in regard to navigation, and making it so that enemies drop health on death.
I started with how the enemies are spawned in. Previously, the enemies were placed in the rooms using objects that would pull from lists of possible enemies, and choose one to spawn. This system was good for encounter design as I could place support units like turrets out of the way and let the shock troops charge. However, there were too many enemies in each room, and they would always be in the room the player spawned in.
To fix this, I created a new spawner object. This one checks for player proximity and then spawns enemies randomly within a certain range of itself, making sure to avoid spawning things inside of walls.
The way that this works is that it chooses a random coordinate within range, runs a collision check in a small circle around that coordinate, and if there’s nothing there, it spawns the enemy and repeats the process until all of the enemies have spawned in. Doing it in sequence like this gives the player a chance to process each enemy as it spawns in, and that little animation make it not only look better but draws the player’s eye to the new threat. In the future, I’d like enemies to not act for a second or so after spawning in as well, to really help sell their warping in.
Though, admittedly, there were a few issues before I worked out the best way to check a coordinate as a valid spawning point.
This dramatically shifted the way the game plays, and for the better. By spawning in enemies anywhere, they come from multiple directions which encourages the player to keep moving to avoid the incoming attacks instead of standing still firing at a horde.
The next major change to make was to have the enemies figure out how to move around obstacles. This turned out to be much easier than I expected it to be. GameMaker has built-in pathfinding tools, which is pretty standard for most game engines nowadays. So to make the enemies figure out the concept of walls, the first thing I did was convert the level to a grid at the end of level generation, with the empty space being valid terrain while walls and pits are not. Like so.
Then I told the enemies to use that grid to navigate their way towards the player until they were close enough, at which point they stop moving so they can stand there and shoot at you. This had a small problem, however, in that standing just around the corner meant that they would stop pursuing you because they were close enough even though they couldn’t shoot you. I fixed this using a simple line check. Much like that circle check I used to determine if a spawn point was valid, this one line of code checks for objects in a specific place—namely, in a straight line between the enemy and the player. If there is still an obstruction, the enemy continues following their pathfinding to walk around it.
The other big thing I did last week is far more minor than the other two, but still important. Enemies can now drop hearts when they die, and picking these up will restore some of the player’s health! This, combined with the reduced number of enemies per floor, gives the player a lot more longevity than they had before, while also introducing new decisions to make on the fly. Like, “is it worth it to try and leap into that crowd of enemies for that heart, or is there a better way to get it?”
I also gave it a small sheen animation to draw the eye, and a flicker effect to show when it’s close to expiring.
Progress on this project has been incremental; comes with the territory of being a solo dev working in my spare time. But with this, all I need to do is fill out the random upgrades, figure out a boss fight, and get some non-placeholder art assets (or at least better placeholders) and I’ll have a full demo on my hands.
Until next Devlog!
-DeusVerve
DevLogs like these are brought to you by Patron(s) like Haelerin!