First Mod - Help With Unique Leader Ability

grimboi368

Chieftain
Joined
Feb 24, 2019
Messages
8
Hi, so this is my first mod and am attempting to create a unique ability for my leader, Shrek. I thought what I wanted to achieve was fairly straight forward but I'm having some difficulty. Essentially, what I want is to give Marsh tiles a +3 Production and +2 Culture. This is to begin with, I'd also like to increase appeal and combat strength on marsh but I'll worry about that later. So I have opened the Civ IV data files and the closest I could find was Peter's Mother Russia. So I plugged that in and changed Tundra to Marsh, game loaded fine but nothing was changed. Here is what I am up to at this point in the code, bearing in mind I am completely new and am teaching myself as I go.
Code:
 <!--Trait-->
    <Kinds>
        <Row Kind="KIND_TRAIT"/>
    </Kinds>
    <Types>
        <Row Type="TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP"/>
    </Types>
    <CivilizationTraits>
        <Row CivilizationType="CIVILIZATION_OGRE" TraitType="TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP"/>
    </CivilizationTraits>

    <TraitModifiers>
        <Row>
            <TraitType>TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP</TraitType>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION</ModifierId>
        </Row>
    </TraitModifiers>

So my next plan was to include a similar line to what appears in the feature data set
<Row FeatureType="FEATURE_MARSH" YieldType="YIELD_FOOD" YieldChange="1"/>, then change the yield. Am I on the correct path and if not, teach this noob.

Any help would be greatly appreciated :)

(also I tried looking at other mods and all the ones I found where in SQL)
 
You don't need nor want this:
Code:
    <Kinds>
        <Row Kind="KIND_TRAIT"/>
    </Kinds>
The game already has that defined for it. What you are attempting to do is tell the game there is a new "Kind" called "KIND_TRAIT" but the base game files already have done so.

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

This
Code:
    <Types>
        <Row Type="TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP"/>
    </Types>
Needs to be this
Code:
    <Types>
        <Row Type="TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP" Kind="KIND_TRAIT"/>
    </Types>

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

This is fine so far as it goes
Code:
    <CivilizationTraits>
        <Row CivilizationType="CIVILIZATION_OGRE" TraitType="TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP"/>
    </CivilizationTraits>

    <TraitModifiers>
        <Row>
            <TraitType>TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP</TraitType>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION</ModifierId>
        </Row>
    </TraitModifiers>
But you've never defined this new modifier you called "TRAIT_INCREASED_MARSH_PRODUCTION", nor given its requirementset, requirements, requirementtype, etc.

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

The following would create the Modifier needed for the increased production on Marsh tiles:
Code:
		<!-- Marsh Production in all the Player's Cities -->
	<Modifiers>
		<Row>
			<ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION</ModifierId>
			<ModifierType>MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER</ModifierType>
		</Row>
		<Row>
			<ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</ModifierId>
			<ModifierType>MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD</ModifierType>
			<SubjectRequirementSetId>PLOT_HAS_MARSH_REQUIREMENTS_LRS</SubjectRequirementSetId>
		</Row>
	</Modifiers>
	<ModifierArguments>
		<!-- Marsh Production in all the Player's Cities -->
		<Row>
			<ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION</ModifierId>
			<Name>ModifierId</Name>
			<Value>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</Value>
		</Row>
		<Row>
			<ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</ModifierId>
			<Name>YieldType</Name>
			<Value>YIELD_PRODUCTION</Value>
		</Row>
		<Row>
			<ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</ModifierId>
			<Name>Amount</Name>
			<Value>3</Value>
		</Row>
	</ModifierArguments>
	<!-- The following Requirement set-ups can be applied to both the Production and Culture Modifiers -->
	<RequirementSets>
		<Row>
			<RequirementSetId>PLOT_HAS_MARSH_REQUIREMENTS_LRS</RequirementSetId>
			<RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
		</Row>
	</RequirementSets>
	<RequirementSetRequirements>
		<Row>
			<RequirementSetId>PLOT_HAS_MARSH_REQUIREMENTS_LRS</RequirementSetId>
			<RequirementId>REQUIRES_PLOT_HAS_MARSH_LRS</RequirementId>
		</Row>
	</RequirementSetRequirements>
	<RequirementArguments>
		<Row>
			<RequirementId>REQUIRES_PLOT_HAS_MARSH_LRS</RequirementId>
			<Name>FeatureType</Name>
			<Value>FEATURE_MARSH</Value>
		</Row>
	</RequirementArguments>
	<Requirements>
		<Row>
			<RequirementId>REQUIRES_PLOT_HAS_MARSH_LRS</RequirementId>
			<RequirementType>REQUIREMENT_PLOT_FEATURE_TYPE_MATCHES</RequirementType>
		</Row>
	</Requirements>
Note that the original modifier attaches a second modifier to all the player's cities. It is the second modifier that actually implements the effect. You would need to duplicate this for the culture effect, except that you would not need to repeat this part for the culture effect since the needed requirements will be the same "Marsh" requirements:
Code:
	<RequirementSets>
		<Row>
			<RequirementSetId>PLOT_HAS_MARSH_REQUIREMENTS_LRS</RequirementSetId>
			<RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
		</Row>
	</RequirementSets>
	<RequirementSetRequirements>
		<Row>
			<RequirementSetId>PLOT_HAS_MARSH_REQUIREMENTS_LRS</RequirementSetId>
			<RequirementId>REQUIRES_PLOT_HAS_MARSH_LRS</RequirementId>
		</Row>
	</RequirementSetRequirements>
	<RequirementArguments>
		<Row>
			<RequirementId>REQUIRES_PLOT_HAS_MARSH_LRS</RequirementId>
			<Name>FeatureType</Name>
			<Value>FEATURE_MARSH</Value>
		</Row>
	</RequirementArguments>
	<Requirements>
		<Row>
			<RequirementId>REQUIRES_PLOT_HAS_MARSH_LRS</RequirementId>
			<RequirementType>REQUIREMENT_PLOT_FEATURE_TYPE_MATCHES</RequirementType>
		</Row>
	</Requirements>
"_LRS" at the end of the various Tags are merely my initials and are there by habit so that my Requirements, etc., cannot be in conflict with someone else's similar requirements, etc. You can delete those characters or better yet change the "LRS" everywhere to your initials. DO NOT add your initials like I have done anywhere I have not done so.
 
Thankyou so much for taking the time to do all of this. I was on the right track with everything, but just struggled with layout and all the requirements, so I cannot say how much I appreciate you ironing all that out for me. Just to clarify for future, where am I able to find modifier types such as
>MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER and
MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD
in the game data files, to use as a reference for further modifiers? As well as all the different Requirement Sets, arguments, etc. Because for example, I wouldn't know if I would need to write PLOT_HAS_MARSH_REQUIREMENT or PLOT_HAS_FEATURE_MARSH_REQUIREMENT.

This is boils down to me being new to modding so even if you could point me in the right direction of a good resource for this stuff that would be great, cause a lot of tutorials I found just go into changing game text and basic stuff. Thanks again.
 
Last edited:
UPDATE: So I have plugged in all the lines of code that you have provided, the solution builds perfectly fine, and the game loads perfectly fine. However, when I settle a city next to marsh tiles, there is no change whatsoever, it still only provides 3 food. Here is what the full code looks like for the trait. Even when I replace the entire code with Russia's Mother Russa trait, and only change the civilization and trait names, it still does not change the tundra tiles. I'm at a loss here.
Code:
    <!--Trait-->
    <Types>
        <Row Type="TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP" Kind="KIND_TRAIT"/>
    </Types>

    <CivilizationTraits>
        <Row CivilizationType="CIVILIZATION_OGRE" TraitType="TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP"/>
    </CivilizationTraits>

    <TraitModifiers>
        <Row>
            <TraitType>TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP</TraitType>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION</ModifierId>
        </Row>
    </TraitModifiers>

    <!--Marsh Production In Player Cities-->
    <Modifiers>
        <Row>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION</ModifierId>
            <ModifierType>MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER</ModifierType>
        </Row>
        <Row>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</ModifierId>
            <ModifierType>MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD</ModifierType>
            <SubjectRequirementSetId>PLOT_HAS_MARSH_REQUIREMENTS</SubjectRequirementSetId>
        </Row>
    </Modifiers>
    <ModifierArguments>
        <Row>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION</ModifierId>
            <Name>ModifierId</Name>
            <Value>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</Value>
        </Row>
        <Row>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</ModifierId>
            <Name>YieldType</Name>
            <Value>YIELD_PRODUCTION</Value>
        </Row>
        <Row>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</ModifierId>
            <Name>Amount</Name>
            <Value>3</Value>
        </Row>
    </ModifierArguments>

    <RequirementSets>
        <Row>
            <RequirementSetId>PLOT_HAS_MARSH_REQUIREMENTS</RequirementSetId>
            <RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
        </Row>
    </RequirementSets>

    <RequirementSetRequirements>
        <Row>
            <RequirementSetId>PLOT_HAS_MARSH_REQUIREMENTS</RequirementSetId>
            <RequirementId>REQUIRES_PLOT_HAS_MARSH</RequirementId>
        </Row>
    </RequirementSetRequirements>

    <RequirementArguments>
        <Row>
            <RequirementId>REQUIRES_PLOT_HAS_MARSH</RequirementId>
            <Name>FeatureType</Name>
            <Value>FEATURE_MARSH</Value>
        </Row>
    </RequirementArguments>

    <Requirements>
        <Row>
            <RequirementId>REQUIRES_PLOT_HAS_MARSH</RequirementId>
            <RequirementType>REQUIREMENT_PLOT_FEATURE_TYPE_MATCHES</RequirementType>
        </Row>
    </Requirements>
 
Last edited:
There are two problems. You've never defined the new trait TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP under table <Traits>.

Your edit to eliminate the "_LRS" characters results in a repeat of part of the code that the game already has
Code:
    <RequirementArguments>
        <Row>
            <RequirementId>REQUIRES_PLOT_HAS_MARSH</RequirementId>
            <Name>FeatureType</Name>
            <Value>FEATURE_MARSH</Value>
        </Row>
    </RequirementArguments>

    <Requirements>
        <Row>
            <RequirementId>REQUIRES_PLOT_HAS_MARSH</RequirementId>
            <RequirementType>REQUIREMENT_PLOT_FEATURE_TYPE_MATCHES</RequirementType>
        </Row>
    </Requirements>
The fact that you did not get shoved back to the main menu leads me to believe you haven't got things set up properly in modbuddy. Likel your code is not even being used by the game.
 
The following code works just fine. Note that I assigned the trait to England for testing purposes:
Code:
<GameData>
    <!--Trait-->
    <Types>
        <Row Type="TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP" Kind="KIND_TRAIT"/>
    </Types>

    <Traits>
        <Row TraitType="TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP" Name="LOC_TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP"/>
    </Traits>
    <CivilizationTraits>
        <Row CivilizationType="CIVILIZATION_ENGLAND" TraitType="TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP"/>
    </CivilizationTraits>

    <TraitModifiers>
        <Row>
            <TraitType>TRAIT_CIVILIZATION_GET_OUT_OF_MY_SWAMP</TraitType>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION</ModifierId>
        </Row>
    </TraitModifiers>

    <!--Marsh Production In Player Cities-->
    <Modifiers>
        <Row>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION</ModifierId>
            <ModifierType>MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER</ModifierType>
        </Row>
        <Row>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</ModifierId>
            <ModifierType>MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD</ModifierType>
            <SubjectRequirementSetId>PLOT_HAS_MARSH_REQUIREMENTS</SubjectRequirementSetId>
        </Row>
    </Modifiers>
    <ModifierArguments>
        <Row>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION</ModifierId>
            <Name>ModifierId</Name>
            <Value>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</Value>
        </Row>
        <Row>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</ModifierId>
            <Name>YieldType</Name>
            <Value>YIELD_PRODUCTION</Value>
        </Row>
        <Row>
            <ModifierId>TRAIT_INCREASED_MARSH_PRODUCTION_MODIFIER</ModifierId>
            <Name>Amount</Name>
            <Value>3</Value>
        </Row>
    </ModifierArguments>

    <RequirementSets>
        <Row>
            <RequirementSetId>PLOT_HAS_MARSH_REQUIREMENTS</RequirementSetId>
            <RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
        </Row>
    </RequirementSets>

    <RequirementSetRequirements>
        <Row>
            <RequirementSetId>PLOT_HAS_MARSH_REQUIREMENTS</RequirementSetId>
            <RequirementId>REQUIRES_PLOT_HAS_MARSH</RequirementId>
        </Row>
    </RequirementSetRequirements>
</GameData>
Since the game already has this code, it is not necessary or desirable to include it:
Code:
    <RequirementArguments>
        <Row>
            <RequirementId>REQUIRES_PLOT_HAS_MARSH</RequirementId>
            <Name>FeatureType</Name>
            <Value>FEATURE_MARSH</Value>
        </Row>
    </RequirementArguments>

    <Requirements>
        <Row>
            <RequirementId>REQUIRES_PLOT_HAS_MARSH</RequirementId>
            <RequirementType>REQUIREMENT_PLOT_FEATURE_TYPE_MATCHES</RequirementType>
        </Row>
    </Requirements>
 
Yeah it is being used, because my unique unit that is within that mod, as well as all the menu text, unique building and all of that is still working. I'll post screenshots to show. All of the changes I've made are within the one solution and mod. So I will quickly add in my initials where necessary and hope that changes things. But I do appreciate the help.
 

Attachments

  • 1.png
    1.png
    622.4 KB · Views: 175
  • 2.png
    2.png
    1.1 MB · Views: 207
  • 3.png
    3.png
    329.3 KB · Views: 171
OK, so I still couldn't get anything to work, so I made a completely empty mod, simply copy and pasting your code in. Opened the game up, chose England, and it still does not affect marsh tiles. I am completely at a loss here.
 
I know this may sound bad, but are you remembering to build the solution, and activate in the additional content menu before starting?
Also, and I know this isn't too relevant to the question, if you want, you can have the ogre's guaranteed to start by swamp with:
<StartBiasFeature>
<Row CivilizationType="CIVILIZATION_OGRE" TerrainType="FEATURE_MARSH" Tier="1"/>
</StartBiasFeature>
Tier is how close you want them, 1 is close, 5 is far.
 
Hahaha yeah, I am building the solution and enabling it but I see where you're coming from. And thanks for that start bias, I did see lines like that in the game files and was going to add it in, but was trying to figure this one out first, but thanks for showing me how!
 
OK, so I still couldn't get anything to work, so I made a completely empty mod, simply copy and pasting your code in. Opened the game up, chose England, and it still does not affect marsh tiles. I am completely at a loss here.
Make sure the file that contains the code is listed under an InGame Actions > UpdateDatabase type of action. I tested and know the last code-chunk I posted works.

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

These kinds of issues are why we generally prefer to be able to look at a zipped copy of the mod as it is in the game's "mods" folder rather than in-game screenshots.


Also, if you have not looked in Database.log for possible error messages related to your mod's files, you need to do so.

C:\Users\[YourUserNameHere]\Documents\My Games\Sid Meier's Civilization VI\Logs/Database.log
 
After using that code you sent and actually building it correctly (forgot to updatedatabase for that one, stupid me), everything is working so far. Thanks for taking the time, I know it can be frustrating dealing with new people so I really appreciate it :) Thanks a lot!!!

Just a quick last question, which of the lines, as in <ModifiersId>, <ModifierType>, etc can I completely name myself and which ones have to be established in the game? For example. For ModifierId, I can call it TRAIT_ANYTHING_I_WANT, but can the same be done for ModifierType? Cause I am trying to change the defence modifier, so can I simply call it <ModifierType>MODIFIER_ADJUST_DEFENCE, or does it have to be called something specific? I hope I explained it properly.
 
Last edited:
Both the short and the long answer is that you have to understand the way the game's database it put together, and the way Firaxis accesses the game's database.

The more-friendly short answer is that <ModifierType> needs to reference exactly to a previously-defined "ModifierType" present within table "DynamicModifiers". We can create our own new "ModifierType" within table "DynamicModifiers", but then we have to use a pre-existing "CollectionType" and "EffectType" that Firaxis has already defined for the game to use, as these last two are always implemented directly at the game's operating-software level, and we cannot add new ones.

The more-friendly long answer is that a look through file 01_GameplaySchema.sql in folder C:\Program Files (x86)\Steam\SteamApps\common\Sid Meier's Civilization VI\Base\Assets\Gameplay\Data\Schema is required. You will find within this file all the definitions and requirements of the various in-game tables. This definition, for example, is how Firaxis has defined table "DistrictModifiers"
Code:
CREATE TABLE "DistrictModifiers" (
		"DistrictType" TEXT NOT NULL,
		"ModifierId" TEXT NOT NULL,
		PRIMARY KEY(DistrictType, ModifierId),
		FOREIGN KEY (DistrictType) REFERENCES Districts(DistrictType) ON DELETE CASCADE ON UPDATE CASCADE,
		FOREIGN KEY (ModifierId) REFERENCES Modifiers(ModifierId) ON DELETE CASCADE ON UPDATE CASCADE);
This definition tells us that within this particular table, the column called "DistrictType" must match exactly to a DistrictType defined within table Districts. That is what this line is doing in the definition:
Code:
FOREIGN KEY (DistrictType) REFERENCES Districts(DistrictType) ON DELETE CASCADE ON UPDATE CASCADE,
Ie, specifying this required relationship.

Table "Modifiers" has the following definition:
Code:
CREATE TABLE "Modifiers" (
		"ModifierId" TEXT NOT NULL,
		"ModifierType" TEXT NOT NULL,
		"RunOnce" BOOLEAN NOT NULL CHECK (RunOnce IN (0,1)) DEFAULT 0,
		"NewOnly" BOOLEAN NOT NULL CHECK (NewOnly IN (0,1)) DEFAULT 0,
		"Permanent" BOOLEAN NOT NULL CHECK (Permanent IN (0,1)) DEFAULT 0,
		"OwnerRequirementSetId" TEXT,
		"SubjectRequirementSetId" TEXT,
		"OwnerStackLimit" INTEGER,
		"SubjectStackLimit" INTEGER,
		PRIMARY KEY(ModifierId),
		FOREIGN KEY (OwnerRequirementSetId) REFERENCES RequirementSets(RequirementSetId) ON DELETE CASCADE ON UPDATE CASCADE,
		FOREIGN KEY (SubjectRequirementSetId) REFERENCES RequirementSets(RequirementSetId) ON DELETE CASCADE ON UPDATE CASCADE);
Column "ModifierId" is not tied to any column within any other game-table, so we can call it anything we want, such as
Code:
<ModifierId>CHEESEBURGERS</ModifierId>
This line tells us however that every new row we add to the table must have a unique tag-name for the "ModifierId" column:
Code:
PRIMARY KEY(ModifierId),
And this line tells us that the "SubjectRequirementSetId" we give (if any) must tie back to a valid "RequirementSetId" listed in table "RequirementSets":
Code:
FOREIGN KEY (SubjectRequirementSetId) REFERENCES RequirementSets(RequirementSetId) ON DELETE CASCADE ON UPDATE CASCADE);
But how do we know that column "ModifierType" must tie back to a valid "ModifierType" in table "DynamicModifiers", since the definition for table "Modifiers" does not state it must?

By experience unfortunately. We've learned as a community that this is required. If we don't tie our "ModifierType" to an existing one already defined in the "DynamicModifiers" table, our "Modifiers" simply fail to execute.
 
LeeS, Although the reply was written many years ago, it is still very valuable for new learner like me. Thank you
 
Last edited:
Top Bottom