Maybe there is a way to make another elevation level through python?

Merkava120

Oberleutnant
Joined
Feb 2, 2013
Messages
450
Location
Socially distant
I've been testing out a bunch of orlanth's terrian textures lately, and somehow ended up with the opposite of a hill (screenshot attached).

I'm in a vanilla mod with the only difference being the terrains I've added, which are all identical except for the 'detail' texture. I wasn't changing plot types at all, so this is just the result of placing terrain. And I've definitely seen this kind of thing before.

Any ideas what causes this to happen? If it's the result of python interacting with the DLL to change terrain after it's already been placed, then maybe that "bug" could be used for a mod that allows another terrain level, without replacing one of the existing hardcoded ones (hill / peak / flatland) ?
 

Attachments

  • Screenshot 2022-06-22 150004.png
    Screenshot 2022-06-22 150004.png
    389.6 KB · Views: 37
Aha, I figured out what causes it!

If you have a map that has generated a coast with land surrounding that coast (a "lake" I think), and you place the new terrain on top of that coast, then the new plot looks like a 'depression'.

EDIT: So after some testing
  1. Any coast tile placed through the map generator gets this 'depressed' look when changed to a regular terrain in the worldbuilder.
  2. Coast tiles placed through the worldbuilder do not become depressions if changed back later.
  3. Saving the scenario and reloading it undoes all the 'depressions'.
  4. You really need the right terrain to make these look right; Orlanth's textures do it a lot better than vanilla terrain, especially "mudflats" in particular (not sure which pack it's from specifically).
So, maybe this is a way to create 'depression' terrains and keep them around:
  1. In CvMapGenerator, just after the loaded mapscript is finished deciding where terrains go, place some inland seas where you want depressions and keep track of where they are.
  2. After the map is fully loaded and generated (maybe on turn 1 of actual gameplay) change these tiles to land terrains called "depressions".
  3. When the game is loaded from a save, in the middle (?) of loading but before gameplay begins, replace all "depressions" with coasts -
  4. And then after gameplay begins when loading the save, replace all of the inland seas with "depressions" again.
Any thoughts on this? I know Dune Wars was able to get a new terrain type by messing with heightmaps and replacing peaks or something, but you could have hills + depressions with this workaround... I think. (I don't think anything in-game recognizes the height difference, though, as far as animations go.)
 
Last edited:
Changing Peak to Coast in WB also has this effect – a Baikal-like extra deep/ dark lake. I think that can also occur after regenerating the map, along with other glitches, e.g. strange shadows on hills. "Rebuilding" the terrain through the debug menu (Ctrl+Alt+D) removes those artifacts. I've just taken a look in the debugger and found that this Rebuild debug command and CvDLLEngineIFaceBase::RebuildAllPlots call the same function in the EXE. That's curious because RebuildAllPlots gets called in CvGame::regenerateMap, and CvDLLEngineIFaceBase::RebuildPlot gets called in CvPlot::setPlotType. So we shouldn't be seeing those glitches. If I call RebuildAllPlots instead of RebuildPlot in setPlotType, there's no glitch, so it might be that RebuildAllPlots does something important in addition to RebuildPlot, but this still doesn't explain glitches visible after regenerating that get purged by the debug command. Seems to be a timing issue: if I call RebuildAllPlots in the next CvGame::update call after regenerating, the terrain surfaces look normal.

Apart from allowing me to fix those issues with regenerated maps, these observations could help simplify your proposed hack for unusual terrain surfaces. It's probably not necessary to call setPlotType – a fairly costly function with a lot of side-effects on the game state. Some combination of m_ePlotType assignments and RebuildPlot calls, properly timed, might do the trick. Simply calling
Code:
void CvPlot::setDepression()
{
    m_ePlotType = PLOT_OCEAN;
    gDLL->getEngineIFace()->RebuildPlot(getX(), getY(),
            /*bRebuildHeights=*/true, /*bRebuildTextures=*/true);
    m_ePlotType = PLOT_LAND;
    gDLL->getEngineIFace()->RebuildPlot(getX(), getY(),
            /*bRebuildHeights=*/true, /*bRebuildTextures=*/true);
}
in a fully initialized game does nothing though, so I suppose the phony plot type needs to stick for a little while(?).
 
Top Bottom