After I implemented my Kamikaze A.I., I knew the fun was over for a bit, because the code was disgusting as all hell, and I had to bring some sort of decency to it, lest I lose my mind. So that’s what I did during the earlier part of the day. And damn, it was boring as shit.
When working on this game, the best parts are when I have a very clear goal, and it’s all about just implementing it. It’s a whole other story if I have a vague goal of what I want to do (i.e. refactor shitty A.I. code), and then spend 80% of the time trying to figure out the best way to do it.
When this happens during the day, for whatever reason, I start to nod off. I’m definitely a night person. I can be up from like 7pm-2am no problem, but 2 in the afternoon? If I’m not working on some pretty cool stuff, it’s curtains for me.
After taking a few breaks, and after the wife and my daughter came home, I got a little re-energized, and was able to pin down exactly what I needed to do, and dammit, just do it. Of course, this will definitely change later. But you know, prototypes.
Once I was done refactoring the main code, it was pretty easy for me to extend my base AI class with ZoneAI, and implement a function that makes sure that if an enemy is not within their zone, do nothing.
It’s funny, because this is one of those things you don’t really think of (well, I don’t anyway) until you have to implement it. We’ve all seen this type of enemy, and for me, mostly in the Fire Emblem series. You’re happily klling enemies left and right, but there are some enemies that don’t approach. Then you finally get in range of them (usually the range is a combination of thier move + attack), and they come barreling towards you.
See below for an example of my implementation:
The first enemy unit attacks because you’re within their zone, but the other 3 do nothing, which is, well… you know, zone A.I. So yeah, it works 🙂
Of course, what is the point of all this A.I. stuff without enemies or the player being able to attack? Yep, that’s next on my plate for things to prototype.