Page 1 of 1

Increase Manpower per turn

Posted: Sat Aug 09, 2014 8:48 am
by PrinceMiskin
I would like to cause a fixed manpower increase each turn per nation. Would this be possible to mod?

Thanks!

Re: Increase Manpower per turn

Posted: Sat Aug 09, 2014 12:24 pm
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

Re: Increase Manpower per turn

Posted: Sat Aug 09, 2014 1:08 pm
by PrinceMiskin
You are such a kind man! This made my day! Thank you. :-)

Re: Increase Manpower per turn

Posted: Sun Nov 30, 2014 6:25 pm
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)