How to add and change TSL for a YnAMP map

Discussion in 'Tutorials and Settings' started by Gedemon, Aug 12, 2017.

  1. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    10,635
    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 TSL (this is to make sure that your XML/SQL file won't fail to load if YnAMP is not loaded)
    Code:
    CREATE TABLE IF NOT EXISTS StartPosition
        (    MapName TEXT NOT NULL,
            Civilization TEXT,
            Leader TEXT,
            DisabledByCivilization TEXT,
            DisabledByLeader TEXT,
            AlternateStart INT default 0,    
            X INT default 0,
            Y 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 code for the TSL of the civilization you want to add in the custom.xml file, like for example:
    Code:
    <GameInfo>
       <StartPosition>
          <Replace MapName="GiantEarth" Civilization="CIVILIZATION_CANADA" X="50" Y="50" />
          <Replace MapName="GiantEarth" Civilization="CIVILIZATION_MONGOLIA" X="50" Y="50" />
        </StartPosition>
    </GameInfo>
    
    of course you have to change X="50" Y="50" to the coordinate of the starting position you want to use (see How to find the X, Y values of a plot in game), and you must check what name was given to each civilization by the mods author, the CIVILIZATION_CANADA and CIVILIZATION_MONGOLIA I put here are just guess.



    Advanced rules for TSL:

    There is 2 options available in the advanced setup screen when selecting "True Start Location" for Civilization placement:
    - Use Leaders TSL when available
    - Use Alternate TSL if required and available

    And here is an exemple of use in the Map.xml with Egypt and Arabia on the Greatest Earth Map:
    Code:
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_ARABIA"        X="64" Y="33" />
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_ARABIA"        X="58" Y="35" Leader="LEADER_SALADIN" DisabledByCivilization="CIVILIZATION_EGYPT" />
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_ARABIA"        X="64" Y="33" Leader="LEADER_SALADIN" AlternateStart="1" />
    
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_EGYPT"        X="58" Y="35" DisabledByLeader="LEADER_SALADIN" />
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_EGYPT"        X="60" Y="30" AlternateStart="1" />
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_EGYPT"        X="57" Y="36" Leader="LEADER_CLEOPATRA" DisabledByLeader="LEADER_SALADIN" />
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_EGYPT"        X="60" Y="30" Leader="LEADER_CLEOPATRA" AlternateStart="1" />
    Here is how it should work:

    - the lines containing Leader="LEADER_XXXXX" will be ignored if the Use Leaders TSL when available option is not checked.

    - the lines containing AlternateStart="1" will be ignored if the Use Alternate TSL if required and available option is not checked.

    - if the Use Leaders TSL when available option is checked, any leader that is referenced for a TSL using "Leader=" will never use a generic TSL for its Civilization. For example with the code above, Cleopatra will never spawn at (58,35) if the option is checked.

    - if the Use Alternate TSL if required and available option is checked then the lines with AlternateStart="1" will be used if the default TSL (defined by the lines without AlternateStart="1") is not available for any reason.

    - there should be only one "default" TSL for a Civilization alone or a Civilization/Leader, but you can use as many lines with AlternateStart="1"

    There can be 3 reasons to make a TSL unavailable:
    - There is another TSL already set under the minimal separation distance for cities (the placement order is defined by the Civilization order on the advanced setup screen, the human player - or host in multi - is always placed first)
    - The Civilization referenced in the tag DisabledByCivilization is in game
    - The Leader referenced in the tag DisabledByLeader is in game

    If the mod can't found a suitable alternate TSL (or if the option is not used), the default TSL will be used.


    Examples:

    1/ If Cleopatra is in game but not Saladin, her TSL will be Alexandria at 57,36 if Use Leaders TSL is checked, and Cairo at 58,35 (default TSL for Egypt) if that option is disabled

    2/ If Saladin is in game but not Cleopatra, his TSL will be Cairo at 58,35 if Use Leaders TSL is checked, and Mecca at 64,33 (default TSL for Arabia) if that option is disabled

    3/ If Cleopatra and Saladin are in game and Use Leaders TSL is checked, then Cleopatra's TSL will be Thebes at 60,30 (Alternate TSL for Cleopatra) because of the DisabledByLeader="LEADER_SALADIN" in her default TSL line, and Saladin will also use his alternate TSL at 64,33 (which is coincidentally the default TSL for Arabia, but we can set it at another position than Mecca) because Egypt is in the game (even if it was an alternate leader than Cleopatra)

    Now if we change the XML a bit to this:
    Code:
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_ARABIA"        X="64" Y="33" />
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_ARABIA"        X="58" Y="35" Leader="LEADER_SALADIN" />
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_ARABIA"        X="64" Y="33" Leader="LEADER_SALADIN" AlternateStart="1" />
    
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_EGYPT"        X="58" Y="35" DisabledByLeader="LEADER_SALADIN" />
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_EGYPT"        X="60" Y="30" AlternateStart="1" />
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_EGYPT"        X="57" Y="36" Leader="LEADER_CLEOPATRA" DisabledByLeader="LEADER_SALADIN" />
            <Replace MapName="GreatestEarthMap" Civilization="CIVILIZATION_EGYPT"        X="60" Y="30" Leader="LEADER_CLEOPATRA" AlternateStart="1" />
    1/ and 2/ won't change but in 3/ Saladin's TSL would be Cairo (and Cleopatra's would be Thebes)

    If we remove all DisabledByLeader and DisabledByCivilization references, then the setup screen order would define who will be in the Nile's delta in case 3/, the last selected leader would use it's alternate TSL

    If Use Leaders TSL was activated but not Use Alternate TSL, then 3/ would result in Cleopatra at Alexandria and Saladin at Cairo.
     
    Last edited: Aug 12, 2017
    Benualdo and Clubber Lang like this.
  2. thecrazyscot

    thecrazyscot Spiffy

    Joined:
    Dec 27, 2012
    Messages:
    2,455
    Question regarding adding city-states: I have a mod adding multiple city-states which would all be within a few tiles of each other in a TSL situation (ancient Burmese cities). When adding TSL support, do I need to have them disable each other? If so, how would I go about disabling 3 other city-states? Just have duplicate entries like so?
    Code:
    INSERT INTO StartPosition (MapName, Civilization, DisabledByCivilization, X, Y)
        VALUES
            ('GreatestEarthMap', 'TCS_CIVILIZATION_SRI_KSETRA', 'TCS_CIVILIZATION_BEIKTHANO', 82, 38),
            ('GreatestEarthMap', 'TCS_CIVILIZATION_SRI_KSETRA', 'TCS_CIVILIZATION_HALIN', 82, 38),
            ('GreatestEarthMap', 'TCS_CIVILIZATION_SRI_KSETRA', 'TCS_CIVILIZATION_MAINGMAW', 82, 38);
     
  3. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    10,635
    Location:
    France
    Yes, let me know if it doesn't works as intended.
     
  4. Fantasieprodukt

    Fantasieprodukt Chieftain

    Joined:
    Dec 27, 2020
    Messages:
    23
    Dear Gedemon, is there any option to create custom random rules for civilization / leaders ban in the Giant Earth? To unknot lil bit the crowded South East Europe area I wish to put my own rule for custom leader/civ ban. I want to do this: The random select should select only one civilization of Byzanz, Macdonia and Greece; i.e., if e.g. Greece is selected, Macedonia and Byzanz are excluded/banned.
    e.g.
    <MapName="GiantEarth" Civilization="CIVILIZATION_GREECE" DisabledByCivilization="CIVILIZATION_MACEDON" />
    <MapName="GiantEarth" Civilization="CIVILIZATION_GREECE" DisabledByCivilization="CIVILIZATION_BYZANTIUM" />
    (and then doing the same for Macdonia and Byzanz vice versa)

    I know my suggested XML commands can't work it's just an exampe to illustrate my idea. What exactly would be the right XML commands and in which file this must be done? Can I do this in the custom.xml?
     
  5. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    10,635
    Location:
    France
    that would have to be scripted, XML is just a way to organize data, the way civs are actually placed based on the data is handled in AssignStartingPlots.lua for TSL

    your idea could be implemented in the AdvancedSetuScreen.lua, but would also require some code to handle the data table.

    the game's config setup rules are quite complex, and powerful, in fact there may be a way to do that without script, using only SQL requests and config entries, but that's beyond my understanding of that part's of the game's code.
     
  6. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    10,635
    Location:
    France
    just realized almost 4 years later that my code won't handle that as I supposed it should...
     
  7. supez38

    supez38 Chieftain

    Joined:
    Oct 19, 2021
    Messages:
    3
    Gender:
    Male
    Is there a way to change the default city name if starting in Alternate Location? For example, I'm using Leugi's Israel Mod and moved Phoenicia's TSL to Carthage but Dido's default capital name remains Tyre. If I have both Egypt and Arabia in the game, Arabia's default city is in Mecca but has the name Cairo. I'm using the Huge Earth map.
     
  8. Wolfdog

    Wolfdog Unit Butcher

    Joined:
    Jun 29, 2012
    Messages:
    660
    Location:
    Australia
    UPDATE CivilizationLeaders SET CapitalName = 'LOC_CITY_NAME_CARTHAGE' WHERE CivilizationType = 'CIVILIZATION_PHOENICIA';
     

Share This Page