Bazaar developer reference

CvDiplomacyAI::IsActHostileTowardsHuman(PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 19716
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_IsActHostileTowardsHuman

Hooks

static bool BeforeCvDiplomacyAI_IsActHostileTowardsHuman(CvDiplomacyAI* self, PlayerTypes eHuman, bool& result);static void AfterCvDiplomacyAI_IsActHostileTowardsHuman(CvDiplomacyAI* self, PlayerTypes eHuman, bool& result);static bool ReplaceCvDiplomacyAI_IsActHostileTowardsHuman(bool (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes eHuman);CivRegisterBefore<CivHooks::CvDiplomacyAI_IsActHostileTowardsHuman>(host, &BeforeCvDiplomacyAI_IsActHostileTowardsHuman);CivRegisterAfter<CivHooks::CvDiplomacyAI_IsActHostileTowardsHuman>(host, &AfterCvDiplomacyAI_IsActHostileTowardsHuman);CivRegisterReplace<CivHooks::CvDiplomacyAI_IsActHostileTowardsHuman>(host, &ReplaceCvDiplomacyAI_IsActHostileTowardsHuman);

Code

19715/// Is the AI acting mean to the active human player?19716bool CvDiplomacyAI::IsActHostileTowardsHuman(PlayerTypes eHuman)19717{19718	MajorCivOpinionTypes eOpinion = GetMajorCivOpinion(eHuman);19719	MajorCivApproachTypes eVisibleApproach = GetMajorCivApproach(eHuman, /*bHideTrueFeelings*/ true);1972019721	bool bAtWar = IsAtWar(eHuman);19722	bool bAtWarButWantsPeace = bAtWar &&					// Have to be at war19723	                           GetTreatyWillingToOffer(eHuman) >= PEACE_TREATY_WHITE_PEACE && GetTreatyWillingToAccept(eHuman) >= PEACE_TREATY_WHITE_PEACE &&		// High-level AI has to want peace19724	                           IsWillingToMakePeaceWithHuman(eHuman);						// Special rules for peace with human (turn count) have to be met1972519726	if(eVisibleApproach == MAJOR_CIV_APPROACH_HOSTILE)	// Hostile Approach19727		return true;19728	else if(bAtWar && !bAtWarButWantsPeace)		// At war and don't want peace19729		return true;19730	else if(eOpinion <= MAJOR_CIV_OPINION_ENEMY && eVisibleApproach != MAJOR_CIV_APPROACH_FRIENDLY)	// Enemy or worse, and not pretending to be friendly19731		return true;1973219733	return false;19734}

Calls

Called by