Mod unit don't appear!

Adrielcz

Chieftain
Joined
Mar 11, 2017
Messages
8
I started my mod by creating a single unit just for test purposes, but when i build the solution and enable it in the game the unit does not appear!What I doing wrong?Plz help! (Sorry my english I'm Brazilian)
 

Attachments

  • WW2 combat.rar
    6.3 KB · Views: 55
Here is the code if you dont want download it
<GameData>
<Types>
<Row Type="UNIT_KAR98K_RIFLEMAN" Kind="KIND_IANFANTRY_UNIT"/>
<Row Type="TRAIT_CIVILIZATION_UNIT_KAR98K_RIFLEMAN" Kind="KIND_TRAIT"/>
</Types>
<Units>
<Row UnitType="UNIT_KAR98K_RIFLEMAN" BaseMoves="2" Cost="430" AdvisorType="ADVISOR_CONQUEST" BaseSightRange="2" ZoneOfControl="true"
Domain="DOMAIN_LAND" FormationClass="FORMATION_CLASS_LAND_COMBAT" Name="LOC_UNIT_KAR98K_RIFLEMAN_NAME"
Description="LOC_UNIT_KAR98K_RIFLEMAN_DESCRIPTION" PurchaseYield="YIELD_GOLD" PromotionClass="PROMOTION_CLASS_MELEE"
Maintenance="6" Combat="70" PrereqTech="TECH_REPLACEABLE_PARTS"/>
</Units>
<CivilizationTraits>
<Row CivilizationType="CIVILIZATION_GERMANY" TraitType="TRAIT_CIVILIZATION_UNIT_KAR98K_RIFLEMAN"/>
</CivilizationTraits>
<UnitReplaces>
<Row CivUniqueUnitType="UNIT_KAR98K_RIFLEMAN" ReplacesUnitType="UNIT_INFANTRY"/>
</UnitReplaces>
<UnityAIInfos>
<Row UnitType="UNIT_KAR98K_RIFLEMAN" AiType="UNITAI_COMBAT"/>
<Row UnitType="UNIT_KAR98K_RIFLEMAN" AiType="UNITAI_EXPLORE"/>
<Row UnitType="UNIT_KAR98K_RIFLEMAN" AiType="UNITTYPE_MELEE"/>
<Row UnitType="UNIT_KAR98K_RIFLEMAN" AiType="UNITTYPE_LAND_COMBAT"/>
</UnityAIInfos>
<Tags>
<Row Tag="CLASS_KAR98K_RIFLEMAN" Vocabulary="ABILITY_CLASS"/>
</Tags>
<TypeTags>
<Row Type="UNIT_KAR98K_RIFLEMAN" Tag="CLASS_MELEE"/>
</TypeTags>
<UnityAbilities>
<Row UnitAbilityType="ABILITY_KAR98K_RIFLEMAN" Name="LOC_ABILITY_KAR98K_RIFLEMAN" Description="LOC_ABILITY_KAR98K_RIFLEMAN_DESCRIPTION"/>
</UnityAbilities>
<UnitAbilityModifiers>
<Row>
<UnitAbilityType>ABILITY_KAR98K_RIFLEMAN</UnitAbilityType>
<ModifierId>UNIT_STRONG_WHEN_DEFENDING</ModifierId>
</Row>
</UnitAbilityModifiers>
<ModifiersStrings>
<Row ModifierId="PLUS_15_WHEN_DEFENDING_COMBAT_BONUS" Context="Preview" Text="PLUS_15_WHEN_DEFENDING_COMBAT_BONUS_DESC"/>
</ModifiersStrings>
<ModifierArguments>
<Row>
<ModifierId>PLUS_15_WHEN_DEFENDING_COMBAT_BONUS</ModifierId>
<Name>Amount</Name>
<Value>15</Value>
</Row>
</ModifierArguments>

</GameData>
 
it needs unit.artdef data, & you need to the link the .artdef in your .dep file.


And Hola from Peru :p
 
Hi and thanks RichAdler, but what I need to put in the .artdef and how I link it?And what is a .dep files?I searched in lots of mods and dont find it!(I did reverse engineering in a lot of mods but it still too complicated!)
 
Last edited:
Both the Australia DLC & Poland DLC add units, & have .dep files... a good place to start.
 
First thing I notice is that the Kind type for the unit is completely wrong. I believe it should just be KIND_UNIT, and even if not, 'infantry' is misspelled.

This is actually a really good time to learn how to read the logs. Look in My Documents/My Games/Sid Meier's Civilization 6/Logs, look in the database log after loading up a game with your mod, and I guarantee you'll see an invalid entry for the Kinds table. When the game runs into an error in the database like that, it stops loading the file at that line, and nothing below that in the file gets loaded. You should learn how to find and diagnose errors from the logs like that, it'll be some of the most useful info for fixing bugs in your mods you'll ever learn.

Also, you DO NOT need an art def and xlp, etc, as long as you are fine with using base game icons for your unit. Adding new graphics should not be a concern on your very first test mod, everything to do with the asset editor is incredibly complex and obtuse. What you DO need, however, is an Icons file, added to the project's properties NOT under UpdateDatabse actions, but under UpdateIcons functions. Look at the base game files (the icons file is under Assets/UI/Icons where the game is installed, I believe) and other mods' Icons files to see the format of everything.
 
Thanks luei333 but can you plz give me a Icons file example?I kinda lost!
 
Yeah, it's not terribly complicated. For reference (and so you can look up what to use for the vanilla icons you want to use), the Icons files for the base game are in: Steam\SteamApps\common\Sid Meier's Civilization VI\Base\Assets\UI\Icons. Here's what my Icons file looks like, just for my unit:

Code:
<GameInfo>
   <IconTextureAtlases>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER" IconSize="22" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Flag_22.dds"/>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER" IconSize="32" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Flag_32.dds"/>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER" IconSize="38" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Flag_38.dds"/>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER" IconSize="50" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Flag_50.dds"/>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER" IconSize="80" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Flag_80.dds"/>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER" IconSize="256" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Flag_256.dds"/>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER_PORTRAIT" IconSize="38" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Portrait_38.dds"/>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER_PORTRAIT" IconSize="50" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Portrait_50.dds"/>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER_PORTRAIT" IconSize="70" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Portrait_70.dds"/>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER_PORTRAIT" IconSize="95" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Portrait_95.dds"/>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER_PORTRAIT" IconSize="200" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Portrait_200.dds"/>
       <Row Name="ICON_ATLAS_LUEI_BAT_SOLDIER_PORTRAIT" IconSize="256" IconsPerRow="1" IconsPerColumn="1" Filename="Gotham_Unit_Portrait_256.dds"/>
   </IconTextureAtlases>
   
   <IconDefinitions>
       <Row Name="ICON_UNIT_LUEI_BAT_SOLDIER" Atlas="ICON_ATLAS_LUEI_BAT_SOLDIER" Index="0"/>
       <Row Name="ICON_UNIT_LUEI_BAT_SOLDIER_BLACK" Atlas="ICON_ATLAS_UNIT_FLAG_SYMBOLS_BLACK" Index="29"/>
       <Row Name="ICON_UNIT_LUEI_BAT_SOLDIER_WHITE" Atlas="ICON_ATLAS_UNIT_FLAG_SYMBOLS_WHITE" Index="29"/>
       <Row Name="ICON_UNIT_LUEI_BAT_SOLDIER_PORTRAIT" Atlas="ICON_ATLAS_LUEI_BAT_SOLDIER_PORTRAIT" Index="0"/>
   </IconDefinitions>
</GameInfo>

That's what you'd need when you have imported your custom assets, but in particular pay attention to the IconDefinitions table; that's what you need to just give it some icons at all. I'm not sure that all of the images I need are accounted for, but for your purposes, that much will definitely get you going.

For an example, if you wanted your unit to have the icons and portrait for the musketman, your file would look like the following:
Code:
<GameInfo>
   <IconDefinitions>
       <Row Name="ICON_UNIT_MY_UNIT" Atlas="ICON_ATLAS_UNITS" Index="53"/>
       <Row Name="ICON_UNIT_MY_UNIT_BLACK" Atlas="ICON_ATLAS_UNIT_FLAG_SYMBOLS_BLACK" Index="53"/>
       <Row Name="ICON_UNIT_MY_UNIT_WHITE" Atlas="ICON_ATLAS_UNIT_FLAG_SYMBOLS_WHITE" Index="53"/>
       <Row Name="ICON_UNIT_MY_UNIT_PORTRAIT" Atlas="ICON_ATLAS_UNIT_PORTRAITS" Index="51"/>
   </IconDefinitions>
</GameInfo>

And that's all you'd need in your file. It'd still have the model and sounds, etc. of the Warrrior I believe, but to change that you need an artdef, so don't worry about it for now. Also, make sure the 'Name' entries use your exact unit type. The game automatically hooks up the images to your unit based on its name, preceeded by 'ICON_' and proceeded by the other types of icon, as you can see. Also, be sure to reference your icon name in the PlayerItems entries for your civ/leader, where the unit's info goes (in the front-end config files).

That's really all the code you need in your icons file, just take that and add an UpdateIcons action to both the in-game and front-end sections, and include that file in both actions, and you should be good to go.
 
Okay, so now that I'm on my desktop and not on mobile, I took a look at your mod. There were a number of things missing, including the Traits table definition of your trait (that gives it to Barbarossa as a unique unit), your TypeTags were incomplete, and your ability would not have been added to your unit, you completely missed the Modifiers table to actually define your modifier, and the ModifierId you used in various places was different for some reason, your UnitAIInfos and UnitAbilities tables were misspelled ('Unity'), ModifierStrings was misspelled ('ModifiersStrings'), you missed the TraitType entry for the Units table entry (which you need for civ- or leader-unique units), and probably a number of other small things.

I took the liberty of fixing it all, and adding what you need to get it off the ground. Now, if you want to get into modding, you should know why I made every single change and addition I did before you continue modifying anything. It's all rather simple, in the grand scheme of things, and it's all stuff you need to know if you want to make more of it. The modified version of your project is attached.

The most important thing I did was add Build Actions. Open up the properties of your project and on the left you should see two sections, 'FrontEnd Actions' and 'In-Game Actions'. You need to set your files to be loaded into the game here for them to have any effect on the game. You'll notice I DIDN'T include your reference file in these actions at all, because it's unneeded and would actually cause an error if I did so. Things can exist in your file structure or project, but if they're not added to a build action, they won't do anything. Front End actions are stuff that is needed for the Leader Select screen, which is not very much at all. Between the actions, I've only included the Icons, Config, and Config Text files, which each contain the least amount of code. That much is all you need to add your unit. In-Game actions are stuff that is needed by the game when you're actually playing it. You'll notice I didn't include the Config file here, since the game no longer needs it. I did include the Config Text file, though, so that you didn't have to re-define your unit's name and description, though if you did copy/paste the contents of the Config Text file into the MyText file, you would no longer need to include it in the In-Game actions (and, in fact, would need to make sure NOT to include it, as the duplicate definition for the variable would cause an error). In both action sets, there are 3 actions that I used, UpdateDatabase, UpdateIcons, and UpdateText. It should be pretty obvious why each file goes where they do, and the distinction between the actions types. If you ever did add new art, via artdefs and xlps, you would need to add an UpdateArt action to both sections, and just set it to use the '(Mod Art Dependency File)' option.

So, as is probably already obvious to you, I also added a few new files. an Icons file, a Config file, and two Text files. Based on the above paragraph, it should be easy to figure out why I needed to add them, but definitely look at the contents of each file and try and reason out why each one has all that it does.

Now, all that said, I didn't test the ability (+15 strength when defending), but unless I really cocked something up, it should be working fine, no errors in any of the logs. Try building the solution I gave you, and see how everything looks. Note where the text from the files actually shows up in-game. (just as a reminder, the unit is exclusive to Germany)
 

Attachments

  • WW2 combat.zip
    9.9 KB · Views: 40
Thank you again lui333! I pick up your version of my mod and tried to add the panzer 4 tank, but when I run the game its comes back to the main menu! The database log says ("OPPONENT_MELEE_CAVALRY_REQUIREMENTS" does not exist in RequirementSets) but when I check on the wikipedia its exists! By the way here is my version of the mod.
 

Attachments

  • WW2 combat.rar
    9.8 KB · Views: 36
Okay I made I think 6 changes. First, you missed the TraitType entry in the Units table for the Panzer. Second, your 'PLUS_20_VERSUS_MELEE_CAVALRY_COMBAT_BONUS' modifier was properly defined in the Modifiers table, but I'm going to assume you forgot to replace the ModifierId when you copy/pasted the entries in the ModifierStrings and ModifierArguments tables, which lead to your file throwing out 'UNIQUE constraint failed' errors and crashing. The thing with the RequirementSet not being recognized was weird and I don't know why it did that, but I just made a new RequirementSet with the same Requirements, and it worked fine. Also, you didn't define the values for your text tags for the civ trait or ability for the Panzer (look in MyText.xml). And one last thing, I just changed the SortIndexfor the Panzer in the Config file; no idea how that value works or if having 2 with the same value would cause bad things, I just took the precaution.
 

Attachments

  • WW2 combat.zip
    11.7 KB · Views: 36
Started the british cromwell, It apears in the main menu with a weird name and not apear in the game.
 

Attachments

  • WW2 combat.rar
    11.4 KB · Views: 51
So, obviously you missed a few things. First and foremost, whenever you add a new file to your project, if you want its data to be included in the game (so, not your Units_Reference file), you HAVE to add it to a Build Action. In this case, you didn't add your new British_Data.xml file to your build actions, specifically under the In-Game Action UpdateDatabase, same place as where your German_Data.xml file goes. You absolutely need to understand this, as it's really the first step to knowing how to use ModBuddy.

Second, in the ConfigText file, you made a new entry to define the cromwell tank's name and description, BUT you forgot to change the text tag entry. So, you had 2 entries for 'LOC_UNIT_PANZER_4_NAME', and this caused the Unique constraint failure error. If you looked in the database log, it's extremely obvious in capital letters, and that's how I found that out in the first place. You really should load up the version that you sent me in the game and look at the logs, see what that error looks like, see if you can figure out how I found where to look.

Third, you didn't give the Cromwell an ability, such as the Panzer's bonus vs Melee or Cavalry units, but you still defined a <Types> and <Tags> entry for it, and still related your nonexistent ability in the <TypeTags> table, which would absolutely have caused a crash. You need to make sure to go over every line of code you copy/paste, and make sure you know whether you need to change a value or variable, delete the line altogether, or keep it as is.

One last thing, and this isn't going to cause a crash, but will introduce a lot of inconsistency in your mods, I noticed specifically with your tanks that they were classified as melee units, instead of heavy cavalry as they should be. When you look through the base game files, you need to search for every table that the unit you're replacing has, and make sure to copy or exclude each of them deliberately. You did this for the Infantry and your new Rifleman unit, but it would seem you only looked up the <Units> entry for the tank. In particular, its <TypeTags> and <UnitAIInfos> entries are very much inconsistent with both of your new tank replacements. ALSO, none of your units have an entry in the <UnitUpgrades> table. Without that, for example, Germany won't be able to upgrade their KAR98K Riflemen to Mechanized Infantry, or their Panzer 4s to Modern Tanks. I've changed only some of the things in this paragraph to reflect how they probably should be, but I leave it to you to fill in the rest. Double check the base game tables for the Infantry and Tank, see what their entries look like, compare them to your own, and see how much you can fix.
 

Attachments

  • WW2 combat.zip
    13.2 KB · Views: 40
Top Bottom