View Full Version : Python/SDK(?) for feature growth


Civ Fuehrer
Sep 26, 2009, 08:32 PM
Touching back with an old project of mine(bio nukes) i realized the gas clouds never moved. The XML tag <iGrowth> seemed to never work. I searched the forums for a number ratio on what it did etc. Finding the overall number should be 12.5% chance if i put in say 1,000. I tested it, using random units on hills / peaks as sentries to see if it grew. Nothing happened, I went well over 100 turns and it didn't grow. I set the number to 1,000,000,000 and still nothing happened, waiting another 100 turns to test it. If I could get some help, (either SDK or Python would be great) to get my feature working properly I would appreciate it greatly.

The_J
Sep 26, 2009, 08:43 PM
I guess, you've moved the value in the false direction.
The normal forest has an iGrowth value from 8, and he sometimes appears.

Civ Fuehrer
Sep 27, 2009, 12:10 AM
well this is where i found the info on how iGrowth works http://forums.civfanatics.com/showthread.php?t=253626&highlight=iGrowth I also put iGrowth to 8, 2, 1 etc. nothing happened. What I'm hoping to do is either make some SDK changes to make iGrowth more responsive to other feature types (i also read that iGrowth applies only to forest and jungles) OR make yet another python code block to make my clouds 'move' by growing (iDisappearance works fine). The iAppearance tag just spawns the feature anywhere on the map at a percentage which is not the effect I'm shooting for.

The_J
Sep 27, 2009, 04:34 PM
:think: that seems to be very low.
But just placing a feature somewhere, when one of the adjacent plots have it, shouldn't be a big problem.

Civ Fuehrer
Sep 27, 2009, 05:33 PM
I'm frustrated as hell why the clouds won't move... I've tried every variable that could play an important role in that tag... but i get no feedback. The cache isn't the problem either, since I clear it before nearly every debugging session.:mad:
Easiest solution i can think of is dipping into either the SDK to change a few things on iGrowth activity or do a python code block, which I would need help with both.

Afforess
Sep 27, 2009, 05:54 PM
Just popping in here, but here's the formula in the SDK for feature growth



void CvPlot::doFeature()
{
PROFILE("CvPlot::doFeature()")

CvCity* pCity;
CvPlot* pLoopPlot;
CvWString szBuffer;
int iProbability;
int iI, iJ;

/************************************************** ***********************************************/
/** DCM 04/19/09 Johny Smith */
/************************************************** ***********************************************/
// Dale - BE: Battle Effect START
if (GC.getDCM_BATTLE_EFFECTS())
{
if (getFeatureType() >= (GC.getNUM_GAME_FEATURES() - 1))
{
if(m_iBattleCountdown > 0)
{
changeBattleCountdown(-1);
}
if(m_iBattleCountdown == 0)
{
setBattleFeature(false);
}
}
}
// Dale - BE: Battle Effect END
/************************************************** ***********************************************/
/** DCM END */
/************************************************** ***********************************************/
if (getFeatureType() != NO_FEATURE)
{
iProbability = GC.getFeatureInfo(getFeatureType()).getDisappearan ceProbability();

if (iProbability > 0)
{
if (GC.getGameINLINE().getSorenRandNum(10000, "Feature Disappearance") < iProbability)
{
setFeatureType(NO_FEATURE);
}
}
}
else
{
if (!isUnit())
{
if (getImprovementType() == NO_IMPROVEMENT)
{
for (iI = 0; iI < GC.getNumFeatureInfos(); ++iI)
{
if (canHaveFeature((FeatureTypes)iI))
{
if ((getBonusType() == NO_BONUS) || (GC.getBonusInfo(getBonusType()).isFeature(iI)))
{
iProbability = 0;

for (iJ = 0; iJ < NUM_CARDINALDIRECTION_TYPES; iJ++)
{
pLoopPlot = plotCardinalDirection(getX_INLINE(), getY_INLINE(), ((CardinalDirectionTypes)iJ));

if (pLoopPlot != NULL)
{
if (pLoopPlot->getFeatureType() == ((FeatureTypes)iI))
{
if (pLoopPlot->getImprovementType() == NO_IMPROVEMENT)
{
iProbability += GC.getFeatureInfo((FeatureTypes)iI).getGrowthProba bility();
}
else
{
iProbability += GC.getImprovementInfo(pLoopPlot->getImprovementType()).getFeatureGrowthProbability( );
}
}
}
}

iProbability *= std::max(0, (GC.getFEATURE_GROWTH_MODIFIER() + 100));
iProbability /= 100;

if (isRoute())
{
iProbability *= std::max(0, (GC.getROUTE_FEATURE_GROWTH_MODIFIER() + 100));
iProbability /= 100;
}

if (iProbability > 0)
{
if (GC.getGameINLINE().getSorenRandNum(10000, "Feature Growth") < iProbability)
{
setFeatureType((FeatureTypes)iI);

pCity = GC.getMapINLINE().findCity(getX_INLINE(), getY_INLINE(), getOwnerINLINE(), NO_TEAM, false);

if (pCity != NULL)
{
// Tell the owner of this city.
szBuffer = gDLL->getText("TXT_KEY_MISC_FEATURE_GROWN_NEAR_CITY", GC.getFeatureInfo((FeatureTypes) iI).getTextKeyWide(), pCity->getNameKey());
gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_FEATUREGROWTH", MESSAGE_TYPE_INFO, GC.getFeatureInfo((FeatureTypes) iI).getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_WHITE"), getX_INLINE(), getY_INLINE(), true, true);
}

break;
}
}
}
}
}
}
}
}
}



It looks like to me that 10000 should guarantee that the feature grows. Of course, there can't be improvements in the way.

Civ Fuehrer
Sep 28, 2009, 03:57 AM
Ehh thanks Aff for the SDK, I've been looking for that, but the point on a cloud is to conusme anything... The dustbowl effect that ran through the U.S. during the great depression didn't care if there was a farm in the way.:sad:

Civ Fuehrer
Sep 28, 2009, 11:16 PM
So which source file is that? I think i found a way to make a special exception for my toxic clouds.

Afforess
Sep 29, 2009, 06:27 AM
So which source file is that? I think i found a way to make a special exception for my toxic clouds.
CvPlot.cpp. It has the name of the source file in the name of the function.

Civ Fuehrer
Sep 29, 2009, 03:25 PM
:cool: