Community-patch-dll: Incorrect calculation of city combat strength

Created on 29 Jul 2020  路  3Comments  路  Source: LoneGazebo/Community-Patch-DLL

Unrelated to #6814 but equally impactful.

In the latest version(s?), city combat strength always increases by half of garrison's CS, even if the garrison unit has higher RCS than CS. Naval units also don't count as half.

    // Garrisoned Unit
    CvUnit* pGarrisonedUnit = GetGarrisonedUnit();
    if(pGarrisonedUnit)
    {
        int iStrengthFromGarrison = (pGarrisonedUnit->GetBaseCombatStrength() * 100) / /*300*/ GC.getCITY_STRENGTH_UNIT_DIVISOR();

        iStrengthValue += (iStrengthFromGarrison * 100);
    }

However, when calculating the RANGED combat strength, it subtracts half of garrison's max(CS, RCS), and half of that value for naval units.

            // We also remove the garrisoned unit's strength
            CvUnit* pGarrisonedUnit = GetGarrisonedUnit();
            if (pGarrisonedUnit)
            {
                int iStrengthFromGarrisonRaw = max(pGarrisonedUnit->GetBaseCombatStrength(), pGarrisonedUnit->GetBaseRangedCombatStrength());
                if (!pGarrisonedUnit->isNativeDomain(plot()))
                    iStrengthFromGarrisonRaw /= 2; //see getBestGarrison ... naval units make weaker garrisons

                int iStrengthFromGarrison = (iStrengthFromGarrisonRaw * 100) / /*300*/ GC.getCITY_STRENGTH_UNIT_DIVISOR();
                iValue -= (iStrengthFromGarrison * 100);
            }

Which leads to potential NEGATIVE ranged combat strength on cities.

image

All code snippets copied from CvCity.cpp

Fixed for upcoming version

Most helpful comment

image

All 3 comments

i have an idea! let's remove the ranged attacks from cities :)

image

no worries, just kidding ...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dape6509 picture dape6509  路  5Comments

wistak103 picture wistak103  路  6Comments

ilteroi picture ilteroi  路  7Comments

MRS-OBAMA picture MRS-OBAMA  路  3Comments

rustyshackle picture rustyshackle  路  10Comments