Tsentom1 Python Wonders

Added a line of code to the Sphinx so that the wonder bonus doesn't apply to the Sphinx itself which was causing large amounts of free production overflow upon construction of the Sphinx.
 
Added a line of code to the Sphinx so that the wonder bonus doesn't apply to the Sphinx itself which was causing large amounts of free production overflow upon construction of the Sphinx.

So THAT's what's hiding in the secret chamber!
 
I get some seemingly non-fatal python errors in CvEventManager.py that seems to relate to Copernicus. I've attached the screenshot from civ.

Never mid the line numbers as I've (carefully) merged the file from an original file, Copernicus, Golden Gate Bridge etc. To make it easier I've also attached my modded .py-file

The line numbers are (Italic correspons to the line with the problem - removed some tabs to make text fit):

Line no 398:

## Copernicus Start ##

## Determines How Often the Stars Change
if ( iGameTurn % 10 ) == 0:
self.doChooseNewStarAlignment( )

## Copernicus End ##

Line no 1468:

if self.iStarAlignment == 4:
szTitle = localText.getText( "TXT_KEY_GODS_STARS_LION", ( ) )
CyInterface().addImmediateMessage( szTitle , None)
self.doStarGoldBonus( "NONE" )if self.iStarAlignment == 5:

Line no 1522

def doStarGoldBonus( self, szReligion ):
lPlayers = PyGame().getCivPlayerList( )

for iPlayer in range( len( lPlayers ) ):
if ( lPlayers[ iPlayer ].getStateReligion( ) == CvUtil.findInfoTypeNum(gc.getReligionInfo,gc.getNumReligionInfos(), szReligion ) ) or ( lPlayers[ iPlayer ].getStateReligion( ) != CvUtil.findInfoTypeNum(gc.getReligionInfo,gc.getNumReligionInfos(), szReligion ) ):

Hope it helps and that I haven't screewed up :lol:

\Skodkim
 
I get some seemingly non-fatal python errors in CvEventManager.py that seems to relate to Copernicus. I've attached the screenshot from civ.

Never mid the line numbers as I've (carefully) merged the file from an original file, Copernicus, Golden Gate Bridge etc. To make it easier I've also attached my modded .py-file

The line numbers are (Italic correspons to the line with the problem - removed some tabs to make text fit):

Line no 398:

## Copernicus Start ##

## Determines How Often the Stars Change
if ( iGameTurn % 10 ) == 0:
self.doChooseNewStarAlignment( )

## Copernicus End ##

Line no 1468:

if self.iStarAlignment == 4:
szTitle = localText.getText( "TXT_KEY_GODS_STARS_LION", ( ) )
CyInterface().addImmediateMessage( szTitle , None)
self.doStarGoldBonus( "NONE" )if self.iStarAlignment == 5:

Line no 1522

def doStarGoldBonus( self, szReligion ):
lPlayers = PyGame().getCivPlayerList( )

for iPlayer in range( len( lPlayers ) ):
if ( lPlayers[ iPlayer ].getStateReligion( ) == CvUtil.findInfoTypeNum(gc.getReligionInfo,gc.getNumReligionInfos(), szReligion ) ) or ( lPlayers[ iPlayer ].getStateReligion( ) != CvUtil.findInfoTypeNum(gc.getReligionInfo,gc.getNumReligionInfos(), szReligion ) ):

Hope it helps and that I haven't screewed up :lol:

\Skodkim

Hmm it looks like you either forgot to merge or merged incorrectly the PyHelpers python file included with the modcomp. Searching for "Copernicus' Observatory" finds the changes in there as well. If you're using a mod that doesn't edit that file you don't need to merge persay just move the whole file into the python directory.

(Basically the Eventmanager is calling back to PyHelpers and not finding the function there).
 
HERC Factory: (Next War Wonder)

I'm sure this one won't be as popular as a few of my other wonders, mainly because it's designed for the Next War mod, but I know quite a few people and mod makers that use Next War as a sort of official future era for BTS. Plus, I try to spread around the wonders I make in terms of culture and time frame and the future era is usually lacking in mods.

This was made for me next version of Thomas' War.

Herc.jpg


Why is it called the HERC Factory, well that's what it is called in Empire Earth 2. It wasn't a wonder in EE2 but it was used to make giant robots. Plus, Walter Hawkwood uploaded those fantastic EE2 rips.

At first glance, the bonuses might seem a little weird. Yes, it causes massive unhealthiness but keep in mind that the -4 in all cities can be countered with Recycling Centers, as the wonder only removes the Recycling Center in the owner city. Plus, the main draw, removing the Assault Mech National Unit Cap applies to all cities.

This modcomp is also somewhat odd as it's the only one of my wonders that won't work independently. The reason being is that I used the Next War XML and Python files (from the BTS 3.17 patch) in the folders as it requires techs and buildings from that mod. It's aimed, I guess, more for mod makers that make use of Next War than the casual modder. Anyway, I know several people like my wonders mainly for the code which they apply to their own ideas and buildings, so people can copy this as a way to remove National Unit Caps for other units.

All the python is labeled and searching for "HERC Factory" should find all the changes.

It activates the USE_CAN_TRAIN_CALLBACK in the PythonCallbackDefines XML file.

I recommend downloading Winmerge to help combine the files.

XML, python, button, static wonder movie: me (tsentom1)
Building:Taken from EE2 uploaded by Walter Hawkwood
 
Good idea, like everytime :goodjob:.

Anyway, I know several people like my wonders mainly for the code which they apply to their own ideas and buildings, so people can copy this as a way to remove National Unit Caps for other units.

:D
But damn, i've said in my mod-developement-thread, that this can't be done.
mmmh, having a new feature, but confessing being stupid, or not a new feature to appear more intelligent :hmm:?
-> New feature :D.
 
Good idea, like everytime :goodjob:.



:D
But damn, i've said in my mod-developement-thread, that this can't be done.
mmmh, having a new feature, but confessing being stupid, or not a new feature to appear more intelligent :hmm:?
-> New feature :D.

It's just setting the CanTrain python function in the GameUtils file. It still says National Unit four left when you hover over the unit (mainly because to remove this you'd have to edit the SDK) but if you have the wonder it will let you train past that (actually it'll start saying National Unit -5 left, etc, when you get past the old national limit, so just a small aesthetic nuisance).
 
Hmm it looks like you either forgot to merge or merged incorrectly the PyHelpers python file included with the modcomp. Searching for "Copernicus' Observatory" finds the changes in there as well. If you're using a mod that doesn't edit that file you don't need to merge persay just move the whole file into the python directory.

(Basically the Eventmanager is calling back to PyHelpers and not finding the function there).

My fault :(

Everything works like a charm now..

Let me just say that your additions to the community is by far the most interesting ones that are seen right now. Good work :goodjob:

\Skodkim
 
Thanks tsentom1,
The Public Works building should work nicely in my mod.
 
Fixed a slight bug with Trafalgar Square that occasionally was causing the steal gold python to fire twice.
 
I noticed a small bug with the Leonardo's Workshop code. My great general unit, after building the wonder, now requires cash to be upgraded. This might be because the check for Leonardo's Workshop comes after the check for the great general.

I'm still getting a massive discount on my army, so it's not a huge problem. Just a feature others might pick up on.
 
I noticed a small bug with the Leonardo's Workshop code. My great general unit, after building the wonder, now requires cash to be upgraded. This might be because the check for Leonardo's Workshop comes after the check for the great general.

I'm still getting a massive discount on my army, so it's not a huge problem. Just a feature others might pick up on.

You're right, it's just an unintended side effect because I changed how the game looks for the upgrade price. Plus, a situation I wouldn't readily think of when writing the code to begin with.

Anyway, an easy fix. Just add:

Code:
		if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_LEADER')):

			iPrice = 0

To the end of the code.

Like so:

Spoiler :
Code:
## Leonardo's Workshop Start ##

		pPlayer = gc.getPlayer(iPlayer)
		pUnit = pPlayer.getUnit(iUnitID)

		iPrice = gc.getDefineINT("BASE_UNIT_UPGRADE_COST")
		iPrice += (max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"))

		if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
			pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
			iPrice = iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100
			iPrice = iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100

		iPrice = iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100)

		b_Leonardo = gc.getInfoTypeForString("BUILDING_LEONARDO")
		obsoleteTech = gc.getBuildingInfo(b_Leonardo).getObsoleteTech()
		if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ppCity.getNumActiveBuilding(b_Leonardo) == true:
					iPrice = ((gc.getDefineINT("BASE_UNIT_UPGRADE_COST"))/2)
					iPrice += (((max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION")))/2)

					if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
						pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
						iPrice = ((iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100)/2)
						iPrice = ((iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100)/2)

						iPrice = ((iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100))/2)

[B]		if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_LEADER')):

			iPrice = 0[/B]
		
		return iPrice

## Leonardo's Workshop End ##
Thanks for noticing this, otherwise I would have probably never caught it.

For everyone else, I updated the main download to correct this oversight.
 
Hi tsentom1,

I am having trouble getting the King Richard's Crusade wonder to work. I have added the Crusade Unit and the Python code to CvEventManager.py. However, the event just never seems to fire. I don't see anything in the logs and the Crusader unit never gets created. Any hints on how I might be mucking this up?

Cheers,
ripple01
 
Hi tsentom1,

I am having trouble getting the King Richard's Crusade wonder to work. I have added the Crusade Unit and the Python code to CvEventManager.py. However, the event just never seems to fire. I don't see anything in the logs and the Crusader unit never gets created. Any hints on how I might be mucking this up?

Cheers,
ripple01

Hmm, well the python is less complicated than some of my other wonders as it really only has two sections (technically it only needs 1, but the two function sort of differently)

The first one is on def onBeginPlayerTurn(self, argsList):

Spoiler :
Code:
	def onBeginPlayerTurn(self, argsList):
		'Called at the beginning of a players turn'
		iGameTurn, iPlayer = argsList

## Crusade Start ##

		pPlayer = gc.getPlayer(iPlayer)
		b_Crusade = gc.getInfoTypeForString("BUILDING_CRUSADE")
		obsoleteTech = gc.getBuildingInfo(b_Crusade).getObsoleteTech()

		if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ppCity.getNumActiveBuilding(b_Crusade) == true:

					iX = ppCity.getX()
					iY = ppCity.getY()
					u_crusader = gc.getInfoTypeForString( 'UNIT_CRUSADER' )

					estiEnd = CyGame().getEstimateEndTurn()
					if ( estiEnd >= 1000 ):
						if ( iGameTurn % 12 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 700 ):
						if ( iGameTurn % 8 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					elif ( estiEnd >= 500 ):
						if ( iGameTurn % 6 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )

					elif ( estiEnd >= 300 ):
						if ( iGameTurn % 4 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
					else:
						if ( iGameTurn % 4 ) == 0:
							for i in range(1):
								pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )

					basechance = 12
					estiEnd = CyGame().getEstimateEndTurn()
					if ( estiEnd >= 1000 ):
						basechance = basechance
					elif ( estiEnd >= 700 ):
						basechance = 6
					elif ( estiEnd >= 500 ):
						basechance = 4
					elif ( estiEnd >= 300 ):
						basechance = 2
					else:
						basechance = 1

					chance = CyGame().getSorenRandNum(basechance, "free state religion spread chance")
					if ( chance == 0 ):
						lppCityUber5 = []
						for iiCity in range(pPlayer.getNumCities()):
							ppCity = pPlayer.getCity(iiCity)
							if ( not ppCity.isHasReligion(pPlayer.getStateReligion()) ):
								lppCityUber5.append(ppCity)
						if ( len(lppCityUber5) != 0 ):
							chance = CyGame().getSorenRandNum(len(lppCityUber5), "which city")
							ppCity = lppCityUber5[chance]
							ppCity.setHasReligion(pPlayer.getStateReligion(), true, true, true)

## Crusade End ##

This once controls the unit spawn every X amount of turns depending on game speed (and also the extra state religion spread chance to your cities).

The other one is on def onBuildingBuilt(self, argsList):

Spoiler :
Code:
	def onBuildingBuilt(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		game = gc.getGame()

### Crusade Start ###

		if ( iBuildingType == gc.getInfoTypeForString("BUILDING_CRUSADE") ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			iPID = pPlayer.getID()
			iTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			u_crusader = gc.getInfoTypeForString( 'UNIT_CRUSADER' )

			for i in range(1):
				pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )

### Crusade End ###

		if ((not gc.getGame().isNetworkMultiPlayer()) and (pCity.getOwner() == gc.getGame().getActivePlayer()) and isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType())):
			# If this is a wonder...
			popupInfo = CyPopupInfo()
			popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
			popupInfo.setData1(iBuildingType)
			popupInfo.setData2(pCity.getID())
			popupInfo.setData3(0)
			popupInfo.setText(u"showWonderMovie")
			popupInfo.addPopup(pCity.getOwner())

		CvAdvisorUtils.buildingBuiltFeats(pCity, iBuildingType)

		if (not self.__LOG_BUILDING):
			return
		CvUtil.pyPrint('%s was finished by Player %d Civilization %s' 
			%(PyInfo.BuildingInfo(iBuildingType).getDescription(), pCity.getOwner(), gc.getPlayer(pCity.getOwner()).getCivilizationDescription(0)))
Which basically serves to give you a free crusader unit on the turn the building is built.

So first make sure you have both of those sections.

Now as for the XML. Assuming you've added the unit and building correctly in the unitinfos and unitclass and artdefines, etc. The python calls:

BUILDING_CRUSADE

UNIT_CRUSADER

As the names of the units, so make sure you have both labeled as such in the XML or the python won't find it.

The game won't actually create a log entry in the event logs tab, since then I'd have to connect the python to SDK which makes the mod-comp overly complicated. Instead the unit should just appear on the turns in the city that has the wonder.

If you still can't get it working, you can post your XML and python here and I can take a look at it to see if I can find the problem.

Also, you can try enabling python exceptions and see if an error message comes up on the turns that are supposed to spawn a crusader, which might help us get to the bottom of it.
 
I downloaded the:
-Sphinx
-GGB
-SOH
-HSC
-Colosseum

It recommends me open up with Firefox, but when I do, it just pops up again and leaving a blank tab. What should I do and once I do download it, where do I extract it to?
 
I downloaded the:
-Sphinx
-GGB
-SOH
-HSC
-Colosseum

It recommends me open up with Firefox, but when I do, it just pops up again and leaving a blank tab. What should I do and once I do download it, where do I extract it to?

You should save the downloads on to your computer instead of opening them directly from the download.

The files are compressed with 7zip, however the newest versions of winrar and winzip can extract them as well.

Once download and extracted you could theoretically play them as mods (they are in the format of a mod) but the only difference would be that one wonder is now in the game. Since they all use python they can't be done solely modular, so if you want to play with multiple wonders in your game you need to combine the xml and python files. The downloads are in the form of a mod to show you exactly which files and where the files are that need to be combined. All the python is labeled (usually the download page has the word to search - often just the wonders name - to find the changes), and the xml changes I tried, when possible, to keep at the bottom of the file.
 
You should save the downloads on to your computer instead of opening them directly from the download.

How exactly do I do that?:confused:
 
Back
Top Bottom