Hooks
static bool BeforeCvDealAI_DoAddEmbassyToThem(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountOverWeWillRequest, bool bUseEvenValue);static void AfterCvDealAI_DoAddEmbassyToThem(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountOverWeWillRequest, bool bUseEvenValue);static void ReplaceCvDealAI_DoAddEmbassyToThem(void (*original)(CvDealAI*, CvDeal*, PlayerTypes, bool, int&, int&, int&, int, bool), CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountOverWeWillRequest, bool bUseEvenValue);CivRegisterBefore<CivHooks::CvDealAI_DoAddEmbassyToThem>(host, &BeforeCvDealAI_DoAddEmbassyToThem);CivRegisterAfter<CivHooks::CvDealAI_DoAddEmbassyToThem>(host, &AfterCvDealAI_DoAddEmbassyToThem);CivRegisterReplace<CivHooks::CvDealAI_DoAddEmbassyToThem>(host, &ReplaceCvDealAI_DoAddEmbassyToThem);
Code
2679/// See if adding Embassy to their side of the deal helps even out pDeal2680void CvDealAI::DoAddEmbassyToThem(CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountOverWeWillRequest, bool bUseEvenValue)2681{2682 CvAssert(eThem >= 0);2683 CvAssert(eThem < MAX_MAJOR_CIVS);2684 CvAssertMsg(eThem != GetPlayer()->GetID(), "DEAL_AI: Trying to add Embassy to Them, but them is us. Please show Jon");26852686 if(!bDontChangeTheirExistingItems)2687 {2688 if(iTotalValue < 0)2689 {2690 if(!pDeal->IsAllowEmbassyTrade(eThem))2691 {2692 PlayerTypes eMyPlayer = GetPlayer()->GetID();26932694 // See if they can actually trade it to us2695 if(pDeal->IsPossibleToTradeItem(eThem, eMyPlayer, TRADE_ITEM_ALLOW_EMBASSY))2696 {2697 int iItemValue = GetTradeItemValue(TRADE_ITEM_ALLOW_EMBASSY, /*bFromMe*/ false, eThem, -1, -1, -1, /*bFlag1*/false, -1, bUseEvenValue);26982699 // If adding this to the deal doesn't take it over the limit, do it2700#if defined(MOD_AI_NO_ZERO_VALUE_TRADE_ITEMS)2701 if((iItemValue > 0) && (iItemValue + iTotalValue <= iAmountOverWeWillRequest))2702#else2703 if(iItemValue + iTotalValue <= iAmountOverWeWillRequest)2704#endif 2705 {2706 pDeal->AddAllowEmbassy(eThem);2707 iTotalValue = GetDealValue(pDeal, iValueImOffering, iValueTheyreOffering, bUseEvenValue);2708 }2709 }2710 }2711 }2712 }2713}