MilitaryAIHelpers::IsTestStrategy_EnoughMilitaryUnits(CvPlayer *)
- Defined in
- CvMilitaryAI.cpp, line 4523
- Hook name
CivHooks::MilitaryAIHelpers_IsTestStrategy_EnoughMilitaryUnits
Hooks
static bool BeforeMilitaryAIHelpers_IsTestStrategy_EnoughMilitaryUnits(CvPlayer* pPlayer, bool& result);static void AfterMilitaryAIHelpers_IsTestStrategy_EnoughMilitaryUnits(CvPlayer* pPlayer, bool& result);static bool ReplaceMilitaryAIHelpers_IsTestStrategy_EnoughMilitaryUnits(bool (*original)(CvPlayer*), CvPlayer* pPlayer);CivRegisterBefore<CivHooks::MilitaryAIHelpers_IsTestStrategy_EnoughMilitaryUnits>(host, &BeforeMilitaryAIHelpers_IsTestStrategy_EnoughMilitaryUnits);CivRegisterAfter<CivHooks::MilitaryAIHelpers_IsTestStrategy_EnoughMilitaryUnits>(host, &AfterMilitaryAIHelpers_IsTestStrategy_EnoughMilitaryUnits);CivRegisterReplace<CivHooks::MilitaryAIHelpers_IsTestStrategy_EnoughMilitaryUnits>(host, &ReplaceMilitaryAIHelpers_IsTestStrategy_EnoughMilitaryUnits);
Code
4522/// "Enough Military Units" Player Strategy: Does this player have too many military units? If so, adjust flavors4523bool MilitaryAIHelpers::IsTestStrategy_EnoughMilitaryUnits(CvPlayer* pPlayer)4524{4525 // Are we running at a deficit?4526 EconomicAIStrategyTypes eStrategyLosingMoney = (EconomicAIStrategyTypes) GC.getInfoTypeForString("ECONOMICAISTRATEGY_LOSING_MONEY");4527 bool bInDeficit = pPlayer->GetEconomicAI()->IsUsingStrategy(eStrategyLosingMoney);45284529 // Are we running anything other than the Conquest Grand Strategy?4530 AIGrandStrategyTypes eConquestGrandStrategy = (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CONQUEST");4531 if(eConquestGrandStrategy != NO_AIGRANDSTRATEGY)4532 {4533 if(bInDeficit || pPlayer->GetGrandStrategyAI()->GetActiveGrandStrategy() != eConquestGrandStrategy || pPlayer->GetMilitaryAI()->GetPercentOfRecommendedMilitarySize() > 125)4534 {4535 if(pPlayer->GetMilitaryAI()->GetLandDefenseState() == DEFENSE_STATE_ENOUGH)4536 {4537 return true;4538 }4539 }4540 else4541 {4542 return false;4543 }4544 }45454546 return false;4547}
Calls
- CvEconomicAI::IsUsingStrategy(EconomicAIStrategyTypes)
- CvGlobals::getInfoTypeForString(const char *, bool) const
- CvGrandStrategyAI::GetActiveGrandStrategy() const
- CvMilitaryAI::GetLandDefenseState() const
- CvMilitaryAI::GetPercentOfRecommendedMilitarySize() const
- CvPlayer::GetEconomicAI() const
- CvPlayer::GetGrandStrategyAI() const
- CvPlayer::GetMilitaryAI() const