[Development Thread]CIVILIZATION 4: World of Pokiphlanon

There's already a "minor civ" in Civ4, i guess you can use this one as base and add your changes to it.

:confused: Isn't the minor civ sort of like barbarian?
 
:yup:, but i think it partially fits.
They are civs with slight disadvantages and don't have the full civ power, so that's something you want.

:think: but short thought about it, it's probably easier to do all the stuff yourself, because then you'll not have some negative supprives from the standard code.
 
UPDATE: I have successfully added our first new XML tag, <PrereqBorderTerrain>! This tag makes the given terrain necessary as a border to the city that wants to construct the building. Got that? I will now assault the Array <NoTerrains>, which declared which terrains the building CAN'T be build on.


EDIT: Sorry about accidentally pluralizing <PrereqBorderTerrain>. It is not an array.
Hi Voyhkah.

I have a question about this code, if you don't mind helping out a noob. I'm trying to improve on a couple of buildings in the Cavemen to Cosmos Mod. Two buildings should require Forest or Jungle in the City Radius to be built, however the python code isn't written or isn't working. I don't know which as I'm new to python, though I presume it just isn't written as I don't get any python errors popping up. Need my Speed directed me to this thread however and I think I may be able to work out how to make it work using your code here... however I have a couple of questions.

Of course it doesn't work with features, although it should be easy enough to make it do so. And yes, <PrereqBorderTerrain>
To make it work with features what would I need to change? I presume I would just substitute the word terrain for feature wherever I see it in this code?

Not sure if this would work, haven't tested it yet due to not enough framework to run the mod, but this is my code.

In CvCity.cpp, under the method canConstruct:

Code:
CvBuildingInfo& building = GC.getBuildingInfo(eBuilding);
	int terrainInt = building.getPrereqBorderTerrain();
	TerrainTypes terrain = (TerrainTypes)terrainInt;
	bool border = true;
	if (terrainInt != -1)
	{
		if (!isBorderTerrain(terrain))
		{
			return false;
		}
	}

Also in CvCity.cpp:

Code:
bool CvCity::isBorderTerrain(TerrainTypes terrain) const
{
	int xCoord = getX();
	int yCoord = getY();
	for(int x = -1; x < 2; x++)
	{
		for(int y = -1; y < 2; y++)
		{
			int relXCoord = xCoord + x;
			int relYCoord = yCoord + y;
			CvPlot* plot = GC.getMap().plot(relXCoord,relYCoord);
			if(plot->getTerrainType() == terrain)
			{
				return true;
			}
		}
	}
	return false;
}

In CvGameTextMgr.cpp:

Code:
if (kBuilding.getPrereqBorderTerrain() != NULL)
	{
		CvTerrainInfo& terrain = GC.getTerrainInfo((TerrainTypes)kBuilding.getPrereqBorderTerrain());
		szBuffer.append(NEWLINE);
		szBuffer.append(gDLL->getText("TXT_KEY_DLL_PREREQTERRAIN", terrain.getDescription()));
	}

I just realized that in my post, I had accidentally made <PrereqBorderTerrain> plural. It is not plural. Sorry, but there can be only one PrereqBorderTerrain per building.
If I was to take this code and drop it into the corresponding python files for the Cavemen to Cosmos Mod and substitute all occurances of "terrain" for "feature" would I then just add the following code in the BuldingInfos file (for the correct buildings of course)?

<PrereqBorderFeature>
<PrereqFeature>
<FeatureType>FEATURE_FOREST</FeatureType>
<bPrereqFeature>1</bPrereqFeature>
</PrereqFeature>
<PrereqFeature>
<FeatureType>FEATURE_JUNGLE</FeatureType>
<bPrereqFeature>1</bPrereqFeature>
</PrereqFeature>
</PrereqBorderFeature>

Is there anything else I should be mindful of, bare in mind I'm practically a beginner in XML and I have no idea when it comes to python. Is there anything I would need to do to any other files? Such as the BuildingSchema etc.

I hope you don't mind helping me out if you have time.
 
This code is C++, not Python, so you can't use it in the Python files.

The core mechanics of the game and some other things - such as reading and parsing the XML - is written in C++ and compiled to the DLL file.
 
Asaf's right, you can't use C++ in Python. What you're doing is very different from what I did, because you want it to be necessary in the city radius, as opposed to what I have, which requires a border.

Anyway, I have a few things to recommend.
1. Take the time to learn Python. It's really easy, and unlocks a lot more stuff. Once you know python pretty well, you can try your hand at SDK (I actually find SDK easier, because Visual Studio has all sorts of useful tools and you can see the definition for all of the stuff. But enough of that). To start out at Python, I recommend reading Head First Programming, and then try one of the numerous Python tutorials.

But for now, I can easily write some code to change PrereqBorderTerrain to PrereqBorderFeature. But to merge this with the C++ code of Caveman2Cosmos, you would need some SDK capability. If you don't want to learn this now, xienwolf wrote a great tutorial (http://forums.civfanatics.com/showthread.php?t=314201). Otherwise, there might be a dirty Python fix, but I'm not all that great at Python:blush:, so you'd have to ask someone, or, because it's easier in the long run (And because Baldyr would never stop annoying you about it :lol: ), learn programming using the instructions above.

EDIT: A few things? Make that 1 thing. :D

Also, it seems you want multiple or-type PrereqBorderFeatures. That would be harder, but I could do it. Still, the problem of merging the two C++ projects (The custom one I would make and the one from Caveman2Cosmos) would still be a big problem, and that's a bit too much to ask of someone. If you have any questions, comments, concerns, etc., feel free to ask.
 
This code is C++, not Python, so you can't use it in the Python files.

The core mechanics of the game and some other things - such as reading and parsing the XML - is written in C++ and compiled to the DLL file.

Asaf's right, you can't use C++ in Python. What you're doing is very different from what I did, because you want it to be necessary in the city radius, as opposed to what I have, which requires a border.

Anyway, I have a few things to recommend.
1. Take the time to learn Python. It's really easy, and unlocks a lot more stuff. Once you know python pretty well, you can try your hand at SDK (I actually find SDK easier, because Visual Studio has all sorts of useful tools and you can see the definition for all of the stuff. But enough of that). To start out at Python, I recommend reading Head First Programming, and then try one of the numerous Python tutorials.

But for now, I can easily write some code to change PrereqBorderTerrain to PrereqBorderFeature. But to merge this with the C++ code of Caveman2Cosmos, you would need some SDK capability. If you don't want to learn this now, xienwolf wrote a great tutorial (http://forums.civfanatics.com/showthread.php?t=314201). Otherwise, there might be a dirty Python fix, but I'm not all that great at Python:blush:, so you'd have to ask someone, or, because it's easier in the long run (And because Baldyr would never stop annoying you about it :lol: ), learn programming using the instructions above.

EDIT: A few things? Make that 1 thing. :D

Also, it seems you want multiple or-type PrereqBorderFeatures. That would be harder, but I could do it. Still, the problem of merging the two C++ projects (The custom one I would make and the one from Caveman2Cosmos) would still be a big problem, and that's a bit too much to ask of someone. If you have any questions, comments, concerns, etc., feel free to ask.

Thanks to both of you. I wasn't aware it was C++ which just shows how much I know about programming. I've cobbled my way through XML from scratch copying what other code is there in various files. Doing this I have added working tech, buildings and civilopedia entries so it all fits together exactly the way it should. I think learning C++ and Python is a going to be a bit like learning to run before I can walk at the moment, but I've bookmarked this post so I can look at your links in the future.

I'm guessing, but I think judging by what Hydro said over in the C2C forum that they need someone with python ability to get the PrereqBorderFeature thing working. Apparently it's already half way done, but Hydro knows a lot more about what is required.

Thanks for the offer to help Voyhkah, but I can see you have your hands full with this project, it would be unfair to ask.
 
UPDATE: I've made a lot of progress and am now working on a WoP unique concept: Derivitive Religions! In the game, there are only 5 religions that can be founded normally. However, each of these religions has a derivitive religion that is randomly founded.

All religions provide unique C++ bonuses.
 
I am having some trouble with my code. Does anyone know a method that returns a CvGame object or pointer? I tried GC.getGame(), but it returns a CvGameAI, which, surprisingly enough, does not inherit from CvGame.
CvGameAI is tiny, I can't imagine what it does if it doesn't inherit from CvGame.

Does anyone know whay CvGameAI does, or how to get CvGame?

EDIT: Wait, I looked in CvGameAI.h, and it turns out it does inherit from CvGame.

The problem is solved. I forgot to rebuild, as opposed to just build. Rebuild is nessecary to recheck the .h files.
 
The problem is solved. I forgot to rebuild, as opposed to just build. Rebuild is nessecary to recheck the .h files.

Not if you use a makefile (and utility) that checks for dependencies, such as DannyDaemonic's makefile (or the make file in my tutorial that's based on his).
 
Where can I get uch a makefile?
 
Download the 'makefile and project' zip from my tutorial. It also contains the fastdep utility in the bin folder which the makefile uses (credit goes to DannyDaemonic).

Note that it might not be compatible with your VS project file. You can post your project file and I'll check it. If you use VS2008 express - just use the project file in that zip.
 
I've been doing some work on the models for units, resources, and features. I've attached a partially-completed model of a Nyurtzar. Wait, the attacher is saying it isn't a valid image file. Somebody know what's going on?
 
I'm not all that familiar with XML on pretty clueless with Python and SDK, but if there's anything I can do to help, just ask. :)
 
I have finished a basic Nyurtzar model!

imgnyurtzar.png
 
I am running into a problem with something called the LSystem.

A line at the top of CIV4BonusInfos states:

<!-- WARNING: It is not recommended that you remove Bonuses due to complications with the LSystem -->

Unfortunately, that is exactly what I must do. Does anyone know how to work with this "LStystem"?

Also, I don't know how to mark seams on my Nyurtzar, because it isn't simple like a square or sphere.
 
I've removed bonuses in my mod, but this has been due to problems with the LSystem file :D, but i don't remember any problems after removing the bonuses :dunno:.

Short summary: The PlotLSystem.xml is somehow the ethnic art styles file for bonuses and improvements. You can define there, how the stuff should get rotated, that different .nifs should get used if the plot is worked or not, ethnic improvements, etc.
So changing the artDefines_Bonus is not enough if you want to change the graphics for improvements and bonuses (if they use this file; not all do), you'd also have to dig in there.

But like said, don't remember any problems.
 
I have been trying to skin my Nyurtzar, but an running into problems. Does anyone know how to convert C. Roland's tutorial on importing models into Civ4 to work with blender 2.49?
 
Back
Top Bottom