How to add a new terrain "channel"?

only sky

Chieftain
Joined
Jan 18, 2013
Messages
65
Location
China
Excuse me, I really hope to add a new terrain to the game called "channel".
that allow land unit and ships to cross, like the English channel between England and France.
but I don't know how, Do you know how to add ?Thanks!

(If adding channel is not possibe, how to edit the terrain "coast" to allow it passible ? Thanks!
 
Nobody answered yet? I wonder why because it shouldn't be that tricky.

From what I can tell you need to edit the DLL to do that. Specifically the function CvUnit::canMoveInto().
This function tells if a unit can move into a specific plot. Make the plot part of DOMAIN_LAND (just like all other land terrain).
In the code there is
Code:
switch (getDomainType())
{
case DOMAIN_SEA:
	if (!pPlot->isWater() && !canMoveAllTerrain() [COLOR="Red"]&& pPlot->getTerrainType() != GC.getDefineINT("TERRAIN_CHANNEL")[/COLOR])
Adding the red text should do the trick. However I would recommend caching the result of getDefineINT() as it is rather slow and this function is called often. You will likely feel the game slowing down if you call it every time the function is called.

Also a disclaimer: I didn't test it, but I see no reason why it shouldn't work.
 
Nightinggale: Did you confuse getDefineINT() with getInfoTypeForString()? You version would require additional XML work.
TerrainInfos are read in CvXMLLoadUtility::LoadPreMenuGlobals(). It is my experience that getDefineINT() works with those read in that function, but you are right that it doesn't work with all XML files. It should be interchangeable with getInfoTypeForString() in this case.
I grew tired of inconsistent behavior and rewrote the XML reading in M:C. Now getDefineINT works on all values and load order of XML files no longer matters. The same goes for order within the files. I wish the XML loading was better documented because it doesn't work like you would expect from the first glance at the code.

I also think that this could cause trouble with the AI.
I don't think so. The AI uses CvUnit::canMoveInto() to figure out valid moves and plan accordingly. That is the main reason why the function is called often and matters for performance.
However problems with the AI is something, which would need testing, regardless of solution for this problem.

Now that I think about it, CvPlot::movementCost() should likely be updated as well. Otherwise ships will gain road bonus.
 
Top Bottom