Bazaar developer reference

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

Defined in
CvDiplomacyAI.cpp, line 15377
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoHappyDenouncedEnemy

Hooks

static bool BeforeCvDiplomacyAI_DoHappyDenouncedEnemy(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void AfterCvDiplomacyAI_DoHappyDenouncedEnemy(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void ReplaceCvDiplomacyAI_DoHappyDenouncedEnemy(void (*original)(CvDiplomacyAI*, PlayerTypes, DiploStatementTypes&, int&), CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoHappyDenouncedEnemy>(host, &BeforeCvDiplomacyAI_DoHappyDenouncedEnemy);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoHappyDenouncedEnemy>(host, &AfterCvDiplomacyAI_DoHappyDenouncedEnemy);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoHappyDenouncedEnemy>(host, &ReplaceCvDiplomacyAI_DoHappyDenouncedEnemy);

Code

15377void CvDiplomacyAI::DoHappyDenouncedEnemy(PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1)15378{15379	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");15380	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.");1538115382	// We denounced the leader we're talking to - no use talking at this point15383	if(IsDenouncedPlayer(ePlayer) || IsAtWar(ePlayer) || GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ true) == MAJOR_CIV_APPROACH_HOSTILE)15384		return;1538515386	if(eStatement == NO_DIPLO_STATEMENT_TYPE)15387	{15388		DiploStatementTypes eTempStatement = DIPLO_STATEMENT_HAPPY_DENOUNCED_ENEMY;1538915390		if(GetNumTurnsSinceStatementSent(ePlayer, eTempStatement) >= 50 &&15391		        GetNumTurnsSinceStatementSent(ePlayer, DIPLO_STATEMENT_HAPPY_DENOUNCED_ENEMY_RANDFAILED) >= 20)15392		{15393			CvDiplomacyAI* pTheirDiploAI = GET_PLAYER(ePlayer).GetDiplomacyAI();1539415395			// Loop through all players until we find one that is our enemy, that ePlayer denounced15396			PlayerTypes eLoopPlayer;15397			for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)15398			{15399				eLoopPlayer = (PlayerTypes) iPlayerLoop;1540015401				// Must be alive15402				if(!GET_PLAYER(eLoopPlayer).isAlive())15403					continue;1540415405				// Can't be either of us15406				if(eLoopPlayer == GetPlayer()->GetID() || eLoopPlayer == ePlayer)15407					continue;1540815409				// We haven't denounced this guy15410				if(!IsDenouncedPlayer(eLoopPlayer))15411					continue;1541215413				// They haven't denounced this guy15414				if(!pTheirDiploAI->IsDenouncedPlayer(eLoopPlayer))15415					continue;1541615417				// Too much time has passed (or maybe we already sent a message recently)15418				if(pTheirDiploAI->GetDenouncedPlayerCounter(eLoopPlayer) > 1)15419					continue;1542015421				// Found a match!1542215423				int iWeight = GetChattiness();		// Usually ranges from 3 to 715424				iWeight += GC.getGame().getJonRandNum(7, "Random roll for AI statement: 0");1542515426				// We're chatty enough to say something15427				if(iWeight >= 7)15428				{15429					eStatement = eTempStatement;15430					iData1 = eLoopPlayer;15431				}15432				// We're going to be nice!15433				else15434				{15435					eStatement = DIPLO_STATEMENT_HAPPY_DENOUNCED_ENEMY_RANDFAILED;15436				}1543715438				// We're done in here15439				break;15440			}15441		}15442	}15443}

Calls

Called by