Help with a <Types> error (or something like it)

Olordrin

Chieftain
Joined
Jan 16, 2017
Messages
25
First off, hello everyone. Been playing Civ and lurking these forums forever, but with this iteration of Civ, I finally decided to try my hand at modding. I figured I'd go "simple" first and just make a custom Civ with a custom leader that replaced most of the standard units with custom units. It's really just stat and icon changes. It was basically just to get a feel for the syntax and inner workings, but now I have to finish it and it has to work. Using the database.log (which I found out about only recently), I've narrowed my errors down to one.

ERROR: Invalid Reference on Units.UnitType - "UNIT_VELISZHA" does not exist in Types

Well, I have my units file open and I'm staring directly at this in <Types>:

<Row Type="UNIT_VELISZHA" Kind=KIND_UNIT"/>

Am I looking for the error in the wrong place? I've been staring at it long enough that my brain has locked itself out of finding the problem. :D
 
The file itself or a link to where the mod itself can be downloaded and examined is always better than snippets of code.

Code:
ERROR: Invalid Reference on Units.UnitType - "UNIT_VELISZHA" does not exist in Types
This error tells me the file where
Code:
<Row Type="UNIT_VELISZHA" Kind=KIND_UNIT"/>
is stated either has an error in it or it has never been loaded into the game's database by the proper commands in the modinfo file.
 
I haven't gotten around to putting the UnitAiInfos in yet, but I wouldn't want to play against this unbalanced civ, lol
 
You have none of these:
Code:
	<TypeTags>
		<Row Type="UNIT_BARBARIAN_HORSEMAN" Tag="CLASS_LIGHT_CAVALRY"/>
		<Row Type="UNIT_BARBARIAN_HORSE_ARCHER" Tag="CLASS_RANGED_CAVALRY"/>
		<Row Type="UNIT_SCOUT" Tag="CLASS_RECON"/>
		<Row Type="UNIT_SCOUT" Tag="CLASS_REVEAL_STEALTH"/>
		<Row Type="UNIT_RANGER" Tag="CLASS_RECON"/>
       ....etc.....
They are needed for your new units but their absense is not what is causing the problem.

The problem is here. If you look very closely at this you may be able to spot the error:
Code:
<Row Type="UNIT_VELISZHA" Kind=KIND_UNIT"/>
It took me a while to see the missing ".

You need
Code:
<Row Type="UNIT_VELISZHA" Kind="KIND_UNIT"/>
Otherwise the new Type in the <Types> table is not recognized as a proper type with a proper kind.

Apparently this sort of syntax error does not in and of itself throw a fatal error, and so nothing for the real error is reported in any way in Database.log.
 
Thank you. This is one thing I miss about programming, compilers that give you line locations for errors. I'd been staring at this for ages. :D
 
Also, as I'm trying to add on to the recon units, will I have to do some "UpgradesTo" kind of thing?
 
And it loads! Yay! I'm just fine-tuning some of the other non-program-breaking errors, like the units are showing up in-game as LOC_UNIT_ENASIRWARRIOR_NAME instead of just Enasir Warrior... and they all have settler icons. Small stuff, though. I'm just happy it runs.

EDIT: Got the names working, just trying to pin down the icons now. :D
 
Last edited:
And by icons, I mean the in game unit icons. Maybe a more correct term would be unit flags? Basically, the symbol overhead of the unit on the map.
 
Not sure which of them does it but you will want all of the following icons

Code:
 <Row Name="ICON_UNIT_UKLONGBOWMAN" Atlas="ICON_ATLAS_UNITS" Index="29"/> <!--Archer-->
    <Row Name="ICON_UNIT_UKLONGBOWMAN_PORTRAIT" Atlas="ICON_ATLAS_UNIT_PORTRAITS" Index="29"/>
    <Row Name="ICON_UNIT_UKLONGBOWMAN_WHITE" Index="29" Atlas="ICON_ATLAS_UNIT_FLAG_SYMBOLS_WHITE"/>
    <Row Name="ICON_UNIT_UKLONGBOWMAN_BLACK" Index="29" Atlas="ICON_ATLAS_UNIT_FLAG_SYMBOLS_BLACK"/>
These are reusing in game icons. Creating my own icons is a bit beyond me but is possible. Some of the new Civ's have their own icons.

Basically any unit or other thing you want to define an icon for just has to have ICON_ in front of and point to one of the icons defined already.
 
Thank you. This is one thing I miss about programming, compilers that give you line locations for errors. I'd been staring at this for ages. :D

In this case the XML wasn't well-formed. That's a pretty easy thing to check using editor plugins. I've been editing using VS Code, which has a plugin that can check this case.
 
Back
Top Bottom