Tsentom1 Python Wonders

Hmm...:hmm:
I can see in the FAssert that it BUGs :)lol:) about CvGlobals.cpp, can you get your hands in your mod's source code? Just wondering why it's about PROMOTION_LEADER and GraphicOptionInfos.

Well, if by that you mean SDK there is none! I am just using BUG and there isn't a CvGlobals.cpp file involved at all. I asked EmperorFool about it (actually a couple people have) but he hasn't fixed it yet. So I suppose for the time being I'll have to deal with this until he fixes it, huh?
 
Well, if by that you mean SDK there is none! I am just using BUG and there isn't a CvGlobals.cpp file involved at all. I asked EmperorFool about it (actually a couple people have) but he hasn't fixed it yet. So I suppose for the time being I'll have to deal with this until he fixes it, huh?

Ok, I can't get any ideas what on earth could do that. Seems like we'll have to wait for EmperorFool. :sad:
 
ignore that promotion. I guess it comes from mongoose sdk. I had it in too.

Your python should work fine as long as you don't have any other python which changes "def getUpgradePriceOverride".
 
Does anybody know if it is possible to edit the Topkapi palace so, instead of only giving you a chance of building your vassal's UUs, it allows you to build either any UU from one of the civs in the game you are playing OR just any civ in BtS at all?
 
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.
 
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.

I understand that, but I'm saying could you remove the requirement that the civ of the civ of the UU has to be a vassal? Is there a way to change it to be any civ in the game you are playing or any civ in BtS?

EDIT: Basically I want this - I build the wonder. I am Greece. The Vikings are either in the game and not my vassal (hell I could even be at war with them), or are not even in the game. I start building a Maceman. When it is finished I get a Beserker.
 
yes this is easy. remove this line "if ( gc.getTeam(ppPlayer.getTeam()).isVassal(iTeam) == true ):"

take care of the tabs.
 
Okay, hopefully someone can help me out with this. Basically I want to use the Topkapi palace wonder, but I don't want the requirement that a civ be your vassal. So I want any random UU to potentially show up when I build a unit. So if I build an Axeman, I could either get a Dogsoldier, Vulture, or Phalanx for example. I do want to retain the 20% chance though. So anyway, Cybah told me what to do but when I looked at the code I found a few references to vassals. Here is the code with the Tsentom parts hilighted:

Code:
	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]

Okay, now in blue I have marked what Cybah told me to remove:

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_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 ##

But the rest of the code has a bunch of references to iVassal in it, so does anyone know what I can remove to get the desired effect? :confused:
 
I don't see any references to iVassal on there at all, not even one.

That part he actually told you to remove, is because that line contains a call to a function; IsVassal. Other than that it doesn't look for vassals at all.

that variable 1_vassalUB start out as blank, and then after it determines what UU to pick, it appends it to that variable. If you remove that blue line, it will basically pick from any UU in your XML files. At least in theory.

And that other reference to vassals, iVassalUUChance is also just another variable, this time random. It picks a random number from 0 to 4 (hence the 20% chance), and if it lands on option 0 then it assigns the UU.

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...
 
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.

:p

you can also change the line to

PHP:
if ( (gc.getTeam(ppPlayer.getTeam()).isHasMet(iTeam)) and (ppPlayer.isAlive()==true) and (ppPlayer.isBarbarian()==false) ):

for example.
 
Additionally, for speed improvement, you can delete these lines here:
PHP:
			topkapi = false
			for iCity in range(pPlayer.getNumCities()):
				if topkapi == false:
					ppCity = pPlayer.getCity(iCity)
					if ppCity.getNumActiveBuilding(b_BUILDING_TOPKAPI) == true:
						topkapi = true

and replace this line:

PHP:
			if ( topkapi == true ):

with

PHP:
			if ( pPlayer.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_TOPKAPI_PALACE"))>0 ):

Will do the same, but faster.
 
Alright, I'm putting everything for the Flavian Amphitheatre in right now. I just wanted to post what I came up with, based on your suggestions, and make sure I did it correctly:

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_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 ##
 
Hmm, that code didn't work, I got a pop up:


Anyone know what I did wrong there?
 

Attachments

  • FlavianPopUp.jpg
    FlavianPopUp.jpg
    20.8 KB · Views: 264
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?
 
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?

I got no errors like this prior to adding it, and as far as I know did not do that. Should I type "civ_type" into a search and see if it is in there though?

EDIT: I searched for it, it is ONLY in this code. I have marked it in red:

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_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 ##
 
Okay, so I took into consideration what you said (about civ_type not being defined) and altered the code to look like this now (blue is the code I use, red is the civ_type stuff):

Code:
	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]

Unfortunately I still got these pop-ups at around turn two or three:


So I'm not sure what the problem coudl really be at this point. But judging by the pop up it appears that line 239 seems to be at issue. Line 239, however, has nothing to do with this code (but didn't cause any issues until this code was used). So I might need some help on this. Here is the surrounding code with line 239 hilighted:

Code:
	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 #
 

Attachments

  • FlavianPopUp2.jpg
    FlavianPopUp2.jpg
    42.5 KB · Views: 746
Top Bottom