I made a lot of progress this week. I was tasked to work on the AI for three enemies. One was the enemy I worked on last week, and the other two were new. All three were simple to make, with the hardest part being the path finding for the piranhas that I did last week. All three are now implemented to the point that they should be testable in QA, at least with most of their planned functions. The piranhas have been at QA all week.
The first enemy I worked on was the piranhas. I worked on their path finding last week, and set up the whole system for how they move. This week, I added wandering, fixed up the movement in general to the specification, and added an attack. I also added an optimization that reduces the time spent on path smoothing, simply by only running it every number of frames. The piranhas are now almost fully functional, with most of the remaining work being visual implementation. I also need to fix the way you kill the piranhas, because it’s still using inflexible temporary code.
The second enemy was the sand dollars. These enemies are mines that sit and wait for the player, then explode once the player is in range. The explosion damages the player and pushes them back. It also damages other enemies and pushes them back. It will destroy walls within a radius, but that isn’t implemented yet. This enemy’s AI is much simpler and doesn’t require any movement, but it still uses all of the same architecture. This made it very easy to set up, with only some of the functions requiring new code. This also means that anything else that uses the same system can use any of the new features I added for it. I used this to make up some exploding piranhas, that simply explode once within range of the player. This only took a few minutes, and didn’t require any new code.
The last enemy was the jellyfish. This enemy also has a simple system, only gently moving between two points. It ignores the player, and damages them if its tentacles touch the player. Once again, I only added a few new scripts, and mostly reused the same systems. The damage is just dealt to a hitbox where the tentacles are for now, because they aren’t using the movement system yet. It is just a sprite for now. Once we get that working, it should be simple to put hitboxes on the tentacles as they move.
We now have three enemies mostly functional, ready to be implemented and tested. As I add more functions to the AI system, it becomes easier to create new enemies with different behaviors. Most of the time, most of the enemy will already be programmed, and I will only need to add in a couple new behaviors or state transitions. The whole system makes it easy to create new state machines, like in the case of the exploding piranhas.