Question about "iImmigrationWeight" and "iImmigrationWeightDecay"

historix69

Emperor
Joined
Sep 30, 2008
Messages
1,412
Hi,

I found following variables in file "CIV4UnitInfos.xml".

- iImmigrationWeight
- iImmigrationWeightDecay

Does anybody know the meaning of these values?
 
Both are used here. I don't know C++ but to me it seems that iImmigrationWeight is the initial iWeight for the unit and iImmigrationWeightDecay lowers the value for every same type of unit already immigrated
Code:
UnitTypes CvPlayer::pickBestImmigrant()
{
	std::vector<int> aiWeights(GC.getNumUnitInfos(), 0);
	for (int iUnitClass = 0; iUnitClass < GC.getNumUnitClassInfos(); ++iUnitClass)
	{
		UnitTypes eUnit = (UnitTypes) GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(iUnitClass);
		if (NO_UNIT != eUnit)
		{
			int iWeight = GC.getUnitInfo(eUnit).getImmigrationWeight();
			for (int i = 0; i < getUnitClassImmigrated((UnitClassTypes) iUnitClass); ++i)
			{
				iWeight *= std::max(0, 100 - GC.getUnitInfo(eUnit).getImmigrationWeightDecay());
				iWeight /= 100;
			}

			aiWeights[eUnit] += iWeight;
		}
	}

	UnitTypes eBestUnit = (UnitTypes) GC.getGameINLINE().getSorenRand().pickValue(aiWeights, "pick immigrant");
	FAssert(NO_UNIT != eBestUnit);
	if (eBestUnit != NO_UNIT)
	{
		changeUnitClassImmigrated((UnitClassTypes) GC.getUnitInfo(eBestUnit).getUnitClassType(), 1);
	}

	return eBestUnit;
}
 
Not quite sure on the exact mechanics but it seems to use the two numbers in concert to affect when (and how long) a particular unit will appear on the selection area. Scouts, which have a high initial and a high decay will appear early and will be rare later in the game. Similar, but lesser degree, for preachers - which are less useful as cross requirements increase. The non-professions and core professions seem to be setup to remain constant throughout the game and they remain useful throughout.

We would need to see the changeUnitClassImmigrated(UnitClassTypes, Integer(+1)) to see what influence having an immigrant of a specific types has on getting a second one of the same type to immigrate.
 
Back
Top Bottom