Add victory condition

Paolo80

Chieftain
Joined
Dec 20, 2019
Messages
85
Hi guys.

I'm editing a scenario setting in the year of the four emperors (68-69 d.c.). I want to set the conquest of the city of Rome as victory condition. In other words, the first team which conquers the city of Rome, wins. How can I do? Have I set it in the xml, pyton or world builder files?

Thanks everyone for help!
 
A combination of XML and Python.

First, you can find a definition of all the existing victory types in Assets/XML/GameInfo/CIV4VictoryInfo.xml. Those are mostly there to say that these victory types exist, what their names are and which video plays if you complete them. If you want a new victory type ("conquest of Rome") you need to add it here. If the conquest of Rome should just trigger any of the existing victory types (e.g. Conquest), there's nothing to do. You have a bunch of entries here that can only control the way the current victory conditions work, so it's not very helpful for you.

You need Python to actually check for the victory. In Assets/Python/CvEventManager.py, there is a number of event hooks where you can put code that will be run each time a specific event happens. In your case, a useful one is "def onCityAcquired", which is triggered whenever someone acquired a new city in any way.

I assume the coordinates of Rome are fixed in your tutorial, let's say they're (50, 50) for the sake of example. You also need to know the ID of the new victory type you added in XML, which is based on the position of its XML entry in the file. If you add it at the end of the BtS file, it should be 7. Then you can add code like:
Code:
if (pCity.getX(), pCity.getY()) == (50, 50):
    gc.getGame().setWinner(iPlayer, 7)
If you're not familiar with Python, you always need to make sure that the code is properly indented to work correctly.
 
Thank you Leoreth,

I changed the python file CvEventManager, but it doesn't work. In every game team 0 wins, even if it doesn't aquire Rome.

I added victory condition in xml and I inserted the code as you suggested (red text down). 7 in the victory condition ID and 38, 14 is the Rome x, y position on the map.

Code:
def onCityAcquired(self, argsList):
        'City Acquired'
        iPreviousOwner,iNewOwner,pCity,bConquest,bTrade = argsList
        CvUtil.pyPrint('City Acquired Event: %s' %(pCity.getName()))
        if (pCity.getX(), pCity.getY()) == (38, 14):
                gc.getGame().setWinner(iPlayer, 7)

What is wrong?
 
It doesn't work anyway.

I upload the files I changed and map scenario.

Can someone correct them please?
 

Attachments

Last edited:
I found the solution. In CIV4VictoryInfo.xml I set bPermanent: 1. Now it works! Thank you for your help.
 
Back
Top Bottom