Event to change name of city

Jesus Civs

Civaholic
Joined
Jan 10, 2006
Messages
398
Location
Ireland
Hi

Would anyone know how to setup an event as follows:

- City X is owned by Civ A

- Civ B captures City X

- On capture, City X changes its name automatically to City Y

Thanks in advance.
 
Anyone any ideas please?
 
You can do this easily with Python. There's an event (an event in Python is not the same as a random event in the game ...) called cityAcquired.

The easiest way to make a mod that did this is to create a new folder in your Program Files/.../BTS/Mods directory called "CityRenameMod" or whatever. Inside this folder, create a folder called Assets and in the Assets folder, create a folder called Python. Then, copy CvEventManager.py from the main BTS/Assets/Python directory to this new Python directory.

You can edit CvEventManager.py with any text editor, though one that's aware of syntax and can show you what's a bunch of spaces and what's a tab will be useful for editing Python (indentation is very important to Python!). I'd recommend Notepad++ if you don't have something already, just Google it.

Then, inside CvEventManger there's a function called onCityAcquired which is where you'd put your code. As a very preliminary see that it works hack, you could just add:

Code:
newName = pCity.getName()
newName = newName[::-1]
newName = newName.capitalize()
pCity.setName( newName )

This will take the existing name, reverse it, and then recapitalize it. Make sure all these lines are indented to the same level as the other contents of onCityAcquired!

onCityAcquired, in addition to giving you pCity also tells you who the city was captured from, who now owns it, and whether it was conquered or not. Like I said before, this is a very inelegant solution to your request, but it will get the job done. In the long term you should check out a CustomEventManager and figure out how to create a separate python file which adds a new handler for the cityAcquired event, this will just get you started.

Good luck.
 
I would suggest you take a look at the Greek World scenario that came with the game. It had a very good example of how this is done. :)
 
You can do this easily with Python. There's an event (an event in Python is not the same as a random event in the game ...) called cityAcquired.

The easiest way to make a mod that did this is to create a new folder in your Program Files/.../BTS/Mods directory called "CityRenameMod" or whatever. Inside this folder, create a folder called Assets and in the Assets folder, create a folder called Python. Then, copy CvEventManager.py from the main BTS/Assets/Python directory to this new Python directory.

You can edit CvEventManager.py with any text editor, though one that's aware of syntax and can show you what's a bunch of spaces and what's a tab will be useful for editing Python (indentation is very important to Python!). I'd recommend Notepad++ if you don't have something already, just Google it.

Then, inside CvEventManger there's a function called onCityAcquired which is where you'd put your code. As a very preliminary see that it works hack, you could just add:

Code:
newName = pCity.getName()
newName = newName[::-1]
newName = newName.capitalize()
pCity.setName( newName )

This will take the existing name, reverse it, and then recapitalize it. Make sure all these lines are indented to the same level as the other contents of onCityAcquired!

onCityAcquired, in addition to giving you pCity also tells you who the city was captured from, who now owns it, and whether it was conquered or not. Like I said before, this is a very inelegant solution to your request, but it will get the job done. In the long term you should check out a CustomEventManager and figure out how to create a separate python file which adds a new handler for the cityAcquired event, this will just get you started.

Good luck.

Nice tip, thanks.
 
Back
Top Bottom