Bazaar developer reference

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

Defined in
CvDiplomacyAI.cpp, line 15725
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoFYIDenouncedHumanEnemy

Hooks

static bool BeforeCvDiplomacyAI_DoFYIDenouncedHumanEnemy(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void AfterCvDiplomacyAI_DoFYIDenouncedHumanEnemy(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void ReplaceCvDiplomacyAI_DoFYIDenouncedHumanEnemy(void (*original)(CvDiplomacyAI*, PlayerTypes, DiploStatementTypes&, int&), CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoFYIDenouncedHumanEnemy>(host, &BeforeCvDiplomacyAI_DoFYIDenouncedHumanEnemy);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoFYIDenouncedHumanEnemy>(host, &AfterCvDiplomacyAI_DoFYIDenouncedHumanEnemy);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoFYIDenouncedHumanEnemy>(host, &ReplaceCvDiplomacyAI_DoFYIDenouncedHumanEnemy);

Code

15724/// Possible Contact Statement15725void CvDiplomacyAI::DoFYIDenouncedHumanEnemy(PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1)15726{15727	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");15728	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.");1572915730	if(eStatement == NO_DIPLO_STATEMENT_TYPE)15731	{15732		DiploStatementTypes eTempStatement = DIPLO_STATEMENT_FYI_DENOUNCED_HUMAN_ENEMY;1573315734		if(GetNumTurnsSinceStatementSent(ePlayer, eTempStatement) >= 50 &&15735		        GetNumTurnsSinceStatementSent(ePlayer, DIPLO_STATEMENT_FYI_DENOUNCED_HUMAN_ENEMY_RANDFAILED) >= 20)15736		{15737			CvDiplomacyAI* pTheirDiploAI = GET_PLAYER(ePlayer).GetDiplomacyAI();1573815739			int iWeight;15740			MajorCivApproachTypes eApproach;15741			MajorCivOpinionTypes eOpinion;1574215743			// Loop through all players until we find one that we just denounced, that ePlayer has denounced15744			PlayerTypes eLoopPlayer;15745			for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)15746			{15747				eLoopPlayer = (PlayerTypes) iPlayerLoop;1574815749				// Must be alive15750				if(!GET_PLAYER(eLoopPlayer).isAlive())15751					continue;1575215753				// Can't be either of us15754				if(eLoopPlayer == GetPlayer()->GetID() || eLoopPlayer == ePlayer)15755					continue;1575615757				// We haven't denounced this guy15758				if(!IsDenouncedPlayer(eLoopPlayer))15759					continue;1576015761				// They haven't denounced this guy15762				if(!pTheirDiploAI->IsDenouncedPlayer(eLoopPlayer))15763					continue;1576415765				// Too much time has passed (or maybe we already sent a message recently)15766				if(GetDenouncedPlayerCounter(eLoopPlayer) > 1)15767					continue;1576815769				eOpinion = GetMajorCivOpinion(ePlayer);15770				eApproach = GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ true);1577115772				// Don't say nice things if we dislike ePlayer15773				if(eOpinion <= MAJOR_CIV_OPINION_COMPETITOR)15774					continue;15775				if(eApproach == MAJOR_CIV_APPROACH_WAR || eApproach == MAJOR_CIV_APPROACH_HOSTILE)15776					continue;1577715778				iWeight = 0;1577915780				if(eOpinion == MAJOR_CIV_OPINION_FAVORABLE)15781					iWeight += 2;15782				else if(eOpinion == MAJOR_CIV_OPINION_FRIEND)15783					iWeight += 5;15784				else if(eOpinion == MAJOR_CIV_OPINION_ALLY)15785					iWeight += 10;1578615787				if(eOpinion == MAJOR_CIV_APPROACH_FRIENDLY)15788					iWeight += 2;1578915790				// Add weight if they're strong15791				if(GetPlayerMilitaryStrengthComparedToUs(ePlayer) > STRENGTH_AVERAGE)15792					iWeight += 3;1579315794				iWeight += GetChattiness();		// Usually ranges from 3 to 715795				iWeight += GC.getGame().getJonRandNum(7, "Random roll for AI statement: 0");1579615797				// We're mean enough to say something15798				if(iWeight >= 7)15799				{15800					eStatement = eTempStatement;15801					iData1 = eLoopPlayer;15802				}15803				// We're going to be nice!15804				else15805				{15806					eStatement = DIPLO_STATEMENT_FYI_DENOUNCED_HUMAN_ENEMY_RANDFAILED;15807				}1580815809				// We're done in here15810				break;15811			}15812		}15813	}15814}

Calls

Called by