naf4ever
Dread Lord
This mod here which I originally created for use with my Ultimate Strategy mod makes the Creative trait better and more unique. Basically for any cities size 5 and under it functions exactly like the creative trait now does giving +2 culture/city. With cities 6 and larger though it removes this bonus and instead replaces it with a free Artist! (note: because the culture bonus for cities size 5 and under is done through python you dont actually see the additional +2 culture rate/turn listed on your city screen. But if you glance at your total culture for that city you will see it is indeed rising by an additional +2 every turn like it should.)
This code was originally a piece to give free specialists to certain civics written by Aussie_Lurker. Also thanks goes out to The_Lopez for assistance.
On another note ive found learning python to be quite a task but this piece of code has been extremely useful in helping me undestand many functions. So for those of you also trying to learn it like me, here is a detailed rundown of the lines of code and what they do. You'll find each line is very useful and can easily be incorporated into other programs you're trying to make:
The class definitions, nothing special here.
This line tells it to check and see if the current active player has the creative trait and if it does then go to the next line. You can change the creative part to any other trait if you want. In addition you can change this line back to the original in Aussie_Lurker's mod: (player.isCivic(gc.getInfoTypeForString("CIVIC_SLAVERY"))): which then makes the whole free specialist dependent on the civics instead of traits, in this case slavery!
This line was very helpful to learn. Its a way to tell the mod to focus on all active cities of that player and then perform the following actions which are on lines below it. Great if you want to do something that affects every city of that player.
This tells it to check if the population is 6 or greater then if so it goes to the next line. You can of course change the pop requirement to anything else. I actually have it set to 8 in my mod. You can also replace .getPopulation() >=6): with another command in case you want it to be based on something else like if the city has a particular building or currently has unhappy people.
Assuming the line above this one is true this tells it to add the free specialist and how many, in this case one. Again very easy to change the values or specialist type if you want.
In case the "If" statement above for the population requirement was false this line gets implemented instead. This is where it gives the cities +2 culture. The "True" part tells the additional culture to function normally and affect city borders and territory appropriately (I think).
Hope this has been useful. I was able to learn a lot by studying these lines of code. Ive tested this mod pretty good but if you find any errors please let me know.
-Naf
This code was originally a piece to give free specialists to certain civics written by Aussie_Lurker. Also thanks goes out to The_Lopez for assistance.
On another note ive found learning python to be quite a task but this piece of code has been extremely useful in helping me undestand many functions. So for those of you also trying to learn it like me, here is a detailed rundown of the lines of code and what they do. You'll find each line is very useful and can easily be incorporated into other programs you're trying to make:
Code:
class FreeSpec:
def onBeginPlayerTurn(self, argsList):
'Called at the beginning of a players turn'
iGameTurn, iPlayer = argsList
player = gc.getActivePlayer()
The class definitions, nothing special here.
Code:
if (player.hasTrait(gc.getInfoTypeForString("TRAIT_CREATIVE"))):
Code:
for i in range(player.getNumCities()):
Code:
if (player.getCity(i).getPopulation() >= 6):
Code:
player.getCity(i).setFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_ARTIST"), 1)
Code:
else:
player.getCity(i).changeCulture(iPlayer, 2, True)
Hope this has been useful. I was able to learn a lot by studying these lines of code. Ive tested this mod pretty good but if you find any errors please let me know.
-Naf