Autoattack is a mode when units immediately attack an enemy unit if it moves around without player's specific command.

History[edit | edit source]

Autoattack was improved in Warserver 0.8.6a (2006), it became possible even out of the cities.

Since Warserver 0.8.7a, units consider winning chance when auto-attack (originally it was 50%).

The autoattack mode for units in a city got into main Freeciv branch with the version 1.8.0; the flag enabling it was located in the city dialog. All-server autoattack was added in 2004 with PR#2415 in October 2004 (r8788). City-specific autoattack was completely removed from the game up to July 2005 (PR#13501, v.2.1.0).

Since 2.3.5, nuclear units won't auto-attack, you can guess why it is good for the defender. In 3.0, this rule is moved to the ruleset by listing the flag in auto_attack.will_never server option. Also, provoking unit types (which used to be diplomatic and transporting units) are moved to the unit flag "Provoking".

Current rules (2.6.0)[edit | edit source]

The code responsible for autoattack behaviour mainly lives in server/unittools.c.

Autoattack is turned on or off for all units in a game by the server option autoattack (game.server.autoattack). The autoattack consideration is triggered for any unit that moves (goes, paradrops, teleports...) and the action may be performed by each of the adjacent enemy units if the criteria are met for that one. Unit actions that do not result in a movement don't trigger an autoattack.

All units on tiles now adjacent to one moved that are hostile to it and are able to attack it are sorted for the order they will auto-attack. If a unit and its transporter are both able to auto-attack, the cargo always goes first. If two units are on the same transporter depth, one with better winning chances will be first. Then, for each point of the list in an order the winning chance will be compared to a threshold (25% usually, but 90% for a sole city defender) and to the winning chance of the moved unit if it will attack first; both probabilities are evaluated regarding defenders of the stacks on the tiles, and the moved unit is always considered having at least 1 movement fragment. A unit perform autoattack if its surval chance is greater then the threshold, and either it is greater in attack on the unit then in defence against it or the unit is provoking. The last condition in 2.6 means that the moved unit has nonzero transport capacity (disregarding if it actually is transporting now or not) or can act hostile (i.e is something like Diplomat or Spy). If the moved unit for any reason can not attack a tile, any units there won't auto-attack this unit unless it is provoking.

Changes in 3.0[edit | edit source]

Since 3.0, attack is an action controlled by action enablers. To sort potential attackers, the probability of the action success is calculated by action_prob() function from common/actions.c; it mostly comes as winning chance rounded to 0.5%. If the unit is unseen to the potential attacker (e.g. has entered a city, who knows if there are peaceful units inside?), the function results in a special value which is pessimistically considered a sign of attack impossibility. The provoking unit types are unhardcoded with the flag "Provoking", and flags that prevent autoattack are listed in will_never ruleset setting.

Tactics[edit | edit source]

Autoattack changes units ballance many ways. If a player moves not simultaneously with his adversaries, in non-autoattack game he or she can easily approach a city with Diplomates and safely do their will to it; but in an autoattack game, the diplomates will be probably killed. Also, fast units weaker in defense than in attack become less powerful since they can't rush from a distance on a strong attacker without being killed on approach if there are no strong enough allied defender near the target.

The usual way to capture cities when autoattack is on is to "lure" the defenders from it with cheap provoking units (if winner advance is on, they will come out of the walls, otherwise at least will lose an attack that could be spent on a unit really dangerous for the city).

Community content is available under CC-BY-SA unless otherwise noted.