DaddyHolby
Chieftain
Hello all this is my first attempt at modifying python and I'm a bit lost.
I've been trying to give the winning unit in a fight extra experience. This is just something I thought would be "easy" for a first attempt. The long term goal is to be able to give a unit a special promotion after X number of victories or span a special unit after a victory (of course this might not be the best place to do this, but like I said this looked to be the easiest place to go).
To do this I found the onCombatResult function in the CvEventManager class. So I did the following:
Orig:
Modified:
This of course doesn't work, so I tried several other things and even just tried to get this function to error out in one of the debug logs and still didn't get anything. I've been searching the forums for anything that would help and haven't found anything that has worked, though this could be because of my lack of python knowledge.
Anybody have any clue as to what I'm doing wrong?
I've been trying to give the winning unit in a fight extra experience. This is just something I thought would be "easy" for a first attempt. The long term goal is to be able to give a unit a special promotion after X number of victories or span a special unit after a victory (of course this might not be the best place to do this, but like I said this looked to be the easiest place to go).
To do this I found the onCombatResult function in the CvEventManager class. So I did the following:
Orig:
Code:
def onCombatResult(self, argsList):
'Combat Result'
pWinner,pLoser = argsList
playerX = PyPlayer(pWinner.getOwner())
unitX = PyInfo.UnitInfo(pWinner.getUnitType())
playerY = PyPlayer(pLoser.getOwner())
unitY = PyInfo.UnitInfo(pLoser.getUnitType())
if (not self.__LOG_COMBAT):
return
if playerX and playerX and unitX and playerY:
CvUtil.pyPrint('Player %d Civilization %s Unit %s has defeated Player %d Civilization %s Unit %s'
%(playerX.getID(), playerX.getCivilizationName(), unitX.getDescription(),
playerY.getID(), playerY.getCivilizationName(), unitY.getDescription()))
Modified:
Code:
def onCombatResult(self, argsList):
'Combat Result'
pWinner,pLoser = argsList
playerX = PyPlayer(pWinner.getOwner())
unitX = PyInfo.UnitInfo(pWinner.getUnitType())
playerY = PyPlayer(pLoser.getOwner())
unitY = PyInfo.UnitInfo(pLoser.getUnitType())
unitX.setExperience(500)
if (not self.__LOG_COMBAT):
return
if playerX and playerX and unitX and playerY:
CvUtil.pyPrint('Player %d Civilization %s Unit %s has defeated Player %d Civilization %s Unit %s'
%(playerX.getID(), playerX.getCivilizationName(), unitX.getDescription(),
playerY.getID(), playerY.getCivilizationName(), unitY.getDescription()))
This of course doesn't work, so I tried several other things and even just tried to get this function to error out in one of the debug logs and still didn't get anything. I've been searching the forums for anything that would help and haven't found anything that has worked, though this could be because of my lack of python knowledge.
Anybody have any clue as to what I'm doing wrong?