not without using a complete new python code.topkapi just replaces a trained unit after it has been built. it does not give you the chance to build the unit urself. there is an assimilation mod anywhere where you have to look for the code.
yes this is easy. remove this line "if ( gc.getTeam(ppPlayer.getTeam()).isVassal(iTeam) == true ):"
take care of the tabs.
def onUnitBuilt(self, argsList):
'Unit Completed'
city = argsList[0]
unit = argsList[1]
player = PyPlayer(city.getOwner())
[COLOR="Red"]## Topkapi Palace Start ##
pCity = argsList[0]
pUnit = argsList[1]
pPlayer = gc.getPlayer(pUnit.getOwner())
iUnitType = pUnit.getUnitType()
b_BUILDING_TOPKAPI = gc.getInfoTypeForString("BUILDING_TOPKAPI_PALACE")
obsoleteTech = gc.getBuildingInfo(b_BUILDING_TOPKAPI).getObsoleteTech()
if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
topkapi = false
for iCity in range(pPlayer.getNumCities()):
if topkapi == false:
ppCity = pPlayer.getCity(iCity)
if ppCity.getNumActiveBuilding(b_BUILDING_TOPKAPI) == true:
topkapi = true
if ( topkapi == true ):
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()).isVassal(iTeam) == true ):
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 ##[/COLOR]
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_TOPKAPI_PALACE")
obsoleteTech = gc.getBuildingInfo(b_BUILDING_TOPKAPI).getObsoleteTech()
if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
topkapi = false
for iCity in range(pPlayer.getNumCities()):
if topkapi == false:
ppCity = pPlayer.getCity(iCity)
if ppCity.getNumActiveBuilding(b_BUILDING_TOPKAPI) == true:
topkapi = true
if ( topkapi == true ):
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) ):
[COLOR="Blue"]if ( gc.getTeam(ppPlayer.getTeam()).isVassal(iTeam) == true ):[/COLOR] 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 ##
edit: just removing that line, it won't work. You'll have to move back the following lines to their indentation is correct too. So that for goes where if was and IUniqueUnit goes where for was...
Cybah said:take care of the tabs.
if ( (gc.getTeam(ppPlayer.getTeam()).isHasMet(iTeam)) and (ppPlayer.isAlive()==true) and (ppPlayer.isBarbarian()==false) ):
topkapi = false
for iCity in range(pPlayer.getNumCities()):
if topkapi == false:
ppCity = pPlayer.getCity(iCity)
if ppCity.getNumActiveBuilding(b_BUILDING_TOPKAPI) == true:
topkapi = true
if ( topkapi == true ):
if ( pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_TOPKAPI_PALACE"))>0 ):
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_FLAVIAN = gc.getInfoTypeForString("BUILDING_FLAVIAN")
obsoleteTech = gc.getBuildingInfo(b_BUILDING_FLAVIAN).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) ):
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 ##
Are you sure it's because of that code above? Did it appear after you added that part of code?
EDIT: Tested your code and got a python error: "civ_type" is not defined
Have you added it somewhere else?
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_FLAVIAN = gc.getInfoTypeForString("BUILDING_FLAVIAN")
obsoleteTech = gc.getBuildingInfo(b_BUILDING_FLAVIAN).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) ):
for iUnit in range(gc.getNumUnitClassInfos()):
iUniqueUnit = gc.getCivilizationInfo([COLOR="Red"]civ_type[/COLOR]).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 ##
def onUnitBuilt(self, argsList):
'Unit Completed'
city = argsList[0]
unit = argsList[1]
player = PyPlayer(city.getOwner())
[COLOR="Blue"]## Topkapi Palace Start ##
pCity = argsList[0]
pUnit = argsList[1]
pPlayer = gc.getPlayer(pUnit.getOwner())
iUnitType = pUnit.getUnitType()
b_BUILDING_FLAVIAN = gc.getInfoTypeForString("BUILDING_FLAVIAN")
obsoleteTech = gc.getBuildingInfo(b_BUILDING_FLAVIAN).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 ( gc.getTeam(ppPlayer.getTeam()).isVassal(iTeam) == true ):
[COLOR="Red"]civ_type = gc.getPlayer(iPlayer).getCivilizationType()[/COLOR] for iUnit in range(gc.getNumUnitClassInfos()):
iUniqueUnit = gc.getCivilizationInfo([COLOR="Red"]civ_type[/COLOR]).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 ##[/COLOR]
def onCityDoTurn(self, argsList):
'City Production'
pCity = argsList[0]
iPlayer = argsList[1]
###from here
[COLOR="Red"]pPlayer = gc.getPlayer(iPlayer)[/COLOR]
if not pPlayer.isCivic(gc.getInfoTypeForString("CIVIC_SLAVERY")):
iSlaveSpecialist = gc.getInfoTypeForString("SPECIALIST_SLAVE")
iSlaveSpecialistInCity = pCity.getSpecialistCount(iSlaveSpecialist)
pCity.alterSpecialistCount(iSlaveSpecialist,-iSlaveSpecialistInCity)
###to here
# no anger defying UN resolutions start #
iGovernmentCivicOption = CvUtil.findInfoTypeNum(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_GOVERNMENT')
iPoliceState = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_POLICE_STATE')
pPlayer = gc.getPlayer(iPlayer)
iGovernmentCivic = pPlayer.getCivics(iGovernmentCivicOption)
if (iGovernmentCivic == iPoliceState):
pCity.changeDefyResolutionAngerTimer(pCity.getDefyResolutionAngerTimer())
# no anger defying UN resolutions end #
def onUnitBuilt(self, argsList):
'Unit Completed'
pCity = argsList[0]
pUnit = argsList[1]
pPlayer = gc.getPlayer(pUnit.getOwner())
if ( pCity.getNumActiveBuilding(gc.getInfoTypeForString('BUILDING_FLAVIAN_AMPHITHEATRE'))==true ):
### FA_chance = Chance in % to get a Unique Unit (UU) of the same Unitclass instead of the Standart Unit (SU) ###
FA_chance = 50
chance = CyGame().getSorenRandNum(100, "Random for UU")
if (chance < FA_chance):
iUnitClassType = pUnit.getUnitClassType()
### Same UnitClass (UC) = UUs and/or EDUs ###
lgleicheUC = []
for i in range(gc.getNumUnitInfos()):
if ( gc.getUnitInfo(i).getUnitClassType() == iUnitClassType ):
lgleicheUC.append(i)
if ( len(lgleicheUC) >= 2 ):
### Choose the UnitClass UU (lgleicheUC[0] = Standard Unit) ###
chance = CyGame().getSorenRandNum(len(lgleicheUC) - 1, "Random for UU")
iNewUU = lgleicheUC[chance + 1]
### Check (not replace UU with same UU) ###
iUnitType = pUnit.getUnitType()
if ( iUnitType != iNewUU ):
### Create/Converte Unit ###
iX = pUnit.getX()
iY = pUnit.getY()
pNewUnit = pPlayer.initUnit( iNewUU, iX, iY, UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION )
pNewUnit.convert(pUnit)
### Ausgabe ###
UnitInfo = gc.getUnitInfo(iUnitType)
UnitInfo2 = gc.getUnitInfo(iNewUU)
CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_FLAVIAN_AMPHITHEATRE_GAMETXT1",( pCity.getName(), UnitInfo2.getDescription(), UnitInfo.getDescription() )),'',0,'art/Interface/Buttons/Buildings/Flavian.dds',ColorTypes(11),iX,iY,True,True)
### message: In %s1 the Flavian Amphitheatre provides a %s2 instead of a %s3 ###