Question: Feature Limited Building Construction.

Joined
Jul 21, 2003
Messages
7,819
Location
Adelaide, South Australia
Hi guys. I'm trying to design a modification that makes Buildings dependent on certain terrain within a City-Radius (like Mountains, Forests & Jungle)-using similar code that used to restrict the building of Harbors or Levees. So, modifying CvInfos went fine, but when I tried to change the code in CvCity, it went totally pear-shaped.

Here is the code from CvCity that controls the construction of Feature dependent buildings:

Code:
if (GC.getBuildingInfo(eBuilding).isWater())
	{
		if (!GC.getBuildingInfo(eBuilding).isRiver() || !plot()->isRiver())
		{
			if (!isCoastal(GC.getBuildingInfo(eBuilding).getMinAreaSize()))
			{
				return false;
			}
		}
	}
	else
	{
		if (area()->getNumTiles() < GC.getBuildingInfo(eBuilding).getMinAreaSize())
		{
			return false;
		}

		if (GC.getBuildingInfo(eBuilding).isRiver())
		{
			if (!(plot()->isRiver()))
			{
				return false;
			}
		}
	}

	return true;
}

So the problem with my changes is that Mountains, Forests & Jungle aren't defined in CvPlot. Yet I couldn't find how to add these features into CvPlot.

So my question is: how can I add isMountain, isJungle & isForests to CvPlots?

Thanks in advance guys :).

Aussie.
 
For mountains (and hills) you have the getPlotType() which returns one of:

Code:
enum PlotTypes                            // Exposed to Python
{
    NO_PLOT = -1,

    PLOT_PEAK,
    PLOT_HILLS,
    PLOT_LAND,
    PLOT_OCEAN,

#ifdef _USRDLL
    NUM_PLOT_TYPES
#endif
};

For forests and jungles you probably need to add new tags in CIV4FeatureInfos.xml (bIsForest, bIsJungle).

But I think there's a better solution:
Add an optional tag to the buildings: RequiredTerrainFeatureInCity (or something), which points to a feature in the features XML file.

Then you need to add code to check if the given terrain feature exists in the city area, but you don't need to check each of the features (mountains, forests) separately in the code.
 
These tags are in AND, I can show you the code if you are interested.
 
Back
Top Bottom