[PYTHON] zLeaders (Ever wanted a Leader Spacific UU)

Zebra 9

Emperor
Joined
May 17, 2006
Messages
1,554
Location
Middle of Cyberspace
zLeaders MOD COMP v0.1

Type: PYTHON MOD COMP
Version: 0.1
Langages Used: Python
By: Zebra 9
Multiplayer Compatible: Shouldn't affect MP games
File DB: Down Load Here

Description:
Have you ever wanted to let only one leader be able to build a certain type of unit, sort of like a Leader Spacific UU? And for that matter a Leader Spacific UB? Well now you can do both!
This is a very simple Python MOD COMP that allows anyone to set units or buildings to require a certain leader.

All of this is acomplished via 2 functions:
self.addUnitLeader: This will add a leader to the list of leaders that can build this unit,
self.addBuildingLeader: This will add a leader to the list of leaders that can build this building.​
Now to use these to do what you want, place the appropriate functions after the code that looks like:
Code:
########################################################################################################
################            Add Your Code Below Here            ################
########################################################################################################
and before the code that looks like:
Code:
########################################################################################################
################            Change Nothing Below Here            ################
########################################################################################################
Now for a little more info on the 2 functions. They both take 2 arguments. The first argument is the unit or building type tag (UNIT_WARRIOR or BUILDING_BARRACKS), and the second argument is a leader type tag (LEADER_ALEXANDER). Now you can set as many leaders as you want to build a certain Unit/Building just by calling the addUnitLeader or the addBuildingLeader functions with the appropriate number of times.
Now for an example:
Code:
        self.addUnitLeader("UNIT_WARRIOR", "LEADER_ALEXANDER")
Now only Alexander can build warriors (Well Huayna Capac can still build the Quechua).
Code:
        self.addBuildingLeader("BUILDING_WALLS", "LEADER_ALEXANDER")
Now only Alexander can build a barracks (Well Shaka can still build his... his... his UB, what ever it's called).
Now let's say you wanted both Alexander and Washington to be able to build warriors, you would use code like this:
Code:
        self.addUnitLeader("UNIT_WARRIOR", "LEADER_ALEXANDER")
        self.addUnitLeader("UNIT_WARRIOR", "LEADER_WASHINGTON")
This also works with the buildings.


Now you could use a combination like this:
Code:
        self.addUnitLeader("UNIT_WARRIOR", "LEADER_ALEXANDER")
        self.addBuildingLeader("BUILDING_WALLS", "LEADER_ALEXANDER")
        self.addUnitLeader("UNIT_WARRIOR", "LEADER_WASHINGTON")
Now only Alexander and Washington can build warriors, and only Alex can build a barracks.:D

Installation:
1) Unzip into "My Documents\My Games\Warlords\MODS".
2) Load the game.
3) Click on "Advanced"-->"Load A MOD"-->"zLeaders"-->"OK", the Game will restart.
4) Now you can play as normal

Enjoy! :goodjob:
 
Hmm i don't want to hijack your work i reale aperciate this modcomp - for sure it will be useful for many ppl.
But it's possible to make this only through .xml
When you create new class in civ4unitsclass you put NONE in the defaultunit tag

And than you make everything like for new unit - the effect is that this unit would have only choosed civilization (in civ4civilizationsinfos)

EDIT

Sorry i misunderstanded what this modcomp gives :(
 
Thanks. I think that this will really be nice. Each civ can now have a unique unit and each leader can add another.
 
Hmm i don't want to hijack your work i reale aperciate this modcomp - for sure it will be useful for many ppl.
But it's possible to make this only through .xml
When you create new class in civ4unitsclass you put NONE in the defaultunit tag

And than you make everything like for new unit - the effect is that this unit would have only choosed civilization (in civ4civilizationsinfos)

Yeah but this mod allows unique units/building for individual leaders (which is impossible only through xml). This is a really good idea :D You could have things like Stalin getting russian tanks while catherine gets the cossack unit.
 
Yeah but this mod allows unique units/building for individual leaders (which is impossible only through xml). This is a really good idea :D You could have things like Stalin getting russian tanks while catherine gets the cossack unit.

Ah now i get it :D
Indeed awesome idea :) it gives a lot of flexibility and honey to the game
 
Glad you guys like it. I'm trying to figure the ini config thingy working so in the future my MOD COMPs are alittle easier to use.:thumbsup:
 
This is a clever idea that I never thought of... it'll be a good way to beef up certain leaders whose traits aren't fantastic by giving them better buildings/units, or to tone down over-powered leaders by giving them units or buildings that don't further accentuate their advantages.

Although coming up with UUs for every leader will be hard I think...
 
Glad to hear your figuring out ini files. A few things you may not be aware of that have come up before.

In normal python os.path.abspath(".") will return the path to the file you run the function from, but from within the game it doesn't work that way. At most it will return 'C:\blah\Civ4' for Vanilla Civ4 or C:\blah\Civ4\Warlords for Warlords.

This is a symptom of the inability to get what mod is running from inside Civ. The current workaround is to include a file called CvModName.py in any of the mod's directories. CvModName file should have an attr named modName that is set to the name of the mods root directory. You can then import this file get the attr and use os.path.join(os.path.abspath("."), "Mods", CvModName.modName, sINIFileName) to get the path to the mods ini file.

Just thought I would mention it, if you run into any problems don't be afraid to ask, I'm always glad to help. :)
 
Excellent idea! Firaxis should have thought of this one.
 
Yeah, but again... it's hard coming up with even a single UU for some civilizations let alone coming up with multiple UUs and UUs that somehow have to tie in with the specific leader at that... I mean, Catherine and Stalin is a good but easy example... can you think of what would be the difference for Hatshepsut and Ramesses? I can't...

I see this being most useful in mods or scenarios where choosing a leader for a particular civ should have interesting consequences on the military. For example, if this isn't already in FfH2, it ought to be...
 
Very nice! Thank you, Zebra! :goodjob:

I'm going to use this in my Rulers of Russia mod.
 
Nice day, Zebra 9. I have big request for you. This idea has birth in asioasioasio thread: http://forums.civfanatics.com/showthread.php?t=223175
Can you, please, write modcomp that allow build by workers AirBase out of town as improvement. So that airplanes can make landing here as in civ2
I asked Lopez but he does not answer. And now I noticed that you are good in Python. Please write me if you are willing to write code for AirBase, please :)
 
Can you, please, write modcomp that allow build by workers AirBase out of town as improvement. So that airplanes can make landing here as in civ2 I asked Lopez but he does not answer. And now I noticed that you are good in Python. Please write me if you are willing to write code for AirBase, please :)

Well, that really is 2 different things, neither of which can be done in python (well, not without getting really hacky and complicated), but both of which are acually done already. TheLopez did make a mod that allows units to build outside culture, look in the downloads database under modcomps sdk, its call Improvements Outside Borders Mod.

As for planes being able to rebase at an airbase, that is done in TradeRoutes Mod by Chinese American, which uses TheLopez's Imp. Outside Borders Mod, and is also in the SDK section of the donwload database.
 
I´m not unfortunately programmer. I dont understand it at all. I and Asio, too, I think, would be glad, if someone manages to do it. :worship:
 
Ok. I want Cossacks as UU for Catherine and T-34 - for Stalin. Cossacks - UU for Russia. So, what Cavalry unit (if any) will be available to Stalin after I add this line:

self.addUnitLeader("UNIT_COSSACKS", "LEADER_CATHERINE")

Any clues? :confused:
 
Well if you leave the cossaks unit class the same as the cavalry Stalin will not be able to build any cavalry units.
 
Not realy, if he changes the cossacks unit class to UNITCLASS_COSSAK (and of course adds it to the UnitClassInfos.xml and removes the Cossak from the as a civ UU), then sets Cathrines UU to cossak Stalin will be able to build cavalry.
 
Back
Top Bottom