[PYTHON] zMax Units

Zebra 9

Emperor
Joined
May 17, 2006
Messages
1,554
Location
Middle of Cyberspace
zMax Units v0.5

Version: v0.5
Type: Python MOD COMP w/ INI Config
Created By: Zebra 9 (@ civfanatics.com)
Compatability: Warlords, and maybe Vanilla (Who knows it might even be compatable w/ Beyond the Sword. Hmmm :D)
MP Compatable: If all players are running it, maybe.
File DB Entry: Download Here

Description:
This allows anyone with an understanding of INI files to prevent civs from training more then a certain number of units. The number of units is determined by, the number of cities the player has, the difficulty level, game speed, map size, and player type (AI, Human). It also displays how many military units you have and how many you are allowed to have. Now v0.3 has the auto AI unit upgrader. v0.4 now allows you have a sort of penalty for having to many cities. Now you can set it so the first city give 4 units, the next 3 and so on.

How To Use:
The base number of units that a city supports is controlled by world size. To set this value you must first find [City Support] in zMax Units Config.ini. After this line put an entry in this form WORLD SIZE TYPE TAG = NEW VALUE, for example WORLDSIZE_TINY = 7. Now there is also an entry that is called "iDefaultCitySupport", the game defaults to this if a map size doesn't have an entry in the file. If this entry is omited the game will default to 0.
Next we have the line [Game Speed], all entries after this are added to the base units that a city supports. After that line put an entry in this form GAME SPEED TYPE TAG = NEW VALUE, for example GAMESPEED_QUICK = -1.
Lastly we have the line that reads [Diff Bonus]. This section controls how many bonus units the human and AI players get on different difficulty levels. Now this is a bit different then the last 2 sections. To set a difficulty level you must go to the line following [Diff Bonus], and put an entry in this form HANDICAP TYPE TAG PLAYER TYPE = NEW VALUE, where PLAYER TYPE can be Human or AI, for example HANDICAP_CHIEFTAIN Human = 6 or HANDICAP_IMMORTAL AI = 8.
At the very end of the file you will see a line that reads [zMax Units Data], and after this line an entry that looks like bAllowContinue = True, this entry controls whether cities should stop production on units that have already been started if you max out your units. If that entry is not found the game defaults to False. If the game doesn't find a certain GAME SPEED or HANDICAP it will default to 0. Also if you copy this MOD COMP into your MOD don't forget to change the file YOUR MOD/Assets/Python/Utils/CvModName.py to read your MOD's name. ;)

How to use v0.4 features:
fNumCitiesChange controls how many unit's each city will change by (set to -1 to have a 4, 3, 2, 1 system, or use a number like -0.5 to get 4, 4, 4, 3, 3, 2, 2, 1, 1) set to 0 to turn off the penalty system
iMinNumSupported controls the minimum number of units a city can support (use this so you don't end up w/ cities that support -5 units)

I hope you all find this to be a very useful MOD COMP. ;) :)

Added 3 Screenies showing the counter. Basically when you hit 75% of the units allowed it displays in yellow, and when you have maxed out it displays in red, anyother time it displays in green.

Check this post to see how awsome this is!:eek:

Spoiler Version Info :
v0.5 Fixed AI auto upgrade
v0.4 added a penalty system
v0.3 added AI auto unit upgrading
v0.25 fixes bug that prevented this from even working


Credits:
Dr. Elmer Jiggle for the INI Config Parser
 

Attachments

  • Green.gif
    Green.gif
    7 KB · Views: 295
  • Yellow.gif
    Yellow.gif
    7 KB · Views: 216
  • Red.gif
    Red.gif
    6.9 KB · Views: 238
Great Zebra 9, absolutely great ;)
 
Hey, by the way, I noticed the counter does not include workers in the total. Is there a way to include them (I mean to include all units except GP's on which one has no control) in the equation?

--------------------------

Edit -- apparently GPs and missionaries don't show up in the total either. I wonder what else isn't counted and why? Does it have to do with whether they come with a maintenance cost?
 
I personally think it's better not including workers, but I guess it depends on the mod...
 
I personally think it's better not including workers, but I guess it depends on the mod...

It also depends upon the intent -- mine was to help limit the total of units the computer has to manage in order to avoid sluggish computer performance in the long run. For some players it's not an issue, for others it is (like me) :mischief:

It's common to see the AI with a bazillion workers doing their stuff, or crowding a city doing absolutely nothing. There's no reason for this, and it I bet it gobbles computer memory pretty good!

The other thing I can do otherwise, is to set low limit on workers (a la "spy"), forcing Civs to rely on captured workers to get the work done when their territory grows larger. It makes sense in my scenario because almost all of the land is already settled. I wouldn't take that approach in a normal, open game, of course.
 
Very nice. Thank you for another excellent component. My game runs adequately as is on most map sizes, but less lag between turns is always a good thing.
 
I ended up with two .ini files after installing the zMaxUnit material. I already had a .ini file in the scenario. Do they need to be combined??
Well this MOD COMP only reads zMax Units.ini, you should also have a normal MOD ini that is created by Civ, normally this ini is has the same name as the MOD.

Yes, this MOD COMP only counts military units (not Settler, Worker, Missionary, or Great Person).
 
Well this MOD COMP only reads zMax Units.ini, you should also have a normal MOD ini that is created by Civ, normally this ini is has the same name as the MOD.

Yes, this MOD COMP only counts military units (not Settler, Worker, Missionary, or Great Person).

OK -- thanks! The comp is terrific. Works very well for what I wanted. :D
 
Ran into a problem. Got to the max limit for combat units, but I could still keep on building new ones past that limit... :confused:

------------------------------------------------------

EDIT

At the very end of the file you will see a line that reads [zMax Units Data], and after this line an entry that looks like bAllowContinue = True, this entry controls whether cities should stop production on units that have already been started if you max out your units. If that enry is not found the game defaults to False.

I deleted these two lines of coding, which seems to fix the problem. It is still possible to select new units to be built at this point (over the max limit when reached), but on the following turn, these builds are cancelled. Would it be complicated to grey out those units that can't be built as a result of the max cap?
 
I'll have to check it. Units shouldn't be listed if you've maxed out. Anyone else encountered this?

When I first encountered the problem I compared the coding you originally came up with in my other thread (Curbing Unit Proliferation) vs the one given here for CvGameUtils.py. They are different. In doubt, I tried copying the earlier coding but I must have done it wrong as the entire section dealing with unit builds disappeared from the city builds screen, regardless of whether I was under or above the max limit. I tossed out that mess, and went back to this thread's coding. I then deleted the two last lines from zMax Units Config.ini. That's when I noticed the excess units weren't greyed out.
 
Yup, there was a hugh bug (It made me wonder if I play test). The bug was so big that this MOD COMP did not work (I'm stupid).
Code:
			if bContinue and not zMaxUnits.canContinue():
should have been:
Code:
			if not bContinue or zMaxUnits.canContinue():
Fixed now.:thumbsup:

Thx Ambreville.

Yea, the code in this is way diff. from what I gave you in that other thread. The reason for this is that I wanted this to have an INI config file.
 
Yea, this code is very user friendly. You could delete everything in the config and it would still work, but it would be useless.
 
Only if you want to. With out them when you max out the units all cities working on units should stop working (very bad if the AI declares war on you and takes a city and maxes your units out).
 
Only if you want to. With out them when you max out the units all cities working on units should stop working (very bad if the AI declares war on you and takes a city and maxes your units out).

OK... I thought this was the point of setting a max limit. With the two lines included and with the above scenario, the cities in the processs of training units would instead be able to complete these builds, but not start new ones afterward -- am I understanding this right?
 
Top Bottom