Bazaar developer reference

CvDiplomacyAI::IsMakeRequest(PlayerTypes, CvDeal *, bool &)

Defined in
CvDiplomacyAI.cpp, line 4862
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_IsMakeRequest

Hooks

static bool BeforeCvDiplomacyAI_IsMakeRequest(CvDiplomacyAI* self, PlayerTypes ePlayer, CvDeal* pDeal, bool& bRandPassed, bool& result);static void AfterCvDiplomacyAI_IsMakeRequest(CvDiplomacyAI* self, PlayerTypes ePlayer, CvDeal* pDeal, bool& bRandPassed, bool& result);static bool ReplaceCvDiplomacyAI_IsMakeRequest(bool (*original)(CvDiplomacyAI*, PlayerTypes, CvDeal*, bool&), CvDiplomacyAI* self, PlayerTypes ePlayer, CvDeal* pDeal, bool& bRandPassed);CivRegisterBefore<CivHooks::CvDiplomacyAI_IsMakeRequest>(host, &BeforeCvDiplomacyAI_IsMakeRequest);CivRegisterAfter<CivHooks::CvDiplomacyAI_IsMakeRequest>(host, &AfterCvDiplomacyAI_IsMakeRequest);CivRegisterReplace<CivHooks::CvDiplomacyAI_IsMakeRequest>(host, &ReplaceCvDiplomacyAI_IsMakeRequest);

Code

4861/// Is this AI willing to make a request of ePlayer4862bool CvDiplomacyAI::IsMakeRequest(PlayerTypes ePlayer, CvDeal* pDeal, bool& bRandPassed)4863{4864	bool bFriendly = GetMajorCivApproach(ePlayer, /*bHideTrueFeelings*/ true) == MAJOR_CIV_APPROACH_FRIENDLY;48654866	if(bFriendly && IsDoFAccepted(ePlayer))4867	{4868		// Is there something we want?4869		bool bWantsSomething = false;4870		// Is there a strong reason why we want something? (added to rand roll)4871		int iWeightBias = 0;48724873		// Luxury Request4874		if(!bWantsSomething)4875			bWantsSomething = IsLuxuryRequest(ePlayer, pDeal, iWeightBias);4876		// Gold Request4877		if(!bWantsSomething)4878			bWantsSomething = IsGoldRequest(ePlayer, pDeal, iWeightBias);48794880		if(bWantsSomething)4881		{4882			// Random element4883			int iRand = GC.getGame().getJonRandNumVA(100, "Diplomacy AI: Friendly civ request roll. (%d; %d)", (int)GetPlayer()->GetID(), (int)ePlayer);48844885			iRand += iWeightBias;48864887			if(iRand >= 67)4888			{4889				bRandPassed = true;4890				return true;4891			}4892			else4893			{4894				bRandPassed = false;4895				return false;4896			}4897		}4898	}48994900	return false;4901}

Calls

Called by