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

Cyphose's Question Thread

Discussion in 'Mod Creation Help' started by Cyphose, Jun 5, 2017.

  1. Cyphose

    Cyphose y tho

    Joined:
    Feb 1, 2016
    Messages:
    181
    Gender:
    Male
    I used to be reasonably proficient at modding back in the Civ5 days, and now Civ6 has finally gotten around to intriguing me, so I started modding here as well. A lot of the same principles apply, so normally I'm able to find the problem... but some things leave me stumped, and that's what this thread is for. I don't know how often I'll be using it, but it will undoubtedly be better than making a new thread every time I have a new question.

    At any rate, here's what's giving me grief at the moment:

    I'm currently making a mod to change the base game tooltips to not suck. It's called Tips are Tools, and if details would help you diagnose the problem, you can read about it here.

    Some things in the game (mostly buildings) don't have initial descriptions to update--their <Description> field in the database is empty. Because I want to add descriptions, I have to update their building definitions too. Nothing fancy, let's take the Library:
    Code:
    <GameData>
        <Buildings>
            <Update>
                <Where BuildingType="BUILDING_LIBRARY" />
                <Set Description="LOC_BUILDING_LIBRARY_DESCRIPTION" />
            </Update>
        </Buildings>
    </GameData>
    Of course, the LOC_BUILDING_LIBRARY_DESCRIPTION is defined elsewhere. The creation of the localization tag works fine, it just seems to be updating the building definitions that's causing issues. All of these updates are in a separate file, called "Updates.xml", because it requires an UpdateDatabase action instead of UpdateText.

    Currently, what my mod does upon starting a game is hang at a black screen and then send you back to the main menu. From what I've read, this is the universal Civ6 sign of "mistakes were made," so after a bit of investigating, I decided to remove any action on Updates.xml and my mod started the game fine. That narrows it down to where the problem is, but I'm not sure how to fix it.

    Here's what I know:
    • The game is parsing Updates.xml. I checked DebugGameplay.sqlite and all the changes in the file were made in the database.
    • Updates.xml used to work fine. For some reason, presumably after making a change I don't remember making, it started crashing the game.
    • My logs aren't pointing me in any direction in particular. They'll be linked below. These lines stick out to me:
      Code:
      [2051945.568] [Gameplay] ERROR: near "Update": syntax error
      [2051945.571] [Gameplay] ERROR: near "Update": syntax error
      [2051945.571] [Gameplay]: Validating Foreign Key Constraints...
      [2051945.586] [Gameplay]: Passed Validation.
      [2051945.586] [Gameplay] ERROR: near "Update": syntax error
      [2051945.586] [Gameplay] ERROR: near "Update": syntax error
      They're SQL errors from an XML-only mod, though, and are completely unhelpful besides. I would assume this means one of my Update statements is wrong, but not only can I not find where, the game is still parsing my file. Usually, XML hits one error and tosses aside everything.
    I'm pretty much at a loss on this one, due to a combination of "it used to work" and "is working, just in a way that now crashes the game." It is undoubtedly something stupid, and likely related to me being blind... but unfortunately that means I need some extra pairs of eyes. The version I uploaded below has the UpdateDatabase action on Updates.xml. If you want to test that it works without it and doesn't work with it, feel free to delete it.
    Thanks in advance for any help anyone can provide. I have another question to ask, but it's not nearly as important, just more of an annoyance. I'll leave that for afterward, since a game-crashing bug is far more critical.
     

    Attached Files:

  2. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,341
    Location:
    Illinois, USA
    Eliminate all spaces in the names of action "id":
    Code:
    <UpdateText id="CivSelectReplacements(BASE)">
    instead of
    Code:
    <UpdateText id="Civ Select Replacements (BASE)">
    Do not start "id" names with numbers, either, as I have had this also result in refusal to load the action properly.

    I also recommend (as a belts and suspenders approach) eliminating all spaces in folder and file names.
     
  3. Cyphose

    Cyphose y tho

    Joined:
    Feb 1, 2016
    Messages:
    181
    Gender:
    Male
    And, like magic, it works! Saving the day as always, LeeS; thank you very much. That's certainly a pretty strange issue (and one I never would've guessed was causing the problem), but I suppose it makes some sort of sense. Spaces always find their way to mess things up.

    I originally had another question, but my time was spent investigating the black screen hang/sending back to the main menu. With that cleared up, I'll probably investigate my other question further on my own before I ask it here, but I imagine if I don't have it solved within a day or two I'll be back.
     
  4. Cyphose

    Cyphose y tho

    Joined:
    Feb 1, 2016
    Messages:
    181
    Gender:
    Male
    What? The last time I was working on this mod was June of last year? Time flies, jeez.

    Anyway, the fire in my tooltip OCD has been kindled with the release of Rise and Fall, because I took one look at the descriptions for Zulu and nearly threw up. My inner consistency nut cannot abide by some of these new tooltips/descriptions and their transgressions on my sanity. If you don't know what I'm talking about, refer to my first post right up above; I link my Tips are Tools mod which, while it has undergone some changes, is still mostly the same. It's a pet project of mine, and I'm hell-bent on bringing Civ6's tooltips up to my personal (ludicrous) standards.

    With that in mind, I'm back... with a bit of a different question than usual, regarding mod compatibility.

    First off, the mod works fine, does all I want it to do with (seemingly) no issues. I haven't tested it with Rise & Fall yet, but that's because my question sort of involves that. I know how to use dependencies and references in ModBuddy and that's all well and good, but this is where I encounter a problem:

    With the release of this expansion, Civilization 6 has essentially split into two different games. I haven't experienced this in Civ modding yet because I started up modding 5 when all of its expansions were already out. Now, a mod like mine encounters some very unique problems with how Firaxis structures their expansion releases: namely, some mechanics change depending on whether or not you have the expansion. For example, America's UA changes as follows:

    Founding Fathers (without R&F): Earn Government Legacy bonuses twice as fast.
    Founding Fathers (with R&F): Diplomatic Policy slots in all Governments are converted to Wildcard Policy slots.
    It's important to note here that America's UA changes if and only if you have the expansion. This is a problem for my mod that strives for tooltip accuracy. With only the tools ModBuddy gives me (references/dependencies), I don't know of any way to tell my mod to, say, use the R&F tooltip with R&F, otherwise use the normal one. As far as I'm aware, it can't do anything conditional like that--it can only change mod loading order. That's sufficient for isolated DLC, but for a massive expansion that also changes things in the base game, I'm left scratching my head on how to handle this.

    Let's say I use a reference for Rise and Fall, causing it to be activated before my mod. In the case that the person doesn't have R&F, I end up changing America's UA tooltip despite not needing to, and thus the person receives entirely wrong information. If they do have R&F, the mod functions as intended. That's great for the person with R&F, but it screws over the person without it.

    To summarize: my problem is essentially "how do I set my mod to only change the database under specific circumstances?" (like having R&F). The most obvious way is to make two separate mods, one with a specific dependency on R&F to ensure it can't be used otherwise. I know this is an option, but I'd rather keep it consolidated as one mod that can conditionally tell which expansion's mechanics it should be using.

    As always when I ask a question, I'm left with an oppressive feeling of how silly this question might be. I might've missed some available resource that answers this problem, but you'll have to forgive me; I'm coming back to modding after not doing so for a fair amount of time.

    Thanks to anyone that can help. If I lost you somewhere along the way in trying to describe what my problem is, feel free to ask me to clarify. It's a bit of a weird problem, and I wasn't sure how to phrase it.
     
  5. Cyphose

    Cyphose y tho

    Joined:
    Feb 1, 2016
    Messages:
    181
    Gender:
    Male
    Alright, I'm back after some on-and-off investigation for the past week(s). Before I start talking about what I've found, I want to address something I said in the previous post.

    Let's start with my mention of the American UA:
    As it turned out, this was a bad example--America's UA was updated, but it also has a separate localization entry, under the name "LOC_TRAIT_CIVILIZATION_FOUNDING_FATHERS_EXPANSION1_DESCRIPTION". Given that it's separate from the base game tag, updating it is easy and free of compatibility issues between the base game and Rise and Fall. This is true of all Civilization/Leader abilities and a number of buildings... but sadly, not all of what was updated for Rise and Fall.

    With this in mind, a better example would be the Market. In Rise & Fall, it was updated to provide an extra Trade Route if the City didn't already have a Lighthouse (compared to the base game, where the Commercial Hub would do it without a Harbor, or vice versa). The Market, however, did not receive an "_EXPANSION1_" localization entry; the expansion merely deletes the existing entry and adds a brand new one under the same name.

    So imagine the following load order of mods, assuming I'm unable to find a way to only activate Rise & Fall tooltips if the expansion is enabled:
    1. Base game is loaded
    2. Rise & Fall is loaded
    3. My base game tooltip updates load
    4. My Rise & Fall tooltip updates load
    This is the ideal circumstance--the player has Rise & Fall and is using it, in which case there are no compatibility issues. However, if they don't have Rise & Fall, this is what happens anyway:
    1. Base game is loaded
    2. My base game tooltip updates load
    3. My Rise & Fall tooltip updates load
    This is problematic. In our example of the Market, I've now incorrectly given its tooltip the "gives Trade Route if the City doesn't have a Lighthouse," even though that's not true for the base game.

    With this in mind and (hopefully) finally explained properly, let me get into what I discovered and the new problems I'm having.

    After investigating both the provided Rise & Fall code and the code of several mods, I came to the (possibly incorrect) conclusion that there should be two ways, in theory, to accomplish what I'm after:
    • Rulesets.
    • Action Criteria.
    Rulesets. This one is fairly straightforward in theory. Rise & Fall adds a Ruleset that must be enabled to play with its content. If I check for it being active, I can theoretically selectively activate parts of my mod, like so:
    Code:
    <Components>
        <LocalizedText id="Base_Text_Updates">
            <Items>
                <!-- Base game text update files go here -->
            </Items>
        </LocalizedText>
        <LocalizedText id="XP1_Text_Updates">
            <Properties>
                <RuleSet>RULESET_EXPANSION_1</RuleSet>
            </Properties>
            <Items>
                <!-- XP1 text update files go here -->
            </Items>
        </LocalizedText>
    </Components>
    
    Ideally, this would make it so that the XP1 text update files would only be used if the Expansion 1 Ruleset was also being used.

    Action Criteria. This is something I happened upon when reading Expansion1.modinfo (Firaxis's implementation of Expansion1 using the "Additional Content" system). With the addition of Expansion 1, a different "core" has been added to the game, which presumably governs the new mechanics introduced in the expansion. Expansion1.modinfo makes use of it, so I figured I'd give it a shot too, with something like the following:
    Code:
    <ActionCriteria>
        <Criteria id="XP1_IN_USE">
            <GameCoreInUse>Expansion1</GameCoreInUse>
        </Criteria>
    </ActionCriteria>
    <InGameActions>
        <UpdateText id="Base_Text_Updates">
            <!-- Base game text update files go here -->
        </UpdateText>
        <UpdateText id="XP1_Text_Updates" Criteria="XP1_IN_USE">
            <!-- XP1 text update files go here -->
        </UpdateText>
    </InGameActions>
    That's all well and good, only what I've found is that neither work. I'm not sure if it's operator error on my part or some typical Firaxis mod interaction goofery, but using either method causes my Rise & Fall files to be added to the game no matter what. I can disable the expansion entirely (thereby limiting myself to both the base game's core and its ruleset) and the files I want to be expansion-specific will still be put into the game.

    I've attached the full versions of the .modinfo files using both methods for those who may want to scrutinize them or catch something I did wrong (which has been known to happen, to understate my propensity for error greatly). I can also upload the entire mod if someone thinks that would help, but it really is just a bunch of localized text updates; nothing fancy. My main question here lies in whether I'm going wrong with how I'm using rulesets/action criteria, because in theory they should not be acting the way they are.

    As always, I appreciate any help or insight that anyone can give me.
     

    Attached Files:

Share This Page