Unit Threat Processing

Unit Threat Processing

An RTS's AI, to me, falls within two categories: Unit & NPC. That is each unit has AI for pathfinding, auto-attack (if on aggressive mode), and general command behaviors (waypoints, following, etc.). More intersesting is what I call NPC AI; that larger AI that gives the non-player units their goals, tasks, and instructions. The way I love to play RTS games is with a bunch of friends working together to fight against a bunch of computer opponents because it is those computer opponents (and how they make decisions) that interestes me.

In my own MMORTS I'm making NPC (or faction based AI) through a threat processing system. Very similar to EISBot, I've created a messaging system to send events to the larger AIs that process what to do. The results are either sent down as commands to the units or sent upwards to the higher levels to deal with.

My different levels are:

  • Squad: Groups of units created for a purpose (i.e. patrolling guards, roaming hit squad, etc.), squad AI deals with threats such as "I see enemy X", or "I've been killed by X." It directs the squad members which enemies to attack or where to move.
  • Keep: Keeps and town centers are the central points of each cities, areas, and regions in zones. They directly control all defensive structures in their region and indirectly control squads of guards.
  • Factions: Each race/faction with any presence in the zone has an over-arching faction AI. These highest level of AI coordinate any keeps under that faction's control as well as raiding and seige squads to attack enemy towns and cities

Here are some of the rules I'v set up for threat messaging:

  • All NPC owned units are a part of Squads, squads can be owned by keeps (dealing with the local garrison) or factions.
  • Squads have a maximum amount of units they can spawn, with logic to vary those units based on various criteria.
  • Squads often have distinct purposes (Guarding, patrolling, wandering, standing at choke points).
  • Keeps and Factions have a maximum number of squads they can spawn, but may not keep those squads active all of the time.
  • Factions, Keeps, and Squads hold "scripts", objects that can be translated into commands for units.
  • Units send threats they encounter up to their Squad (i.e. "seen an enemy", "got hit", "I'm dead"). These threats are parsed and commands are sent back to the unit.
  • If the threat is too large for the squad, it will send it up to its owner. Keeps can send threats up to the Faction.
  • The owners will then parse the elevated script and send down threat messages as responses that the squad can handle, or deal with it other ways (i.e. spawn more units).
Author face

Christopher Axthelm

Creator of Mad Hatter Worlds games. Facinated with logic, world building, and software systems.

Recent post

-->