Bazaar developer reference

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

Defined in
CvDiplomacyAI.cpp, line 13662
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoCoopWarTimeStatement

Hooks

static bool BeforeCvDiplomacyAI_DoCoopWarTimeStatement(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void AfterCvDiplomacyAI_DoCoopWarTimeStatement(CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);static void ReplaceCvDiplomacyAI_DoCoopWarTimeStatement(void (*original)(CvDiplomacyAI*, PlayerTypes, DiploStatementTypes&, int&), CvDiplomacyAI* self, PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoCoopWarTimeStatement>(host, &BeforeCvDiplomacyAI_DoCoopWarTimeStatement);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoCoopWarTimeStatement>(host, &AfterCvDiplomacyAI_DoCoopWarTimeStatement);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoCoopWarTimeStatement>(host, &ReplaceCvDiplomacyAI_DoCoopWarTimeStatement);

Code

13661/// Possible Contact Statement13662void CvDiplomacyAI::DoCoopWarTimeStatement(PlayerTypes ePlayer, DiploStatementTypes& eStatement, int& iData1)13663{13664	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");13665	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.");1366613667	if(eStatement == NO_DIPLO_STATEMENT_TYPE)13668	{13669		// Don't send this to AI players - coop war timer is automatically handled in DoCounters()13670		if(!GET_PLAYER(ePlayer).isHuman())13671			return;1367213673		CvTeam* pTeam = &GET_TEAM(GET_PLAYER(ePlayer).getTeam());1367413675		PlayerTypes eTargetPlayer;13676		TeamTypes eTargetTeam;1367713678		for(int iTargetLoop = 0; iTargetLoop < MAX_MAJOR_CIVS; iTargetLoop++)13679		{13680			eTargetPlayer = (PlayerTypes) iTargetLoop;1368113682			// Agreed to go to war soon... what's the counter at?13683			if(GetCoopWarAcceptedState(ePlayer, eTargetPlayer) == COOP_WAR_STATE_SOON)13684			{13685				if(GetCoopWarCounter(ePlayer, eTargetPlayer) == /*10*/ GC.getCOOP_WAR_SOON_COUNTER())13686				{13687					eTargetTeam = GET_PLAYER(eTargetPlayer).getTeam();1368813689					// If we're already at war, don't bother13690					if(!pTeam->isAtWar(eTargetTeam) && GET_PLAYER(eTargetPlayer).isAlive())13691					{13692						eStatement = DIPLO_STATEMENT_COOP_WAR_TIME;13693						iData1 = eTargetPlayer;1369413695						// Don't evaluate other players13696						break;13697					}13698					// Human is already at war - process what we would have if he'd agreed at this point13699					else13700					{13701						SetCoopWarAcceptedState(ePlayer, eTargetPlayer, COOP_WAR_STATE_ACCEPTED);1370213703						// AI declaration13704						if(!IsAtWar(eTargetPlayer) && GET_PLAYER(eTargetPlayer).isAlive())13705						{13706							DeclareWar(eTargetPlayer);13707							GetPlayer()->GetMilitaryAI()->RequestBasicAttack(eTargetPlayer, 1);13708						}13709					}13710				}13711			}13712		}13713	}13714}

Calls

Called by