I am making a Final Fantasy-style battle system.

I have a random generator that select the monsters move when it is their turn; different moves have different chances to be performed. I also have reactions and conditional actions for the monster to create simulated intelligence... but what I can't figure out is targeting.

I could just choose randomly between the five player characters, but I was looking for something that would make the game more challenging by adding some kind of strategy to the monsters' actions.

I code in C++.

Does anyone have an idea how to implement a system for the monster to choose who to attack besides completely random?

  • \$\begingroup\$ You might want to edit add an question to your post. What are you asking for? \$\endgroup\$ Commented May 9, 2011 at 12:39
  • \$\begingroup\$ It seems like a combination of chaos' and tenpn's answer makes the most sense.. both from the developer side and from the players. \$\endgroup\$
    – Angelo R.
    Commented May 9, 2011 at 15:06

2 Answers 2


My answer from this question would fit here.

To adapt for your problem: A monster would look to assign a score to each enemy. Pass the enemy to each of a collection of behaviour classes, which each return an integer score. Add all these scores together, and assign the final score to the enemy. Attack the enemy with the highest score.

This has the scope for different monsters having different behaviours, evaluating targets in different ways, and the personality extension I mentioned in the other answer could be modified at run time to alter target choice based on the monster's situation: maybe he becomes more aggressive as his health lowers?

From chaos' answer, you could keep a sticky target by remembering the score of the last target, and any new target would have to beat that score by some extra %.

Examples of the behaviours might be:

  • defenseless target behaviour: returns high scores for targets that are particularly susceptible to this monster's attacks - eg a mage vulnerable to red magic in a battle with a fire demon.
  • weak target behaviour: returns high scores for targets that are close to death
  • decapitation behaviour: returns a high score for the player or leader of the group
  • splash damage behaviour: if your game is a strategy-style rpg, that can make attacks across various team members, this behaviour could return high scores for targets that affect large numbers of bystanders, eg if a target is in the center of a tight group.

All of these behaviours are based on snapshots of the current game state, and require no long-term planning and little state on behalf of the monster.

More ideas: if your monster has multiple attacks, run this whole alg once for each attack, and pick the target/attack pair with the highest score. This was how I made enemy infantry select weapons on one big-budget FPS.

  • \$\begingroup\$ Its easy to say generate a score for each player and pick the highest but what would you base the scores on ? \$\endgroup\$
    – Skeith
    Commented May 9, 2011 at 16:19
  • \$\begingroup\$ I'll update the answer with more details \$\endgroup\$
    – tenpn
    Commented May 9, 2011 at 16:50

If you wanted them to act really smart, usually in RPGs the best thing for the monsters to do is all attack the PC with the highest ratio of offensive capability to hit points. You don't see this actually done a lot, though, since it tends not to be rewarding for the player. :)

One place I might recommend starting is to come up with some general categorization scheme for your PCs -- bucket them as melee, casters, healers, and stealth, or as offensive, defensive, support, or what-have-you -- and have each type of monster display a preference for the category of PC it will attack. Maybe some almost always go for that category, while some have a mild preference. This provides something useful the player can learn about the monster types and gives more interesting behavior than pure randomness.

You may also want to make monsters "sticky" in their target preference to some degree, i.e. make them tend to continue attacking whoever they last attacked.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .