Army upkeep in other theatres
Moderators: Slitherine Core, The Lordz
Army upkeep in other theatres
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
Re: Army upkeep in other theatres
Okay fans, all three of you please hate Kossatx, he's stealing my precious time I could otherwise invest into the next update!
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! )
There's not much sense in doing funny things to game_resources.lua if the pre-onditions don't already exist.
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! )
There's not much sense in doing funny things to game_resources.lua if the pre-onditions don't already exist.
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
Re: Army upkeep in other theatres
Three against one is enough ratio for victory
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
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
Re: Army upkeep in other theatres
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:
*edit*
okay, here's the damn GetUpkeep function for game_resources.lua
So you don't say that customer service is bad here!
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
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
Re: Army upkeep in other theatres
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 wrote: ↑Fri Aug 28, 2020 8:06 pmCode: Select all
function RussiaFarEast() local russia = game:GetFactionById(4) if GetEvent("JapanWar") >0 then russia:ConsumeProductionPoints(10) else russia:ConsumeProductionPoints(18) end end
Re: Army upkeep in other theatres
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?
Nobody ever listens to me!
Nobody ever listens to me!
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
Re: Army upkeep in other theatres
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
Re: Army upkeep in other theatres
You are supposed to use either one or the other. Not both!
If you use both, then PP for upkeep will be deducted twice!
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.
If you use both, then PP for upkeep will be deducted twice!
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.
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
Re: Army upkeep in other theatres
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 itRobotron 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!
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.
Code: Select all
function RussiaFarEast()
local russia = game:GetFactionById(4)
if GetEvent("JapanWar") >0 then
russia:ConsumeProductionPoints(10)
else
russia:ConsumeProductionPoints(18)
end
end
Re: Army upkeep in other theatres
I'm repeating myself:
Do not use it. This is already included in the modified Getupkeep function.
Do not use it. This is already included in the modified Getupkeep function.
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
Re: Army upkeep in other theatres
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
Re: Army upkeep in other theatres
You are entering that code directly into TriggerTurnEvents() ????
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?
And this goes anywhere into game_events.lua, it can be at the start or the end, it does not matter:
Also note that
means that Russian gains production
while
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.
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()
----
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
Code: Select all
russia:ConsumeProductionPoints(-15)
while
Code: Select all
russia:ConsumeProductionPoints(15)
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.
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
Re: Army upkeep in other theatres
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
About the "ConsumeProductionPoints" function, better tidy as you say It works perfectlyRobotron wrote: ↑Sat Aug 29, 2020 1:56 pmAnd this goes anywhere into game_events.lua, it can be at the start or the end, it does not matter:Code: Select all
------ ChristmasTruce() Mud() OffMapUpkeep() ----<<<<------ this will trigger your function Storm() RussianPorts() ----
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