u/AaronWizard1

Making monsters make room for other monsters to better surround the player (or whatever they're attacking)

This is basically a repost of a thread I started on /r/roguelikedev. I'm looking for second opinions.

I'm working on my game's NPC/enemy AI. Currently when an NPC sees any enemies - currently just the player, but I want to support NPC vs NPC fights - it pathfinds to the closest enemy and attacks. I don't really need it to be more advanced than this, but I am seeing cases where an attacking NPC will block allies from attacking a target even when there's room for all of them to attack. Basically, I'd like logic that makes an NPC move around an enemy instead of just attacking if it would make sense to do so.

Ways to solve this I've seen suggested are:

  • Letting NPCs push each other out of the way
  • Some kind of tactical planner that NPCs allied with each other share which assigns attack positions around a target

Any other ideas? Or details on how a tactical planner would work, especially when I want to support NPC vs NPC battles and factions?

Note that I'm writing this for a turn-based game. For an action game I imagine I could use a boids flocking algorithm to make NPCs surround a target.

reddit.com
u/AaronWizard1 — 3 days ago