[GS] Placing Improvements or Routes on a YnAMP .lua format map using XML?

Mew151

Chieftain
Joined
Jun 24, 2019
Messages
31
I'm making a Middle Earth map using Zobtzler's fantastic YnABMC tool and YnAMP, and I was wondering if it's possible to pre-place Improvements and Routes using an .xml file?

The reason I'm asking is because there are some landmarks, such as Helm's Deep that I would like to place as a "Fort" Improvement upon loading the map.

I'm a noob when it comes to modding, and I tried inserting this imitation line into ExtraPlacement.xml, but it didn't do anything in-game:

Code:
<GameData><ExtraPlacement>

<Replace MapName="MyMapName" X="70" Y="34" RuleSet="RULESET_EXPANSION_2" TerrainType="TERRAIN_PLAINS_HILLS" ImprovementType="IMPROVEMENT_FORT" />

</ExtraPlacement></GameData>


An earlier version of my map uses the .Civ6Map format from WorldBuilder, and I noticed that it can pre-place Improvements and Routes, but it doesn't do TSL or City Naming (that I know of), which is why I'd rather stick with Zobtzler's .lua format, especially as most of the Improvements I want to add are just fluff (for example, since a Fort at Helm's Deep would be nestled in the White Mountains, it actually serves no strategic purpose in Civ 6, and I expect a player settling a city there to just build a Campus or Holy Site over it, but it would still be cool fluff for players to see as they explore the map!)

Thank you in advance! :)
 
Yes, YnAMP allows scenario placement on maps, but I've not documented it yet (except in the code itself)

See an example code:
Code:
<GameData>

    <ScenarioCities>
        <Replace ScenarioName="GedStalingrad" MapName="GedStalingradMap" CivilizationType="CIVILIZATION_GERMANY" CitySize="3"    CityName="Tsymlyankaya"    X="4" Y="1"    />
        <Replace ScenarioName="GedStalingrad" MapName="GedStalingradMap" CivilizationType="CIVILIZATION_RUSSIA" CitySize="1"    CityName="Kremenskaya"    X="16" Y="34"    />
    </ScenarioCities>
    
    <ScenarioUnits>
        <Replace ScenarioName="GedStalingrad" MapName="GedStalingradMap" CivilizationType="CIVILIZATION_GERMANY" UnitType="UNIT_GERMAN_INFANTRY"    Name="6.Ar VIII.A.K. 76.Infanterie-Division"    Damage="0"    X="18" Y="28"    />
        <Replace ScenarioName="GedStalingrad" MapName="GedStalingradMap" CivilizationType="CIVILIZATION_RUSSIA" UnitType="UNIT_BOMBER_IL2"    Name="4th Bomber Aviation Division"    Damage="0"    X="37" Y="26"    />
    </ScenarioUnits>
    
    <ScenarioInfrastructure>
        <Replace ScenarioName="GedStalingrad" MapName="GedStalingradMap"  RouteType="0" X="4" Y="0"        />
        <Replace ScenarioName="GedStalingrad" MapName="GedStalingradMap"  RouteType="1" X="12" Y="1"        />
        <Replace ScenarioName="GedStalingrad" MapName="GedStalingradMap" ImprovementType="IMPROVEMENT_FARM"  X="4" Y="11"        />
    </ScenarioInfrastructure>
    
    <ScenarioTerritory>
        <Replace ScenarioName="GedStalingrad" MapName="GedStalingradMap" CivilizationType="CIVILIZATION_GERMANY" X="0" Y="0"        />
        <Replace ScenarioName="GedStalingrad" MapName="GedStalingradMap" CivilizationType="CIVILIZATION_RUSSIA" X="47" Y="19"        />
    </ScenarioTerritory>
    
</GameData>

Note that <ScenarioName> is optional, but if you want to use it, you'll have to setup a scenario in a config file under <DomainValues> (this allows to select a blank map or one with the scenario infrastructure from the advanced setup screen)
Code:
    <DomainValues>
        
        <Replace Domain="GedStalingradScenario" Value="GedStalingrad"     Name="LOC_STALINGRAD_MAP_NAME"         Description="LOC_STALINGRAD_MAP_DESC"                 SortIndex="30"/>
        
    </DomainValues>

If you don't use it, and just have every line like that
Code:
    <ScenarioInfrastructure>
        <Replace MapName="GedStalingradMap"  RouteType="0" X="4" Y="0"        />
        <Replace MapName="GedStalingradMap"  RouteType="1" X="12" Y="1"        />
        <Replace MapName="GedStalingradMap" ImprovementType="IMPROVEMENT_FARM"  X="4" Y="11"        />
    </ScenarioInfrastructure>
then the infrastructure is always placed on that map.
 
Thank you, Gedemon! This is super helpful! I didn't even think about different Scenarios originally, although I'm glad you included example code for it! My original intent with the release of Gathering Storm was to make a Middle-Earth map that has both the Third Age lands combined with Beleriand (a continent formerly west of Middle-Earth that sank below the sea at the end of the First Age) and have Beleriand submerge at the first sea level rise. I didn't even consider changing anything else to be different from normal Civilization. But now I'm getting ideas for different scenarios options based on the time period in Middle-Earth.

For now, I'm going to play around with the ability to add infrastructure, as it helps to really flesh out many of the landmarks in Middle-Earth! Cheers!
 
Last edited:
Let me know if you have issues with it.
 
Placing units works like a charm, though unit name and damage don't work for me. Because my intent with the map is to have more of a sandbox experience akin to the normal Civ 6 gameplay except in Middle-Earth as opposed to a "Middle-Earth simulator" where everything is pre-placed (though this might come later in a Scenario!), unit name and damage aren't actual issues for me, and just things I noticed while testing the xml code.

Unfortunately, I have not been able to get the placement of cities, infrastructure, and territory to work.

I just added these lines at the bottom of Maps/ExtraPlacement.xml, and this is what my ExtraPlacement.xml looks like (I purposefully only included one line in each category to reduce clutter.)

Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
<ExtraPlacement>
        <Replace MapName="Mew_MiddleEarth_Map" X="88" Y="68" RuleSet="RULESET_EXPANSION_2" TerrainType="TERRAIN_PLAINS_MOUNTAIN" FeatureType="FEATURE_VOLCANO" />
</ExtraPlacement>

<ScenarioCities>
    <Replace MapName="Mew_MiddleEarth_Map" CivilizationType="CIVILIZATION_AZTEC" CitySize="1"    CityName="Barad-dur"    X="96" Y="29"    />
</ScenarioCities>

<ScenarioUnits>
    <Replace MapName="Mew_MiddleEarth_Map" CivilizationType="CIVILIZATION_AZTEC" UnitType="UNIT_AZTEC_EAGLE_WARRIOR" Name="test" Damage="99" X="95" Y="27"    />
</ScenarioUnits>

<ScenarioInfrastructure>
    <Replace MapName="Mew_MiddleEarth_Map" ImprovementType="IMPROVEMENT_FORT"  X="69" Y="34" />
</ScenarioInfrastructure>

<ScenarioTerritory>
    <Replace MapName="Mew_MiddleEarth_Map" CivilizationType="CIVILIZATION_AZTEC" X="94" Y="28"  />
</ScenarioTerritory>
</GameData>

Aside from this, I haven't made any other changes to the files outside of what's automatically generated from Zobtzler's tool (with the exception of ordinary TSL and CityName stuff in Maps/Map.xml and Maps/MapText.xml). However, because the placement of all of these things work fine with the YnAMP generated scenarios, it makes me think it may be an issue with my mod files?
 
Absolutely! I really appreciate your willingness to help me with this! Here's my lua.log (I renamed it lua.log.txt so that the extension is valid for uploading.)

Also, if it makes it any easier for you to troubleshoot, I could also upload the folder for my mod.
 

Attachments

Ho, yes, I forgot that not everything can be set from the setup screen, you may need to manually add a few lines in your Config.xml file in the config folder of your mod, before the </Parameters> tag, something like that:

Code:
        <Replace Key1="Map" Key2="GedStalingradMap.lua"     ParameterId="GedStalingradCityPlacement"             Name="CityPlacement"                 Domain="text"                     Visible="0"            DefaultValue="PLACEMENT_IMPORT" ConfigurationGroup="Map" ConfigurationId="CityPlacement"             GroupId="MapOptions" SortIndex="10000"/>
        <Replace Key1="Map" Key2="GedStalingradMap.lua"     ParameterId="GedStalingradBorderPlacement"             Name="BorderPlacement"                 Domain="text"                     Visible="0"            DefaultValue="PLACEMENT_IMPORT" ConfigurationGroup="Map" ConfigurationId="BorderPlacement"             GroupId="MapOptions" SortIndex="10000"/>
        <Replace Key1="Map" Key2="GedStalingradMap.lua"     ParameterId="GedStalingradInfrastructurePlacement"     Name="InfrastructurePlacement"         Domain="text"                     Visible="0"            DefaultValue="PLACEMENT_IMPORT" ConfigurationGroup="Map" ConfigurationId="InfrastructurePlacement"     GroupId="MapOptions" SortIndex="10000"/>

The framework is still a W.I.P., but I'd really like to expand it to support custom scenarios like yours, so I'm happy to help.

In the code above, you need to change the <key2> tags to be your map name and <parameterID> so that they are unique (don't use ParameterId="CityPlacement" for example, as this is used for YnAMP base scenario setting), <name> and <SortIndex> (and maybe <GroupId>) are not important here as the <Visible="0"> tag make those config entries invisible, and everything else must stay identical (<Domain>, <DefaultValue>, <ConfigurationGroup>, <ConfigurationId>)

And I'll have to look at the code as I don't remember exactly, but it's possible that setting unit's names and damage are not implemented in the placement code yet.
 
Last edited:
No worries about the Unit names and damage! Those aren't features I'm planning on using, but just things I noticed while testing.

However, I think I may be doing something really wrong with the Config.xml file. After adding in the example code into Config/Config.xml, the Unit placement stopped working, while Improvements, Cities, and Borders still don't show up. What's also weird is that for some reason, Enforce TSL stops working too (it doesn't even show up in the "Advanced Setup" screen anymore) even though these three lines are all I've added. My Config.xml looks like this:

Code:
<?xml version="1.0" encoding="utf-8"?>
<GameInfo>
    <Maps>
        <Row Domain="Maps:Expansion2Maps" File="Mew_MiddleEarth_Map.lua" Name="LOC_Mew_MiddleEarth_Map_NAME" Description="LOC_Mew_MiddleEarth_Map_DESC" SortIndex="50"/>
    </Maps>
    <Parameters>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="RiversPlacement" Name="LOC_MAP_RIVERS_PLACEMENT_NAME" Description="LOC_MAP_RIVERS_PLACEMENT_DESCRIPTION" Domain="RiversPlacement" DefaultValue="PLACEMENT_IMPORT" ConfigurationGroup="Map"    ConfigurationId="RiversPlacement"    GroupId="MapOptions" Visible="0" SortIndex="231"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="ContinentsPlacement" Name="LOC_MAP_CONTINENT_PLACEMENT_NAME" Description="LOC_MAP_CONTINENT_PLACEMENT_DESCRIPTION" Domain="ContinentsPlacement" DefaultValue="PLACEMENT_IMPORT" ConfigurationGroup="Map"    ConfigurationId="ContinentsPlacement"    GroupId="MapOptions" Visible="0" SortIndex="232"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="NaturalWondersPlacement" Name="LOC_MAP_NATURAL_WONDERS_PLACEMENT_NAME" Description="LOC_MAP_NATURAL_WONDERS_PLACEMENT_DESCRIPTION" Domain="NaturalWondersPlacement" DefaultValue="PLACEMENT_IMPORT" ConfigurationGroup="Map"    ConfigurationId="NaturalWondersPlacement"    GroupId="MapOptions" Hash="0" Visible="0" SortIndex="244"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="FeaturesPlacement" Name="LOC_MAP_FEATURES_PLACEMENT_NAME" Description="LOC_MAP_FEATURES_PLACEMENT_DESCRIPTION" Domain="FeaturesPlacement" DefaultValue="PLACEMENT_IMPORT" ConfigurationGroup="Map"    ConfigurationId="FeaturesPlacement"    GroupId="MapOptions" Hash="0" Visible="0" SortIndex="245"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="Rainfall" Name="LOC_MAP_RAINFALL_NAME" Description="LOC_MAP_RAINFALL_DESCRIPTION" Domain="Rainfall" DefaultValue="2" ConfigurationGroup="Map"    ConfigurationId="rainfall"    GroupId="MapOptions" Hash="0" SortIndex="250"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="ResourcesPlacement" Name="LOC_MAP_RESOURCES_PLACEMENT_NAME" Description="LOC_MAP_RESOURCES_PLACEMENT_DESCRIPTION" Domain="ResourcesPlacement" DefaultValue="PLACEMENT_DEFAULT" ConfigurationGroup="Map"    ConfigurationId="ResourcesPlacement"    GroupId="MapOptions" Hash="0" Visible="0" SortIndex="269"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="Resources" Name="LOC_MAP_RESOURCES_NAME" Description="LOC_MAP_RESOURCES_DESCRIPTION" Domain="Resources" DefaultValue="2" ConfigurationGroup="Map"    ConfigurationId="resources"    GroupId="MapOptions" Hash="0" SortIndex="270"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="StartPosition" Name="LOC_MAP_START_POSITION_NAME" Description="LOC_MAP_START_POSITION_DESCRIPTION" Domain="StartPosition" DefaultValue="2" ConfigurationGroup="Map"    ConfigurationId="start"    GroupId="MapOptions" Hash="0" SortIndex="280"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="CivilizationPlacement" Name="LOC_MAP_CIVILIZATION_PLACEMENT_NAME" Description="LOC_MAP_CIVILIZATION_PLACEMENT_DESCRIPTION" Domain="CivilizationPlacement" DefaultValue="PLACEMENT_TSL" ConfigurationGroup="Map"    ConfigurationId="CivilizationPlacement"    GroupId="MapOptions" Hash="0" SortIndex="280"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="ForceTSL" Name="LOC_MAP_FORCE_TSL_NAME" Description="LOC_MAP_FORCE_TSL_DESCRIPTION" Domain="ForceTSL" DefaultValue="FORCE_TSL_AI" ConfigurationGroup="Map"    ConfigurationId="ForceTSL"    GroupId="MapOptions" Hash="0" SortIndex="281"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="StartPosition" Name="LOC_MAP_START_POSITION_NAME" Description="LOC_MAP_START_POSITION_DESCRIPTION" Domain="StartPosition" DefaultValue="2" ConfigurationGroup="Map"    ConfigurationId="start"    GroupId="MapOptions" Hash="0" SortIndex="285"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="AutoCityNaming" Name="LOC_MAP_AUTO_CITY_NAMING_NAME" Description="" Domain="bool" DefaultValue="1" ConfigurationGroup="Map" ConfigurationId="AutoCityNaming" GroupId="MapOptions" Visible="1" SortIndex="2000"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="Mew_MiddleEarth_MapSize" Name="LOC_MAP_SIZE" Description="" Domain="StandardMapSizes" DefaultValue="MAPSIZE_ENORMOUS" ConfigurationGroup="Map" ConfigurationId="MAP_SIZE" GroupId="MapOptions" Hash="1" Visible="0" SortIndex="225"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="HideSize" Name="HideSize" Description="" Domain="bool" DefaultValue="1" ConfigurationGroup="Map" ConfigurationId="HideSize" GroupId="MapOptions" Visible="0" SortIndex="2010"/>
        <Row Key1="Map" Key2="Mew_MiddleEarth_Map.lua" ParameterId="Mew_MiddleEarth_MapName" Name="MapName" Description="" Domain="text" DefaultValue="Mew_MiddleEarth_Map" ConfigurationGroup="Map" ConfigurationId="MapName" GroupId="MapOptions" Visible="0" SortIndex="2010"/>

            <Replace Key1="Map" Key2="Mew_MiddleEarth_Map.lua"     ParameterId="Mew_MiddleEarth_CityPlacement"             Name="CityPlacement"                 Domain="text"                     Visible="0"            DefaultValue="PLACEMENT_IMPORT" ConfigurationGroup="Map" ConfigurationId="CityPlacement"             GroupId="MapOptions" SortIndex="10000"/>
            <Replace Key1="Map" Key2="Mew_MiddleEarth_Map.lua"     ParameterId="Mew_MiddleEarth_BorderPlacement"             Name="BorderPlacement"                 Domain="text"                     Visible="0"            DefaultValue="PLACEMENT_IMPORT" ConfigurationGroup="Map" ConfigurationId="BorderPlacement"             GroupId="MapOptions" SortIndex="10000"/>
            <Replace Key1="Map" Key2="Mew_MiddleEarth_Map.lua"     ParameterId="Mew_MiddleEarth_InfrastructurePlacement"     Name="InfrastructurePlacement"         Domain="text"                     Visible="0"            DefaultValue="PLACEMENT_IMPORT" ConfigurationGroup="Map" ConfigurationId="InfrastructurePlacement"     GroupId="MapOptions" SortIndex="10000"/>

        </Parameters>
    <MapSupportedValues>
        <Row Map = "Mew_MiddleEarth_Map.lua" Domain = "RiversPlacement" Value = "PLACEMENT_IMPORT" />
        <Row Map = "Mew_MiddleEarth_Map.lua" Domain = "ContinentsPlacement" Value = "PLACEMENT_IMPORT" />
        <Row Map = "Mew_MiddleEarth_Map.lua" Domain = "NaturalWondersPlacement" Value = "PLACEMENT_IMPORT" />
        <Row Map = "Mew_MiddleEarth_Map.lua" Domain = "FeaturesPlacement" Value = "PLACEMENT_IMPORT" />
        <Row Map = "Mew_MiddleEarth_Map.lua" Domain = "ResourcesPlacement" Value = "PLACEMENT_DEFAULT" />
    </MapSupportedValues>
</GameInfo>

I've attached the lua.log file in case it's useful.
 

Attachments

Could you please attach the mod?

Something is not triggering, and I think it's in my code, I need to run some tests.
 
Back
Top Bottom