Bazaar developer reference

CvDiplomacyAI::DoUpdateOnePlayerOpinion(PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 2339
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoUpdateOnePlayerOpinion

Hooks

static bool BeforeCvDiplomacyAI_DoUpdateOnePlayerOpinion(CvDiplomacyAI* self, PlayerTypes ePlayer);static void AfterCvDiplomacyAI_DoUpdateOnePlayerOpinion(CvDiplomacyAI* self, PlayerTypes ePlayer);static void ReplaceCvDiplomacyAI_DoUpdateOnePlayerOpinion(void (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoUpdateOnePlayerOpinion>(host, &BeforeCvDiplomacyAI_DoUpdateOnePlayerOpinion);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoUpdateOnePlayerOpinion>(host, &AfterCvDiplomacyAI_DoUpdateOnePlayerOpinion);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoUpdateOnePlayerOpinion>(host, &ReplaceCvDiplomacyAI_DoUpdateOnePlayerOpinion);

Code

2338/// What is our basic opinion of the role a player has in our game?2339void CvDiplomacyAI::DoUpdateOnePlayerOpinion(PlayerTypes ePlayer)2340{2341	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");2342	CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");23432344	if(!IsPlayerValid(ePlayer))2345		return;23462347	MajorCivOpinionTypes eOpinion;2348	CvPlayer& kPlayerEvaluating = GET_PLAYER(ePlayer);23492350	// Teammates?2351	if(GetPlayer()->getTeam() == kPlayerEvaluating.getTeam())2352	{2353		eOpinion = MAJOR_CIV_OPINION_ALLY;23542355#if defined(MOD_AI_MP_DIPLOMACY)2356		if (MOD_AI_MP_DIPLOMACY) {2357			// JdH => calculate ai to human trade priority for multiplayer2358			DoUpdateHumanTradePriority(ePlayer, GC.getOPINION_THRESHOLD_ALLY());2359		}2360#endif2361	}2362	// Different teams2363	else2364	{2365		int iOpinionWeight = GetMajorCivOpinionWeight(ePlayer);23662367		if(iOpinionWeight >= /*50*/ GC.getOPINION_THRESHOLD_UNFORGIVABLE())2368			eOpinion = MAJOR_CIV_OPINION_UNFORGIVABLE;2369		else if(iOpinionWeight >= /*30*/ GC.getOPINION_THRESHOLD_ENEMY())2370			eOpinion = MAJOR_CIV_OPINION_ENEMY;2371		else if(iOpinionWeight >= /*10*/ GC.getOPINION_THRESHOLD_COMPETITOR())2372			eOpinion = MAJOR_CIV_OPINION_COMPETITOR;2373		else if(iOpinionWeight >= /*-10*/ GC.getOPINION_THRESHOLD_FAVORABLE())2374			eOpinion = MAJOR_CIV_OPINION_NEUTRAL;2375		else if(iOpinionWeight >= /*-30*/ GC.getOPINION_THRESHOLD_FRIEND())2376			eOpinion = MAJOR_CIV_OPINION_FAVORABLE;2377		else if(iOpinionWeight >= /*-50*/ GC.getOPINION_THRESHOLD_ALLY())2378			eOpinion = MAJOR_CIV_OPINION_FRIEND;2379		else2380			eOpinion = MAJOR_CIV_OPINION_ALLY;23812382		// If we've agreed to work against someone, then the worst we can feel towards this guy is enemy2383		//if (IsWorkingAgainstPlayer(ePlayer) && eOpinion < MAJOR_CIV_OPINION_COMPETITOR)2384		//	eOpinion = MAJOR_CIV_OPINION_COMPETITOR;23852386#if defined(MOD_AI_MP_DIPLOMACY)2387		if (MOD_AI_MP_DIPLOMACY) {2388			// JdH => calculate ai to human trade priority for multiplayer2389			DoUpdateHumanTradePriority(ePlayer, iOpinionWeight);2390		}2391#endif2392	}23932394	// Finally, set the Opinion2395	SetMajorCivOpinion(ePlayer, eOpinion);23962397	//LogOpinionUpdate(ePlayer, viOpinionWeights);2398}

Calls

Called by