Hooks
static bool BeforeCvDealAI_MakeOfferForEmbassy(CvDealAI* self, PlayerTypes eOtherPlayer, CvDeal* pDeal, bool& result);static void AfterCvDealAI_MakeOfferForEmbassy(CvDealAI* self, PlayerTypes eOtherPlayer, CvDeal* pDeal, bool& result);static bool ReplaceCvDealAI_MakeOfferForEmbassy(bool (*original)(CvDealAI*, PlayerTypes, CvDeal*), CvDealAI* self, PlayerTypes eOtherPlayer, CvDeal* pDeal);CivRegisterBefore<CivHooks::CvDealAI_MakeOfferForEmbassy>(host, &BeforeCvDealAI_MakeOfferForEmbassy);CivRegisterAfter<CivHooks::CvDealAI_MakeOfferForEmbassy>(host, &AfterCvDealAI_MakeOfferForEmbassy);CivRegisterReplace<CivHooks::CvDealAI_MakeOfferForEmbassy>(host, &ReplaceCvDealAI_MakeOfferForEmbassy);
Code
3824/// A good time to make an offer to get an embassy?3825bool CvDealAI::MakeOfferForEmbassy(PlayerTypes eOtherPlayer, CvDeal* pDeal)3826{3827 CvAssert(eOtherPlayer >= 0);3828 CvAssert(eOtherPlayer < MAX_MAJOR_CIVS);38293830 // Don't ask for Open Borders if we're hostile or planning war3831 MajorCivApproachTypes eApproach = GetPlayer()->GetDiplomacyAI()->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ false);3832 if(eApproach == MAJOR_CIV_APPROACH_HOSTILE ||3833 eApproach == MAJOR_CIV_APPROACH_WAR ||3834 eApproach == MAJOR_CIV_APPROACH_GUARDED)3835 {3836 return false;3837 }38383839 // Can we actually complete this deal?3840 if(!pDeal->IsPossibleToTradeItem(eOtherPlayer, GetPlayer()->GetID(), TRADE_ITEM_ALLOW_EMBASSY))3841 {3842 return false;3843 }38443845 // Do we actually want OB with eOtherPlayer?3846 if(GetPlayer()->GetDiplomacyAI()->WantsEmbassyAtPlayer(eOtherPlayer))3847 {3848 // Seed the deal with the item we want3849 pDeal->AddAllowEmbassy(eOtherPlayer);3850 bool bDealAcceptable = false;38513852 // AI evaluation3853 if(!GET_PLAYER(eOtherPlayer).isHuman())3854 {3855 bDealAcceptable = DoEqualizeDealWithAI(pDeal, eOtherPlayer); // Change the deal as necessary to make it work3856 }3857 else3858 {3859 bool bUselessReferenceVariable;3860 bool bCantMatchOffer;3861 bDealAcceptable = DoEqualizeDealWithHuman(pDeal, eOtherPlayer, false, true, bUselessReferenceVariable, bCantMatchOffer); // Change the deal as necessary to make it work3862 }38633864 return bDealAcceptable;3865 }38663867 return false;3868}