Mod in Works: Trade Route/Tech Leak (SevoMod 3.0 compatible)

AltarisGreyhawk

Chieftain
Joined
Jul 6, 2006
Messages
21
I have been working on a mod for SevoMod 3.0 that makes some interesting changes to the trade routes in Civ 4.

I have been playing Civ 4 for several months now, and I find Prince to be the most enjoyable difficulty setting. However, I noticed that I have a bit of a problem. On Prince, by 1300 or so, I vastly out-tech the other Civs, and on Monarch, I get vastly out-teched by the other Civs. Both of these situations are not very enjoyable, so I started looking at some alternative solutions.

Basically, this mod causes a tech leak to occur over trade routes. When a city trades with a foreign city belonging to another civ, it passes along 0.2% of points (rounded up, minimum 1 point) needed for ALL techs the foreign civ does not yet have but can research. This tech leak occurs for each trade route, so the more foreign trade routes that are open, the more a tech leak occurs.

For example, if I am playing England, and London has three trade routes with France, it is passing 0.6% points for all techs France does not yet have, but can research, each turn. The reverse is also true, where any trade routes France has open to me, passes along the same tech leak.

I am currently testing this mod (on Prince/Marathon), and it has made for a more enjoyable experience all around. I am currently around 800 AD, and no civ is more than 150 points apart in score. When one civ falls behind in tech progress, its trade routes help to boost it back up over 50-60 turns.

What's really neat about this mod is that it increases/decreases the handicap boost exponentially depending on the tech gap. If there is a large tech gap, the civ that is trailing gets a major boost from trade routes connected to its cities. As it catches up, this boost gradually dwindles away. The rules apply to both the AI and the human player, so the system is fair all around.

This also makes Closed Borders and the Mercantilsm civic more viable, as either of these will close off foreign trade routes. Basically, it forces the player to give up something for those often extremely profitable foreign trade routes.

I am interested to see what occurs in the later stages of the game. Theoretically, as tech advances increase, the tech leak will cause lagging civs to catch up even quicker, as more tech leak will occur from advancing civs. This seems realistic to me, as it never made any sense to me how a highly advanced civ could trade for 200+ years with a primitive civ, and the primitive civ not pick up on some of the advancements.

So far, I am very pleased with the results. The change is a subtle one, and with such a small percentage of points leaked each turn, the player has time to still react to the changes in foreign civ advancement. Also, it can give the player a reason to cancel open borders with a civ, something I rarely had reason to do before.

I am going to finish through my test game to see how it pans out over the scope of the game. If all looks well, I plan on posting the mod here for anyone who would be interested in giving it a try. If anyone has any thoughts/suggestions on this mod, please feel free to share them. Over all, I think it makes a nice addition to the game without causing imbalances in gameplay.
 
Excellent idea and I heartily congratulate you on being able to successfully implement it! I'd be interested in seeing your code for it once you release it; I may integrate it (along with Mylon's culture-over-trade-routes model) into my own in-progress mod.
 
I concur with the others, excellent mod idea...

There's only two things I can think of to make this better:
1.) Make the percentage of transfer dependent on relations, with the positive or negative bonus from diplomacy being the prime factor, not just the description (gracious, friendly, etc.). It makes sense that nations with closer relations would get a greater bonus from this sort of thing. This shouldn't be a huge effect, if the default rate is .2% add +.01% for each +1 bonus and negative values for negative relations (I don't think relations go over +/-20). Obviously this won't have much effect on small numbers, but as they grow larger it will have a more pronounced effect.

2.) Make the time of contact slightly increase the transfer rate. So if you are at +10 relations with someone, as long as that doesn't change you get an additional +.01 per turn (actually that's probably too much, but you get the idea) - but the moment it changes (up or down), reset this bonus to 0% and start over at the new relations value. It also makes sense that prolonged contact would increase the bonus, IMO.
 
I've attached the python (.py) file I'm using to run the tech spread code. If you want to take a look at it, detach the attachment, change the file name to BTMAddon.py (just remove the .txt file extension at the end), and open in a text editor (I prefer WordPad). It's a fairly short script, and I've commented each line to indicate what it is doing.

View attachment BTMAddon.py.txt

I plan to release a formal addon in the next few days, but this will give an idea of how the code works for any who may be interested in the meantime.

The script is designed to run at the beginning of each player's turns. It finds the players trade routes by cycling through each of the player's cities, then cycling through each city's trade routes. When matches are found, it cycles through all techs, seeing if the player has one that the target does not, and that the target can currently research. When matches are found, the tech leak occurs.

Note that the tech leak never auto-grants a tech. It will always stop 1 point short of granting a tech to another civ. I did this to avoid any potential synch problems with scripts that run on acquiring techs, and to avoid any potential spillover of points after a tech has been achieved. Basically, it all but grants the tech, but the receiving civ does have to spend the final point to actually get the tech.

You can modify the percent of tech leak per trade route through the variable "iTechPercentModifier". Right now it is set to 0.002 (or 0.2%). Keep in mind that this number is the percent leaked of ALL techs for ALL trade routes, so I'd recommend keeping it fairly low. I've found as I've tested that 0.2% may be a bit low, but I doubt I'd ever raise it higher than 0.5% just for game balance.

If you want to use this code, it does have to be called from somewhere in an event manager file. I have not included any event files in this message, but if you're familiar with modding Civ4 Python, that shouldn't be difficult to do.

You could also modify this code to perform other actions over trade routes. I've played around with religion spread using this template as well, though that gets a little more complex to calculate. I think religion spread will be my next project though. I toyed around some with decreasing the spread of early religions Buddism and Hinduism, and increasing the spread of later religions Christianity and Islam. I've also been working on improving the natural spread of multiple religions to cities. Functionally, it works well, but I'm still fine tuning the numbers to get it right. I like the way it operates, though, as it causes a wider variety of religions to appear among civs, causing for more inter-civ conflict (something that is way too lacking when 2-3 religions dominate the game from 600 BC onward).

Anyway, feel free to take a look through the code and see if there is anything helpful. Look for a release by the end of the weekend!
 
Thank you very much for the code, Altaris. Looking forward to the release versions of the mod :)
 
Bright day
Ah, I hold out my breath for this for a long long time:).
 
I have uploaded the Trade Route/Tech Leak mod at the link below:

http://forums.civfanatics.com/showthread.php?p=4262410#post4262410

Please note that it does require SevoMod 3.0 to work. I may release a non-SevoMod version at some point, but for now, this is what I am going with.

I had a blast with testing this. Definitely makes the game more balanced in the late game (though I still outsmarted the AI... not too hard to do).

Please feel free to leave any feedback as to what you think of it!
 
Very nice addition to the game. What makes SevoMod required for it? I didn't see anything in the BTMAddon.py that looked like SevoMod was required. Also, DataStorage is imported but not used anywhere so I think you can remove that.

Roger Bacon
 
Actually, the only reason SevoMod is necessary is the EventManager file. The BTM_Addon.py file could easily be imported into another mod's EventManager file, though, and incorporated with the exact same functionality. It just has to be called somewhere on the OnBeginPlayerTurn event.

If you're comfortable modding python events, it would be a very simple change to add the tech leak script into another mod.

I'm planning on using this as part of a larger compliation for SevoMod in the future, and I don't want to have multiple versions floating around at the moment. I might update in the future to be non-SevoMod compatible, though.
 
Great idea :thumbsup: and it's good that you made it so this effect doesn't ever actually grant a tech - it makes sense from thematic point of view as well.
 
Back
Top Bottom