Swapping the effects of Food and Health

Joined
Jul 21, 2003
Messages
7,819
Location
Adelaide, South Australia
Hi to all you skilled with SDK. I really want to change the way in which population growth is determined. Essentially, HEALTH will be what determines if a city grows, shrinks or remains stagnant-and food surpluses or deficits modify health for the purpose of population growth.

Now, I have the following sections of the SDK for City Growth:

Code:
int CvCity::getFoodTurnsLeft()
{
	int iFoodLeft;
	int iTurnsLeft;

	iFoodLeft = (growthThreshold() - getFood());

	if (foodDifference() <= 0)
	{
		return iFoodLeft;
	}

	iTurnsLeft = (iFoodLeft / foodDifference());

	if ((iTurnsLeft * foodDifference()) <  iFoodLeft)
	{
		iTurnsLeft++;
	}

	return max(1, iTurnsLeft);
}


bool CvCity::isProduction()
{
	return (headOrderQueueNode() != NULL);
}

and this section on health

Code:
int CvCity::getBonusHealth(BonusTypes eBonus)
{
	int iHealth;
	int iI;

	iHealth = GC.getBonusInfo(eBonus).getHealth();

	for (iI = 0; iI < GC.getNumBuildingInfos(); iI++)
	{
		if (hasActiveBuilding((BuildingTypes)iI))
		{
			iHealth += GC.getBuildingInfo((BuildingTypes) iI).getBonusHealthChanges(eBonus);
		}
	}

	return iHealth;
}

Can anyone point me in the right direction as to how I can modify this?
Thanks in advance.

Aussie_Lurker.
 
Hi, just a short comment:

I never had a look into the Civ 4 code, but the second part rather looks like a funcition that merely determines how many health a city actually gets out of a certain bonus resource by taking into account the buildings the city has (+1 for granary or the like).

The first function seems to compute the number of turns left until the city grows, but does nothing else. It simply takes the ammount of food surplus per turn (as given by foodDifference()) and compares it with the food already stored and the growth threshold. In particularl no health seems to appear hear.

you should have a look at the foodDifference() function, where the food surplus probably computed taking worked terrain and health into account...
 
What I am after is a direct swap of health and food.

So, if you have a health 'deficit', then your population will shrink. If you have a Health 'Surplus' then your population will grow. Any food surpluses will actually add-directly or indirectly-into the amount of Health your city has, wheras food deficits will add to unhealthiness.

Hope that makes more sense.

Aussie_Lurker.
 
But in the game health is already an indirect food adjustment variable (or whatever it is called).

But what you mean is ->
If a city has more health than unhealth(iness) then it will automaticly increase or it will be a slow progress like food is now (like adding health to the city's health storage, hope you understand me?)
 
I guess that this is what I am trying to say-not a health 'pool' though, like they have with food, but yes-the more health is greater than unHealth, then the faster the city grows. I think we can all accept that food-particularly in the modern age-is NOT the key contributor to if a city (or nation's) population grows or shrinks.

Aussie_Lurker.
 
Back
Top Bottom