Upgrading a spearman to a pikeman should keep the progress, though ranks cost differently
When a unit changes into a better kind, its experience points mean something else, because the new kind has a different scale. Copying the number gives a free rank or sends the unit back to start. This entry shows how to keep the rank and the share of progress inside it, and what to do when the new kind has fewer or more ranks.
Why this works
A point of experience means different things on different scales, like a mark of 3 out of 5 and 6 out of 10. What carries over is the rank earned and how far along it the unit is, so convert the share, not the raw number.
When not to use it
Skip it when upgrading is meant to be a fresh start, for example a trade-off where the new unit begins as a recruit and must prove itself again. Then reset on purpose and tell the player, rather than faking a carry-over.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- 15 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Upgrading a spearman to a pikeman should keep the progress, though ranks cost differently" (read_entry unit-upgrade-keeps-the-progress-between-different-rank-tables) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP