Giving mountains production and resources.

Johnen

Chieftain
Joined
Jul 27, 2013
Messages
41
Mountains are by default impassible, so they can't yeld any resources (like iron) or production for that matter. I want to alter the impassible modifier to still block movement of units but at the same time stop it from blocking the generation of production and resources. How do I do that?

OR! Alternatively... perhaps it would be possible to restrict certain units to specific terrains? That way horsemen and tanks could be excluded from mountain terrain but infantry units could pass through them freely after removing Impassable="1" from all mountain types.
 
Last edited:
Or maybe it would be possible to create another DOMAIN_LAND like DOMAIN_LAND2 which excludes mountain terrains?
 
SUCCESS!!!

Here's the code I used:

UnitAbilities file:

Code:
    <Types>
       <Row Type="ABILITY_NO_GRASS_MOUNTAIN_MOVE" Kind="KIND_ABILITY"/>

Code:
    <TypeTags>
       <Row Type="ABILITY_NO_GRASS_MOUNTAIN_MOVE" Tag="CLASS_HEAVY_CAVALRY"/>

Note: Just change class type from CLASS_HEAVY_CAVALRY to any other in order to prevent other units from running up mountains which no longer have Impassable="1".

Code:
    <UnitAbilities>
       <Row UnitAbilityType="ABILITY_NO_GRASS_MOUNTAIN_MOVE" Name="LOC_ABILITY_ANTI_CAVALRY_NAME" Description="LOC_ABILITY_ANTI_CAVALRY_DESCRIPTION"/>

Note2: Name="LOC_ABILITY_ANTI_CAVALRY_NAME" Description="LOC_ABILITY_ANTI_CAVALRY_DESCRIPTION" can be changed to something more custom once you create the new name and description text.

Code:
    <UnitAbilityModifiers>
        <Row>
            <UnitAbilityType>ABILITY_NO_GRASS_MOUNTAIN_MOVE</UnitAbilityType>
            <ModifierId>NO_GRASS_MOUNTAIN_MOVE_BONUS</ModifierId>
        </Row>

Code:
    <Modifiers>
        <Row>
            <ModifierId>NO_GRASS_MOUNTAIN_MOVE_BONUS</ModifierId>
            <ModifierType>MODIFIER_PLAYER_UNITS_ADJUST_VALID_TERRAIN</ModifierType>
        </Row>

Code:
    <ModifierArguments>
        <Row>
            <ModifierId>NO_GRASS_MOUNTAIN_MOVE_BONUS</ModifierId>
            <Name>TerrainType</Name>
            <Value>TERRAIN_GRASS_MOUNTAIN</Value>
        </Row>
        <Row>
            <ModifierId>NO_GRASS_MOUNTAIN_MOVE_BONUS</ModifierId>
            <Name>Valid</Name>
            <Value>false</Value>
        </Row>

Rejoice!!!



Note: This is juts one example that works on Grass Mountains but the same can be done for all other mountain types by making the same ability type which blocks TERRAIN_SNOW_MOUNTAIN, TERRAIN_TUNDRA_MOUNTAIN, etc.
 
Last edited:
While we're on the subject of mountains...

How about making them impassible except for Helicopters and Observation Balloons? Is there a modifier/class that can be attached to the unit so they ignore all terrain?
 
While we're on the subject of mountains...

How about making them impassible except for Helicopters and Observation Balloons? Is there a modifier/class that can be attached to the unit so they ignore all terrain?

Just go in to:

Terrains:

Code:
    <Terrains>
        <Row TerrainType="TERRAIN_GRASS_MOUNTAIN" Name="LOC_TERRAIN_GRASS_MOUNTAIN_NAME" Mountain="true" MovementCost="1" InfluenceCost="3" SightModifier="2" SightThroughModifier="2" Impassable="1" Appeal="1"/>

See the Impassable="1" part? Change it to 0 and you are done for the most part, then just block the units you wanna block as I have explained above. In essence you'll just give the units the inability to pass them since Impassable="1" makes the mountains fully unusable but when set to Impassable="0" they are usable and passible by everyone unless you block it individually for several unit types.
 
Last edited:
I'm having really weird results with that. As soon as I build a unit of the class defined for the "no move" ability, all other units stop being able to move on that mountain type as well.
And if I set it to CLASS_MELEE, it doesn't work for any unit because of the starting warrior unit. I.e. the settler can't move there, and when I build a Slinger (CLASS_RANGED) he isn't able to move on top of the mountain either.
 
Last edited:
So it seems I was able to fix this by adding a RequirementSet to the modifier, which defines the units that are affected by the "no movement" ability.

I.e. like as seen below (sorry, no XML notation). The various <Modifiers> need the UNIT_MOUNTAIN_MOVEMENT_NOT_ALLOWED to be set in their <SubjectRequirementSetId> tag for this to work.
I say "various" because I also tried to merge the different mountain terrain types into one RequirementSets, with the already existing ROUGH_RIDER_HILL_TERRAIN_REQUIREMENTS RequirementSet being the model for it. But this didn't seem to work, and movement was never blocked. So currently I need one modifier for each of the mountain terrain types (of which there are 5).

Code:
-- Define the units that are not allowed to enter mountains
INSERT INTO `RequirementSets` VALUES 
('UNIT_MOUNTAIN_MOVEMENT_NOT_ALLOWED', 'REQUIREMENTSET_TEST_ALL');

INSERT INTO `RequirementSetRequirements` VALUES 
('UNIT_MOUNTAIN_MOVEMENT_NOT_ALLOWED', 'REQUIRES_LAND_DOMAIN'),                     -- Predefined
('UNIT_MOUNTAIN_MOVEMENT_NOT_ALLOWED', 'REQUIREMENT_UNIT_IS_NOT_BUILDER'),          -- See below
('UNIT_MOUNTAIN_MOVEMENT_NOT_ALLOWED', 'REQUIREMENT_UNIT_IS_NOT_HELICOPTER');       -- See below

INSERT INTO `Requirements` VALUES 
('REQUIREMENT_UNIT_IS_NOT_BUILDER',    'REQUIREMENT_UNIT_TYPE_MATCHES', 0, 1, 0),   -- 1 = Inverted
('REQUIREMENT_UNIT_IS_NOT_HELICOPTER', 'REQUIREMENT_UNIT_TYPE_MATCHES', 0, 1, 0);   -- 1 = Inverted

INSERT INTO `RequirementArguments` VALUES 
('REQUIREMENT_UNIT_IS_NOT_BUILDER',    'UnitType', 'ARGTYPE_IDENTITY', 'UNIT_BUILDER',    NULL, NULL), 
('REQUIREMENT_UNIT_IS_NOT_HELICOPTER', 'UnitType', 'ARGTYPE_IDENTITY', 'UNIT_HELICOPTER', NULL, NULL);
 
Wouldn't it be easier to just set which units CAN move over mountains instead of the ones that can't? There is the MODIFIER_PLAYER_UNITS_ADJUST_VALID_TERRAIN modifier. Is it possible to assign this modifier to units? It's not like many units would need it.
 
Wouldn't it be easier to just set which units CAN move over mountains instead of the ones that can't? There is the MODIFIER_PLAYER_UNITS_ADJUST_VALID_TERRAIN modifier. Is it possible to assign this modifier to units? It's not like many units would need it.
I'm not sure this would work for movement, as mountains have the "Impassable" property set, while ocean tiles do not (and the modifier is used to allow Norway to enter ocean tiles earlier). But even if it works this would probably make the movement issue easier, but I don't think it alone would allow you to set the tile to be worked within your city, because they still have that "Impassible" property set. So if you just want movement over mountains, this could be an option to pursue, but if you want the mountain tiles to actually add to your city production, less so.
 
I'm not sure this would work for movement, as mountains have the "Impassable" property set, while ocean tiles do not (and the modifier is used to allow Norway to enter ocean tiles earlier). But even if it works this would probably make the movement issue easier, but I don't think it alone would allow you to set the tile to be worked within your city, because they still have that "Impassible" property set. So if you just want movement over mountains, this could be an option to pursue, but if you want the mountain tiles to actually add to your city production, less so.

I, personally, am not trying to make mountains workable. I'm trying to make them passable to helicopters. I'm thinking I could just add the modifier information into the helicopter class, allowing it to ignore mountains. I'll be trying that out in the next few days.
 
You still might need to add a RequirementSet to limit this to the helicopter. The MODIFIER_PLAYER_UNITS_ADJUST_VALID_TERRAIN seems to apply to every unit, even if you apply it only to a specific class. See my previous post above where I applied it only to CLASS_MELEE, but it prevented Settlers and Slingers to go on mountains as well. It seems to be a global modifier.
 
So it seems I was able to fix this by adding a RequirementSet to the modifier, which defines the units that are affected by the "no movement" ability.

I.e. like as seen below (sorry, no XML notation). The various <Modifiers> need the UNIT_MOUNTAIN_MOVEMENT_NOT_ALLOWED to be set in their <SubjectRequirementSetId> tag for this to work.
I say "various" because I also tried to merge the different mountain terrain types into one RequirementSets, with the already existing ROUGH_RIDER_HILL_TERRAIN_REQUIREMENTS RequirementSet being the model for it. But this didn't seem to work, and movement was never blocked. So currently I need one modifier for each of the mountain terrain types (of which there are 5).

Code:
-- Define the units that are not allowed to enter mountains
INSERT INTO `RequirementSets` VALUES
('UNIT_MOUNTAIN_MOVEMENT_NOT_ALLOWED', 'REQUIREMENTSET_TEST_ALL');

INSERT INTO `RequirementSetRequirements` VALUES
('UNIT_MOUNTAIN_MOVEMENT_NOT_ALLOWED', 'REQUIRES_LAND_DOMAIN'),                     -- Predefined
('UNIT_MOUNTAIN_MOVEMENT_NOT_ALLOWED', 'REQUIREMENT_UNIT_IS_NOT_BUILDER'),          -- See below
('UNIT_MOUNTAIN_MOVEMENT_NOT_ALLOWED', 'REQUIREMENT_UNIT_IS_NOT_HELICOPTER');       -- See below

INSERT INTO `Requirements` VALUES
('REQUIREMENT_UNIT_IS_NOT_BUILDER',    'REQUIREMENT_UNIT_TYPE_MATCHES', 0, 1, 0),   -- 1 = Inverted
('REQUIREMENT_UNIT_IS_NOT_HELICOPTER', 'REQUIREMENT_UNIT_TYPE_MATCHES', 0, 1, 0);   -- 1 = Inverted

INSERT INTO `RequirementArguments` VALUES
('REQUIREMENT_UNIT_IS_NOT_BUILDER',    'UnitType', 'ARGTYPE_IDENTITY', 'UNIT_BUILDER',    NULL, NULL),
('REQUIREMENT_UNIT_IS_NOT_HELICOPTER', 'UnitType', 'ARGTYPE_IDENTITY', 'UNIT_HELICOPTER', NULL, NULL);

So... what file and where does this code go in to? I'm not a programmer, I'm just trying to figure out how to make some changes that I need.

Also... did you happen to get mines working on mountain tiles?

Edit: It seems I have noticed something very strange, have you notices that settlers can build cities on mountain tiles? Once you try settling them they turn the entire mountain in to a hill.
 
Last edited:
So... what file and where does this code go in to? I'm not a programmer, I'm just trying to figure out how to make some changes that I need.

Also... did you happen to get mines working on mountain tiles?

Edit: It seems I have noticed something very strange, have you notices that settlers can build cities on mountain tiles? Once you try settling them they turn the entire mountain in to a hill.
Yes, Settlers can build cities upon mountains if movement is not restricted for them. I didn't check if the terrain is transformed into a hill though. But the graphic certainly does change when you place a mine on it. Which I was somewhat successful with (see the other thread). But it's a UI workaround, and the AI will not be able to place any improvement on a mountain tile this way. And without DLL access this will not change.
I'm currently doing a bit of play testing with my WIP mod.

As far as the file is concerned, the SQL notation is designed to be used within a mod. You can also combine your XML notation with my SQL notation, by using yours in an .xml file and mine in an .sql one to complement it. Just don't forget to add the <SubjectRequirementSetId> tags to your unit modifiers.
 
Yes, Settlers can build cities upon mountains if movement is not restricted for them. I didn't check if the terrain is transformed into a hill though. But the graphic certainly does change when you place a mine on it. Which I was somewhat successful with (see the other thread). But it's a UI workaround, and the AI will not be able to place any improvement on a mountain tile this way. And without DLL access this will not change.
I'm currently doing a bit of play testing with my WIP mod.

As far as the file is concerned, the SQL notation is designed to be used within a mod. You can also combine your XML notation with my SQL notation, by using yours in an .xml file and mine in an .sql one to complement it. Just don't forget to add the <SubjectRequirementSetId> tags to your unit modifiers.

SQL? XML? You already lost me, I have mentioned that "I'm not a programmer". I'm just trying to make the game less nonsensical which is turning out to be quite the undertaking. I'd need to know what files to open/edit and where to write the code.
 
In your original changes above you've edited the core game UnitAbilities.xml file directly to make the necessary changes.
However this is not the best choice, as your changes will be overwritten once there's a game update (and you can't easily share your changes with anybody else). Instead, you can achieve the same results without having to modify the core game files by creating a mod, and use an UnitAbilities.xml in that mod folder with only your changed entries. And the SQL code I've posted above would go into the same folder, but into an UnitAbilities.sql file (or whatever you want to call them, the file names don't really matter for these type of changes - except for the file extensions of course).

Of course you then also need a modinfo file to tell the game which files to load in your mod. The information on how to do so is right here in this forum, and you can always download another mod to see some examples (which is what I did). But I'm afraid you'll have to wrap your head around this.
Two tips for the .modinfo file: the .xml and .sql file need to be in the <UpdateDatabase> section. And for the UUID use this site to generate one: https://www.uuidgenerator.net/
 
In your original changes above you've edited the core game UnitAbilities.xml file directly to make the necessary changes.
However this is not the best choice, as your changes will be overwritten once there's a game update (and you can't easily share your changes with anybody else). Instead, you can achieve the same results without having to modify the core game files by creating a mod, and use an UnitAbilities.xml in that mod folder with only your changed entries. And the SQL code I've posted above would go into the same folder, but into an UnitAbilities.sql file (or whatever you want to call them, the file names don't really matter for these type of changes - except for the file extensions of course).

Of course you then also need a modinfo file to tell the game which files to load in your mod. The information on how to do so is right here in this forum, and you can always download another mod to see some examples (which is what I did). But I'm afraid you'll have to wrap your head around this.
Two tips for the .modinfo file: the .xml and .sql file need to be in the <UpdateDatabase> section. And for the UUID use this site to generate one: https://www.uuidgenerator.net/

Ah! OK that explains a lot of things but what if I remade the entire tech tree and removed a bunch of useless stuff from it like astronomy and I've noticed that some of the mods I used also use the same kind of files I've been editing, so I'm guessing they wouldn't be compatible and the mods would conflict with one another?
 
Depends on the type of mod. If they replace whole files, they naturally also replace all of the changes made to an original game file. If they include only the changes made to specific files, they might be compatible or not, depending on what has been actually changed. And then there are mods that try to change the same things, which is when things get complicated, because currently the load order of the mods is somewhat undefined, and it also seems to differ between loading a saved game and starting a new one.

For example, when I try to allow improvements to be build on top of mountains, I have to replace the ProductionPanel.lua file, because I need to overwrite if enabled status of the improvement buttons. However the very excellent Production Queue mod is also replacing exactly this file, so I'll probably have to make two versions of this mod (if I release it), one for the original game, and one that builds on top of the Production Queue mod.
 
Depends on the type of mod. If they replace whole files, they naturally also replace all of the changes made to an original game file. If they include only the changes made to specific files, they might be compatible or not, depending on what has been actually changed. And then there are mods that try to change the same things, which is when things get complicated, because currently the load order of the mods is somewhat undefined, and it also seems to differ between loading a saved game and starting a new one.

For example, when I try to allow improvements to be build on top of mountains, I have to replace the ProductionPanel.lua file, because I need to overwrite if enabled status of the improvement buttons. However the very excellent Production Queue mod is also replacing exactly this file, so I'll probably have to make two versions of this mod (if I release it), one for the original game, and one that builds on top of the Production Queue mod.

Ops! Sorry I have posted the wrong message in this thread! Apologies if you've seen it, I was in a hurry.

Anyway! I have altered the entire Technologies file and completely removed some tech from the game, so if I wanted to make a mod I would have to replace the entire file with the one I have, correct? Because normally the changes I make would alter the already existing teach tree and the removal of certain technologies would never take place as they'd still exist in the original game file.... so how can I replace an entire file while making a mod?
 
Ops! Sorry I have posted the wrong message in this thread! Apologies if you've seen it, I was in a hurry.

Anyway! I have altered the entire Technologies file and completely removed some tech from the game, so if I wanted to make a mod I would have to replace the entire file with the one I have, correct? Because normally the changes I make would alter the already existing teach tree and the removal of certain technologies would never take place as they'd still exist in the original game file.... so how can I replace an entire file while making a mod?
Yeah, you can simply use the whole file and place it in your mod folder.
 
Back
Top Bottom