[XML] Add your own tech! (Open)

Deon

Lt. of Mordor
Joined
Jan 13, 2008
Messages
2,956
Location
St.Petersburg, Russian Federation
Instead of prologue: EXTRA RULE:
If you comment your CIV4TechInfos.xml inside the <Techinfos></Techinfos> tags, you can get some problems with the tech prereqs. Be sure not to use the spaces before any tag (even "<!--") while you're using tabs in all the document.

If you're new to XML editing or want to add a tech without reading the modiki for all the tags info, here's some easy tutorial for you.
I'd recommend you to use some advanced text editor, because the basic notepad can be uncomfortable. I usually use Notepad2 freeware program.

Locate your \Assets\XML\Technologies\CIV4TechInfos.xml

Then copy it to your mod folder in the "BTS folder\Mods\Yourmod\Assets\XML\Technologies\". I hope you know how to make your own mod folder. Do not ever modify your vanilla game files (please :lol:).

Open your new "BTS folder\Mods\Yourmod\Assets\XML\Technologies\CIV4TechInfos.xml" and scroll down to the end.
Maybe you will want to edit your existing tech (at least to give a place for your tech). I will describe how-to move the tech in the tech tree later.

To add a new tech you want to copy this text and paste it after the last </Techinfo> and before the </TechInfos> tags in your CIV4TechInfos.xml.
Here's the text:
Spoiler :

Code:
		<TechInfo>
			<Type>[COLOR="Blue"]TECH_SAMPLE[/COLOR]</Type>
			<Description>[COLOR="Red"]TXT_KEY_TECH_SAMPLE[/COLOR]</Description>
			<Civilopedia>[COLOR="#ff0000"]TXT_KEY_TECH_SAMPLE_PEDIA[/COLOR]</Civilopedia>
			<Help/>
			<Strategy>[COLOR="#ff0000"]TXT_KEY_TECH_SAMPLE_STRATEGY[/COLOR]</Strategy>
			<Advisor>[COLOR="Blue"]ADVISOR_SCIENCE[/COLOR]</Advisor>
			<iAIWeight>0</iAIWeight>
			<iAITradeModifier>0</iAITradeModifier>
			<iCost>100</iCost>
			<iAdvancedStartCost>100</iAdvancedStartCost>
			<iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
			<Era>[COLOR="#0000ff"]ERA_ANCIENT[/COLOR]</Era>
			<FirstFreeUnitClass>NONE</FirstFreeUnitClass>
			<iFeatureProductionModifier>0</iFeatureProductionModifier>
			<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
			<iTradeRoutes>0</iTradeRoutes>
			<iHealth>0</iHealth>
			<iHappiness>0</iHappiness>
			<iFirstFreeTechs>0</iFirstFreeTechs>
			<iAsset>10</iAsset>
			<iPower>0</iPower>
			<bRepeat>0</bRepeat>
			<bTrade>0</bTrade>
			<bDisable>0</bDisable>
			<bGoodyTech>0</bGoodyTech>
			<bExtraWaterSeeFrom>0</bExtraWaterSeeFrom>
			<bMapCentering>0</bMapCentering>
			<bMapVisible>0</bMapVisible>
			<bMapTrading>[COLOR="Blue"]0[/COLOR]</bMapTrading>
			<bTechTrading>[COLOR="Blue"]0[/COLOR]</bTechTrading>
			<bGoldTrading>[COLOR="Blue"]0[/COLOR]</bGoldTrading>
			<bOpenBordersTrading>[COLOR="Blue"]0[/COLOR]</bOpenBordersTrading>
			<bDefensivePactTrading>[COLOR="Blue"]0[/COLOR]</bDefensivePactTrading>
			<bPermanentAllianceTrading>[COLOR="Blue"]0[/COLOR]</bPermanentAllianceTrading>
			<bVassalTrading>[COLOR="Blue"]0[/COLOR]</bVassalTrading>
			<bBridgeBuilding>0</bBridgeBuilding>
			<bIrrigation>0</bIrrigation>
			<bIgnoreIrrigation>0</bIgnoreIrrigation>
			<bWaterWork>0</bWaterWork>
			<iGridX>20</iGridX>
			<iGridY>13</iGridY>
			<DomainExtraMoves/>
			<CommerceFlexible/>
			<TerrainTrades/>
			<bRiverTrade>0</bRiverTrade>
			<Flavors>
				<Flavor>
					<FlavorType>FLAVOR_SCIENCE</FlavorType>
					<iFlavor>1</iFlavor>
				</Flavor>
			</Flavors>
[COLOR="DarkGreen"]			<OrPreReqs>
			</OrPreReqs>
			<AndPreReqs>
			</AndPreReqs>[/COLOR]
			<Quote>[COLOR="Red"]TXT_KEY_TECH_SAMPLE_QUOTE[/COLOR]</Quote>
			<Sound/>
			<SoundMP/>
			<Button>Art/Interface/Buttons/TechTree/Sample.dds
			</Button>
		</TechInfo>


Then you will want to edit the tech.
There're some parts of editing this sample tech.
1) You change its tags to be an unique tech.
2) You change the effect on game variables (like +1:health:, workers build improvements +50% faster and all).
3) You select the prerequisites for it.
4) You find a place for it in the techtree layout.
5) You make descriptions (name, pedia info) for it in TEXT xml files.
6) You make buttons for it.


1) Unique tech tags

Replace all the TECH_SAMPLE tags with your tech's name tags, like TECH_SAILING or TECH_KITCHENKNIFES. In Notepad2 there's a special hotkey combination Ctrl-H, which allows you to replace the one expression with another in the whole document.

Spoiler :

This is the tech name tag which is referred to when you want some unit/civic/tech/anything to require this tech. YOURTECH is your tech's name.
<Type>TECH_YOURTECH</Type>

======================================

These are the text keys for the description (Name, pedia info, strategy, quote) of the tech in your text file, YOURTECH is your tech's name. You will make this file later.
<Description>TXT_KEY_TECH_YOURTECH_DESCR</Description>
<Civilopedia>TXT_KEY_TECH_YOURTECH_PEDIA</Civilopedia>
<Strategy>TXT_KEY_TECH_YOURTECH_STRATEGY</Strategy>
<Quote>TXT_KEY_TECH_YOURTECH_QUOTE</Quote>

======================================

This is the tag which points which advisor will recommend you the tech when it's the time.
<Advisor>
Spoiler :
(ADVISOR_GROWTH, ADVISOR_MILITARY, ADVISOR_ECONOMY, ADVISOR_SCIENCE, ADVISOR_CULTURE)




2) Various parameters of the tech.

Spoiler :


Basic info
* Technology cost in beakers: <iCost>
* Era the tech is in: <Era>
* Score points for the tech: <iAsset>
* Power points for the tech: <iPower>
* Can be traded: <bTrade>
* Can be researched multiple times: <bRepeat>
* Can be found in native villages: <bGoodyTech>
* Flavors of the tech. For AI types, also allows certain great people to research the tech: <Flavors>
* The cost of the tech at the advanced start: <iAdvancedStartCost>. Set it to -1 to be unavaliable for the adv. start.

Free cakes
* Free unit for being 1st to research the tech: <FirstFreeUnitClass> (from CIV4UnitClassInfos.xml)
* Number of free techs given for being 1st to research the tech: <iFirstFreeTechs>

Your global parameters
* Water tiles can be worked in city radius: <bWaterWork>
* Increases the output of forest chopping (%): <iFeatureProductionModifier>
* Increases the workers' productivity (%): <iWorkerSpeedModifier>
* Allows bridgebuilding (no movement penalties with roads due a river-crossing): <bBridgeBuilding>
* Farms spread irrigation: <bIrrigation>
* Farms don't need irrigation: <bIgnoreIrrigation>
* Additional trade routes for each city: <iTradeRoutes>
* Additional :health: for each city: <iHealth>
* Additional :) for each city: <iHappiness>
* Enables trade on rivers: <bRiverTrade>
* Reveals all the map: <bMapVisible>
* Centers the map: <bMapCentering>
* Increases the sight range over the water: <bExtraWaterSeeFrom>
* Increases the movement in the certain domain: <DomainExtraMoves>
Spoiler :
I.e. +1 sea movement
Code:
			<DomainExtraMoves>
				<DomainExtraMove>
					<DomainType>DOMAIN_SEA</DomainType>
					<iExtraMoves>1</iExtraMoves>
				</DomainExtraMove>
			</DomainExtraMoves>

Diplomacy
* Allows Map trading: <bMapTrading>
* Allows Open borders: <bOpenBordersTrading>
* Allows Technology trading: <bTechTrading>
* Allows Gold trading: <bGoldTrading>
* Allows defensive pacts: <bDefensivePactTrading>
* Allows permanent alliances <bPermanentAllianceTrading>
* Allows vassal state: <bDVassalTrading>

Bugged disable
* Stops the tech from being researched: <bDisable>. But beware of the bug. If you start the game in the later era than this tech's era, you will get it for free anyway.


3) Adding prerequisites.
Note: If your prereqs are not working, check your file for comments. There should be NO comments between <Techinfos></Techinfos> tags

There're tags :<OrPreReqs>, <AndPreReqs>, and they are used for indicating the technologies which are required for your tech to be researched.

Any of the techs written inside the <OrPreReqs></OrPreReqs> tag will have an arrow leading to your tech, and it means any of them could be researched to gain access to your tech.
All the techs written inside the <AndPreReqs></AndPreReqs> tag are REQUIRED to get your tech. Their buttons are shown on the tab after your tech's name.

Spoiler :

i.e.
The tech requires Mining OR Hunting
Code:
<OrPreReqs>
    <PrereqTech>TECH_MINING</PrereqTech>
    <PrereqTech>TECH_HUNTING</PrereqTech>
</OrPreReqs>
The tech requires Mining AND Hunting
Code:
<AndPreReqs>
    <PrereqTech>TECH_MINING</PrereqTech>
    <PrereqTech>TECH_HUNTING</PrereqTech>
</AndPreReqs>
The tech requires (Mining) AND (Hunting OR Agriculture)
Code:
<OrPreReqs>
    <PrereqTech>TECH_AGRICULTURE</PrereqTech>
    <PrereqTech>TECH_HUNTING</PrereqTech>
</OrPreReqs>
<AndPreReqs>
    <PrereqTech>TECH_MINING</PrereqTech>
</AndPreReqs>


4) Tech coordinates

There're tags: <iGridX> and <iGridY> which represent the position of the tech on the tech-tree "table".
I.E.
Code:
<iGridX>1</iGridX>
<iGridY>1</iGridY>
means that the tech is in the 1st column and the 1st raw of the tech tree.
Spoiler :

This is how the techs are placed:
techtreebc8.jpg

So all the techs in the same column should has a step of 2 in the <GridX>, or they will overlap.


5)TEXT Descriptions

Make a file TechDescriptions.xml in the "BTS folder\Mods\Yourmod\Assets\XML\Text\" folder. You can simply make an empty txt file and change its extension to XML.
Fill it with the following text:
Spoiler :
Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Soren Johnson (Firaxis Games) -->
<!-- Sid Meier's Civilization 4 -->
<!-- Copyright Firaxis Games 2005 -->

<!-- Game Text Objects -->
<Civ4GameText xmlns="http://www.firaxis.com">
</Civ4GameText>
[/spoiler]

This is an empty file template for all of your descriptions.
After you've created this file, open it. You will need the code:
[code]<TEXT>
  <TAG>TXT_KEY_SAMPLE<TAG>
  <english>sample text</english>
</TEXT>
inside of the <Civ4GameText ... ></Civ4GameText> tags which are already present in the file. If you want the text to be avaliable in other languages, you may put the <italian> and other tags just after the </english> and before the </TEXT>

Now it's time to fill the text info about your tech.
1) Paste the sample code and rename TXT_KEY_SAMPLE to TXT_KEY_TECH_YOURTECH_DESCR, where TECH_YOURTECH is your tech's tag.
Then fill the space between <english> </english> with the name of your tech
Spoiler :
i.e.
Code:
<TEXT>
  <TAG>TXT_KEY_TECH_ARCOLOGY_DESCR<TAG>
  <english>Arcology</english>
</TEXT>

After you made the description, it's time to make the strategy info, the pedia info and quote for your tech.
Follow the same algorythm as for the tech description, just replace the TXT_KEY_SAMPLE with TXT_KEY_TECH_YOUTECH_STRATEGY, TXT_KEY_TECH_YOUTECH_PEDIA and TXT_KEY_TECH_YOUTECH_QUOTE. As always, all the text shown in game goes between the <english></english> tags.
After you load the game everything should be at the place.

6) Buttons!
There's a nice tutorial about how to make your own buttons for your tech. Scroll down until you see the Part4 - that's it.
Place the final version of your button in the "BTS folder\Mods\Yourmod\Assets\Art\Interface\Buttons\Techtree" and make sure the path in your CIV4TechInfos.xml is right for the tech.
It is <button></button> tag, and it should look like
Code:
<Button>Art/Interface/Buttons/TechTree/Yourtech.dds</Button>

0) Just to make sure you're not forgotten: the guys who should get a credit for helping me to fix/expand this article:
-Seven05
 
If you think that something should be added, please post it here.
I'm not too good at english and this is my first tutorial, so I would like to have some useful criticism =).
 
Question: I've created a new tech, and it appears as it's supposed to. However, how do I connect the new tech box on the tech tree screen with its prerequisite(s)? (As you have done in the picture labeled "This is how the techs are placed".)
 
The arrows point from the 'or' prereqs, the 'and' prereq techs show up as an icon on the uper right corner of your tech's box.

A few other goodies:

Setting the advanced start cost to -1 makes it unavailable for purchase in advanced starts. Setting bGoody to 1 makes it possible for this tech to appear in good huts.

Setting bDisable to 1 disables the tech, sort of, this is bugged in that while you can't research the tech you will get it for free in any game that you start in any era later than the tech's defined era. For instance, if you set bDisable to 1 for TECH_IRON_WORKING and then start a game in the Medieval era you will start with iron working. This also applies to any free techs defined in the handicap infos or for the specific civilization. So if you make a new tech, set it to be disabled and assign it as a free tech for the Incans when you start your game the Incans will have the tech and nobody else will be able to research it, well unless you start in a later era :)
 
Thank you, Seven05. I will add this to the main post with a credit.
By the way, your weather mod is great =).

By the way, there already was a line about the <bGoodyTech> parameter =).
 
Question: I've created a new tech, and it appears as it's supposed to. However, how do I connect the new tech box on the tech tree screen with its prerequisite(s)? (As you have done in the picture labeled "This is how the techs are placed".)

Read the spoiler under the part
3) Adding prerequisites.
There're living examples.
 
Got it. The problem was that I was using all "and" prerequisites. I changed one to an "or", and the box linked up as it was supposed to. Thanks!
 
Thank you very much Deon, Seven05, this tutorial is of great help!
:goodjob:

EDIT: To those who think that the comment tags (<!-- -->) will not affect.... they do!
...now feel free to say, "I told you" :-p
 
I followed this tutorial as i was unhappy with the way our current tech tree works. There were a lot of <OrPreReq> which was causing a fast run through to the higher techs. I wanted to slow this down and, using this tutorial changed the <OrPreReq> techs to <AndPreReq>. Now the mod doesn't load at all.:cry:
I'll show you.

This is what we had.
Spoiler :
<TechInfo>
<Type>TECH_B5_SHIP_CONSTRUCTION</Type>
<Description>TXT_KEY_B5_SHIP_CONSTRUCTION_DESC</Description>
<Civilopedia>TXT_KEY_B5_SHIP_CONSTRUCTION_PEDIA</Civilopedia>
<Help/>
<Strategy>TXT_KEY_B5_SHIP_CONSTRUCTION_STRATEGY</Strategy>
<Advisor>ADVISOR_MILITARY</Advisor>
<iAIWeight>0</iAIWeight>
<iAITradeModifier>0</iAITradeModifier>
<iCost>70</iCost>
<iAdvancedStartCost>70</iAdvancedStartCost>
<iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
<Era>ERA_MODERN</Era>
<FirstFreeUnitClass>NONE</FirstFreeUnitClass>
<iFeatureProductionModifier>0</iFeatureProductionModifier>
<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
<iTradeRoutes>0</iTradeRoutes>
<iHealth>0</iHealth>
<iHappiness>0</iHappiness>
<iFirstFreeTechs>0</iFirstFreeTechs>
<iAsset>8</iAsset>
<iPower>6</iPower>
<bRepeat>0</bRepeat>
<bTrade>1</bTrade>
<bDisable>0</bDisable>
<bGoodyTech>1</bGoodyTech>
<bExtraWaterSeeFrom>0</bExtraWaterSeeFrom>
<bMapCentering>0</bMapCentering>
<bMapVisible>0</bMapVisible>
<bMapTrading>0</bMapTrading>
<bTechTrading>0</bTechTrading>
<bGoldTrading>0</bGoldTrading>
<bOpenBordersTrading>0</bOpenBordersTrading>
<bDefensivePactTrading>0</bDefensivePactTrading>
<bPermanentAllianceTrading>0</bPermanentAllianceTrading>
<bVassalTrading>0</bVassalTrading>
<bBridgeBuilding>0</bBridgeBuilding>
<bIrrigation>0</bIrrigation>
<bIgnoreIrrigation>0</bIgnoreIrrigation>
<bWaterWork>0</bWaterWork>
<iGridX>4</iGridX>
<iGridY>17</iGridY>
<DomainExtraMoves/>
<CommerceFlexible/>
<TerrainTrades/>
<bRiverTrade>0</bRiverTrade>
<Flavors>
<Flavor>
<FlavorType>FLAVOR_MILITARY</FlavorType>
<iFlavor>10</iFlavor>
</Flavor>
<Flavor>
<FlavorType>FLAVOR_SCIENCE</FlavorType>
<iFlavor>2</iFlavor>
</Flavor>
<Flavor>
<FlavorType>FLAVOR_CULTURE</FlavorType>
<iFlavor>2</iFlavor>
</Flavor>
</Flavors>
<OrPreReqs>
<PrereqTech>TECH_B5_ORBITAL_ENGINEERING</PrereqTech>
<PrereqTech>TECH_B5_BASIC_ART_GRAVITY</PrereqTech>
</OrPreReqs>
<AndPreReqs/>
<Quote>TXT_KEY_B5_TECH_SHIP_CONSTRUCTION_QUOTE</Quote>
<Sound/>
<SoundMP/>
<Button>Art/Interface/Buttons/Technologies/SHIP_CONSTRUCTION.dds</Button>
</TechInfo>

and here is what i changed it to.
Spoiler :
<TechInfo>
<Type>TECH_B5_SHIP_CONSTRUCTION</Type>
<Description>TXT_KEY_B5_SHIP_CONSTRUCTION_DESC</Description>
<Civilopedia>TXT_KEY_B5_SHIP_CONSTRUCTION_PEDIA</Civilopedia>
<Help/>
<Strategy>TXT_KEY_B5_SHIP_CONSTRUCTION_STRATEGY</Strategy>
<Advisor>ADVISOR_MILITARY</Advisor>
<iAIWeight>0</iAIWeight>
<iAITradeModifier>0</iAITradeModifier>
<iCost>70</iCost>
<iAdvancedStartCost>70</iAdvancedStartCost>
<iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
<Era>ERA_MODERN</Era>
<FirstFreeUnitClass>NONE</FirstFreeUnitClass>
<iFeatureProductionModifier>0</iFeatureProductionModifier>
<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
<iTradeRoutes>0</iTradeRoutes>
<iHealth>0</iHealth>
<iHappiness>0</iHappiness>
<iFirstFreeTechs>0</iFirstFreeTechs>
<iAsset>8</iAsset>
<iPower>6</iPower>
<bRepeat>0</bRepeat>
<bTrade>1</bTrade>
<bDisable>0</bDisable>
<bGoodyTech>1</bGoodyTech>
<bExtraWaterSeeFrom>0</bExtraWaterSeeFrom>
<bMapCentering>0</bMapCentering>
<bMapVisible>0</bMapVisible>
<bMapTrading>0</bMapTrading>
<bTechTrading>0</bTechTrading>
<bGoldTrading>0</bGoldTrading>
<bOpenBordersTrading>0</bOpenBordersTrading>
<bDefensivePactTrading>0</bDefensivePactTrading>
<bPermanentAllianceTrading>0</bPermanentAllianceTrading>
<bVassalTrading>0</bVassalTrading>
<bBridgeBuilding>0</bBridgeBuilding>
<bIrrigation>0</bIrrigation>
<bIgnoreIrrigation>0</bIgnoreIrrigation>
<bWaterWork>0</bWaterWork>
<iGridX>4</iGridX>
<iGridY>17</iGridY>
<DomainExtraMoves/>
<CommerceFlexible/>
<TerrainTrades/>
<bRiverTrade>0</bRiverTrade>
<Flavors>
<Flavor>
<FlavorType>FLAVOR_MILITARY</FlavorType>
<iFlavor>10</iFlavor>
</Flavor>
<Flavor>
<FlavorType>FLAVOR_SCIENCE</FlavorType>
<iFlavor>2</iFlavor>
</Flavor>
<Flavor>
<FlavorType>FLAVOR_CULTURE</FlavorType>
<iFlavor>2</iFlavor>
</Flavor>
</Flavors>
<OrPreReqs/>
<AndPreReqs>
<PrereqTech>TECH_B5_ORBITAL_ENGINEERING</PrereqTech>
<PrereqTech>TECH_B5_BASIC_ART_GRAVITY</PrereqTech>
</AndPreReqs>
<Quote>TXT_KEY_B5_TECH_SHIP_CONSTRUCTION_QUOTE</Quote>
<Sound/>
<SoundMP/>
<Button>Art/Interface/Buttons/Technologies/SHIP_CONSTRUCTION.dds</Button>
</TechInfo>

There were a number of other techs that i did this to. I can't see any errors and i get no XML error messages when the mod loads which i have had in the past. Would you need to see both (the pre revision and post revison) versions of the complete tech tree to locate the problem?
 
@PsiCorps

No idea, when you try to start the game, does a warning message tell you of this specific tech? or you just piqued one at random.

I would suggest that you grab the original file, make a single change an see if it works, then you can start modding the others, this makes debugging easier.

BTW, good call on this. I did foresee this, but I thought on fine tuning this later. :goodjob:
 
Back
Top Bottom