Adding more than one free bulidings to traits xml

Howitzer

Chieftain
Joined
Jan 5, 2006
Messages
95
Location
Greek Empire
Hi guys,

I'm trying to create a super trairt for Alexander, just for the fun of it..

I have given him a free harbor for all of his cities, like the Carthage civ has.

It wortks fine along with the shoshone expansion and polynesia ocean movement and others I've given him

When I try to have his trait of city state friendship include more than one free buildings none of the other attributes of his trait works and I get stupid things..

check the attached screen..what am i doing wrong?
 

Attachments

  • trait.jpg
    trait.jpg
    121.4 KB · Views: 154
You can't have more than one entry for a single column in a single row. The easiest way I can think of to do this is to create a few dummy buildings and place their classes into Civilization_FreeBuildingClasses, then for each dummy add the building class you want to FreeBuilding.
 
Pretty sure free buildings stack in traits, so create N traits, each with only one free building and give all N traits to the leader
 
Being quite lazy by nature, Instead of creating new traits, I just added free buildings to other existing traits inside traits.xml and put them on Alex's leaders.xml

<Row>
<Type>TRAIT_FIGHT_WELL_DAMAGED</Type>
<Description>TXT_KEY_TRAIT_FIGHT_WELL_DAMAGED</Description>
<ShortDescription>TXT_KEY_TRAIT_FIGHT_WELL_DAMAGED_SHORT</ShortDescription>
<FightWellDamaged>true</FightWellDamaged>
<FreeBuilding>BUILDING_BARRACKS</FreeBuilding>
</Row>
<Row>
<Type>TRAIT_CONVERTS_LAND_BARBARIANS</Type>
<Description>TXT_KEY_TRAIT_CONVERTS_LAND_BARBARIANS</Description>
<ShortDescription>TXT_KEY_TRAIT_CONVERTS_LAND_BARBARIANS_SHORT</ShortDescription>
<LandBarbarianConversionPercent>67</LandBarbarianConversionPercent>
<LandUnitMaintenanceModifier>-25</LandUnitMaintenanceModifier>
<FreeBuilding>BUILDING_MARKET</FreeBuilding>
</Row>
<Row>
<Type>TRAIT_CONVERTS_SEA_BARBARIANS</Type>
<Description>TXT_KEY_TRAIT_CONVERTS_SEA_BARBARIANS</Description>
<ShortDescription>TXT_KEY_TRAIT_CONVERTS_SEA_BARBARIANS_SHORT</ShortDescription>
<NavalUnitMaintenanceModifier>-66</NavalUnitMaintenanceModifier>
<FreeBuilding>BUILDING_MONUMENT</FreeBuilding>
</Row>
<Row>
<Type>TRAIT_IGNORE_TERRAIN_IN_FOREST</Type>
<Description>TXT_KEY_TRAIT_IGNORE_TERRAIN_IN_FOREST</Description>
<ShortDescription>TXT_KEY_TRAIT_IGNORE_TERRAIN_IN_FOREST_SHORT</ShortDescription>
<MoveFriendlyWoodsAsRoad>true</MoveFriendlyWoodsAsRoad>
<FreeBuilding>BUILDING_SHRINE</FreeBuilding>


<Leader_Traits>
<Row>
<LeaderType>LEADER_ALEXANDER</LeaderType>
<TraitType>TRAIT_CITY_STATE_FRIENDSHIP</TraitType>
<TraitType>TRAIT_STRATEGIC_RICHES</TraitType>
<TraitType>TRAIT_FIGHT_WELL_DAMAGED</TraitType>
<TraitType>TRAIT_CONVERTS_LAND_BARBARIANS</TraitType>
<TraitType>TRAIT_CONVERTS_SEA_BARBARIANS</TraitType>
<TraitType>TRAIT_IGNORE_TERRAIN_IN_FOREST</TraitType>
</Row>
</Leader_Traits>
</GameData>

I get the same thing as when I had all the building onto his trait...

I remember reading in some thread that you can't have multiple traits in one leader...

Can you please advice?
 
Being quite lazy by nature, Instead of creating new traits, I just added free buildings to other existing traits inside traits.xml and put them on Alex's leaders.xml

Use CODE tags instead of quotes when posting code; it preserves formatting, like tabs.

Anyway, this is a bad way of doing it, because every other leader in the game will also get the free buildings related to the trait you're giving to Alexander (so, for example, Japan will be getting a free Barracks, Germany will be getting a free Market, etc). If you want that to happen, fine, but just know that is what will happen.

That aside, the reason it's not working is because, when you want to change existing database entries (like traits), you do not use <Row> and everything associated with it; you must use the <Update> tag (and sometimes the <Replace> tag if you want to redefine it entirely).

So, for example, when you're updating Japan's trait (FIGHT_WELL_DAMAGED), instead of using the definition you've provided, use this:

Code:
<Traits>
	<Update>
		<Where Type="TRAIT_FIGHT_WELL_DAMAGED" />
		<Set FreeBuilding="BUILDING_BARRACKS" />
	</Update>
</Traits>

Again, though, you really shouldn't mess with existing traits to get this done, as it will most likely cause unwanted side effects. Funny thing is: your definitions using <Row> actually work if you want to create new traits from scratch anyway; just rename them--so instead of "TRAIT_FIGHT_WELL_DAMAGED," for example, just name it "TRAIT_FREE_BARRACKS" (assuming that's all you want the trait to give). Make new traits for each of the buildings you want to give, set them all to Alexander using <Leader_Traits>, and voila. Also, relevant:
I remember reading in some thread that you can't have multiple traits in one leader...
You can have as many traits as you want on the same leader.
 
Thank you for your prompt reply :)

I knew that other leaders will also get some of the good staff too, by coding that way, but 1)enormous lazyness and 2) what the heck I'm doing a super cheating Alex, let them be a little competitive...

that aside, I will try to overcome my lazyness and work on new traits tommorow and let you know!


Once again thanks a lot everyone for your effort, I will be giving you my feedback hopefully tomorrow! ;)
 
If you want to be lazy (and all programmers are, it's why we write tools to make our lives easier), check out the "My - Changes" mod linked in my sig ... a fully working mod that does nothing ... but ready to take any XML/SQL/Lua additions that you want to add (without all the work of starting up ModBuddy and making a basic mod!)
 
This is also part of the problem:
Code:
<GameData>
	<Leader_Traits>
		<Row>
			<LeaderType>LEADER_ALEXANDER</LeaderType>
			<TraitType>TRAIT_CITY_STATE_FRIENDSHIP</TraitType>
			<TraitType>TRAIT_STRATEGIC_RICHES</TraitType>
			<TraitType>TRAIT_FIGHT_WELL_DAMAGED</TraitType>
			<TraitType>TRAIT_CONVERTS_LAND_BARBARIANS</TraitType>
			<TraitType>TRAIT_CONVERTS_SEA_BARBARIANS</TraitType>
			<TraitType>TRAIT_IGNORE_TERRAIN_IN_FOREST</TraitType>
		</Row>
	</Leader_Traits>
</GameData>
Just as you cannot have <FreeBuilding> more than once within the same <Row>, you cannot have <TraitType> more than once within the same <Row>. You need to break each one up so that any one <Row> --- </Row> pair only contains <LeaderType> once and <TraitType> once, as in:
Code:
<GameData>
	<Leader_Traits>
		<Row>
			<LeaderType>LEADER_ALEXANDER</LeaderType>
			<TraitType>TRAIT_CITY_STATE_FRIENDSHIP</TraitType>
		</Row>
		<Row>
			<LeaderType>LEADER_ALEXANDER</LeaderType>
			<TraitType>TRAIT_STRATEGIC_RICHES</TraitType>
		</Row>
	</Leader_Traits>
</GameData>
But since Alexander already has TRAIT_CITY_STATE_FRIENDSHIP you should not repeat that in a new <Row>.
 
hmm I don't know what's wrong with me...

I've edited the following files:

\sid meier's civilization v\Assets\Gameplay\XML\Civilizations\civ5traits.xml

(I think that's for vanilla traits right?)

\sid meier's civilization v\Assets\DLC\Expansion\Gameplay\XML\Civilizations\civ5traits.xml

which is for the first expansion

\sid meier's civilization v\Assets\DLC\Expansion2\Gameplay\XML\Civilizations\civ5traits.xml

which I think is for BNW?

and also edited:

\sid meier's civilization v\Assets\DLC\Expansion\Gameplay\XML\Leaders\civ5leader_alexander.xml

and

\sid meier's civilization v\Assets\Gameplay\XML\Leaders\civ5leader_alexander.xml


my civ5traits files all read:

Code:
....

               <Row>
			<Type>TRAIT_FREE_BARRACKS</Type>
			<Description></Description>
			<FreeBuilding>BUILDING_BARRACKS</FreeBuilding>
		</Row>
		<Row>
			<Type>TRAIT_FREE_LIBRARY</Type>
			<Description></Description>
			<FreeBuilding>BUILDING_LIBRARY</FreeBuilding>
		</Row>
		<Row>
			<Type>TRAIT_FREE_MARKET</Type>
			<Description></Description>
			<FreeBuilding>BUILDING_MARKET</FreeBuilding>
		</Row>
		<Row>
			<Type>TRAIT_FREE_MONUMENT</Type>
			<Description></Description>
			<FreeBuilding>BUILDING_MONUMENT</FreeBuilding>
		</Row>
		<Row>
			<Type>TRAIT_FREE_SHRINE</Type>
			<Description></Description>
			<Freebuilding>BUILDING_SHRINE</FreeBuilding>
		</Row>

.....

<Row>
			<Type>TRAIT_CITY_STATE_FRIENDSHIP</Type>
			<Description>TXT_KEY_TRAIT_CITY_STATE_FRIENDSHIP</Description>
			<ShortDescription>TXT_KEY_TRAIT_CITY_STATE_FRIENDSHIP_SHORT</ShortDescription>
			<CityStateFriendshipModifier>100</CityStateFriendshipModifier>
			<ExtraEmbarkMoves>2</ExtraEmbarkMoves>
			<CapitalBuildingModifier>50</CapitalBuildingModifier>
			<WonderProductionModifier>50</WonderProductionModifier>
			<FreeBuilding>BUILDING_HARBOR</FreeBuilding>
			<EmbarkedAllWater>true</EmbarkedAllWater>
			<TechBoostFromCapitalScienceBuildings>true</TechBoostFromCapitalScienceBuildings>
			<ExtraFoundedCityTerritoryClaimRange>8</ExtraFoundedCityTerritoryClaimRange>
			<GreatPeopleRateModifier>100</GreatPeopleRateModifier>
		</Row>

....

the city state friendship trait is perfectly executed....

in my leader alex.xml:

Code:
...

<Leader_Traits>
		<Row>
			<LeaderType>LEADER_ALEXANDER</LeaderType>
			<TraitType>TRAIT_CITY_STATE_FRIENDSHIP</TraitType>
		</Row>
		<Row>
			<LeaderType>LEADER_ALEXANDER</LeaderType>
			<TraitType>TRAIT_STRATEGIC_RICHES</TraitType>
		</Row>
		<Row>
			<LeaderType>LEADER_ALEXANDER</LeaderType>
			<TraitType>TRAIT_FREE_BARRACKS</TraitType>
		</Row>
		<Row>
			<LeaderType>LEADER_ALEXANDER</LeaderType>
			<TraitType>TRAIT_FREE_MARKET</TraitType>
		</Row>
		<Row>
			<LeaderType>LEADER_ALEXANDER</LeaderType>
			<TraitType>TRAIT_FREE_SHRINE</TraitType>
		</Row>
		<Row>
			<LeaderType>LEADER_ALEXANDER</LeaderType>
			<TraitType>TRAIT_FREE_MONUMENT</TraitType>
		</Row>
		<Row>
			<LeaderType>LEADER_ALEXANDER</LeaderType>
			<TraitType>TRAIT_FREE_LIBRARY</TraitType>
		</Row>
	</Leader_Traits>
</GameData>

Like I said city state friendship gets executed with all new elements, but new traits are not being implemented...

what am I doing wrong?
 
No I'm way too noob (in programming), too lazy, too busy and too 36 years old with a wife and infant daughter to make a complete mod!! hahaha
 
What LeeS is asking is whether or not you're using ModBuddy to build a mod and then activating that mod in-game, or "modding" by editing the base game's files. The difference is that activating a mod only temporarily changes the game; it goes back to normal once you deactivate the mod. Editing the game's base files is... well, just that. Because you're changing the definitions of the base game, it won't go back to normal (as your changes are the new "normal,") and that's usually not a very good idea and can cause any number of problems, especially considering (as you've noticed) the sheer amount of files you have to account for, all of which can have different, isolated problems. It also has the problem of not really being possible for other people to test and troubleshoot.

Since I suspect it's the latter (editing the base game's files): as a corollary to the above, we can't really say definitively what's going wrong because there are so many areas in which something could be messing up... and, as I mentioned, because you don't have a proper mod that we can install and test, we also can't troubleshoot for you. Try enabling logging and see what xml.log and database.log tell you when you launch the game, or better yet, change your base game files back to normal (I sure hope you backed them up) and make a mod using ModBuddy (it's really not as hard as you make it out to be--in fact, it's more or less the same process you've done, except much safer).
 
Already backed 'em up with .old extension for the original files...

this is what my .xml log reads:

6116.182] **** Validating Game Database *****
[16120.862] Performing Localization Checks
[16120.862] Checking Tag Format...
[16120.862] Note: Tags must only use [A-Z_] characters, start with 'TXT_KEY_', and be under 128 characters long.
[16120.878] Validating UnitGameplay2DScripts
[16120.878] Missing Entry for UNIT_BARBARIAN_HORSEMAN
[16120.878] **** VALIDATION FAILED *****

[16120.878] Validation Took 4.697173 seconds
[16121.845] **** Validating Prefetch Process *****
[16121.845] **** Validation Success *****
[16121.845] SetGlobalActionInfo
[16121.845]
-- SQLite Memory Statistics --
Memory Usage:
[Cur] [Max]
Malloc: 6225608 75789152
PageCache: 6 12
LookAside: 0 0
Scratch: 0 1

Static Buffer Overflows:
[TooLarge] [NoSpace]
PageCache: 5810616 62884248
Scratch: 0 0

Largest Allocations:
Malloc: 262144
PageCache: 1172
Scratch: 6640

Prepared Statements:
Current: 6
------------------------------
[16121.892] **** Validating Game Database *****
[16126.540] Performing Localization Checks
[16126.540] Checking Tag Format...
[16126.540] Note: Tags must only use [A-Z_] characters, start with 'TXT_KEY_', and be under 128 characters long.
[16126.556] Validating UnitGameplay2DScripts
[16126.556] Missing Entry for UNIT_BARBARIAN_HORSEMAN
[16126.556] **** VALIDATION FAILED *****

[16126.556] Validation Took 4.662818 seconds
[16127.523] **** Validating Prefetch Process *****
[16127.523] **** Validation Success *****
[16127.523] SetGlobalActionInfo
[16127.523]
-- SQLite Memory Statistics --
Memory Usage:
[Cur] [Max]
Malloc: 6226784 75789152
PageCache: 6 12
LookAside: 0 0
Scratch: 0 1

Static Buffer Overflows:
[TooLarge] [NoSpace]
PageCache: 5811792 62884248
Scratch: 0 0

Largest Allocations:
Malloc: 262144
PageCache: 1172
Scratch: 6640

Prepared Statements:
Current: 6
------------------------------
 
The UNIT_BARBARIAN_HORSEMAN error is a false error, it doesn't actually cause any problems (and everyone gets it).

Check database.log as well, it will report errors more often than xml; xml.log reports errors with the actual syntax of an XML statement (like misspelling a tag or something) whereas database.log will report an error when something fails to read into the database (which sounds like the problem you're having).
 
that's the complete database.log

Code:
[16098.008] columns StrategicViewType, TileType are not unique
[16098.008] While executing - 'INSERT INTO ArtDefine_StrategicView(StrategicViewType, TileType, Asset) VALUES(?,?,?)'
[16101.611] no such table: ContentPackage.LocalizedText
[16101.627] no such table: ContentPackage.LocalizedText
[16101.627] no such table: ContentPackage.LocalizedText
[16103.562] no such table: ContentPackage.LocalizedText
[16106.151] columns StrategicViewType, TileType are not unique
[16106.151] While executing - 'INSERT INTO ArtDefine_StrategicView(StrategicViewType, TileType, Asset) VALUES(?,?,?)'
[16107.602] no such table: ContentPackage.LocalizedText
[16107.602] no such table: ContentPackage.LocalizedText
[16107.602] no such table: ContentPackage.LocalizedText
[16116.198] Validating Foreign Key Constraints...
[16116.198] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16116.213] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16116.213] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16116.213] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16116.213] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16116.213] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16116.213] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16116.213] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16116.213] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16117.461] Invalid Reference on Trait_ResourceQuantityModifiers.ResourceType - "RESOURCE_ALUMINIUM" does not exist in Resources
[16120.862] Failed Validation.
[16121.845] 
-- SQLite Memory Statistics --
Memory Usage:
		[Cur]		[Max]
Malloc:		6225608		75789152
PageCache:	6		12
LookAside:	0		0
Scratch:	0		1

Static Buffer Overflows:
		[TooLarge]	[NoSpace]
PageCache:	5810616		62884248
Scratch:	0		0

Largest Allocations:
Malloc:		262144
PageCache:	1172
Scratch:	6640

Prepared Statements:
Current:		6
------------------------------
[16121.907] Validating Foreign Key Constraints...
[16121.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16121.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16121.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16121.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16121.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16121.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16121.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16121.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[16121.923] Invalid Reference on ArtDefine_Landmarks.LayoutHandler - "SPECIAL" does not exist in ArtDefine_LandmarkTypes
[color=red][16123.155] Invalid Reference on Trait_ResourceQuantityModifiers.ResourceType - "RESOURCE_ALUMINIUM" does not exist in Resources[/color]
[16126.540] Failed Validation.
[16127.523] 
-- SQLite Memory Statistics --
Memory Usage:
		[Cur]		[Max]
Malloc:		6226784		75789152
PageCache:	6		12
LookAside:	0		0
Scratch:	0		1

Static Buffer Overflows:
		[TooLarge]	[NoSpace]
PageCache:	5811792		62884248
Scratch:	0		0

Largest Allocations:
Malloc:		262144
PageCache:	1172
Scratch:	6640

Prepared Statements:
Current:		6
------------------------------

And while posting I saw the syntax error....It doesn't like the aluminium I was trying to give to stategic riches...maybe due to not using the update syntax :D Well I think I'll have to live without double aluminium...
 
Not only is there not a RESOURCE_ALUMINIUM in the game, in the United States there is no such thing either. Remember where the game was built, and also refer to CIV5Resources.xml : RESOURCE_ALUMINUM
 
oh yes!! t568a vs t568b for those who get it ;)

Oh ps.. let me reintroduce myself. I am Howitzer and started this thread as Theodore1 and the admins merged my accounts.. so

back to our discussion..

Deleting Aliminium did not help either...

Strange thing is that I noticed I do get the free barracks..I just dont get the other buildings...

:hammer2:
 
I can get this to work in a mod for a Barracks:
Code:
<GameData>
	<Traits>
		<Update>
			<Where Type="TRAIT_CITY_STATE_FRIENDSHIP" />
			<Set Freebuilding="BUILDING_BARRACKS" /> 
		</Update>
	</Traits>
</GameData>
But I can't get multiple traits with a FreeBuilding to impliment. When I do not update Alex's standard trait and instead try to pile a bunch of new traits onto Alex, each trait with its own FreeBuilding, I get nada. I don't get database.log errors, and the traits are being registered in table <Traits>, they just aren't showing up in table <Leader_Traits> as being assigned to Alex when I view the contents of the game's database.

These sorts of reasons are why I generally use lua to accomplish such things.
 
Top Bottom