movesleft()

vincentz

Programmer
Joined
Feb 4, 2009
Messages
3,614
Location
Denmark
Im trying to get the movesLeft() for the attacking unit (this) in void CvUnit::resolveCombat(CvUnit* pDefender, CvPlot* pPlot, CvBattleDefinition& kBattle), but getting a strangely large negative number.
The same happens when I try to get maxMoves - getMoves()

If I just want the baseMoves() it works fine.

What am I missing?

upload_2018-12-27_13-7-28.png
 
Nevermind, Just me being stupid. It actually gives me the right number (240, the breakpoint is obviously too early).
The number is however before MOVE_DENOMINATOR so need to divide it first :)
int AttackerMoves = movesLeft()/GC.getDefineINT("MOVE_DENOMINATOR");
 
MOVE_DENOMINATOR is used because ints can't have fractions. The idea is that each movement point is MOVE_DENOMINATOR (default 60). Moving on plots with one user movement point cost then cost 60. Routes (like roads) can then cost fractions of 60, like 10, 15, 20, 30 etc, hence setting how many plots each user movement point can take the unit.

The design is actually a decent solution considering ints are preferred in order to avoid network desyncs due to float rounding. The problem is the documentation, or rather the no documentation at all.
 
Top Bottom