• Advertisement
Sign in to follow this  

Hack 'n Slash AI

This topic is 1600 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All,

 

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.

Share this post


Link to post
Share on other sites
Advertisement


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.

 

sounds like they have dummied down the AI or sacrificced realism for game balance purposes

 

if you want to study AI techniques, there's  good overview article here on gamedev. if you're looking for suggestions for an AI type to use, i suggest a hierarchical approach, a decision tree where each node is an "expert system" to choose the sub-node. each "expert system" node can be implemented as state machine, rule based or whatever works best. and of course some has to have written a book by now.

Share this post


Link to post
Share on other sites


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.

 

Those are all design decisions that have little to do with the actual architecture and programming of AI.

 


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.

 

There is no "how AI works in a hack 'n slash game" that can be explained. Everyone likely does it different. Best bet is to learn more about how AI is constructed first. Then the applications of it will be clearer.

 

For an overview, there is a sticky post at the top of this forum that has a link to an article I wrote on the different types of AI architecture, what they mean, how they are used, and the pros and cons. That will help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement