So, i tried my hands on 2 requested projects with a python effect, and realized afterwards that the AI will never ever build them, because there's no XML value to influence that.
But i remembered the AI_chooseProduction function in CvGameUtils, and that you can hook in there to influence the production choice.
I added my code, tested it...and it wrecked the AI! The code was executed, but the cities were just sitting idle, doing nothing.
Since the AI is still randomly chaning the production from *nothing* to the preferred units or buildings, there must be somewhere be a really damn small and dumb error, which i can't see at the moment.
Can anyone maybe take a look at the code (see below)?
In my opinion it should work, and i also don't get any exception messages, but something is borked.
The included prerequisites are custom for the project, and since turning the True into a False will fix the problem i know the code works to its end...but something doesn't. Does anyone see what exactly?
But i remembered the AI_chooseProduction function in CvGameUtils, and that you can hook in there to influence the production choice.
I added my code, tested it...and it wrecked the AI! The code was executed, but the cities were just sitting idle, doing nothing.
Since the AI is still randomly chaning the production from *nothing* to the preferred units or buildings, there must be somewhere be a really damn small and dumb error, which i can't see at the moment.
Can anyone maybe take a look at the code (see below)?
Spoiler :
PHP:
def AI_chooseProduction(self,argsList):
pCity = argsList[0]
###hanseatic league - AI start
pPlot = pCity.plot()
if pPlot.isCoastalLand():
pPlayer = gc.getPlayer(pCity.getOwner())
iHanse = gc.getInfoTypeForString("PROJECT_HANSEATIC_LEAGUE")
if pPlayer.canCreate(iHanse, True,False):
pTeam = gc.getTeam(pPlayer.getTeam())
if pTeam.isHasTech(gc.getInfoTypeForString("TECH_ASTRONOMY")):
if pTeam.getAtWarCount(True)<=0:
pCity.chooseProduction(pCity.getProductionUnit (),pCity.getProductionBuilding (),iHanse,False,False)
return True
###hanseatic league - AI end
return False
In my opinion it should work, and i also don't get any exception messages, but something is borked.
The included prerequisites are custom for the project, and since turning the True into a False will fix the problem i know the code works to its end...but something doesn't. Does anyone see what exactly?