CvPlayerEspionage::GetCoupChanceOfSuccess(uint)
- Defined in
- CvEspionageClasses.cpp, line 2097
- Class
- CvPlayerEspionage
- Hook name
CivHooks::CvPlayerEspionage_GetCoupChanceOfSuccess
Hooks
static bool BeforeCvPlayerEspionage_GetCoupChanceOfSuccess(CvPlayerEspionage* self, uint uiSpyIndex, int& result);static void AfterCvPlayerEspionage_GetCoupChanceOfSuccess(CvPlayerEspionage* self, uint uiSpyIndex, int& result);static int ReplaceCvPlayerEspionage_GetCoupChanceOfSuccess(int (*original)(CvPlayerEspionage*, uint), CvPlayerEspionage* self, uint uiSpyIndex);CivRegisterBefore<CivHooks::CvPlayerEspionage_GetCoupChanceOfSuccess>(host, &BeforeCvPlayerEspionage_GetCoupChanceOfSuccess);CivRegisterAfter<CivHooks::CvPlayerEspionage_GetCoupChanceOfSuccess>(host, &AfterCvPlayerEspionage_GetCoupChanceOfSuccess);CivRegisterReplace<CivHooks::CvPlayerEspionage_GetCoupChanceOfSuccess>(host, &ReplaceCvPlayerEspionage_GetCoupChanceOfSuccess);
Code
2096/// GetCoupChangeOfSuccess - What is the % chance of success that a spy will be able to pull off a coup?2097int CvPlayerEspionage::GetCoupChanceOfSuccess(uint uiSpyIndex)2098{2099 // if you can't stage a coup, then the likelihood is zero!2100 if(!CanStageCoup(uiSpyIndex))2101 {2102 return 0;2103 }21042105 CvCity* pCity = GetCityWithSpy(uiSpyIndex);2106 CvAssertMsg(pCity, "No city");2107 if(!pCity)2108 {2109 return 0;2110 }21112112 CvCityEspionage* pCityEspionage = pCity->GetCityEspionage();2113 CvAssertMsg(pCityEspionage, "No city espionage");2114 if(!pCityEspionage)2115 {2116 return 0;2117 }21182119 PlayerTypes eCityOwner = pCity->getOwner();2120 CvAssertMsg(GET_PLAYER(eCityOwner).isMinorCiv(), "Owner is not a minor civ");2121 if(!GET_PLAYER(eCityOwner).isMinorCiv())2122 {2123 return 0;2124 }21252126 CvMinorCivAI* pMinorCivAI = GET_PLAYER(eCityOwner).GetMinorCivAI();2127 CvAssertMsg(pMinorCivAI, "pMinorCivAI is null");2128 if(!pMinorCivAI)2129 {2130 return 0;2131 }21322133 PlayerTypes eAllyPlayer = pMinorCivAI->GetAlly();2134 int iAllySpyRank = 0;2135 bool bNoAllySpy = true;2136 if(pCityEspionage->m_aiSpyAssignment[eAllyPlayer] != -1)2137 {2138 int iAllySpyIndex = pCityEspionage->m_aiSpyAssignment[eAllyPlayer];2139 iAllySpyRank = GET_PLAYER(eAllyPlayer).GetEspionage()->m_aSpyList[iAllySpyIndex].m_eRank;2140 bNoAllySpy = true;2141 }21422143 int iAllyInfluence = pMinorCivAI->GetEffectiveFriendshipWithMajorTimes100(eAllyPlayer);2144 int iMyInfluence = pMinorCivAI->GetEffectiveFriendshipWithMajorTimes100(m_pPlayer->GetID());2145 int iDeltaInfluence = iAllyInfluence - iMyInfluence;21462147 //float fNobodyBonus = 0.5;2148 //float fMultiplyConstant = 3.0f;2149 //float fSpyLevelDeltaZero = 0.0f;2150 //float fSpyLevelDeltaOne = 1.5f;2151 //float fSpyLevelDeltaTwo = 2.25;2152 //float fSpyLevelDeltaThree = 3.0f;21532154 float fNobodyBonus = GC.getESPIONAGE_COUP_NOBODY_BONUS();2155 float fMultiplyConstant = GC.getESPIONAGE_COUP_MULTIPLY_CONSTANT();2156 float fSpyLevelDeltaZero = GC.getESPIONAGE_COUP_SPY_LEVEL_DELTA_ZERO();2157 float fSpyLevelDeltaOne = GC.getESPIONAGE_COUP_SPY_LEVEL_DELTA_ONE();2158 float fSpyLevelDeltaTwo = GC.getESPIONAGE_COUP_SPY_LEVEL_DELTA_TWO();2159 float fSpyLevelDeltaThree = GC.getESPIONAGE_COUP_SPY_LEVEL_DELTA_THREE();2160 float fSpyLevelDeltaFour = GC.getESPIONAGE_COUP_SPY_LEVEL_DELTA_FOUR();21612162 float fAllySpyValue = 0.0f;2163 float fMySpyValue = 0.0;21642165 int iMySpyRank = m_aSpyList[uiSpyIndex].m_eRank;2166 iMySpyRank += m_pPlayer->GetCulture()->GetInfluenceCityStateSpyRankBonus(eCityOwner);2167 switch (iMySpyRank)2168 {2169 case 0:2170 fMySpyValue = fSpyLevelDeltaZero;2171 break;2172 case 1:2173 fMySpyValue = fSpyLevelDeltaOne;2174 break;2175 case 2:2176 fMySpyValue = fSpyLevelDeltaTwo;2177 break;2178 case 3:2179 fMySpyValue = fSpyLevelDeltaThree;2180 break;2181 case 4:2182 fMySpyValue = fSpyLevelDeltaFour;2183 break;2184 }21852186 switch (iAllySpyRank)2187 {2188 case 0:2189 fAllySpyValue = fSpyLevelDeltaZero;2190 break;2191 case 1:2192 fAllySpyValue = fSpyLevelDeltaOne;2193 break;2194 case 2:2195 fAllySpyValue = fSpyLevelDeltaTwo;2196 break;2197 } 21982199 float fSpyMultipier = fAllySpyValue - fMySpyValue + fMultiplyConstant;2200 if (bNoAllySpy)2201 {2202 fSpyMultipier *= fNobodyBonus;2203 }22042205 int iResultPercentage = 100 - (int)((iDeltaInfluence * fSpyMultipier) / 100);22062207 if(iResultPercentage > 85)2208 {2209 iResultPercentage = 85;2210 }2211 else if(iResultPercentage < 0)2212 {2213 iResultPercentage = 0;2214 }22152216 //int iAdjustedAllyInfluenceTimes100 = iAllyInfluence * (100 + m_aSpyList[uiSpyIndex].m_eRank * 100);2217 //int iAdjustedAllyInfluence = iAdjustedAllyInfluenceTimes100 / 100;2218 //int iResultPercentage = 0;2219 //if (iAdjustedAllyInfluence != 0)2220 //{2221 // iResultPercentage = 100 - ((iDeltaInfluence * 100) / iAdjustedAllyInfluence);2222 //}222322242225 return iResultPercentage;2226}
Calls
BaseVector::operator[]- CvCity::GetCityEspionage() const
- CvCity::getOwner() const
- CvGlobals::getESPIONAGE_COUP_MULTIPLY_CONSTANT()
- CvGlobals::getESPIONAGE_COUP_NOBODY_BONUS()
- CvGlobals::getESPIONAGE_COUP_SPY_LEVEL_DELTA_FOUR()
- CvGlobals::getESPIONAGE_COUP_SPY_LEVEL_DELTA_ONE()
- CvGlobals::getESPIONAGE_COUP_SPY_LEVEL_DELTA_THREE()
- CvGlobals::getESPIONAGE_COUP_SPY_LEVEL_DELTA_TWO()
- CvGlobals::getESPIONAGE_COUP_SPY_LEVEL_DELTA_ZERO()
- CvMinorCivAI::GetAlly() const
- CvMinorCivAI::GetEffectiveFriendshipWithMajorTimes100(PlayerTypes)
- CvPlayer::GetCulture() const
- CvPlayer::GetEspionage() const
- CvPlayer::GetID() const
- CvPlayer::GetMinorCivAI() const
- CvPlayer::isMinorCiv() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerCulture::GetInfluenceCityStateSpyRankBonus(PlayerTypes) const
- CvPlayerEspionage::CanStageCoup(uint)
- CvPlayerEspionage::GetCityWithSpy(uint)
Firaxis::Array::operator[]