Engine > Systems > Combat System

Stateless system for target selection, damage calculation, and move-to-attack pathfinding. Used by EntityCommandPhase for human attacks and by BotSystem for bot turn resolution.

executeAttack

Executes an attack from attacker to target. Resolves AOE targets, applies damage with multipliers, removes dead entities, spends AP, and returns all resulting effects.

hasAttackAvailable

Returns true if the entity has a valid attack available this turn.

getAttackTargetTiles

Returns all tiles containing valid attack targets for the given entity from its current position. Convenience wrapper around getTargetTilesFrom.

getAttackAoeTargets

Returns all attack targets for the given attacker and primary target as a Map of entity to damage multiplier. The primary target always has multiplier 1.0. If the attacker has aoe > 0, each ring up to that radius is checked against BALANCE.DAMAGE.AOE for a falloff multiplier, stops early if the ring index exceeds the AOE array length.

calculateDamage

Calculates damage from attacker to target using the Civ6-style exponential formula. Uses attack vs armor. Result is randomised plus or minus 15% and rounded up.

findMoveToAttackTile

Finds a reachable tile, within the given AP budget, from which the entity has at least one valid attack target in range. Uses BFS so all candidates at the minimum move cost are found before one is picked at random, preventing the bot from always favoring the same neighbor direction. Returns the chosen tile, its movement cost, and the precomputed target tiles from that position, or null if no valid position exists within budget.

#getTargetTilesFrom

Returns all tiles containing valid attack targets for the given entity when standing on fromTile. Valid targets belong to a different player and are not incapacitated. Uses the entity's range ring so range > 1 is handled correctly.




© Gamesanova 2026