Bazaar developer reference

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

Defined in
CvDiplomacyAI.cpp, line 15640
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoFYIDenouncedHumanFriend

Hooks

static bool BeforeCvDiplomacyAI_DoFYIDenouncedHumanFriend(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void AfterCvDiplomacyAI_DoFYIDenouncedHumanFriend(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void ReplaceCvDiplomacyAI_DoFYIDenouncedHumanFriend(void (*original)(CvDiplomacyAI*, PlayerTypes, DiploStatementTypes&, int&), CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoFYIDenouncedHumanFriend>(host, &BeforeCvDiplomacyAI_DoFYIDenouncedHumanFriend);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoFYIDenouncedHumanFriend>(host, &AfterCvDiplomacyAI_DoFYIDenouncedHumanFriend);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoFYIDenouncedHumanFriend>(host, &ReplaceCvDiplomacyAI_DoFYIDenouncedHumanFriend);

Code

15639/// Possible Contact Statement15640void CvDiplomacyAI::DoFYIDenouncedHumanFriend(PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1)15641{15642	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");15643	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.");1564415645	if(eStatement == NO_DIPLO_STATEMENT_TYPE)15646	{15647		DiploStatementTypes eTempStatement = DIPLO_STATEMENT_FYI_DENOUNCED_HUMAN_FRIEND;1564815649		if(GetNumTurnsSinceStatementSent(ePlayer, eTempStatement) >= 50 &&15650		        GetNumTurnsSinceStatementSent(ePlayer, DIPLO_STATEMENT_FYI_DENOUNCED_HUMAN_FRIEND_RANDFAILED) >= 20)15651		{15652			CvDiplomacyAI* pTheirDiploAI = GET_PLAYER(ePlayer).GetDiplomacyAI();1565315654			int iWeight;15655			MajorCivApproachTypes eApproach;15656			MajorCivOpinionTypes eOpinion;1565715658			// Loop through all players until we find one that we just denoucned, that ePlayer has befriended15659			PlayerTypes eLoopPlayer;15660			for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)15661			{15662				eLoopPlayer = (PlayerTypes) iPlayerLoop;1566315664				// Must be alive15665				if(!GET_PLAYER(eLoopPlayer).isAlive())15666					continue;1566715668				// Can't be either of us15669				if(eLoopPlayer == GetPlayer()->GetID() || eLoopPlayer == ePlayer)15670					continue;1567115672				// We haven't denounced this guy15673				if(!IsDenouncedPlayer(eLoopPlayer))15674					continue;1567515676				// They haven't befriended this guy15677				if(!pTheirDiploAI->IsDoFAccepted(eLoopPlayer))15678					continue;1567915680				// Too much time has passed (or maybe we already sent a message recently)15681				if(GetDenouncedPlayerCounter(eLoopPlayer) > 1)15682					continue;1568315684				eOpinion = GetMajorCivOpinion(ePlayer);15685				eApproach = GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ true);1568615687				// Don't say mean things if we like ePlayer15688				if(eOpinion >= MAJOR_CIV_OPINION_FAVORABLE)15689					continue;15690				if(eApproach == MAJOR_CIV_APPROACH_FRIENDLY)15691					continue;1569215693				iWeight = 0;1569415695				if(eOpinion == MAJOR_CIV_OPINION_COMPETITOR)15696					iWeight += 2;15697				else if(eOpinion == MAJOR_CIV_OPINION_ENEMY)15698					iWeight += 5;15699				else if(eOpinion == MAJOR_CIV_OPINION_UNFORGIVABLE)15700					iWeight += 10;1570115702				iWeight += GetMeanness();		// Usually ranges from 3 to 715703				iWeight += GC.getGame().getJonRandNum(7, "Random roll for AI statement: 0");1570415705				// We're mean enough to say something15706				if(iWeight >= 7)15707				{15708					eStatement = eTempStatement;15709					iData1 = eLoopPlayer;15710				}15711				// We're going to be nice!15712				else15713				{15714					eStatement = DIPLO_STATEMENT_FYI_DENOUNCED_HUMAN_FRIEND_RANDFAILED;15715				}1571615717				// We're done in here15718				break;15719			}15720		}15721	}15722}

Calls

Called by