[Python] <canTriggerUnit>

jkp1187

Unindicted Co-Conspirator
Joined
Aug 29, 2004
Messages
2,496
Location
Pittsburgh, Pennsylvania
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.

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
 
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.

Why not simply 1) Pick a city that meets certain criteria and have an unit located in with certain criteria . ?

Tcho !
 
I suppose I could...I was trying to keep things in sync with the pre-existing tags in the Events XML file, which meant following their pattern (python trigger/python cando city/python cando unit.) I suppose I could just put everything in the python trigger file, ask for the appropriate city and make sure that it has that specific unit, then when the event choice is made, make the subsequent script in Python too (because if x = 1 in the trigger, it will continue to =1 in the candoEvent script). It was just conceptually easier for me to keep as much in the XML as possible. I'll see what i can do with that route.

Yawn. Tomorrow...zzzzz.....
 
Back
Top Bottom