Skip to content

AI for Mapping

Subject9x edited this page Oct 21, 2020 · 9 revisions

_(this is up-to-date for current release, however I am taking a look at some medium sized tweaks to AI behavior which may not be shown in this article, but I will update asap. 10/21/2020)

The bots are my friends...

This is not an article on all the intricacies of how the AI works, (article todo), instead this will be about how AI is placed onto a map to make sure they work and their placement jives with your map.

Units

The first part is knowing where the AI Units are for mapping - they are all located under unit_* in the point entity context menu. From here you can place copies of all enemy vehicles in the game.

they are filtered by the following tags

  • _type
  • _faction_
  • _style

Types

There are 5 vehicles and 3 mechs in regular battleMETAL.

  • Dunerunner - 'hover' tank.
  • Foslager - regular tank.
  • Onnek - turretless tank destroyer.
  • Sorcerer - turretless missile carrier.
  • Trowel - heavy battle tank.

Mechs

  • Balaket - light mech.
  • Matok - medium mech.
  • Monitor - heavy mech.

Factions - 3 original

  • PSC - default 'player' faction.
  • Survest - aristocratic but low technology.
  • Militar - high-tech corporate overlords and mercenaries.

Type

Now type is a bit more flexible. In the grand tradition of mech games, units usually have a large amount of variants trying to fulfill a niche on the battlefield. I broke it down to 3-4 main types.

  • Brawler - generally equipped with short-range weaponry, best fighting under < 600 game units. Usually not geared to breaking shields.
  • Zapper - designed to attack and destroy shields, but weak at full damage output.
  • Lobber - carries 'lobbed' weapons like missiles, artillery, plasma...terrible shield damage.
  • Gunner - mostly 'ballistc' / non-shield breaking items.

So the types give you a general idea of where these AI fit into combat scenarios.

Placement

As of this writing, AI has 2 specific placement methods that work and must be follow in order for the bots to function at all.

  • ai_node_tether
  • ai_node

When placing either type of node, it is strongly recommended that you place them as close to your floors as possible. Both nodes do not automatically drop to floor, they hover wherever they have been placed!

for original battleMETAL I used a practice of having nodes slightly underneath the floor they were above.

Tether Nodes

The basic way to place AI onto the map correctly. Simply drop a ai_node_tether entity in a place that bots can walk. This entity doesn't require any other fields.

Next, place your unit_* entities around the ai_node_tether using these rules.

  • any AI entity must be able to draw a direct line of sight to the nearest tether node, no obstructions!
  • AI bots scan for the nearest tether node when they spawn into the map, and error-out if they can't get a Line of sight to one.

and that's all for ai_node_tether. When the AI spawns in, it will grab the nearest one as its 'tether' node, and will walk back towards the node if it moves out of node range for any reason.

Patrol Nodes

the other slightly more complicated setup is setting patrol routes for bots. This uses the ai_node map entity.

  • Place any number of these entities on the map just like you would ai_node_tether.
  • .targetname - required used by AI to find nodes, and used by nodes to link to other nodes.
  • .target - optional can be other ai_node entities, or empty, when empty, the bot will reach this node and then treat it like an ai_node_tether.

Now place your unit_* entities around these nodes just like ai_node_tether. required make sure all unit_* that are to use these patrol nodes have .target match .targetname of their starting node.

If you've done it correctly, when the bots spawn into your map, they will move towards their assigned nodes.

note what is not possible is for bots to switch between ai_node_tether and ai_node, once they're assigned one or the other then that is what they'll be for their entire lives.