How to adjust coup success rates?

Deadstarre

Expert
Joined
Nov 1, 2015
Messages
960
Location
New York
rank 3 spy for example always has a %70 chance of success. Anyone know where this can be altered? I looked through the EspionageOverview lua but didn't find it
 
ugh. Im not about to download software so i can even read it, so I suppose its worth saying then; its strange the success rate doesn't take into account difference of influence - like I can be at -60 influence, Ghandi can be at 2000 influence, yet if I send my rank 3 spy there I have a %70 chance to gain 2060 influence. it seems intuitive the difference in influence should affect the rate of success (did it used to?).

its fine, if suboptimal for AI reasons, that it works this way, but if so %70 is a bit high for rate of success. its very easy/quick/safe to level up spies as diplomats and wreak havoc on the map with that kind of rate.
 
ugh. Im not about to download software so i can even read it, so I suppose its worth saying then; its strange the success rate doesn't take into account difference of influence - like I can be at -60 influence, Ghandi can be at 2000 influence, yet if I send my rank 3 spy there I have a %70 chance to gain 2060 influence. it seems intuitive the difference in influence should affect the rate of success (did it used to?).

its fine, if suboptimal for AI reasons, that it works this way, but if so %70 is a bit high for rate of success. its very easy/quick/safe to level up spies as diplomats and wreak havoc on the map with that kind of rate.

If you want the code:

Code:
/// GetCoupChangeOfSuccess - What is the % chance of success that a spy will be able to pull off a coup?
int CvPlayerEspionage::GetCoupChanceOfSuccess(uint uiSpyIndex)
{
    // if you can't stage a coup, then the likelihood is zero!
    if(!CanStageCoup(uiSpyIndex))
    {
        return 0;
    }

    CvCity* pCity = GetCityWithSpy(uiSpyIndex);
    CvAssertMsg(pCity, "No city");
    if(!pCity)
    {
        return 0;
    }

    CvCityEspionage* pCityEspionage = pCity->GetCityEspionage();
    CvAssertMsg(pCityEspionage, "No city espionage");
    if(!pCityEspionage)
    {
        return 0;
    }

    PlayerTypes eCityOwner = pCity->getOwner();
    CvAssertMsg(GET_PLAYER(eCityOwner).isMinorCiv(), "Owner is not a minor civ");
    if(!GET_PLAYER(eCityOwner).isMinorCiv())
    {
        return 0;
    }

    CvMinorCivAI* pMinorCivAI = GET_PLAYER(eCityOwner).GetMinorCivAI();
    CvAssertMsg(pMinorCivAI, "pMinorCivAI is null");
    if(!pMinorCivAI)
    {
        return 0;
    }

    PlayerTypes eAllyPlayer = pMinorCivAI->GetAlly();
    int iAllySpyRank = 0;
    bool bNoAllySpy = true;
    if(pCityEspionage->m_aiSpyAssignment[eAllyPlayer] != -1)
    {
        int iAllySpyIndex = pCityEspionage->m_aiSpyAssignment[eAllyPlayer];
        iAllySpyRank = GET_PLAYER(eAllyPlayer).GetEspionage()->m_aSpyList[iAllySpyIndex].m_eRank;
        bNoAllySpy = true;
    }

    int iAllyInfluence = pMinorCivAI->GetEffectiveFriendshipWithMajorTimes100(eAllyPlayer);
    int iMyInfluence = pMinorCivAI->GetEffectiveFriendshipWithMajorTimes100(m_pPlayer->GetID());
    int iDeltaInfluence = iAllyInfluence - iMyInfluence;
#if defined(MOD_BALANCE_CORE)
    iDeltaInfluence /= 2;
    if(iDeltaInfluence >  7000)
    {
        iDeltaInfluence = 7000;
    }
#endif
    //float fNobodyBonus = 0.5;
    //float fMultiplyConstant = 3.0f;
    //float fSpyLevelDeltaZero = 0.0f;
    //float fSpyLevelDeltaOne = 1.5f;
    //float fSpyLevelDeltaTwo = 2.25;
    //float fSpyLevelDeltaThree = 3.0f;

    float fNobodyBonus = GC.getESPIONAGE_COUP_NOBODY_BONUS();
    float fMultiplyConstant = GC.getESPIONAGE_COUP_MULTIPLY_CONSTANT();
    float fSpyLevelDeltaZero = GC.getESPIONAGE_COUP_SPY_LEVEL_DELTA_ZERO();
    float fSpyLevelDeltaOne = GC.getESPIONAGE_COUP_SPY_LEVEL_DELTA_ONE();
    float fSpyLevelDeltaTwo = GC.getESPIONAGE_COUP_SPY_LEVEL_DELTA_TWO();
    float fSpyLevelDeltaThree = GC.getESPIONAGE_COUP_SPY_LEVEL_DELTA_THREE();
    float fSpyLevelDeltaFour = GC.getESPIONAGE_COUP_SPY_LEVEL_DELTA_FOUR();

    float fAllySpyValue = 0.0f;
    float fMySpyValue = 0.0;

    int iMySpyRank = m_aSpyList[uiSpyIndex].m_eRank;
    iMySpyRank += m_pPlayer->GetCulture()->GetInfluenceCityStateSpyRankBonus(eCityOwner);
    switch (iMySpyRank)
    {
    case 0:
        fMySpyValue = fSpyLevelDeltaZero;
        break;
    case 1:
        fMySpyValue = fSpyLevelDeltaOne;
        break;
    case 2:
        fMySpyValue = fSpyLevelDeltaTwo;
        break;
    case 3:
        fMySpyValue = fSpyLevelDeltaThree;
        break;
    case 4:
        fMySpyValue = fSpyLevelDeltaFour;
        break;
    }

    switch (iAllySpyRank)
    {
    case 0:
        fAllySpyValue = fSpyLevelDeltaZero;
        break;
    case 1:
        fAllySpyValue = fSpyLevelDeltaOne;
        break;
    case 2:
        fAllySpyValue = fSpyLevelDeltaTwo;
        break;
    }   

    float fSpyMultipier = fAllySpyValue - fMySpyValue + fMultiplyConstant;
    if (bNoAllySpy)
    {
        fSpyMultipier *= fNobodyBonus;
    }

    int iResultPercentage = 100 - (int)((iDeltaInfluence * fSpyMultipier) / 100);


#if defined(MOD_BALANCE_CORE)
    if (MOD_BALANCE_CORE_SPIES_ADVANCED)
    {
        iResultPercentage *= (100 + m_pPlayer->GetPlayerPolicies()->GetNumericModifier(POLICYMOD_RIGGING_ELECTION_MODIFIER));
        iResultPercentage /= 100;
    }
#endif

    if(iResultPercentage > 70)
    {
        iResultPercentage = 70;
    }
#if defined(MOD_BALANCE_CORE)
    else if(iResultPercentage < 5)
    {
        iResultPercentage = 5;
    }
#else
    else if(iResultPercentage < 0)
    {
        iResultPercentage = 0;
    }
#endif
    //int iAdjustedAllyInfluenceTimes100 = iAllyInfluence * (100 + m_aSpyList[uiSpyIndex].m_eRank * 100);
    //int iAdjustedAllyInfluence = iAdjustedAllyInfluenceTimes100 / 100;
    //int iResultPercentage = 0;
    //if (iAdjustedAllyInfluence != 0)
    //{
    //    iResultPercentage = 100 - ((iDeltaInfluence * 100) / iAdjustedAllyInfluence);
    //}

    return iResultPercentage;
}

There are a few defines there (the GC.get values) that will be in the database. Probably the GlobalDefines.xml file. You can tinker with them if you want.

G
 
found them. will lead to other fruitful efforts as well. apparently

<Row Name="ESPIONAGE_INFLUENCE_LOST_FOR_RIGGED_ELECTION">
<Value>5</Value>

that is a paltry sum in the CBP! =) thanks
 
so... there is something in the code to adjust spy % for difference of influence

iDeltaInfluence = iAllyInfluence - iMyInfluence

int iResultPercentage = 100 - (int)((iDeltaInfluence * fSpyMultipier) / 100);



I guess just overall the numbers have been arranged so it ultimately becomes insignificant? I know i've been behind by thousands of influence and still had a %70 rate of success.


right here I guess?

#if defined(MOD_BALANCE_CORE)
iDeltaInfluence /= 2;

not sure Im understanding that equation... sigh math.
 
Last edited:
so... there is something in the code to adjust spy % for difference of influence

iDeltaInfluence = iAllyInfluence - iMyInfluence

int iResultPercentage = 100 - (int)((iDeltaInfluence * fSpyMultipier) / 100);



I guess just overall the numbers have been arranged so it ultimately becomes insignificant? I know i've been behind by thousands of influence and still had a %70 rate of success.


right here I guess?

#if defined(MOD_BALANCE_CORE)
iDeltaInfluence /= 2;

not sure Im understanding that equation... sigh math.
Something /= other_thing

Is the same as

Something = Something / other_thing

Which is the same as saying

Make iDeltaInfluence half its value.
 
i'm guessing thats halving its significance in the end. I can see its purposefully put in there to CBP from the vanilla code but I wonder why, the other inserted CBP stuff makes sense to me.

all the explanations are right there but ultimately I can't work through the math, i'm very likely to do a calculation out of its proper order and mess the whole thing up. if someone has smarts and time they should just assume a 1000 influence difference and a spy level 3 (with no opposing spy in the city, I think that must be a delta level four case) and work through the math to see what the iresultpercentage is.

only thing I dont get is why spyleveldelta 3 = 3.0 there when in the defines (which cbp isnt altering I believe) its

"ESPIONAGE_COUP_SPY_LEVEL_DELTA_THREE"
<Value>2.60</Value>


the other numbers up there are all right (nobody bonus, multiplyconstant etc). and doesnt look like anyone put in a number for delta four but its

ESPIONAGE_COUP_SPY_LEVEL_DELTA_FOUR"
<Value>2.80</Value>

randomly tinkering with the numbers could wind up with a desired effect, but I wont be able to edit that iDeltaInfluence halving anyway
 
Top Bottom