I wanted to start off simple, with two AI states to test out the state machine. The AI was supposed to:
1. Find a random trash can in the stage and pick it up.
2. Take the trash can, line up with the player, and throw it at him.
The first attempt did not go so well. They all picked up trash cans, eventually, but some of them walked in place after grabbing it, some of them just threw it randomly, and some of them appeared to be having a seizure by moving back and forth rapidly. So, I redid step 2 so they would simply throw the trash can once they picked it up.
This worked better, but there were still numerous problems, like some enemies following others, some walking in place, and some trying to walk off the map. Then I realized the obvious, the enemies were trying to pick up a random trash can in the stage, even ones that were already held or off the map. I knew this because I was actually able to play fetch with one of the enemies by tossing the trash can back and forth, and he would always follow it.
Although I was enjoying playing fetch with them, I decided to fix the AI so they would only go for trash cans that were on the floor and still on the map. With this fixed, I watched as they found each trash can in the stage, picked it up, and threw it right off the stage, with the exception of one. Then something interesting happened. Two enemies, perfectly lined up, began to toss the remaining trash can back and forth to each other, like a bizarre game of catch. Before I could take a screenshot, the third enemy intercepted the trash can and chucked it off the stage.
Finally, I fixed step 2 so they would actually throw the trash cans at the player, and it works. Next up, I have to get the AI working for actual close-up fighting. For this, I'll add a "Fight" and "Retreat" AI state for this purpose(and probably also a "Charge" state for running attacks).
I was thinking of how I would handle the retreating aspect of the AI, and I actually looked to Warhammer 40k for inspiration. In that game, if a unit is in melee combat, and they lose a turn, they have to take a morale check to determine if they continue fighting or flee. I'll have a similar concept in this, as if an enemy is knocked to the ground, they'll take a "morale check" to determine if they continue fighting. I mentioned in the last entry that the AI would have traits, and I figure that they'll have a "bravery" trait which will determine how they pass a morale check.
Hmmm, that was a long entry. I'll try and replace the excessive text with excessive screenshots in later entries[grin]
Its this kind of odd behaviour that I love to find in my games. It can be particularly hilarious sometimes when it is a bug. For example, one of the earliest games a friend of mine and I made had a wonderful bug caused by a copy and paste error: gravity in both the X and Y dimensions [smile]