The Capo
godless Heathen
I am in the process of creating a mod, and I noticed after adding a new python wonder (the Flavian Amphitheatre) I am starting to experience sporadic MAFs. Which is upsetting because, up until this point, I had played and finished many long games without a MAF.
I was just wondering if there was a way to tell how much memory is wasted on a particular function. I am asking this as a general question, but here is a specific example of the wonder I am talking about. Here is the code for it:
If anyone could tell me how memory-demanding this code is, that would be helpful. I am deciding if this wonder is worth having. Basically what it does is give you a chance to build a rival's UU rather than the unit in replaces. So if you were the Maya and were playing a game against the Byzantines, when you build a Knight there is an X% chance it will be a Cataphract.
The wonder is cool, but not game-breaking or that necessary, so I was just wondering if I should do away with it.
I was just wondering if there was a way to tell how much memory is wasted on a particular function. I am asking this as a general question, but here is a specific example of the wonder I am talking about. Here is the code for it:
Code:
def onUnitBuilt(self, argsList):
'Unit Completed'
city = argsList[0]
unit = argsList[1]
player = PyPlayer(city.getOwner())
## Topkapi Palace Start ##
pCity = argsList[0]
pUnit = argsList[1]
pPlayer = gc.getPlayer(pUnit.getOwner())
iUnitType = pUnit.getUnitType()
b_BUILDING_TOPKAPI = gc.getInfoTypeForString("BUILDING_FLAVIAN")
obsoleteTech = gc.getBuildingInfo(b_BUILDING_TOPKAPI).getObsoleteTech()
if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
if ( pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_FLAVIAN"))>0 ):
iTeam = pPlayer.getTeam()
pTeam = gc.getTeam(iTeam)
l_vassalUB = []
for iPlayer in range(gc.getMAX_PLAYERS()):
ppPlayer = gc.getPlayer(iPlayer)
if ( (ppPlayer.isAlive()==true) and (ppPlayer.isBarbarian()==false) ):
if ( (gc.getTeam(ppPlayer.getTeam()).isHasMet(iTeam)) and (ppPlayer.isAlive()==true) and (ppPlayer.isBarbarian()==false) ):
civ_type = gc.getPlayer(iPlayer).getCivilizationType()
for iUnit in range(gc.getNumUnitClassInfos()):
iUniqueUnit = gc.getCivilizationInfo(civ_type).getCivilizationUnits(iUnit);
iDefaultUnit = gc.getUnitClassInfo(iUnit).getDefaultUnitIndex();
if (iDefaultUnit > -1 and iUniqueUnit > -1 and iDefaultUnit != iUniqueUnit):
if ( iUnitType == iDefaultUnit ):
l_vassalUB.append(iUniqueUnit)
if ( len(l_vassalUB) >= 1 ):
self.iVassalUUChance = self.getRandomNumber( 4 )
if self.iVassalUUChance == 0:
chance = CyGame().getSorenRandNum(len(l_vassalUB), "Random for UB")
iX = pUnit.getX()
iY = pUnit.getY()
pNewUnit = pPlayer.initUnit( l_vassalUB[chance], iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION )
pNewUnit.convert(pUnit)
## Topkapi Palace End ##
If anyone could tell me how memory-demanding this code is, that would be helpful. I am deciding if this wonder is worth having. Basically what it does is give you a chance to build a rival's UU rather than the unit in replaces. So if you were the Maya and were playing a game against the Byzantines, when you build a Knight there is an X% chance it will be a Cataphract.
The wonder is cool, but not game-breaking or that necessary, so I was just wondering if I should do away with it.