View Full Version : Help with python.


chrisruls00
Jun 01, 2006, 09:08 PM
I was reading to rulebook and it said you could use python to make certian squares give units experiance or destroy a mountian in mid-game,but i cant find out how to do this.Can anyone tell me how?:confused:

Sto
Jun 02, 2006, 04:58 AM
This is more a question for modders than map scripters . but for the gain of xp ,it should be easy by changing CvEventManager.py :

- you can check every unit ,every turn if it is on a certain plot in : onBeginGameTurn ,onEndGameTurn , onBeginPlayerTurn , onEndPlayerTurn or any event that occur every turn .

- or you can check the plot in : onUnitMove

this depend on what you want to do . (but i'm sure an expert modder can give you more advice )

to change the plot in the current of the game , i try one time to do that and i had an error telling me that the plot generation was done and can't be changed .So i can't tell you more on this , you need the held of an expert modder .

tcho!

Sto
Jun 02, 2006, 05:27 AM
An example that give 1 XP for each unit that are on a hill at the end turn :

change CvEventManager.py :

def onEndGameTurn(self, argsList):
'Called at the end of the end of each turn'
iGameTurn = argsList[0]
map=CyMap()
iW = map.getGridWidth()
iH = map.getGridHeight()
for iX in range(iW):
for iY in range(iH):
pLoopPlot=map.plot(iX,iY)
if pLoopPlot.isHills():
for idUnit in range(pLoopPlot.getNumUnits()):
unit=pLoopPlot.getUnit(idUnit)
if unit.canAcquirePromotionAny():
unit.changeExperience(1,unit.maxXPValue())

Tcho !

EDIT : you can surely check each unit instead of each plot in this case . that may be faster but that depend on the number of plot you want to affect .