Civ's UA: Building Holy Sites on a specific terrain

byPythagorion

Chieftain
Joined
Jul 21, 2020
Messages
16
Location
the Home of Barbarossa
Greetings,
I´ve started Modding an own Civilization some days ago. the localisation is almost finished, so I started today with the Civilization's UA. Short explanation of what I am trying to achieve:
When a Holy Site is built on a tundra tile, you shall gain +2 Great General Points & +3 Great Prophet Points. If another player completes Stonehenge you shall get +10 Faith.

I can't get any further when it comes to the fact that the holy site has to be placed on a tundra tile to receive the bonuses. To make sure that the bonuses are only given if it is a holy site, I have set as a requirement that the district is a holy site. How can I now specify that the terrain on which the holy site is placed is a tundra tile?

Thank you very much.
 
Thanks. I think I managed to set the Tundra by using the requirement "PLOT_TERRAIN_TYPE_MATCHES" (or something like that).
Yeah, the RequirementType "REQUIREMENT_PLOT_TERRAIN_TYPE_MATCHES" is what the SubjectRequirementSetId "PLOT_HAS_ANYTUNDRA_REQUIREMENTS" uses. Since it already exists it would have just saved you from having to define any new requirements. It also includes both Tundra and Tundra Hills terrain.
 
Yeah, the RequirementType "REQUIREMENT_PLOT_TERRAIN_TYPE_MATCHES" is what the SubjectRequirementSetId "PLOT_HAS_ANYTUNDRA_REQUIREMENTS" uses. Since it already exists it would have just saved you from having to define any new requirements. It also includes both Tundra and Tundra Hills terrain.
Good to know that. Thanks ;)
 
Yeah, the RequirementType "REQUIREMENT_PLOT_TERRAIN_TYPE_MATCHES" is what the SubjectRequirementSetId "PLOT_HAS_ANYTUNDRA_REQUIREMENTS" uses. Since it already exists it would have just saved you from having to define any new requirements. It also includes both Tundra and Tundra Hills terrain.
You said in the closed thread "Just looking real quick you can't have the same modifier with two different requirement sets. You need to fold both those requirements into a single requirement set."
I know what say, but I can´t follow you how to change that. Could you please be a little more specific? I'm afraid I'm still a complete beginner.

Here is the code again: https://pastebin.com/MS61UHnU
 
Last edited:
@byPythagorion - What do your Database & Modding logs say? Any errors? Does the game actually load or do you get an error popup or CTD? You could try using COLLECTION_OWNER instead of COLLECTION_PLAYER_DISTRICTS. Also, change Permanent to false (0) instead of true (1).

Also, REQUIREMENT_REQUIREMENTSET_IS_MET isn't necessary in this instance.
 
@Laurana Kanan So I have an update. At first I made the changes you said. I changed nothing. The Building of the Solution worked fine and there were no errors at all. I tried another modifier to see whether the requirements work or not, but nothing happened. So I went through all the code and I found something: In line 19 I forgot to set a comma. This one I set then. The Building worked fine. No errors. But when I loaded the lobby with my civilization, the lobby crashed with the advice to deactivate all mods. Still there are no errors, but at least the game reacts to my mod ;) Any ideas what to do?
 
Ah I found the database log. I didn´t know where it was. Line 84 I have fixed before, so that has nothing to do with the crash, I tink. But I found 2 lines in the Database-log that refer to the UA:

[2247579.483] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "MODIFIER_IN_THE_BEGINNING_WAS_THE_MANGO_GREAT_PROPHET" does not exist in Modifiers
[2247579.483] [Gameplay] ERROR: Invalid Reference on TraitModifiers.ModifierId - "MODIFIER_IN_THE_BEGINNING_WAS_THE_MANGO_GREAT_GENERAL" does not exist in Modifiers

This Error occurs just before the lobby crashes.
 
Invalid Reference errors always cause return to main menu.

You either still have a syntax error in your code somewhere or the file that adds MODIFIER_IN_THE_BEGINNING_WAS_THE_MANGO_GREAT_PROPHET is not actually being executed as part of an UpdateDatabase action within the InGame Actions tab of modbuddy.

Also, Modbuddy does not generate error messages for code syntax errors when you build the mod or the solution in modbuddy. Your code in XML, SQL, or Lua files can be utter rubbish and Modbuddy will not report an error while building the mod.

Modbuddy only gives error reports for such things as non-existant files, files it cannot open, or not being able to wipe the previous version of the mod from the game's MODS folder (usually because one or more files within the built version of the mod are open in some other application).

In Database.log, when you see an Invalid Reference error message, you need to look higher up in the Database.log file for an error message related to syntax issues. For SQL files this will generally be a laconic and easy to miss error meesage like
Code:
near ";": syntax error
In Database.log 'lingo', "near" means "previous to"

In order to know which file or files an error is located within for SQL files you need to compare the Timestamp at the beginning of the error message in Database.log to the Timestamps found in Modding.log --> the relevant SQL file(s) will be shown as loading at the same or a similar numerical Timestamp in Modding.log as the Timestamp shown in Database.log

For XML files, a group of usually four error message lines will be generated in Database.log all with the same Timestamp -- the final of these messages will give you the name of the file that the game was attempting to load when it encountered the error.

Regardless of whether the error was found in an XML file or an SQL file, the game retains everything in the file up to the point where it encounters a fatal syntax or other error, and discards the remainder of the code within the file. So part of your code can "reference" a ModifierId, but the definition of the ModifierId can be located in the file below the location where there is a syntax error -- resulting in the Invalid Reference error and the shunt back to the main menu because when the game checks the contents of the database for references between one game-table and another game-table (which is done as the very last "database" thing before getting "ingame") it cannot find a specified item in the associated (ie, referenced) game-table. Civ6 does not allow the game to proceed past checking for references in the database unless the entire contents of the database are "clean" of missing references between game-tables.

This behavior makes things harder on mod-makers perhaps, but it also tends to make the game operate more smoothly for users of mods. There are far far fewer mystery-crashes during gameplay in Civ6 than there were in civ5 because of malformed database code in mods.
 
Last edited:
Invalid Reference errors always cause return to main menu.

You either still have a syntax error in your code somewhere or the file that adds MODIFIER_IN_THE_BEGINNING_WAS_THE_MANGO_GREAT_PROPHET is not actually being executed as part of an UpdateDatabase action within the InGame Actions tab of modbuddy.

Also, Modbuddy does not generate error message for code syntax errors when you build the mod or the solution in modbuddy. Your code in XML, SQL, or Lua files can be utter rubbish and Modbuddy will not report an error while building the mod.

Modbuddy only gives error reports for such things as non-existant files, files it cannot open, or not being able to wipe the previous version of the mod from the game's MODS folder (usually because one or more files within the built version of the mod are open in some other application).

In Database.log, when you see an Invalid Reference error message, you need to look higher up in the Database.log file for an error message related to syntax issues. For SQL files this will generally be a laconic and easy to miss error meesage like
Code:
near ";": syntax error
In Database.log 'lingo', "near" means "previous to"

In order to know which file or files an error is located within for SQL files you need to compare the Timestamp at the beginning of the error message in Database.log to the Timestamps found in Modding.log --> the relevant SQL file(s) will be shown as loading at the same or a similar numerical Timestamp in Modding.log as the Timestamp shown in Database.log

For XML files, a group of usually four error message lines will be generated in Database.log all with the same Timestamp -- the final of these messages will give you the name of the file that the game was attempting to load when it encountered the error.

Regardless of whether the error was found in an XML file or an SQL file, the game retains everything in the file up to the point where it encounters a fatal syntax or other error, and discards the remainder of the code within the file. So part of your code can "reference" a ModifierId, but the definition of the ModifierId can be located in the file below the location where there is a syntax error -- resulting in the Invalid Reference error and the shunt back to the main menu because when the game checks the contents of the database for references between one game-table and another game-table (which is done as the very last "database" thing before getting "ingame") it cannot find a specified item in the associated (ie, referenced) game-table. Civ6 does not allow the game to proceed past checking for references in the database unless the entire contents of the database are "clean" of missing references between game-tables.

This behavior makes things harder on mod-makers perhaps, but it also tends to make the game operate more smoothly for users of mods. There are far far fewer mystery-crashes during gameplay in Civ6 than there were in civ5 because of malformed database code in mods.
The explanation about Modbuddy - what it does and what it doesn´t - is very helpful. Thanks about that. I checked the inGame Actions tab and couldn´t find any mistakes there. Perhaps you want to take a look by yourself (The code I posted is located in the Civilization_UA.sql)
Anmerkung-2020-07-25-180309.png

Also I couldn´t find any syntax errors by controlling the code. This doesn´t mean that there is none. If I cannot find it, I will just go on and write the Code from scratch to make sure I really didn´t miss anything.
Just to be sure: As a beginner I am not always aware of what I am doing: Aside from any syntax errors that are maybe hidden in the code: Should the code work as it is now or have I made any coding mistakes?

Also I really appreciate your comprehensive, fast feedback to my questions. Thank you very much for helping me Learing all that stuff.
 
Regarding working with the error messages in Database.log :

It is useful to start a test-game with no mods at all active except the Firaxis DLC and expansions. This will generate a Database.log you can then copy elsewhere on your computer to compare against what you get when you run the game with your mod active. Anything that is generated in Database;log when no mods are running is related to Firaxis content and cannot have anything to do with the code of your or anyone else's mods so you can safely ignore those messages when you run your mod.

This is what a "clean" Database.log ought to look like
Code:
[1645244.609] [Localization]: StartupErrorMessages.xml
[1645244.609] [Localization]: Input XML does not contain database entry tags. GameData, GameInfo or Database
[1645248.049] [Localization]: Validating Foreign Key Constraints...
[1645248.049] [Localization]: Passed Validation.
[1645248.062] [Configuration]: Validating Foreign Key Constraints...
[1645248.062] [Configuration]: Passed Validation.
[1645249.368] [FullTextSearch]: Initializing FullTextSearch
[1645250.428] [Gameplay]: Validating Foreign Key Constraints...
[1645250.440] [Gameplay]: Passed Validation.
[1645251.824] [Configuration]: Validating Foreign Key Constraints...
[1645251.825] [Configuration]: Passed Validation.
[1645253.409] [HallofFame]: Database found. Checking versions...
[1645253.410] [HallofFame]: Database is up-to-date!
[1645267.453] [FullTextSearch]: FTS - Creating Context
[1645276.575] [Configuration]: Validating Foreign Key Constraints...
[1645276.576] [Configuration]: Passed Validation.
[1645282.018] [Gameplay]: Validating Foreign Key Constraints...
[1645282.039] [Gameplay]: Passed Validation.
[1645291.682] [FullTextSearch]: FTS - Creating Context
[1645291.682] [FullTextSearch]: FTS - Creating Context
[1645292.027] [FullTextSearch]: FTS - Creating Context
[1645293.008] [FullTextSearch]: FTS - Creating Context
[1645294.841] [FullTextSearch]: FTS - Creating Context
Note the " [Localization]" error message. Firaxis caused this in one of the early patches. It seems to not have an actual effect on the game, and everyone gets that message.
 
You'd need to zip & attach the entire mod folder as it currently is within the game's Mods folder rather than posting links to individual files. The most recent code from your pastebin link has this error at the very top which should not allow you to ever get the missing rerference error you are showing from Database.log
Code:
 INSERT INTO	Types
		(Type,								Kind			)
VALUES		('TRAIT_CIVILIZATION_IN_THE_BEGINNING_WAS_THE_MANGO',		'KIND_TRAIT'	),
		('MODTYPE_IN_THE_BEGINNING_WAS_THE_MANGO_GREAT_GENERAL',	'KIND_MODIFIER'	)
		('MODTYPE_IN_THE_BEGINNING_WAS_THE_MANGO_GREAT_PROPHET',	'KIND_MODIFIER'	);
Don't zip the Modbuddy project -- zip the built version of the mod the game is actually attempting to use.
 
You'd need to zip & attach the entire mod folder as it currently is within the game's Mods folder rather than posting links to individual files. The most recent code from your pastebin link has this error at the very top which should not allow you to ever get the missing rerference error you are showing from Database.log
Code:
 INSERT INTO    Types
        (Type,                                Kind            )
VALUES        ('TRAIT_CIVILIZATION_IN_THE_BEGINNING_WAS_THE_MANGO',        'KIND_TRAIT'    ),
        ('MODTYPE_IN_THE_BEGINNING_WAS_THE_MANGO_GREAT_GENERAL',    'KIND_MODIFIER'    )
        ('MODTYPE_IN_THE_BEGINNING_WAS_THE_MANGO_GREAT_PROPHET',    'KIND_MODIFIER'    );
Don't zip the Modbuddy project -- zip the built version of the mod the game is actually attempting to use.
Alright. Thank you for your answer. I will re-write the code and see what happens. If there are still any errors I´ll come back with the build.
 
Just a little question about adding more than one language to the mod:
If I want to add another language then english to code, does it work to do it like this (inside the Localization.sql):

('en_US', 'LOC_NAMED_RIVER_GRANDE', 'Rio Grande' ),

('de_DE', 'LOC_NAMED_RIVER_GRANDE', 'Rio Grande' ),

Or is there anything I have to do besides that?
 
It took me a little bit longer, but I have rewritten the code. And it fixed the error, I think. The Loading Screen actually occured, but the Mod crashed again, showing me in the database log a new error:

[2601382.277] [Gameplay] ERROR: Invalid Reference on RequirementSetRequirements.RequirementId - "REQUIRES_TILE_TUNDRA" does not exist in Requirements

I will attach the built version of the mod - zipped - as LeeS told me above.

Thank you for your help in advance.
 

Attachments

Back
Top Bottom