Bazaar developer reference

MilitaryAIHelpers::IsTestStrategy_WarMobilization(MilitaryAIStrategyTypes, CvPlayer *)

Defined in
CvMilitaryAI.cpp, line 4605
Hook name
CivHooks::MilitaryAIHelpers_IsTestStrategy_WarMobilization

Hooks

static bool BeforeMilitaryAIHelpers_IsTestStrategy_WarMobilization(MilitaryAIStrategyTypes eStrategy, CvPlayer* pPlayer, bool& result);static void AfterMilitaryAIHelpers_IsTestStrategy_WarMobilization(MilitaryAIStrategyTypes eStrategy, CvPlayer* pPlayer, bool& result);static bool ReplaceMilitaryAIHelpers_IsTestStrategy_WarMobilization(bool (*original)(MilitaryAIStrategyTypes, CvPlayer*), MilitaryAIStrategyTypes eStrategy, CvPlayer* pPlayer);CivRegisterBefore<CivHooks::MilitaryAIHelpers_IsTestStrategy_WarMobilization>(host, &BeforeMilitaryAIHelpers_IsTestStrategy_WarMobilization);CivRegisterAfter<CivHooks::MilitaryAIHelpers_IsTestStrategy_WarMobilization>(host, &AfterMilitaryAIHelpers_IsTestStrategy_WarMobilization);CivRegisterReplace<CivHooks::MilitaryAIHelpers_IsTestStrategy_WarMobilization>(host, &ReplaceMilitaryAIHelpers_IsTestStrategy_WarMobilization);

Code

4604/// "War Mobilization" Player Strategy: Does this player want to mobilize for war?  If so, adjust flavors4605bool MilitaryAIHelpers::IsTestStrategy_WarMobilization(MilitaryAIStrategyTypes eStrategy, CvPlayer* pPlayer)4606{4607	int iCurrentWeight = 0;4608	PlayerTypes eOtherPlayer;46094610	// If we're at war don't bother with this Strategy4611	MilitaryAIStrategyTypes eStrategyAtWar = (MilitaryAIStrategyTypes) GC.getInfoTypeForString("MILITARYAISTRATEGY_AT_WAR");46124613	if(eStrategyAtWar != NO_MILITARYAISTRATEGY)4614	{4615		if(pPlayer->GetMilitaryAI()->IsUsingStrategy(eStrategyAtWar))4616		{4617			return false;4618		}4619	}46204621	// Are we running the Conquest Grand Strategy?4622	AIGrandStrategyTypes eConquestGrandStrategy = (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CONQUEST");4623	if(eConquestGrandStrategy != NO_AIGRANDSTRATEGY)4624	{4625		if(pPlayer->GetGrandStrategyAI()->GetActiveGrandStrategy() == eConquestGrandStrategy)4626		{4627			iCurrentWeight += 25;4628		}4629	}46304631	CvDiplomacyAI* pkDiplomacyAI = pPlayer->GetDiplomacyAI();4632	for(int iMajorLoop = 0; iMajorLoop < MAX_MAJOR_CIVS; iMajorLoop++)4633	{4634		eOtherPlayer = (PlayerTypes) iMajorLoop;46354636		// Mobilize for war is automatic if we are preparing a sneak attack4637		if(pkDiplomacyAI->GetWarGoal(eOtherPlayer) == WAR_GOAL_PREPARE || pPlayer->GetMilitaryAI()->GetArmyBeingBuilt() != NO_ARMY_TYPE)4638		{4639			iCurrentWeight += 100;4640		}46414642		// Add in weight for each civ we're on really bad terms with4643		else if(pkDiplomacyAI->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ false) == MAJOR_CIV_APPROACH_WAR ||4644		        pkDiplomacyAI->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ false) == MAJOR_CIV_APPROACH_HOSTILE ||4645		        pkDiplomacyAI->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ false) == MAJOR_CIV_APPROACH_AFRAID)4646		{4647			iCurrentWeight += 50;4648		}46494650		// And some if on fairly bad terms4651		// Add in weight for each civ we're on really bad terms with4652		else if(pkDiplomacyAI->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ false) == MAJOR_CIV_APPROACH_GUARDED ||4653		        pkDiplomacyAI->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ false) == MAJOR_CIV_APPROACH_DECEPTIVE)4654		{4655			iCurrentWeight += 25;4656		}4657	}46584659	CvMilitaryAIStrategyXMLEntry* pStrategy = pPlayer->GetMilitaryAI()->GetMilitaryAIStrategies()->GetEntry(eStrategy);4660	CvAssert(pStrategy != NULL);4661	if(pStrategy)4662	{4663		int iWeightThreshold = pStrategy->GetWeightThreshold();	// 1004664		if(iCurrentWeight >= iWeightThreshold)4665		{4666			return true;4667		}4668	}46694670	return false;4671}

Calls

Called by