AI Leader

Task

  • Set up leader
  • Tell other AI to wait for the leader to perform event
  • Switch to new leader after AI event finishes

How would you go about doing this?
I’m developing a combat system similar to Arkham series and Shadow of War.

Hey there @Codename_Prince! There’s many ways to pull this off, but from a high level design standpoint I’ll tell you how I would pull this off.

I personally have a fixation with managers (not the best design paradigm all the time, but for games like this where you want a group to be managed at once it’s useful). I would first create a script that manages any current fight. Basically every time combat starts, the fight manager populates all the enemies involved in the fight in an array and calls out to them to let them know when it’s their turn. This would also mean having a base class for your enemies that always call to the fight manager to tell it that the entity is joining the fight as well as calls to tell the fight manager when it dies, gives up it’s turn for whatever reason, uses it’s turn, or leaves a fight. This way you can keep the system up to date at all times.


Fight manager functions:

Add enemy: Adds an enemy to the array
Remove enemy: Removes an enemy from the array
Turn Taken: (ends the current NPC’s turn and shuffles them to the end of the array)
New Leader: (this then checks the array for a viable actor to be the next leader)
Call Attack: (this is called to send info to the current leader that they can execute their Blackboard events other than their idles).


This is a simplification, but I hope it gets the idea across and inspires your design a bit. Since this is rather specific I don’t have too many full fledged resources for it besides my experience.

It’s not too different from a normal turn based system besides the fact it needs to be real time, so that’s the recommendation I’ll drop below!

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

1 Like

I wish I saw this before buying the AI toolkit for $100. Luckily it has its own combat manager.

No worries (as long as that money wasn’t for food), take a look at how they did it for the future, I guarantee these paradigms will come up again and the one I described is probably just the simplest possible version!

1 Like