Rescale PP-Income (Mod)

A forum to discuss custom scenarios, campaigns and modding in general.

Moderators: Slitherine Core, The Lordz

Post Reply
Historion
Corporal - 5 cm Pak 38
Corporal - 5 cm Pak 38
Posts: 31
Joined: Wed Jul 30, 2014 10:41 pm

Rescale PP-Income (Mod)

Post by Historion »

1. Historic Tables

According to Paul Kennedy, The Rise and Fall of the Great Powers :
Table 18 : relative World-Industry-Production 1913 : USA 32%, Germany 14.8%, Great Britain 13.6%, Russia 8.2%, France 6.1%, Austria 4.4%, Italy 2.4%,
Table 15 : total Steal Production 1913 (in million tons) : USA 31.8, Germany 17.6, Great Britain 7.7, Russia 4.8, France 4.6, Austria 2.6, Italy 0.93,
Table 21 : Total Income 1914 (in billion $) : USA 37, Germany 12, Great Britain 11, Russia 7, France 6, Italy 4, Austria 3
Table 23 : British arms production (type : 1914,15,16,17,18) : (artillery : 91, 3390, 4314, 5137, 8039), (airplanes : 200, 1900, 6100, 14700, 32000), (machine guns : 300, 6100, 33500, 79700, 120900)
Table 25 : War Effort 14-19 (in billion $) : British Empire 23.0, Germany 19.9, USA 17.1, France 9.3, Russia 5.4, Austria 4.7, Italy 3.2, others 0.1-0.3
Table 25 : Mobilization 14-19 (in million men) : Germany 13.25, Russia 13, British Empire 9.5, Austria 9.0, France 8.2, Italy 5.6, USA 3.8, others (CP) 2.85, others (Entente) 2.6


2. 1914 Scenario Faction starting economic values

PP = Production Points
MP = ManPower (Recrution Pool)
AM = Ammunition

All values from a balanced game 1914 at faction's starting turn ingame

Entente :
Serbia : 30 PP (+21), 430 MP, 5 AM (+2), -24 PP Upkeep (military)
Belgium : 7 PP (+8), 170 MP, 0 AM, -5 PP Upkeep (after German attack)
France : 20 PP (+41), 1100 MP, 5 AM (+4), -47 PP Upkeep
Britain : 25 PP (+39), 600 MP, 4 AM (+5), -25 PP Upkeep
Rusiia : 20 PP (+67), 2500 MP, 6 AM (+4), -66 PP Upkeep

Central Powers :
Austria : 35 PP (+41), 1600 MP, 7 AM (+4), -40 PP Upkeep
Germany : 55 PP (+75), 1900 MP, 15 AM (+9), -77 PP Upkeep
Turkey : 10 PP (+23), 1000 MP, 3 AM (+3), (-34 PP Upkeep ???)

(Note : There are additional Upkeep costs due to Research ... -20 PP for all 5 labs)


3. Reasons for Rescale

3.1 FreeUpkeep -> 0

Full military upkeep costs are usually not visible in the management panel due to following definition in game.lua :

Code: Select all

gameplay.FreeUpkeep = 70
but when you set

Code: Select all

gameplay.FreeUpkeep = 0
they appear and apply, killing all the factions budgets.

Free Upkeep of 70 PP means that each faction can have units up to 70 PP upkeep without paying any unit upkeep. They only pay for the military upkeep above 70. Germany is the only faction which starts with a military upkeep above 70 and has to pay unit upkeep from start. Russia is close. The consequence is that all smaller nations can use their full PP income to build up a military force comparable to German or Russian at start before their PP income is reduced by upkeep.
If you ignore Belgium and Turkey, it means that Entente (France, Britain, Russia and Serbia) have 4 x 70 = 280 PP free upkeep while Central Powers (CP) (Germany, Austria) only have 140 PP. With current PP income values, FreeUpkeep is necessary for CP factions, who have multiple fronts to manage, to be able to field enough troops to just cover the front line. On the other side it is also a handicap since it allows Entente to place almost twice as many units as CP.

As can be seen from the stats in 2., every faction starts with a military force whose PP upkeep is around the same value as their PP income. If FreeUpkeep is set to zero, all factions would have a negative PP income so if FreeUpkeep is to be removed, the income of all factions in game will have to be rescaled. A simple approach is just multiplying all PP income by 2 to get positive income for all factions.


3.2 Historical Reasons

As can be seen from the tables above, some factions in history had a much stronger economical / industrial basis than other factions compared to the values in the game. Therefore it would be usefull to be able to individually change the PP income for certain factions in a scenario without having to edit PP values of all their cities on the map.

The table of british arms production shows that production from 1915 to 1918 in all areas was multiplied by values between 3 and 30 or higher. In 1918, an equivalent of about 50% of british GDP was spent for the war, that is 20 times more than the peace times military budget. The numbers show that economical / industrial mobilization of a society can provide increasing resources for war for a few years, similar to an athlete in competition ... however if war continues for too long (and cities are conquered / destroyed and population is reduced), the economy will finally collapse.
The game uses WarEffort to simulate the mobilization of PP income for some nations, which means that they are increasing the part of GDP for war budget. The game also calculates the ratio of ManPower to MaxManPower ... declining ManPower reduces the GDP in game ...


4. Modding the Income-Scaling

PP Income is calculated in file "game_resources.lua".

Code: Select all

function GetFactionProduction(faction)
  local income = 0
  for construction in faction.constructions do
    income = income + GetConstructionProduction(construction)
  end
  return income
end
The income is modified by WarEffort and MPOutput

Code: Select all

function GetIncomePP(faction, ignoreWarEffort)
  local income = 0
  if ignoreWarEffort then
    income = math.ceil(GetFactionProduction(faction) * GetMPOutput(faction) / 100)
  else
    income = math.ceil(GetFactionProduction(faction) * GetMPOutput(faction) / 100 * faction.luaData.warEffort / 100)
  end

  return income
end
To rescale the income we define a new function GetIncomeModifier(faction) and call it in function GetFactionProduction(faction)

Code: Select all

-- new function to individually adjust Income-Modifier

function GetIncomeModifier(faction)
  local modifier = 2
  local turnbased_bonus = (1 + game.turn / scenario.turnLimit)

  if faction.id == 0 then -- france
    -- modifier = 1
  end

  if faction.id == 1 then -- britain
    -- modifier = 1
  end
  
  if faction.id == 2 then -- germany
    modifier = 2.5
  end

  if faction.id == 3 then -- austria
    -- modifier = 1
  end

  if faction.id == 4 then -- russia
    -- modifier = 1
  end

  if faction.id == 5 then -- turkey
    -- modifier = 1
  end

  if faction.id == 6 then -- belgium
    -- modifier = 1
  end

  if faction.id == 7 then -- serbia
    -- modifier = 1
  end

  if faction.id == 8 then -- italy
    -- modifier = 1
  end

  if faction.id == 9 then -- netherlands
    -- modifier = 1
  end

  if faction.id == 10 then -- usa
    -- modifier = 1
  end

  if faction.id == 18 then -- romania
    -- modifier = 1
  end

  if faction.id == 19 then -- bulgaria
    -- modifier = 1
  end  

  return modifier * turnbased_bonus 

end

Code: Select all

function GetFactionProduction(faction)
  local income = 0
  for construction in faction.constructions do
    income = income + GetConstructionProduction(construction)
  end  
  return income * GetIncomeModifier(faction)  -- new modifier		
end

The function GetIncomeModifier(faction) in detail :

Code: Select all

 local modifier = 2
sets a default value of 2 which doubles the income. You can replace 2 by any other value except 0. Value 1 is neutral.

Code: Select all

local turnbased_bonus = (1 + game.turn / scenario.turnLimit)
calculates a turn-dependant modifier which slowly grows from 1 to 2 as the number of played turns increases. This is experimental and can be replaced by a different function (e.g. Gaussian curve) or set to 1 if it is not used.

Code: Select all

if faction.id == 0 then -- france
    -- modifier = 1
  end
France (id : 0) here uses the default modifier (=2) from above since the individual modifier is commented out ("--" = comment).

Code: Select all

  if faction.id == 2 then -- germany
    modifier = 2.5
  end
Here the default modifier (=2) for Germany (id : 2) is overwritten with an individual value (=2.5).

Code: Select all

return modifier * turnbased_bonus 
The product of (individual) modifier and turnbased modifier is returned, e.g. in midgame around turn 60 the IncomeModifier would be around 2 x 1,5 = 3 for default factions.

Code: Select all

function GetFactionProduction(faction)
  local income
  ...
  return income * GetIncomeModifier(faction)  	
end
Finally the calculated PP Income in game is multiplied with the Modifier.


Please note that the PP income is still modified by WarEffort and MPOutput (standard game mechanics, see function GetIncomePP).
markja
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 11
Joined: Fri Nov 21, 2014 2:55 am

Re: Rescale PP-Income (Mod)

Post by markja »

Sorry for stupid question, but HOW am I supposed to modify that file (game_resources.lua)? Am I supposed to replace the content of that file with that code OR simply add that code to the file content (and if so, where in it)?

And how do I actually "call it in function GetFactionProduction(faction)"? Am I supposed to add this code to what file(???) or replace the content of what file?
Historion
Corporal - 5 cm Pak 38
Corporal - 5 cm Pak 38
Posts: 31
Joined: Wed Jul 30, 2014 10:41 pm

Re: Rescale PP-Income (Mod)

Post by Historion »

1. Always make a backup copy before changing game files.

2. The idea was to simply add the new function and make only small changes in existing code in file "game_resources.lua" as described in detail in my opening post.
- Copy the code of function GetIncomeModifier(faction) and insert it e.g. at top of file "game_resources.lua".
- Change the line with the return statement in function GetFactionProduction(faction) to call the function GetIncomeModifier(faction) :
return income * GetIncomeModifier(faction) -- new modifier
3. The changes were intended to improve historical balance for version from July / August 2014. According to latest patch notes, there were changes to game balancing so please check if balancing still needs to be fixed for historical accuracy.
Preliminary Beta patch 1.6.0 Patch Changelog notes:
...
Gameplay changes / balancing:

- Free Upkeep allowance is now zero,which means you now pay for each and
every unit on the map.

- Country PPs increased to offset the effects of the Free Upkeep allowance change.

- All Nations Man Power has been reduced, to a scale appropriate to
historic national forces levels per Country.
...
markja
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 11
Joined: Fri Nov 21, 2014 2:55 am

Re: Rescale PP-Income (Mod)

Post by markja »

Thanks, now I got it working! :)
krogo
Private First Class - Wehrmacht Inf
Private First Class - Wehrmacht Inf
Posts: 7
Joined: Sun Dec 28, 2014 6:38 am

Re: Rescale PP-Income (Mod)

Post by krogo »

can anybody tell me how is it possible that i can adjust the PP of every city, fortress and capital in the range of 0-99 in file constructions.lua - but two cities!
yep. in finland, cities of turku and vaasa can be only in the range of 0-2, whatever i do.
Post Reply

Return to “Commander the Great War : Mods & Scenario Design”