View Full Version : on Improvement Destroyed


Zuul
Jan 24, 2006, 05:44 AM
Is there any API call when you destroy/remove/pillage improvements?

And is there any API call when you create and remove units in the world builder? Can't get onUnitCreated and onUnitLost to work.

TheLopez
Jan 24, 2006, 06:05 AM
Is there any API call when you destroy/remove/pillage improvements?


I don't think there is anyway to check for the event when a improvement is destroyed.


And is there any API call when you create and remove units in the world builder? Can't get onUnitCreated and onUnitLost to work.


I couldn't find any.

snarko
Jan 24, 2006, 07:21 PM
From CvWorldBuilderScreen.py:


def placeObject( self ) :
*snip*
elif ((self.m_bNormalPlayer) and (self.m_normalPlayerTabCtrl.getActiveTab() == self.m_iUnitTabID)):
iUnitType = self.m_iNormalPlayerCurrentIndexes[self.m_normalPlayerTabCtrl.getActiveTab()]
pPlayer = gc.getPlayer(self.m_iCurrentPlayer)
iPlotX = self.m_iCurrentX
iPlotY = self.m_iCurrentY
pPlayer.initUnit(iUnitType, iPlotX, iPlotY, UnitAITypes.NO_UNITAI)


def removeObject( self ):
*snip*
elif ((self.m_bNormalPlayer) and (self.m_normalPlayerTabCtrl.getActiveTab() == self.m_iUnitTabID)):
for i in range (self.m_pCurrentPlot.getNumUnits()):
pUnit = self.m_pCurrentPlot.getUnit(i)
if (pUnit.getUnitType() == self.m_iNormalPlayerCurrentIndexes[self.m_normalPlayerTabCtrl.getActiveTab()]):
pUnit.kill(false, PlayerTypes.NO_PLAYER)
return 1

The Great Apple
Jan 25, 2006, 07:19 AM
I'm pretty sure I had onUnitCreated working with the WB.

CvWorldBuilderScreen.py would be safer though!