CvDealAI::GetEmbassyValue(bool, PlayerTypes, bool)
- Defined in
- CvDealAI.cpp, line 1517
- Class
- CvDealAI
- Hook name
CivHooks::CvDealAI_GetEmbassyValue
Hooks
static bool BeforeCvDealAI_GetEmbassyValue(CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue, int& result);static void AfterCvDealAI_GetEmbassyValue(CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue, int& result);static int ReplaceCvDealAI_GetEmbassyValue(int (*original)(CvDealAI*, bool, PlayerTypes, bool), CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue);CivRegisterBefore<CivHooks::CvDealAI_GetEmbassyValue>(host, &BeforeCvDealAI_GetEmbassyValue);CivRegisterAfter<CivHooks::CvDealAI_GetEmbassyValue>(host, &AfterCvDealAI_GetEmbassyValue);CivRegisterReplace<CivHooks::CvDealAI_GetEmbassyValue>(host, &ReplaceCvDealAI_GetEmbassyValue);
Code
1516// How much is an embassy worth?1517int CvDealAI::GetEmbassyValue(bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue)1518{1519 CvAssertMsg(GetPlayer()->GetID() != eOtherPlayer, "DEAL_AI: Trying to check value of a Embassy with oneself. Please send slewis this with your last 5 autosaves and what changelist # you're playing.");15201521 int iItemValue = 35;15221523 // Scale up or down by deal duration at this game speed1524 CvGameSpeedInfo *pkStdSpeedInfo = GC.getGameSpeedInfo((GameSpeedTypes)GC.getSTANDARD_GAMESPEED());1525 if (pkStdSpeedInfo)1526 {1527 iItemValue *= GC.getGame().getGameSpeedInfo().GetDealDuration();1528 iItemValue /= pkStdSpeedInfo->GetDealDuration();1529 }15301531 if(bFromMe) // giving the other player an embassy in my capital1532 {1533 // Approach is important1534 switch(GetPlayer()->GetDiplomacyAI()->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ true))1535 {1536 case MAJOR_CIV_APPROACH_HOSTILE:1537 iItemValue *= 250;1538 break;1539 case MAJOR_CIV_APPROACH_GUARDED:1540 iItemValue *= 130;1541 break;1542 case MAJOR_CIV_APPROACH_AFRAID:1543 iItemValue *= 80;1544 break;1545 case MAJOR_CIV_APPROACH_FRIENDLY:1546 iItemValue *= 100;1547 break;1548 case MAJOR_CIV_APPROACH_NEUTRAL:1549 iItemValue *= 100;1550 break;1551 default:1552 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.")1553 iItemValue *= 100;1554 break;1555 }1556 iItemValue /= 100;1557 }15581559 // Are we trying to find the middle point between what we think this item is worth and what another player thinks it's worth?1560 if(bUseEvenValue)1561 {1562 iItemValue += GET_PLAYER(eOtherPlayer).GetDealAI()->GetTradeAgreementValue(!bFromMe, GetPlayer()->GetID(), /*bUseEvenValue*/ false);15631564 iItemValue /= 2;1565 }15661567 return iItemValue;1568}
Calls
- CvDealAI::GetPlayer()
- CvDealAI::GetTradeAgreementValue(bool, PlayerTypes, bool)
- CvDiplomacyAI::GetMajorCivApproach(PlayerTypes, bool) const
- CvGame::getGameSpeedInfo() const
- CvGameSpeedInfo::GetDealDuration() const
- CvGlobals::getGame()
- CvGlobals::getGameSpeedInfo(GameSpeedTypes)
- CvGlobals::getSTANDARD_GAMESPEED()
- CvPlayer::GetDealAI() const
- CvPlayer::GetDiplomacyAI() const
- CvPlayer::GetID() const
- CvPlayerAI::getPlayer(PlayerTypes)