AC's assorted code questions

acbooster

Chieftain
Joined
Jul 28, 2017
Messages
15
Okay so I started poking around in the game files to understand how everything works and came across a bonus I didn't quite understand in the Civilizations.xml file

<Row>
<ModifierId>TRAIT_BUILDERPRODUCTION</ModifierId>
<ModifierType>MODIFIER_PLAYER_UNITS_ADJUST_UNIT_PRODUCTION</ModifierType>
</Row>

It references the following lines later on in the file

<Row>
<ModifierId>TRAIT_BUILDERPRODUCTION</ModifierId>
<Name>UnitType</Name>
<Value>UNIT_BUILDER</Value>
</Row>
<Row>
<ModifierId>TRAIT_BUILDERPRODUCTION</ModifierId>
<Name>Amount</Name>
<Value>100</Value>
</Row>

What my question is: What does this trait do? The way I'm seeing it is that it's increasing production for Builders.

Since I know I'm gonna have a LOT of questions as I learn how it all works, I'm gonna keep them all here
 
The trait you found isn't assigned to any civilization (at least not in Civilizations.xml), but the ModifierType is all over the place. An easy place to find it is in the Policies.xml file, in relation to the Colonization policy. Looking at the text of the Colonization policy, this ModifierType is used to grant a percent bonus to Production when a city produces a unit of the given UnitType, the value of the percentage being the given Amount. If you attached this trait to your Civ, it would give a civ-wide +100% bonus Production when producing Builders.

Going deeper into Modifiers and everything, if you wanted to take that effect, but, for example, only apply it to cities with a given building, then you could dive into the Modifiers.xml file, search up 'MODIFIER_PLAYER_UNITS_ADJUST_UNIT_PRODUCTION', find the associated Collection and Effect, and either find a Modifier with the same Effect but appropriate Collection, or make your OWN DynamicModifier entry with the relevant Collection and Effect.
 
Awesome, thanks. I'm attaching a modifier like that to a district replacement, a Harbor replacement that boosts the production of some Naval units. I think I have a good method down to start knocking something together from the sample, I just need to remember to be consistent with my elements
 
Okay so a follow-up to that one. Is there a Collection that's more general than, say, "ATOMIC_NAVAL_RANGED"? This district is going to give +10% production to all naval units, so I want to be able to cut down on lines when I can

Oh and one other thing. When looking at the Policies.xml for templating, I noticed something. All of the policies that boost military unit production have the additional line <Extra>-1</Extra> on it. What does this line do?
 
Last edited:
Okay so I went a little smaller to start with instead and am making a new building replacement for a specific civ that already exists. I started with the ModBuddy template for a building and make all the adjustments, added some traits, all that stuff. Everything works fine, except I'm trying to make it exclusively for France. I added in a new .xml file to the Solution with the following:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<GameData>
    <Types>
        <Row Type="TRAIT_CIVILIZATION_BUILDING_ANCIENT_MYSTERY" Kind="KIND_TRAIT"/>
    </Types>
    <Traits>
        <Row TraitType="TRAIT_CIVILIZATION_BUILDING_ANCIENT_MYSTERY" Name="LOC_TRAIT_CIVILIZATION_BUILDING_ANCIENT_MYSTERY_NAME"/>
    </Traits>
    <CivilizationTraits>
        <Row CivilizationType="CIVILIZATION_FRANCE" TraitType="TRAIT_CIVILIZATION_BUILDING_ANCIENT_MYSTERY"/>
    </CivilizationTraits>
</GameData>

This doesn't seem to make it exclusively for France, as it shows up for other Civs when I go to play them. What should I be doing instead?
 
have you attached the trait to the building? Ex:
Code:
		<Row BuildingType="BUILDING_ROMAN_FORUM"
			Name="LOC_BUILDING_ROMAN_FORUM_NAME"
			Description="LOC_BUILDING_ROMAN_FORUM_DESCRIPTION"
			PrereqDistrict="DISTRICT_CITY_CENTER"
			Cost="65"
			PurchaseYield="YIELD_GOLD"
			AdvisorType="ADVISOR_GENERIC"
			Entertainment="1"
			Maintenance="0"
			TraitType="TRAIT_CIVILIZATION_BUILDING_ROMAN_FORUM"/>
have you forgotten to tell modbuddy it needs to add the file to the list for <UpdateDatabase> ?

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

There are just too many errors you could be making to guess which of them you are making, which is why it is always better to zip the mod as it is in the game's MODS folder, and attach the zip to a post.
 
I knew I was forgetting something, I had an empty Requirements tag in the building file that I meant to fill in once I found the right way to format it.

Code:
<?xml version="1.0" encoding="utf-8" ?>
<GameData>
  <Types>
    <Row Type="BUILDING_ANCIENT_MYSTERY" Kind="KIND_BUILDING" />
  </Types>
    <BuildingReplaces>
        <Row CivUniqueBuildingType="BUILDING_ANCIENT_MYSTERY" ReplacesBuildingType="BUILDING_LIBRARY"/>
    </BuildingReplaces>
  <Buildings>
    <Row BuildingType="BUILDING_ANCIENT_MYSTERY" Name="LOC_BUILDING_ANCIENT_MYSTERY_NAME" PrereqTech="TECH_WRITING" PrereqDistrict="DISTRICT_CAMPUS" PurchaseYield="YIELD_GOLD" Cost="100" AdvisorType="ADVISOR_TECHNOLOGY"/>
  </Buildings>
  <Building_YieldChanges>
    <Row BuildingType="BUILDING_ANCIENT_MYSTERY" YieldType="YIELD_SCIENCE" YieldChange="100"/>
  </Building_YieldChanges>
  <Building_GreatPersonPoints>
    <Row BuildingType="BUILDING_ANCIENT_MYSTERY" GreatPersonClassType="GREAT_PERSON_CLASS_SCIENTIST" PointsPerTurn="50"/>
  </Building_GreatPersonPoints>
    <Building_GreatWorks>
        <Row BuildingType="BUILDING_ANCIENT_MYSTERY" GreatWorkSlotType="GREATWORKSLOT_WRITING" NumSlots="3"/>
    </Building_GreatWorks>
    <Requirements>
        <Row>
            
        </Row>
    </Requirements>
</GameData>

To fill in the empty row, I think I need to use <Row BuildingType="BUILDING_ANCIENT_MYSTERY" TraitType="TRAIT_CIVILIZATION_BUILDING_ANCIENT_MYSTERY"/>

Is this right?
 
Code:
  <Buildings>
    <Row BuildingType="BUILDING_ANCIENT_MYSTERY" Name="LOC_BUILDING_ANCIENT_MYSTERY_NAME"
 PrereqTech="TECH_WRITING" PrereqDistrict="DISTRICT_CAMPUS"
 PurchaseYield="YIELD_GOLD" Cost="100"
 AdvisorType="ADVISOR_TECHNOLOGY"
 TraitType="TRAIT_CIVILIZATION_BUILDING_ANCIENT_MYSTERY"/>
  </Buildings>
You don't use table <Requirements> to make a building unique to a leader or civ
 
Ohhhh okay, that makes more sense lol. Thanks! I want to start making mods that add entire civs, but I figure I should start small and learn how to write working files for all the components first. Next up is gonna be Units.
 
Okay so I ran into a problem with making the unit. The game will go to start, go to a black screen with "Start Game" in the center, and kick back to the main menu. When I checked the Database log, the only issues were in Gameplay:

[Gameplay] ERROR: table Units has no column named Row
[2424737.923]
[Gameplay]: In Query - insert into Units('Row') values (?);
[2424737.923]
[Gameplay]: In XMLSerializer while updating table Units from file NewUnit_Gameplay.xml.
[2424737.923]
[Gameplay] ERROR: FOREIGN KEY constraint failed
[2424737.923]
[Gameplay] ERROR: FOREIGN KEY constraint failed
[2424737.923]
[Gameplay]: Validating Foreign Key Constraints...
[2424737.938]
[Gameplay] ERROR: Invalid Reference on UnitReplaces.CivUniqueUnitType - "UNIT_BRAZILIAN_BOPERATIVES" does not exist in Units
[2424737.939]
[Gameplay]: Failed Validation.
[2424737.966]
[Gameplay]: Validating Foreign Key Constraints...
[2424737.982]
[Gameplay]: Passed Validation.
[2424740.590]

I'm not sure how to fix this.
 

Attachments

  • Test Unit.rar
    4.4 KB · Views: 32
UNIT_BRAZILIAN_BOPERATIVES did not successfully get added into table <Units> and therefore creates an invalid reference error.

Invalid reference errors always cause return to the main menu

Your basic problem is being reported here:
Code:
[Gameplay] ERROR: table Units has no column named Row
 [2424737.923] [Gameplay]: In Query - insert into Units('Row') values (?);
[2424737.923] [Gameplay]: In XMLSerializer while updating table Units from file NewUnit_Gameplay.xml.
You have a fatal syntax error in your file NewUnit_Gameplay.xml. This fatal syntax error then causes the Invalid Reference error, which then causes the return to the main menu

You can't have <Row> within an already open <Row> as you have here:
Code:
  <Units>
    <Row>
		<Row UnitType="UNIT_BRAZILIAN_BOPERATIVES" BaseMoves="5" Cost="380" AdvisorType="ADVISOR_CONQUEST" BaseSightRange="5" ZoneOfControl="true" Domain="DOMAIN_LAND" FormationClass="FORMATION_CLASS_LAND_COMBAT" Name="LOC_UNIT_BRAZILIAN_BOPERATIVES_NAME" Description="LOC_UNIT_BRAZILIAN_BOPERATIVES_DESCRIPTION" PurchaseYield="YIELD_GOLD" PromotionClass="PROMOTION_CLASS_RECON" Maintenance="0" Combat="90" RangedCombat="120" Range="3" PrereqTech="TECH_RIFLING" TraitType="TRAIT_CIVILIZATION_UNIT_BRAZILIAN_BOPERATIVES"/>
    </Row>
  </Units>
 
Okay yeah I found it, when I went to paste in the Ranger unit from the base files I forgot to remove the extra Row tag. It works perfectly now!
 
So trying to make a new district, everything seems to be working fine except when it comes to trying to set an icon and text. I edited the NewUnit_Icons.xml and NewUnit_Text.xml from the Unit template to fit for Districts and thought I was setting it up right, but it's returning the same syntax error that the Unit mod was when I had the extra Row tag. What should I do to fix the syntax?

EDIT: I misread the error report, it actually says that the tables don't exist? That seems strange to me, considering that they do exist, at least for Units and Buildings.
 

Attachments

  • Test District.rar
    2.5 KB · Views: 33
These types of files are not loaded through an <UpdateDabase> type of action
Code:
      <File>NewDistrict_Icons.xml</File>
      <File>NewDistrict_Text.xml</File>
      <File>Mod.Art.xml</File>
example of correct way to "load" these files. In Modbuddy these action-types can be selected from a dropdown within the action once you add a new action to the project
Code:
  <InGameActions>
	<UpdateDatabase id="XML_GameplayChanges">
		<File>MyCiv6XMLGameplayChanges.xml</File>
	</UpdateDatabase>
	<UpdateText id="XML_TextChanges">
		<File>MyCiv6XMLTextChanges.xml</File>
	</UpdateText>
	<UpdateIcons id="XML_IconChanges">
		<File>MyCiv6XMLNewIconDefinitions.xml</File>
	</UpdateIcons>
  </InGameActions>
  <Files>
    <File>MyCiv6XMLGameplayChanges.xml</File>
    <File>MyCiv6XMLNewIconDefinitions.xml</File>
    <File>MyCiv6XMLTextChanges.xml</File>
  </Files>
I haven't cracked art other than to add dds files and "<UpdateIcons>" actions so I am not sure how the Mod.Art.xml needs to be handled
 
Right that makes sense. I'll take a look at the other mods to see how they handle Mod.Art.xml, it should be the same

EDIT: Looking into it, it doesn't seem that Mod.Art.xml is loaded in at all, the other mods don't have it in any of the In-Game Actions and have no issues loading in.
 
I believe the Mod.Art.xml file is just used when building the mod, to help build all the custom assets, everything in the Platforms file, stuff like that. Said file isn't in any built versions of mods, and you don't need to set an action for it in the mod prefs.
 
Okay so I got cracking on an actual civ mod and made one for Mexico. Everything loads in fine for the game, all the text shows up fine, icons match, everything is good. However when I go to start a game with it, the game crashes. I can't make heads nor tails of the .pkg that's created with a crash, any help on figuring out where I went wrong would be much appreciated.
 

Attachments

  • Error Report 7-30-2017-240.rar
    7.7 KB · Views: 33
  • Test Civ.rar
    100.9 KB · Views: 44
In your leader's xml file, you try and define an argument for the modifier to set 'Domestic' to true. You may not fully understand the modifiers system yet, because the MODIFIER_UNIT_ADJUST_COMBAT_STRENGTH modifier has no such argument. The only thing I found after a cursory search that uses that argument is to reduce war weariness for domestic battles. Which is obviously not the same modifier. What you'd have to do to achieve that effect is to attach a Subject requirement set that tested if they were in friendly/owned territory; look at the Cossack's modifiers and requirements.

In your civ's file: in the Modifiers table, you have 2 entries, but you are missing the lines to close and open the rows for those entries; as it stands now, you have 4 lines in 1 row when you need 2 lines in 2 rows. That's a pretty hefty error. Also, while we're on the topic, you don't ever define a trait to attach said modifiers to. You need another definition in the Traits table and Types tables, and a couple entries in the TraitModifiers table for said modifiers to have any effect whatsoever, ALSO you'll probably want to rename your modifiers to something more appropriate and use one of the names as you have them as the Trait name. Still on the topic of your Modifiers, the first has the type 'MODIFIER_PLAYER_ADJUST_IMPROVEMENT_BEACH_RESORT' which doesn't exist at all in the game (far as I can find), and which you don't define in your code, far as I saw. I'm not sure what you'd have to do to achieve the effect you want there, but you need to find a better modifier. I'd say axe that effect for now, at least until you get the civ to load in-game and not crash everything. Also, with the TRAIT_GREAT_WORK_TOURISM_BONUS modifier, you'll definitely want to test what exactly the Amount argument affects; it's either a 25% boost to the tourism, or a +25 per turn boost to the tourism, which would be insane, haha.


So, definitely some stuff that would cause a crash. A CTD is somewhat surprising, but you still have a way to go until you fully grasp all the moving parts. My advice, don't try and get too much into modifiers yet. They are easily the most complex part of the game (for xml/sql anyways). Once you feel ready to dive into the system as a whole, this is a good resource to start with: https://nycholusv.com/guides/using-modifiers/chapter-1/

Another thing, we generally want the log files, even if in addition to the crash report. Look at:
C:\Users\YOU\Documents\My Games\Sid Meier's Civilization VI\Logs
Find the Database and Lua logs, and maybe also Modding, UserInterface, and ArtDef for good measure.
 
Thanks, I'll take a look into those. I'm still new to everything so a lot of it is getting jumbled around and I'm missing parts that I shouldn't be. I've also tried using the guide before, but I'm still learning the XML equivalents for SQL inputs and such.
 
Top Bottom