Tsentom1 Python Traits

works a little bit like a granary. if a city grows, the city receives additional food defined by the python code.
 
I'm using the Nomadic trait but I would like to take away the part that Enemis Can't Capture Gold inside your Cultural Borders. Which part of the Python code should I change back to the original to do this?
 
change:

Code:
## Nom Trait Start ##

		pPlayer = gc.getPlayer( pUnit.getOwner( ) )
		iTrait = CvUtil.findInfoTypeNum(gc.getTraitInfo,gc.getNumTraitInfos(),'TRAIT_NOMADIC')

		if (pPlayer.hasTrait(iTrait)):
			iPillageGold = ( ( 0 ) * 2 ) 
			iPillageGold = ( ( CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 1") ) * 2 )
			iPillageGold += ( ( CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 2") ) * 2 )

			iPillageGold += ( ( (pUnit.getPillageChange() * iPillageGold) / 100 ) * 2 )
		else:
			iPillageGold = 0
			iPillageGold = CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 1")
			iPillageGold += CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 2")

			iPillageGold += (pUnit.getPillageChange() * iPillageGold) / 100

		pPlayer2 = gc.getPlayer( pPlot.getOwner( ) )

		if pPlot.getOwner( ) >= 0:
			if (pPlayer2.hasTrait(iTrait)):
				iPillageGold = 0

## Nom Trait End ##

to

Code:
## Nom Trait Start ##

		pPlayer = gc.getPlayer( pUnit.getOwner( ) )
		iTrait = CvUtil.findInfoTypeNum(gc.getTraitInfo,gc.getNumTraitInfos(),'TRAIT_NOMADIC')

		if (pPlayer.hasTrait(iTrait)):
			iPillageGold = ( ( 0 ) * 2 ) 
			iPillageGold = ( ( CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 1") ) * 2 )
			iPillageGold += ( ( CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 2") ) * 2 )

			iPillageGold += ( ( (pUnit.getPillageChange() * iPillageGold) / 100 ) * 2 )
		else:
			iPillageGold = 0
			iPillageGold = CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 1")
			iPillageGold += CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 2")

			iPillageGold += (pUnit.getPillageChange() * iPillageGold) / 100

## Nom Trait End ##
 
Is that code to make it so that enemies only can capture or that enemies are able to both capture and pillage gold inside my cultural border?

I would like delete everything that has this effect:

Enemies can't Capture or Pillage Gold inside Cultural Borders
 
My code was that enemies can pilllage - because tsentom1's pillaging code is bad for the AI (the AI will still pillage but without receiving gold) - but will not get gold when capturing cities.

If you also want to remove the capturing part, you have to change

Code:
	def doCityCaptureGold(self, argsList):
		"controls the gold result of capturing a city"
		
		pOldCity = argsList[0]
		
		iCaptureGold = 0
		
		iCaptureGold += gc.getDefineINT("BASE_CAPTURE_GOLD")
		iCaptureGold += (pOldCity.getPopulation() * gc.getDefineINT("CAPTURE_GOLD_PER_POPULATION"))
		iCaptureGold += CyGame().getSorenRandNum(gc.getDefineINT("CAPTURE_GOLD_RAND1"), "Capture Gold 1")
		iCaptureGold += CyGame().getSorenRandNum(gc.getDefineINT("CAPTURE_GOLD_RAND2"), "Capture Gold 2")

		if (gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS") > 0):
			iCaptureGold *= cyIntRange((CyGame().getGameTurn() - pOldCity.getGameTurnAcquired()), 0, gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS"))
			iCaptureGold /= gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS")


## Nom Trait Start ##

		pPlayer = gc.getPlayer( pOldCity.getOwner( ) )
		iTrait = CvUtil.findInfoTypeNum(gc.getTraitInfo,gc.getNumTraitInfos(),'TRAIT_PROTECTIVE')
		
		if (pPlayer.hasTrait(iTrait)):
			iCaptureGold = 0
		else:	
			iCaptureGold = 0
		
			iCaptureGold += gc.getDefineINT("BASE_CAPTURE_GOLD")
			iCaptureGold += (pOldCity.getPopulation() * gc.getDefineINT("CAPTURE_GOLD_PER_POPULATION"))
			iCaptureGold += CyGame().getSorenRandNum(gc.getDefineINT("CAPTURE_GOLD_RAND1"), "Capture Gold 1")
			iCaptureGold += CyGame().getSorenRandNum(gc.getDefineINT("CAPTURE_GOLD_RAND2"), "Capture Gold 2")

			if (gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS") > 0):
				iCaptureGold *= cyIntRange((CyGame().getGameTurn() - pOldCity.getGameTurnAcquired()), 0, gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS"))
				iCaptureGold /= gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS")

## Nom Trait End ##

		
		return iCaptureGold

to the original code:

Code:
	def doCityCaptureGold(self, argsList):
		"controls the gold result of capturing a city"
		
		pOldCity = argsList[0]
		
		iCaptureGold = 0
		
		iCaptureGold += gc.getDefineINT("BASE_CAPTURE_GOLD")
		iCaptureGold += (pOldCity.getPopulation() * gc.getDefineINT("CAPTURE_GOLD_PER_POPULATION"))
		iCaptureGold += CyGame().getSorenRandNum(gc.getDefineINT("CAPTURE_GOLD_RAND1"), "Capture Gold 1")
		iCaptureGold += CyGame().getSorenRandNum(gc.getDefineINT("CAPTURE_GOLD_RAND2"), "Capture Gold 2")

		if (gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS") > 0):
			iCaptureGold *= cyIntRange((CyGame().getGameTurn() - pOldCity.getGameTurnAcquired()), 0, gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS"))
			iCaptureGold /= gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS")
		
		return iCaptureGold
 
I would if I still had it. I've lost all of my older civ4 downloads. :(
 
the scientist trait was basically the posted python code below i think, it's what i've been using at least. Just add it to cveventmanager.py and it should work out just fine. It's quite easy to modify to fit other traits and other specialists. Just replace TRAIT_SCIENTIFIC with any other trait string and the same concept applies for the string SPECIALIST_SCIENTIST.

Code:
	def onCityBuilt(self, argsList):
		'City Built'
		city = argsList[0]

#FREE SPEC FROM TRAIT
		player = PyPlayer(city.getOwner())
		pPlayer = gc.getPlayer(city.getOwner())

		iTrait2 = CvUtil.findInfoTypeNum(gc.getTraitInfo,gc.getNumTraitInfos(),'TRAIT_SCIENTIFIC')
		iSpecialist = CvUtil.findInfoTypeNum(gc.getSpecialistInfo, gc.getNumSpecialistInfos(), 'SPECIALIST_SCIENTIST', )

		if (pPlayer.hasTrait(iTrait2)):
			city.changeFreeSpecialistCount(iSpecialist, 1)
#END SPEC FROM TRAIT #
 
Mercantile is actually all XML so the confusing wording of the trait (20% of Food is Trade) is all firaxis' fault.

The way it works currently every 5 commerce a trade route makes (as 20% of a 100 is 5) you will also get 1 hammer and 1 food. This applies to all trade routes. It's generally weak late game but gets strong once you have harbors and custom houses.
That's odd. I had the following in a trait I created:
Code:
[B]			<TradeYieldModifiers>
				<iYield>100</iYield>
				<iYield>0</iYield>
				<iYield>0</iYield>
			</TradeYieldModifiers>[/B]
Now, my understanding of what you said means I should be getting an extra +1 :food: for every trade route in the city, but I get nothing. What am I doing wrong here?

BTW, the download for the scientific trait is broken.
 
you should get +1 food for every COMMERCE per trade route in this case.

example:

3 trade routes:

1st: 8 commerce
2nd: 5 commerce
3rd: 2 commerce

-> you should get +15 food in that city.

Can't believe that you get nothing. Will try it out.
 
Also, it won't show up as a +25% when hovering over your hammers in the city screen. Rather if you compare the actual hammer cost of the building or unit when selecting production it'll be lower.

I like the Mercantile Trait very much, thank you!!

I noticed that when hovering over the trade routes in the city screen, only the default yield of gold is detailed. Is there any way to add the detailed explanation on the trade route city screen for the Mercantile Trait effects?
 
in the file:
\Sid Meier's Civilization 4\Beyond the Sword\Mods\Thomas' War\Assets\XML\PythonCallbackDefines.xml

I see:
<DefineName>USE_USE_CANNOT_SPREAD_RELIGION_CALLBACK</DefineName>


Looks like a typo... should it be
<DefineName>USE_CANNOT_SPREAD_RELIGION_CALLBACK</DefineName>
?

I haven't modified anything. This is how the file was after downloading the current version of the mod few weeks ago.
 
Hi guys, I know Tsentom isn't around, but would be glad if someone can solve this.

The influential trait "100% Golden Age Length" doesn't work as advertised.

Because the code is coded under def OnGoldenAge, it only works when Golden Age is started regardless of situation (event, great person, wonder). Then the Golden Age will really be longer.

However, if Golden Age is triggered during an existing Golden Age, (Eg using Great Person after building Taj Mahal), because Golden Age is already ongoing, def OnGoldenAge won't be called and the extra length caused by the 2nd Golden Age won't be affected.

Any idea how to fix this?
 
Well, I can give you the SDK code if you want. But I don't know any alternate way in python.
 
Top Bottom