Hooks
static bool BeforeCvDealAI_DoAddEmbassyToUs(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountUnderWeWillOffer, bool bUseEvenValue);static void AfterCvDealAI_DoAddEmbassyToUs(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountUnderWeWillOffer, bool bUseEvenValue);static void ReplaceCvDealAI_DoAddEmbassyToUs(void (*original)(CvDealAI*, CvDeal*, PlayerTypes, bool, int&, int&, int&, int, bool), CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountUnderWeWillOffer, bool bUseEvenValue);CivRegisterBefore<CivHooks::CvDealAI_DoAddEmbassyToUs>(host, &BeforeCvDealAI_DoAddEmbassyToUs);CivRegisterAfter<CivHooks::CvDealAI_DoAddEmbassyToUs>(host, &AfterCvDealAI_DoAddEmbassyToUs);CivRegisterReplace<CivHooks::CvDealAI_DoAddEmbassyToUs>(host, &ReplaceCvDealAI_DoAddEmbassyToUs);
Code
2715/// See if adding Embassy to our side of the deal helps even out pDeal2716void CvDealAI::DoAddEmbassyToUs(CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeMyExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountUnderWeWillOffer, bool bUseEvenValue)2717{2718 CvAssert(eThem >= 0);2719 CvAssert(eThem < MAX_MAJOR_CIVS);2720 CvAssertMsg(eThem != GetPlayer()->GetID(), "DEAL_AI: Trying to add Embassy to Us, but them is us. Please show Jon");27212722 if(!bDontChangeMyExistingItems)2723 {2724 if(iTotalValue > 0)2725 {2726 PlayerTypes eMyPlayer = GetPlayer()->GetID();27272728 if(!pDeal->IsAllowEmbassyTrade(eMyPlayer))2729 {2730 // See if we can actually trade it to them2731 if(pDeal->IsPossibleToTradeItem(eMyPlayer, eThem, TRADE_ITEM_ALLOW_EMBASSY))2732 {2733 int iItemValue = GetTradeItemValue(TRADE_ITEM_ALLOW_EMBASSY, /*bFromMe*/ true, eThem, -1, -1, -1, /*bFlag1*/false, -1, bUseEvenValue);27342735 // If adding this to the deal doesn't take it under the min limit, do it2736#if defined(MOD_AI_NO_ZERO_VALUE_TRADE_ITEMS)2737 if((iItemValue > 0) && (-iItemValue + iTotalValue >= iAmountUnderWeWillOffer))2738#else2739 if(-iItemValue + iTotalValue >= iAmountUnderWeWillOffer)2740#endif 2741 {2742 pDeal->AddAllowEmbassy(eMyPlayer);2743 iTotalValue = GetDealValue(pDeal, iValueImOffering, iValueTheyreOffering, bUseEvenValue);2744 }2745 }2746 }2747 }2748 }2749}