[How to...] make fundamental changes to Cities

ZooMan2

Warlord
Joined
Oct 5, 2007
Messages
100
Location
North Carolina, USA
I'd like to make a couple of fundamental changes to the rules about city placement and the resources they can draw on as follows:

1) I'd like to change or remove the restriction on how closely cities can be founded. I'm assuming this has to be done either in the SDK or in Python or both. Is there an existing mod that does this? If not, can someone give me some quick pointers on where to go and what I need to do to implement this change.

2) I'd like to change the resources that a city can call on either up or down (example larger T, smaller T or no T). The "Big City" mod reads like it does this but I can't figure out where this specific change is implemented.

I've scanned a lot of "how to" threads and docs but I haven't found the answers yet. Any help will be appreciated.
:confused:
 
Thanks Fanatic Demon - answer for #1 is exactly what I was looking for. Sorry for not being clear on #2. Re #2, when you are inside the city screen you can see that the maximum number of squares availble for a city to use is 21 squares in the following pattern:

_xxx
xxxxxx
xxxxxx
xxxxxx
_xxx

What I am asking with #2 is how to change that either larger or smaller. I'll check out your mod and see if that does what I am looking for.
 
I see, you want to have multiple levels in city plot size.

I happen to created a modification to mylons larger city size mod which does exactly that:

It turns the default 2 city range levels into 10 city levels delpending on culture level:

Culture level --- plots - delta
=======================
POOR ---------- 9 ----- start
FLEDGLING ----- 13 ---- +4
DEVELOPING ---- 21 ---- +8
ELEGANT ------- 29 ---- +8
REFINED -------- 37 ---- +8
DISTINGUISHED - 45 ---- +8
INFLUENTIAL ---- 57 --- +12
EXTRAVAGANT--- 69 --- +12
ICONIC ---------- 81 --- +12
LEGENDARY ------ 97 --- +16

this is what legendary city look like with 10 culture levels:
CityScreen.JPG

now doesn't that look great?

you can download the mod from: http://forums.civfanatics.com/uploads/49944/Enhanced_Size_Cities_0.93_plus_Level_10_fix.rar

Check the code on how I exacly managed this.

CvDefines
Code:
#define NUM_CITY_PLOTS_1 			(9)
#define NUM_CITY_PLOTS_2  			(13)
#define NUM_CITY_PLOTS_3 			(21)
#define NUM_CITY_PLOTS_4 			(29)
#define NUM_CITY_PLOTS_5 			(37)
#define NUM_CITY_PLOTS_6				(45)
#define NUM_CITY_PLOTS_7				(57)
#define NUM_CITY_PLOTS_8				(69)
#define NUM_CITY_PLOTS_9				(81)
#define NUM_CITY_PLOTS_10			(97)
#define NUM_CITY_PLOTS				(97)
#define CITY_HOME_PLOT				(0)
#define CITY_PLOTS_RADIUS			(5)

CvCity.cpp
Code:
int CvCity::getNumPlots() {
	int iRadius;
	int var_city_plots;
    iRadius = GC.getCultureLevelInfo(getCultureLevel()).getCityRadius();
    switch (iRadius)
    {
    case 10:
        var_city_plots = NUM_CITY_PLOTS_10;
        break;
    case 9:
        var_city_plots = NUM_CITY_PLOTS_9;
        break;
    case 8:
        var_city_plots = NUM_CITY_PLOTS_8;
        break;
    case 7:
        var_city_plots = NUM_CITY_PLOTS_7;
        break;
    case 6:
        var_city_plots = NUM_CITY_PLOTS_6;
        break;
    case 5:
        var_city_plots = NUM_CITY_PLOTS_5;
        break;
    case 4:
        var_city_plots = NUM_CITY_PLOTS_4;
        break;
    case 3:
        var_city_plots = NUM_CITY_PLOTS_3;
        break;
    case 2:
        var_city_plots = NUM_CITY_PLOTS_2;
        break;
    default:
        var_city_plots = NUM_CITY_PLOTS_1;
        break;
    }
	return(var_city_plots);
}

CvGlobals.cpp
Code:
	int aiCityPlotX[NUM_CITY_PLOTS] =
	{
	0,
	0, 1, 1, 1, 0,-1,-1,-1,
	0, 2, 0,-2,
	1, 2, 2, 1,-1,-2,-2,-1,
	0, 2, 3, 2, 0,-2,-3,-2,
	1, 3, 3, 1,-1,-3,-3,-1,
	2, 3, 3, 2,-2,-3,-3,-2,
	0, 1, 4, 4, 4, 1, 0,-1,-4,-4,-4,-1,
	2, 3, 4, 4, 3, 2,-2,-3,-4,-4,-3,-2,
	0, 1, 5, 5, 5, 1, 0,-1,-5,-5,-5,-1,
	2, 3, 4, 5, 5, 4, 3, 2,-2,-3,-4,-5,-5,-4,-3,-2,
	};

	int aiCityPlotY[NUM_CITY_PLOTS] =
	{
	0,
	1, 1, 0,-1,-1,-1, 0, 1,
	2, 0,-2, 0,
	2, 1,-1,-2,-2,-1, 1, 2,
	3, 2, 0,-2,-3,-2, 0, 2,
	3, 1,-1,-3,-3,-1, 1, 3,
	3, 2,-2,-3,-3,-2, 2, 3,
	4, 4, 1, 0,-1,-4,-4,-4,-1, 0, 1, 4,
	4, 3, 2,-2,-3,-4,-4,-3,-2, 2, 3, 4,
	5, 5, 1, 0,-1,-5,-5,-5,-1, 0, 1, 5,
	5, 4, 3, 2,-2,-3,-4,-5,-5,-4,-3,-2, 2, 3, 4, 5,
	};

	int aiCityPlotPriority[NUM_CITY_PLOTS] =
	{
	0,
	1, 2, 1, 2, 1, 2, 1, 2,
	3, 3, 3, 3,
	4, 4, 4, 4, 4, 4, 4, 4,
	5, 6, 5, 6, 5, 6, 5, 6,
	7, 7, 7, 7, 7, 7, 7, 7,
	9, 9, 9, 9, 9, 9, 9, 9,
	10,10,10,10,10,10,10,10,10,10,10,10,
	11,11,11,11,11,11,11,11,11,11,11,11,
	12,12,12,12,12,12,12,12,12,12,12,12,
	13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
	};

	int aaiXYCityPlot[CITY_PLOTS_DIAMETER][CITY_PLOTS_DIAMETER] =
	{
	    {-1,-1,-1,92,77,78,79,93,-1,-1,-1},
	    {-1,-1,91,65,53,54,55,66,94,-1,-1},
	    {-1,90,64,42,34,27,35,43,67,95,-1},
	    {89,63,41,26,18,12,19,28,44,68,96},
	    {76,52,33,17, 6, 7, 8,20,36,56,80},
	    {75,51,25,11, 5, 0, 1, 9,21,45,69},
	    {74,50,32,16, 4, 3, 2,13,29,46,70},
	    {88,62,40,24,15,10,14,22,37,57,81},
	    {-1,87,61,39,31,23,30,38,58,82,-1},
	    {-1,-1,86,60,49,48,47,59,83,-1,-1},
	    {-1,-1,-1,85,73,72,71,84,-1,-1,-1},
	};
As you can see, the plots are arranged in a circular motion from the center

Note however that there is a 90 degree turn to the right when the X,Y coordinates are plotted from aiCityPlotX/aiCityPlotY to aaiXYCityPlot

I hope this is what you were looking for ;)
 
You are Great! That is exactly what I was looking for - thanks heeps!
 
Well I was planning to look at them actually and understand what they are doing and how they work. At the moment I'm trying to bring myself up to speed on how you mod in Civ4. I've worked extensively with Civ III but the Civ4 modding process is a completely new world. I've programmed in the past but never in C++ (mostly RPG/400 and a long time ago COBOL and Fortran). I've been reading through a bunch of "how to" doc and threads but I've found that actually reading the code does wonders for understanding how to actually make stuff work. Eventually I'll try to take some of my more ambitious Civ III projects and see if I can do the things I could never do in Civ III in Civ4.

Be sure I'll ask before I use anything you've developed and of course I'll make sure you are credited in anything I release if I ever get that far.

Long answer to a short question but hopefully I have answered the question.
 
I've been reading through a bunch of "how to" doc and threads but I've found that actually reading the code does wonders for understanding how to actually make stuff work.
I'd start with small changes to get familiar with the Civ4 convoluted class setup and their apparent love of macros :)

For example, look at some Python mods and try to convert them into SDK mods, a good one that isn't too complicated is tile stack limits (it fits entirely within a single method of the unit class). Another good way to get up to speed with the SDK is to look at parts that you understand exactly how they work in the game so you can see how that is expressed.
 
cool - thanks for the tips. That is a good idea about starting with small changes and working up. I'll give it a shot.

Thanks,
ZooMan2
 
Back
Top Bottom