Hooks
static bool BeforeCvDiplomacyAI_DoCoopWarStatement(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void AfterCvDiplomacyAI_DoCoopWarStatement(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void ReplaceCvDiplomacyAI_DoCoopWarStatement(void (*original)(CvDiplomacyAI*, PlayerTypes, DiploStatementTypes&, int&), CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoCoopWarStatement>(host, &BeforeCvDiplomacyAI_DoCoopWarStatement);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoCoopWarStatement>(host, &AfterCvDiplomacyAI_DoCoopWarStatement);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoCoopWarStatement>(host, &ReplaceCvDiplomacyAI_DoCoopWarStatement);
Code
13716/// Possible Contact Statement13717void CvDiplomacyAI::DoCoopWarStatement(PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1)13718{13719 CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");13720 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.");1372113722 if(eStatement == NO_DIPLO_STATEMENT_TYPE)13723 {13724 // slewis - added so that a player already at war wouldn't try to start another war with another player. The AI should try to only have one war going at a time if possible.13725 if (GET_TEAM(GetTeam()).getAtWarCount(true) == 0)13726 {13727 PlayerTypes eTargetPlayer;13728 if(DoTestCoopWarDesire(ePlayer, /*passed by address*/ eTargetPlayer))13729 {13730 DiploStatementTypes eTempStatement = DIPLO_STATEMENT_COOP_WAR_REQUEST;13731 int iTurnsBetweenStatements = 10;1373213733 if(GetNumTurnsSinceStatementSent(ePlayer, eTempStatement) >= iTurnsBetweenStatements)13734 {13735 bool bSendStatement = true;1373613737 //// 1 in 2 chance we don't actually send the message (don't want full predictability)13738 //if (50 < GC.getGame().getJonRandNum(100, "Diplomacy AI: rand roll to see if we ask to work with a player"))13739 // bSendStatement = false;1374013741 if(bSendStatement)13742 {13743 eStatement = eTempStatement;13744 iData1 = eTargetPlayer;13745 }1374613747 // Add this statement to the log so we don't evaluate it again until time has passed13748 else13749 DoAddNewStatementToDiploLog(ePlayer, eTempStatement);13750 }13751 } 13752 }13753 }13754}