Placing Improvements At Start of Game

OzzyKP

Deity
Joined
Dec 16, 2000
Messages
2,044
Location
Washington, DC USA
For my Vanilla map I placed all the resources myself but had towers and goody huts and barrows and such drawn randomly at the beginning of the game so there would be some novelty and unpredictability in the map. The code I had for vanilla doesn't work now in BTS and the file it was in is completely different now.

So does anyone know what code I need and which file to put it in?
 
iAppearanceProbability in CIV4ImprovementInfos.xml was added in FfH2.25(see Modder's Guide to FfH2). I'm not certain if there is another check somewhere to see if the improvement is enabled for random placement or not(I thought there was, but can't seem to find it atm).

It's easy enough to test by setting it at 100, however.
 
Pretty sure that value is only for unique features (Dragon Bones, Ygg...). The barrows and goody huts, which you always have in game, and have multiple of, don't seem to fit a value that caps at 100% (unless that means one on every tile, which would be insanely wierd)
 
It might be possible to place a resource on the tile during map generation and then change the code so that it replaces those resources with whatever those improvements are. But it might pose a problem if it appears on a rare resource.
 
Improvement Attributes:
iAppearanceProbability- chance (in 10,000) that this improvement will be placed on applicable plots by the random map generator
so roughly 1 for every 100 tiles, could go crazy and set it at 1000 if you want to be REAL certain =p
 
For my Vanilla map I placed all the resources myself but had towers and goody huts and barrows and such drawn randomly at the beginning of the game so there would be some novelty and unpredictability in the map. The code I had for vanilla doesn't work now in BTS and the file it was in is completely different now.

So does anyone know what code I need and which file to put it in?

If i have well understood , you play with a scenario without resources , hut etc , and like to add them randomly at the beginning of the game ? ( if not what's your code , are you running a map script generator ) .
 
If i have well understood , you play with a scenario without resources , hut etc , and like to add them randomly at the beginning of the game ? ( if not what's your code , are you running a map script generator ) .

Correct (i think).

It is a premade map. The map has sugar, iron, horses, mana, etc already placed on the map. But I haven't placed huts, towers, & barrows and want them to be placed randomly at the start of the game. Typically all resources and tile improvements (like barrows etc) are placed randomly at the beginning of the game, but since I'm using a premade map that map overrides the random placement. That is good since I don't want the random placement to mess up my resources (mana, furs, etc). But I DO want the improvements (towers, huts, etc) to be placed at the start.
 
Correct (i think).

It is a premade map. The map has sugar, iron, horses, mana, etc already placed on the map. But I haven't placed huts, towers, & barrows and want them to be placed randomly at the start of the game. Typically all resources and tile improvements (like barrows etc) are placed randomly at the beginning of the game, but since I'm using a premade map that map overrides the random placement. That is good since I don't want the random placement to mess up my resources (mana, furs, etc). But I DO want the improvements (towers, huts, etc) to be placed at the start.

Ok this is not so simple , because you can't use CyMapGenerator().addGameElements() ( including all feature elements ). there is no python entries for addImprovement and addUniqueImprovement , so if you don't want that the generation replace the resources , features and rivers . The only thing to do is to rewrite the C++ functions that add the improvements in python at the beginning of the game . Do you want that i try to do the function ? have you a python knowledge in order to debug the function in case that do not work ?

Tcho !
 
Someone wrote up some code in python for me in vanilla and it worked fine. I'll post that here for you sometime later tonight. That worked wonderfully, but it doesn't work with BTS and v.25. So if you want to take a look at that and make it work in BTS I would greatly appreciate it (and fans of my map would as well). Having that code from .23 will give you a good headstart too.
 
Someone wrote up some code in python for me in vanilla and it worked fine. I'll post that here for you sometime later tonight. That worked wonderfully, but it doesn't work with BTS and v.25. So if you want to take a look at that and make it work in BTS I would greatly appreciate it (and fans of my map would as well). Having that code from .23 will give you a good headstart too.

Yes , you can . But can you post your scenario also , because if you're not able to debug , i will do it with the scenario . Another thing , do you want that the special features appears at a minimum range of the starting locations ?

Tcho !
 
This, I believe, is the part that does it:
Code:
	def FFHAddImprovements(self):
		iBarrow = gc.getInfoTypeForString('IMPROVEMENT_BARROW')
		iBarrowChance = gc.getDefineINT('BARROW_CHANCE')
		iRuins = gc.getInfoTypeForString('IMPROVEMENT_RUINS')
		iRuinsChance = gc.getDefineINT('RUINS_CHANCE')
		iTower = gc.getInfoTypeForString('IMPROVEMENT_TOWER')
		iTowerChance = gc.getDefineINT('TOWER_CHANCE')
		iGoodyHut = gc.getInfoTypeForString('IMPROVEMENT_GOODY_HUT')
		iGoodyHutChance = gc.getDefineINT('GOODY_HUT_CHANCE')
		for i in range (CyMap().numPlots()):
			if CyGame().getSorenRandNum(10000, "Add Barrows") <= iBarrowChance:
				pPlot = CyMap().plotByIndex(i)
				if (pPlot.canHaveImprovement(iBarrow,-1,True) and pPlot.getImprovementType() == -1 and pPlot.isCity() == False and pPlot.getFeatureType() == -1):
					pPlot.setImprovementType(iBarrow)
			if CyGame().getSorenRandNum(10000, "Add Ruins") <= iRuinsChance:
				pPlot = CyMap().plotByIndex(i)
				if (pPlot.canHaveImprovement(iRuins,-1,True) and pPlot.getImprovementType() == -1 and pPlot.isCity() == False):
					pPlot.setImprovementType(iRuins)
			if CyGame().getSorenRandNum(10000, "Add Tower") <= iTowerChance:
				pPlot = CyMap().plotByIndex(i)
				if (pPlot.canHaveImprovement(iTower,-1,True) and pPlot.getImprovementType() == -1 and pPlot.isCity() == False):
					pPlot.setImprovementType(iTower)
			if CyGame().getSorenRandNum(100, "Place Goody Hut") <= iGoodyHutChance:
				pPlot = CyMap().plotByIndex(i)
				if (pPlot.canHaveImprovement(iGoodyHut,-1,True) and pPlot.getImprovementType() == -1 and pPlot.isCity() == False):
					pPlot.setImprovementType(iGoodyHut)

It was in CustomFunctions.py
 
Ok , i will try to do something . But the lair improvements are placed with the SDK in 0.25l . so the code is not the same . I 'll tell you as soon i have a result . Note that will probably not work with shadow since the team will change a lot of things with improvements in shadow if i've well understood .

Tcho !
 
But i need the map for 0.25l . i got a crash with the scenario and FFH2 0.25l . And i don't know how to convert the scenario to BtS .

Tcho !
 
Ok , all works . Here the file to replace .

Tcho !
 
Sto, for some reason now I get a python error whenever I load a mod (any mod). This is the error message I get:

http://forums.civfanatics.com/showthread.php?p=6238230#post6238230

Is it related?

I've just change the file CvModEvents.py (you just have to replace it , and restore it when you play a regular game ) . The function ffhAddImprovements is not in FFH 0.25 so i think you should have inserted an error in the file when you have copy paste it on the forum ( a space or a tabulation probably ) .Can you post the file . ( or install this version on a temp folder , and replace the file )

Tcho !
 
Back
Top Bottom