5.10 AI - Trails

Trails are used to establish AI patrol paths. Create and name your trails as explained in Section 2.8. Trails need to belong to the team that uses them, so make sure you have the AI team selected when creating your trails. These trails can then be used in your scripts.


ExecuteScript("[name]", "squad.move.typebasetotrail")
{
 Op("%.types", "=", "[name]");
 Op("%.base", "=", "[name]");
 Op("%.trail", "=", "[name]");
}


In this example, the recruit type does not have a source region. Instead, it is recruiting from "the base," all units available to the AI team, irrespective of distance. The squad will then move to the specified trail and follow it.


Weightings
All scripts are created equally in the AI's eyes. It will attempt to hand out units by equally dividing them between new squads. For example, if you execute three identical scripts that require four units each in the same objective, each will be assigned one unit at a time. Thus, each will get one unit before any of them get a second. As a result, even if there are ten units available, no squad will get enough to execute. To prevent this, you can assign weightings to the scripts.

Weightings have two values and are noted after the squad type in the objective action. The first rates its weighting importance within its ranking, the second is its ordinal ranking. Ordinal rankings are absolute numbers and determine the absolute order in which scripts will be executed. The weighting determines how assets are allocated between squads with the same ordinal ranking. Unlike the ordinal ranking, the weighting number is relative to other numbers among squads with identical ordinal ranks.

In the example below, assuming the scripts are executed simultaneously, the third script will be assigned all of its units first. This is due to its ranking of "4." The other two scripts will then be assigned units simultaneously. However, script 2 will gain units at twice the rate of script 1, since its ranking of 2000 is twice that of script 1's weighting of 1000.


ExecuteScript("[name]", "squad.explore.type", 1000, 5)
{
 Op("%.types", "=", "[name]");
 Op("%.region", "=", "[name]");
}

ExecuteScript("[name]", "squad.explore.type", 2000, 5)
{
 Op("%.types", "=", "[name]");
 Op("%.region", "=", "[name]");
}

ExecuteScript("[name]", "squad.explore.type", 500, 4)
{
 Op("%.types", "=", "[name]");
 Op("%.region", "=", "[name]");
}