AoE

AoE

> Concepts and strategies

Area damage (or AoE, for Area of Effect) exists in many games. In Leek Wars, it isn't just a way to affect several opponents at once: it also makes for an interesting coding challenge.

Explanations

The getWeaponArea and getChipArea functions return the AoE type of a weapon and of a chip, respectively.

These functions return a constant, which can be:

AoEs with a radius of 3 cells (25 cells hit, as many as AREA_SQUARE_2) are among the largest in the game; AREA_X_3 reaches up to 6 cells from the center, and AREA_ALLIES and AREA_ENEMIES have no distance limit. The area hit is substantial. ![](/user-image/c1/80/c180710439acbd1c6c4e7f32e4344ef15a2f3df227ee1a234743a3f49bd7d266.webp)

Effect reduction

The strength of the effect decreases with the distance from the center of the AoE\*.

The targeted cell, in the center, receives 100% of the effect. For the other cells, the share of the effect decreases linearly. The percentage is calculated with the following equation:

percentage = max(0., 1. - 0.2 * getCellDistance(center, cell))

Keep in mind that the effect can't reach beyond the area's radius!

!AOE values

\* For Lasers, AREA_FIRST_INLINE, AREA_ALLIES and AREA_ENEMIES, there is no reduction: every cell receives 100% of the effect.

Through obstacles

Area damage goes through obstacles (except with Lasers). So you can hit a leek standing behind an obstacle by targeting a specific cell.

You can target a specific cell to make full use of area damage. To do so, use the useWeaponOnCell and useChipOnCell functions. This way, you can shoot the cell right next to your opponent to damage them even if they're hiding behind an obstacle!

However, you can't shoot at an obstacle. Only cells you have line of sight to can be targeted.

Example: !AOE obstacles

In gray, the obstacles; in red, the cells hit by the area damage.

The targeted cell is the one in the center of the image.