Most units in Ransacked have a base attack, where they attack a single target until the target is killed or the unit is given another order. This attack can be either melee or ranged. The rules for the attack are simple. They must have vision of the target, be standing still and facing the target.
For units that are controlled by the player, there are a few ways of acquiring a target. The first is ordering the unit to attack the target directly.
Secondly, you can issue an attack move order. The unit moves towards the specified location and will attack the first enemy it encounters.
The player also has the option to override this functionality, if desired, and make the units perform a "smart attack." When smart attack is enabled, the unit will attack the target closest to the attack move location instead of the target closest to itself.
An attack command can be issued to every selected unit at the same time.
After the target has been killed, the unit will search their surrounding area for a new target. In the case that vision is lost, the unit will move to the last known location of the target.
The unit will skip the search if they have an action in queue.
The search will be maintained until a new order is given.
The speed of the attack is determined by two factors: the base attack time(BAT) and an attack speed value. The BAT is the length an attack will take from beginning to end. The attack speed adjusts the BAT to make the length shorter or longer. A positive number decreases the value and vice versa. Each point represents 1/300th of a second.
A base attack is broken into 2 segments: the windup and the backswing. The meeting point of the two is called the attack point. It represents a position from 0% to 100% of the total attack length. This is the point where a ranged attack releases a projectile or a melee attack hits.
All of these variables can be adjusted on the fly by items and abilities in-game; so, it was important to create a system to sync the animations automatically. This is similar to the system used to adjust walking animations to movement speed. Here are a few examples:
BAT: 1.5s | Attack Speed: 0 | Attack Point: 0.5
BAT: 1.0s | Attack Speed: 0 | Attack Point: 0.5
BAT: 1.5s | Attack Speed: 0 | Attack Point: 0.3
BAT: 1.5s | Attack Speed: 0 | Attack Point: 0.7
BAT: 1.5s | Attack Speed: 100 | Attack Point: 0.5
Units can also have multiple animations for an attack and they will all sync accordingly.
As long as an attack has reached its attack point, the backswing can be cancelled, allowing a player to shorten the time between attacks when more precisely controlling a unit.