Bazaar developer reference

CvPlayerTechs::AddFlavorAsStrategies(int)

Defined in
CvTechClasses.cpp, line 1607
Class
CvPlayerTechs
Hook name
CivHooks::CvPlayerTechs_AddFlavorAsStrategies

Hooks

static bool BeforeCvPlayerTechs_AddFlavorAsStrategies(CvPlayerTechs* self, int iPropagatePercent);static void AfterCvPlayerTechs_AddFlavorAsStrategies(CvPlayerTechs* self, int iPropagatePercent);static void ReplaceCvPlayerTechs_AddFlavorAsStrategies(void (*original)(CvPlayerTechs*, int), CvPlayerTechs* self, int iPropagatePercent);CivRegisterBefore<CivHooks::CvPlayerTechs_AddFlavorAsStrategies>(host, &BeforeCvPlayerTechs_AddFlavorAsStrategies);CivRegisterAfter<CivHooks::CvPlayerTechs_AddFlavorAsStrategies>(host, &AfterCvPlayerTechs_AddFlavorAsStrategies);CivRegisterReplace<CivHooks::CvPlayerTechs_AddFlavorAsStrategies>(host, &ReplaceCvPlayerTechs_AddFlavorAsStrategies);

Code

1606// Internal method to add all of this leaderheads' flavors as strategies for tech AI1607void CvPlayerTechs::AddFlavorAsStrategies(int iPropagatePercent)1608{1609	// Start by resetting the AI1610	m_pTechAI->Reset();16111612	int iBiggestFlavor = -1000;1613	for(int iFlavor = 0; iFlavor < GC.getNumFlavorTypes(); iFlavor++)1614	{1615		int iFlavorValue = GetLatestFlavorValue((FlavorTypes) iFlavor);1616		if(iFlavorValue > iBiggestFlavor)1617		{1618			iBiggestFlavor = iFlavorValue;1619		}1620	}16211622	// Now populate the AI with the current flavor information1623#if defined(MOD_AI_SMART_V3)1624	int iDifficultyBonus = (200 - ((GC.getGame().getHandicapInfo().getAIGrowthPercent() + GC.getGame().getHandicapInfo().getAITrainPercent()) / 2));1625	int estimatedTurnsWithDiff = MOD_AI_SMART_V3 ? (GC.getGame().getDefaultEstimateEndTurn() * 90) / iDifficultyBonus : GC.getGame().getDefaultEstimateEndTurn();1626	int iGameProgressFactor = (GC.getGame().getElapsedGameTurns() * 1000) / estimatedTurnsWithDiff;1627#else1628	int iGameProgressFactor = (GC.getGame().getElapsedGameTurns() * 1000) / GC.getGame().getDefaultEstimateEndTurn();1629#endif1630	iGameProgressFactor = min(900,max(100,iGameProgressFactor));1631	for(int iFlavor = 0; iFlavor < GC.getNumFlavorTypes(); iFlavor++)1632	{1633		int iCurrentFlavorValue = GetLatestFlavorValue((FlavorTypes) iFlavor);16341635		// Scale the current to the same scale as the personality1636		iCurrentFlavorValue = (iCurrentFlavorValue * 10) / iBiggestFlavor;16371638#if defined(MOD_AI_SMART_V3)1639		int iPersonalityFlavorValue = m_pPlayer->GetGrandStrategyAI()->GetPersonalityAndGrandStrategy((FlavorTypes) iFlavor, MOD_AI_SMART_V3 /*bBoostGSMainFlavor*/);1640#else1641		int iPersonalityFlavorValue = m_pPlayer->GetGrandStrategyAI()->GetPersonalityAndGrandStrategy((FlavorTypes) iFlavor);1642#endif16431644		// this should give a more even blend between the personality and long term strategy and the more fickle current needs1645		// in the beginning of the game it will be responsive to current events, but later it should try to go for the goal more strongly1646		int iFlavorValue = ((iCurrentFlavorValue * (1000 - iGameProgressFactor)) + (iPersonalityFlavorValue * iGameProgressFactor)) / 1000;16471648#if defined(MOD_AI_SMART_V3)1649		// Try always give a significant flavor, as is easily zeroed with previous computations...1650		if (MOD_AI_SMART_V3 && iFlavorValue < 10)1651		{1652			int flavorDivisor = (iGameProgressFactor > 500) ? 8 : 4;1653			int boostValue = (10 - iFlavorValue) / flavorDivisor;1654			iFlavorValue += boostValue;1655		}1656#endif16571658		if(iFlavorValue > 0)1659		{1660			m_pTechAI->AddFlavorWeights((FlavorTypes)iFlavor, iFlavorValue, iPropagatePercent);1661		}1662	}1663}

Calls

Called by