why is this mod only working on human players?

naf4ever

Dread Lord
Joined
Feb 8, 2003
Messages
405
Location
Southeast Washington State
This is a very simple mod that touches up the creative trait some. It basically gives you a free specialist once your cities get to size 12 or greater. Through further testing though its come to my attention that this mod doesnt work for AI players, only human ones. I have no clue why. Here is the code:

Code:
class FreeSpec:
	def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		
		iGameTurn, iPlayer = argsList
		player = gc.getActivePlayer()
		
		if (player.hasTrait(gc.getInfoTypeForString("TRAIT_CREATIVE"))):
			for i in range(player.getNumCities()):
				if (player.getCity(i).getPopulation() >= 12):
					player.getCity(i).setFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_ARTIST"), 1)

Its nothing special as you can see. I tested it by making some AI cities big enough with the world editor then using the game.toggledebugmode option in the command console so i can see everyones cities. I of course tested it on a creative race. The AI cities would not generate the free artist like they should. In addition i was messing with another mod im using that gives a free building to certain cities. Again it would work perfect for humans but wasnt benefitting the AI players. Anyone know why?

If youd like to try and download it and test it out yourself can do so with a slightly modified version here: http://forums.civfanatics.com/showthread.php?t=162656

Im curious to know why this isnt working on the computer. Or is my testing method flawed?
 
The reason why is because in your code you are getting the active player. You need to change the line:
player = gc.getActivePlayer()

to:

player = gc.getPlayer(iPlayer)
 
Back
Top Bottom