Bazaar developer reference

CvDiplomacyAI::DoEstimateOtherPlayerOpinions()

Defined in
CvDiplomacyAI.cpp, line 2619
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoEstimateOtherPlayerOpinions

Hooks

static bool BeforeCvDiplomacyAI_DoEstimateOtherPlayerOpinions(CvDiplomacyAI* self);static void AfterCvDiplomacyAI_DoEstimateOtherPlayerOpinions(CvDiplomacyAI* self);static void ReplaceCvDiplomacyAI_DoEstimateOtherPlayerOpinions(void (*original)(CvDiplomacyAI*), CvDiplomacyAI* self);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoEstimateOtherPlayerOpinions>(host, &BeforeCvDiplomacyAI_DoEstimateOtherPlayerOpinions);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoEstimateOtherPlayerOpinions>(host, &AfterCvDiplomacyAI_DoEstimateOtherPlayerOpinions);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoEstimateOtherPlayerOpinions>(host, &ReplaceCvDiplomacyAI_DoEstimateOtherPlayerOpinions);

Code

2618/// What is our our guess as to other players' Opinions about everyone else?2619void CvDiplomacyAI::DoEstimateOtherPlayerOpinions()2620{2621	MajorCivOpinionTypes eOpinion;26222623	int iOpinionWeight;26242625	PlayerTypes eLoopOtherPlayer;2626	int iOtherPlayerLoop;26272628	// Loop through all (known) Majors2629	PlayerTypes eLoopPlayer;2630	for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)2631	{2632		eLoopPlayer = (PlayerTypes) iPlayerLoop;26332634		if(IsPlayerValid(eLoopPlayer))2635		{2636			// Now loop through every player HE knows2637			for(iOtherPlayerLoop = 0; iOtherPlayerLoop < MAX_MAJOR_CIVS; iOtherPlayerLoop++)2638			{2639				eLoopOtherPlayer = (PlayerTypes) iOtherPlayerLoop;26402641				// Don't compare a player to himself2642				if(eLoopPlayer != eLoopOtherPlayer)2643				{2644					// Do both we and the guy we're looking about know the third guy?2645					if(IsPlayerValid(eLoopOtherPlayer, true) && GET_PLAYER(eLoopPlayer).GetDiplomacyAI()->IsPlayerValid(eLoopOtherPlayer))2646					{2647						iOpinionWeight = 0;26482649						// Look at Land Dispute2650						switch(GetEstimateOtherPlayerLandDisputeLevel(eLoopPlayer, eLoopOtherPlayer))2651						{2652						case DISPUTE_LEVEL_FIERCE:2653							iOpinionWeight += /*30*/ GC.getOPINION_WEIGHT_LAND_FIERCE();2654							break;2655						case DISPUTE_LEVEL_STRONG:2656							iOpinionWeight += /*20*/ GC.getOPINION_WEIGHT_LAND_STRONG();2657							break;2658						case DISPUTE_LEVEL_WEAK:2659							iOpinionWeight += /*10*/ GC.getOPINION_WEIGHT_LAND_WEAK();2660							break;2661						case DISPUTE_LEVEL_NONE:2662							iOpinionWeight += /*0*/ GC.getOPINION_WEIGHT_LAND_NONE();2663							break;2664						}26652666						// Look at Victory Competition Dispute2667						switch(GetEstimateOtherPlayerVictoryDisputeLevel(eLoopPlayer, eLoopOtherPlayer))2668						{2669						case DISPUTE_LEVEL_FIERCE:2670							iOpinionWeight += /*30*/ GC.getOPINION_WEIGHT_VICTORY_FIERCE();2671							break;2672						case DISPUTE_LEVEL_STRONG:2673							iOpinionWeight += /*20*/ GC.getOPINION_WEIGHT_VICTORY_STRONG();2674							break;2675						case DISPUTE_LEVEL_WEAK:2676							iOpinionWeight += /*10*/ GC.getOPINION_WEIGHT_VICTORY_WEAK();2677							break;2678						case DISPUTE_LEVEL_NONE:2679							iOpinionWeight += /*0*/ GC.getOPINION_WEIGHT_VICTORY_NONE();2680							break;2681						}26822683						// Now do the final assessment2684						if(iOpinionWeight >= /*50*/ GC.getOPINION_THRESHOLD_UNFORGIVABLE())2685							eOpinion = MAJOR_CIV_OPINION_UNFORGIVABLE;2686						else if(iOpinionWeight >= /*30*/ GC.getOPINION_THRESHOLD_ENEMY())2687							eOpinion = MAJOR_CIV_OPINION_ENEMY;2688						else if(iOpinionWeight >= /*10*/ GC.getOPINION_THRESHOLD_COMPETITOR())2689							eOpinion = MAJOR_CIV_OPINION_COMPETITOR;2690						else if(iOpinionWeight < /*-10*/ GC.getOPINION_THRESHOLD_FAVORABLE())2691							eOpinion = MAJOR_CIV_OPINION_FAVORABLE;2692						else if(iOpinionWeight < /*-30*/ GC.getOPINION_THRESHOLD_FRIEND())2693							eOpinion = MAJOR_CIV_OPINION_FRIEND;2694						else if(iOpinionWeight < /*-50*/ GC.getOPINION_THRESHOLD_ALLY())2695							eOpinion = MAJOR_CIV_OPINION_ALLY;2696						else2697							eOpinion = MAJOR_CIV_OPINION_NEUTRAL;26982699						// Finally, set the Opinion2700						SetMajorCivOtherPlayerOpinion(eLoopPlayer, eLoopOtherPlayer, eOpinion);2701					}2702				}2703			}2704		}2705	}2706}

Calls

Called by