creating new plot types

hachejay

beta shopper
Joined
Dec 30, 2009
Messages
43
Location
United Kingdom
Anyone ever try making new plot types? I looked around here and on civ4 but couldnt see any and theres a few things I was hoping to try.

Out of curiosity I copied out the code for peaks everywhere I could find it with the goal of simply making a second height of mountain for purely asthetic reasons and while the dll builds fine and the game loads the mod fine when I try and start a new game I get an xml parsing error for CIV4TerrainSettings.xml.

Anyone know if plot types are somthing likely to be hard coded that I'm not gonna be able to change or have I probably just messed up somewhere?
 
I have created a new terrain myself ("light green savanna" like in original civ) and did not have any problems.

It was pure xml (and graphics of course).

There is nothing hardcoded as far as I know.

Here is a screen (from the german forum, where I am developing my mod):
Screenshot
 
I mean plot types, not terrain types.

ie. Flatlands, Hills, Peaks, Coast, Ocean

not Grassland, Plains, Marsh etc.

This definately takes SDK, Python and XML work, but I was wondering if there was anything further that would stop it being possible as I can't get it working despite there being no errors in my code that I can see, and as far as I can tell from looking around, there dont seem be any mods for CIV4 that do this.
 
No problems with compiling the dll or loading the moad, but then there is no "Play Now" option in the menu and if I start a custom game I get this error followed by the game crashing:

 
Did you do any changes in CvInfos.cpp and CvInfos.h? If so, which were those

Likewise, did you do any changes to the TerrainInfos XML?

Anyhow, AFAIK no "Play Now" option means there are no map scripts available for use (if you don't let the mod use the public maps, that happens if you don't have a custom mapscript in it, or it could have been caused by the game not being able to successfully read the mapscripts due to the changes you did).
 
Hi hachejay!

I found the thread about Seasonal terrain changes.

Are you plan to apply your work for CivIVColonization?


No problems with compiling the dll or loading the moad, but then there is no "Play Now" option in the menu and if I start a custom game I get this error followed by the game crashing:


There is only one line for Peak in the CIV4TerrainSettings.xml

Code:
			<fPeakScale>0.24</fPeakScale>

If I understand your idea correctly, you added the second type of Peak. Thus, you have to add an additional line for your new Peak in this file, too. I'm not 100% sure, but I recommend to check.

P.S. Under upper "XML Load Error" screen, you must see the line number (on the bottom "XML Load Error" screen), where exactly you have the error.
 
Did you do any changes in CvInfos.cpp and CvInfos.h? If so, which were those

Likewise, did you do any changes to the TerrainInfos XML?

I think I did changes in all 3, but I can't remember right now. When I get back from work later I'll take a look at them and let you know.

Hi hachejay!

I found the thread about Seasonal terrain changes.

Are you plan to apply your work for CivIVColonization?

actually... Yes! this thread and that thread are both about an upcoming terrain mod for CivIVCol that I am working on at the moment...

I should have it ready to upload very soon, but for now I will upload some screen shots of what I have done so far at the end of this post!

There is only one line for Peak in the CIV4TerrainSettings.xml

Code:

<fPeakScale>0.24</fPeakScale>

If I understand your idea correctly, you added the second type of Peak. Thus, you have to add an additional line for your new Peak in this file, too. I'm not 100% sure, but I recommend to check.

I have added the line:

Code:
			<fHighPeakScale>0.42</fHighPeakScale>

P.S. Under upper "XML Load Error" screen, you must see the line number (on the bottom "XML Load Error" screen), where exactly you have the error.

This is very true... but unfortunatetly the file it lists there, FXml.cpp, is not found in CVGameCoreDLL, which is why I am thinking that maybe this is in the .exe file and I can't change it?

I will look into again, but for now I have other things to be working on! ;)

Thanks for your advice!

H.
 

Attachments

  • screen1jan.jpg
    screen1jan.jpg
    314.5 KB · Views: 125
  • screen2feb.jpg
    screen2feb.jpg
    315 KB · Views: 78
  • screen3march.jpg
    screen3march.jpg
    303.7 KB · Views: 89
  • screen4april.jpg
    screen4april.jpg
    295.2 KB · Views: 113
  • screen5may.jpg
    screen5may.jpg
    292.2 KB · Views: 74
  • screen6june.jpg
    screen6june.jpg
    280.7 KB · Views: 88
  • screen9sep.jpg
    screen9sep.jpg
    281 KB · Views: 77
  • screen8aug.jpg
    screen8aug.jpg
    281.1 KB · Views: 110
  • screen7july.jpg
    screen7july.jpg
    281.7 KB · Views: 89
  • screen10oct.jpg
    screen10oct.jpg
    293.3 KB · Views: 83
actually... Yes! this thread and that thread are both about an upcoming terrain mod for CivIVCol that I am working on at the moment...

I should have it ready to upload very soon, but for now I will upload some screen shots of what I have done so far at the end of this post!

Great! The seasonal color changes of terrains are very interesting in CivIVColonization, especially if you play as 1 turn = 1 month.

Moreover, such seasonal changes of terrains could be related to the seasonal variations in the production output of tiles. For instance, for the tile with Bonus_wheat or Bonus_corn: output from the bonus tile is minimal or zero at winter time, output from the same tile is maximum in summer/autumn months.

P.S. Anyway, if possible, please, print here the first error message screen, that was partially covered with the upper one.
 
Quote:
Did you do any changes in CvInfos.cpp and CvInfos.h? If so, which were those

Likewise, did you do any changes to the TerrainInfos XML?
I think I did changes in all 3, but I can't remember right now. When I get back from work later I'll take a look at them and let you know.

Nevermind, didn't go to work! :mischief:

Yes, there are changes in CvInfos.cpp and CvInfos.h, basically everywhere it said PeakSomething before it now says HighPeakSomething aswell on the line below it (I literally just duplicated the peak code everywhere I could find it just as a test of a new plot type) and in TerrainInfos.xml there is a new terrain type, HIGH_PEAK.

I have added a .rar of the plot test mod, you will be able to find all changes in the SDK by searching for highpeak.

P.S. Anyway, if possible, please, print here the first error message screen, that was partially covered with the upper one.

Unfortunately as soon as the error message appears the game crashes so I do not have time to move the upper error message away before it does. Try running the attached mod and see if it's different on your computer mayber?

Great! The seasonal color changes of terrains are very interesting in CivIVColonization, especially if you play as 1 turn = 1 month.

Moreover, such seasonal changes of terrains could be related to the seasonal variations in the production output of tiles. For instance, for the tile with Bonus_wheat or Bonus_corn: output from the bonus tile is minimal or zero at winter time, output from the same tile is maximum in summer/autumn months.

This is what I am thinking! So that colonies have to prepare for long hard winters with little or no food production, and change the way that starvation happens to make it a real challenge to establish colonies in northern climates! I think this is realistic of the way it would have been for colonies such as Jamestown trying to survive when they were first established in the new world!

At the moment I haven't got bonuses changing with the season (only terrain and features) but this is definately on my to do list... I will do some research on when crops are planted/harvested and then make it so that there is a "growing season" each year (for each different crop) when the bonus resource will appear, and then it will dissapear in the winter / the "off season". What do you think?

The hardest part of this mod is going to be writing a map script that can place all the new terrain types (currently I have 12 terrain types most of which change 3 or 4 times a year and 11 forest types that also change with them!), so for the first release I am going to design several historical scenarios, 1 for each country, with realistic starting positions and dates; eg. the england one will be called 1607: Jamestown or something and will start in may 1607 around the chesapeake bay area of virginia.

That way you don't have to play 250 years of 1 turn per month as well!
 
This is what I am thinking! So that colonies have to prepare for long hard winters with little or no food production, and change the way that starvation happens to make it a real challenge to establish colonies in northern climates! I think this is realistic of the way it would have been for colonies such as Jamestown trying to survive when they were first established in the new world!

At the moment I haven't got bonuses changing with the season (only terrain and features) but this is definately on my to do list... I will do some research on when crops are planted/harvested and then make it so that there is a "growing season" each year (for each different crop) when the bonus resource will appear, and then it will dissapear in the winter / the "off season". What do you think?

EXACTLY! The first change that I did in my current version of "1492: Global Colonization" mod was the radical correction of all resources. All mineral resources are available only in exhausted deposits, all natural resources (sugar, coffee, cocoa, tea, etc.) - only as BONUSES on rather rare bonus tiles. Now each bonus tile is very important.

Each bonus-free land tile has now only a 1-3 food, 1-3 lumber and 1-2 furs (hides) depending on the terrain type. Thus, the available food is the first and the main problem, when the player establishes his first city. I even plan to add some quantity of food in starting conditions for each player (a ship + 100 Food).

The hardest part of this mod is going to be writing a map script that can place all the new terrain types (currently I have 12 terrain types most of which change 3 or 4 times a year and 11 forest types that also change with them!)

Well, maybe exactly here I stopped when introduced "LONGITUDE" parameter in the game. No problems in dll compilation, no problems during testing and mod loading, but CTD during the map generation.....

Good luck in your work!
 
EXACTLY! The first change that I did in my current version of "1492: Global Colonization" mod was the radical correction of all resources. All mineral resources are available only in exhausted deposits, all natural resources (sugar, coffee, cocoa, tea, etc.) - only as BONUSES on rather rare bonus tiles. Now each bonus tile is very important.

Each bonus-free land tile has now only a 1-3 food, 1-3 lumber and 1-2 furs (hides) depending on the terrain type. Thus, the available food is the first and the main problem, when the player establishes his first city. I even plan to add some quantity of food in starting conditions for each player (a ship + 100 Food).

I very much agree! I will start putting things like this in once I have finished making all the terrains. To make the exhaustable deposits did you use this modcomp: http://forums.civfanatics.com/downloads.php?do=file&id=14881 or did you write something yourself? If so was it difficult? I haven't really looked into that yet...

Well, maybe exactly here I stopped when introduced "LONGITUDE" parameter in the game. No problems in dll compilation, no problems during testing and mod loading, but CTD during the map generation.....

That was kinda what I was thinking of doing as well. I don't really know much python unfortunately, but it's gonna be important for the mod so I guess I better start learning quick!

I'll keep you posted on my progess!



-----EDIT-----

ps. I also took a look at your weather mod because I was thinking of making a tropical "rainy season" for the amazon and places..! unfortunately I see you have done the storms as features (very cool though!) which means I couln't do something similar over brazil because the forests would disappear! perhaps there is a way to put two features on a plot? haha, I think im gonna make this mod WAY too complicated!
or how about merging the rain model with a forest model and swapping it in? but then how to make it happen randomly... dammit, I should stop thinking about these things and get on with what I'm tyring to do already or I'm never gonna get it finished! :lol:
 
I found error in your mod. Here report:

CIV4TerrainSettings.xml, line 21
You write:

Code:
			<fHighPeakScale>0.48</fPeakScale>

but should be

Code:
			<fHighPeakScale>0.48</fHighPeakScale>

Change and run your mod.

The picture however is a very strange:



Moreover, I cannot find on the map any HighPeaks at all.
 
<fHighPeakScale>0.48</fPeakScale>

doh! :crazyeye: I thought it would be something stupid like that! Thank you very much!

The world is definately wrong though! and your right, no high peaks anywhere. Which is strange. I'd reckon that my mistake here is going to be in the python, as I have no clue when it comes to python, probably in CvMapGeneratorUtil.py, and probably in this part here:

Code:
		for x in range(self.iNumPlotsX):
			for y in range(self.iNumPlotsY):
				i = y*self.iNumPlotsX + x
				val = self.continentsFrac.getHeight(x,y)
				if val <= iWaterThreshold:
					self.plotTypes[i] = PlotTypes.PLOT_OCEAN
				else:
					hillVal = self.hillsFrac.getHeight(x,y)
					if ((hillVal >= iHillsBottom1 and hillVal <= iHillsTop1) or (hillVal >= iHillsBottom2 and hillVal <= iHillsTop2)):
						peakVal = self.peaksFrac.getHeight(x,y)
[B]						highpeakVal = self.highpeaksFrac.getHeight(x,y)
						
						if (highpeakVal <= iHighPeakThreshold):
							self.plotTypes[i] = PlotTypes.PLOT_HIGHPEAK
						else [/B]if (peakVal <= iPeakThreshold):
							self.plotTypes[i] = PlotTypes.PLOT_PEAK
						else:
							self.plotTypes[i] = PlotTypes.PLOT_HILLS
					else:
						self.plotTypes[i] = PlotTypes.PLOT_LAND

(changes in bold)

but i'm not really sure. When i'm less hungover and I've finished the seasonal work I'll dive into it some more and see what I can come up with... It would be cool to be able to define other plots, I have a few ideas: Unpassable mountains and large rivers (that boats can sail down) are a couple of them, and I was also thinking about adding unique geological features, such as the grand canyon or the amazon river, that could be randomly placed and discovered kind of like in Sid Meier's Alpha Centuari if anyone rembers that?

So much to do, so little time! Well, it's more productive than actually working, right? ;)




------ edit ------

haha, as soon as I wrote that I noticed error no.2:

Code:
else if

is not used by python at all is it? nope nope nope. should be elif!

this solves the map generator problem, but still no high peaks anywhere to be seen!

back to square one much?



------ edit 2 ------

i also noticed that there was an error with the world builder... the hill button added plains, the plains button hills, and the water button plains as well. This is to do with the order of the plot types in the sdk, which I have no fixed by moving the PLOT_HIGHPEAK to the bottom of the list rather than after PLOT_PEAK. I took at look at CvWorldBuilderScreen.py which I hadn't before, and noticed the following code:

def allPlotsCB(self):
self.m_normalPlayerTabCtrl.enable(False)
self.m_normalMapTabCtrl.enable(False)
if (self.m_tabCtrlEdit != 0):
self.m_tabCtrlEdit.enable(False)

popup = CyPopup(CvUtil.EventWBAllPlotsPopup, EventContextTypes.EVENTCONTEXT_ALL, True)
iPopupWidth = 200
iPopupHeight = 50*PlotTypes.NUM_PLOT_TYPES
popup.setSize(iPopupWidth, iPopupHeight)

popup.setHeaderString(localText.getText("TXT_KEY_WB_CHANGE_ALL_PLOTS",()), CvUtil.FONT_CENTER_JUSTIFY)

for i in range (PlotTypes.NUM_PLOT_TYPES):
if (i==0):
popup.addButton(localText.getText("TXT_KEY_WB_ADD_MOUNTAIN",()))
elif(i==1):
popup.addButton(localText.getText("TXT_KEY_WB_ADD_HILL",()))
elif(i==2):
popup.addButton(localText.getText("TXT_KEY_WB_ADD_GRASS",()))
elif(i==3):
popup.addButton(localText.getText("TXT_KEY_WB_ADD_OCEAN",()))
elif(i==4):
popup.addButton(localText.getText("Add High Peak",()))

popup.addButton(localText.getText("TXT_KEY_SCREEN_CANCEL", ()))
popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
return 1

which I take to be the code for adding the plot type buttons to the world builder, but the changes I made in bold have no effect at all.

I'ved attached the updated mod code for anyone whos curious.
 

Attachments

...saw your post in Civ4 SDK...

I don't think anyone has ever added a new type of plot.
Deliverator tried it in Dune Wars, but didn't succeed.
They wanted to have a type of lowered terrain, which was achieved by abolishing peaks at all and turning them into this terrain type.
One of the additional infos which is missing here and was there needed is that somewhere is a height map (don't ask me where, i don't know it; .tga file, IIRC), which defines, how the visual structure, like a peak, appears ingame.
Don't know if this helps, but i guess it would not ever work without that info.

I guess there's also somewhere something hardcoded about terrain.
e.g. try to add a new terrain after TERRAIN_PEAK in the terrainInfos, and place it on the map via WB. It's distorted, and i have no idea why.
 
Hi The_J, thanks for your information! (amazing how many more people read the Civ4 forums than here ;) )

...you are very right about the height maps, thinking about it now and having done a search there is no where in the code I can find that refers to them at all... I had assumed it was with the art_defines or something but its not at all so yeah I suppose this must be hard coded in the exe, no?

but it did make me think about the code I'd written and realised that if that were the case... my terrain would be invisible on the map even if the code was working and sure enough, take a look at the screenshot attached! The plot type is there alright, and underneath grassland, so by all acounts barring the height map than this code is actually working! :crazyeye:

Well that makes me feel rather better about the whole thing... while being somewhat disheartening at the same time cos it probably means this is a dead end. So the question now is how to write a function from scratch that calls upon the height maps when drawing the plot. ho-hum. A problem for another day methinks, must sleep now so I actually get up and go do some actual work tomorow!

cheers for ya help!



----edit-----

ps. btw... if the dune wars peeps still want lowered terrain... that is actually the easiest modification in the world. You can infact do it by adding a single character to an xml file! Just edit Civ4TerrainSettings and use a negative modifier for fPeakScale. To look better youll need to edit the heightmap tgas as well, but in principal its that easy (see second screenshot for reverse hills in action!)


pps... there are only two lines in the SDK i can find in reference to heighmaps::

Code:
virtual float GetHeightmapZ(const NiPoint3 &pt3, bool bClampAboveWater = true) = 0;
in CvDLLEngineIFaceBase.h

and

Code:
NiPoint3 CvPlot::getPoint() const
{
	NiPoint3 pt3Point;

	pt3Point.x = getPointX();
	pt3Point.y = getPointY();
	pt3Point.z = 0.0f;

	pt3Point.z = gDLL->getEngineIFace()->GetHeightmapZ(pt3Point);

	return pt3Point;
}
in CvPlot.cpp

neither mean anything to me!
 

Attachments

  • screen2.jpg
    screen2.jpg
    206.1 KB · Views: 88
  • screen3.jpg
    screen3.jpg
    296.5 KB · Views: 113
Back
Top Bottom