Personally, I would create functions for each attack you want the enemy to do. That way, upon the time of attack, a controlled random event, it will make the enemy attack, and it can't do anything else. When the attack ends, it may continue about its AI life. The function would set the enemy's animation, set a variable to signify attack, and other. This really depends on how you are doing damage, general attacking, and more. I could help you out, but can you post a demo of your game? Or perhaps you could just explain it. But here is a sample of what I am talking about.
- Code: Select all
void
AI_Sword(void)
{
//The change animation code here
Enemy_Attack=1; // this would be an int, if it equals one, it can't do anything
//Other code depending on what system you are using
|
If you don't like this method, I can show you several more.