1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Modifying tile improvement

Discussion in 'Mod Creation Help' started by Evalyn, Nov 7, 2018.

  1. Evalyn

    Evalyn Chieftain

    Joined:
    Nov 6, 2018
    Messages:
    4
    Hey, so I've been trying to work on creating a custom civ with help from the tutorial at https://forums.civfanatics.com/threads/how-to-create-your-own-civilization.621377/ .
    This is my first attempt at modding civ 6 but it's going pretty well. I've got most of what I want working, but I've been trying to make a civilization trait that changes the yield of farms in the civ.
    I can't seem to figure out what I need to do modifier wise to get it to work.
    Any help would be appreciated.
    Also I don't have Rise & Fall.
     
  2. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,688
    Location:
    Illinois, USA
    Untested but I think this would work:
    Spoiler :
    Code:
    <GameData>
    	<Types>
    		<Row Type="TRAIT_X" Kind="KIND_TRAIT"/>
    	</Types>
    	<Traits>
    		<Row TraitType="TRAIT_X" Name="LOC_TRAIT_X_NAME" Description="LOC_TRAIT_X_DESCRIPTION"/>
    	</Traits>
    	<Modifiers>
    		<Row>
    			<ModifierId>FARMS_INCREASED_FOOD_TRAIT_X</ModifierId>
    			<ModifierType>MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER</ModifierType>
    		</Row>
    		<Row>
    			<ModifierId>FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X</ModifierId>
    			<ModifierType>MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD</ModifierType>
    			<SubjectRequirementSetId>PLOT_HAS_FARM_REQUIRMEMENT_SET</SubjectRequirementSetId>
    		</Row>
    	</Modifiers>
    	<ModifierArguments>
    		<Row>
    			<ModifierId>FARMS_INCREASED_FOOD_TRAIT_X</ModifierId>
    			<Name>ModifierId</Name>
    			<Value>FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X</Value>
    		</Row>
    		<Row>
    			<ModifierId>FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X</ModifierId>
    			<Name>YieldType</Name>
    			<Value>YIELD_FOOD</Value>
    		</Row>
    		<Row>
    			<ModifierId>FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X</ModifierId>
    			<Name>Amount</Name>
    			<Value>1</Value>
    		</Row>
    	</ModifierArguments>
    	<Requirements>
    		<Row>
    			<RequirementId>PLOT_HAS_A_FARM_REQUIREMENT</RequirementId>
    			<RequirementType>REQUIREMENT_PLOT_IMPROVEMENT_TYPE_MATCHES</RequirementType>
    		</Row>
    	</Requirements>
    	<RequirementArguments>
    		<Row>
    			<RequirementId>PLOT_HAS_A_FARM_REQUIREMENT</RequirementId>
    			<Name>ImprovementType</Name>
    			<Value>IMPROVEMENT_FARM</Value>
    		</Row>
    	</RequirementArguments>
    	<RequirementSets>
    		<Row>
    			<RequirementSetId>PLOT_HAS_FARM_REQUIRMEMENT_SET</RequirementSetId>
    			<RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
    		</Row>
    	</RequirementSets>
    	<RequirementSetRequirements>
    		<Row>
    			<RequirementSetId>PLOT_HAS_FARM_REQUIRMEMENT_SET</RequirementSetId>
    			<RequirementId>PLOT_HAS_A_FARM_REQUIREMENT</RequirementId>
    		</Row>
    	</RequirementSetRequirements>
    	<TraitModifiers>
    		<Row TraitType="TRAIT_X" ModifierId="FARMS_INCREASED_FOOD_TRAIT_X"/>
    	</TraitModifiers>
    	<LeaderTraits>
    		<Row LeaderType="LEADER_X" TraitType="TRAIT_X"/>
    	<LeaderTraits>
    </GameData>
    You will want to change LEADER_X to the appropriate name for your leader, and you will want to change TRAIT_X to the primary trait-name your leader uses.

    You can also make it an inherent ability of the civ instead simply by changing from using the <LeaderTraits> table to the <CivilizationTraits> table and giving the name of your civ instead of the name of a leader.

    If you want production instead you change the yield to YIELD_PRODUCTION. But if you want more than one yield you will need to create seperate modifier set-ups for each yield, and add each of those to the TraitModifiers as the simplest way to go about it.
     
  3. Evalyn

    Evalyn Chieftain

    Joined:
    Nov 6, 2018
    Messages:
    4
    Thanks! I'm trying to figure out how to implement that in the SQL files that the template I'm trying to follow uses, I'll let you know if it works as soon as I can figure this file out!
     
  4. Evalyn

    Evalyn Chieftain

    Joined:
    Nov 6, 2018
    Messages:
    4
    Not sure if this works or not. I know that I couldn't get it to work, but I can't figure out how to get any traits to work properly.
    I've tried to use the SQL files from the template I originally linked, I've tried to unravel it and make XML files since they make more sense currently. I also found this thread called SQL modding for dummies! (specially those that still use XML).
    I tried to use the advice from that to convert this into a SQL formatted trait, though it is from civ 5 so I don't know if that's incompatible advice.
    The SQL I made from it is here.
    Spoiler :


    INSERT INTO Types
    (Type, Kind)
    VALUES ('TRAIT_X', 'KIND_TRAIT);

    --
    INSERT INTO Traits
    (TraitType, Name, Description)
    VALUES ('TRAIT_X', 'LOC_TRAIT_X_NAME', 'LOC_TRAIT_X_DESCRIPTION');

    --
    INSERT INTO TraitModifiers
    (ModifierId, ModifierType, SubjectRequirementSetId);
    VALUES ('FARMS_INCREASED_FOOD_TRAIT_X', 'MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER'),
    ('FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X', 'MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD', 'PLOT_HAS_FARM_REQUIRMEMENT_SET');

    --
    INSERT INTO ModifierArguements
    (ModifierId, Name, Value);
    VALUES ('FARMS_INCREASED_FOOD_TRAIT_X', 'ModifierId', 'FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X'),
    ('FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X', 'YieldType', 'YIELD_FOOD'),
    ('FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X', 'Amount', '1'),

    --
    INSERT INTO Requirements
    (RequirementId, RequirementType);
    VALUES ('PLOT_HAS_FARM_REQUIRMEMENT', 'REQUIREMENT_PLOT_IMPROVEMENT_TYPE_MATCHES');

    --
    INSERT INTO RequirementArguements
    (RequirementId, Name, Value);
    VALUES ('PLOT_HAS_A_FARM_REQUIREMENT', 'ImprovementType', 'IMPROVEMENT_FARM',);

    --
    INSERT INTO RequirementSets
    (RequirementSetId, RequirementSetType);
    VALUES ('PLOT_HAS_FARM_REQUIRMEMENT_SET', 'REQUIREMENTSET_TEST_ALL');

    --
    INSERT INTO RequirementSetRequirements
    (RequirementSetId, RequirementId);
    VALUES ('PLOT_HAS_FARM_REQUIRMEMENT_SET', 'PLOT_HAS_A_FARM_REQUIREMENT');

    --
    INSERT INTO TraitModifiers
    (TraitType, ModifierId);
    VALUES ('TRAIT_X', 'FARMS_INCREASED_FOOD_TRAIT_X');

    --
    INSERT INTO LeaderTraits
    (LeaderType, TraitType)
    VALUES ('LEADER_X', 'TRAIT_X');
    --------------------------------------------------------------------------------------------------------------------------



    So thanks for trying, I'm just sorta at the end of my rope and don't know what to do.
    I would like to figure this out so I can make ANY working civilization.
     
    Last edited: Nov 9, 2018
  5. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,688
    Location:
    Illinois, USA
    Code:
    INSERT INTO TraitModifiers
     (ModifierId, ModifierType, SubjectRequirementSetId);
     VALUES ('FARMS_INCREASED_FOOD_TRAIT_X', 'MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER'),
     ('FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X', 'MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD', 'PLOT_HAS_FARM_REQUIRMEMENT_SET');
    You have two three problems.
    1. It needs to be table Modifiers rather than table TraitModifiers. Table TraitModifiers is used to assign a Modifier to a Trait, not to define the Modifier.
    2. You have an incorrect extra ";" in the middle of the code-chunk here at the end of this line
      Code:
      (ModifierId, ModifierType, SubjectRequirementSetId);
    3. You only have two "values" given on the first line
      Code:
      ('FARMS_INCREASED_FOOD_TRAIT_X', 'MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER'),
      but you've told the database you are going to give values for three columns on all your lines of "INSERT INTO"
      Code:
       (ModifierId, ModifierType, SubjectRequirementSetId);
    Change to
    Code:
    INSERT INTO Modifiers
     (ModifierId, ModifierType, SubjectRequirementSetId)
     VALUES ('FARMS_INCREASED_FOOD_TRAIT_X', 'MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER', null),
     ('FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X', 'MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD', 'PLOT_HAS_FARM_REQUIRMEMENT_SET');
    "null" in SQL is when no data is needed for a specific column for a given row "INSERT"

    The result of your syntax errors is that the game stops reading anything within the file upon encountering the first fatal syntax error. You had three in that chunk of code. I did not look to see if you have errors of a similar sort elsewhere in the code.

    I've tested the XML version of the code and know it to work. Any troubles you are having are in translation to SQL.
     
    Last edited: Nov 12, 2018
  6. Evalyn

    Evalyn Chieftain

    Joined:
    Nov 6, 2018
    Messages:
    4
    Thanks again for your help!

    So, I followed your advice. I checked for all three problems.
    I fixed the TraitModifiers line into Modifiers.
    I checked the whole thing for both the mistake of an extra ";" and made sure all the lines had the proper ending as well as verifying all the tags had 'these' around them properly.

    I then fixed the code to include the null as you said.

    After that I plugged the edited code in to the GameDefines SQL file.

    This time the civilization was able to actually launch, but still did not have the bonus food that the trait should be giving.

    I went through and checked the references in the other files as well as in the rest of the game defines file, correcting them as needed, checking after the changes to make sure if it was working or not. After that I verified that the trait that was originally in the template was working to make sure that it was properly loading any traits, finding that to work.

    After that I checked the code again, but still no luck

    One weird thing throughout all of this is that when the civilization was loading, all the custom information about the civilization disappeared. So trying to follow that thread I checked the references in the GameText file, which isn't SQL (further compounding confusion thanks to this template), All of the text references seemed correct from what I could tell. I also checked the Config file, the references in that file seemed correct as well.

    So in the end, the corrected code looks like this
    Spoiler :


    INSERT INTO Types
    (Type, Kind)
    VALUES ('TRAIT_X', 'KIND_TRAIT');

    --------------------------------------------------------------------------------------------------------------------------
    INSERT INTO Traits
    (TraitType, Name, Description)
    VALUES ('TRAIT_X', 'LOC_TRAIT_X_NAME', 'LOC_TRAIT_X_DESCRIPTION');

    --------------------------------------------------------------------------------------------------------------------------
    INSERT INTO Modifiers
    (ModifierId, ModifierType, SubjectRequirementSetId)
    VALUES ('FARMS_INCREASED_FOOD_TRAIT_X', 'MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER' null),
    ('FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X', 'MODIFIER_CITY_PLOT_YIELDS_ADJUST_PLOT_YIELD', 'PLOT_HAS_FARM_REQUIRMEMENT_SET');

    --------------------------------------------------------------------------------------------------------------------------
    INSERT INTO ModifierArguements
    (ModifierId, Name, Value)
    VALUES ('FARMS_INCREASED_FOOD_TRAIT_X', 'ModifierId', 'FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X'),
    ('FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X', 'YieldType', 'YIELD_FOOD'),
    ('FARMS_PLUS_1_FOOD_MODIFIER_TRAIT_X', 'Amount', '1');

    --------------------------------------------------------------------------------------------------------------------------
    INSERT INTO Requirements
    (RequirementId, RequirementType)
    VALUES ('PLOT_HAS_FARM_REQUIRMEMENT', 'REQUIREMENT_PLOT_IMPROVEMENT_TYPE_MATCHES');

    --------------------------------------------------------------------------------------------------------------------------
    INSERT INTO RequirementArguements
    (RequirementId, Name, Value)
    VALUES ('PLOT_HAS_A_FARM_REQUIREMENT', 'ImprovementType', 'IMPROVEMENT_FARM',);

    --------------------------------------------------------------------------------------------------------------------------
    INSERT INTO RequirementSets
    (RequirementSetId, RequirementSetType)
    VALUES ('PLOT_HAS_FARM_REQUIRMEMENT_SET', 'REQUIREMENTSET_TEST_ALL');

    --------------------------------------------------------------------------------------------------------------------------
    INSERT INTO RequirementSetRequirements
    (RequirementSetId, RequirementId)
    VALUES ('PLOT_HAS_FARM_REQUIRMEMENT_SET', 'PLOT_HAS_A_FARM_REQUIREMENT');

    --------------------------------------------------------------------------------------------------------------------------
    INSERT INTO TraitModifiers
    (TraitType, ModifierId)
    VALUES ('TRAIT_X', 'FARMS_INCREASED_FOOD_TRAIT_X');

    --------------------------------------------------------------------------------------------------------------------------
    INSERT INTO LeaderTraits
    (LeaderType, TraitType)
    VALUES ('LEADER_X', 'TRAIT_X');
    --------------------------------------------------------------------------------------------------------------------------

     
  7. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,688
    Location:
    Illinois, USA
    Code:
    VALUES ('FARMS_INCREASED_FOOD_TRAIT_X', 'MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER' null),
    You're missing a comma between 'MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER' and null. Database.log would have reported this syntax error. You can't usefully test anything in-game if you have database syntax errors.

    Use "code" instead of "spoiler" to wrap your code on the forum. It's much easier to read code in a code-box than in a spoiler.
     

Share This Page