Concept:Military Size limit

Slash1667

Chieftain
Joined
Sep 1, 2010
Messages
4
I figured I'd throw this out and see what everyone thought about it. I'd like to see a mod that would limit military production to a calculation based on your total Civ population. For example say you have 5 cities each with a 10 pop. If the military production rate is set to 50% then you would only be able to have 25 MILITARY units in play at one time. You could then have another 50% of your pop in city garrisons which could not be moved out of the city if you were already at the other limit. This would not effect non-military units such as Settlers, Scouts, Workers and Missionaries. You might also want to have naval units restricted to 25% not included in the 50% military limit. This is an idea that I've had since I heard ciV was 1upt and didn't care for it but thought that SODs should be limited and have a disadvantage other than Nukes. :)
 
A limit on production would probably be easy to achieve, but the city garrison limitation not so. It would be confusing at best. The implementation would also possibly be somewhat awkward.

What I propose, instead, is to use the national unit feature on all military units, but make the actual limit dynamic. This wouldn't only limit the total number of military units, but would also force a more balanced makeup of forces.

Both proposals probably require SDK changes though. Its doable but its a real programming job.
 
Ok, how about we cut out the calculations and limit total unit production to civ population?
 
Simpler is often better, but there needs to be something that the player can build after all buildings have been built - if the unit limit has been reached. Since I found a way to fetch the number of military units there is no reason to limit non-military units.

This would be easy to implement if you wanna test it. It involves editing a method definition in CvGameUtils.py and enabling the associated callback in PythonCallbackDefines.xml.
Spoiler :
@ \My Documents\My Games\Beyond the Sword\CustomAssets\Python\CvGameUtils.py
Code:
	def cannotTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]

[B]		pPlayer = gc.getPlayer(pCity.getOwner())
		iNumMilitaryUnits = pPlayer.getNumMilitaryUnits()
		iNumCitizens = pPlayer.getTotalPopulation()
		return iNumMilitaryUnits >= iNumCitizens[/B]
@ \My Documents\My Games\Beyond the Sword\CustomAssets\XML\PythonCallbackDefines.xml
Code:
	<Define>
		<DefineName>USE_CANNOT_TRAIN_CALLBACK</DefineName>
		<iDefineIntVal>[B]1[/B]</iDefineIntVal>
	</Define>
 
Just to throw in another idea I did in my mod to limit military units and to encourage diversity in the army (sounded a bit gay didnt it :))

Every type of unit will get 5% more expensive for each of the same unit built.
So it would be cheaper to built 5 archers, 5 javelineers and 5 spearmen rather than build 15 archers if for example the 3 units cost 100 :hammers: each.
5 of each : (100+105+110+115+120) x 3 = 1650
15 of one : (100+105+110+115.. ..+170) = 2025
 
Something like limiting the production of units by population seems to be the most intelligent solution yet for CivIV as a unit stack limitation is problematic and just gives the same "log jam" the plagues Civ5.

In addition, although my earlier idea to attach a mineral cost to unit upkeep would more accurately reflect the "real world" cost of maintaining military forces it carries the possibility that the CivIV AI would not recognise it and routinely just run it's economies into stagnation. (Similarly, I think Vincent's suggestion may carry this same problem. Although making late game units progressively more expensive to build and maintain is an interesting thought to add more realism.)

Simpler is often better, but there needs to be something that the player can build after all buildings have been built - if the unit limit has been reached. Since I found a way to fetch the number of military units there is no reason to limit non-military units.

This would be easy to implement if you wanna test it. It involves editing a method definition in CvGameUtils.py and enabling the associated callback in PythonCallbackDefines.xml.
Spoiler :
@ \My Documents\My Games\Beyond the Sword\CustomAssets\Python\CvGameUtils.py
Code:
	def cannotTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]

[B]		pPlayer = gc.getPlayer(pCity.getOwner())
		iNumMilitaryUnits = pPlayer.getNumMilitaryUnits()
		iNumCitizens = pPlayer.getTotalPopulation()
		return iNumMilitaryUnits >= iNumCitizens[/B]
@ \My Documents\My Games\Beyond the Sword\CustomAssets\XML\PythonCallbackDefines.xml
Code:
	<Define>
		<DefineName>USE_CANNOT_TRAIN_CALLBACK</DefineName>
		<iDefineIntVal>[B]1[/B]</iDefineIntVal>
	</Define>

I like this idea! It is simple and practical without "butchering" the game's code and leaves the possibility for little tweaks to be applied. It is probably compatable with the CivIV AI as well. However, whereas I understand the basic concepts, I am not a python programmer. Baldyr how would one write this to, for example, limit one military unit per 1000 population of a civ?

I would like to jump on board and help test and develope this a little more.
 
How would one write this to, for example, limit one military unit per 1000 population of a civ?
Probably like this:
Code:
		pPlayer = gc.getPlayer(pCity.getOwner())
		iUnitPerPopulation = 1000
		iNumMilitaryUnits = pPlayer.getNumMilitaryUnits()
		iPopulationUnitLimit = int(pPlayer.getRealPopulation() / iUnitPerPopulation)
		return iNumMilitaryUnits >= iPopulationUnitLimit
 
Probably like this:
Code:
		pPlayer = gc.getPlayer(pCity.getOwner())
		iUnitPerPopulation = 1000
		iNumMilitaryUnits = pPlayer.getNumMilitaryUnits()
		iPopulationUnitLimit = int(pPlayer.getRealPopulation() / iUnitPerPopulation)
		return iNumMilitaryUnits >= iPopulationUnitLimit

I see and of course one could use other values besides 1000 but I do believe I can use it now that you've laid it all out for me and I thank you for doing that. Perhaps I'll give it a try tomorrow and see how it goes. It may need a few tweaks if the concept proves sound, (i.e. what will the AI do with all the gold and minerals not being spent on units, etc.), but I think this is good and may work very well.
 
Thanks for the kind words and assistance on this everyone. If i can figure out the python and mod stuff I'll try it out tomorrow and see how it works. The idea came from an extreme dislike of the 1upt while also trying to keep SoDs to a more manageable level. One question, would it be easier to do per population (2,000,000 people) or city population (10 cities with a total of 125 population)?
 
I would favor the per-total-population-of-the-civ as that seems to keep the changes as plain as is possible. Like I alluded earlier, I feel it is important to keep script and coding changes simple and to a bare minimum when moding so as not to "butcher" the game with overly ambitious projects that may exceed its inherent design limitations.

You know, as a by-product, a population/unit cap can improve the games speed and performance on larger maps. Especially late game turns.
 
If i can figure out the python and mod stuff I'll try it out tomorrow and see how it works.
When you edit the files concerned, be sure to use UTF-8 encoding when saving. If you can't get it right, holler and I'll provide you with a working set of files.

Anyone editing .py files should enable Python exceptions, logging and pop-up messages in the CivilizationIV.ini file. Otherwise you don't know why things aren't working or what the problem is.

One question, would it be easier to do per population (2,000,000 people) or city population (10 cities with a total of 125 population)?
I'm not sure I understand. I think I already did both setups, not? :confused:
 
is there an easy way to add a counter on the main screen. something like 12/36 meaning that I have 12 units and my limit is 36..
 
I am totally going to use this in my mod. Except that in my version, buildings, wonders, and civics can also effect the military size. Of course, I can do more, since I'll be doing it in C++.
 
is there an easy way to add a counter on the main screen. something like 12/36 meaning that I have 12 units and my limit is 36..
It might be... I'm not sure how to do it exactly however, as I never modded the interface myself.
 
is there an easy way to add a counter on the main screen. something like 12/36 meaning that I have 12 units and my limit is 36..

You would need to change CvMainInterface.py. In Rise of Mankind just this thing was added to the city screen to tell you how many national and great wonders you had built and the limit.
 
I have no idea of coding, as you can see, but at least it works:

szText8 = localText.getText("TXT_KEY_UL1", (gc.getPlayer(ePlayer).getNumMilitaryUnits() , )) + localText.getText("TXT_KEY_UL2", (gc.getPlayer(ePlayer).getTotalPopulation() / 2 + 4 , ))

I placed this in CvMainInterface.py and defined in the text files TXT_KEY_UL1 and 2 with one parameter each.
In my version of this, the limit is equal 4 + (citypops / 2).

Please, give some advice how to make the code simpler.
 
Please, give some advice how to make the code simpler.
It works? What could be simplified, you mean? I'd say let it be if it works.
 
It works? What could be simplified, you mean? I'd say let it be if it works.

Maybe there is a way to do it, without adding entries to the XML\Text files. I ll be happier if I don't have to edit multiple files, but you are right - it works :)
 
If you post the actual strings you added in the XML someone will be able to help you put everything into the same file.

But doing it the proper way allows for translation, if that is of any concern to you.
 
Top Bottom