[GS] "Simple" modding question

QuasarNebula

Chieftain
Joined
Jul 4, 2020
Messages
10
Location
France
Hello there,
I've started modding since a bit of time but never actually went deep into it.
But just yesterday I started working on a Civilization, and I wanted to add to it quite a "simple" Unique Trait
Most of its effects, I can manage them, but, I want it to basically do just like "Mother Russia" from Russia, so to increase Yields of Faith and Food in tundras (and snow, in my particular case)
But, well, I can't figure out how to do it, it just won't work, and I feel than my current solution to the problem is waaaay too over-complicated.

I could use some help on how to implement this increase in yields for tundras, thanks !
 
Code:
<GameData>
	<Types>
		<Row Type="TRAIT_TUNDRA_SNOW_EXTRA_YIELDS" Kind="KIND_TRAIT"/>
	</Types>
	<Traits>
		<Row TraitType="TRAIT_TUNDRA_SNOW_EXTRA_YIELDS" Name="Extra Yields in Tundra and Snow" Description="+1 [ICON_Food] Food and [ICON_Faith] Faith in Tundra and Snow"/>
	</Traits>
	<Modifiers>
		<Row>
			<ModifierId>MODIFIER_TUNDRA_SNOW_EXTRA_YIELDS</ModifierId>
			<ModifierType>MODIFIER_PLAYER_ADJUST_PLOT_YIELD</ModifierType>
			<SubjectRequirementSetId>PLOT_HAS_TRAIT_TUNDRA_SNOW_EXTRA_YIELDS_REQUIRMEMENT_SET</SubjectRequirementSetId>
		</Row>
	</Modifiers>
	<ModifierArguments>
		<Row>
			<ModifierId>MODIFIER_TUNDRA_SNOW_EXTRA_YIELDS</ModifierId>
			<Name>YieldType</Name>
			<Value>YIELD_FOOD,YIELD_FAITH</Value>
		</Row>
		<Row>
			<ModifierId>MODIFIER_TUNDRA_SNOW_EXTRA_YIELDS</ModifierId>
			<Name>Amount</Name>
			<Value>1,1</Value>
		</Row>
	</ModifierArguments>
	<Requirements>
		<Row>
			<RequirementId>PLOT_IS_TUNDRA_EXTRA</RequirementId>
			<RequirementType>REQUIREMENT_PLOT_TERRAIN_CLASS_MATCHES</RequirementType>
		</Row>
		<Row>
			<RequirementId>PLOT_IS_SNOW_EXTRA</RequirementId>
			<RequirementType>REQUIREMENT_PLOT_TERRAIN_CLASS_MATCHES</RequirementType>
		</Row>
	</Requirements>
	<RequirementArguments>
		<Row>
			<RequirementId>PLOT_IS_SNOW_EXTRA</RequirementId>
			<Name>TerrainClass</Name>
			<Value>TERRAIN_CLASS_SNOW</Value>
		</Row>
		<Row>
			<RequirementId>PLOT_IS_TUNDRA_EXTRA</RequirementId>
			<Name>TerrainClass</Name>
			<Value>TERRAIN_CLASS_TUNDRA</Value>
		</Row>
	</RequirementArguments>
	<RequirementSets>
		<Row>
			<RequirementSetId>PLOT_HAS_TRAIT_TUNDRA_SNOW_EXTRA_YIELDS_REQUIRMEMENT_SET</RequirementSetId>
			<RequirementSetType>REQUIREMENTSET_TEST_ANY</RequirementSetType>
		</Row>
	</RequirementSets>
	<RequirementSetRequirements>
		<Row>
			<RequirementSetId>PLOT_HAS_TRAIT_TUNDRA_SNOW_EXTRA_YIELDS_REQUIRMEMENT_SET</RequirementSetId>
			<RequirementId>PLOT_IS_TUNDRA_EXTRA</RequirementId>
		</Row>
		<Row>
			<RequirementSetId>PLOT_HAS_TRAIT_TUNDRA_SNOW_EXTRA_YIELDS_REQUIRMEMENT_SET</RequirementSetId>
			<RequirementId>PLOT_IS_SNOW_EXTRA</RequirementId>
		</Row>
	</RequirementSetRequirements>
	<TraitModifiers>
		<Row TraitType="TRAIT_TUNDRA_SNOW_EXTRA_YIELDS" ModifierId="MODIFIER_TUNDRA_SNOW_EXTRA_YIELDS"/>
	</TraitModifiers>
</GameData>
You will need to edit the name of the Trait to make it match either your Leader or Civilization Trait.
 
Thanks a lot for checking my problem out !
This code is interesting, but I'm sure I'm doing something wrong while plugin it in, it doesn't seem to work ingame, tundras are still worth just one food.
I did edit the name of the trait, and make sure it's associated to the civilization, but I have no errors, so it seems that the game just doesn't read the code, I might have to change de whole template, any suggestions ? (The majority of the template is in sql btw)
 
Are you checking a plot that is actually owned by the Civilization ?

The game does not show the change in the User Interface if the plot is not owned by the player. It just shows the yields for an un-owned Tundra or Snow or whatever Terrain plot.
 
Yep, I created a city in the middle of a tundra (on a test map so it's really not that complicated to test) and the yields sadly stays the same, I did not try on snow thought
 
You would need to zip up the mod and attach the zip to a post in order for me to diagnose what you have likely done wrong.

Zip the whole folder for the mod found in the game's "Mods" folder rather than the Modbuddy Project
…..\Documents\My Games\Sid Meier's Civilization VI\Mods
 
Thanks for the time you take for me, its appreciated a lot !

There is some french text here and there, but nothing that touches the coding, only flavoring of the actual civ
Its quite messy thought, not an expert
 

Attachments

Code:
    <UpdateDatabase id="NewAction">
      <File>Core/Civilization_Config.sql</File>
      <File>Leader/Leader_Core.sql</File>
      <File>Core/Civilization_UA.sql</File> …
vs
Code:
  <Files>
    <File>Core/Civilization_Colors.sql</File>
    <File>Core/Civilization_Config.sql</File>
    <File>Core/Civilization_Localisation.sql</File>
    <File>Core/Civilization_UA.xml</File>
          …..
There will be a no such filename error of some kind being reported in Modding.log

You are using a file called "Civilization_UA.xml" rather than a file called "Civilization_UA.sql"

--------------------------------------------------------------------------------------------------------------------------------------

Second, you cannot have this in two different files
Code:
INSERT INTO	Types
	(Type,					Kind)
VALUES	('TRAIT_CIVILIZATION_QUA_FJORM_UA',	'KIND_TRAIT'	),
	('TRAIT_CIVILIZATION_QUA_FJORM_UA',	'KIND_MODIFIER'	);
and this
Code:
<GameData>
	<Types>
		<Row Type="TRAIT_CIVILIZATION_QUA_FJORM_UA" Kind="KIND_TRAIT"/>
	</Types>
While one is SQL and the other is XML they are equivalent code for adding a new Trait into the "Types" table. And you can only ever register the same "Type" once into the table. SQL and XML code all go to the same database.

Also the quoted SQL snippet should be causing a fatal syntax error since you are using the exact same designation for the "Type" column. It does not matter that the first is using 'KIND_TRAIT' and the second is using 'KIND_MODIFIER'. All that matters in the "Types" table is what is registered for the "Type", and every new addition to the table must be unique to any and all Types already added to the table. This error will cause the game to cease reading anything further from within the same SQL file or XML file.

I would eliminate this entirely from your SQL file
Code:
INSERT INTO	Types
		(Type,											Kind			)
VALUES	('TRAIT_CIVILIZATION_QUA_FJORM_UA',			'KIND_TRAIT'	),
		('TRAIT_CIVILIZATION_QUA_FJORM_UA',			'KIND_MODIFIER'	);
The needed definition of the Trait is being done in the xml file so you don't need to do it in the SQL file.

----------------------------------------------------------------------------------------------------------------------------------------------

I don't see anywhere that you have attached TRAIT_CIVILIZATION_QUA_FJORM_UA to the civilization under table "CivilizationTraits" so you would need to alter the bottom of the XML file to this
Code:
	<TraitModifiers>
		<Row TraitType="TRAIT_CIVILIZATION_QUA_FJORM_UA" ModifierId="MODIFIER_TUNDRA_SNOW_EXTRA_YIELDS"/>
	</TraitModifiers>
	<CivilizationTraits>
		<Row CivilizationType="CIVILIZATION_QUA_FJORM" TraitType="TRAIT_CIVILIZATION_QUA_FJORM_UA" />
	</CivilizationTraits>
</GameData>
  1. A modifier is attached to a Trait via table "TraitModifiers"
  2. The Trait is then attached to a Leader or a Civilization via tables "CivilizationTraits" or "LeaderTraits"
There's more wrong with the mod but this is enough to fix for now.

------------------------------------------------------------------------------------------------------------------------------------

Every time you apply a fix and test your mod in-game the first place to look for errors is in file Database.log
Then look in file Modding.log to determine which files (for SQL files) were being loaded with the same or a similar timestamp as that showing in Database.log
This is what a Database.log looks like with no errors being reported other than those everyone gets because Firaxis
Code:
[478013.024] [Localization]: StartupErrorMessages.xml
[478013.024] [Localization]: Input XML does not contain database entry tags. GameData, GameInfo or Database
[478016.518] [Localization]: Validating Foreign Key Constraints...
[478016.518] [Localization]: Passed Validation.
[478016.531] [Configuration]: Validating Foreign Key Constraints...
[478016.531] [Configuration]: Passed Validation.
[478017.858] [FullTextSearch]: Initializing FullTextSearch
[478018.988] [Gameplay]: Validating Foreign Key Constraints...
[478019.000] [Gameplay]: Passed Validation.
[478020.390] [Configuration]: Validating Foreign Key Constraints...
[478020.390] [Configuration]: Passed Validation.
[478021.932] [HallofFame]: Database found. Checking versions...
[478021.933] [HallofFame]: Database is up-to-date!
[478035.959] [FullTextSearch]: FTS - Creating Context
[478046.719] [Configuration]: Validating Foreign Key Constraints...
[478046.719] [Configuration]: Passed Validation.
[478052.170] [Gameplay]: Validating Foreign Key Constraints...
[478052.190] [Gameplay]: Passed Validation.
[478060.378] [FullTextSearch]: FTS - Creating Context
[478060.378] [FullTextSearch]: FTS - Creating Context
[478060.713] [FullTextSearch]: FTS - Creating Context
[478061.595] [FullTextSearch]: FTS - Creating Context
[478064.177] [FullTextSearch]: FTS - Creating Context
The number references at the start of each line are time-stamps rather than error codes.
 
Woaw ! Damn, what's fascinating is that everything of what you told me is pure logic, I just didn't knew, Thanks !

For the logs, I did use them a lot, they helped me search and research for my previous method, before accepting that I couldn't do it x)
Well, I will apply all that you said and test it, I'll post again to update you
 
(Sorry for the double post)

Well, it works ! When a city is built, every tundra tile turns to +2 food +1 faith, just as expected, thanks !
I added a unique unit, it works pretty normally for now (just a special archer with only one MP but 3 range)
And I tried to create a unique district, mostly for training, and seeing how it works, so I wanted to recreate an equivalent of the Lavra from Russia, but it, well, doesn't work. Used the logs to figure out the error, and it did help me clarify one or two things, but still.
I do have an idea on what is the problem, but I'm gonna post the code here (sql), because even if I know the problem, I don't have the fix under the hand

-----------------------------------------------
-- Types
-----------------------------------------------

INSERT INTO Types
(Type, Kind )
VALUES ('DISTRICT_QUA_FJORM_UI', 'KIND_DISTRICT' );

-----------------------------------------------
-- Traits
-----------------------------------------------

INSERT INTO Traits
(TraitType, Name )
VALUES ('DISTRICT_QUA_FJORM_UI', 'LOC_BUILDING_QUA_FJORM_UI_NAME' );

-----------------------------------------------
-- CivilizationTraits
-----------------------------------------------

INSERT INTO CivilizationTraits
(TraitType, CivilizationType )
VALUES ('DISTRICT_QUA_FJORM_UI', 'CIVILIZATION_QUA_FJORM' );

-----------------------------------------------
-- Buildings
-----------------------------------------------

INSERT INTO Districts (
DistrictType,
Name,
Description,
TraitType,
PrereqTech,
PrereqCivic,
Cost,
PrereqDistrict,
Housing,
PurchaseYield,
Maintenance,
CitizenSlots,
OuterDefenseStrength,
DefenseModifier,
AdvisorType
)
SELECT 'DISTRICT_QUA_FJORM_UI', -- BuildingType
'LOC_BUILDING_QUA_FJORM_UI_NAME', -- Name
'LOC_BUILDING_QUA_FJORM_UI_DESCRIPTION', -- Description
'DISTRICT_QUA_FJORM_UI', -- TraitType
'TECH_ASTROLOGY', -- PrereqTech
PrereqCivic,
Cost,
PrereqDistrict,
Housing,
PurchaseYield,
Maintenance,
CitizenSlots,
OuterDefenseStrength,
DefenseModifier,
AdvisorType
FROM Districts
WHERE DistrictType = 'DISTRICT_HOLY_SITE';

-----------------------------------------------
-- BuildingReplaces
-----------------------------------------------

INSERT INTO DistrictReplaces
(CivUniqueDistrictType, ReplacesDistrictType )
VALUES ('DISTRICT_QUA_FJORM_UI', 'DISTRICT_HOLY_SITE' );


-----------------------------------------------
-- Building_YieldChanges
-----------------------------------------------

INSERT INTO District_YieldChanges
(DistrictType, YieldType, YieldChange )
VALUES ('DISTRICT_QUA_FJORM_UI', 'YIELD_FAITH', 3 ),
('DISTRICT_QUA_FJORM_UI', 'YIELD_FOOD', 2 );

In my opinion the error is that I just changed the template (which was for a building) and "turned" it into a district, which obviously doesn't work.
Any idea on what to change ?

I guess the
INSERT INTO Districts (
DistrictType,
Name,
Description,
TraitType,
PrereqTech,
PrereqCivic,
Cost,
PrereqDistrict,
Housing,
PurchaseYield,
Maintenance,
CitizenSlots,
OuterDefenseStrength,
DefenseModifier,
AdvisorType
)
SELECT 'DISTRICT_QUA_FJORM_UI', -- BuildingType
'LOC_BUILDING_QUA_FJORM_UI_NAME', -- Name
'LOC_BUILDING_QUA_FJORM_UI_DESCRIPTION', -- Description
'DISTRICT_QUA_FJORM_UI', -- TraitType
'TECH_ASTROLOGY', -- PrereqTech
PrereqCivic,
Cost,
PrereqDistrict,
Housing,
PurchaseYield,
Maintenance,
CitizenSlots,
OuterDefenseStrength,
DefenseModifier,
AdvisorType
FROM Districts
WHERE DistrictType = 'DISTRICT_HOLY_SITE';

to be the problem.
 
Last edited:
You're attempting to use columns that are valid in table "Buildings" but which are not part of table "Districts". This will cause instant rejection by the database. You should be seeing a message in Databse.log saying something like
Code:
table Districts has no column called PrereqDistrict

This is the definition of the Districts table listing all the valid columns and showing the references to data in other tables
Code:
CREATE TABLE "Districts" (
		"DistrictType" TEXT NOT NULL,
		"Name" TEXT NOT NULL,
		"PrereqTech" TEXT,
		"PrereqCivic" TEXT,
		"Coast" BOOLEAN NOT NULL CHECK (Coast IN (0,1)) DEFAULT 0,
		"Description" TEXT,
		"Cost" INTEGER NOT NULL DEFAULT 0,
		"RequiresPlacement" BOOLEAN NOT NULL CHECK (RequiresPlacement IN (0,1)),
		"RequiresPopulation" BOOLEAN NOT NULL CHECK (RequiresPopulation IN (0,1)) DEFAULT 1,
		"NoAdjacentCity" BOOLEAN NOT NULL CHECK (NoAdjacentCity IN (0,1)),
		"CityCenter" BOOLEAN NOT NULL CHECK (CityCenter IN (0,1)) DEFAULT 0,
		"Aqueduct" BOOLEAN NOT NULL CHECK (Aqueduct IN (0,1)),
		"InternalOnly" BOOLEAN NOT NULL CHECK (InternalOnly IN (0,1)),
		"ZOC" BOOLEAN CHECK (ZOC IN (0,1)) DEFAULT 0,
		"FreeEmbark" BOOLEAN NOT NULL CHECK (FreeEmbark IN (0,1)) DEFAULT 0,
		"HitPoints" INTEGER DEFAULT 0,
		"CaptureRemovesBuildings" BOOLEAN NOT NULL CHECK (CaptureRemovesBuildings IN (0,1)),
		"CaptureRemovesCityDefenses" BOOLEAN NOT NULL CHECK (CaptureRemovesCityDefenses IN (0,1)),
		"PlunderType" TEXT NOT NULL,
		"PlunderAmount" INTEGER NOT NULL DEFAULT 0,
		"TradeEmbark" BOOLEAN NOT NULL CHECK (TradeEmbark IN (0,1)) DEFAULT 0,
		"MilitaryDomain" TEXT NOT NULL,
		"CostProgressionModel" TEXT NOT NULL DEFAULT "NO_COST_PROGRESSION",
		"CostProgressionParam1" INTEGER NOT NULL DEFAULT 0,
		"TraitType" TEXT,
		"Appeal" INTEGER NOT NULL DEFAULT 0,
		"Housing" INTEGER NOT NULL DEFAULT 0,
		"Entertainment" INTEGER NOT NULL DEFAULT 0,
		"OnePerCity" BOOLEAN NOT NULL CHECK (OnePerCity IN (0,1)) DEFAULT 1,
		"AllowsHolyCity" BOOLEAN NOT NULL CHECK (AllowsHolyCity IN (0,1)) DEFAULT 0,
		"Maintenance" INTEGER NOT NULL DEFAULT 0,
		"AirSlots" INTEGER NOT NULL DEFAULT 0,
		"CitizenSlots" INTEGER,
		"TravelTime" INTEGER NOT NULL DEFAULT -1,
		"CityStrengthModifier" INTEGER NOT NULL DEFAULT 0,
		"AdjacentToLand" BOOLEAN NOT NULL CHECK (AdjacentToLand IN (0,1)) DEFAULT 0,
		"CanAttack" BOOLEAN NOT NULL CHECK (CanAttack IN (0,1)) DEFAULT 0,
		"AdvisorType" TEXT,
		"CaptureRemovesDistrict" BOOLEAN NOT NULL CHECK (CaptureRemovesDistrict IN (0,1)) DEFAULT 0,
		"MaxPerPlayer" REAL NOT NULL DEFAULT -1,
		PRIMARY KEY(DistrictType),
		FOREIGN KEY (PrereqTech) REFERENCES Technologies(TechnologyType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT,
		FOREIGN KEY (PrereqCivic) REFERENCES Civics(CivicType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT,
		FOREIGN KEY (TraitType) REFERENCES Traits(TraitType) ON DELETE SET DEFAULT ON UPDATE SET DEFAULT,
		FOREIGN KEY (DistrictType) REFERENCES Types(Type) ON DELETE CASCADE ON UPDATE CASCADE);
Firaxis defines nearly all the various game tables that are valid and their columns in an SQL file called "01_GameplaySchema.sql". This file is located on a windows machine at
Code:
C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization VI\Base\Assets\Gameplay\Data\Schema
You can open and look at this file to check whether the code you are attempting is going to work so far as having correct column-names and references to data in other tables is concerned.

You don't need to concern yourself with the commands
Code:
ON DELETE SET DEFAULT ON UPDATE SET DEFAULT
ON DELETE CASCADE ON UPDATE CASCADE
They are used by Firaxis to ensure that when something is removed or added from/to one table, all other necessary tables are kept in line with the changes.

--------------------------------------------

Also I would point you to the game's base xml files at
Code:
C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization VI\Base\Assets\Gameplay\Data
Because you have other errors with using tables that don't exist or column-name mismatching. There is for example no table called "District_YieldChanges". File "Districts.xml" would be the one you want to open and inspect. The definition of the Lavra is in that file. If you want to continue modding Civ6 after you complete your current project you will need to get used to reading the game's xml files even if you decide to continue using SQL to make your code.
 
Last edited:
Update !

Well, after a bit of time and a dead spider, here I am, I managed to make it all work, thanks to you LeeS, the district works, the unit works, and the unique ability works
For now I think I'm not gonna add much, I want to make sure that I can manage to add textures, but I have literally no ideas at all on how to do it, I tried searching through other mods, never saw any .dds files or anything that looks like an image, and I'm having a hard time understanding how the code founds the images (which I can't find myself)
I searched for a guide, but couldn't find anything, I'll continue searching for guides or mods to scavenge, but I'm not against a little helping hand !
 
Update !

Well, after a bit of time and a dead spider, here I am, I managed to make it all work, thanks to you LeeS, the district works, the unit works, and the unique ability works
For now I think I'm not gonna add much, I want to make sure that I can manage to add textures, but I have literally no ideas at all on how to do it, I tried searching through other mods, never saw any .dds files or anything that looks like an image, and I'm having a hard time understanding how the code founds the images (which I can't find myself)
I searched for a guide, but couldn't find anything, I'll continue searching for guides or mods to scavenge, but I'm not against a little helping hand !

What specifically are you trying to achieve in terms of 'textures' - are you trying to add new 2D icons to the district and unit you've mentioned here? Or also create custom 3D models?

The learning curve can be quite steep, especially if you arrive at a finished, functional mod (with no graphics) and then are wondering 'OK, so where do I start?'. I get it.

I'd recommend this thread to understand some of the principles of how you have to include 2D artwork as part of your mod: https://forums.civfanatics.com/threads/loading-new-artwork-into-a-mod.657356/#post-15745119. It won't have all of the answers - but it helped me (you're looking for the explanations by Deliverator, not my amateur questions...). It may help explain why you're not seeing DDS files in the mods you're referencing.

For creating a 3D 'custom' unit, but without modelling anything in 3D, I recommend this guide: https://docs.google.com/document/u/...K2_m6aLiBT9PMGsQeM/mobilebasic?urp=gmail_link. I used it and it worked a treat.

For creating a 3D custom building, there's the following guide: https://forums.civfanatics.com/resources/beginners-guide-to-3d-art-assets-buildings.26469/.

This is not intended as a shameless plug, either - but if you are looking for a ModBuddy project that contains DDS files to serve as a reference, you're welcome to download the one I recently uploaded. It doesn't make any attempt to describe the process of getting the images created and 'imported' into the right format; it does show the various files all in one mod, though, and serves the purpose of illustrating how they reference one another. That template is available via https://forums.civfanatics.com/resources/custom-civilization-modbuddy-template.28386/.
 
Thank you for your help, as for now, the mod looks like this : (attached file)

I tried a bit to see how could I import just a simple image but did not succeed
 

Attachments

Back
Top Bottom