Usable Mountains

Elucidus

King
Joined
Mar 3, 2002
Messages
983
Location
USA
So I am trying to make mountains usable. Basically giving them 3 move cost, +1 production and -1 food from the hills version of the terrain. I added some resources, for a test, Mining is allowed on the terrain, however, even though I can move there, and resources generate, food/production work fine, but the option to make a mine, never shows up. See details below and some screen shots.

Anyone know what I am missing?

I changed the following xml:
Resources: added <Row ResourceType="RESOURCE_COPPER" TerrainType="TERRAIN_DESERT_MOUNTAIN"/> for several different resources and every type of mountain. - Confirmed this is working.
Terrain: Removed impassable and changed movement cost to "3" added Defense modifier "4". and added yield values as appropriate. All of this appears to be working.
Improvements: added <Row ImprovementType="IMPROVEMENT_MINE" TerrainType="TERRAIN_GRASS_MOUNTAIN"/> for each mountain type - This is where things break down.

As it stands everything works, except for building improvements on a mountain. I can even settle on a mountain. I tried it with copper and on its own. I made sure Mining was researched and I even gave it an extra turn, just for good measure. Also made sure no other mods were loaded.

2016-11-13 (2).png 2016-11-13 (3).png

Any help would be appreciated.
 
Last edited:
Improvements: added <Row ImprovementType="IMPROVEMENT_MINE" TerrainType="TERRAIN_GRASS_MOUNTAIN"/> for each mountain type - This is where things break down.

In what table, what does the database.log say? (Improvement_ValidTerrains is the correct table)
Have you looked to see if your changes have been applied to the database if there are no errors in the log?
You ask if anyone knows what your missing, but you show no code, provide no mod for people to see if you have missed anything :crazyeye:
 
This is the code I am having issues with.
Code:
<GameInfo>
    <Improvement_ValidTerrains>
        <Row ImprovementType="IMPROVEMENT_MINE" TerrainType="TERRAIN_GRASS_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_MINE" TerrainType="TERRAIN_PLAINS_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_MINE" TerrainType="TERRAIN_DESERT_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_MINE" TerrainType="TERRAIN_TUNDRA_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_MINE" TerrainType="TERRAIN_SNOW_MOUNTAIN"/>
        <!--Unique Improvements -->
        <Row ImprovementType="IMPROVEMENT_GREAT_WALL" TerrainType="TERRAIN_DESERT_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_GREAT_WALL" TerrainType="TERRAIN_TUNDRA_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_GREAT_WALL" TerrainType="TERRAIN_PLAINS_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_GREAT_WALL" TerrainType="TERRAIN_GRASS_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_GREAT_WALL" TerrainType="TERRAIN_SNOW_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_FORT" TerrainType="TERRAIN_DESERT_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_FORT" TerrainType="TERRAIN_TUNDRA_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_FORT" TerrainType="TERRAIN_PLAINS_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_FORT" TerrainType="TERRAIN_GRASS_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_FORT" TerrainType="TERRAIN_SNOW_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_ROMAN_FORT" TerrainType="TERRAIN_DESERT_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_ROMAN_FORT" TerrainType="TERRAIN_TUNDRA_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_ROMAN_FORT" TerrainType="TERRAIN_PLAINS_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_ROMAN_FORT" TerrainType="TERRAIN_GRASS_MOUNTAIN"/>
        <Row ImprovementType="IMPROVEMENT_ROMAN_FORT" TerrainType="TERRAIN_SNOW_MOUNTAIN"/>
    </Improvement_ValidTerrains>
</GameInfo>
 
If you gave mountains 3 movement costs, how are workers able to enter? Wouldn't only scouts and cavalry be able to climb the mountains, since you'd need more than 2 base movement points?
 
So I have gotten everything else to work. But I cannot for the life of me get the improvement to be buildable.

Also a worker can walk on the mountain regardless of its movement cost. I guess the new movement rules only count for second moves. Note though that the movement options border does not highlight the mountains as an option, but you can still go there.
 
If you gave mountains 3 movement costs, how are workers able to enter? Wouldn't only scouts and cavalry be able to climb the mountains, since you'd need more than 2 base movement points?

IIRC, the movement costs are a bit weird. The first move (a unit has used 0% of his movement) will always allow you in to any tile, and deduct remaining movement points based on the cost of the tile. Move after movement points are not at 100% can not be done if the resulting remaining points are negative.
 
@Elucidus
Have you tried to manually initiate a UnitManager.RequestOperation() call to build an improvement yet? The code for that is in UnitPanel.lua, line 456 resp. 2270.
If not, can you upload the current status of the Usable Mountains mod, I might give this a shot some time.
 
Ok, so manually calling the RequestOperation() method does not work. Obviously the game somehow internally checks if there's a mountain in the plot, and doesn't perform the action.
However I was able to cheat. I'm using WorldBuilder.MapManager():SetTerrainType(plot, terrainType) to change the plot to a hill, then let the builder perform its action, and then after that change back the terrain type to a mountain - and the improvement actually remains on the changed plot. You can also directly use WorldBuilder.MapManager():SetImprovementType(plot, improvementType, owner) to set an improvement to a certain plot, however in this case the builder does not use up one of its charges. Changing the terrain type was the only way I could think of where a builder charge could be used (as I've found no way to manipulate the builder charges directly). I haven't tested this with plots containing any resources yet though.

There's also another check for the build icons, where they're checking with UnitManager.CanStartOperation() if a builder can place an improvement - and just like for RequestOperation() this returns false for mountain tiles. So you need to overwrite this variable if this is command is initiated from a unit standing on a mountain.

Unfortunately these checks make it necessary to insert code directly into the UnitPanel.lua file - something I'm really trying to avoid. Especially since I'm using the AlertGuard mod, which also directly modifies this file (the internal alert function is pretty useless). I don't think there's a way around this, but I'll tinker around a bit more.


Screenshot: the mountain has become significantly less impressive with a mine on top of it...
MineOnMountain.jpg
 
Back
Top Bottom