How to make a building: Entry level.

thadian

Kami of Awakened Dreamers
Joined
Sep 27, 2006
Messages
2,288
Location
Indiana, USA
We all want to make the game how we want it, but it can be tough to do with all the strange codes and complex stuff. Recently, i have begun tearing into files of different mods, including Religion and Revolution for Civ4Col - and for Civ 5, i have torn into the files of Echoes of Ages and Community Call to Power. I have gained a great deal of knowledge in a short amount of time, and if i can do it, so can you! Now, i believe a core element in learning is teaching. In this instructional tutorial, my goal is to teach an average, unskilled Civilization 5 player how to create a building.

Lets start by downloading a program called Notepad++ which is a piece of freeware, very high quality notepad-like tool for modding. Using this, you can open almost anything, and with it's plugin's like Compare, you just can't go wrong. Only download this from it's official website.

1. Download, and Install Notepad++.

2. Open Notepad++.

3. Name your file - I named mine Buildings_Template.xml - XML is one of the bottom "save as" extensions on the list, use it.

Now that you have come this far, let's copy-paste a gift from me to you, This template can be used for EVERYTHING:

Don't worry, i will help you understand this as well as i do.
Spoiler :

Code:
<GameData>
	<Table name="Building_BuildingClassYieldChanges">
		<Column name="BuildingType" type="text" reference="Buildings(Type)"/>
		<Column name="BuildingClassType" type="text" reference="BuildingClasses(Type)"/>
		<Column name="YieldType" type="integer" reference="Yields(Type)"/>
		<Column name="YieldChange" type="integer" default="0"/>
	</Table>
		<Table name="Building_Flavors">
		<Column name="BuildingType" type="text" reference="Buildings(Type)"/>
		<Column name="FlavorType" type="text" reference="Flavors(Type)"/>
		<Column name="Flavor" type="integer"/>
	</Table>
	<Table name="Building_ClassesNeededInCity">
		<Column name="BuildingType" type="text" reference="Buildings(Type)"/>
		<Column name="BuildingClassType" type="text" reference="BuildingClasses(Type)"/>
	</Table>
	<Table name="Building_PrereqBuildingClasses">
		<Column name="BuildingType" type="text" reference="Buildings(Type)"/>
		<Column name="BuildingClassType" type="text" reference="BuildingClasses(Type)"/>
		<Column name="NumBuildingNeeded" type="integer"/>
	</Table>
	<Table name="Building_YieldChanges">
		<Column name="BuildingType" type="text" reference="Buildings(Type)"/>
		<Column name="YieldType" type="text" reference="Yields(Type)"/>
		<Column name="Yield" type="integer"/>
	</Table>
	<Table name="Building_YieldChangesPerPop">
		<Column name="BuildingType" type="text" reference="Buildings(Type)"/>
		<Column name="YieldType" type="text" reference="Yields(Type)"/>
		<Column name="Yield" type="integer"/>
	</Table>
	<Table name="Building_YieldModifiers">
		<Column name="BuildingType" type="text" reference="Buildings(Type)"/>
		<Column name="YieldType" type="text" reference="Yields(Type)"/>
		<Column name="Yield" type="integer"/>
	</Table>


Before you confuse yourself, this is the Palace in your capital. We will analyze which functions from the above table is used in the palace.
Spoiler :

Code:
<buildings>
	<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>
		<Defense>250</Defense>
		<ArtInfoCulturalVariation>true</ArtInfoCulturalVariation>
		<DisplayPosition>32</DisplayPosition>
		<NeverCapture>true</NeverCapture>
		<IconAtlas>BW_ATLAS_1</IconAtlas>
		<PortraitIndex>19</PortraitIndex>
	</Row>
</Buildings>


Now, lets break this down.
Spoiler :

Code:
<Buildings>
	<Row>
			<Type>BUILDING_PALACE</Type>
			<BuildingClass>BUILDINGCLASS_PALACE</BuildingClass>
			<Cost>0</Cost>

Above us, This means the building is a Palace - and the Class is a Palace. This is because there might be multiple types of palaces (or barracks, such as Krepost).

Spoiler :

Code:
                        <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>
Above us, These are your entries for texts, such as Civlopedia. Below this, most info should make itself obvious or be irrelevant in the starter stages. Note that <NeverCapture> Is used by National Wonders to prevent the conqueror from keeping the building when the city falls.
Spoiler :

Code:
			<Capital>true</Capital>
			<NukeImmune>true</NukeImmune>
			<MinAreaSize>-1</MinAreaSize>
			<Defense>250</Defense>
			<ArtInfoCulturalVariation>true</ArtInfoCulturalVariation>
			<DisplayPosition>32</DisplayPosition>
			<NeverCapture>true</NeverCapture>

For art, to simplify things, we will use icons that exist in the game. There is no shame in setting up art files to these icons to get your building in the game - you can always go back and add a new artwork later, but that is a different tutorial.
Spoiler :

Code:
			<IconAtlas>BW_ATLAS_1</IconAtlas>
			<PortraitIndex>19</PortraitIndex>
	</Row>
	</Buildings>

Below us, Flavors tell the AI how to value a building. For example, FlavorType can be SCIENCE or GOLD. Sometimes a building can be more than ONE flavor to appeal to different AI mentality.
Spoiler :

Code:
	<Building_Flavors>
		<Row>
			<BuildingType>BUILDING_PALACE</BuildingType>
			<FlavorType>FLAVOR_GOLD</FlavorType>
			<Flavor>5</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_PALACE</BuildingType>
			<FlavorType>FLAVOR_SCIENCE</FlavorType>
			<Flavor>10</Flavor>
		</Row>
		<Row>
			<BuildingType>BUILDING_PALACE</BuildingType>
			<FlavorType>FLAVOR_CULTURE</FlavorType>
			<Flavor>10</Flavor>
		</Row>
        </Building_Flavors>


Below us, we are going to look at what causes the palace to produce gold, production and science.

Spoiler :

Code:
	<Building_YieldChanges>
		<Row>
			<BuildingType>BUILDING_PALACE</BuildingType>
			<YieldType>YIELD_GOLD</YieldType>
			<Yield>3</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_PALACE</BuildingType>
			<YieldType>YIELD_PRODUCTION</YieldType>
			<Yield>3</Yield>
		</Row>
		<Row>
			<BuildingType>BUILDING_PALACE</BuildingType>
			<YieldType>YIELD_SCIENCE</YieldType>
			<Yield>3</Yield>
		</Row>
	</Building_YieldChanges>


Lets take just 2 minutes, and look at the "Template" i provided you. Can you find the values in it the palace is using? Your building, like the palace will need to do something. Now, to practice what we have learned and create a new building!

Open a new file in Notepad++. This will be called Palace_Altar.xml -

I will give you another present, you may even copy-paste this to the bottom of your template file so you can get use to this.

Copy / Paste this code into Palace_Altar.xml

Spoiler :

Code:
<!-- Palace Altar--->
<GameData>
	<BuildingClasses>
		<Row>
			<Type>BUILDINGCLASS_PALACE_ALTAR</Type>
			<DefaultBuilding>BUILDING_PALACE_ALTAR</DefaultBuilding>
			<Description>TXT_KEY_BUILDING_PALACE_ALTAR</Description>
		</Row>
	</BuildingClasses>
	<Buildings>
		<Row>
			<Type>BUILDING_PALACE_ALTAR</Type>
			<BuildingClass>BUILDINGCLASS_PALACE_ALTAR</BuildingClass>
			<Cost>40</Cost>
			<GoldMaintenance>0</GoldMaintenance>
			<Description>TXT_KEY_BUILDING_PALACE_ALTAR</Description>
			<Civilopedia>TXT_KEY_CIV5_BUILDINGS_PALACE_ALTAR_TEXT</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_PALACE_ALTAR_STRATEGY</Strategy>
			<Help>TXT_KEY_BUILDING_PALACE_ALTAR_HELP</Help>
			<ArtDefineTag>ART_DEF_BUILDING_GPALACE_ALTAR</ArtDefineTag>
			<MinAreaSize>-1</MinAreaSize>
			<Happiness>1</Happiness>
			<ConquestProb>66</ConquestProb>
			<HurryCostModifier>25</HurryCostModifier>
			<NeverCapture>true</NeverCapture>
			<IconAtlas>BW_ATLAS_1</IconAtlas>
			<PortraitIndex>19</PortraitIndex>
		</Row>
	</Buildings>
	<Building_ClassesNeededInCity>
		<Row>
			<BuildingType>BUILDING_PALACE_ALTAR</BuildingType>
			<BuildingClassType>BUILDINGCLASS_PALACE</BuildingClassType>
		</Row>
	</Building_ClassesNeededInCity>
	<Building_YieldChanges>
		<Row>
			<BuildingType>BUILDING_PALACE_ALTAR</BuildingType>
			<YieldType>YIELD_FAITH</YieldType>
			<Yield>1</Yield>
		</Row>
	</Building_YieldChanges>
	<Building_Flavors>
		<Row>
			<BuildingType>BUILDING_PALACE_ALTAR</BuildingType>
			<FlavorType>FLAVOR_RELIGION</FlavorType>
			<Flavor>10</Flavor>
		</Row>
	</Building_Flavors>
	<Language_en_US>
		<Row Tag="TXT_KEY_BUILDING_PALACE_ALTAR">
			<Text>The Palace Alter</Text>
		</Row>
		<Row Tag="TXT_KEY_BUILDING_PALACE_ALTAR_HELP">
			<Text>The Palace Alter adds +1 [ICON_PEACE] Faith.</Text>
		</Row>
		<Row Tag="TXT_KEY_BUILDING_PALACE_ALTER_STRATEGY">
			<Text>The Palace Altar provides a boost to your [ICON_PEACE] Faith.</Text>
		</Row>
		<Row Tag="TXT_KEY_BUILDING_PALACE_ALTAR_Text">
			<Text>The Palace Altar allows a great leader to perform spiritual ceremonies. These can be performed by a high priest or the leader personally. Inspiring faith and happiness among those closest to the throne, those officials will help garner the trust of the people. As your people explore the vast unknown, Faith provides security and hope in dangerous times while inspiring people during good times.</Text>
		</Row>
	</Language_en_US>
</GameData>


Lets look at WHAT this building is going to do, one step at a time. Palace Alter uses a comment <!-- Here --> which keeps things clean. You should use comments to make small notes of things. <GameData> and </GameData> is how you begin and end EVERY file for it to effect the game.

Spoiler :

Code:
<!-- Palace Altar--->
<GameData>
	<BuildingClasses>
		<Row>
			<Type>BUILDINGCLASS_PALACE_ALTAR</Type>
			<DefaultBuilding>BUILDING_PALACE_ALTAR</DefaultBuilding>
			<Description>TXT_KEY_BUILDING_PALACE_ALTAR</Description>
		</Row>
	</BuildingClasses>

Above we are setting the Building Class, Default Version of the building and it's description name. If we made it BUILDINGCLASS_MONUMENT, then this would be a unique monument instead of it's own building. Lets stick with PALACE_ALTAR.


Spoiler :

Code:
	<Buildings>
		<Row>
			<Type>BUILDING_PALACE_ALTAR</Type>
			<BuildingClass>BUILDINGCLASS_PALACE_ALTAR</BuildingClass>
			<Cost>40</Cost>
			<GoldMaintenance>0</GoldMaintenance>


Above us, we set the cost of 40 hammers, and 0 Gold in maintenance. Below us, we are going to tell it what it's description targets are.
Spoiler :

Code:
	<Description>TXT_KEY_BUILDING_PALACE_ALTAR</Description>
	<Civilopedia>TXT_KEY_CIV5_BUILDINGS_PALACE_ALTAR_TEXT</Civilopedia>
	<Strategy>TXT_KEY_BUILDING_PALACE_ALTAR_STRATEGY</Strategy>
	<Help>TXT_KEY_BUILDING_PALACE_ALTAR_HELP</Help>
	<ArtDefineTag>ART_DEF_BUILDING_PALACE_ALTAR</ArtDefineTag>

Now we are going to cause it to give one happiness and set it's icons.
Spoiler :

Code:
			<MinAreaSize>-1</MinAreaSize>
			[B]<Happiness>1</Happiness>[/B]
			<ConquestProb>66</ConquestProb>
			<HurryCostModifier>25</HurryCostModifier>
			<NeverCapture>true</NeverCapture>
			<IconAtlas>BW_ATLAS_1</IconAtlas>
			<PortraitIndex>19</PortraitIndex>
		</Row>
	</Buildings>
The next part will make the Palace Altar require a palace.
Spoiler :

Code:
	<Building_ClassesNeededInCity>
		<Row>
			<BuildingType>BUILDING_PALACE_ALTAR</BuildingType>
			<BuildingClassType>BUILDINGCLASS_PALACE</BuildingClassType>
		</Row>
	</Building_ClassesNeededInCity>

The next step is telling it to produce 1 Faith in addition to it's happiness.
Spoiler :

Code:
	<Building_YieldChanges>
		<Row>
			<BuildingType>BUILDING_PALACE_ALTAR</BuildingType>
			<YieldType>YIELD_PEACE</YieldType>
			<Yield>1</Yield>
		</Row>
	</Building_YieldChanges>

Almost done, bear with me! Time to set the flavor. We could go with religion, happiness or both. I will let you choose, i set mine to Religion.
Spoiler :

Code:
	<Building_Flavors>
		<Row>
			<BuildingType>BUILDING_PALACE_ALTAR</BuildingType>
			<FlavorType>FLAVOR_RELIGION</FlavorType>
			<Flavor>30</Flavor>
		</Row>
	</Building_Flavors>

To be clean we will put our information right here for civlopedia entries.
Spoiler :

Code:
	<Language_en_US>
		<Row Tag="TXT_KEY_BUILDING_PALACE_ALTAR">
			<Text>Palace Alter</Text>
		</Row>
		<Row Tag="TXT_KEY_BUILDING_PALACE_ALTAR_HELP">
			<Text>The Palace Altar adds +1 [ICON_PEACE] Faith.</Text>
		</Row>
		<Row Tag="TXT_KEY_BUILDING_PALACE_ALTAR_STRATEGY">
			<Text>The Palace Altar provides a boost to your Palace [ICON_PEACE] Faith.</Text>
		</Row>
		<Row Tag="TXT_KEY_BUILDING_PALACE_ALTAR_Text">
			<Text>The Palace Altar allows a great leader to perform spiritual ceremonies. These can be performed by a high priest or the leader personally. Inspiring faith and happiness among those closest to the throne, those officials will help garner the trust of the people.</Text>
		</Row>
	</Language_en_US>
</GameData>


Do you notice how easy this is? At this point, you can insert another comment for another cool building - or you can make changes to this one! Remember the template i gave you for the buildings?

Now would be a good time to go into one of these 2 places:

Vanilla:
C:\Program Files (x86)\Steam\steamapps\common\sid meier's civilization v\assets\Gameplay\XML\Buildings

Gods and Kings:

C:\Program Files (x86)\Steam\steamapps\common\sid meier's civilization v\assets\DLC\Expansion\Gameplay\XML\Buildings

Open these files with Notepad++ and look at them. Start by opening the template, then looking at the buildings. Library, Monument, Shrine, Palace, and Barracks give you a good idea of what lines in the template are used by that building.

Save your file, and make some changes. Change the name of the building and always ask questions when you have them - most modders are happy to help others learn. I welcome criticism on how to improve this tutorial, and better information from more experienced modders.

Please bear in mind this is a "101" tutorial, and the target audience is the person who has never modded before but just knows if they can just add ONE building, they can add more buildings, then a unit, then more units. We all start somewhere, and this building was my start and i share it with you.

Last thing:
Open modbuddy.
Click file, new project - name it! go through the basics until it stops guiding you.
Click "open" and "file" - open your .xml file you made.
Click build - build solution. Click build then build modname (under it build solution).
Click Save All.
Open Solution Manager, and right click - click properties.
Click Action
Click Add
UpdateDatabase - Modname.

Spoiler :

this tells the mod to load itself into the database when the player clicks the green light to activate your mod.


Happy Modding!
 
Question. So I've gone through multiple create-a-building tutorials (great job on yours btw- very clear and neat), but i still cant get the buildings i created to show up in-game. idk why. Other parts of the mod I'm working in are showing up in-game, like the civilization the mod creates, but any new buildings i create arent there once i start playing the actual game. Like, take the alter you created for an example. I've done everything, copied the portions of text into an xml file, its put under the actions tab, just like the other parts of my mod, but when i go in game, and load the mod, i can, like, play as the new civ that was part of my mod, but when im actually playing a map, the alters not there. Like shouldnt i beable to produce that alter right from turn 1? but its not there... idk. im obviously doing something totally wrong. any ideas?


edit*** I figured out what was wrong, at least why the palace alter wasnt working. That code we were supposed to copy and paste: the closing and ending <gamedata> things, were wrong. once i changed then from <gamedata> to <GameData>, it worked, so i think that was maybe the problem. as for why my buildings werent working, have no idea. i probably made some kinda similar mistake somewhere in my code. Thats all :)
 
thadian, I think every newcomer would appreciate it if you spaced that stuff out. Use the
Code:
 tags because

[CODE]

<Buildings>
   <Row>
      <Type>BUILDING_PALACE</Type>
      <BuildingClass>BUILDINGCLASS_PALACE</BuildingClass>
      <Cost>0</Cost>

looks so much better than


<Buildings>
<Row>
<Type>BUILDING_PALACE</Type>
<BuildingClass>BUILDINGCLASS_PALACE</BuildingClass>
<Cost>0</Cost>
 
I will make some edits and im glad you figured it out - I am going to actually expand this into the commerce district and discuss balance issues - i will also look at "cloning" - the action of taking already existing code and "tweaking it".

When cloning, you should pm the maker of the code - never assume a cold shoulder, most modders are pretty nice and can help you with a few things. Remember to give credit to the author! The best thing i can say for now is meeting some of the modders and getting their feedback is incredible feeling. Working on Religion and Revolution and working on Monarchy Plus+ i have learned a whole lot in just weeks. So never be shy to PM a modder and say that you would like to use a component.

Also, i am an entry level modder learning the ropes and i encourage anyone and everyone to give it a whirl. Hopefully we can all add something fun.
 
Hi!

I'm just trying to add some simple buildings. But the buildings won't show up in th e game. Just described as above, but I can not find my mistake. Can anyone help me.

Max
 
If you added another BUILDING_CLASS... to this code, would it require BOTH buildings to be present?

i.e.

Code:
	<Building_ClassesNeededInCity>
		<Row>
			<BuildingType>BUILDING_PALACE_ALTAR</BuildingType>
			<BuildingClassType>BUILDINGCLASS_PALACE</BuildingClassType>
                        <BuildingClassType>BUILDINGCLASS_BARRACK</BuildingClassType>
		</Row>
	</Building_ClassesNeededInCity>


Now it requires both palace and barracks?
 
If you added another BUILDING_CLASS... to this code, would it require BOTH buildings to be present?
You never use the same tag twice like that. The XML doesn't work that way. What might work instead is using two rows, as follows:
Code:
	<Building_ClassesNeededInCity>
		<Row>
			<BuildingType>BUILDING_PALACE_ALTAR</BuildingType>
			<BuildingClassType>BUILDINGCLASS_PALACE</BuildingClassType>
		</Row>
                <Row>
			<BuildingType>BUILDING_PALACE_ALTAR</BuildingType>
                        <BuildingClassType>BUILDINGCLASS_BARRACKS</BuildingClassType>
		</Row>
	</Building_ClassesNeededInCity>
I'm not entirely certain that will work, but it seems like your best shot.
 
Hi, I'm kind of new to modding and I've watched and read a bunch of tutorials about how to mod. I noticed none of them explained how to make a building or unit unique to a civilization. If someone could help me that would be great!
 
I noticed none of them explained how to make a building or unit unique to a civilization.

Search for "Civilization_UnitClassOverrides" and "Civilization_BuildingClassOverrides" - there are references out there on how to do this
 
i have tried several methods of learning how to mod but none of them are working...i need some more help on how to mod. looking to edit buildings in BNW..i assume that should be simple.. can anyone give me some help? i dont know what i ma doing wrong..

thanks all
 
Thadian,

If it's OK with you, I want to add a link or text referal (something like in the spoiler)

Spoiler :
hey folks, go look at Thadian's tutorial first!


from my recently-added (tutorial) on BNW Buildings XML to your tutorial here. I knew there was one here on the forum, just took me a while to find it again.

I'm going to tell first time modders to look through your tutorial 1st, and then to come back to mine when they're ready for more detail on what all the XML commands for buildings and wonders do.

I'll wait to hear back if that's OK with you
 
Top Bottom