CvDealAI::GetThirdPartyPeaceValue(bool, PlayerTypes, TeamTypes)
- Defined in
- CvDealAI.cpp, line 1997
- Class
- CvDealAI
- Hook name
CivHooks::CvDealAI_GetThirdPartyPeaceValue
Hooks
static bool BeforeCvDealAI_GetThirdPartyPeaceValue(CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, TeamTypes eWithTeam, int& result);static void AfterCvDealAI_GetThirdPartyPeaceValue(CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, TeamTypes eWithTeam, int& result);static int ReplaceCvDealAI_GetThirdPartyPeaceValue(int (*original)(CvDealAI*, bool, PlayerTypes, TeamTypes), CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, TeamTypes eWithTeam);CivRegisterBefore<CivHooks::CvDealAI_GetThirdPartyPeaceValue>(host, &BeforeCvDealAI_GetThirdPartyPeaceValue);CivRegisterAfter<CivHooks::CvDealAI_GetThirdPartyPeaceValue>(host, &AfterCvDealAI_GetThirdPartyPeaceValue);CivRegisterReplace<CivHooks::CvDealAI_GetThirdPartyPeaceValue>(host, &ReplaceCvDealAI_GetThirdPartyPeaceValue);
Code
1996/// What is the value of peace with eWithTeam? NOTE: This deal item should be disabled if eWithTeam doesn't want to go to peace1997int CvDealAI::GetThirdPartyPeaceValue(bool bFromMe, PlayerTypes eOtherPlayer, TeamTypes eWithTeam)1998{1999 CvAssertMsg(GetPlayer()->GetID() != eOtherPlayer, "DEAL_AI: Trying to check value of a Third Party Peace with oneself. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");20002001 int iItemValue = 0;20022003 CvDiplomacyAI* pDiploAI = GetPlayer()->GetDiplomacyAI();20042005 PlayerTypes eWithPlayer = NO_PLAYER;20062007 // find the first player associated with the team2008 for (uint ui = 0; ui < MAX_CIV_PLAYERS; ui++)2009 {2010 PlayerTypes ePlayer = (PlayerTypes)ui;2011 if (GET_PLAYER(ePlayer).isAlive() && GET_PLAYER(ePlayer).getTeam() == eWithTeam) 2012 {2013 eWithPlayer = ePlayer;2014 break;2015 }2016 }20172018 CvAssertMsg(eWithPlayer != NO_PLAYER, "eWithPlayer could not be found");2019 if (eWithPlayer == NO_PLAYER)2020 {2021 return 0;2022 }20232024 WarProjectionTypes eWarProjection = pDiploAI->GetWarProjection(eWithPlayer);20252026 EraTypes eOurEra = GET_TEAM(GetPlayer()->getTeam()).GetCurrentEra();20272028 MajorCivOpinionTypes eOpinionTowardsAskingPlayer = pDiploAI->GetMajorCivOpinion(eOtherPlayer);2029 MajorCivOpinionTypes eOpinionTowardsWarPlayer = NO_MAJOR_CIV_OPINION_TYPE;20302031 bool bMinor = false;20322033 // Minor2034 if(GET_PLAYER(eWithPlayer).isMinorCiv())2035 {2036 // if we're at war with the opponent, then this must be a peace deal. In this case we should evaluate minor civ peace deals as zero2037 if (GET_TEAM(m_pPlayer->getTeam()).isAtWar(GET_PLAYER(eOtherPlayer).getTeam()))2038 {2039 PlayerTypes eMinorAlly = GET_PLAYER(eWithPlayer).GetMinorCivAI()->GetAlly();2040 // if they are allied with the city state or we are allied with the city state2041 if (eMinorAlly == eOtherPlayer || eMinorAlly == m_pPlayer->GetID())2042 {2043 return 0;2044 }2045 }20462047 bMinor = true;2048 }2049 // Major2050 else2051 eOpinionTowardsWarPlayer = pDiploAI->GetMajorCivOpinion(eWithPlayer);20522053 // From me2054 if(bFromMe)2055 {2056 if(eWarProjection == WAR_PROJECTION_VERY_GOOD)2057 iItemValue = 600;2058 else if(eWarProjection == WAR_PROJECTION_GOOD)2059 iItemValue = 400;2060 else if(eWarProjection == WAR_PROJECTION_UNKNOWN)2061 iItemValue = 250;2062 else2063 iItemValue = 200;20642065 // Add 50 gold per era2066 int iExtraCost = eOurEra * 50;2067 iItemValue += iExtraCost;20682069 // Minors2070 if(bMinor)2071 {2072 }2073 // Majors2074 else2075 {2076 // Modify for our feelings towards the player we're at war with2077 if(eOpinionTowardsWarPlayer == MAJOR_CIV_OPINION_UNFORGIVABLE)2078 {2079 iItemValue *= 300;2080 iItemValue /= 100;2081 }2082 else if(eOpinionTowardsWarPlayer == MAJOR_CIV_OPINION_ENEMY)2083 {2084 iItemValue *= 200;2085 iItemValue /= 100;2086 }2087 }20882089 // Modify for our feelings towards the asking player2090 if(eOpinionTowardsAskingPlayer == MAJOR_CIV_OPINION_ALLY)2091 {2092 iItemValue *= 30;2093 iItemValue /= 100;2094 }2095 else if(eOpinionTowardsAskingPlayer == MAJOR_CIV_OPINION_FRIEND)2096 {2097 iItemValue *= 50;2098 iItemValue /= 100;2099 }2100 else if(eOpinionTowardsAskingPlayer == MAJOR_CIV_OPINION_FAVORABLE)2101 {2102 iItemValue *= 75;2103 iItemValue /= 100;2104 }2105 }2106 // From them2107 else2108 {2109 iItemValue = -10000;2110 }21112112 return iItemValue;2113}
Calls
- CvDealAI::GetPlayer()
- CvDiplomacyAI::GetMajorCivOpinion(PlayerTypes) const
- CvDiplomacyAI::GetWarProjection(PlayerTypes) const
- CvMinorCivAI::GetAlly() const
- CvPlayer::GetDiplomacyAI() const
- CvPlayer::GetID() const
- CvPlayer::GetMinorCivAI() const
- CvPlayer::getTeam() const
- CvPlayer::isAlive() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvTeam::GetCurrentEra() const
- CvTeam::getTeam(TeamTypes)
- CvTeam::isAtWar(TeamTypes) const