Modding Free Promotions into Buildings

wrai7h_blade

Chieftain
Joined
Aug 3, 2011
Messages
4
I've been modding CiV for awhile now (mostly units and promotion changes) and I just recently decided to make the jump to buildings. I read through the XML and it seemed pretty straight forward, so I created the following code:

Spoiler :
<GameData>
<Buildings>
<Row>
<Type>BUILDING_HOSPITAL</Type>
<TrainedFreePromotion>PROMOTION_MEDIC</TrainedFreePromotion>
</Row>

<Row>
<Type>BUILDING_MEDICAL_LAB</Type>
<TrainedFreePromotion>PROMOTION_FASTER_HEAL</TrainedFreePromotion>
</Row>

<Row>
<Type>BUILDING_BARRACKS</Type>
<TrainedFreePromotion>PROMOTION_WOODSMAN</TrainedFreePromotion>
</Row>

<Row>
<Type>BUILDING_ARMORY</Type>
<TrainedFreePromotion>PROMOTION_COVER_1</TrainedFreePromotion>
</Row>

<Row>
<Type>BUILDING_CASTLE</Type>
<GoldMaintenance>2</GoldMaintenance>
<TrainedFreePromotion>PROMOTION_SIEGE</TrainedFreePromotion>
</Row>

<Row>
<Type>BUILDING_ARSENAL</Type>
<GoldMaintenance>2</GoldMaintenance>
<TrainedFreePromotion>PROMOTION_DEFENSIVE_EMBARKATION</TrainedFreePromotion>
</Row>

<Row>
<Type>BUILDING_MILITARY_BASE</Type>
<GoldMaintenance>3</GoldMaintenance>
<TrainedFreePromotion>PROMOTION_MARCH</TrainedFreePromotion>
</Row>

<Row>
<Type>BUILDING_MILITARY_BASE</Type>
<TrainedFreePromotion>PROMOTION_SUPPLY</TrainedFreePromotion>
</Row>

<Row>
<Type>BUILDING_MILITARY_BASE</Type>
<TrainedFreePromotion>PROMOTION_REPAIR</TrainedFreePromotion>
</Row>

<Row>
<Type>BUILDING_MILITARY_BASE</Type>
<TrainedFreePromotion>PROMOTION_AIR_REPAIR</TrainedFreePromotion>
</Row>

<Row>
<Type>BUILDING_MILITARY_BASE</Type>
<TrainedFreePromotion>PROMOTION_HELI_REPAIR</TrainedFreePromotion>
</Row>

<Row>
<Type>BUILDING_HIMEJI_CASTLE</Type>
<FreePromotion>PROMOTION_MOBILITY</FreePromotion>
</Row>

<Row>
<Type>BUILDING_BRANDENBURG_GATE</Type>
<FreePromotion>PROMOTION_SPAWN_GENERALS_I</FreePromotion>
</Row>

<Row>
<Type>BUILDING_PENTAGON</Type>
<MutuallyExclusiveGroup>2</MutuallyExclusiveGroup>
</Row>

<Row>
<Type>BUILDING_KREMLIN</Type>
<MutuallyExclusiveGroup>2</MutuallyExclusiveGroup>
</Row>

</Buildings>

<Building_DomainProductionModifiers>
<Row>
<BuildingType>BUILDING_KREMLIN</BuildingType>
<DomainType>DOMAIN_LAND</DomainType>
<Modifier>30</Modifier>
</Row>
<Row>
<BuildingType>BUILDING_KREMLIN</BuildingType>
<DomainType>DOMAIN_SEA</DomainType>
<Modifier>30</Modifier>
</Row>
<Row>
<BuildingType>BUILDING_KREMLIN</BuildingType>
<DomainType>DOMAIN_AIR</DomainType>
<Modifier>30</Modifier>
</Row>
</Building_DomainProductionModifiers>

<Building_DomainFreeExperiences>
<Row>
<BuildingType>BUILDING_PENTAGON</BuildingType>
<DomainType>DOMAIN_LAND</DomainType>
<Experience>15</Experience>
</Row>
<Row>
<BuildingType>BUILDING_PENTAGON</BuildingType>
<DomainType>DOMAIN_SEA</DomainType>
<Experience>15</Experience>
</Row>
<Row>
<BuildingType>BUILDING_PENTAGON</BuildingType>
<DomainType>DOMAIN_AIR</DomainType>
<Experience>15</Experience>
</Row>
</Building_DomainFreeExperiences>

<Building_SeaPlotYieldChanges>
<Row>
<BuildingType>BUILDING_HARBOR</BuildingType>
<YieldType>YIELD_GOLD</YieldType>
<Yield>1</Yield>
</Row>
<Row>
<BuildingType>BUILDING_SEAPORT</BuildingType>
<YieldType>YIELD_PRODUCTION</YieldType>
<Yield>2</Yield>
</Row>
<Row>
<BuildingType>BUILDING_LABORATORY</BuildingType>
<YieldType>YIELD_SCIENCE</YieldType>
<Yield>2</Yield>
</Row>
</Building_SeaPlotYieldChanges>

<Building_ResourceYieldChanges>
<Row>
<BuildingType>BUILDING_FACTORY</BuildingType>
<ResourceType>RESOURCE_IRON</ResourceType>
<YieldType>YIELD_PRODUCTION</YieldType>
<Yield>2</Yield>
</Row>
<Row>
<BuildingType>BUILDING_FACTORY</BuildingType>
<ResourceType>RESOURCE_COAL</ResourceType>
<YieldType>YIELD_PRODUCTION</YieldType>
<Yield>2</Yield>
</Row>
<Row>
<BuildingType>BUILDING_FACTORY</BuildingType>
<ResourceType>RESOURCE_ALUMINUM</ResourceType>
<YieldType>YIELD_PRODUCTION</YieldType>
<Yield>2</Yield>
</Row>
</Building_ResourceYieldChanges>
</GameData>


I intended to give some of the promotions I never really get to to units trained by buildings, using the Hero Epic national wonder as a template.

But when I try to run the mod, nothing happens. I've tried it with everything in the <Buildings> tags commented out, and everything else works, but the TrainedFreePromotions stuff somehow breaks the mod.

Could someone help me out with this? I'm fairly sure it's not a spelling error, but I could be mistaken.
 
When you're modifying an existing value in an XML table, you need to use the <Update> syntax, not the <Row> syntax. Go to the References section and find Kael's beginner modders' guide, it explains this in much more detail.

Simply put, you have to phrase it as:
Code:
<GameData>
  <Buildings>
    <Update>
      <Set TrainedFreePromotion="PROMOTION_MEDIC"/>
      <Where Type="BUILDING_HOSPITAL"/>
    </Update>
  </Buildings>
</GameData>

In fact, I think he used that specific one as an example in the guide. So go read that guide; a few sections of it are a bit outdated, but it should get you started.
 
Thank you, I tried it and it worked perfectly. I didn't realize that all the buildings had a default TrainedFreePromotions value set to Null.

Hopefully this topic helps anyone else with the same issue I had.
 
What it is is that there are basically two types of XML table. Let's call them "Primary" and "Secondary".

Primary tables are the big ones: <Units>, <Buildings>, <Technologies>, and so on. The easy way to identify these is that they'll have an <ID> field that auto-increments.
In these tables, nearly every variable has been pre-defined to have a default value, usually 0/null/whatever. To modify these, then, you generally use an <Update> syntax, because even if the original entry didn't mention <TrainedFreePromotion>, it's still there, just set to NULL by the default value. You will only use <Row> definitions here if you're adding an entirely new unit, building, technology, promotion, resource, etc., and if you're doing that, then you'll have a LOT of other things you'd have to add as well.

Secondary tables are the small ones, things like Units_ResourceQuantityRequirements or Building_Flavors. These generally connect the Primary tables together in various ways, and almost never have any Default settings. While you'll occasionally use an <Update> to modify an existing entry, you're far more likely to be in a situation where you just create a new Row instead.

Once you get the hang of it it's pretty simple, but the first thing you need to consider in any change is whether you should be using a <Row> or an <Update>, so this is something you need to learn.
 
Back
Top Bottom