fast movement on normal terrain?

davidlallen

Deity
Joined
Apr 28, 2008
Messages
4,743
Location
California
I want to have a unit which moves fast on certain normal terrains. The trick is that these terrains only cost one movement point to move into. I can define a promotion which gives double move on these terrains, except it has no effect. It seems that a double move promotion will decrease the move cost from 2 to 1, but not from 1 to 0.5. This is surprising, but you can easily try it by adding TerrainDoubleMoves for grass onto any promotion. It doesn't make any difference. And there is no way to trick it by giving the unit a high move, and a "half move speed" on the other terrain.

This is for Dune Wars. Both deep desert and land have a movement cost of 1. But I want Fremen desert raider units to move 2 on desert and 1 on land. Is there any way to accomplish this?
 
At the end of planetfall CvPlot::movementCost, there is a line:

return max (1, some_other_value)

It is an int function, and the max() call means it can never return less than one. So I do not see how this would enable a unit with one movement point to move two squares.

However, I must be missing something somewhere, because as The_J points out, a vanilla warrior with one movement point and the Guerilla II promotion can move two plots as long as the first one is a hill.

Can anybody help me to understand how the promotion xml tag bHillsDoubleMove lets a warrior move two plots?

There may be some other hooks, but I cannot see how they work either. There is a function for extra moves on sea terrain, which your team gets when your unit is first to circumnavigate the globe. I don't think this can be applied to only certain units of the team, however. And since Dune Wars does not use roads, maybe we could use the road movement hooks somehow. If the ocean had invisible roads, and only these certain units could benefit from road movement, we might get the effect.
 
Note that moves are not 1-based. A unit with 1 MP has baseMoves() = 12 IIRC. This is how fractional moves are handled. Note this code from CvPlot::movementCost():

Code:
iRegularCost *= GC.getMOVE_DENOMINATOR();

if (bHasTerrainCost)
{
	if (((getFeatureType() == NO_FEATURE) ? pUnit->isTerrainDoubleMove(getTerrainType()) : pUnit->isFeatureDoubleMove(getFeatureType())) ||
		(isHills() && pUnit->isHillsDoubleMove()))
	{
		iRegularCost /= 2;
	}
}

First it takes the regular cost (1 or 2 typically) and multiplies by MOVE_DENOMINATOR (12). Then it handles the feature/terrain double movement.

Are you sure you specifying the terrain type correctly? Perhaps add some logging code in here to detect that it's seeing the terrain type correctly.
 
(EDIT: previous version of this post is incorrect)

Without modifying the sdk, we cannot get a unit with one movement point to move two plots on clear terrain with a double move promotion. I had done an original experiment which showed this. Earlier today I did another experiment which I interpreted incorrectly; when I do the experiment correctly it confirms my original result. In CvPlot::movementCost() the line which divides the movement cost in half is protected by "if (bHasTerrainCost)". This means, if the plot has no special movement cost, then the double speed modification is not applied.

However, Maniac's original post is the correct solution. He has modified this function by removing the "if (bHasTerrainCost)". So in Planetfall, this works; but in vanilla, it does not.

I will use Maniac's modification to solve my problem. Thanks!
 
Back
Top Bottom