Having a trait give food/production on trade routes

deanej

Deity
Joined
Apr 8, 2006
Messages
4,859
Location
New York State
I'm trying to make a trait that gives +1 food and +1 production per trade route that a civ has. I've used
Code:
			<TradeYieldModifiers>
				<iYield>1</iYield>
				<iYield>1</iYield>
				<iYield>0</iYield>
			</TradeYieldModifiers>
in Civ4TraitInfos.xml and everything looks OK in the civilopedia but when I test it out in-game nothing happens. How can I fix the game so that it does this?
 
With trade yield modifiers, they increase the percent yields per trade route, so the code above would only give +1% food and +1% production, which would probably round down to 0...
 
One would think, but the game text generated for the civilopedia clearly states: +1 food , +1 hammers from trade routes. No percent sign anywhere. I've just tested it with Financial (which I've modded the same way to give an additional commerce) and it looks like the civilopedia text is just plain wrong and that it is indeed a modifier. How would I go about doing what I intend? If I can't get this to work I have two leader traits I need to change, and I'm not creative enough to come up with alternates.
 
I have wondered about this too, since typically "modifier" always translates into a percent, and ingame the it simply says "+X"

I believe the text in the pedia is just a bug. No trait in standard civilization games uses that tag, so it might have "slipped through" untested to this point.

To be certain, one could always use a value like 100. if the trade route food/commerce is doubled, then you know its a percent.
 
Tests seem to indicate it's percent, assuming it's hooked in at all. There's a similar tag with the civics so I can't find how this is applied in the DLL so I can change it. Does anyone know how?

EDIT: I've just looked at Final Frontier again and it seems there is at least a python way of doing it, as the Red Syndicate has this bonus. I'll probably just fix the text and adjust my Financial accordingly. That's the last time I use XML tags not used by the base game or an official mod without testing them.

EDIT2: I've tested it, and it is indeed that way. I got the python change to work, though it naturally doesn't advertise itself on the city screen. I do seem to have some bug where cities will start trading even though they aren't connected (resources work fine though).
 
I actually have a similar request that I have been needing for a while: If anyone could come up with this, I would be indebted to them.

I am looking for a TradeRouteCommerceChange so that a trait/building/civic etc. could simply give 1 (or whatever #) gold, science, culture, or espionage per trade route that a city has. I can think of a number of uses for this. Any takers?

Cheers,
ripple01
 
Each turn you would probably loop through each city and if the condition is met loop though the trade routes and give whatever for each one. Here's some code from Star Trek:
Code:
				iTrait = CvUtil.findInfoTypeNum(gc.getTraitInfo,gc.getNumTraitInfos(),'TRAIT_KAZON')
				if (pPlayer.hasTrait(iTrait)):
					for iTradeCity in range (pCity.getTradeRoutes()):
						pTradeCity = pCity.getTradeCity(iTradeCity)
#						printd("Trade city object:")
#						printd(pTradeCity)
						if (pTradeCity):
							if (pTradeCity.getName() != ""):
#								printd("entering trade route additions")
								aiSystemYield[0] += 1
								aiSystemYield[1] += 1
 
@deanej - Unrelated comment: don't use CvUtil.findInfoTypeNum(). It is unnecessary slow and was replaced with gc.getInfoTypeForString():

Code:
iTrait = CvUtil.findInfoTypeNum(gc.getTraitInfo,gc.getNumTraitInfos(),'TRAIT_KAZON')

becomes this

Code:
iTrait = [B][COLOR="Orange"]gc.getInfoTypeForString[/COLOR][/B]('TRAIT_KAZON')

It doesn't matter what you're searching for--a trait, tech, leader, whatever--the call is the same. The difference is like searching for a word in the dictionary by comparing it to every word one-by-one instead of using the words at the top of the page to find the correct page first.
 
If it's in a tight loop, yes.
If you get a little chill down your spine whenever you see the old form, yes.
If you like kittens, yes.

Otherwise, it doesn't really matter. It only loops through the traits looking for that key, so it won't be that much of a difference.
 
Each turn you would probably loop through each city and if the condition is met loop though the trade routes and give whatever for each one. Here's some code from Star Trek:
Code:
				iTrait = CvUtil.findInfoTypeNum(gc.getTraitInfo,gc.getNumTraitInfos(),'TRAIT_KAZON')
				if (pPlayer.hasTrait(iTrait)):
					for iTradeCity in range (pCity.getTradeRoutes()):
						pTradeCity = pCity.getTradeCity(iTradeCity)
#						printd("Trade city object:")
#						printd(pTradeCity)
						if (pTradeCity):
							if (pTradeCity.getName() != ""):
#								printd("entering trade route additions")
								aiSystemYield[0] += 1
								aiSystemYield[1] += 1


and where? which eventhandler? my mod does not know aiSystemYield... do i need additional sdk changes?
 
Top Bottom