"Behind the BANG!" is a new irregular blog series that looks behind the scenes of the mechanics of the game engine.
Micromanagement is a key skill in AOEO, especially in PvP. Still, it would be lame if you had to command every single unit all the time. Therefore, there are times when units are automatically commanded, such as when an enemy unit comes near. When a single enemy unit comes along, it's pretty clear what's being attacked. But what about when a whole army comes? Which unit from the army should be attacked first? Now you could say it's clear anyway: the unit closest to you will be attacked. But this is not the case, or at least not exclusively. Here a system called "target selector" is used which tries to calculate the best possible target. This system is not only used in AOEO, but also in AOE3 + (DE) and AOM, whereby there are differences between the versions.
== The Target Selector ==The target selector is used when there are several possible targets. However, it is not only used for attacking, but also in other (non-military) situations. The target selector offers 4 different modes:
Generally, the target selector is used when the last action is finished and no further actions have been set by the player. The game tries to select the best possible target for the given action.
== The process ==
But how does the target selector work? This process is divided into 4 parts:
At the end of this process, the goal with the highest priority score is selected.
- Determination/filtering of the valid targets.
- Calculation of factors to determine a priority score.
- Special adjustments of the score.
- Sorting the valid targets according to the score.
== Filtering ==
First of all, it must be determined which targets are actually valid. Depending on the situation, these filter parameters can be used. For example, in an attack scenario, the filters are set very loosely. Here you would search for those targets that you can attack. In a healing scenario, for example, you would only search for friendly targets. The filters can be set according to certain unit types, abstract types, player ID, relations (friendly or hostile) and many other settings. All valid targets that match these filter rules are collected in a list.
== The Factors ==As mentioned before, distance is not the only value used for prioritization. The target selector can use the following factors to calculate the priority score:
There are also other factors, but they are not currently used (1). For each of these factors, the respective minimum and maximum value is calculated from all possible targets, and then a relative value between 0 and 1 is calculated for each possible target.
The calculation in AOE3 is basically the same, only with the factor "Working Unit" AOEO makes a difference: Here the maximum value is capped at 5. This means that if a unit is attacked by more than 5 enemy units then it makes no difference. This also means that the values from 0 to 5 are weighted more differently. The "working unit" factor is also calculated differently depending on the prioritization mode. In attack mode, smaller values are preferred, which means that units that are not yet attacked by another unit are preferred. In gathering mode, for example, resources that are already being mined by another villager are preferred.
- 3 possible targets:
- Target 1: 10 HP
- Target 2: 70 HP
- Target 3: 110 HP
- Accordingly, minimum value: 10 HP and maximum value: 110 HP
- Accordingly, value range = maximum value - minimum value = 110 HP - 10 HP = 100 HP
- Calculation of the relative value: (maximum value - target hp) / value range
- Target 1: (110 HP - 10 HP) / 100 HP = 1.0
- Target 2: (110 HP - 70 HP) / 100 HP = 0.4
- Target 3: (110 HP - 110 HP) / 100 HP = 0.0
Now the individual factors are weighted and the base score is calculated. These are (for AOEO):
- Distance: x95
- Hitpoints: x5
- Working Units: x35
There are special cases where one or the other factor is adapted, but by default these weightings are used. This means that the different factors have a different influence on the score. The score is now added up from all factors with the respective weights for each individual target:
base score = distance factor * 95 + hitpoints factor * 5 + working unit factor * 35
For our example, the weighted HP factor would then be:
Thus, a base score has now been calculated for each individual possible target.
- Target 1: 1.0 * 5 = 5.0
- Target 2: 0.4 * 5 = 2.0
- Target 3: 0.0 * 5 = 0.0
== Special Adjustments ==Depending on the priority mode and situation, this score is added and subtracted with absolute values to prioritize different groups differently in special cases.
In attack mode, units are treated equally in principle. Anyone who has played AOEO/AOE3 for a long time will have noticed that enemy units are preferred over enemy buildings. For buildings, however, an extra distinction is made.
The prioritization is as follows:
An exception (AOEO exclusive) are units with the flag "AttackBuildingsFirst", which is set for siege units, like rams or palintonons. In this case, buildings are preferred over units. Only if there are no buildings in the list, units are prioritized.
Then the prioritization is as follows:
There is also a special case for the gathering mode. If the respective target is within 10 meters, then a distinction is made between resource types. So the prioritization is as follows:
== Sorting & Finalization ==
Now the list is sorted according to the priority score. The best result can then be processed.
In conclusion, we can say:
What do you think about the blog? Let us know in the comments below!
- Distance is still the primary value, but not the exclusive one.
- Units that have low HP and are not yet attacked by another unit are attacked preferentially.
- Low HP is also preferred for healing and building, but only to a very small extent.
- Building types are prioritized very differently when attacking.
- In gathering mode, certain types of resources are preferred and resources that are already being mined by other villagers.
Previous Behind the BANG! blogs:
All current and future content will stay 100% free and accessible to everyone.
Thank you so much for reading, and we will see you all next time!
Project Celeste Development Team
The Romans are here! Watch the Overview Trailer.
Project Celeste is completely free and always will be. However, we gladly accept donations for our overhead costs, which are larger than we have budgeted. If you want to support us, you can do so HERE.
Read every Romans related blog HERE.
Tell your friends! Join our Discord HERE.
(1) Damage and Angle
By Kevsoft on Jul 17, 2021 at 6:07 PM
- Similar Threads - Behind BANG Prioritize