Increase Manpower per turn

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

Moderators: Slitherine Core, The Lordz

Post Reply
PrinceMiskin
Lance Corporal - SdKfz 222
Lance Corporal - SdKfz 222
Posts: 21
Joined: Fri Aug 03, 2007 6:05 pm

Increase Manpower per turn

Post by PrinceMiskin »

I would like to cause a fixed manpower increase each turn per nation. Would this be possible to mod?

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

Re: Increase Manpower per turn

Post by Historion »

Adding ManPower is no problem but adding a UI-feature which shows the rate at which MP increases will be more difficult.

Define a new function :

Code: Select all

function DoMPIncome(faction)
  local growthrate = 2 -- 0.002  -- Growthrate 5% of MPmax per year => ca 0.2 % per turn (when ca 25 turns = 1 year)
  local MPIncome = math.ceil(growthrate * data.factions[faction.id+1].manpowerMax / 1000)  -- small factions get +1 MP per turn due to rounding up
  faction:ConsumeManpower(-MPIncome)
end
and add it in file "game_resources.lua".

In this file the function ManageFinances does allocate ressources and pays maintenance for the active alliance at the start of each turn. Call the new function before the MPLevel is checked :

Code: Select all

function ManageFinances(alliance)

  if alliance.id ~= 0 then

    for faction in alliance.factions do

      -- Check if Manpower reserve drops below a certain %
      DoMPIncome(faction)   ---                                                    <--Our new function !!!
      CheckManpowerLevel(faction)

      PayFactionIncome(faction)

      -- Extra income for AI on highest difficulty level
      if game.type == Game.TYPE_SINGLE and alliance.id ~= playerAlliance.id then
        local percentage = 50

        -- start with lower bonuses first 5 turns
        if game.turn <= 5 then
          percentage = percentage - percentage / game.turn
        end
        if game:GetAlliancePlayer(alliance).difficulty == 3 then
          GiveExtraIncome(faction, percentage)
        elseif game:GetAlliancePlayer(alliance).difficulty == 1 then
          GiveExtraIncome(faction, -percentage*2/3)
        end
      end

      SpendFactionResearchUpkeep(faction)

      SpendFactionUpkeep(faction)

      CheckDebtMoraleEffect(faction)

      ProduceAmmunition(faction)

      RepairConstructions(faction)

    end

  end

end
PrinceMiskin
Lance Corporal - SdKfz 222
Lance Corporal - SdKfz 222
Posts: 21
Joined: Fri Aug 03, 2007 6:05 pm

Re: Increase Manpower per turn

Post by PrinceMiskin »

You are such a kind man! This made my day! Thank you. :-)
markja
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 11
Joined: Fri Nov 21, 2014 2:55 am

Re: Increase Manpower per turn

Post by markja »

How to add more moderate growthrate, lets say 2% per year? Should making the line like this work:
local growthrate = 2 -- 0.0008 -- Growthrate 5% of MPmax per year => ca 0.2 % per turn (when ca 25 turns = 1 year)
Post Reply

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