Can Python bring back terrain-transforming (a la Civ2's Engineer)?

Man, you are so descriptive sometimes...
 
FALSE ALARM -
i rechecked and i did something wrong with the python.

sweeeet!

now lets complicate stuff :)
1. not quite sure how to implement this on hills and peaks - despite what you said....:(
2. how about a code, that leaves the improvement instead of eliminating it after build, and upon pillage or building another imp on it, down grades the terrain?

anyway, isenchine, i sense that you are a great modder thats on the rise :) thank you for the scroll board as well.
 
1) what is the problem: the code or something else?

The code could look like:
Spoiler :
Code:
	def onImprovementBuilt(self, argsList):
		'Improvement Built'
		iImprovement, iX, iY = argsList
		
		if(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_PEAK_TO_LAND')):
			pPlot = CyMap().plot(iX,iY)
			pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
 			# pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_PLAINS" ), True, True)
			pPlot.setImprovementType(-1)
		
		if (not self.__LOG_IMPROVEMENT):
			return
		CvUtil.pyPrint('Improvement %s was built at %d, %d'
			%(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))
assuming that you want to change a peak to land and that the improvement you are building on top of your peak is called 'IMPROVEMENT_PEAK_TO_LAND'.

In this example, the pPlot.setTerrainType is commented out but you can ofc uncomment it if, at the same time, you want to change the terrain.

2a) to leave an improvement, just comment out the line "pPlot.setImprovementType(-1)"

2b) how can you build another improvement on top of it? What you can do is have an improvement that grows when worked by citizens, just like for the cottage/hamlet/town. Or that is reduced to ruins when pillaged (or to any other improvement). Those ruins can then have a negative yield on the terrain. Or just any other Python effect with the function onImprovementDestroyed.

Thanks for the praise but I'm just dwelling on stuff already created by others, even this idea of a fake improvement comes from a modcomp like this one by Avain. Nothing new under the sun here.
 
Which I did point out there are issues if you consider the AI.

Given a poor yield on the fake improvement, the AI will never use it.

Given a supreme yield, the AI will be misled to destroy a good improvement for it, such as a town, just to end up with perhaps no benefit, from plains to grass which is just converting 1 hammer to 1 food, yet an improvement that requires 100s of turns is gone.

For plots with resources, the AI will never replace the existing improvement, such as pasture for it.
Yet humans will just do it, and then rebuild the pasture in 3 turns.

Since you cannot build improvement in cities, you cannot terraform the city plot itself.

Terrain to terrain, AI is already dumb enough, add plot types and that's it.
 
Changing plots is indeed dangerous, as was already discussed for the change from flat terrain to coast. You have to set limits if you want to allow the AI to use it.

Also, if you allow workers on peaks, they will build farms or cottages on top of them.

You think it's a good 'fake' improvement: give some benefits to it and the AI will build it and benefit from it (think of forests added, a desert changed into an oasis or a flood plain).

You think it's dangerous to let the AI build it and just wanna use it occasionnally for yourself: don't give any benefits and the AI will never use it.

You want to cheat: up to you, you decide, people do what they want with their mod...
 
hey guys,
interesting thoughts.

if i want land to terrain - i need to switch this:
pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
to this:
pPlot.setPlotType(PlotTypes.PLOT_PEAK, True, True)
?

the pillage improvement is nice, but i thought of reverse terraforming :) but its not something id use i guess.

in my mod, theere are two codes that works well with this code for terra you given here,
i limit the construction of the improvement terrain, to 2 tile away - meaning you can have 2 workers build the terraforming improvement next to each other unless the improvement is destroyed. upon completion.
so its nice.

to fool the ai, i just gave on the terraforming improvments, some good bonuses - to fool the ai to do the improvement - 2 food 2 hammers 2 gold.
also raised the time length.

also i use mountains pass mod comp.

so eventually id like for my map to be terraformed slowly, allowing the terraforming improvements in mid game.

my mod had mars terrain, so mid game id like to make it greener - this way it will work.

too bad this code cant work like an improvement on an improvement on the plot - so you can terraform an existing plot with an improvement on it....

i guess this can be made to create a feature as well?


thanks for all the help guys,

im about to open up a new help thread - how to make "wormwholes on the map (feature or improvement) that can allow transportation between locations on the map - something like in ff+.

:)
 
if i want land to terrain - i need to switch this:
pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
to this:
pPlot.setPlotType(PlotTypes.PLOT_PEAK, True, True)
?

I don't understand you. A plot is a plot and a terrain is a terrain. On a tile you have both a plot and a terrain. I gave a list of the 4 plots, the terrains you have them in the xml (count off TERRAIN_PEAK and TERRAIN_HILL as explained above as they are rather plots than terrains).

i guess this can be made to create a feature as well?

Yes, with this line of Python, the last number being the variety of the feature.
Code:
pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST'), 0)
 
hehe yes sry man, i sometimes have trouble explianing what i want....

ill do some experiments :)

u thought this is how it will be , the feature thingy, cool, now ill make some improvements that create features.

veriety of the feature? "0"? whats that? different types of the forest?

cool.

feautes can be made to grow on an existing improvement only via sdk right?

thanks for everything so far friend.
hope im not babaling :)
 
HEY again

ok got a nice code working,
i did a nice system like you suggested -
i have a temporary improvement that adds a feature, that gives health, but is for limited turns - it upgrades to an empty improvement - so it will give boost to terrain for a short time, so does the feature removed when the improvement is gone.

cool :)

but -
i wasnt able to create a peak to hills code -can you help?

Spoiler :

# HILLS TO LAND
# elif(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_HILLS_X_LAND')):
# pPlot = CyMap().plot(iX,iY)
# pPlot.setPlotType(PlotTypes.PLOT_LAND, True, True)
# # pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_PLAINS" ), True, True)
# pPlot.setImprovementType(-1)
# THIS ONE CREATES TEMP IMP + FEATURE FOR HEALTH
elif(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_GROW_X')):
pPlot = CyMap().plot(iX,iY)
pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_GROW_X'), 0)
# pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_PLAINS" ), True, True)
#pPlot.setImprovementType(-1)
# LAND TO HILLS
# elif(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_PEAK_X_HILLS')):
# pPlot = CyMap().plot(iX,iY)
# pPlot.setPlotType(PlotTypes.PLOT_HILLS, True, True)
# # pPlot.setTerrainType(gc.getInfoTypeForString( "TERRAIN_PLAINS" ), True, True)
# pPlot.setImprovementType(-1)
if (not self.__LOG_IMPROVEMENT):
return
 
What is the problem? Do you get any Python errors or what?

You should put this with code quotes (spoiler, then code). Like this, I see no indentation. Otherwise your code looks correct to me but it is commented out.
 
ye i commented it out,
see - for some reason the workers, put on a peak - did not have the build mission for peaks.

although i have made that action to be only on peaks (using a peakmakevalid tag from a mod)
it didnt work - i also tried terrain makes valid - peak, but no go.
although - on hills, it did work :)
 
So the problem is not Python.

I was under the false impression that workers could work on peaks if made passable, but they can only build roads (never tried it myself before). I know that in C2C they have mines on peaks but no idea how they make it.
 
hey guys, well, so far i got what i need ,
so i thank you all.

god-emp - i got an upgraded code of the mountains (from dune wars) but thanks man.


*****

ok, now i want, another thing upon building an improvement,
can you guys , add me a line - that upon building an improvement, that changes terrain and being destroyed (the current code you guys helped with), there will be a line that adds X amount of gold?
meaning i want terraforming to add gold in addition to the terrafroming...?
 
And x would be what amount of gold? Fixed, random? If random, between what and what amount of gold?
 
Back
Top Bottom