CvDealAI::GetThirdPartyWarValue(bool, PlayerTypes, TeamTypes)
- Defined in
- CvDealAI.cpp, line 2116
- Class
- CvDealAI
- Hook name
CivHooks::CvDealAI_GetThirdPartyWarValue
Hooks
static bool BeforeCvDealAI_GetThirdPartyWarValue(CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, TeamTypes eWithTeam, int& result);static void AfterCvDealAI_GetThirdPartyWarValue(CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, TeamTypes eWithTeam, int& result);static int ReplaceCvDealAI_GetThirdPartyWarValue(int (*original)(CvDealAI*, bool, PlayerTypes, TeamTypes), CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, TeamTypes eWithTeam);CivRegisterBefore<CivHooks::CvDealAI_GetThirdPartyWarValue>(host, &BeforeCvDealAI_GetThirdPartyWarValue);CivRegisterAfter<CivHooks::CvDealAI_GetThirdPartyWarValue>(host, &AfterCvDealAI_GetThirdPartyWarValue);CivRegisterReplace<CivHooks::CvDealAI_GetThirdPartyWarValue>(host, &ReplaceCvDealAI_GetThirdPartyWarValue);
Code
2115/// What is the value of war with eWithPlayer?2116int CvDealAI::GetThirdPartyWarValue(bool bFromMe, PlayerTypes eOtherPlayer, TeamTypes eWithTeam)2117{2118 CvAssertMsg(GetPlayer()->GetID() != eOtherPlayer, "DEAL_AI: Trying to check value of a Third Party War with oneself. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");21192120 int iItemValue = 0;21212122 CvDiplomacyAI* pDiploAI = GetPlayer()->GetDiplomacyAI();21232124 // How much does this AI like to go to war? If it's a 3 or less, never accept2125 int iWarApproachWeight = pDiploAI->GetPersonalityMajorCivApproachBias(MAJOR_CIV_APPROACH_WAR);2126 if(bFromMe && iWarApproachWeight < 4)2127 return 100000;212821292130 PlayerTypes eWithPlayer = NO_PLAYER;2131 // find the first player associated with the team2132 for (uint ui = 0; ui < MAX_CIV_PLAYERS; ui++)2133 {2134 PlayerTypes ePlayer = (PlayerTypes)ui;2135 if (GET_PLAYER(ePlayer).getTeam() == eWithTeam) 2136 {2137 eWithPlayer = ePlayer;2138 break;2139 }2140 }2141 WarProjectionTypes eWarProjection = pDiploAI->GetWarProjection(eWithPlayer);21422143 EraTypes eOurEra = GET_TEAM(GetPlayer()->getTeam()).GetCurrentEra();21442145 MajorCivOpinionTypes eOpinionTowardsAskingPlayer = pDiploAI->GetMajorCivOpinion(eOtherPlayer);2146 MajorCivOpinionTypes eOpinionTowardsWarPlayer = NO_MAJOR_CIV_OPINION_TYPE;2147 MinorCivApproachTypes eMinorApproachTowardsWarPlayer = NO_MINOR_CIV_APPROACH;21482149 bool bMinor = false;21502151 // Minor2152 if(GET_PLAYER(eWithPlayer).isMinorCiv())2153 {2154 bMinor = true;2155 eMinorApproachTowardsWarPlayer = pDiploAI->GetMinorCivApproach(eWithPlayer);2156 }2157 // Major2158 else2159 eOpinionTowardsWarPlayer = pDiploAI->GetMajorCivOpinion(eWithPlayer);21602161 // From me2162 if(bFromMe)2163 {2164 if(eWarProjection >= WAR_PROJECTION_GOOD)2165 iItemValue = 400;2166 else if(eWarProjection == WAR_PROJECTION_UNKNOWN)2167 iItemValue = 600;2168 else if(eWarProjection == WAR_PROJECTION_STALEMATE)2169 iItemValue = 1000;2170 else2171 iItemValue = 50000;21722173 // Add 50 gold per era2174 int iExtraCost = eOurEra * 50;2175 iItemValue += iExtraCost;21762177 // Modify based on our War Approach2178 int iWarBias = /*5*/ GC.getDEFAULT_FLAVOR_VALUE() - iWarApproachWeight;2179 int iWarMod = iWarBias * 10; // EX: 5 - War Approach of 9 = -4 * 10 = -40% cost2180 iWarMod *= iItemValue;2181 iWarMod /= 100;21822183 iItemValue += iWarMod;21842185 // Minor2186 if(bMinor)2187 {2188 if(eMinorApproachTowardsWarPlayer == MINOR_CIV_APPROACH_FRIENDLY)2189 iItemValue = 100000;2190 else if(eMinorApproachTowardsWarPlayer == MINOR_CIV_APPROACH_PROTECTIVE)2191 iItemValue = 100000;2192 }2193 // Major2194 else2195 {2196 // Modify for our feelings towards the player we're would go to war with2197 if(eOpinionTowardsWarPlayer == MAJOR_CIV_OPINION_UNFORGIVABLE)2198 {2199 iItemValue *= 25;2200 iItemValue /= 100;2201 }2202 else if(eOpinionTowardsWarPlayer == MAJOR_CIV_OPINION_ENEMY)2203 {2204 iItemValue *= 50;2205 iItemValue /= 100;2206 }2207 else if(eOpinionTowardsWarPlayer == MAJOR_CIV_OPINION_COMPETITOR)2208 {2209 iItemValue *= 75;2210 iItemValue /= 100;2211 }2212 }22132214 // Modify for our feelings towards the asking player2215 if(eOpinionTowardsAskingPlayer == MAJOR_CIV_OPINION_ALLY)2216 {2217 iItemValue *= 50;2218 iItemValue /= 100;2219 }2220 else if(eOpinionTowardsAskingPlayer == MAJOR_CIV_OPINION_FRIEND)2221 {2222 iItemValue *= 75;2223 iItemValue /= 100;2224 }2225 else if(eOpinionTowardsAskingPlayer == MAJOR_CIV_OPINION_FAVORABLE)2226 {2227 iItemValue *= 85;2228 iItemValue /= 100;2229 }2230 else if(eOpinionTowardsAskingPlayer == MAJOR_CIV_OPINION_COMPETITOR)2231 {2232 iItemValue *= 125;2233 iItemValue /= 100;2234 }2235 }22362237 // From them2238 else2239 {2240 // Minor2241 if(bMinor)2242 iItemValue = -100000;22432244 // Major2245 else2246 {2247 // Modify for our feelings towards the player they would go to war with2248 if(eOpinionTowardsWarPlayer == MAJOR_CIV_OPINION_UNFORGIVABLE)2249 iItemValue = 200;2250 else if(eOpinionTowardsWarPlayer == MAJOR_CIV_OPINION_ENEMY)2251 iItemValue = 100;2252 else2253 iItemValue = -100000;2254 }2255 }22562257 return iItemValue;2258}
Calls
- CvDealAI::GetPlayer()
- CvDiplomacyAI::GetMajorCivOpinion(PlayerTypes) const
- CvDiplomacyAI::GetMinorCivApproach(PlayerTypes) const
- CvDiplomacyAI::GetPersonalityMajorCivApproachBias(MajorCivApproachTypes) const
- CvDiplomacyAI::GetWarProjection(PlayerTypes) const
- CvGlobals::getDEFAULT_FLAVOR_VALUE()
- CvPlayer::GetDiplomacyAI() const
- CvPlayer::getTeam() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvTeam::GetCurrentEra() const
- CvTeam::getTeam(TeamTypes)