In event, unit in a particular city

wotan321

Emperor
Joined
Oct 25, 2001
Messages
1,228
Location
NC, USA
This is similar to another thread question but I gave it its own thread because when I am searching its a pain when things are discussed in threads totally unrelated to the thread name.... so anyway....

In python, in an event trigger, I want a particular unit in a particular city, or in a city with a certain wonder, to trigger the event. I am not sure if the existing xml trigger file does this, the documentation does not discuss this, and info on the forum is unclear as well.

Any help is appreciated.
 
Okay, I see where there is already a trigger for that using python. I found some custom events others had made and that is answering a lot of questions.

There is some python that asks if a certain building is in the picked city. Hmmm... but that does NOT answer my question actually. I still want to know if a particular unit is in a city with a certain building.
 
Shouldn't be that much different.

PHP:
def canTriggerSomeUnit(argsList):
	eTrigger = argsList[0]
	ePlayer = argsList[1]
	iUnit = argsList[2]
	
	player = gc.getPlayer(ePlayer)
	unit = player.getUnit(iUnit)
	
	if unit.isNone():
		return False

	iX = unit.getX()
	iY = unit.getY()
	pPlot = CyMap().plot(iX,iY)
	if pPlot.isCity ():
                pCity = pPlot.getPlotCity ()
                if (player.getCivilizationType () == gc.getInfoTypeForString("CIVILIZATION_GERMANY")) and (unit.getUnitType () == gc.getInfoTypeForString("UNIT_FIGHTER")) and ("Red Baron" in unit.getName ()) and (pCity.getName () == "Cologne"):
                        return True

	return False

You see, civ, unit and unit name checks are still in, but i added some code snippets to check for a city and its name.
 
Back
Top Bottom