Unit Upkeep Modifications

About income updating immediately… yes, in vanilla, it does. I also agree that it would be great if C2C did the same. But since updating other things mid turn that affect game play (build queue options like national units) is both difficult and low priority, I assumed that updates only affecting displayed values but not impacting gameplay would still be difficult and even lower priority. I have no problem with accurate information being displayed to the player, and encourage anyone that wants to tackle more frequent updates that don’t impact the application’s speed/memory/responsiveness to please go forward with that. But, I will reiterate that, when it comes to unit upkeep costs not changing, it is just a display problem. I tested this months ago, that losing a unit (to mission/battle/delete) does not impact the displayed gold per turn in the upper left of the main screen, but the actual gold per turn lost or gained between turns does accurately reflect the unit changes.
Making the gold display refresh from dll is as easy as using this one liner "gDLL->getInterfaceIFace()->setDirty(GameData_DIRTY_BIT, true);"
It's used a lot, and only makes a small portion of the main interface refresh, so it wouldn't hurt performance to use it whenever unit upkeep changes, which happens relatively rarely, like the refresh per second would be much less than 1 per sec on average from this.
My goal here is to help, and I think I have information, background, skill, and experience that allows me to try.
That's cool, your wall of text radiate enthusiasm, I welcome people to get invested in C2C.
To back up a little, the current state of the function doesn’t really matter, except in relation to how difficult it has to be to address our needs. Let’s examine the problems that need to be fixed, or at least the ways in which unit upkeep needs to be handled differently than vanilla civ4. Thus far, I see three separate ones mentioned in this conversation. They are subdued animals, promotions, and unit group size (when the Size Matters game option is activated). Are there any other ways that C2C needs to handle unit upkeep differently than BtS?
Yes, in C2C we want a unit to have much higher upkeep than what vanilla was set up for, and therefore we need information transparency for the player, the player must be able to mouse over one of his/her units and see exactly how much gold that one unit cost in upkeep in the tooltip, e.g. Unit Upkeep: 2403.48 :gold:. This exact gold amount display for units would be clunky with the vanilla unit upkeep system.
List of things we want:
• Information transparency mentioned above.
• Easy to setup units to have 0 in upkeep cost in the unit xml file.
• Easy to setup units to have any kind of base upkeep cost for that matter.
• Ways for promotions and unitcombats to modify the base upkeep.
• A final modifier specifically for SM so that merging three units always cost 1.5 more in upkeep than each individual did before.
I could hardcode this, but I prefer having an xml tag in case we want a different multiplier than 1.5 at some point. (1.5 is the multiplier used for most stuff in SM merge)
Currently, this cost modifier is just added to the same modifier value as other promotions/unitcombats contribute to, when it should multiply with it.
e.g. Three divine quality units merged into one let's say they cost 100 gold each, will cost 105 gold after merging when it should cost 150
And three incapable units (same unit type as above) may cost 10 gold each and will cost 15 gold after merging.​
These numbers are arbitrary, but they illustrate how the current modifiers typically work at this time, which leaves something to be desired.​
• Easy to understand coding, more straight forward than what we currently got.
I already offered one way that subdued animals could be handled. Another option would be to subtract them from the total amount of units before any math is done, so they aren’t even displayed as “free” units, let alone taken into account in the equation. A third would be something similar to what we have now, adding them to the number of free units after the free unit calculations have been done but before handicap costs are tallied. And so forth. (Another, possibly easier and more accurate method becomes obvious further down in the post.) Whatever we choose, it will have an impact on how supply for the subdued animals will need to be handled. Either way, I think there are a lot of options here, and I don’t see any that are invasive to a final overall solution.
I see two good options.
1. We switch from "free units" to "free unit upkeep gold", that way units with zero upkeep won't interfere in how free unit upkeep is handled.
2. We keep a count in the player object of how many units have upkeep greater than zero so that we can easily get the average gold cost of units without free units affecting the average value.
upkeep = totalUpkeep minus "free units" multiplied with totalUpkeep divided by iNumUnitWithUpkeep
if (upkeep < 0) upkeep = 0​

I like approach number one, because it won't favour players with an army with high average unit upkeep like approach 2 does.
Approach two can be described as: The more expensive your units, the more free the army becomes. This description also fits the current system in use for free units.
There are multiple creative ways I can think of for tallying those costs, but I think there is an important restriction in any efforts. Namely, that SM is still an option, not an integral and necessary part of C2C If that is the case, any final solution must be able to handle the option being both on and off.
The only way to balance unit upkeep is imo with the SM option off. SM is per definition a shift in unit balance so it doesn't matter if upkeep feel different under it. It may have some unit that cost less and some units that cost more than without the option, in the same way it has units that have less or more strength than they do without the option. SM will be designed so that unit cost is scaled by unit strength in an indirect way, so it is self balancing if its modifiers are set to reasonable values. Most C2C balance work should in general always happen with as few options enabled as possible, the options should be tweaked to work inside a balanced C2C, any shifts in balance if not tweak-able through option specific content should be accepted as part of what the option is designed to do.
Let me give a few examples of one way promotions might work in this paradigm. Say we want to balance the Might promotions (not saying we need to, just an example). Each level of Might could multiply the modified ‘unit upkeep number’ by +25%.
I like the suggestion, haven't though too hard on what promotions should utilizxe this yet, but might seems like a perfect candidate. Other possibilities would be equipment promotions that in nature are more expensive to maintain than the default unit equipment is. Fanatic promotion may make the unit cheaper by a percentage, they don't fight for gold but through belief/loyalty. Etc.
Anyway, this makes sense to me. In code, as a player, and in context of the future conversations I have been hearing about. I know I have only been lurking and listening for less than a year, and I hope that me having an opinion on the direction of a part of the mod isn’t offensive, but this seems to meet the goals of transparency, ability to be built upon, and easier to understand and maintain by multiple coders.
Feel free to chat about the topic on discord, I can keep you in the loop of the development process there if you'd like that.
 
Yeah, well, wall of text is kind of my trademark. At work, and, well… anywhere. My own wife doesn’t even read my emails anymore. I’m working on it. You have seen my attempt at improvement here and in discord.

I think your option 1 is very close to what I said, and your option 2 is very close to what was said before, which I don’t like. What I was trying to get at, which Thunderbrd’s response shows me was not understood, was that recalculating averages or ranking units just sounds like a waste of processing, very difficult code, so incredibly much harder for the player to understand, and most importantly not necessary. And I think your option 1 does exactly that. Your label is better than mine, which I didn't like the moment I typed it.

I only used 20% because that is what Thunderbrd said it was, in 2018, in the linked thread. I agree that 50% is more consistent, and easier for the player to understand. Maybe update the post again? Either way, though, still don’t care what the multiplier is, just that it is a multiplier.

As to balancing upkeep only being possible with SM off, I am not necessarily in disagreement… but the person doing the unit balancing always has SM on, right? And the person balancing civics always has SM off, right? In other words, I agree with you in theory, but that is not possible in practice. Am I wrong?

And yes, please keep me in the loop
 
I think your option 1 is very close to what I said, and your option 2 is very close to what was said before, which I don’t like. What I was trying to get at, which Thunderbrd’s response shows me was not understood, was that recalculating averages or ranking units just sounds like a waste of processing, very difficult code, so incredibly much harder for the player to understand, and most importantly not necessary. And I think your option 1 does exactly that. Your label is better than mine, which I didn't like the moment I typed it.
The average I suggested in approach number two would be very simple code. As long as the iNumUnitWithUpkeep and iTotalUpkeep are updated when they change, then calculating the average unit upkeep is as easy as one number divided by the other:
iUpkeep = iTotalUpkeep - iFreeUnits * iTotalUpkeep / iNumUnitWithUpkeep.
 
you know, you are right. I guess I was still thinking of ranking units instead of averaging them. But modifying the average after every mission and unit created or destroyed... well, I guess that isn't the worst... but still not easy for the player to track. And balancing very cheap units would be harder or create exploits... I guess I just don't like it. it could probably work fine, just not my favorite.
 
Approach two can be described as: The more expensive your units, the more free the army becomes. This description also fits the current system in use for free units.
Rather, the more expensive your units, the more a 'free unit' means, since the measure of a free unit should be somewhat based on the existing cost of units. Higher level civics probably should be less giving of 'free unit' upkeep because the concept of the free unit is generally an expression of how willing the people in a society are to be a warrior for their people as a matter of pride more than any kind of arranged compensation from the governing body. Thus tribal warfare as a civic may give a lot of 'free units' and some traits may add to the free unit count, but volunteerism (not just self-determined willingness but to play a professional role for free) starts fading fast with more complex governing systems and economies that aren't as communal.

If the gold cost of a free unit is considered a count of gold alone, then it should at least go up over the eras I think. If it's just a flat amount then it might as well just be 'free gold' that can only count towards unit upkeep totals.

Again, however, merged units should count as more 'free unit volume' being absorbed as well so that 3 units merged doesn't count as a whole free unit either.
 
Last edited:
And balancing very cheap units would be harder or create exploits...
Only way to 'exploit' this would be to maintain a more expensive unit force, which isn't really helping the player in any way directly. As for it being difficult for the player to track - a display line in the gold advisor could at least show that average upkeep cost of a unit. Tracking it so as to exploit it obviously isn't what we're trying to make possible so much as trying to maintain a conceptual meaning of what a free unit actually is a reflection of in a governing system.

Remember there are also two kinds of 'free units' we're actually talking about here, military and non-military, though I think that military might just be an extra cost for military units on top of the underlying unit costs - I've never fully sorted that out how the code considers the difference in the accounting, other than to understand which units are considered military.
 
This is why I am arguing against the idea of 'free units'. It leads to a misunderstanding of the dynamic, and might lead to (another) complete rewrite of the upkeep mechanic to try to match the misunderstanding.

In vanilla, it makes sense to be hamfisted about this, since each unit has the same upkeep relative cost. They were being hamfisted about the size and relative strengths of the units in vanilla, which I gather was an impetus for much of your own work with units. But, in vanilla, they aren't 'free units'. Sure, there is the comment and misunderstanding that started this conversation, but further than that, unit support doesn't refer to feeding and clothing and arming soldiers: it has to do with the ability of the society to continue to function with that much of a standing army, the loss of workforce and able-bodied workers. That is why, in vanilla as well as C2C, the majority of 'free units' has nothing to do with civic, but with population. In vanilla, there were two civics that impacted unit support (differently), but most civics didn't impact unit cost or unit support or supply or whatever. The population multiplier may well have been exposed in this mod (I don't know if that is possible or done, I haven't been through the whole code base), but in vanilla it wasn't even exposed to be modifiable, and every population point gave 0.24 additional 'free units', rounded down. In any civic. Pacifism cost more, Vassalage cost less (and more, usually just more, but that is a different problem), and that was it. I understand that unit support has been used as an additional lever in C2C to fine tune balancing of civics, and that is great... but it should be done with the realization that the game core never intended this. And even when Vassalage was used, it was a multiplier by population, not a straight additive. 'Unit support' has always been, in civ4, a measure of a population's ability to handle the consequences of fielding a standing army.

Now, maybe you think that, in C2C, that an additional or different mechanism should be put in place, to reproduce the cost of feeding and clothing soldiers. I am open to that, but I would caution against it. My understanding is that the idea of a professional soldier is relatively new in history, and most soldiers were really just farmers who left their fields in service of their king (through patriotism or government threats or self-preservation), and for most the only expected pay was the honor when they came home, and any spoils they got from defeated enemies.

And to clear up a common misconception: In vanilla, there was never military and non-military. There was only a poorly labeled financial advisor screen. The 'military' unit cost you recall, was 0. Always 0, never no 0, no matter your population, size of your army, technology level, year in the game, etc... *Unless* you were running the civic Pacifism. There was never a non-military group. Just the regular unit support cost, and the extra pacifism cost. I don't have my notes on the code in front of me, but I am pretty sure that is still the case in C2C. I don't actually know which civics add to that pool in C2C, but I am pretty sure it is civic only, even still.
 
Sure, there is the comment and misunderstanding that started this conversation, but further than that, unit support doesn't refer to feeding and clothing and arming soldiers: it has to do with the ability of the society to continue to function with that much of a standing army, the loss of workforce and able-bodied workers.
I guess I've always considered it equipment maintenance and salary costs for the soldiers. If it was loss of workforce, there should perhaps be a production upkeep expense?
Now, maybe you think that, in C2C, that an additional or different mechanism should be put in place, to reproduce the cost of feeding and clothing soldiers.
I do hope to make an optional food support mechanism at some point as well. It would be more a matter handled through direct consumption of available food where they are at along with food stores in inventories and would lead to wanting to maintain merchant units to caravan food to the front and hold it for supplying units there, as well as at least early hunting to help support a travelling army and pillaging to collect more directly from the tiles. Not so much an automated drain from the city they were created in or from the player level (which doesn't track food on a national level anyhow.)

My understanding is that the idea of a professional soldier is relatively new in history, and most soldiers were really just farmers who left their fields in service of their king (through patriotism or government threats or self-preservation), and for most the only expected pay was the honor when they came home, and any spoils they got from defeated enemies.
I'm sure even by the Classical era, soldiers were being given some direct compensation throughout their time in service, at least as long as currency was in place. Prior to that, sure, it was mostly a fully volunteer job, but yeah basic maintenance would've cost the empire something in most cases. This is why I would envision 'free units' being a factor mostly for earlier civic selections and when armies get past a point it stops being effective.

Your point about pillaging being for the benefit of the soldiers also certainly was a thing... perhaps we should make certain military civics give some free units while then making pillaging not give anything to the state coffers but enhancing morale (at least once I have morale in place, which is actually coming up fairly soon - been sorting out how that's going to work.)

And to clear up a common misconception: In vanilla, there was never military and non-military. There was only a poorly labeled financial advisor screen. The 'military' unit cost you recall, was 0. Always 0, never no 0, no matter your population, size of your army, technology level, year in the game, etc... *Unless* you were running the civic Pacifism. There was never a non-military group. Just the regular unit support cost, and the extra pacifism cost. I don't have my notes on the code in front of me, but I am pretty sure that is still the case in C2C. I don't actually know which civics add to that pool in C2C, but I am pretty sure it is civic only, even still.
Ah that makes more sense that it was an extra expense on pacifism. Huh... I also wondered if it (military upkeep) was somehow tied to the 'outside of borders' added cost.
 
Glad my old research is having some use here. I realize that much of the things I have learned are not common knowledge, even among committed civ players.

You may not recall civ2, but it used production and food as unit upkeep costs instead of gold. There were balance problems… or at least it was a completely different strategy. It was easy to grind your capital into the ground supplying the entire army, making it completely worthless. The micromanagement of moving units around inside your own borders was a significant part of making sure that the right city had full production at the right time. Things like Heroic Epic and West Point (or equivalents like Buffalo Run in C2C) lost a lot of their value. Unit upkeep was changed to gold in later releases because (if I understand correctly, which might be an assumption) that was an empire wide value, whereas production (and food for settlers and workers) was a city level value. It made gameplay more tedious, and in civ2 the values were too big of a percentage of the total to really make sense. In C2C, there is so much more food and production than in civ2, so you could try it again… but there is also so many more units. In addition, civ2 didn’t have buildings that were required to allow certain units, so if one city could build airplanes, they all could. This would be very tedious in C2C… but imagine the AI load, not being able to understand how to balance their cities properly, or to create the right balance of unit enabling buildings.

I suggest that gold per turn instead be thought of and imagined as resource value per turn, and include inside of it the transfer and/or loss of food and/or production. I realize it isn’t ideal, but I think that making a civ2 model or some other supply train model to work well here might be… well, I don’t want to kill your puppy. It’s just, supply has been done and redone so many times by Sid and his successors, I really think it is a bigger can of worms than most people realize.

I do think that the Romans started fielding a standing army at the time of the republican reforms and paid their professionals (in salt?)… but I believe that such *regular* or expected payment (or standing army) was a new idea, and would be more akin to a quality or combat promotion in C2C than a unit every nation can build. I don’t think the Mongolian Hordes were ever paid a salary, and even wages for European knights were rare. But I suppose I don’t know most of the hundreds of military compensation structures prior to Napoleon, so I could be wrong. Either way, we are seeing that paying soldiers for their time and not their success is the exception, not the rule, in history.
 
You may not recall civ2, but it used production and food as unit upkeep costs instead of gold. There were balance problems… or at least it was a completely different strategy. It was easy to grind your capital into the ground supplying the entire army, making it completely worthless. The micromanagement of moving units around inside your own borders was a significant part of making sure that the right city had full production at the right time. Things like Heroic Epic and West Point (or equivalents like Buffalo Run in C2C) lost a lot of their value. Unit upkeep was changed to gold in later releases because (if I understand correctly, which might be an assumption) that was an empire wide value, whereas production (and food for settlers and workers) was a city level value. It made gameplay more tedious, and in civ2 the values were too big of a percentage of the total to really make sense. In C2C, there is so much more food and production than in civ2, so you could try it again… but there is also so many more units. In addition, civ2 didn’t have buildings that were required to allow certain units, so if one city could build airplanes, they all could. This would be very tedious in C2C… but imagine the AI load, not being able to understand how to balance their cities properly, or to create the right balance of unit enabling buildings.
I remember, which is why I don't want to strap it directly to the cities that produce the units directly. The production upkeep probably isn't something to work into the picture and if we did it would have to be evenly distributed throughout the entire nation based on some % of the total against the population of the city sort of calculation. The food would be more of a physical transfer through unit yield inventories the way I have it in mind, so could come from anywhere you want to provide it. It's something that would be based on the concepts I intend for Nomadic stuff.

Either way, we are seeing that paying soldiers for their time and not their success is the exception, not the rule, in history.
Well, sort of depends more on the civics adopted wouldn't it?
 
Back
Top Bottom