Something wrong with DoUpdateTotalUnhappiness?

glider1

Deity
Joined
May 29, 2006
Messages
2,905
Location
Where animals hop not run
In the function DoUpdateTotalUnhappiness() for the case of !MOD_BALANCE_CORE_HAPPINESS unhappiness is added to get a final value except that right at the end the modifier is multiplied. In the comment it says the AI gets "reduced" unhappiness but in the handicap file the AI modifier is zero for a lot of difficulties so isn't the final iUnhappiness for the AI equal to zero?

Spoiler :
Code:
/// How much of our Happiness is being used up? (Population + Units)
int CvPlayer::DoUpdateTotalUnhappiness(CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted)
{

   if (isMinorCiv() || isBarbarian())
    {
        return 0;
    }

    int iUnhappiness = 0;

    if (!MOD_BALANCE_CORE_HAPPINESS)
    {

        // City Count Unhappiness
        iUnhappiness += GetUnhappinessFromCityCount(pAssumeCityAnnexed, pAssumeCityPuppeted);

        // Occupied City Count Unhappiness
        iUnhappiness += GetUnhappinessFromCapturedCityCount(pAssumeCityAnnexed, pAssumeCityPuppeted);

        // City Population Unhappiness
        iUnhappiness += GetUnhappinessFromCityPopulation(pAssumeCityAnnexed, pAssumeCityPuppeted);

        // Occupied City Population Unhappiness
        iUnhappiness += GetUnhappinessFromOccupiedCities(pAssumeCityAnnexed, pAssumeCityPuppeted);

        // Unit Unhappiness (Builders)
        iUnhappiness += GetUnhappinessFromUnits();

        iUnhappiness /= 100;
    }

    iUnhappiness += GetCulture()->GetPublicOpinionUnhappiness();

    if (MOD_BALANCE_CORE_JFD && !isMinorCiv() && !isBarbarian())
    {
        iUnhappiness += getUnhappinessFromCityJFDSpecial();
    }

    if (MOD_BALANCE_CORE_HAPPINESS && !isMinorCiv() && !isBarbarian())
    {
        iUnhappiness += GetUnhappinessFromWarWeariness();
    }
    if (!MOD_BALANCE_CORE_HAPPINESS)
    {
        // AI gets reduced Unhappiness on higher levels
        if (!isHuman())
        {
            iUnhappiness *= GC.getGame().getHandicapInfo().getAIUnhappinessPercent();
            iUnhappiness /= 100;
        }
    }

    SetUnhappiness(iUnhappiness);
    return iUnhappiness;
}

I'm thinking it should be:
Code:
    if (!MOD_BALANCE_CORE_HAPPINESS)
    {
       // AI gets reduced Unhappiness on higher levels
        if (!isHuman())
        {
           iUnhappiness += GC.getGame().getHandicapInfo().getAIUnhappinessPercent();

Thanks and sorry if I'm confused been in lockdown too long.
 
Last edited:
In the function DoUpdateTotalUnhappiness() for the case of !MOD_BALANCE_CORE_HAPPINESS unhappiness is added to get a final value except that right at the end the modifier is multiplied. In the comment it says the AI gets "reduced" unhappiness but in the handicap file the AI modifier is zero for a lot of difficulties so isn't the final iUnhappiness for the AI equal to zero?

Spoiler :
Code:
/// How much of our Happiness is being used up? (Population + Units)
int CvPlayer::DoUpdateTotalUnhappiness(CvCity* pAssumeCityAnnexed, CvCity* pAssumeCityPuppeted)
{

   if (isMinorCiv() || isBarbarian())
    {
        return 0;
    }

    int iUnhappiness = 0;

    if (!MOD_BALANCE_CORE_HAPPINESS)
    {

        // City Count Unhappiness
        iUnhappiness += GetUnhappinessFromCityCount(pAssumeCityAnnexed, pAssumeCityPuppeted);

        // Occupied City Count Unhappiness
        iUnhappiness += GetUnhappinessFromCapturedCityCount(pAssumeCityAnnexed, pAssumeCityPuppeted);

        // City Population Unhappiness
        iUnhappiness += GetUnhappinessFromCityPopulation(pAssumeCityAnnexed, pAssumeCityPuppeted);

        // Occupied City Population Unhappiness
        iUnhappiness += GetUnhappinessFromOccupiedCities(pAssumeCityAnnexed, pAssumeCityPuppeted);

        // Unit Unhappiness (Builders)
        iUnhappiness += GetUnhappinessFromUnits();

        iUnhappiness /= 100;
    }

    iUnhappiness += GetCulture()->GetPublicOpinionUnhappiness();

    if (MOD_BALANCE_CORE_JFD && !isMinorCiv() && !isBarbarian())
    {
        iUnhappiness += getUnhappinessFromCityJFDSpecial();
    }

    if (MOD_BALANCE_CORE_HAPPINESS && !isMinorCiv() && !isBarbarian())
    {
        iUnhappiness += GetUnhappinessFromWarWeariness();
    }
    if (!MOD_BALANCE_CORE_HAPPINESS)
    {
        // AI gets reduced Unhappiness on higher levels
        if (!isHuman())
        {
            iUnhappiness *= GC.getGame().getHandicapInfo().getAIUnhappinessPercent();
            iUnhappiness /= 100;
        }
    }

    SetUnhappiness(iUnhappiness);
    return iUnhappiness;
}

I'm thinking it should be:
Code:
    if (!MOD_BALANCE_CORE_HAPPINESS)
    {
       // AI gets reduced Unhappiness on higher levels
        if (!isHuman())
        {
           iUnhappiness += GC.getGame().getHandicapInfo().getAIUnhappinessPercent();

Thanks and sorry if I'm confused been in lockdown too long.

The Community Patch only version uses !MOD_BALANCE_CORE_HAPPINESS, and the vanilla values for AIUnhappinessPercent are used, not the CBP version.
 
Top Bottom