Help with custom trait required

Lord Shadow

General
Joined
Oct 14, 2005
Messages
2,005
Location
Buenos Aires
So I'm trying to create a custom trait which grants +1 Production from Forests and Jungles, but I can't seem to be able to figure it out from Civ5Traits.xml. I might need to create a new table, and I have zero experience with that.

I worked rather blindly and here's the result

Code:
<GameData>
    <Table name="Trait_FeatureYieldChanges">
        <Column name="TraitType" type="text" reference="Traits(Type)"/>
        <Column name="FeatureType" type="text"/>
        <Column name="YieldType" type="text" reference="Yields(Type)"/>
        <Column name="Yield" type="integer"/>
    </Table>
    <Traits>
        <Row>
            <Type>TRAIT_TREE_PRODUCTION</Type>
            <Description>TXT_KEY_TRAIT_TREE_PRODUCTION</Description>
            <ShortDescription>TXT_KEY_TRAIT_TREE_PRODUCTION_SHORT</ShortDescription>
        </Row>
    </Traits>
    <Trait_FeatureYieldChanges>
        <Row>
            <Type>TRAIT_TREE_PRODUCTION</Type>
            <FeatureType>FEATURE_FOREST</FeatureType>
            <YieldType>YIELD_PRODUCTION</YieldType>
            <Yield>1</Yield>
        </Row>
        <Row>
            <Type>TRAIT_TREE_PRODUCTION</Type>
            <FeatureType>FEATURE_JUNGLE</FeatureType>
            <YieldType>YIELD_PRODUCTION</YieldType>
            <Yield>1</Yield>
        </Row>
    </Trait_FeatureYieldChanges>
</GameData>
There must be some error(s) in there. I'd love some input.
 
I got nearly excatly the same issue. Can't figure out how to make trait give extra production or similirar from terrain or feature. (And I made a topic about it.)
 
Sorry, it doesn't work that way. The game doesn't have a Trait_FeatureYieldChanges table. While you can create a table with whatever data you please, the game won't actually know what to DO with that data. So it won't work. Trait modding in XML is sadly pretty limited, you can only use the parameters that already exist in the schemas. For instance, you can give Great People or Great Scientist generation bonuses, but you can't make a trait that affects Great Merchant generation.
 
Sorry, it doesn't work that way. The game doesn't have a Trait_FeatureYieldChanges table. While you can create a table with whatever data you please, the game won't actually know what to DO with that data. So it won't work. Trait modding in XML is sadly pretty limited, you can only use the parameters that already exist in the schemas. For instance, you can give Great People or Great Scientist generation bonuses, but you can't make a trait that affects Great Merchant generation.
Is there any way to achieve my desired effect then? :(

There's the Trait_YieldChanges and Trait_YieldModifiers tables, but they don't specify terrain nor features, so I'm not quite sure how they're supposed to work.
 
Not right now. Once the DLL code is released, it will be possible to program new effects altogether in C++.

Trait_YieldChanges will change ALL yields of a type. Say, you can use it to give a civ extra food. But those are global, not tied to terrain/features. The Trait_YieldModifiers table is something similar, not sure how it differs from the first one exactly, but it won't do what you want either.

In the absence of C++ code, it's quite likely you could work around this through Lua, but I am not currently knowledgable about that.
 
Do you have any programming experience? If you do, you'll be able to get into Lua fairly quickly.
 
Sorry, it doesn't work that way. The game doesn't have a Trait_FeatureYieldChanges table. While you can create a table with whatever data you please, the game won't actually know what to DO with that data. So it won't work. Trait modding in XML is sadly pretty limited, you can only use the parameters that already exist in the schemas. For instance, you can give Great People or Great Scientist generation bonuses, but you can't make a trait that affects Great Merchant generation.

Really, you can't even specify by great person type? Could you, at least theoretically, swap the Great Merchant and Great Scientist abilities so the "Faster Great Scientist" ability would give you faster great merchants?
 
Shown in the spoiler below is the schema located in Civ5Traits.xml located at D:\Program Files (x86)\Steam\SteamApps\common\sid meier's civilization v\Assets\Gameplay\XML\Civilizations

I am working on a Sumeria civilization (probably just a remake from Civ IV) to test my XML modding skills. From what I understand if I want to make a trait the options in the schema is what i'm limited to. Someone else could confirm this. Hope this helps at least. I went through all the traits for all the leaders so I could understand the XML language a little better and that helped tremendously.

Spoiler :
<Table name="Traits">
<Column name="ID" type="integer" primarykey="true" autoincrement="true"/>
<Column name="Type" type="text" notnull="true" unique="true"/>
<Column name="Description" type="text"/>
<Column name="ShortDescription" type="text"/>
<Column name="LevelExperienceModifier" type="integer" default="0"/>
<Column name="GreatPeopleRateModifier" type="integer" default="0"/>
<Column name="GreatScientistRateModifier" type="integer" default="0"/>
<Column name="GreatGeneralRateModifier" type="integer" default="0"/>
<Column name="GreatGeneralExtraBonus" type="integer" default="0"/>
<Column name="MaxGlobalBuildingProductionModifier" type="integer" default="0"/>
<Column name="MaxTeamBuildingProductionModifier" type="integer" default="0"/>
<Column name="MaxPlayerBuildingProductionModifier" type="integer" default="0"/>
<Column name="CityUnhappinessModifier" type="integer" default="0"/>
<Column name="PopulationUnhappinessModifier" type="integer" default="0"/>
<Column name="CityStateBonusModifier" type="integer" default="0"/>
<Column name="CityStateFriendshipModifier" type="integer" default="0"/>
<Column name="CityStateCombatModifier" type="integer" default="0"/>
<Column name="LandBarbarianConversionPercent" type="integer" default="0"/>
<Column name="SeaBarbarianConversionPercent" type="integer" default="0"/>
<Column name="CapitalBuildingModifier" type="integer" default="0"/>
<Column name="PlotBuyCostModifier" type="integer" default="0"/>
<Column name="PlotCultureCostModifier" type="integer" default="0"/>
<Column name="CultureFromKills" type="integer" default="0"/>
<Column name="CityCultureBonus" type="integer" default="0"/>
<Column name="PolicyCostModifier" type="integer" default="0"/>
<Column name="TradeRouteChange" type="integer" default="0"/>
<Column name="WonderProductionModifier" type="integer" default="0"/>
<Column name="PlunderModifier" type="integer" default="0"/>
<Column name="GoldenAgeDurationModifier" type="integer" default="0"/>
<Column name="GoldenAgeMoveChange" type="integer" default="0"/>
<Column name="GoldenAgeCombatModifier" type="integer" default="0"/>
<Column name="ExtraEmbarkMoves" type="integer" default="0"/>
<Column name="FightWellDamaged" type="boolean" default="false"/>
<Column name="MoveFriendlyWoodsAsRoad" type="boolean" default="false"/>
<Column name="FasterAlongRiver" type="boolean" default="false"/>
<Column name="EmbarkedNotCivilian" type="boolean" default="false"/>
<Column name="FreeUnit" type="text" reference="UnitClasses(Type)" default="NULL"/>
<Column name="FreeUnitPrereqTech" type="text" reference="Technologies(Type)" default="NULL"/>
<Column name="ObsoleteTech" type="text" reference="Technologies(Type)" default="NULL"/>
</Table>
<Table name="Trait_ExtraYieldThresholds">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="YieldType" type="text" reference="Yields(Type)"/>
<Column name="Yield" type="integer"/>
</Table>
<Table name="Trait_YieldChanges">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="YieldType" type="text" reference="Yields(Type)"/>
<Column name="Yield" type="integer"/>
</Table>
<Table name="Trait_YieldChangesStrategicResources">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="YieldType" type="text" reference="Yields(Type)"/>
<Column name="Yield" type="integer"/>
</Table>
<Table name="Trait_YieldModifiers">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="YieldType" type="text" reference="Yields(Type)"/>
<Column name="Yield" type="integer"/>
</Table>
<Table name="Trait_FreePromotions">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="PromotionType" type="text" reference="UnitPromotions(Type)"/>
</Table>
<Table name="Trait_FreePromotionUnitCombats">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="UnitCombatType" type="text" reference="UnitCombatInfos(Type)"/>
<Column name="PromotionType" type="text" reference="UnitPromotions(Type)"/>
</Table>
<Table name="Trait_MovesChangeUnitCombats">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="UnitCombatType" type="text" reference="UnitCombatInfos(Type)"/>
<Column name="MovesChange" type="int"/>
</Table>
<Table name="Trait_Terrains">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="TerrainType" type="text"/>
<Column name="StrategicResourceQuantityModifier" type="integer" default="0"/>
</Table>
<Table name="Trait_ResourceQuantityModifiers">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="ResourceType" type="text" reference="Resources(Type)"/>
<Column name="ResourceQuantityModifier" type="integer" default="0"/>
</Table>
 
Shown in the spoiler below is the schema located in Civ5Traits.xml located at D:\Program Files (x86)\Steam\SteamApps\common\sid meier's civilization v\Assets\Gameplay\XML\Civilizations

I am working on a Sumeria civilization (probably just a remake from Civ IV) to test my XML modding skills. From what I understand if I want to make a trait the options in the schema is what i'm limited to. Someone else could confirm this. Hope this helps at least. I went through all the traits for all the leaders so I could understand the XML language a little better and that helped tremendously.

Spoiler :
<Table name="Traits">
<Column name="ID" type="integer" primarykey="true" autoincrement="true"/>
<Column name="Type" type="text" notnull="true" unique="true"/>
<Column name="Description" type="text"/>
<Column name="ShortDescription" type="text"/>
<Column name="LevelExperienceModifier" type="integer" default="0"/>
<Column name="GreatPeopleRateModifier" type="integer" default="0"/>
<Column name="GreatScientistRateModifier" type="integer" default="0"/>
<Column name="GreatGeneralRateModifier" type="integer" default="0"/>
<Column name="GreatGeneralExtraBonus" type="integer" default="0"/>
<Column name="MaxGlobalBuildingProductionModifier" type="integer" default="0"/>
<Column name="MaxTeamBuildingProductionModifier" type="integer" default="0"/>
<Column name="MaxPlayerBuildingProductionModifier" type="integer" default="0"/>
<Column name="CityUnhappinessModifier" type="integer" default="0"/>
<Column name="PopulationUnhappinessModifier" type="integer" default="0"/>
<Column name="CityStateBonusModifier" type="integer" default="0"/>
<Column name="CityStateFriendshipModifier" type="integer" default="0"/>
<Column name="CityStateCombatModifier" type="integer" default="0"/>
<Column name="LandBarbarianConversionPercent" type="integer" default="0"/>
<Column name="SeaBarbarianConversionPercent" type="integer" default="0"/>
<Column name="CapitalBuildingModifier" type="integer" default="0"/>
<Column name="PlotBuyCostModifier" type="integer" default="0"/>
<Column name="PlotCultureCostModifier" type="integer" default="0"/>
<Column name="CultureFromKills" type="integer" default="0"/>
<Column name="CityCultureBonus" type="integer" default="0"/>
<Column name="PolicyCostModifier" type="integer" default="0"/>
<Column name="TradeRouteChange" type="integer" default="0"/>
<Column name="WonderProductionModifier" type="integer" default="0"/>
<Column name="PlunderModifier" type="integer" default="0"/>
<Column name="GoldenAgeDurationModifier" type="integer" default="0"/>
<Column name="GoldenAgeMoveChange" type="integer" default="0"/>
<Column name="GoldenAgeCombatModifier" type="integer" default="0"/>
<Column name="ExtraEmbarkMoves" type="integer" default="0"/>
<Column name="FightWellDamaged" type="boolean" default="false"/>
<Column name="MoveFriendlyWoodsAsRoad" type="boolean" default="false"/>
<Column name="FasterAlongRiver" type="boolean" default="false"/>
<Column name="EmbarkedNotCivilian" type="boolean" default="false"/>
<Column name="FreeUnit" type="text" reference="UnitClasses(Type)" default="NULL"/>
<Column name="FreeUnitPrereqTech" type="text" reference="Technologies(Type)" default="NULL"/>
<Column name="ObsoleteTech" type="text" reference="Technologies(Type)" default="NULL"/>
</Table>
<Table name="Trait_ExtraYieldThresholds">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="YieldType" type="text" reference="Yields(Type)"/>
<Column name="Yield" type="integer"/>
</Table>
<Table name="Trait_YieldChanges">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="YieldType" type="text" reference="Yields(Type)"/>
<Column name="Yield" type="integer"/>
</Table>
<Table name="Trait_YieldChangesStrategicResources">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="YieldType" type="text" reference="Yields(Type)"/>
<Column name="Yield" type="integer"/>
</Table>
<Table name="Trait_YieldModifiers">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="YieldType" type="text" reference="Yields(Type)"/>
<Column name="Yield" type="integer"/>
</Table>
<Table name="Trait_FreePromotions">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="PromotionType" type="text" reference="UnitPromotions(Type)"/>
</Table>
<Table name="Trait_FreePromotionUnitCombats">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="UnitCombatType" type="text" reference="UnitCombatInfos(Type)"/>
<Column name="PromotionType" type="text" reference="UnitPromotions(Type)"/>
</Table>
<Table name="Trait_MovesChangeUnitCombats">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="UnitCombatType" type="text" reference="UnitCombatInfos(Type)"/>
<Column name="MovesChange" type="int"/>
</Table>
<Table name="Trait_Terrains">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="TerrainType" type="text"/>
<Column name="StrategicResourceQuantityModifier" type="integer" default="0"/>
</Table>
<Table name="Trait_ResourceQuantityModifiers">
<Column name="TraitType" type="text" reference="Traits(Type)"/>
<Column name="ResourceType" type="text" reference="Resources(Type)"/>
<Column name="ResourceQuantityModifier" type="integer" default="0"/>
</Table>


To reiterate what someone else said earlier there is not a element to increase great merchats. Below are the available trait options for great people

<Column name="GreatPeopleRateModifier" type="integer" default="0"/>
<Column name="GreatScientistRateModifier" type="integer" default="0"/>
<Column name="GreatGeneralRateModifier" type="integer" default="0"/>
<Column name="GreatGeneralExtraBonus" type="integer" default="0"/>

There is nothing to say you can give your new civ a UB that increases great merchant production by X% and give them a really weak civ trait to compensate. I'd have to look at the building schema first which I haven't.

Sorry about double post. My bad
 
Yeah, that's exactly it, and that's what we're limited to for now. Great General or Great Scientist modifiers exist, but there's no proper way to apply them to, say, Artists or Merchants.

EDIT: And no, the building workaround won't do either, buildings can increase the rate of all GPs, but not one GP type specifically.
 
I'll have to settle with another trait for the time being, it seems.



Not too bad, and looks balanced enough, considering strategic resources are Horses, Iron, Coal, Oil, Aluminum and Uranium. I wouldn't be getting science from cows and bananas. :lol:
 
I have an idea that might work. Shown in the quote below is an excerpt from schema for Civ5Buildings.xml located at D:\Program Files (x86)\Steam\SteamApps\common\sid meier's civilization v\Assets\Gameplay\XML\Buildings.

In the schema there is this option

<Table name="Building_FeatureYieldChanges">
<Column name="BuildingType" type="text" reference="Buildings(Type)"/>
<Column name="FeatureType" type="text" reference="Features(Type)"/>
<Column name="YieldType" type="text" reference="Yields(Type)"/>
<Column name="Yield" type="integer"/>

You could create an UB for your Civ that gives you a +1 prod from jungles/forests using Building_featureYieldChanges. You could then even make the building free in every city therefore creating a psuedotrait.

You add the free building in Civ5Civilizations in the following directory D:\Program Files (x86)\Steam\SteamApps\common\sid meier's civilization v\Assets\Gameplay\XML\Civilizations. In the schema there is this option

<Table name="Civilization_FreeBuildingClasses">
<Column name="CivilizationType" type="text" reference="Civilizations(Type)"/>
<Column name="BuildingClassType" type="text" reference="BuildingClasses(Type)"/>
</Table>

The palace is given to everyone using this example

<Civilization_FreeBuildingClasses>
<Row>
<CivilizationType>CIVILIZATION_SONGHAI</CivilizationType>
<BuildingClassType>BUILDINGCLASS_PALACE</BuildingClassType>
</Row>
</Civilization_FreeBuildingClasses>

Unfortunately you would use up your UB for the Civilization and i'm not sure if you can have two unique buildings to get the trait you were intersted in. But you could do this and then give them a very weak trait to compensate. It isn't ideal granted but maybe it will help. Sorry i'm no pro. Someone else might be able to confirm.
 
Clever, but yeah, I'm not sure if you can have more than a couple of unique things besides the trait.
 
well each civ has two UUs so i thought maybe they could have two UBs. One for your trait essentially then the real one. I'll dive into more code.
 
In CIV5Civilizations there is this in the schema. This is the section of code that implements UBs for each Civilization.

Spoiler :
<Civilization_BuildingClassOverrides>
<Row>
<CivilizationType>CIVILIZATION_SONGHAI</CivilizationType>
<BuildingClassType>BUILDINGCLASS_TEMPLE</BuildingClassType>
<BuildingType>BUILDING_MUD_PYRAMID_MOSQUE</BuildingType>
</Row>[/QUOTE]
</Civilization_BuildingClassOverrides>


In the mod made by Kael for Celtic. He created his own building class in CIV5BuildingClasses.xml for his UB.

Spoiler :
<GameData>
<BuildingClasses>
<Row>
<Type>BUILDINGCLASS_PALISADE</Type>
<DefaultBuilding>BUILDING_PALISADE</DefaultBuilding>
<Description>TXT_KEY_BUILDING_PALISADE</Description>
</Row>
</BuildingClasses>
</GameData>


Then he added the building to Civ5Buildings.xml for UB specific data.

Spoiler :
<Buildings>
<Row>
<Type>BUILDING_PALISADE</Type>
<BuildingClass>BUILDINGCLASS_PALISADE</BuildingClass>
<Cost>60</Cost>
<GoldMaintenance>1</GoldMaintenance>
<Help>TXT_KEY_BUILDING_PALISADE_STRATEGY</Help>
<Description>TXT_KEY_BUILDING_PALISADE</Description>
<Civilopedia>TXT_KEY_CIV5_BUILDINGS_PALISADE_TEXT</Civilopedia>
<Strategy>TXT_KEY_BUILDING_PALISADE_STRATEGY</Strategy>
<ArtDefineTag>ART_DEF_BUILDING_WALLS</ArtDefineTag>
<MaxStartEra>ERA_ANCIENT</MaxStartEra>
<MinAreaSize>-1</MinAreaSize>
<AllowsRangeStrike>true</AllowsRangeStrike>
<Defense>250</Defense>
<CityWall>true</CityWall>
<HurryCostModifier>25</HurryCostModifier>
<IconAtlas>BW_ATLAS_1</IconAtlas>
<NeverCapture>true</NeverCapture>
<PortraitIndex>32</PortraitIndex>
</Row>
</Buildings>


I see absolutely no reason why you can't have two UB. Create one UB from scratch and its building class and make it free for your civilization as I showed in a previous post. Give your civilization no trait which I think is possible (haven't verified: the barbs have no traits and minor civs so i'm thinking maybe). The text description can explain everything so people don't get confused. Then give them the two UUs and one more UBs like normal.
 
A handful of concerns about that particular method:

- If the civilization had two standard UUs and the UB representing the trait, would the latter appear on the right-hand side of the civ selection window during game setups? That'd be ugly.
- I'm not sure how the "free building" mechanic works. Yes, it's used by the capitol, but that's a unique building that exists only in the capital. The trait-building would have to be present in every city.
- If another civilization were to take one of your cities, he'd either gain your 'trait' in that particular place, or destroy the building during the conquest of the settlement. The latter would present a problem to you if you were to retake the city. You'd have to somehow rebuild the thing.
 
A handful of concerns about that particular method:

- If the civilization had two standard UUs and the UB representing the trait, would the latter appear on the right-hand side of the civ selection window during game setups? That'd be ugly.
- I'm not sure how the "free building" mechanic works. Yes, it's used by the capitol, but that's a unique building that exists only in the capital. The trait-building would have to be present in every city.
- If another civilization were to take one of your cities, he'd either gain your 'trait' in that particular place, or destroy the building during the conquest of the settlement. The latter would present a problem to you if you were to retake the city. You'd have to somehow rebuild the thing.

1) My theory on the first one i'm hoping is that only one of the building shows up and the second is not placed but i don't know yet. I will be doing this same theory for my sumerian civ on tuesday can't start till then.
2) I thought the palace was treated like a national wonder so even though it is a free building it only appears once. Going to confirm. EDIT: Palace is considered a national wonder so it isn't given free to each city so any other free building in theory should go to every city. I won't know definitely until I do but i'm hoping it is like in previous civ games where a wonder would give a free building to each city. similar concept.

Spoiler :
<!--National Wonders -->
<Row>
<Type>BUILDING_PALACE</Type>
<BuildingClass>BUILDINGCLASS_PALACE</BuildingClass>
<Cost>0</Cost>
<Help>TXT_KEY_BUILDING_PALACE_HELP</Help>
<Description>TXT_KEY_BUILDING_PALACE</Description>
<Civilopedia>TXT_KEY_CIV5_BUILDINGS_PALACE_TEXT</Civilopedia>
<Strategy>TXT_KEY_BUILDING_PALACE_STRATEGY</Strategy>
<ArtDefineTag>PALACE</ArtDefineTag>
<Capital>true</Capital>
<NukeImmune>true</NukeImmune>
<MinAreaSize>-1</MinAreaSize>
<Culture>1</Culture>
<Defense>200</Defense>
<ArtInfoCulturalVariation>true</ArtInfoCulturalVariation>
<DisplayPosition>32</DisplayPosition>
<NeverCapture>true</NeverCapture>
<IconAtlas>BW_ATLAS_1</IconAtlas>
<PortraitIndex>19</PortraitIndex>
</Row>
3) You can make a building always get destroyed when captured. I'll find the tag after this post. When you recapture it it should be placed back in the city in the same manner when you capture an enemy city.

Spoiler :
<NeverCapture>true</NeverCapture>


You bring up good points. I'll have answers next week after my vacation.
 
Top Bottom