View Full Version : How to make mountains passable? (Vanilla 1.61)


Caesium
Aug 12, 2006, 11:45 AM
Hi!

Another interesting question:

How to make mountains passable during the game?

I gave my workers the ability to walk over mountains and to build roads on mountains. But the roads weren't passable, because mountains aren't passable.
So I tried following code, that worked in 1.51:


pPlot.setPlotType(PlotTypes.PLOT_HILLS, true, true)
iPEAKID = gc.getInfoTypeForString("TERRAIN_PEAK")
pPlot.setTerrainType(iPEAKID, true, true)
pPlot.setFeatureType(-1,0)

But the mountains changed to a lake.

Is there anybody who solved a similar problem?

Caesium
Aug 13, 2006, 02:05 PM
Nobody out there, who's got an idea?

Chinese American
Aug 13, 2006, 05:57 PM
try to set terrain type to hills instead

Caesium
Aug 13, 2006, 06:51 PM
Then this wouldn't be mountains anymore...

Gerikes
Aug 13, 2006, 08:48 PM
Let me just get this straight: you're trying to make it so that worker units can freely move into peaks so that they can build roads, and that all other units can only go into those plots with peaks if a worker has first built a road there?

Caesium
Aug 13, 2006, 09:34 PM
Exactly as you described it, Gerikes.
And, if someone pillages the road, the mountain is only passable for workers then.

Gerikes
Aug 13, 2006, 09:39 PM
Exactly as you described it, Gerikes.
And, if someone pillages the road, the mountain is only passable for workers then.

Probably should take a look at CvUnit::canMoveInto


bool CvUnit::canMoveInto(const CvPlot* pPlot, bool bAttack, bool bDeclareWar, bool bIgnoreLoad) const
{
TeamTypes ePlotTeam;

FAssertMsg(pPlot != NULL, "Plot is not assigned a valid value");

if (atPlot(pPlot))
{
return false;
}

if (pPlot->isImpassable())
{
if (!canMoveImpassable())
{
return false;
}
}


So, your first step is probably to make worker units as canMoveImpassable units by changing their XML. Then, make sure that, through XML, roads can be built into terrains with peaks in them (I'm not sure if this is available by default or not).

Finally, you'll probably have to change the emboldened section so that instead of just checking for if the plot is impassable, check that it's impassable and also that it doesn't have a route (road, railroad) on it.