feat(combat): support partial and improved cover levels

This commit is contained in:
2026-09-10 11:32:08 +02:00
parent 2eed752f7f
commit e6125b04f6
6 changed files with 401 additions and 23 deletions
+4 -5
View File
@@ -115,7 +115,7 @@ if TYPE_CHECKING:
TrickCondition = Literal["dazzled", "blinded", "deafened", "entangled", "nauseated"]
from pf1e_simulator.los import (
has_cover_cells,
cover_bonus_cells,
has_line_of_effect_cells,
)
@@ -123,7 +123,6 @@ _SQUARE_FT = 5 # Phase 0 maps use 5-ft squares
_DEATH_FLOOR = -10 # PF1e: dead when hp < -10 or -CON, whichever is lower
_NATURAL_ONE = 1 # PF1e: natural 1 always misses
_NATURAL_TWENTY = 20 # PF1e: natural 20 always hits and threatens
_COVER_AC_BONUS = 4 # PF1e: partial cover grants +4 AC
_RANGE_INCREMENT_PENALTY = 2 # PF1e: -2 per full range increment beyond the first
_MAX_RANGE_INCREMENTS = 10 # PF1e: projectile weapons shoot up to 10 increments
_MAX_TOUCH_RANGE_INCREMENTS = 5 # PF1e: thrown/firearm touch weapons shoot up to 5 increments
@@ -720,6 +719,7 @@ class CombatEngine:
"move_cost": cell.move_cost,
"blocks_los": cell.blocks_los,
"cover": cell.cover,
"cover_bonus": cell.cover_bonus,
}
for cell in (seen[name] for name in sorted(seen))
)
@@ -1418,14 +1418,13 @@ class CombatEngine:
if s.active and s is not attacker and s is not target
for cell in s.occupied_cells()
)
if has_cover_cells(
ac += cover_bonus_cells(
self._grid,
attacker.occupied_cells(),
target.occupied_cells(),
ranged=self._is_ranged_attack(weapon),
occupied=occupied,
):
ac += _COVER_AC_BONUS
)
hit = roll == _NATURAL_TWENTY or (roll != _NATURAL_ONE and total >= ac)
damage = 0
concealment_miss = False