In which files is coded the turn manpower income?

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

Moderators: Slitherine Core, The Lordz

Post Reply
Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 132
Joined: Wed Nov 27, 2013 3:27 pm

In which files is coded the turn manpower income?

Post by Kossatx » Thu Aug 23, 2018 9:03 pm

Hi, I'm trying to modify the turn manpower income, but I can't find where it is coded. I know where is coded the initial manpower for each country, but not the turn income. Can anyone help me?

Robotron
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1230
Joined: Tue Nov 23, 2010 3:35 pm

Re: In which files is coded the turn manpower income?

Post by Robotron » Thu Aug 23, 2018 11:12 pm

There is no such thing in the basic game but I modded it into Potzblitz.
The code was designed by a fellow forum user called Hyperion back in the days.

It's found in game_resources.lua under the function called DoMPIncome(faction)

Change the number value in:

Code: Select all

local growthrate = 2
The value 2 equals 0,2% manpower gain per turn.

Consider that in 1914 a turn covers two weeks, while after 1914 a turn covers a whole month.

For this reason I doubled the manpower gain per turn after 1914.

Code: Select all

if game.date.year == 1914 then
	faction:ConsumeManpower(-MPIncome)
    elseif game.date.year >= 1915 then
	faction:ConsumeManpower(-MPIncome *2)
and even raised it, if "Volunteer Recruits" were played with a 33% chance per turn

Code: Select all

if faction.alliance.id == 1 and GetEvent("MPBonusEnt") >0 and math.random(1,6) >= 5 then
	faction:ConsumeManpower(-MPIncome)
end
if faction.alliance.id == 2 and GetEvent("MPBonus") >0 and math.random(1,6) >= 5 then
	faction:ConsumeManpower(-MPIncome)
end
end
Hope you can make sense of that.
If not, just ask.
Slitherine's Commander the Great War on steroids: POTZBLITZ mod!
http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610

Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 132
Joined: Wed Nov 27, 2013 3:27 pm

Re: In which files is coded the turn manpower income?

Post by Kossatx » Fri Aug 24, 2018 8:01 am

Robotron wrote:
Thu Aug 23, 2018 11:12 pm
There is no such thing in the basic game but I modded it into Potzblitz.
The code was designed by a fellow forum user called Hyperion back in the days.

It's found in game_resources.lua under the function called DoMPIncome(faction)

Change the number value in:

Code: Select all

local growthrate = 2
The value 2 equals 0,2% manpower gain per turn.

Consider that in 1914 a turn covers two weeks, while after 1914 a turn covers a whole month.

For this reason I doubled the manpower gain per turn after 1914.

Code: Select all

if game.date.year == 1914 then
	faction:ConsumeManpower(-MPIncome)
    elseif game.date.year >= 1915 then
	faction:ConsumeManpower(-MPIncome *2)
and even raised it, if "Volunteer Recruits" were played with a 33% chance per turn

Code: Select all

if faction.alliance.id == 1 and GetEvent("MPBonusEnt") >0 and math.random(1,6) >= 5 then
	faction:ConsumeManpower(-MPIncome)
end
if faction.alliance.id == 2 and GetEvent("MPBonus") >0 and math.random(1,6) >= 5 then
	faction:ConsumeManpower(-MPIncome)
end
end
Hope you can make sense of that.
If not, just ask.
Great job Robotron :D I only don't understand where is specified in "MPBonusEnt" the bonus for MP income. I understand the chance is "math.random(1,6) >= 5", but where is specified the bonus?

Robotron
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1230
Joined: Tue Nov 23, 2010 3:35 pm

Re: In which files is coded the turn manpower income?

Post by Robotron » Fri Aug 24, 2018 10:49 am

The bonus comes from:

Code: Select all

faction:ConsumeManpower(-MPIncome)
ConsumeManpower is a sub-function that consumes manpower.
HOWEVER: if we give it a negative value, it adds a bonus (as in: if you subtract a negative value, you in fact add a positive value)

faction is any given nation in the game.
Every faction will go through the process of getting a manpower bonus at the start of the turn.

MPIncome is a variable, it contains a number value that was created at the start of the function in

Code: Select all

      
local MPIncome = math.ceil(growthrate * data.factions[faction.id+1].manpowerMax / 1000)  -- small factions get +1 MP per turn due to rounding up
Instead of using a variable you can be more specific too, for example:

Code: Select all

italy:ConsumeManpower(5)
which will have Italy consume 5 manpower or

Code: Select all

britain:ConsumeManpower(-20)
which will have Britian add 20 manpower (-20 = add 20)

Of course in the above two cases you will first have to tell the game, who the hell "italy" and "britain" are.

So in case you did not already know, do this by assigning a faction id to the name of the nation

Code: Select all

local italy = game:GetFactionById(8)
or

Code: Select all

local britain= game:GetFactionById(1)
See, any nation in the game has a number ID

France is 0, Britain is 1, Germany is 2, Austria is 3, Russia is 4, Turkey is 5, Belgium is 6, Serbia is 7, Italy is 8 etc. (see factions.lua for more info)

And then finally there are also

anynationnamehere:ConsumeProductionPoints(insert value here) ---- to add/consume production

and

anynationnamehere:ConsumeAmmo(insert value here) ---- to add/consume ammo
Slitherine's Commander the Great War on steroids: POTZBLITZ mod!
http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610

Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 132
Joined: Wed Nov 27, 2013 3:27 pm

Re: In which files is coded the turn manpower income?

Post by Kossatx » Fri Aug 24, 2018 11:06 am

Robotron wrote:
Fri Aug 24, 2018 10:49 am

Code: Select all

      
local MPIncome = math.ceil(growthrate * data.factions[faction.id+1].manpowerMax / 1000)  -- small factions get +1 MP per turn due to rounding up
Ok, great, this was what I'd like to change. I don't like this "+1" for small factions. Do you know if decimal values are cummulative or they are lost every turn?

Robotron
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1230
Joined: Tue Nov 23, 2010 3:35 pm

Re: In which files is coded the turn manpower income?

Post by Robotron » Fri Aug 24, 2018 11:24 am

They will be rounded up because of math.ceil (there is also math.floor for rounding down btw.)

However since most minors have maximum manpower below 1000 and the manpower per turn is divided by 1000 at the end of the function even rounding up will still produce only 1.
Slitherine's Commander the Great War on steroids: POTZBLITZ mod!
http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610

Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 132
Joined: Wed Nov 27, 2013 3:27 pm

Re: In which files is coded the turn manpower income?

Post by Kossatx » Fri Aug 24, 2018 6:05 pm

Thanks very much Robotron :D

Robotron
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1230
Joined: Tue Nov 23, 2010 3:35 pm

Re: In which files is coded the turn manpower income?

Post by Robotron » Fri Aug 24, 2018 6:15 pm

Always happy to help.

So what did you do? Did you give Serbia a per turn manpower bonus of 10? ;)
Slitherine's Commander the Great War on steroids: POTZBLITZ mod!
http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610

Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 132
Joined: Wed Nov 27, 2013 3:27 pm

Re: In which files is coded the turn manpower income?

Post by Kossatx » Fri Aug 24, 2018 10:20 pm

Robotron wrote:
Fri Aug 24, 2018 6:15 pm
Always happy to help.

So what did you do? Did you give Serbia a per turn manpower bonus of 10? ;)
No, no, just the opposite. I think I'll remove this "+1" for minor countries. The modifications I do are focused on population weight and industrial capacities of each country in order to improve the historical simulation. So, for example, Serbia has only 14PP and 225MP. I know it seems too low but, in my opinion, after all the changes I have done the game is as balanced as WWI was :wink:

Robotron
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1230
Joined: Tue Nov 23, 2010 3:35 pm

Re: In which files is coded the turn manpower income?

Post by Robotron » Sat Aug 25, 2018 12:53 am

Historical correctness applied to CTGW will often lead to totally non-historical results because of the way the game was designed.
This I can tell you from my experience.
Slitherine's Commander the Great War on steroids: POTZBLITZ mod!
http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610

Post Reply

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