View Full Version : How do I associatie a population cost with unit production


Dave Lawson
Jul 20, 2009, 04:08 PM
I'm interested in creating a mod that involves the player having a limited population which they can shift between one task and another. Some of those tasks involve becoming a unit that moves about the playing field. What would be the best way to reduce the population of a town by one upon construction of a unit (think settlers in the older civ incarnations), and similarly to increase the population of the city if that unit decides to return home (also something settlers could do, once upon a time).

PieceOfMind
Jul 21, 2009, 04:57 AM
If you're ok with SDK stuff, I might suggest having a look at CvCity.cpp, and find this:

void CvCity::changePopulation(int iChange)
{
setPopulation(getPopulation() + iChange);
}
The functions in that vicinity concern the population points of a city.

Tholish
Jul 21, 2009, 05:58 AM
The remerging of population was one of my favorite exploits in civ 3. The AI had no idea how to use that feature.

Dave Lawson
Jul 21, 2009, 08:40 PM
Thanks a bunch for the info. I just got the SDK functioning, so I'll take a look in there.

This ain't for the typical civ game, it's for a survivalist game, where you only have a set # of people. The scope is a lot smaller, and one unit literally represents one person. Anyways, I'm rambling now.

Dave Lawson
Jul 21, 2009, 10:06 PM
Got another question somewhat related:

After looking through the code for a while, and seeing the python invocations, it occurred to me that there might be absolutely no reason for me to use the python, since I can simply modify the c++ directly, with which I'm a great deal more familiar.

Am I missing something? Does the python route provide some unique opportunities?

TC01
Jul 21, 2009, 10:24 PM
Got another question somewhat related:

After looking through the code for a while, and seeing the python invocations, it occurred to me that there might be absolutely no reason for me to use the python, since I can simply modify the c++ directly, with which I'm a great deal more familiar.

Am I missing something? Does the python route provide some unique opportunities?

Python is easier to change- not necessarily because the language is easier, but because you don't have to recompile a new DLL every single time you want to test one change. The whole point of Python is to be more accessible then the C++ when you want to change something. It's also where the random and scripted events are done in normal Civ, but I imagine both of these are doable in the SDK as well.

Whereas, Python code slows down the game because of the callback time, and it is completely ignored by the AI. And you can do so much more in the SDK than you can in Python.

So it's probably better to do it in the C++, but I do my modding in Python because of the accessibility.