Python modcomp for conditional promotions and opp fire

mtagge

Clueless Tweaker
Joined
Dec 29, 2007
Messages
111
Location
Frankfurt
I don't play regular Civ IV anymore (almost exclusively FFH II when I find the time for a game), but I thought I would throw out the python modcomp that I have setup for my own enjoyment in case anyone else out there is interested.

All of the variables are set for FFH units, but the python is easy to modify with all the variables up front and documented. There are two parts to the modcomp, one lets units provide opportunity fire when in certain improvements to hostile units entering their borders, the other one lets units provide custom promotions based on conditions. If you use the conditional promotions you will need to create your own promotions in XML, but here is an light example of some of the stuff I did (remember I play FFH, so these are all fantasy units):

• Great Commanders provide a promotion to all units stacked with them that increases the XP gained from combat, lets the units attack across rivers without penalty, gives a 10% increase in city defense, and reduces upgrade costs by 25%.
• Hawks provide +2 sight range to recon units in the same stack as themselves as well as provide 1 first strike.
• Rangers, Satyrs, and Druids are invisible to enemy units as long as they remain in a forest, jungle, or an ancient forest.
• Archmages tutor arcane units in the same stack. This provides a 20% upgrade discount. In my game I use it to increase the rate of XP gain to adepts, but that is beyond the scope if this modcomp and uses additional python calls.

Feel free to mess with this all you want, if you use it in a larger mod, just let me know so I can try it out.

Cheers

edit: AFAIK this only works for BTS, I haven't tried it on other versions.
 
Awesome. Thanks for this. :goodjob:

Can this also control interactions between units and civics? I know that in FfH2 when under slavery you can enslave enemy units. How is that done?

If I were to do an enslavement mechanism, I would do a python check during onUnitKilled, check the attacker, check the attacker's civic, then do a random check to decide to create a unit.

If someone were to go the SDK route, I think that is one of the example in Kael's tutorial.
 
A major lightbulb went off I pulled all the variables into the class and set them as global variables to do all the gc.getInfoTypeForString() commands only once. This let me dramatically speed up the code so that on a large map it played much faster than a standard map before. This let me pull out most of the for i in (0, len(x)): code and replace it with if y in x: doubling the speed gains. This did cause me to pull all three major functions into one class so that all the variable would be set in one place.
 
Back
Top Bottom