Route PlotPath's AP estimate through the authoritative ActionPointCost - #688
Merged
Conversation
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
force-pushed
the
fix_ap_discrepancy
branch
from
August 21, 2026 19:14
801ffb5 to
43b8da4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.