Editing CvMapGeneratorUtil

tsentom1

Bubble Dragon
Joined
Jul 24, 2007
Messages
1,000
Location
New York
Hi, I want to know if it's possible to edit this python file for my mod so it will never generate a certain type of terrain on any map that calls it. if so, any tips?

For example. I made a new terrain (lets call it terrain a) that's tied to a specific event. however, since i made it, it gets randomly generated into maps. i want to prevent this from happening so the terrain type will only appear with my event (i already coded it appearing for the event)
 
It's better to subclass the Feature Generator (or Terrain Generator, or what ever you need) and overwrite / overload the functions you want to chage within your map script.

This way you won't affect the other scripts that do rely on the CvMapGeneratorUtil classes.

But you can als edit the CvMapGeneratorUtil if you prefer. Depending on what exactly you need to change... Just find the Class/Function placing the terrain you want to get rid of..
 
I actually want it to affect all map scripts, as I don't want the terrain to appear in any map not just one map type. However, since it's a new terrain type it won't have an existing function. So say I define iNewTerrain (blah blah get infotype "terrain_a"). I can then set it in the terrain generator? I'll try when I get home from work. Thanks.
 
What exactly did you add ? Is is a Terrain (like grass, plains, desert ...) or feature (forest, jungle...) etc...
 
if you have added a new terrain. CvMapGeneratorUtil shouldn't add some unless you have specified a function for your terrain in. If you just get some terrain generated near starting locations : this is probably because of the normalization functions (normalizeAddGoodTerrain, normalizeRemoveBadTerrain) that can add another terrain not generated before.
To prevent that some SDK changes may be required. But perhaps not if :

_ the sum of yields is the same of 2 other terrains, just put your terrain between this two ones in the xml. For normalizeAddGoodTerrain, the process take the last terrain in the xml that have 2 foods. For normalizeRemoveBadTerrain, it takes the first one with 1/2 food and 1/2 total yield depending on some cases.

But with the basic terrains i don't think about a good solution that can match with all cases. Perhaps replace them at onGameStart with python is the easiest solution in this case.


Tcho !
 
Top Bottom