j_mie6
Deity
did it like this:
Code:
def constructionTimer(self):
if self.isUnit() and self.isSite():
if self.isInvalidUnit():
self.removeUnit(self.getUnit())
elif self.getTimer() == 1:
self.spawnCatapult()
self.enableUnitAI()
else:
if self.getSite().getFeatureType() == eForest:
self.countdown()
return True
else:
self.enableUnitAI()
self.reset()
## def checkUnits(self):
## for pUnit, pPlot in list((pUnit, pUnit.plot()) for pUnit in self.iterateUnits()):
## if pPlot.isNone() or pUnit.isDead(): continue
## if pPlot.getFeatureType() == eForest:
## if isEnemyTerritory(pUnit, pPlot, self.pCivPlayer.get(CyTeam)) or self.isUsed(pUnit): return
## self.activateOverwatch(pUnit, pPlot)
## break
def checkUnits(self):
for pUnit, pPlot in list((pUnit, pUnit.plot()) for pUnit in self.iterateUnits()):
try:
if pPlot.isNone() or pUnit.isDead(): continue
if pPlot.getFeatureType() == eForest:
if isEnemyTerritory(pUnit, pPlot, self.pCivPlayer.get(CyTeam)) or self.isUsed(pUnit): return
self.activateOverwatch(pUnit, pPlot)
break
except:
self.removeUnit(pUnit)
print ("invalid unit!", pUnit)
def activateOverwatch(self, pUnit, pPlot):
self.setUnit(pUnit)
self.setSite(pPlot)
self.resetTimer()