View Full Version : Terrain/Feature Impassable Bug?


TC01
Aug 27, 2009, 09:23 PM
I don't know if this is a bug, or if it is intentional, but I ran into it and thought I'd post it here. This only shows up when you mod terrain impassability. (Since the only time vanilla BTS uses this is to make a unit unable to enter oceans, it doesn't appear normally). It happens in BTS 3.19. Anyway, I thought I'd post it here.

When I make a unit unable to pass into a certain terrain, everything works fine. However, I can walk into a feature such as a forest even if that forest is on blocked terrain.

I ran into this bug while modding Fall from Heaven 2 (a unit that was blocked from moving on non-Snow terrain could move into non-Snow tiles with Forests or other features on them.

A quick test in Beyond the Sword unmodded revealed the same was true when I blocked the Lion from moving into Plains, allowing it to walk over forests on plains tiles.

The code in CvUnit::canMoveInto that is responsible is below:

if (pPlot->getFeatureType() != NO_FEATURE)
{
if (m_pUnitInfo->getFeatureImpassable(pPlot->getFeatureType()))
{
TechTypes eTech = (TechTypes)m_pUnitInfo->getFeaturePassableTech(pPlot->getFeatureType());
if (NO_TECH == eTech || !GET_TEAM(getTeam()).isHasTech(eTech))
{
if (DOMAIN_SEA != getDomainType() || pPlot->getTeam() != getTeam()) // sea units can enter impassable in own cultural borders
{
return false;
}
}
}
}
else
{
if (m_pUnitInfo->getTerrainImpassable(pPlot->getTerrainType()))
{
TechTypes eTech = (TechTypes)m_pUnitInfo->getTerrainPassableTech(pPlot->getTerrainType());
if (NO_TECH == eTech || !GET_TEAM(getTeam()).isHasTech(eTech))
{
if (DOMAIN_SEA != getDomainType() || pPlot->getTeam() != getTeam()) // sea units can enter impassable in own cultural borders
{
if (bIgnoreLoad || !canLoad(pPlot))
{
return false;
}
}
}
}
}
}

If there is a feature on the plot, the game doesn't even check if you can pass the terrain. Either someone at Firaxis forgot a line of code or this was done by design.

jdog5000
Aug 28, 2009, 03:37 PM
That is quite bizarre ... certainly fixing this isn't going to affect any BtS units as all of the features are either land based or impassable:

Ice (impassable)
Jungle
Oasis
Floodplains
Forest
Fallout

Why would they have set things up with the feature check first? I can't think of any reason why it would be that way.

MadmanAtW
Aug 28, 2009, 11:13 PM
This is a total stab in the dark, but could it be related to the fact that the feature is the more important aspect of a tile in circumstances where you get a movement bonus due to features? (By my lights, "double movement in woods" would still cause you to only be able to take one step onto a forest/hill, but in the game the double movement in the forests is more important than the extra cost for moving onto a hill.)

TheDS
Oct 17, 2009, 10:24 AM
I consider that an unintended feature, myself. Is a hill easier to climb just because it has trees on it? (Of course, having a 1 MP unit suddenly have 2 MP when it moves into a forest/hill first is just as wonky, so I guess it balances out.)

Afforess
Oct 17, 2009, 09:30 PM
I noticed this bug too, and it caused me to have to do a lot of extra work for my Mountains mod, getting around this. It would be nice to be fixed.

Although to some this may be an unintended feature, I must say, to any modder, this is more of a nightmare...