jkp1187
Unindicted Co-Conspirator
I am trying to do two things in an event:
1.) Pick a city that meets certain criteria
and
2.) Pick a unit that is located in that city.
Problem is that I can pick the appropriate city, and the appropriate unit, but I'm not sure how to identify the plot of the picked city and the plot of the picked unit to verify that the unit is in the appropriate plot.
I am using callbacks to the python script to identify both via PythonCanDoCity and PythonCanDoUnit in the Civ4EventTriggerInfos.xml file. Problem is that when you use PythonCanDoCity, the city is identified as argsList[2], and under PythonCanDoUnit, the unit is identified as argsList[2]. I'm not sure how to refer to the city under PythonCanDoUnit.
This is the code I had written so far, but obviously I can't progress on this until I can identify the city plot and the unit's plot under the unit script.
1.) Pick a city that meets certain criteria
and
2.) Pick a unit that is located in that city.
Problem is that I can pick the appropriate city, and the appropriate unit, but I'm not sure how to identify the plot of the picked city and the plot of the picked unit to verify that the unit is in the appropriate plot.
I am using callbacks to the python script to identify both via PythonCanDoCity and PythonCanDoUnit in the Civ4EventTriggerInfos.xml file. Problem is that when you use PythonCanDoCity, the city is identified as argsList[2], and under PythonCanDoUnit, the unit is identified as argsList[2]. I'm not sure how to refer to the city under PythonCanDoUnit.
This is the code I had written so far, but obviously I can't progress on this until I can identify the city plot and the unit's plot under the unit script.
Code:
def canTriggerEventUnit(argsList):
ePlayer = argsList[1]
iUnit = argsList[2]
iCity = argsList[2]
kTriggeredData = argsList[0]
pPlayer = gc.getPlayer(kTriggeredData.ePlayer)
pCity = pPlayer.getCity(kTriggeredData.iCityId)
pPlot = pCity.getPlotCity()
pUnit = pPlayer.getUnit(iUnit)
if pUnit.isNone():
return False
if pUnit.atPlot(pPlot):
return True
return False