Skip to content

Route PlotPath's AP estimate through the authoritative ActionPointCost - #688

Merged
majcosta merged 5 commits into
1dot13:masterfrom
majcosta:fix_ap_discrepancy
Aug 21, 2026
Merged

Route PlotPath's AP estimate through the authoritative ActionPointCost#688
majcosta merged 5 commits into
1dot13:masterfrom
majcosta:fix_ap_discrepancy

Conversation

@majcosta

@majcosta majcosta commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

PlotPath carried its own hand-rolled copy of the per-tile AP math, which could and DID drift from what movement actually spends, e.g. a path predicted to cost 80 AP actually cost 81 AP, to much annoyance and sitting right next to a guy with 1 health and a loaded automatic weapon.

this adds a couple convenience overloads to ActionPointCost and EstimateActionPoint cost and uses ActionPointCost for both estimating the cost and drawing the footstep-colors.

Checked in-game, seemed fine. Even if there's a mistake here, at least it's 1 place to fix instead of 3.

majcosta and others added 5 commits August 21, 2026 16:14
Add an ActionPointCost overload taking the previous tile's movement mode
explicitly, used to charge the one-time start-run penalty. The existing
4-arg overload forwards the soldier's live anim state, so real per-step
movement and every other caller are unchanged. This lets a path-cost
estimator - which does not move the soldier - supply its simulated prior
mode instead of reading a frozen live anim state, so the estimate and the
real deduction can share one cost function.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Forwards to the new ActionPointCost prev-mode overload so a path estimator
can pass its simulated prior tile mode. Existing 6-arg callers use the
soldier's live anim state and are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PlotPath carried its own inline copy of the per-tile movement-cost math,
which had drifted from ActionPointCost (the function the real per-step
movement and the AI path estimate both already use). That divergence is
what made the movement cursor mis-predict the real AP spend - e.g. the
start-run penalty getting the diagonal x1.4 in the real cost but not the
cursor.

Replace the inline switch (and its fence/start-run special-cases) with a
per-tile EstimateActionPointCost call, threading the simulated previous
tile mode so the one-time start-run charge lands exactly once. The cursor
estimate now equals what movement deducts, by construction.

Behavioural: player movement-cursor AP numbers (and path reachability
colouring that keys off the same total) now match the real spend. Real
per-step deduction and AI estimates are unchanged - they already used
ActionPointCost. The footstep-colour budget still has its own cost copy;
left for a follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The footstep-colour budget kept its own inline per-mode copy of the
movement-cost modifiers (walk/crawl/swat/run), the last duplicate of the
cost math left in PlotPath. Replace it with one EstimateActionPointCost
call per stance, so the reachability colours use the same per-tile cost
as the real spend, and drop the now-orphaned per-tile TerrainActionPoints
recompute and its dead locals (sTileCost, sMovementAPsCost,
sExtraCostStand).

Cosmetic-only: footprint colours now include the diagonal x1.4 the old
budget omitted, so they track the real reachable distance more closely.
The water->walk terrain override stays; it keeps the start-run charge
correct when a run path crosses water.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
EstimateActionPointCost adds the post-fence start-run flat at the
fence tile; real spend adds it on the next tile, with the diagonal
x1.4 - cursor read 1 AP low. Sum ActionPointCost direct instead, and
mark the fence landing non-running so the next tile re-charges
start-run itself: right tile, right multiplier.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@majcosta
majcosta force-pushed the fix_ap_discrepancy branch from 801ffb5 to 43b8da4 Compare August 21, 2026 19:14
@majcosta
majcosta merged commit 6270ca8 into 1dot13:master Aug 21, 2026
6 checks passed
@majcosta
majcosta deleted the fix_ap_discrepancy branch August 21, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant