Bazaar developer reference

CvDiplomacyAI::DoUpdatePlotBuyingAggressivePosture()

Defined in
CvDiplomacyAI.cpp, line 8587
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoUpdatePlotBuyingAggressivePosture

Hooks

static bool BeforeCvDiplomacyAI_DoUpdatePlotBuyingAggressivePosture(CvDiplomacyAI* self);static void AfterCvDiplomacyAI_DoUpdatePlotBuyingAggressivePosture(CvDiplomacyAI* self);static void ReplaceCvDiplomacyAI_DoUpdatePlotBuyingAggressivePosture(void (*original)(CvDiplomacyAI*), CvDiplomacyAI* self);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoUpdatePlotBuyingAggressivePosture>(host, &BeforeCvDiplomacyAI_DoUpdatePlotBuyingAggressivePosture);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoUpdatePlotBuyingAggressivePosture>(host, &AfterCvDiplomacyAI_DoUpdatePlotBuyingAggressivePosture);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoUpdatePlotBuyingAggressivePosture>(host, &ReplaceCvDiplomacyAI_DoUpdatePlotBuyingAggressivePosture);

Code

8586/// Updates how aggressively ePlayer is buying land near us8587void CvDiplomacyAI::DoUpdatePlotBuyingAggressivePosture()8588{8589	PlayerTypes eLoopPlayer;85908591	AggressivePostureTypes ePosture;85928593	int iCityLoop;8594	CvCity* pLoopCity;85958596	int iAggressionScore;85978598	// Loop through all (known) Players8599	for(int iPlayerLoop = 0; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++)8600	{8601		eLoopPlayer = (PlayerTypes) iPlayerLoop;86028603		if(IsPlayerValid(eLoopPlayer))8604		{8605			iAggressionScore = 0;86068607			// Loop through all of our Cities to see if this player has bought land near them8608			for(pLoopCity = GetPlayer()->firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = GetPlayer()->nextCity(&iCityLoop))8609			{8610				iAggressionScore += pLoopCity->AI_GetNumPlotsAcquiredByOtherPlayer(eLoopPlayer);8611			}86128613			// Now See what our new Dispute Level should be8614			if(iAggressionScore >= /*10*/ GC.getPLOT_BUYING_POSTURE_INCREDIBLE_THRESHOLD())8615				ePosture = AGGRESSIVE_POSTURE_INCREDIBLE;8616			else if(iAggressionScore >= /*7*/ GC.getPLOT_BUYING_POSTURE_HIGH_THRESHOLD())8617				ePosture = AGGRESSIVE_POSTURE_HIGH;8618			else if(iAggressionScore >= /*4*/ GC.getPLOT_BUYING_POSTURE_MEDIUM_THRESHOLD())8619				ePosture = AGGRESSIVE_POSTURE_MEDIUM;8620			else if(iAggressionScore >= /*2*/ GC.getPLOT_BUYING_POSTURE_LOW_THRESHOLD())8621				ePosture = AGGRESSIVE_POSTURE_LOW;8622			else8623				ePosture = AGGRESSIVE_POSTURE_NONE;86248625			SetPlotBuyingAggressivePosture(eLoopPlayer, ePosture);8626		}8627	}8628}

Calls

Called by