Army upkeep in other theatres

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

Moderators: Slitherine Core, The Lordz

Post Reply
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

Army upkeep in other theatres

Post by Kossatx »

Hi again, I'm thinking about how to represent the armies upkeep in other theatres not reflected in the map. I would like to add this upkeep to the total in the economics interface. I think it could be done in "game_resources.lua", using the "GetUpkeep(faction)" command, probably modding "SpendFactionUpkeep(faction)" function. Anyone can dare with this? Robotron, your fans are waiting for next Potzblitz update with reds and whites, and If you waste your time with this thread they will hate me :?
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Army upkeep in other theatres

Post by Robotron »

Okay fans, all three of you please hate Kossatx, he's stealing my precious time I could otherwise invest into the next update! :mrgreen:

No, seriously, I haven't thought about such a thing like your proposal before, so that's new territory for me too.

First I'd need to know what kind of theatres you are thinking of and if such theatres are already implemented by you (or me? oh dear! :shock: )

There's not much sense in doing funny things to game_resources.lua if the pre-onditions don't already exist. :wink:
Image
Slitherine's Commander the Great War - Director's Cut: POTZBLITZ mod!
FIND IT HERE: http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

Re: Army upkeep in other theatres

Post by Kossatx »

Three against one is enough ratio for victory :lol:

I'll begin with a very simple example. Russia must pay an upkeep of 120pp per turn (army + labs), but only units in the map are included in "army upkeep". But, of course, Russia has units along the chinesse border... how many pp is Russia saving every turn if these troops are not included in the "army upkeep"? Austria Hungary hasn't this kind of problems, but the Entente yes! In this example I would like to increase in 18pp per turn the russian "army upkeep". Moreover, it wold be interesting to link this script to "Japan join Entente" event, and if it's triggered the 18pp per turn would be reduced to 10pp. This is what I would like to do :roll:
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Army upkeep in other theatres

Post by Robotron »

Aw, come on, this is getting way beyond the scope of the game.
We don't even have flags for China or Japan to show on the diplomatic screen, so why do you want to be so specific and include the impact of far-eastern theaters on the PP-Upkeep values?

If you believe Russian PP are too high then go into constructions.lua and simply lower the values, this would be a lot easier.
Or make a new function that consumes or generates Russian PP if a specific event has triggered:

Code: Select all

function RussiaFarEast()
local russia = game:GetFactionById(4)

  if GetEvent("JapanWar") >0 then
	russia:ConsumeProductionPoints(10)
  else
	russia:ConsumeProductionPoints(18)
  end	
	
end

*edit*

okay, here's the damn GetUpkeep function for game_resources.lua

Code: Select all

function GetUpkeep(faction, pureArmyCost)
local russia = game:GetFactionById(4)
local upkeep = 0
  
  for unit in faction.units do
    if unit.alive and unit.prototype.upkeepPP > 0 and not (unit.type == Unit.NAVAL and unit.hex.construction ~= nil) then

	  local temp = 0
      if unit.hp < 80 then
        temp = math.floor(unit.prototype.upkeepPP * unit.hp / 100)
        if temp == 0 then
          temp = 1
        end
      else
        temp = unit.prototype.upkeepPP
      end
      upkeep = upkeep + temp
    end
  end
  for unit in faction.production_que do
    upkeep = upkeep + unit.prototype.upkeepPP
  end
  if faction.id == 4 then
  
  if GetEvent("JapanWar") >0 then
	upkeep = upkeep +10
  else
	upkeep = upkeep +18
  end


  end

  -- Free 10 PP
  if not pureArmyCost then
    if upkeep > gameplay.FreeUpkeep then
      upkeep = upkeep - gameplay.FreeUpkeep
    else
      upkeep = 0
    end
  end
  return upkeep
end
So you don't say that customer service is bad here! :mrgreen:
Image
Slitherine's Commander the Great War - Director's Cut: POTZBLITZ mod!
FIND IT HERE: http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

Re: Army upkeep in other theatres

Post by Kossatx »

Robotron wrote: Fri Aug 28, 2020 8:06 pm

Code: Select all

function RussiaFarEast()
local russia = game:GetFactionById(4)

  if GetEvent("JapanWar") >0 then
	russia:ConsumeProductionPoints(10)
  else
	russia:ConsumeProductionPoints(18)
  end	
	
end
Yes, this way is much easier and probably better. The reason I was talking about "upkeep" and not "ConsumeProductionPoints" command is I thought it would be better for the player (and, probably, even for the AI) to have predictive information for the next turn (which appears in the economis interface). But I have actually no idea about how the AI works with this stuff :?: Anyway, your suggestion is a shortcut to avoid a waste of time. Thanks again Robotron!
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Army upkeep in other theatres

Post by Robotron »

Hey, wait, I've also given you the solution for your problem in the modified GetUpkeep function in my last post, did you even give it a try? 8)

Nobody ever listens to me! :mrgreen:
Image
Slitherine's Commander the Great War - Director's Cut: POTZBLITZ mod!
FIND IT HERE: http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

Re: Army upkeep in other theatres

Post by Kossatx »

Robotron wrote: Fri Aug 28, 2020 8:40 pm Hey, wait, I've also given you the solution for your problem in the modified GetUpkeep function in my last post, did you even give it a try? 8)

Nobody ever listens to me! :mrgreen:
Oh! Great! I'll give you feedbak tomorrow :D
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

Re: Army upkeep in other theatres

Post by Kossatx »

It's difficult to explain accuratelly, but finally I'll use both scripts, the "upkeep" script for nations wich all PP are represented in the map, and the "ConsumeProductionPoints" for the rest. The "upkeep" script works fine, but not the other. I'm not sure where in "game_events.lua" I have to insert the script, I have tried to put it in "TriggerTurnEvents()" and alone, as an independent function, but althought there are no crashes, I can't see any income PP :idea:
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Army upkeep in other theatres

Post by Robotron »

You are supposed to use either one or the other. Not both! :?
If you use both, then PP for upkeep will be deducted twice! :roll:

The first short function will just reduce PP but the higher upkeep will NOT show on the management screen. Do not use it.

The second, modified version of function GetUpkeep works fine!
I just tested it by exchanging Russia with Austria so I can check it on turn 1.
Image
Slitherine's Commander the Great War - Director's Cut: POTZBLITZ mod!
FIND IT HERE: http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

Re: Army upkeep in other theatres

Post by Kossatx »

Robotron wrote: Sat Aug 29, 2020 11:20 am You are supposed to use either one or the other. Not both! :?
If you use both, then PP for upkeep will be deducted twice! :roll:

The first short function will just reduce PP but the higher upkeep will NOT show on the management screen. Do not use it.

The second, modified version of function GetUpkeep works fine!
I just tested it by exchanging Russia with Austria so I can check it on turn 1.
Yes I know, no problem with using both scripts. I did the same you did exchanging Russia with Austria with upkeep script, is this one which I'm not sure where put it :?

Code: Select all

function RussiaFarEast()
local russia = game:GetFactionById(4)

  if GetEvent("JapanWar") >0 then
	russia:ConsumeProductionPoints(10)
  else
	russia:ConsumeProductionPoints(18)
  end	
	
end
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Army upkeep in other theatres

Post by Robotron »

I'm repeating myself:
Do not use it. This is already included in the modified Getupkeep function.
Image
Slitherine's Commander the Great War - Director's Cut: POTZBLITZ mod!
FIND IT HERE: http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

Re: Army upkeep in other theatres

Post by Kossatx »

Robotron wrote: Sat Aug 29, 2020 11:59 am I'm repeating myself:
Do not use it. This is already included in the modified Getupkeep function.
I'm not sure if I missunderstood you, I know both scripts you have done solve the Russian Far East issue, so I don't have to use both as you have written them. What I say is I will use bot but modifying them for each nation I need. If I use the "upkeep" script for Britain and the "ConsumeProductionPoints" script for Russia, where is the problem? :|

At last the "ConsumeProductionPoints" script works if I remove its function code line and I include it in "TriggerTurnEvents()" function. I don't know if it would be better to put it in another way :?:

Code: Select all

local russia = game:GetFactionById(4)

  if GetEvent("JapanWar") >0 then
	russia:ConsumeProductionPoints(-15)
  else
	russia:ConsumeProductionPoints(- math.random(10,15))
  end	
Robotron
Brigadier-General - Elite Grenadier
Brigadier-General - Elite Grenadier
Posts: 2151
Joined: Tue Nov 23, 2010 3:35 pm

Re: Army upkeep in other theatres

Post by Robotron »

You are entering that code directly into TriggerTurnEvents() ???? :shock:

TriggerTurnEvents is just for triggering other functions, let's keep things tidy and use it only for that purpose.

Why not just make a new function called "OffMapUpkeep"and trigger it from TriggerTurnEvents like every other event function?

Code: Select all

------
ChristmasTruce()

Mud()
  
OffMapUpkeep() ----<<<<------ this will trigger your function
  
Storm()
  
RussianPorts()
----
And this goes anywhere into game_events.lua, it can be at the start or the end, it does not matter:

Code: Select all

function OffMapUpkeep()
local russia = game:GetFactionById(4)
local britain = game:GetFactionById(1)  ----<<<<----- etc., add as many nations as you like

  if GetEvent("JapanWar") >0 then
	russia:ConsumeProductionPoints(15)
  else
	russia:ConsumeProductionPoints(math.random(10,15))
  end
    if GetEvent("JapanWar") == 0 then
	britain:ConsumeProductionPoints(15)
  else
	britain:ConsumeProductionPoints(math.random(10,15))
  end
  
  
end	
Also note that

Code: Select all

russia:ConsumeProductionPoints(-15)
means that Russian gains production

while

Code: Select all

russia:ConsumeProductionPoints(15)
means that Russia loses production

The "-" before the number makes all the difference.

Anyway, if you do your OffMapUpkeep-stuff the way like described above you won't see the raised upkeep on the management panel.
To see the raised upkeep on the management panel you would need to go the other way I described yesterday. It's up to you, of course.
Image
Slitherine's Commander the Great War - Director's Cut: POTZBLITZ mod!
FIND IT HERE: http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610
Kossatx
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 241
Joined: Wed Nov 27, 2013 3:27 pm

Re: Army upkeep in other theatres

Post by Kossatx »

Yes, I know how "ConsumeProductionPoints" command works with the "-", no matter, the script probably seems a bit weird but it works the way I want :D
Robotron wrote: Sat Aug 29, 2020 1:56 pm

Code: Select all

------
ChristmasTruce()

Mud()
  
OffMapUpkeep() ----<<<<------ this will trigger your function
  
Storm()
  
RussianPorts()
----
And this goes anywhere into game_events.lua, it can be at the start or the end, it does not matter:

Code: Select all

function OffMapUpkeep()
local russia = game:GetFactionById(4)
local britain = game:GetFactionById(1)  ----<<<<----- etc., add as many nations as you like

  if GetEvent("JapanWar") >0 then
	russia:ConsumeProductionPoints(15)
  else
	russia:ConsumeProductionPoints(math.random(10,15))
  end
    if GetEvent("JapanWar") == 0 then
	britain:ConsumeProductionPoints(15)
  else
	britain:ConsumeProductionPoints(math.random(10,15))
  end
  
  
end	
About the "ConsumeProductionPoints" function, better tidy as you say :mrgreen: It works perfectly :!:
Post Reply

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