Resource icon

Dynamic City Naming 1.0

Xyth

History Rewritten
Joined
Jul 14, 2004
Messages
4,106
Location
Aotearoa
Overview

Dynamic City Naming is a Python component for modders that adds much more flexibility when defining the list of cities for a civilization.

In BTS citylists are sequential and unchanging, the same no matter what leader you're playing or the era you are in. Dynamic City Naming (DCN) uses a priority system instead. Each player will have an internal list of cities it is eligible to found, and each city in this list has an assigned 'priority' value which is determined by leader or civilization choice. When the player builds a city, priorities are adjusted for the current era, and the highest priority city is selected from the list. If there are several cities at the same priority one of them is chosen randomly.

Cities can be flagged as capitals and have several different names assigned to them so the one that best matches the player's civilization, leader, and the current era is chosen. Finally, once the city is built and named it is removed from the list of all other players (should it be on any), so it cannot be built again.

Note that this is not a standalone mod. It does not include adapted citylists for all BTS civilizations. But it does include instructions and examples for modders to create the dynamic citylists they may need.


Features

  • Capitals, cities, or even entire citylists can be assigned to individual leaders. Agamemnon could start with Mykenai, Perikles with Athens, Leonidas with Sparta, Alexander with Pella. Brennus could found the Celtic settlements from the continent while Boudica could found those from from the British Isles.

  • Capitals, cities, or even entire citylists can be assigned to different eras. The Indians could found Vedic cities in the Ancient Era, Mauryan cities in the Classical era, Gupta cities in the Medieval Era, Mughal cities in the Renaissance Era, and so on.

  • Cities can have different names under different civilizations, leaders, or eras. Stalin will found Stalingrad but the other Russian leaders will found Tsaritsyn - unless it's the Modern Era in which case it can be founded as Volgograd instead.

  • Cities can be assigned to multiple civilizations or leaders and they won't be founded more than once, even if they have different names. The Greeks won't found Byzantium and the Turks won't found Istanbul if the Byzantines have already founded Constantinople. The Romans won't found Londinium if the English have founded London.

  • You can define as few or as many cities as you need - the system falls back on the list defined in CIV4CivilizationInfos.xml once it runs out of cities for a player.

  • Renaming of cities is supported; DCN will try and match the new name with cities you've defined.

  • Common non-ASCII characters in city names are supported.

Download

http://forums.civfanatics.com/downloads.php?do=file&id=19686


Installation

Note that DCN won't work if your mod is installed in the 'My Documents' (Windows) or 'Documents' (OSX) folder. It needs to be placed in the Mods folder found in the same location as the Beyond the Sword application. The same place as Afterworld, Road to War and the other mods that shipped with BTS are found. I hope to fix this eventually. There are 4 files to install:


<your mod>/Assets/XML/Civilizations/CIV4CityInfos.xml
This file is used to define settings for individual cities. Instructions and examples are in the file itself.

<your mod>/Assets/XML/Civilizations/CIV4CityListInfos.xml
This file is used to define settings for groups of cities. Instructions and examples are in the file itself.

<your mod>/Assets/Python/DynamicCityNaming.py
You do not need to change anything in this file.

<your mod>/Assets/Python/CvEventManager.py
You need to merge the DCN changes in this file into your mod's existing CvEventManager.py. Each section is labelled, search for "Dynamic City Naming". In the first section there are 2 path variables that show DCN where to find its XML files. You need to change these to match the name of your mod.​


Debugging

Although CIV4CityInfos.xml and CIV4CityListInfos.xml use XML formatting for familiarity, they are not true XML; there are no schema and they are not read by Civ4's XML parser. No errors will be generated at launch if tags are missing or broken, or if invalid data is entered. Useful debugging information is output to PythonDbg.log though; check there first if you encounter any issues (search for 'DCN').

There is also a global variable 'bDCNDebugging' in CvEventManager.py - set this to 'True' for more detailed output to PythonDbg.log.


Credits

Thanks to The_J and God-Emperor for some borrowed code and advice.
 
Cool idea, and one that has been missing for a bit

Another thing you could add is once a civ runs out of cities (usually a custom civ since usually they have a smaller city list) it automatically goes to a certain list. Or maybe have it so cities are named based on what plot they are placed on (or if on coast)
 
Nice! I assume you can use, for example, <CivilizationCityName>TXT_KEY_CITY_NAME_ATHENS</CivilizationCityName> instead of <CivilizationCityName>Athenai</CivilizationCityName>?

No, it does not in the example but it could. Yes I have looked at pillaging this for C2C. What it really needs is a utility to build the XML.:mischief:
 
Thanks all, I hope people find this useful.

Another thing you could add is once a civ runs out of cities (usually a custom civ since usually they have a smaller city list) it automatically goes to a certain list.

Good idea.

Or maybe have it so cities are named based on what plot they are placed on (or if on coast)

Some geographical checks wouldn't be too hard to implement, so long as they were considered after priority and completely optional in the XML. I'll have a think about it for a future version; I want to be sure there's no bugs with the current implementation first.

Nice, nice :goodjob:.

Now we just have to come up with lists for all BtS civs and leaders :mischief:.

If anyone puts any together I'd be happy to add them to a future version. I need to still need to convert all the citylists from HR; several of those would be useful more generally so I'll add them when they're done.

Nice! I assume you can use, for example, <CivilizationCityName>TXT_KEY_CITY_NAME_ATHENS</CivilizationCityName> instead of <CivilizationCityName>Athenai</CivilizationCityName>?

Unfortunately, no. It did originally, but I had to remove it in order to get UTF-8 and renaming support working properly. I'll try work out a way to reenable it.
 
Nice! I plan to use it in my mod.

What it really needs is a utility to build the XML.:mischief:

Since I'm programming a XML Scripting utility and I need some testing, I could make a script that extracts at least the information from the Civ4CivilizationInfos.xml city lists. Anyone interested?

EDIT:

I got an error on game start regarding line 361 "cannot convert to unicode" or something like that.
Code:
return unicode(cityname, 'utf-8')
I changed it to
Code:
return cityname
and now it works. Maybe that bug is system dependent? I'm using Win7x64

Did you consider that the edited city dictionary is lost after reloading the game (If I didn't miss someting)?
 
Is there anyway that you could change a civs description with a specific leader. Like Stalin has the USSR although the other leaders have standard Russia
 
I got an error on game start regarding line 361 "cannot convert to unicode" or something like that.
Code:
return unicode(cityname, 'utf-8')
I changed it to
Code:
return cityname
and now it works. Maybe that bug is system dependent? I'm using Win7x64

Sorry, I didn't see your edit till just now or I would have responded sooner. That will remove such an error yes, but it will likely throw a different error if you try to found a city with a non-standard ASCII character in its name. I'll try to replicate and solve the original issue.

Did you consider that the edited city dictionary is lost after reloading the game (If I didn't miss someting)?

When a game is loaded the city database is completely rebuilt, but when it's rebuilding each player's list it will check for and exclude cities that are already founded. The relevent code is in buildPlayerDict().

Is there anyway that you could change a civs description with a specific leader. Like Stalin has the USSR although the other leaders have standard Russia

That's outside the scope of this mod component, at least for now, but I think there is a component already available somewhere that can do that.
 
Back
Top Bottom