1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

[R&F] Current era and dark/golden ages score requirements

Discussion in 'Mod Creation Help' started by Crusader2010, Feb 12, 2018.

  1. Crusader2010

    Crusader2010 Chieftain

    Joined:
    Aug 17, 2014
    Messages:
    61
    Hello,

    I'm trying to alter the mod 8AgesOfPace to suit my needs in terms of progression and would really like some help with some issues:

    1. Where can I find the current era that the game reached? I mean the SQL table.

    2. In what table can I find the speed of the current game? (i.e. Marathon, Epic, etc)

    3. The values for GOLDEN_AGE_SCORE_BASE_THRESHOLD (24) and DARK_AGE_SCORE_BASE_THRESHOLD (12) are in any way influenced by the chosen speed of the game? These can be found in the GlobalParameters table. Also, am I correct when saying that these thresholds keep on doubling for each era that passes (i.e. 12/24 for Ancient, 24/48 for Classical, and so on)?

    4. It seems that if I update the table Eras_XP1 to increase GameEraMaximumTurns, the multiplier doesn't get applied. Does anyone know why this happens (i'm trying to go around this issue with question number 2) ? Here's the simple code that I'm trying to execute:

    Code:
    UPDATE Eras_XP1
    SET GameEraMaximumTurns = GameEraMaximumTurns * 3,
            GameEraMinimumTurns = GameEraMinimumTurns * 3
    
    Thanks.
     
    Last edited: Feb 12, 2018
  2. Ulixes

    Ulixes Prince

    Joined:
    May 2, 2010
    Messages:
    307
    (1) I don't understand the question, there is no "reached era" table in the database. The SQL database contains only game settings, not game progress.

    (2) GameSpeeds.xml

    (3) not really sure

    (4) I think the code is wrong.

    it should be written this way.
    Code:
    UPDATE Eras_XP1 SET GameEraMinimumTurns * 3, GameEraMaximumTurns * 3 WHERE EraType = 'ERA_ANCIENT';
    
    Do the same for all other EraType (classical, medieval...), especially if you want to set different values for different eras.

    You are altering a database, it's not enough to write what you want to change, you also have to specify WHERE you want to change it.

    Anyway, once you test it, could you post your results here?

    I'd like to know too if it works as intended.
     
    Last edited: Feb 13, 2018
  3. Crusader2010

    Crusader2010 Chieftain

    Joined:
    Aug 17, 2014
    Messages:
    61
    Hi,

    1. Let me rephrase the question:

    - how can I find out the current era to use it in XML and/or SQL?
    - I found some piece of code that (I think) does this, but it's in LUA:

    Code:
    local pGameEras:table = Game.GetEras();
        local currentEraIndex:number = pGameEras:GetCurrentEra();
        local currentEraDef:table = GameInfo.Eras[currentEraIndex];
    
    4. My actual code is below (towards the end).
    I've tested the code in an SQL SERVER environment and it works properly. It seems that updating GameEraMaximumTurns simply has no effect (everything else works properly), or the update just doesn't happen :confused::confused:. Also, I've checked that on standard speed I have the default values - 40 and 60 (so the update simply doesn't happen or the text is not shown).

    Could it be an issue with the text shown in the game panel (upper right corner of the golden/dark age screen, where it says "120-180 turns or something). Going to try a quick game and see if the values hold true.
    I've looked in EraProgressPanel.xml and it doesn't seem to be anything wrong. The corresponding LUA file has a section regarding this. The only two methods that seem to matter are GetCurrentEraMaximumEndTurn and GetCurrentEraMinimumEndTurn (I don't see anything wrong with this either):

    Code:
    local nextEraCountdown = pGameEras:GetNextEraCountdown() + 1; -- 0 turns remaining is the last turn, shift by 1 to make sense to non-programmers
        if nextEraCountdown > 0 then
            -- If the era countdown has started only show that number
            m_EraData.NextEraMinTurn = nextEraCountdown;
            m_EraData.NextEraMaxTurn = nextEraCountdown;
        else
            local inactiveCountdownLength = GlobalParameters.NEXT_ERA_TURN_COUNTDOWN; -- Even though the countdown has not started yet, account for it in our time estimates
            m_EraData.NextEraMinTurn = pGameEras:GetCurrentEraMinimumEndTurn() - currentTurn;
            if (m_EraData.NextEraMinTurn < inactiveCountdownLength) then
                m_EraData.NextEraMinTurn = inactiveCountdownLength;
            end
            m_EraData.NextEraMaxTurn = pGameEras:GetCurrentEraMaximumEndTurn() - currentTurn;
            if (m_EraData.NextEraMaxTurn < 0) then
                m_EraData.NextEraMaxTurn = 0;
            end
        end
    When altering a database, if I don't specify where the change occurs, it should happen everywhere that fits the conditions. At least that's how T-SQL works (is there some limitation to SQLITE that I don't know about?).
    Going to try with some fixed values and post the results here.

    Code:
    CREATE TABLE TimeXFactor
    (
        ID INT NOT NULL,
        EraType TEXT NOT NULL,
        Factor INT DEFAULT 1
    );
    
    INSERT INTO TimeXFactor(ID, EraType, Factor)
    VALUES    (1, "ERA_ANCIENT", 10),
            (2, "ERA_CLASSICAL", 10),
            (3, "ERA_MEDIEVAL", 10),
            (4, "ERA_RENAISSANCE", 10),
            (5, "ERA_INDUSTRIAL", 10),
            (6, "ERA_MODERN", 10),
            (7, "ERA_ATOMIC", 10),
            (8, "ERA_INFORMATION", 10);
    
    CREATE TABLE EraIncreases
    (
        EraType TEXT NOT NULL,
        IncreaseMinTurns INT DEFAULT 0,
        IncreaseMaxTurns INT DEFAULT 0,
    );
    
    INSERT INTO EraIncreases (EraType)
    VALUES    ("ERA_ANCIENT"),
            ("ERA_CLASSICAL"),
            ("ERA_MEDIEVAL"),
            ("ERA_RENAISSANCE"),
            ("ERA_INDUSTRIAL"),
            ("ERA_MODERN"),
            ("ERA_ATOMIC");
    
    WITH cte AS
    (
        SELECT EI.EraType AS EraType, TX.Factor AS Factor
        FROM EraIncreases AS EI
        INNER JOIN TimeXFactor AS TX ON EI.EraType = TX.EraType
    )
    UPDATE EraIncreases
    SET IncreaseMinTurns = 20 * (SELECT Factor FROM cte WHERE cte.EraType = EraIncreases.EraType LIMIT 1),
        IncreaseMaxTurns = 20 * (SELECT Factor FROM cte WHERE cte.EraType = EraIncreases.EraType LIMIT 1)
    WHERE EXISTS (SELECT 1 FROM cte WHERE cte.EraType = EraIncreases.EraType LIMIT 1);
    
    UPDATE Eras_XP1
    SET GameEraMinimumTurns = GameEraMinimumTurns * (1 + ROUND((SELECT IncreaseMinTurns FROM EraIncreases WHERE EraType = Eras_XP1.EraType LIMIT 1)/100))
    WHERE EXISTS (SELECT 1 FROM EraIncreases WHERE EraType = Eras_XP1.EraType LIMIT 1)
    
    UPDATE Eras_XP1
    SET GameEraMaximumTurns = GameEraMaximumTurns * (1 + ROUND((SELECT IncreaseMaxTurns FROM EraIncreases WHERE EraType = Eras_XP1.EraType LIMIT 1)/100))
    WHERE EXISTS (SELECT 1 FROM EraIncreases WHERE EraType = Eras_XP1.EraType LIMIT 1)
    
     
  4. Ulixes

    Ulixes Prince

    Joined:
    May 2, 2010
    Messages:
    307
    If you want to apply your modifications to a specific era the database allow you to do so, you don't have to find it.

    Here, I just tried this code on my own mod and it works as intended:

    Code:
    UPDATE Eras_XP1 SET GameEraMinimumTurns = 40, GameEraMaximumTurns = 160 WHERE EraType = 'ERA_ANCIENT';
    UPDATE Eras_XP1 SET GameEraMinimumTurns = 40, GameEraMaximumTurns = 160 WHERE EraType = 'ERA_CLASSICAL';
    UPDATE Eras_XP1 SET GameEraMinimumTurns = 40, GameEraMaximumTurns = 160 WHERE EraType = 'ERA_MEDIEVAL';
    UPDATE Eras_XP1 SET GameEraMinimumTurns = 40, GameEraMaximumTurns = 160 WHERE EraType = 'ERA_RENAISSANCE';
    UPDATE Eras_XP1 SET GameEraMinimumTurns = 40, GameEraMaximumTurns = 160 WHERE EraType = 'ERA_INDUSTRIAL';
    UPDATE Eras_XP1 SET GameEraMinimumTurns = 40, GameEraMaximumTurns = 160 WHERE EraType = 'ERA_MODERN';
    UPDATE Eras_XP1 SET GameEraMinimumTurns = 40, GameEraMaximumTurns = 160 WHERE EraType = 'ERA_ATOMIC';
    Since I doubled the maximum extension of each age, I also tweaked those other values accordingly:

    Code:
    UPDATE GlobalParameters SET Value = 24 WHERE Name ='DARK_AGE_SCORE_BASE_THRESHOLD';    --DEFAULT 12
    
    UPDATE GlobalParameters SET Value = 48 WHERE Name ='GOLDEN_AGE_SCORE_BASE_THRESHOLD';    --DEFAULT 24
    
    UPDATE GlobalParameters SET Value = -10 WHERE Name ='THRESHOLD_SHIFT_PER_PAST_DARK_AGE';    --DEFAULT -5
    
    UPDATE GlobalParameters SET Value = 10 WHERE Name ='THRESHOLD_SHIFT_PER_PAST_GOLDEN_AGE';    --DEFAULT 5
    
    UPDATE GlobalParameters SET Value = 2 WHERE Name ='THRESHOLD_SHIFT_PER_CITY';    --DEFAULT 1
    As for the SQL in general, you seem well acquainted with it (maybe more than me).
    The simple logic would prove you right, in theory, but I still wouldn't modify a data without specifying the location in a database I don't know (not fully, at least).

    How do you know there isn't a tag with the same name in another table (risking to make unintentional modifications) ?

    Anyway, I'm not even sure the system is designed to accept a modification without specifying the relative table.
     
    Last edited: Feb 13, 2018
    Anvari likes this.
  5. Crusader2010

    Crusader2010 Chieftain

    Joined:
    Aug 17, 2014
    Messages:
    61
    Thanks for the reply! Allow me to answer every point:

    1.
    Unfortunately that is not what I am looking for. Look at the code I posted above, the TimeXFactor table specifically. Now consider the following code:

    Code:
     UPDATE GlobalParameters
    SET Value = Value +
               ROUND(Value * 0.0165 * (SELECT Factor FROM TimeXFactor WHERE EraType = "ERA_ANCIENT" LIMIT 1))
    WHERE Name = "DARK_AGE_SCORE_BASE_THRESHOLD"
           AND EXISTS (SELECT 1 FROM TimeXFactor WHERE EraType = "ERA_ANCIENT" LIMIT 1); --ERA_ANCIENT used as a reference -> should be the current era of the game!
    
    UPDATE GlobalParameters
    SET Value = Value +
               ROUND(Value * 0.0185 * (SELECT Factor FROM TimeXFactor WHERE EraType = "ERA_ANCIENT" LIMIT 1))
    WHERE Name = "GOLDEN_AGE_SCORE_BASE_THRESHOLD"
           AND EXISTS (SELECT 1 FROM TimeXFactor WHERE EraType = "ERA_ANCIENT" LIMIT 1); --ERA_ANCIENT used as a reference -> should be the current era of the game!
    
    What I want is to dynamically change the coefficient for the value of DARK_AGE_SCORE_BASE_THRESHOLD (and GOLDEN), from the table GlobalParameters, by an amount stored in one of my tables, based on the current era the game is in. I.e. [WHERE EraType = "ERA_ANCIENT"] from the above code should take the current era dynamically and then compute the values based on it (since GlobalParameters does not have an EraType column to link to).

    So, for example, if the game reached Modern Era, instead of the coefficient 0.0165, to be able to have any other value... and so on (dynamically). Can this be done from SQL/XML without any LUA code (the database seems to be more or less static)? I understand that this will imply not dropping the table TimeXFactor at the end of the mod (I'm not sure if the CIV6 database allows tables to be created permanently by mods, but I hope there is no restriction).

    In other words, I'm curious to find out how the method GetCurrentEra() computes the current era the game is in, and whether it is linked somehow/somewhere to the database (i.e. reading/computing a value that somehow stores the current era). I'm more or less trying to add triggers/events that change some values in the database when they occur (this implies: defining what the trigger is [in my case - the current era the game reached], what values to change and where to change them, plus the balancing part of getting the values right) :crazyeye::crazyeye::crazyeye:.

    Code:
    local pGameEras:table = Game.GetEras();
    local currentEraIndex:number = pGameEras:GetCurrentEra();
    local currentEraDef:table = GameInfo.Eras[currentEraIndex];
    
    2.
    Can you please tell me what these values are used for (in terms of game play)? I also found them but don't understand what they actually do.
    • 'THRESHOLD_SHIFT_PER_PAST_DARK_AGE'
    • 'THRESHOLD_SHIFT_PER_PAST_GOLDEN_AGE'
    • 'THRESHOLD_SHIFT_PER_CITY'
    3.
    Because SQL forces you to always specify a table that you want to update/delete/insert into. So when I wrote "UPDATE GlobalParameters", then the data from the table GlobalParameters gets modified and nothing else. There can be any number of other tables with the same column names and the same values - the update is only done to the one specified in the update/delete/insert instruction. Sorry if I misunderstood your question.

    Thank you
     
  6. Crusader2010

    Crusader2010 Chieftain

    Joined:
    Aug 17, 2014
    Messages:
    61
    Update: I tried even a simple update for the values and still the game doesn't show them properly.

    Code:
    UPDATE Eras_XP1
    SET GameEraMinimumTurns = GameEraMinimumTurns * 3
    WHERE Eras_XP1.EraType = 'ERA_ANCIENT';
    
    UPDATE Eras_XP1
    SET GameEraMaximumTurns = GameEraMaximumTurns * 3
    WHERE Eras_XP1.EraType = 'ERA_ANCIENT';
    Is there a way to log/read/display a value from a database table after the game started?
     
    Last edited: Feb 13, 2018
  7. Infixo

    Infixo Warlord

    Joined:
    Jan 9, 2016
    Messages:
    2,210
    Gender:
    Male
    Location:
    Warsaw
    @Crusader2010 You cannot change anything in DB during the game. All xml/sql is processed before the actual game starts and the DB becomes read-only. If you want to apply any effect during the game you can either a) use available game mechanics like Modifiers b) use Lua.
     
  8. Ulixes

    Ulixes Prince

    Joined:
    May 2, 2010
    Messages:
    307
    (1) Okay, now I understand.

    Short answer: no, at least not with only with xml/sql.

    Long answer: I assume you are experienced in programming but new to modding civ.

    If so: you can mod the game with xml/sql, Lua, C++ if the DLL is released (not yet for Civ6, but it has always been released after a while in the past iterations of the game).

    With xml/sql you can modify the game settings you will keep for the rest of the game (some require starting a new game, some not, I never enabled a mod mid-game personally).
    The things you can modify are set by the developers through pre-set tables (a static database, although this iteration seems to have more versatility in my opinion).
    If you want to create a new table or column, you'll have to back it up with some Lua (or a DLL modification if/when the DLL will be avalaible).

    So, in the case in question, you can decide the min/max of each age as the Devs allow you to.

    You can change the base thresold of dark/golden age in the terms they allow you to.

    Maybe you can do more with Lua but I don't know for sure, you should look for the advice of someone who already tried (is anybody out there?)

    (2) As for the tags:

    'THRESHOLD_SHIFT_PER_PAST_DARK_AGE': how much the threshold varies if you just had a dark age (by default is -5, so, if you just had a dark age it is easier to get a normal/golden age in the following era)

    'THRESHOLD_SHIFT_PER_PAST_GOLDEN_AGE': how much the threshold varies if you just had a golden age (by default is 5, so, if you just had a golden age it is harder to get another golden age in the following era)

    'THRESHOLD_SHIFT_PER_CITY': apparently it means that the threshold increases per every city you have (I haven't paid attention to this detail in my last playthrough so I'm not 100% sure, but it makes so much sense that I expect it to work as intended)

    (3) You're right, the table is always unique. My mistake.
    Anyway after modding a lot in both Civ5 and Civ6 specifying "WHERE" as become a reflex :)
     
    Last edited: Feb 13, 2018
  9. Infixo

    Infixo Warlord

    Joined:
    Jan 9, 2016
    Messages:
    2,210
    Gender:
    Male
    Location:
    Warsaw
  10. Ulixes

    Ulixes Prince

    Joined:
    May 2, 2010
    Messages:
    307
    Oh, and yes, as he said, you can. I usually read my modded database with SQLiteStudio
     
  11. Crusader2010

    Crusader2010 Chieftain

    Joined:
    Aug 17, 2014
    Messages:
    61
    Thank you very much guys! Now for the followup questions since I am indeed new to modding CIV but quite good at MSSQL and programming (not LUA, but C# isn't very different) :)

    1. Where can I find a tutorial on how to "link" LUA files with the game (i.e. alter in-game behavior/variables/etc) or with values from XMLs? (as I've seen, XMLs are used to insert/update values easier into the database tables; so it's more or less an alternative to an SQL file in most cases).

    2. What file(s) do I need to open with SQLiteStudio while I'm in a game in order to view the tables I'm interested in?

    Thanks a lot! :grouphug:


    EDIT: I think I found them... in the Cache subfolder: "DebugGameplay.sqlite" and "DebugConfiguration.sqlite". Are these the ones?

    EDIT2: FINALLY GOT IT WORKING! :goodjob: There were 3 typos: one extra comma when creating the EraIncreases table, as well as missing two semicolons - after each of the updates that change the number of turns required for an era to pass. :sad:

    Didn't know SQLite is so restrictive. Live and learn... :cringe:
     
    Last edited: Feb 13, 2018
  12. Infixo

    Infixo Warlord

    Joined:
    Jan 9, 2016
    Messages:
    2,210
    Gender:
    Male
    Location:
    Warsaw
  13. Crusader2010

    Crusader2010 Chieftain

    Joined:
    Aug 17, 2014
    Messages:
    61
  14. Ulixes

    Ulixes Prince

    Joined:
    May 2, 2010
    Messages:
    307
    Last edited: Feb 14, 2018
  15. Crusader2010

    Crusader2010 Chieftain

    Joined:
    Aug 17, 2014
    Messages:
    61
    No problem :) will definitely look at those and see what I can do.

    One more question though... China has an interesting trait, that increases inspirations from 40% to 50%. This will definitely require tweaking (I've reduced all boosts from inspirations to 20). So... where can I find this value of "50", specific to China, so I can alter it properly? Strangely enough, my database has all the boosts at 50 (no idea when the 40 from China's ability should apply).

    EDIT: found the value in the ModifierArguments table. Now searching for the description text...

    EDIT2: Ok, found the Localization database but it seems that my changes don't reflect anywhere. What I need to change is this:
    - the civilization text when mousing over the leader in the game setup screen
    - the text shown during the loading screen of a game
    - the text shown in-game, after clicking on my leader's portrait.

    Any ideas why this isn't working? :sad: I've uploaded the related modinfo and sql files (it's a slightly modified version of RealTechTree suited for what I like to play).
     

    Attached Files:

    Last edited: Feb 15, 2018
  16. Ulixes

    Ulixes Prince

    Joined:
    May 2, 2010
    Messages:
    307
    Just read your post. If you still need advice: try building your modinfo file like this:

    Code:
    
    <Properties>
        <Name>YourMod</Name>
        <Description>optional, your personal modifications</Description>
        <Teaser>optional, your personal modifications</Teaser>
        <Authors>You</Authors>
    </Properties>
    <FrontEndActions>
        <UpdateDatabase id="MenuSettings">
          <File>xml/sql menu settings that have to be loaded before the game starts</File>
        </UpdateDatabase>
    </FrontEndActions>
    <InGameActions>
        <UpdateText id="NewText">
          <File>your text file</File>
        </UpdateText>
        <UpdateDatabase id="NewAction">
          <Properties>
            <LoadOrder>5 (you don't necessarily need it, and surely you don't need it to be one million)</LoadOrder>
          </Properties>
         ...other xml/sql files...
        </UpdateDatabase>
    </InGameActions>
        <Files>
        ...ALL the files included in your mod have to be listed here.
        </Files>
    
    Also, if you don't want to wast time on the modinfo file you should build the structure of your mod on modbuddy (you can download it on steam: Sid Meier's Civilization VI Development Tools).

    I were used to do everything only with notepad++, but the Civ 6 modinfo file is more complex than the Civ 5 one and I discovered that using the modbuddy to create it automatically is waaay easier than manually write it (you can then use whatever you want to write the other files).
     
    Last edited: Feb 16, 2018

Share This Page

Ebates: Get Paid to Shop