[Development Thread]CIVILIZATION 4: World of Pokiphlanon

I actually never looked at a map script, but you should learn Python anyway (if you haven't already). Because if you do I could probably help you decipher some existing map scripts. (I'm guessing they're all basically following the same template. Copy-pasting, that sort of thing. :rolleyes: You probably end up doing something similar, but you really need to be able to read and write Python to make your own.)
 
I KNOW PYTHON. Note my 5 Python modcomps (I know, I have 9 modcomps, but 3 weren't entirely mine, and 1 is a reskin).
 
Ah, then it wouldn't even be an issue creating your own? You'll probably end up giving me a crash-course in map script writing one of these days. :D
 
There's another concept that seems easy enough(Relative Term): City Size Limits. In World of Pokiphlanon, cities have a size limit. Cities can only grow to a certain size, which can be increased by researching the Urbanization tech line. I think this would be fairly easy in C++, just add something to stop a city from growing if it's a certain size. But would I need to make some sort of major AI change?
 
I guess Civ4 is not your first Civ :D.

Funny, it is...
AI has to be modified, so that it will priorize these techs when it has many growing cities near at the limit, but else i don't think any adjustions have to be made.

And how would I make those adjustments?
 
Funny, it is...

:lol: okay.
Why i said it: I think all previous civs had a sort of city growth limitation, and people are always thinking about the same for 4.

And how would I make those adjustments?

No concrete idea :dunno: (SDK is not my field).
I think there has to be somewhere a choose tech function for the AI (at least you can hook into that via python), so you "just" have to add some checks, if there are some cities at their limit and could grow further.
 
Well, I've played all version of Civilization and the city size limit thing is something that is to be expected. But I guess Firaxis substituted it with the Health system instead.

But the question remains - what would be the best approach for limiting city size? A dirty Python fix is of course always available - get the city size limit and adjust the city size every turn. But that's probably not even the second best option... :p
 
But the question remains - what would be the best approach for limiting city size? A dirty Python fix is of course always available - get the city size limit and adjust the city size every turn. But that's probably not even the second best option... :p

Right :D. In CvGameUtils, there's the doGrowth callback, which could be used.
But because he's already doing SDK, i'd never ever suggest it. With SDK you can do the already mentioned proper AI modifications, which makes this method quite superior.
 
Well, I think I've thought of a way to do it in SDK, not sure though.
 
Oh, I should probably have looked for that then. And there is of course no need for the Python work-arounds if you can edit the SDK.

I guess the answer to my question is to locate the place where the doGrowth callback (or whatever) is made (in the SDK) and add the check for city growth condition vs city size there. And where might this be...?
 
First, you indeed have CvCity::doGrowth() to add your limitation.

Second, as for the AI - that depends on which changes you want to do exactly:
For tech choosing - look at the (very) long function CvPlayerAI::AI_bestTech() - it goes over all available techs and scores each of them according to a variety of parameters. You can add your code here.
If you also have buildings which affect maximum city size, then for city production selection look at CvCityAI::AI_bestBuildingThreshold().
 
If you also have buildings which affect maximum city size, then for city production selection look at CvCityAI::AI_bestBuildingThreshold().

I don't, but good idea, maybe later, if I don't feel like I have enough buildings...

I've run into a problem. In CvPlayerAI::AI_ChooseTech , how can I get the player who's AI we're talking about? In fact, how does CvPlayerAI relate to CvPlayer?

What I need to do is call this method:
Code:
int CvPlayer::getAvgCityGrowthRoom()
,
,which is a method of CvPlayer.

Oh, and how do you get a CvPlayer from a PlayerTypes?
 
I'm guessing that the source code is capable of detecting if a given player is AI or human, so perhaps you don't even have to think about it. And the PlayerTypes is just a enumerated index of CvPlayer instances. You get a CvPlayer with GC.getPlayer().
 
And the PlayerTypes is just a enumerated index of CvPlayer instances.
I know.
You get a CvPlayer with GC.getPlayer().
I should have mentioned: CvGlobals has no method "getPlayer". In other words: there is no GC.getPlyaer()
 
Look at the existing code to see how it does things. Obviously it must use the player index to get the actual corresponding CvPlayer object in a lot of places.

So, to help you out a bit more, in this case the answer is that it uses the GET_PLAYER macro, which is actually defined in CvPlayerAI.h to be CvPlayerAI::getPlayer. So do what it does and use GET_PLAYER(iWhoAmI).
 
Also note that in your case you don't need GET_PLAYER.

Look at this line (taken from CvPlayerAI.h):
Code:
class CvPlayerAI : public CvPlayer

This is the declaration of the class CvPlayerAI.
It means that CvPlayerAI inherits from the class CvPlayer, which means that it has all of its methods and members.
So anything* you can do inside CvPlayer you can also do inside CvPlayerAI, since you're already inside the scope of the player (all players are actually instances of CvPlayerAI, not CvPlayer).

* Well, in this case, anyway. There are cases where there are things you cannot do in an inherited class, but it's not relevant to this case.
 
I saw that after my last post, but it still has the red line. The error says, when I mouse over it,

Error: the object has type qualifiers that are not compatable with the member function "CvPlayerAI::getAvgCityGrowthRoom"

Know what it means?
 
This function is probably one you've written, since it doesn't exist in BTS code, but I'm guessing you declared it as a non-const method and you're trying to call it with a const pointer?

A const method is defined like this:
Code:
int getAvgCityGrowthRoom() [B]const[/B];

If you're using 'this' (or simply call a method for the current object) from within a const method, the pointer will be const as well.
 
I thought const was used for things that didn't change (i.e. XML values). I though I read that somewhere.
 
Back
Top Bottom