Bazaar developer reference

CvDiplomacyAI::DoAngryDenouncedFriend(PlayerTypes, DiploStatementTypes &, int &)

Defined in
CvDiplomacyAI.cpp, line 15309
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoAngryDenouncedFriend

Hooks

static bool BeforeCvDiplomacyAI_DoAngryDenouncedFriend(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void AfterCvDiplomacyAI_DoAngryDenouncedFriend(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void ReplaceCvDiplomacyAI_DoAngryDenouncedFriend(void (*original)(CvDiplomacyAI*, PlayerTypes, DiploStatementTypes&, int&), CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoAngryDenouncedFriend>(host, &BeforeCvDiplomacyAI_DoAngryDenouncedFriend);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoAngryDenouncedFriend>(host, &AfterCvDiplomacyAI_DoAngryDenouncedFriend);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoAngryDenouncedFriend>(host, &ReplaceCvDiplomacyAI_DoAngryDenouncedFriend);

Code

15309void CvDiplomacyAI::DoAngryDenouncedFriend(PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1)15310{15311	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");15312	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.");1531315314	// We denounced the leader we're talking to - no use whining at this point15315	if(IsDenouncedPlayer(ePlayer) || IsAtWar(ePlayer) || GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ true) == MAJOR_CIV_APPROACH_HOSTILE)15316		return;1531715318	if(eStatement == NO_DIPLO_STATEMENT_TYPE)15319	{15320		DiploStatementTypes eTempStatement = DIPLO_STATEMENT_ANGRY_DENOUNCED_FRIEND;1532115322		if(GetNumTurnsSinceStatementSent(ePlayer, eTempStatement) >= 50 &&15323		        GetNumTurnsSinceStatementSent(ePlayer, DIPLO_STATEMENT_ANGRY_DENOUNCED_FRIEND_RANDFAILED) >= 20)15324		{15325			CvDiplomacyAI* pTheirDiploAI = GET_PLAYER(ePlayer).GetDiplomacyAI();1532615327			// Loop through all players until we find one that is our friend, that ePlayer denounced15328			PlayerTypes eLoopPlayer;15329			for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)15330			{15331				eLoopPlayer = (PlayerTypes) iPlayerLoop;1533215333				// Must be alive15334				if(!GET_PLAYER(eLoopPlayer).isAlive())15335					continue;1533615337				// Can't be either of us15338				if(eLoopPlayer == GetPlayer()->GetID() || eLoopPlayer == ePlayer)15339					continue;1534015341				// We haven't befriended this guy15342				if(!IsDoFAccepted(eLoopPlayer))15343					continue;1534415345				// They haven't denounced this guy15346				if(!pTheirDiploAI->IsDenouncedPlayer(eLoopPlayer))15347					continue;1534815349				// Too much time has passed (or maybe we already sent a message recently)15350				if(pTheirDiploAI->GetDenouncedPlayerCounter(eLoopPlayer) > 1)15351					continue;1535215353				// Found a match!1535415355				int iWeight = GetMeanness();		// Usually ranges from 3 to 715356				iWeight += GC.getGame().getJonRandNum(7, "Random roll for AI statement: 0");1535715358				// We're mean enough to say something15359				if(iWeight >= 7)15360				{15361					eStatement = eTempStatement;15362					iData1 = eLoopPlayer;15363				}15364				// We're going to be nice!15365				else15366				{15367					eStatement = DIPLO_STATEMENT_ANGRY_DENOUNCED_FRIEND_RANDFAILED;15368				}1536915370				// We're done in here15371				break;15372			}15373		}15374	}15375}

Calls

Called by