Hooks
static bool BeforeCvDealAI_GetResearchAgreementValue(CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue, int& result);static void AfterCvDealAI_GetResearchAgreementValue(CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue, int& result);static int ReplaceCvDealAI_GetResearchAgreementValue(int (*original)(CvDealAI*, bool, PlayerTypes, bool), CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue);CivRegisterBefore<CivHooks::CvDealAI_GetResearchAgreementValue>(host, &BeforeCvDealAI_GetResearchAgreementValue);CivRegisterAfter<CivHooks::CvDealAI_GetResearchAgreementValue>(host, &AfterCvDealAI_GetResearchAgreementValue);CivRegisterReplace<CivHooks::CvDealAI_GetResearchAgreementValue>(host, &ReplaceCvDealAI_GetResearchAgreementValue);
Code
1855/// How much is a Research Agreement worth?1856int CvDealAI::GetResearchAgreementValue(bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue)1857{1858 CvAssertMsg(GetPlayer()->GetID() != eOtherPlayer, "DEAL_AI: Trying to check value of a Research Agreement with oneself. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");18591860 int iItemValue = 100;18611862 if(bFromMe)1863 {1864 // if they are ahead of me in tech by one or more eras ratchet up the value since they are more likely to get a good tech than I am1865 EraTypes eMyEra = GET_TEAM(GetPlayer()->getTeam()).GetCurrentEra();1866 EraTypes eTheirEra = GET_TEAM(GET_PLAYER(eOtherPlayer).getTeam()).GetCurrentEra();18671868 int iAdditionalValue = iItemValue * max(0,(int)(eTheirEra-eMyEra));1869 iItemValue += iAdditionalValue;18701871 // Approach is important1872 switch(GetPlayer()->GetDiplomacyAI()->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ true))1873 {1874 case MAJOR_CIV_APPROACH_HOSTILE:1875 iItemValue *= 1000;1876 break;1877 case MAJOR_CIV_APPROACH_GUARDED:1878 iItemValue *= 100;1879 break;1880 case MAJOR_CIV_APPROACH_AFRAID:1881 iItemValue *= 80;1882 break;1883 case MAJOR_CIV_APPROACH_FRIENDLY:1884 iItemValue *= 100;1885 break;1886 case MAJOR_CIV_APPROACH_NEUTRAL:1887 iItemValue *= 100;1888 break;1889 default:1890 CvAssertMsg(false, "DEAL_AI: AI player has no valid Approach for Research Agreement valuation. Please send Jon this with your last 5 autosaves and what changelist # you're playing.")1891 iItemValue *= 100;1892 break;1893 }1894 iItemValue /= 100;18951896 }18971898 // Are we trying to find the middle point between what we think this item is worth and what another player thinks it's worth?1899 if(bUseEvenValue)1900 {1901 iItemValue += GET_PLAYER(eOtherPlayer).GetDealAI()->GetResearchAgreementValue(!bFromMe, GetPlayer()->GetID(), /*bUseEvenValue*/ false);19021903 iItemValue /= 2;1904 }19051906 return iItemValue;1907}