CvPlayerPolicies::AddFlavorAsStrategies(int)
- Defined in
- CvPolicyClasses.cpp, line 4743
- Class
- CvPlayerPolicies
- Hook name
CivHooks::CvPlayerPolicies_AddFlavorAsStrategies
Hooks
static bool BeforeCvPlayerPolicies_AddFlavorAsStrategies(CvPlayerPolicies* self, int iPropagatePercent);static void AfterCvPlayerPolicies_AddFlavorAsStrategies(CvPlayerPolicies* self, int iPropagatePercent);static void ReplaceCvPlayerPolicies_AddFlavorAsStrategies(void (*original)(CvPlayerPolicies*, int), CvPlayerPolicies* self, int iPropagatePercent);CivRegisterBefore<CivHooks::CvPlayerPolicies_AddFlavorAsStrategies>(host, &BeforeCvPlayerPolicies_AddFlavorAsStrategies);CivRegisterAfter<CivHooks::CvPlayerPolicies_AddFlavorAsStrategies>(host, &AfterCvPlayerPolicies_AddFlavorAsStrategies);CivRegisterReplace<CivHooks::CvPlayerPolicies_AddFlavorAsStrategies>(host, &ReplaceCvPlayerPolicies_AddFlavorAsStrategies);
Code
4742// Internal method to add all of this leaderheads' flavors as strategies for policy AI4743void CvPlayerPolicies::AddFlavorAsStrategies(int iPropagatePercent)4744{4745 int iFlavorValue;47464747 // Start by resetting the AI4748 m_pPolicyAI->Reset();47494750 // Now populate the AI with the current flavor information4751 for(int iFlavor = 0; iFlavor < GC.getNumFlavorTypes(); iFlavor++)4752 {4753// OLD WAY: use CURRENT player flavors4754// iFlavorValue = GetLatestFlavorValue((FlavorTypes) iFlavor);47554756// NEW WAY: use PERSONALITY flavors (since policy choices are LONG-TERM)4757// EVEN NEWER WAY: add in a modifier for the Grand Strategy we are running (since these are also long term)4758#if defined(MOD_AI_SMART_V3)4759 // Before medieval era, the AI still doesn't know if the Grand Strategy is solid.4760 EraTypes eMedieval = (EraTypes) GC.getInfoTypeForString("ERA_MEDIEVAL", true);4761 if (MOD_AI_SMART_V3 && m_pPlayer->GetCurrentEra() < eMedieval)4762 {4763 iFlavorValue = m_pPlayer->GetFlavorManager()->GetPersonalityIndividualFlavor((FlavorTypes) iFlavor);4764 }4765 else4766#endif4767 iFlavorValue = m_pPlayer->GetGrandStrategyAI()->GetPersonalityAndGrandStrategy((FlavorTypes) iFlavor);47684769// Boost flavor even further based on in-game conditions4770 47714772 EconomicAIStrategyTypes eStrategyLosingMoney = (EconomicAIStrategyTypes) GC.getInfoTypeForString("ECONOMICAISTRATEGY_LOSING_MONEY", true);4773 if (eStrategyLosingMoney == NO_ECONOMICAISTRATEGY)4774 {4775 continue;4776 }4777 CvTeam& kTeam = GET_TEAM(m_pPlayer->getTeam());4778 bool bIsAtWarWithSomeone = (kTeam.getAtWarCount(false) > 0);4779 bool bInDeficit = m_pPlayer->GetEconomicAI()->IsUsingStrategy(eStrategyLosingMoney);47804781 if(bInDeficit && iFlavor == GC.getInfoTypeForString("FLAVOR_GOLD"))4782 {4783 iFlavorValue += 5;4784 }4785 else if(m_pPlayer->GetHappiness() < m_pPlayer->GetUnhappiness() && iFlavor == GC.getInfoTypeForString("FLAVOR_HAPPINESS"))4786 {4787 iFlavorValue += 5;4788 }4789 else if(bIsAtWarWithSomeone && iFlavor == GC.getInfoTypeForString("FLAVOR_DEFENSE"))4790 {4791 iFlavorValue += 3;4792 }4793 else if(bIsAtWarWithSomeone && iFlavor == GC.getInfoTypeForString("FLAVOR_CITY_DEFENSE"))4794 {4795 iFlavorValue += 3;4796 }47974798 if(iFlavorValue > 0)4799 {4800 m_pPolicyAI->AddFlavorWeights((FlavorTypes)iFlavor, iFlavorValue, iPropagatePercent);4801 }4802 }4803}
Calls
- CustomMods::isAI_SMART_V3()
- CvEconomicAI::IsUsingStrategy(EconomicAIStrategyTypes)
- CvFlavorManager::GetPersonalityIndividualFlavor(FlavorTypes)
- CvGlobals::getInfoTypeForString(const char *, bool) const
- CvGlobals::getNumFlavorTypes()
- CvGrandStrategyAI::GetPersonalityAndGrandStrategy(FlavorTypes, bool)
- CvPlayer::GetCurrentEra() const
- CvPlayer::GetEconomicAI() const
- CvPlayer::GetFlavorManager() const
- CvPlayer::GetGrandStrategyAI() const
- CvPlayer::GetHappiness() const
- CvPlayer::getTeam() const
- CvPlayer::GetUnhappiness(CvCity *, CvCity *) const
- CvPolicyAI::AddFlavorWeights(FlavorTypes, int, int)
- CvPolicyAI::Reset()
- CvTeam::getAtWarCount(bool) const
- CvTeam::getTeam(TeamTypes)