feat(combat): grant soft cover (+4 AC) to ranged attacks through creatures

This commit is contained in:
2026-08-17 22:49:50 +02:00
parent f67cd017e4
commit bb53d049ee
5 changed files with 129 additions and 19 deletions
+14 -4
View File
@@ -15,11 +15,12 @@ Phase 0 documented deviations from PF1e (conventions):
- Line of effect gates all attacks: a target fully behind blocking terrain
cannot be attacked, and the policy moves to gain sight instead.
- Cover (corner rule) grants +4 AC on hit and crit-confirm rolls; melee and
ranged reuse the same corner rule.
ranged reuse the same corner rule. Soft cover: active creatures between
attacker and target also grant +4 AC on ranged attacks (CRB soft cover);
melee attacks ignore creatures.
- Ranged: cumulative -2 per full range increment beyond the first, up to 10
range increments; the penalty applies to attack and crit-confirm rolls.
Thrown weapons (5 increments max) are not distinguished; soft cover from
creatures is not modeled.
Thrown weapons (5 increments max) are not distinguished.
"""
from __future__ import annotations
@@ -221,7 +222,16 @@ class CombatEngine:
penalty = self.range_penalty(weapon, dist_ft)
total = roll + weapon.attack_bonus + penalty
ac = target.combatant.ac.total
if has_cover(self._grid, attacker.pos, target.pos, ranged=weapon.kind == "ranged"):
occupied = frozenset(
s.pos for s in self._states if s.active and s is not attacker and s is not target
)
if has_cover(
self._grid,
attacker.pos,
target.pos,
ranged=weapon.kind == "ranged",
occupied=occupied,
):
ac += _COVER_AC_BONUS
hit = roll == _NATURAL_TWENTY or (roll != _NATURAL_ONE and total >= ac)
crit = False