Bazaar developer reference

CvDiplomacyAI::IsPlayerDemandAttractive(PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 4791
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_IsPlayerDemandAttractive

Hooks

static bool BeforeCvDiplomacyAI_IsPlayerDemandAttractive(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static void AfterCvDiplomacyAI_IsPlayerDemandAttractive(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static bool ReplaceCvDiplomacyAI_IsPlayerDemandAttractive(bool (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_IsPlayerDemandAttractive>(host, &BeforeCvDiplomacyAI_IsPlayerDemandAttractive);CivRegisterAfter<CivHooks::CvDiplomacyAI_IsPlayerDemandAttractive>(host, &AfterCvDiplomacyAI_IsPlayerDemandAttractive);CivRegisterReplace<CivHooks::CvDiplomacyAI_IsPlayerDemandAttractive>(host, &ReplaceCvDiplomacyAI_IsPlayerDemandAttractive);

Code

4790/// Are we willing to make a demand of ePlayer?4791bool CvDiplomacyAI::IsPlayerDemandAttractive(PlayerTypes ePlayer)4792{4793	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");4794	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.");47954796	// Being hostile towards this guy? (ignore war face, as if we're planning a war already, making a demand doesn't mesh well with that)4797	if(GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ false) != MAJOR_CIV_APPROACH_HOSTILE)4798	{4799		return false;4800	}48014802	// Player can't be distant4803	if(GetPlayer()->GetProximityToPlayer(ePlayer) < PLAYER_PROXIMITY_FAR)4804	{4805		return false;4806	}48074808	// If they're a bad or impossible target then that's not good at all for us4809	if(GetPlayerTargetValue(ePlayer) < TARGET_VALUE_AVERAGE)4810	{4811		return false;4812	}48134814	// Don't make demands of them too often4815	if(GetNumTurnsSinceStatementSent(ePlayer, DIPLO_STATEMENT_DEMAND) < 40)4816	{4817		return false;4818	}48194820	// If we're planning a war or at war with anyone, making a demand is unwise4821	PlayerTypes eLoopPlayer;4822	for(int iPlayerLoop = 0; iPlayerLoop < MAX_CIV_PLAYERS; iPlayerLoop++)4823	{4824		eLoopPlayer = (PlayerTypes) iPlayerLoop;48254826		if(GetWarGoal(eLoopPlayer) == WAR_GOAL_PREPARE)4827		{4828			return false;4829		}48304831		if(IsAtWar(eLoopPlayer))4832		{4833			return false;4834		}4835	}48364837	// Player has to be on the same area as us4838	if(GetPlayer()->getCapitalCity() != NULL)4839	{4840		if(GET_PLAYER(ePlayer).getCapitalCity() != NULL)4841		{4842			if(GetPlayer()->getCapitalCity()->getArea() == GET_PLAYER(ePlayer).getCapitalCity()->getArea())4843			{4844				return true;4845			}4846		}4847	}48484849	return false;4850}

Calls

Called by