Combat boost on forest ability, and now: Questions I Couldn't Find the Answers for by Searching

earlc

Warlord
Joined
Jun 9, 2017
Messages
113
Old first post:
Spoiler :
I'm a newbie to modding. I've been able to figure out and troubleshoot a bunch by copying others, but now I'm trying to add a leader ability to a custom civ/leader that gives a combat bonus to all units on rainforests, forests and marshes. I was using America's home continent ability and the rough rider's hills bonus as a model, with the main difference being that hills are considered a terrain type, and forests/jungles/marshes are all considered features by the game. So for those I looked at Brazil's adjacency bonuses and crossed my fingers.

Now I get booted out whenever trying to start a new game. Here's the code I'm attempting:
Code:
--==========================================================================================================================
-- LEADERS: TRAITS
--==========================================================================================================================
-- Types
--------------------------------------------------------------------------------------------------------------------------
INSERT INTO Types
        (Type,                                                        Kind)
VALUES    ('TRAIT_OSCEOLA_EVERGLADES',                        'KIND_TRAIT');
--------------------------------------------------------------------------------------------------------------------------        
-- Traits        
--------------------------------------------------------------------------------------------------------------------------            
INSERT INTO Traits            
        (TraitType,                                                    Name,                                                    Description)
VALUES    ('TRAIT_OSCEOLA_EVERGLADES',                        'LOC_TRAIT_OSCEOLA_EVERGLADES_NAME',            'LOC_TRAIT_OSCEOLA_EVERGLADES_DESCRIPTION');
--------------------------------------------------------------------------------------------------------------------------    
-- TraitModifiers    
--------------------------------------------------------------------------------------------------------------------------        
INSERT INTO TraitModifiers        
        (TraitType,                                                    ModifierId)
VALUES    ('TRAIT_OSCEOLA_EVERGLADES',                        'OSCEOLA_EVERGLADES_COMBAT_BONUS'),
        ('TRAIT_OSCEOLA_EVERGLADES',                        'OSCEOLA_EVERGLADES_COMBAT_BONUS_MODIFIER');
--------------------------------------------------------------------------------------------------------------------------
-- Modifiers
--------------------------------------------------------------------------------------------------------------------------
INSERT INTO Modifiers
        (ModifierId,                                                ModifierType,                            OwnerRequirementSetId,                    SubjectRequirementSetId)
VALUES    ('OSCEOLA_EVERGLADES_COMBAT_BONUS',                        'MODIFIER_PLAYER_UNITS_ATTACH_MODIFIER',    null,                                null),
        ('OSCEOLA_EVERGLADES_COMBAT_BONUS_MODIFIER',            'MODIFIER_UNIT_ADJUST_COMBAT_STRENGTH',        'REQUIREMENTS_UNIT_LAND_DOMAIN',    'REQUIRE_UNIT_FEATURE_MARSH_FOREST');
--------------------------------------------------------------------------------------------------------------------------
-- ModifierArguments
--------------------------------------------------------------------------------------------------------------------------
INSERT INTO ModifierArguments
        (ModifierId,                                                Name,            Value)
VALUES    ('OSCEOLA_EVERGLADES_COMBAT_BONUS',                        'ModifierId',        'OSCEOLA_EVERGLADES_COMBAT_BONUS_MODIFIER'),
        ('OSCEOLA_EVERGLADES_COMBAT_BONUS',                        'Amount',            7);
--------------------------------------------------------------------------------------------------------------------------
-- RequirementSets
--------------------------------------------------------------------------------------------------------------------------
INSERT INTO RequirementSets
        (RequirementSetId,            RequirementSetType)
VALUES    ('REQUIRE_UNIT_FEATURE_MARSH_FOREST',                        'REQUIREMENTSET_TEST_ALL');
--------------------------------------------------------------------------------------------------------------------------
-- RequirementSetRequirements
--------------------------------------------------------------------------------------------------------------------------
INSERT INTO RequirementSetRequirements
        (RequirementSetId,                                RequirementId)
VALUES    ('REQUIRE_UNIT_FEATURE_MARSH_FOREST',        'PLOT_IS_FOREST_FEATURE_REQUIREMENT'),
        ('REQUIRE_UNIT_FEATURE_MARSH_FOREST',        'PLOT_IS_RAINFOREST_FEATURE_REQUIREMENT'),
        ('REQUIRE_UNIT_FEATURE_MARSH_FOREST',        'PLOT_IS_MARSH_FEATURE_REQUIREMENT');
--------------------------------------------------------------------------------------------------------------------------
-- Requirements
--------------------------------------------------------------------------------------------------------------------------
INSERT INTO Requirements
        (RequirementId,                                    RequirementType)
VALUES    ('PLOT_IS_FOREST_FEATURE_REQUIREMENT',            'REQUIREMENT_PLOT_FEATURE_TYPE_MATCHES'),
        ('PLOT_IS_RAINFOREST_FEATURE_REQUIREMENT',        'REQUIREMENT_PLOT_FEATURE_TYPE_MATCHES'),
        ('PLOT_IS_MARSH_FEATURE_REQUIREMENT',            'REQUIREMENT_PLOT_FEATURE_TYPE_MATCHES');
--------------------------------------------------------------------------------------------------------------------------
-- RequirementArgumets
--------------------------------------------------------------------------------------------------------------------------
INSERT INTO RequirementArguments
        (RequirementId,                                    Name,            Value)
VALUES    ('PLOT_IS_FOREST_FEATURE_REQUIREMENT',            'FeatureType'    'FEATURE_FOREST'),
        ('PLOT_IS_RAINFOREST_FEATURE_REQUIREMENT',        'FeatureType'    'FEATURE_JUNGLE'),
        ('PLOT_IS_MARSH_FEATURE_REQUIREMENT',            'FeatureType'    'FEATURE_MARSH');
And here is my database log. I'm getting a syntax error by FEATURE_FOREST, but I don't understand why.
Code:
[3846476.701] [Localization]: Validating Foreign Key Constraints...
[3846476.703] [Localization]: Passed Validation.
[3846476.723] [Configuration]: Validating Foreign Key Constraints...
[3846476.723] [Configuration]: Passed Validation.
[3846490.634] [FullTextSearch]: Initializing FullTextSearch
[3846490.941] [Gameplay]: Validating Foreign Key Constraints...
[3846490.950] [Gameplay]: Passed Validation.
[3846491.364] [Configuration] ERROR: no such table: Types
[3846491.364] [Configuration]: In Query - insert into Types('Type', 'Kind') values (?, ?);
[3846491.364] [Configuration]: In XMLSerializer while updating table Types from file Template_Buildings.xml.
[3846491.364] [Configuration] ERROR: no such table: Types
[3846491.364] [Configuration]: In Query - insert into Types('Type', 'Kind') values (?, ?);
[3846491.364] [Configuration]: In XMLSerializer while updating table Types from file Template_Units.xml.
[3846491.364] [Configuration]: Validating Foreign Key Constraints...
[3846491.365] [Configuration]: Passed Validation.
[3846509.458] [FullTextSearch]: FTS - Creating Context
[3846520.287] [Configuration] ERROR: no such table: Types
[3846520.287] [Configuration]: In Query - insert into Types('Type', 'Kind') values (?, ?);
[3846520.287] [Configuration]: In XMLSerializer while updating table Types from file Template_Buildings.xml.
[3846520.287] [Configuration] ERROR: no such table: Types
[3846520.287] [Configuration]: In Query - insert into Types('Type', 'Kind') values (?, ?);
[3846520.287] [Configuration]: In XMLSerializer while updating table Types from file Template_Units.xml.
[3846520.354] [Configuration]: Validating Foreign Key Constraints...
[3846520.354] [Configuration]: Passed Validation.
[3846523.204] [Gameplay] ERROR: near "'FEATURE_FOREST'": syntax error
[3846523.205] [Gameplay] ERROR: FOREIGN KEY constraint failed
[3846523.205] [Gameplay] ERROR: FOREIGN KEY constraint failed
[3846523.205] [Gameplay]: Validating Foreign Key Constraints...
[3846523.206] [Gameplay] ERROR: Invalid Reference on Buildings.TraitType - "TRAIT_CIVILIZATION_BUILDING_TEMP_CUSTOM" does not exist in Traits
[3846523.213] [Gameplay] ERROR: Invalid Reference on Units.TraitType - "TRAIT_CIVILIZATION_UNIT_TUSTENU" does not exist in Traits
[3846523.214] [Gameplay]: Failed Validation.
[3846523.230] [Gameplay]: Validating Foreign Key Constraints...
[3846523.239] [Gameplay]: Passed Validation.
[3846524.376] [FullTextSearch]: FTS - Creating Context
[3846524.465] [Configuration] ERROR: no such table: Types
[3846524.465] [Configuration]: In Query - insert into Types('Type', 'Kind') values (?, ?);
[3846524.465] [Configuration]: In XMLSerializer while updating table Types from file Template_Buildings.xml.
[3846524.465] [Configuration] ERROR: no such table: Types
[3846524.465] [Configuration]: In Query - insert into Types('Type', 'Kind') values (?, ?);
[3846524.465] [Configuration]: In XMLSerializer while updating table Types from file Template_Units.xml.
[3846524.465] [Configuration]: Validating Foreign Key Constraints...
[3846524.465] [Configuration]: Passed Validation.
[3846529.571] [FullTextSearch]: FullTextSearch - Shutting down
I figure the invalid references are unrelated, probably stemming from using a template and not resolving all the tags. I think it all worked before I tried this LA though. I have no idea what the "types" errors are, but again, those didn't stop the game from starting before.

Hopefully it's an easy, dumb mistake?
 
Last edited:
Neither file Template_Buildings.xml nor Template_Units.xml should be shown in <FrontEndActions> in the modinfo file. The code they contain is not allowed in the <FrontEndActions> for game set-up datas. This has been the main problem with the template you are using since it was first created. It does not actually hurt anything per se to have these files shown within a <FrontEndActions> <UpdateDatabase> action except in that
  1. it teaches bad habits
  2. it kludges and clutters the output of Database.log and Modding.log unnecessarily
The InvalidReference errors are in fact what are shoving you back to the main menu. Whenever Database.log shows an InvalidReference error this is a signal to you to find the root cause of this issue and eliminate it. Also whenever Database.log shows an InvalidReference error this shoves you back to the main menu.

The root cause for why you are getting InvalidReference errors is because you have a Syntax error in an SQL file.
Code:
[3846523.204] [Gameplay] ERROR: near "'FEATURE_FOREST'": syntax error
SQL files however do not generate a message telling you which file is creating the error. This is a second fundamental error in the construction of the template you are using. If a person needs to use a template to create a mod because they are not yet versed and experienced in modding civ6, it is a fundamentally flawed approach to use SQL simply because trouble-shooting a broken mod is many times more difficult when using SQL files.

If you do not know which SQL file contains the code with the syntax error, then you need to compare the timestamp in the error message ([3846523.204]) to the timestamps in Modding.log to determine which file or files the game was attempting to load at or just before an equivalent timestamp.

When the game encounters a fatal syntax error in either an XML file or an SQL file, the game ceases to read anything further from within the same file. Anything lower down in the same file therefore does not "exist" so far as the game is concerned, and can therefore cascade and cause the errors you are seeing for the Invalid References.
 
Ah, thanks a bunch for clearing those up! And yeah, after I learned a little more about modding this game I found the xml/sql split of the template pretty odd and counterintuitive. Next time around I'll just use XML, as I've seen so many others do successfully. I'm very close with this one though, so I'm going to try to wrap it up as it is.

SQL files however do not generate a message telling you which file is creating the error. This is a second fundamental error in the construction of the template you are using. If a person needs to use a template to create a mod because they are not yet versed and experienced in modding civ6, it is a fundamentally flawed approach to use SQL simply because trouble-shooting a broken mod is many times more difficult when using SQL files.

If you do not know which SQL file contains the code with the syntax error, then you need to compare the timestamp in the error message ([3846523.204]) to the timestamps in Modding.log to determine which file or files the game was attempting to load at or just before an equivalent timestamp.

When the game encounters a fatal syntax error in either an XML file or an SQL file, the game ceases to read anything further from within the same file. Anything lower down in the same file therefore does not "exist" so far as the game is concerned, and can therefore cascade and cause the errors you are seeing for the Invalid References.
Fortunately this ramshackle template only comes with two SQL files, and I do know which it is - the only place in the entire solution I use 'FEATURE_FOREST', which I copied into the code above. That part comes at the very end, where I'm trying to set the RequirementArguments for applying the +7 combat bonus. But I'm not sure what the syntax issue is. I thought someone might be able to tell just by looking at the code I've attempted.
 
You are missing the needed comma seperators between 'FeatureType' and 'FEATURE_FOREST', etc. in this insert block
Code:
INSERT INTO RequirementArguments
        (RequirementId,                                    Name,            Value)
VALUES    ('PLOT_IS_FOREST_FEATURE_REQUIREMENT',            'FeatureType'    'FEATURE_FOREST'),
        ('PLOT_IS_RAINFOREST_FEATURE_REQUIREMENT',        'FeatureType'    'FEATURE_JUNGLE'),
        ('PLOT_IS_MARSH_FEATURE_REQUIREMENT',            'FeatureType'    'FEATURE_MARSH');
 
Ohhh haha. I was so wrapped up in my gamble whether "FeatureType" and FEATURE_FOREST would even be recognized that I completely overlooked that and didn't even notice on subsequent reviews! Thanks again for the help.

So now the game starts fine and neither log file returns any errors. The LA doesn't actually appear to work though, or at least the game doesn't say it's working when I try to enter combat. Hmm. Going to have to take a deeper look at this to figure it out
 
So I noticed I had REQUIREMENTSET_TEST_ALL where it should have been _ANY, which should have been obvious enough. But I can't check to see if it works, because I was renaming some icon files and tags, and now the game crashes to desktop during the loading screen with your civ and leader that leads into gameplay.

Here's the modbuddy file if anyone can help: https://www.dropbox.com/s/9dwfppzrwo28dpc/Seminole.rar?dl=0

Unfortunately none of the typical log files turned up any errors.

I'm finding this game's modding ability (pertaining to something that should be as simple as adding a new civ and leader) pretty irritating. I have the writing, history, and graphics chops to make a quality custom civ (the leader graphics in the dropbox file are sloppy stand-ins btw), and I have a little coding ability from many years ago, but this has still become far more difficult and convoluted than I had anticipated. Seems like something that really could have been streamlined for users to plug in their icons, leader art and text, and do a little coding of custom abilities and the like. Hopefully someone can help with this or I can continue to poke around and try to figure it out, or I'm going to have to either start over or just abandon this altogether.
 
Did you ever get this working? I'm working on a similar project (attempting to add a leader trait that gives all units a combat bonus on Forest tiles).
 
This should be very straightforward, but you seem to have made several small errors that each prevent the whole thing from functioning, which may be confusing you. I will assume you are still using the code you posted further up.

1) Your first modifier is supposed to assign your second modifier to all of the player's units (hence why it is called MODIFIER_PLAYER_UNITS_ATTACH_MODIFIER). The second modifier only works for an individual unit. Only the first modifier needs to be assigned to the Civ's trait. I'm not sure if assigning the second one does anything harmful, but it is certainly unnecessary. So you can remove it from TraitModifiers (and of course move your semicolon to the end of the line before it, as that will now be the end of your statement)

2) Your OwnerRequirements and SubjectRequirements are weird. Owner Requirements are checking whatever is *assigning* the modifier, while Subject Requirements check the *target*. So in the case of the ones you've written, the Owner Requirement is trying to check itself but so is the Subject Requirement. I'm not sure if what you have will work, but you'd be much better off putting both together into one Set and making it a Subject Requirement of your *first* modifier, where it is trying to target each individual unit. That way is sure to work.

3) Your problem might just be that your requirement set wants ALL the conditions to be true, instead of ANY. Obviously, the unit will never be on a tile that is forest, rainforest, AND marsh at the same time.

I know nothing about art files so I can't help you there, sorry.

Edit: And as LeeS mentioned, missing commas.
 
Top Bottom