1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

How to add a new terrain "channel"?

Discussion in 'Civ4 - Creation & Customization' started by only sky, Jan 8, 2014.

  1. only sky

    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!
     
  2. Rob (R8XFT)

    Rob (R8XFT) Ancient Briton Super Moderator

    Joined:
    Aug 11, 2002
    Messages:
    10,783
    Location:
    Leeds (UK)
  3. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    4,114
    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.
     
  4. lfgr

    lfgr Chieftain

    Joined:
    Feb 6, 2010
    Messages:
    673
    Nightinggale: Did you confuse getDefineINT() with getInfoTypeForString()? You version would require additional XML work.

    I also think that this could cause trouble with the AI.
     
  5. Nightinggale

    Nightinggale Chieftain Supporter

    Joined:
    Feb 2, 2009
    Messages:
    4,114
    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 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.
     

Share This Page