Bazaar developer reference

CvDiplomacyAI::IsWillingToMakePeaceWithHuman(PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 5412
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_IsWillingToMakePeaceWithHuman

Hooks

static bool BeforeCvDiplomacyAI_IsWillingToMakePeaceWithHuman(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static void AfterCvDiplomacyAI_IsWillingToMakePeaceWithHuman(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static bool ReplaceCvDiplomacyAI_IsWillingToMakePeaceWithHuman(bool (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_IsWillingToMakePeaceWithHuman>(host, &BeforeCvDiplomacyAI_IsWillingToMakePeaceWithHuman);CivRegisterAfter<CivHooks::CvDiplomacyAI_IsWillingToMakePeaceWithHuman>(host, &AfterCvDiplomacyAI_IsWillingToMakePeaceWithHuman);CivRegisterReplace<CivHooks::CvDiplomacyAI_IsWillingToMakePeaceWithHuman>(host, &ReplaceCvDiplomacyAI_IsWillingToMakePeaceWithHuman);

Code

5411/// Need some special rules for humans so that the AI isn't exploited5412bool CvDiplomacyAI::IsWillingToMakePeaceWithHuman(PlayerTypes ePlayer)5413{5414	CvPlayer& kHumanPlayer = GET_PLAYER(ePlayer);5415	if (kHumanPlayer.isHuman())5416	{5417#if defined(MOD_CONFIG_GAME_IN_XML)5418		bool bWillMakePeace = GetPlayerNumTurnsAtWar(ePlayer) >= GD_INT_GET(WAR_MAJOR_MINIMUM_TURNS);5419#else5420		bool bWillMakePeace = GetPlayerNumTurnsAtWar(ePlayer) >= 5;5421#endif54225423		if(!GET_TEAM(m_pPlayer->getTeam()).canChangeWarPeace(kHumanPlayer.getTeam()))5424		{5425			return false;5426		}54275428		// If either of us are locked in, then we're not willing to make peace (this prevents weird greetings and stuff) - we use > 1 because it'll get decremented after it appears the human make peace again5429		if(GET_TEAM(GetPlayer()->getTeam()).GetNumTurnsLockedIntoWar(kHumanPlayer.getTeam()) > 1)5430			return false;5431		if(GET_TEAM(kHumanPlayer.getTeam()).GetNumTurnsLockedIntoWar(GetPlayer()->getTeam()) > 1)5432			return false;54335434		return bWillMakePeace;5435	}5436	return true;5437}

Calls

Called by