I'm am writing ( or trying to, at least ) a simple 2D hack 'n slash RPG in C++ / SDL. Something like Diablo ( or Flare ).
I've got most of the stuff down, but I'm quite perplexed about how the AI should behave. It seems that the monsters don't automatically attack you as soon as they spot you, or you would never be able to get the first hit in. They also don't seem to be attacking continuously like you are, and sometimes leave you an opening for a free attack.
I can't seem to figure out their patterns, and the random things they do sometimes. Could someone refer me to a related tutorial or explain to me how AI works in a hack 'n slash game. An example pseudocode function will be really helpful as well.
Thanks in advance.