Skip to content

Team execution

Gives every team one logic turn a frame, in which it retests its strength, starts or regroups, gathers its members, and works down its Script.

Features & systemsScenarios & AIAI & teams

Changed in 0.1.0

Every team in a scenario takes one logic turn a frame, and that turn is the same for all of them whatever their Script asks for. It retests the team’s strength against its roster, starts the team or sends it back to regroup, recomputes the point its members gather on, looks for new members, disbands the team when there is nothing left of it, and then either carries out the line of the Script the team is on or spends the turn pulling the members back together.

AI triggers and team production introduces teams, TeamTypes and the three sections a TeamType points at, and owns everything up to the moment a team exists. What each line of a Script asks for belongs to the individual team missions. This page is the framework those missions run inside.

The steps run in the order below. More than one can fire on the same turn, and three of them can end the team, so where a step sits is often the whole explanation for a behavior further down this page.

  1. Suspension. A team suspended by a base defense call-up leaves the turn at once and runs none of the rest. On the turn its timer reaches zero it clears the suspension and carries on through the remaining steps.
  2. The strength recalculation. Run only when the roster has changed since the last one; joining or losing a member marks it. It settles the full-strength, under-strength and reforming flags below. A team left holding nobody that already carries the started mark — set the first time a team reaches full strength or is flagged into action, and never cleared afterward — is deleted here, in the same way step 7 deletes one, and the rest of the turn does not run.
  3. The regroup. A team that is under way — flagged into action and not since sent back — and is under strength is stopped, its script is rewound, and it is sent to gather at a friendly building; base defense response covers which building.
  4. The start. A team that is not under way and is either at full strength — holding every member its TaskForce asks for — or forced active, a mark only a reinforcement group carries, is flagged into action. This can fire on the same turn as the regroup above, but only for a forced active team: a regroup leaves a team short of full strength, and being forced active is the only other way past this step’s test.
  5. The center. The team’s center and its nearest member are recomputed under any of: it is reforming; it is under way; it has no center recorded; it has no nearest member recorded.
  6. Recruitment. The team looks for members to fill the places its TaskForce still wants. The recruitment pass owns the gate, the ranking and the tests a candidate has to clear.
  7. Dissolution. A team left holding nobody, that either carries the started mark or — outside a campaign — has outlived the unfilled-team delay, springs Leaves map (team) if it is marked as having left the map, and is then deleted.
  8. The fork. The script step runs under all of: the team is under way; it is not reforming; it is not under strength. Otherwise a team that is under way runs the regroup coordinator, and one that is not runs the move coordinator.

Team turns run at a fixed point in the logic frame, before object turns and before house turns. They are taken over a copy of the team list made immediately beforehand, because a team’s turn can delete the team. Orders a team issues are therefore acted on by its members later in the same frame, while anything a team reads about its members is what the previous frame left behind.

Six flags between them decide which branch each step takes. The table gives what raises and what clears each one; the two rows that nothing ever clears are where most of the behavior on this page comes from.

FlagRaised byCleared by
Under wayThe start stepThe regroup step
Full strengthThe recalculation, when the member count equals what the TaskForce asks forThe recalculation, on any other count
Under strengthThe recalculation, at the threshold belowThe recalculation above that threshold, the start step, and being marked forced active
The started markThe recalculation on reaching full strength, and the start stepNothing
Forced activeCreation as a reinforcement group, which is the only thing that sets itNothing. The line that would have cleared it at the start step is disabled
ReformingThe recalculation, whenever the under-strength flag came out different from the value it went in with, and damage to a memberThe regroup coordinator, once every member is gathered

The under-strength threshold depends on Reinforce. A Reinforce=yes team whose TaskForce asks for three or more members is under strength while it holds a third of that count or fewer, rounded down; one asking for two or fewer is under strength while it is short of full. A Reinforce=no team is under strength only until it first carries the started mark, and is permanently not under strength afterward. A team holding nobody at all is under strength and not at full strength whatever its type says.

Two consequences are worth stating on their own.

The reforming flag cannot clear while the team is stopped. Its only clearing site is the regroup coordinator, and the fork reaches that coordinator only for a team that is under way. Whatever raises the flag while the team is stopped — the recalculation, or damage — leaves it raised until the team is started again.

The start step reads the reforming flag. A team flagged into action while reforming has every one of its members counted as being in formation from that moment. A team flagged into action while not reforming leaves each member to reach the center on its own. Being forced active has the same effect here as reforming does.

The ordinary way a team starts guarantees that it is reforming when it does. A team is created under strength and stops being under strength at or before the moment it reaches full strength, and whichever recalculation makes that change raises the reforming flag. Nothing can clear the flag in between, because the only thing that clears it is the regroup coordinator and the fork cannot reach that coordinator while the team is stopped. The flag is therefore still raised when the start step fires; the start step does not clear it; and the fork sends the team to the regroup coordinator rather than to its script. Only once every member is within Stray of the center does the coordinator report the team gathered; the reforming flag clears then, and the following turn reaches the first line of the Script.

A forced active team skips the delay. A reinforcement group is marked forced active as it is created, before a single member is added, and that mark clears the under-strength flag straight away; the recalculation that follows finds the group at full strength — a group is created with its whole TaskForce at once — and leaves the flag where it already was, so nothing raises the reforming flag and the group reaches its first script line on its very first turn.

A regroup rewinds the team’s Script to before its first line, and nothing remembers where the team had reached. The regroup step stops the script; when the team is next flagged into action the start step stops it again and raises the flag that tells the team to move on to its next line; and that advance then steps the cursor from before the first line onto the first line. A team sent back to regroup restarts its mission list from the top, however far through it had worked. There is no resume.

Only a Reinforce=yes team can be sent back at all. The regroup step is reached only by a team that is under strength, and a Reinforce=no team stops being under strength for good the moment it is started. Reinforce therefore governs the restart as firmly as it governs recruitment: it is the setting that admits a team to the regroup step, and every visit to that step costs the team its progress.

A team’s center is the point its members gather on and are measured against. It is a reference to a cell or to one of the members rather than a fixed coordinate, so it moves when what it refers to moves.

The center is recomputed from scratch each time step 5 runs. A member is counted under all of: it is alive and out of limbo; it is in formation, meaning that it has reached the center once and is treated as taking part from then on, though an aircraft counts without ever having reached it; and it has entered the playable area. The counted positions are averaged, with a GuardSlower team counting a slow member’s position twice.

The average is then usually discarded. Where the member nearest the team’s current target could move into the averaged cell as things stand, the center becomes that member instead; the averaged cell survives as the center only where it could not, whether because the ground is impassable or because something is standing there at that moment. The center of a team on open ground is one member’s position rather than the middle of the group.

That nearest member is recorded alongside the center, and nothing live measures against it: the lagging test is the only thing that would, and it never runs. It has one remaining effect, in step 5 — a team with no nearest member recorded recomputes its center every turn.

A team whose current line is Follow friendlies takes its center from the nearest vehicle or infantry belonging to an allied house other than its own, and has no center at all where there is none.

Waypoint gives a team a center as it is created, and step 5 runs on the team’s first turn whatever else is true, so that cell is replaced before anything has measured against it. The origin’s live roles — ranking recruitment candidates, the retreat destination, the landing zone an aircraft carrying a member picks, and the cell a reinforcement group enters at — all read it directly rather than through the center.

The regroup step recomputes the center itself and then reads it back without testing that one was found. A team that still holds members but none the count above accepts — all of them in limbo, or none of them yet inside the playable area — has no center to read, and the step faults there.

The regroup and move coordinators start each member with the same test, and so do the mission handlers that give orders to the whole team. A member that is on the map and not yet in formation is measured against the center: farther away than Stray and not already heading somewhere, it is put on the Move mission and sent to the center; within that distance, it counts as in formation from then on and is never tested again. Until it arrives, everything else the coordinators do passes over it, and it holds up a move.

A team that has not been given a target does not reach this test at all, because the move coordinator does nothing whatever without one. Members recruited into a team that is still filling therefore stay exactly where they were recruited, which is why the gathering happens after the team starts rather than before. A team stopped by the regroup step is the exception: it is given its regroup building as a target, so it does walk there, bringing stragglers into formation as it goes.

The regroup coordinator holds a team in place and closes it up. Each member in formation that is farther than Stray from the center is put on the Move mission and sent there, unless it holds an Area Guard mission with a target; a member that already has a destination is left alone, and does not hold the gathering up either. Every other member is put on Guard, unless it is already on Area Guard. The coordinator reports the team gathered only on a turn where it issued no move order at all, and that report is what clears the reforming flag.

The move coordinator walks the team toward its target. Each member in formation that is not unloading is measured against that target and ordered to it under any of:

  • it is farther from the target than Stray, which is tripled for an aircraft;
  • All of: it is below ground level, and the next line of the Script is not itself a move;
  • All of: it is an aircraft, it is above the ground, it is not already over the target, and the next line of the Script is not itself a move.

A member that is none of those is instead released from a move it has finished, under all of:

  • it is on the Move mission;
  • Any of: it has no destination left, or it is within CloseEnough of its destination and has stopped moving;
  • it holds no target.

Release clears the destination and puts the member back into its idle behavior. Either way, a member still holding a destination keeps the move outstanding.

The team counts as having arrived once no member is outstanding and at least one was measured — a team whose members are all still unloading, or all still out of formation, never arrives. Only then is the advance flag raised, and only for a team that is under way, so the same coordinator walking a stopped team to its regroup building never advances anything.

Aggressive exempts a member that already holds a target. It is passed over entirely: not ordered to the target, and not counted as outstanding either, so the rest of the team can arrive and move on without it. TransportsReturnOnUnload stamps each member that can carry passengers with a return point at the top of this same coordinator.

A team carries two targets. The mission target is what the current line of the Script asks for. The current target is what the members are actually pointed at, and it can be overridden — damage turning the team onto its attacker is what does that. Assigning a mission target normally sets both; where the current target has already been overridden, only the mission target moves, so the team finishes the fight it is in and picks the new mission target up afterward. On the turns between advances the script step restores the current target from the mission target whenever something has cleared it, and the loss of whatever a target referred to clears it.

Changing the mission target also puts every member that was aiming at or heading for the old one back on Guard, with its own target and destination cleared.

Each team runs its own copy of the Script its TeamType names, and that copy carries a cursor: the line the team is presently on, or a position before the first line while the script has yet to start or has been stopped. A separate advance flag records that the team should move on, and it is the team mission handlers that raise it.

The script step runs only when the fork selects it. Where the advance flag is set, the step clears it, steps the cursor on by one, and clears every member’s recorded return point. A cursor stepped past the last line deletes the team outright, which is the ordinary end of a team that finishes its work. Otherwise the mission target is cleared and the handler for the new line is run and told this is its first pass. On every later turn the same handler runs again and is told it is not.

Damage to a member is handed to its team, and what the team does with it turns on whether it is under way. A team that is not under way drops its center and raises the reforming flag, wherever the damage came from. A team that is under way normally turns on a non-allied attacker instead, using the team’s house to test the alliance; damage from an allied house leaves the team’s target and its members’ orders alone. The team raises the reforming flag only where its type sets Annoyance=yes — which owns the ordering that decides whether the retarget then happens at all. Suicide=yes switches the whole response off.

A team carries a mark recording that it has left the map. Leaves map (team) tests that mark together with the team being empty, and both the recalculation and the dissolution step spring the event for the team they are about to delete.

Three things raise the mark on terms that match its name: a vehicle on Guard deleted for standing outside the playfield after having once entered the playable area, an aircraft on Retreat deleted for flying outside the playable area, and each passenger such an aircraft was carrying. The mark is cleared in one place only — assigning the team a mission target that is a cell inside the playable area.

What belonging to a team changes about a member

Section titled “What belonging to a team changes about a member”

A member is not simply an object under new management: several settings reach it through the team and stop reaching it the moment it leaves. The list gathers them, pointing at the page that owns each.

  • Its orders are reissued every turn by whichever coordinator the fork selected, overriding whatever it was doing before.
  • Its group number is overwritten with the team’s, and its autocreate-recruitable state with the TeamType’s, as it joins.
  • A team of strictly higher Priority can take it, and it is stripped from the team outright when the team’s priority falls below the base defense threshold.
  • IonImmune=yes spares it ion storm lightning and warhead damage for as long as it is a member.
  • Suicide=yes stops it retaliating and stops it scanning for targets as it moves.
  • AvoidThreats=yes overrides its own threat avoidance.
  • Beginning a path search toward a temporarily blocked destination, it measures the distance against Stray where an object on no team measures it against CloseEnough.
  • Loadable decides whether the player may order infantry aboard it.
  • It answers a base defense call-up only while its team is a base defense team.

What the member picks for itself is not narrowed by any of this. OnlyTargetHouseEnemy=yes restricts the target the team’s script asks the engine to find, and nothing else.

GuardSlower carries a lagging-formation mechanic alongside its weighting, and that mechanic never runs. The move coordinator asks whether the team has members lagging behind before it does anything else, and the routine it asks returns immediately unless a flag is already set saying that it has. The only place that flag is ever assigned is the end of that same routine, past the return; it starts clear, and nothing else in the engine writes it. The ordering that would hold the fast members in place while the slow ones caught up is unreachable.

Four further pieces of team state are maintained and reach no decision. A regrouping flag is written by the damage response and cleared by the regroup coordinator, and nothing reads it — not even the multiplayer checksum. A GuardSlower team’s record of whether it is above its under-strength threshold is written and never read at all. A running total of the members’ threat values, and a second copy of the roster-changed flag kept beside the first, are read by the checksum and by nothing else.

15 of 15

KeyDescriptionValueWhen omitted
AggressiveTeamTypeLets a member that holds a target stay and fight instead of closing on the team's destination.booleanno
AnnoyanceTeamTypeMakes a team that is already under way regroup when one of its members is fired on.booleanno
CloseEnoughglobal rulesDistance in cells within which a blocked ground object treats its destination as reached.distance (cells)2.5
GuardSlowerTeamTypeWeights the team's formation toward the members it counts as slow.booleanno
HouseTeamTypeThe country whose house in the match owns teams built from this TeamType.HouseTypenone
IonImmuneTeamTypeExempts the team's members from ion storm lightning damage and from being aimed at.booleanno
OnlyTargetHouseEnemyTeamTypeRestricts the team's scripted target choice to the owner's declared enemy.booleanno
PriorityTeamType, SoundsHow firmly a team holds its members against other teams, or how hard a sound competes for a playback channel.integerVaries by type
ReinforceTeamTypeWhether a team of this type keeps recruiting after it has begun to move.booleanno
ScriptTeamTypeThe Script whose team missions a team of this type carries out.classnone
Strayglobal rulesDistance in cells a team member may drift from the team before it is ordered back.distance (cells)2
SuicideTeamTypeStops the team and its members from answering anything but their script.booleanno
TaskForceTeamTypeThe TaskForce whose composition a team of this type recruits and builds toward.classnone
TransportsReturnOnUnloadTeamTypeSends each transport back to where it set out from once the team's unload finishes.booleanno
WaypointTeamTypeThe waypoint a team of this type starts at and recruits around.stringnone

History

  1. Changed0.1.0In development

    Keep AI teams from retaliating against allies