deanej
Deity
I'm trying to make it so that if an animal captures a city the city gets automatically killed (naturally I made it so that animals can enter borders in the first place). I'm trying to add code to onCityAcquired to make this happen, but it doesn't work at all. I think it's because the unit moves before the onCityAcquired code occurs, but I can't know for sure because when I attempted to add messages to debug the problem I suddenly got a python exception when the code runs.
Python Exception:
Debug Text:
I also want to make it possible for the game to find where a specific unit is on the map and trigger events based on what feature the unit is on. I'm hoping to loop through the plots on the map and using code similar to this. Is this feasible?
Code:
if(pCity.isBarbarian()):
bCityAlive = true
pPlot = pCity.plot()
print "City captured by barbarians"
#unitList = pPlot.getUnits()
iNumUnits = pPlot.getNumUnits
print "iNumUnits: %d" (iNumUnits)
for c in range(pPlot.getNumUnits()):
unit = pPlot.getUnit(c)
print "Cycle units, unit number %d" (c)
if (unit.isAnimal() and bCityAlive):
pCity.kill()
print "Unit is Animal, city killed"
bCityAlive = false
Python Exception:
Spoiler :
Traceback (most recent call last):
File "CvEventInterface", line 19, in onEvent
File "CvEventManager", line 187, in handleEvent
File "CvFinalFrontierEvents", line 1639, in onCityAcquired
TypeError: 'str' object is not callable
ERR: Python function onEvent failed, module CvEventInterface
File "CvEventInterface", line 19, in onEvent
File "CvEventManager", line 187, in handleEvent
File "CvFinalFrontierEvents", line 1639, in onCityAcquired
TypeError: 'str' object is not callable
ERR: Python function onEvent failed, module CvEventInterface
Debug Text:
Spoiler :
PY:City Acquired Event: Planet 1
City captured by barbarians
PY:City Acquired and Kept Event: Planet 1
City captured by barbarians
PY:City Acquired and Kept Event: Planet 1
I also want to make it possible for the game to find where a specific unit is on the map and trigger events based on what feature the unit is on. I'm hoping to loop through the plots on the map and using code similar to this. Is this feasible?