How to make a few changes to terrain, features and resources of a YnAMP map using XML

Gedemon

Modder
Super Moderator
Joined
Oct 4, 2004
Messages
11,622
Location
France
Note: for the examples in this thread I use the Giant Earth, the other names can be found in the corresponding map's threads or in the Map.xml file in the map's folder.


If you are a modder:


You'll need to set this in a SQL file loaded before the file setting the changes to the map (this is to make sure that your XML/SQL file won't fail to load if YnAMP is not activated)
Code:
CREATE TABLE IF NOT EXISTS ExtraPlacement
    (    MapName TEXT NOT NULL,
        X INT default 0,
        Y INT default 0,
        ConfigurationId TEXT,
        ConfigurationValue TEXT,
        Civilization TEXT,
        TerrainType TEXT,
        FeatureType TEXT,
        ResourceType TEXT,
        Quantity INT default 0);

Then see the XML example below to add the code in one of you file loaded after the one creating the table.


If you are not a modder:

See How to create custom.xml and custom.sql to make simple changes and add the XML code in the custom.xml file following the examples below.

  • Simple terrain change:
Code:
<GameInfo>
    <ExtraPlacement>  
        <Replace MapName="GiantEarth" X="21" Y="75" TerrainType="TERRAIN_GRASS" />
    </ExtraPlacement>
</GameInfo>

This one will replace the sea plot at 21,75 by grassland on the giant earth, closing the strait between Denmark and Sweden.

  • Conditional changes, depending of Civilizations:
Code:
<GameInfo>
    <ExtraPlacement>
        <!-- Around Riyadh TSL -->
        <Replace MapName="GiantEarth" X="39" Y="43" Civilization="CIVILIZATION_ARABIA"     TerrainType="TERRAIN_GRASS_HILLS" />
        <Replace MapName="GiantEarth" X="40" Y="45" Civilization="CIVILIZATION_ARABIA"     FeatureType="FEATURE_OASIS" />
        <Replace MapName="GiantEarth" X="39" Y="44" Civilization="CIVILIZATION_ARABIA"     FeatureType="FEATURE_OASIS" />
        <Replace MapName="GiantEarth" X="40" Y="43" Civilization="CIVILIZATION_ARABIA"     FeatureType="FEATURE_OASIS" />
        <Replace MapName="GiantEarth" X="39" Y="45" Civilization="CIVILIZATION_ARABIA"     ResourceType="RESOURCE_STONE" />
        <!-- Copenhaguen TSL -->
        <Replace MapName="GiantEarth" X="21" Y="75" Civilization="CIVILIZATION_DENMARK"    TerrainType="TERRAIN_GRASS" />
    </ExtraPlacement>
</GameInfo>

This one will change some terrain, feature and resource around Riyadh position if CIVILIZATION_ARABIA is in the game, and will close the strait between Denmark and Sweden if CIVILIZATION_DENMARK is in the game.

  • Conditional change, depending of setup option (advanced modding):
Code:
    <ExtraPlacement>
        <Replace MapName="GiantEarth" X="31" Y="59" ConfigurationId="ClosedBosphorus"     TerrainType="TERRAIN_GRASS_HILLS" />
        <Replace MapName="GiantEarth" X="10" Y="67" ConfigurationId="MontSaintMichel"     FeatureType="FEATURE_MARSH" />
        <Replace MapName="GiantEarth" X="10" Y="73" ConfigurationId="Stonehenge"         ResourceType="RESOURCE_STONE" />
    </ExtraPlacement>

This code change some terrains, features or resources depending of some configuration options.

You can't change configuration options using the custom.xml or custom.sql method (I may add code to allow a custom_config.xml file at some point), but you can change the Config.xml file of an existing map, the code above is linked to the following code from Config.xml in the Maps/GiantEarth folder

Code:
        <Row Key1="Map" Key2="GiantEarth.lua" ParameterId="GiantEarthBosphorus" Name="LOC_MAP_CLOSED_BOSPHORUS_NAME" Description="" Domain="bool" DefaultValue="0" ConfigurationGroup="Map" ConfigurationId="ClosedBosphorus" GroupId="MapOptions" SortIndex="1000"/>
        <Row Key1="Map" Key2="GiantEarth.lua" ParameterId="GiantEarthMontSaintMichel" Name="LOC_MAP_MONT_SAINT_MICHEL_MARSH_NAME" Description="" Domain="bool" DefaultValue="0" ConfigurationGroup="Map" ConfigurationId="MontSaintMichel" GroupId="MapOptions" SortIndex="1000"/>
        <Row Key1="Map" Key2="GiantEarth.lua" ParameterId="GiantEarthStonehenge" Name="LOC_MAP_STONEHENGE_STONE_NAME" Description="" Domain="bool" DefaultValue="0" ConfigurationGroup="Map" ConfigurationId="Stonehenge" GroupId="MapOptions" SortIndex="1000"/>

it's the "ConfigurationId" entries which link the setting and the effect on the map.


For all those changes, you can find the type names in the game's files (Terrains.xml, Features.xml and Resources.xml) in "\Steam\steamapps\common\Sid Meier's Civilization VI\Base\Assets\Gameplay\Data", in the equivalent files for DLC/scenarios or in the corresponding tables if you use a SQL manager.


Note that while you could potentially use a FeatureType entry to add a one-plot Natural Wonder on the map, I'd advise to follow the How to change or add Natural Wonders position of a YnAMP map tutorial for that, as some additional code is required for a placement overriding the game's rules.
 
Last edited:
Need only custom.xml and the good code here:
<GameInfo>
<ExtraPlacement>
<Replace MapName="GiantEarth" X="154" Y="65" ResourceType="RESOURCE_SUGAR" Quantity="2" />
<Replace MapName="GiantEarth" X="156" Y="64" ResourceType="RESOURCE_WHALES" Quantity="2" />
<Replace MapName="GiantEarth" X="157" Y="64" ResourceType="RESOURCE_CRABS" Quantity="2" />
<Replace MapName="GiantEarth" X="155" Y="64" ResourceType="RESOURCE_HORSES" Quantity="2" />
<Replace MapName="GiantEarth" X="153" Y="65" TerrainType="TERRAIN_GRASS_HILLS" />
<Replace MapName="GiantEarth" X="153" Y="65" FeatureType="FEATURE_FOREST" />
</ExtraPlacement>
</GameInfo>
 
How can I add Rivers to GiantEarth map via custom.xml/sql?
Or should I modify the MapToConvert Table in GiantEarth.lua directly?

-- MapToConvert[x][y] = {civ6TerrainType, civ6FeatureTypes, civ6ContinentType, {{IsNEOfRiver, flow}, {IsWOfRiver, flow}, {IsNWOfRiver, flow}}, {Civ6ResourceType, num}, {IsNEOfCliff, IsWOfCliff, IsNWOfCliff} }

I would like to add a few rivers near starting positions of Civs and some Canal Cities ,
e.g. X="103" Y="10" for Australia.
 
No XML abilities for that, you can modify the table directly, I don't know the values, but I think that you can directly use those in the table:
Code:
FlowDirectionTypes.FLOWDIRECTION_NORTH
FlowDirectionTypes.FLOWDIRECTION_NORTHEAST
FlowDirectionTypes.FLOWDIRECTION_SOUTHEAST
FlowDirectionTypes.FLOWDIRECTION_SOUTH
FlowDirectionTypes.FLOWDIRECTION_SOUTHWEST
FlowDirectionTypes.FLOWDIRECTION_NORTHWEST

and 1/0 for true/false at the position for the IsNEOfRiver, IsWOfRiver, ...
 
Thanks for the info.
Placing rivers works fine now.

I tried placing Coral-Reefs via ExtraPlacement and noticed that they do not feature resources unless I specify the resource, too. Is it possible that placing a feature removes the resource generated before by Map-Generator?
 
No XML abilities for that, you can modify the table directly, I don't know the values, but I think that you can directly use those in the table:
Code:
FlowDirectionTypes.FLOWDIRECTION_NORTH
FlowDirectionTypes.FLOWDIRECTION_NORTHEAST
FlowDirectionTypes.FLOWDIRECTION_SOUTHEAST
FlowDirectionTypes.FLOWDIRECTION_SOUTH
FlowDirectionTypes.FLOWDIRECTION_SOUTHWEST
FlowDirectionTypes.FLOWDIRECTION_NORTHWEST

and 1/0 for true/false at the position for the IsNEOfRiver, IsWOfRiver, ...

The Flow-Direction-Definitions for the 3 possible river segments are overcomplicated.
0-1-2 is for counter-clockwise flow.
3-4-5 is for clockwise flow.
Unless I'm missing some info, a single bit would have been sufficient to indicate the flow-direction since the segments itself are separately activated.
So far the Flow-Direction not only contains the flow direction but also the position of the river segment itself, which is a redundant information.
 
Can you add the instructions for adding goody huts to a map here? The YNaMBC/YNaMP trick to get flood plains working deletes goody huts from my map and I'd like to add them back but don't know how. Haven't been able to find the XML for it anywhere.
 
Can you add the instructions for adding goody huts to a map here? The YNaMBC/YNaMP trick to get flood plains working deletes goody huts from my map and I'd like to add them back but don't know how. Haven't been able to find the XML for it anywhere.
Thanks, your post made me realize that one of the option of the mod was broken (the scenario part of the export log that was still a W.I.P. when I stopped modding) some patches ago.

Goody huts are improvements, they should have been visible in the lua.log after pressing the export map button, but it is that part that is broken ATM (I've pushed a small fix to gitHub and I'll notify SeelingCat)

Once the fix is applied you should see something like that in the Lua.log:
Code:
InGameTopOptionsMenu: <ScenarioInfrastructure>
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="43" Y="3"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="50" Y="6"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="64" Y="7"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="44" Y="7"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="25" Y="7"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="53" Y="8"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="15" Y="9"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="45" Y="12"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="28" Y="12"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="22" Y="13"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="14" Y="15"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="45" Y="16"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="61" Y="17"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="67" Y="19"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="47" Y="19"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="11" Y="19"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="58" Y="23"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="19" Y="23"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="13" Y="23"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="69" Y="27"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="14" Y="27"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="44" Y="29"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="55" Y="31"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="12" Y="31"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="16" Y="36"        />
InGameTopOptionsMenu:     <Replace  ImprovementType="IMPROVEMENT_GOODY_HUT"  X="33" Y="38"        />
InGameTopOptionsMenu: </ScenarioInfrastructure>


then this can manually being added in the Map.xml created by the YnABMC tool (before the closing </GameData>) using this syntax (removing the InGameTopOptionsMenu: at the beginning of each lines, adding the MapName in the <Replace> tag):
Code:
 <ScenarioInfrastructure>
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="50" Y="5"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="46" Y="6"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="53" Y="7"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="14" Y="8"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="44" Y="9"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="25" Y="13"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="7" Y="13"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="64" Y="14"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="67" Y="17"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="9" Y="17"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="61" Y="20"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="22" Y="20"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="12" Y="20"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="58" Y="23"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="19" Y="23"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="11" Y="24"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="39" Y="25"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="33" Y="25"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="47" Y="27"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="39" Y="29"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="16" Y="33"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="31" Y="34"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="11" Y="34"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="55" Y="36"        />
    <Replace  MapName="YourMapName" ImprovementType="IMPROVEMENT_GOODY_HUT"  X="27" Y="39"        />
 </ScenarioInfrastructure>

They should then be placed when your map is loaded except if someone change the scenario "default" option to "none"
 
Top Bottom