Hi, I am having some trouble figuring out why I can use these functions in some places and not others. If someone could enlighten me I would appreciate it.
For example if I put this I can kill a city as soon as it is created:
However if I put this my log file shows that the city object has no attibute .kill():
I can however use the .setPopulation attribute as such:
For example if I put this I can kill a city as soon as it is created:
Code:
def onCityBuilt(self, argsList):
'City Built'
city = argsList[0]
if (city.getOwner() == CyGame().getActivePlayer()):
self.__eventEditCityNameBegin(city, False)
city.kill()
CvUtil.pyPrint('City Built Event: %s' %(city.getName()))
However if I put this my log file shows that the city object has no attibute .kill():
Code:
def onUnitKilled(self, argsList):
'Unit Killed'
unit, iAttacker = argsList
player = PyPlayer(unit.getOwner())
attacker = PyPlayer(iAttacker)
if (not self.__LOG_UNITKILLED):
return
CityList = player.getCityList()
for City in CityList:
City.kill()
CvUtil.pyPrint('Player %d Civilization %s Unit %s was killed by Player %d'
%(player.getID(), player.getCivilizationName(), PyInfo.UnitInfo(unit.getUnitType()).getDescription(), attacker.getID()))
I can however use the .setPopulation attribute as such:
Code:
def onUnitKilled(self, argsList):
'Unit Killed'
unit, iAttacker = argsList
player = PyPlayer(unit.getOwner())
attacker = PyPlayer(iAttacker)
if (not self.__LOG_UNITKILLED):
return
CityList = player.getCityList()
for City in CityList:
City.setPopulation(40)
CvUtil.pyPrint('Player %d Civilization %s Unit %s was killed by Player %d'
%(player.getID(), player.getCivilizationName(), PyInfo.UnitInfo(unit.getUnitType()).getDescription(), attacker.getID()))