Page 1 of 1

Unit upkeep inflation currently affects manpower and metal upkeep, not just money — is this intended?

Posted: Sat Oct 24, 2026 1:15 am
by duirixuanyan
Hi everyone,

I've been digging into the upkeep code (`Unit.BSF` and `Faction_Recruitment.CalcUpkeep`) and found something that looks like a mismatch between design intent and actual implementation. I'd like to check whether this is intended.

What the comment says it should do

The function's own comment is explicit:

Code: Select all

// UPKEEP INFLATION COST
// This does not apply in balanced or easy difficulty for human
// Some units are costlier ([b]in money only[/b]) for each unit on map beyond the first (buying and upkeeping)
// To avoid checking the index of the unit (to get a formula identical to the inflation cost from buying)
// We multiply inflation cost by total unit count, but we then divide the result by 5
// The breakpoint is at 20 units, before, this formula favors the faction, so it should be 'kind' enough most of the time
So the intent is clearly money only.

Code: Select all

extraPerc = GetUnitInt(unitID, $UNIT_MONEYINFLATIONCOST);
...
extraPerc = DivideAndRound(extraPerc * count, UPKEEP_INCMONEY_DIVIDER);
What actually happens in `Faction_Recruitment_CalcUpkeep`

The result is added to a shared `localCoeff`:

Code: Select all

localCoeff += Unit_UpkeepInflationCoeff(unitID);
...
moneyCoeff  = localCoeff + CallFunctionInScenario(...TRUE, FALSE, FALSE);
manpwCoeff  = localCoeff + CallFunctionInScenario(...FALSE, TRUE, FALSE);
metalCoeff  = localCoeff + CallFunctionInScenario(...FALSE, FALSE, TRUE);

moneyCost    = DivideAndRound(moneyCost    * moneyCoeff,  100);
manpowerCost = DivideAndRound(manpowerCost * manpwCoeff,  100);
metalCost    = DivideAndRound(metalCost    * metalCoeff,  100);
Because `localCoeff` feeds all three coefficients, `Unit_UpkeepInflationCoeff` ends up affecting money, manpower, and metal upkeep.

Questions
  1. Is it intended that same-template inflation affects manpower and metal upkeep in the actual upkeep settlement (`Faction_Recruitment_CalcUpkeep`)?
  2. If the intent is money-only, would the fix be to add `Unit_UpkeepInflationCoeff` only to `moneyCoeff` rather than to the shared `localCoeff`?
Any clarification would be appreciated. Thanks!