How to: Begin Modding Civ IV Mac

Flintlock1415

Emperor
Joined
Feb 24, 2008
Messages
1,057
Location
MN
With BtS for Mac now out, and the amount of new interest in mods steadily increasing, I was inspired to make a guide to help mac users mod this game. A lot of modding is not Mac specific, but there are a few things that can trip people up. This thread will be full of links, explanations, and examples, but I want to centralize this around an example mod I'll make as I go along, with small elements of things that you can do with this game.
I will start with how to set up a mod and the basics, then move to XML, and make a Civ for the example mod. I will then move to graphics, making a flag, buttons, and unique building, with the possibility of a UU and leaderhead. Next will be a small Python intro, with a sample function that I will have to think of, and maybe I'll talk about event modding (once I learn how to do it.) Next will be a page on how to convert existing mods, and dealing with possible roadblocks, then I'll finish with a general troubleshooting/conclusion. I'll try to limit some rewriting of some other tutorials and just link, but some of those are pretty old and outdated, and tough to follow.

I want this to be a clean, concise, and continuously updated thread to help anyone, whether new to modding or needing a refresher.

Before You Begin
Since this page will be under construction for a while, I'll post a few links to help get you started on your own. The Mac Modding Index is a compilation of Tutorials, Utilities, and Mods specific to the Mac. The Tutorial Thread Index by Woodelf is a huge list of tutorials made by the modders in the Creation & Customization forum. The C&C forum, which is linked next, is a great place to ask general modding questions and post your work. The modiki has lots of info, the most useful imo being the XML reference.

Setting up a Mod
The most common and easiest way to set up a mod is to create a new mod folder. Here is what you do:
  • Open Documents/Civilization IV/Beyond the Sword/Mods and create a new folder named Test_Mod
  • Inside of Test_Mod, make a folder named Assets and one named PublicMaps. (Assets is where all of your XML, Art and Python will go. PublicMaps is for maps to be used in your mod.)
  • Inside of Assets, create 3 folders: Art, XML, and Python.
  • Inside of the XML folder, create 8 new folders (for now). Name them Art, Civilizations, Units, Buildings, Technologies, GameInfo, Interface, and Text.

The folder we will concern ourselves with for now is XML. XML is the backbone of nearly every mod, all of your new Civs, units, buildings, Technologies, Texts, etc. will go in here. Now that your mod is set up, we can move on to learning XML.

Next Page
 
XML
Now we will begin with the basics of XML.

  • First of all, open up Documents/Civilization IV/Beyond the Sword/Assets/XML/Units.
  • Scroll down until you see a file called CIV4UnitInfos.xml.
  • Drag and drop this file to your desktop (a green plus should appear.)
  • If the file doesn't create a duplicate of itself, you cannot take it. Instead duplicate it, drag to Desktop and rename the duplicate.

This brings us to the golden rule of modding:
NEVER EDIT THE ORIGINAL GAME FILES!! EVER!

Doing so will screw up your game when trying other mods or multiplayer, and if you can't trace back to all of your changes, you'll have to reinstall.

Now back to the UnitInfos file... drop this file into your Test_Mod/Assets/XML/Units file. In its current state, any copied file will be read only.

To get permission to read and write, simply highlight the file, hit cmd-I, and under Ownership & Permissions change 'Read Only' to 'Read and Write'. Once this is done, open up CIV4UnitInfos.xml with your text editor. Below is a section on selecting one if you haven't already.

Spoiler :
TextEdit, which comes with your Mac, will do just fine, but its kind of hard to look at and you have to open a new window for each file you open. I recommend getting a better text editor.

The two that I recommend are Smultron and TextWrangler. My personal favorite is Smultron, but it is rather similar to TextWrangler. I just don't like TextWrangler because the search function is awkward and some files get screwed up looking tags when you open them. I still recommend getting TextWrangler though. This is because if you plan on using Windows mods, you will have to use a feature called 'Zap Gremlins' (I'll discuss that later.) You can find both of these editors in the Mac Modding Index under Utilities.


Intro to XML
Here is my intro to XML, it does some basic explanations of XML with a Civ 4 oriented part at the end.

Spoiler :
Looking at CIV4UnitInfos.xml...

At the top of the file you'll see this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
This is just a declaration of information about the file. Just ignore this. Next, you'll see some lines with comments. Comments are ignored by the computer; they just give info to the reader. Ex.
Code:
<!-- This is a comment -->
Next you'll see tags. Tags start with < and end with >. An end tag starts with </ and ends with >. Empty Element Tags (tags without values) start with < and end with /> Ex.
Code:
<Tag>
</Tag>
<Empty Tag/>
Elements are values inside of tags, they can be strings or numbers. These are what you change to create new effects in game. Ex.
Code:
<Tag>Element</Tag>
As you can probably tell, the info for each unit starts with <UnitInfo> and ends with </UnitInfo>. All of the attributes of the unit are contained between these tags. To find out what each one means, check out the Modiki. There is also lots of other info for different types of modding, so I encourage you to take a look at it sometime. If you can't find what you want, just ask a question in the main Creation & Customization forum.

Now on to our first example. Lets say you thought the Warrior just wasn't strong enough. Let's fix this.
  • Do a search for 'unit_warrior' then another for 'iCombat'. You'll see that this is a 2, just like in game.
  • You think you should be allowed to crush tanks under your club, so change the 2 to 50.
  • Now, fire up Beyond the Sword and when you check the Civilopedia entry it should say the warrior has a strength of 50.
  • After a few games of tank crushing, you find the warrior to be a bit overpowered with being able to spam them so quickly. You decide to change the hammer cost from 15 to 250.
  • Again, simply type in 250 over the 15 and sure enough, your super warrior now is hopelessly expensive.
  • Still, you find that the warrior is still too strong, so change everything back. Again, more info on what you can change is in the Modiki.


Now that you've been exposed to some simple XML, lets move on to actually making a custom Civ.

How to Add a Civilization

For this section of the tutorial, I will walk you through how to create a Civ. I will be adding an Iroquois Civilization, being my favorite from Civ 3. (My first ever Civ game! :king: ) First, lets grab all of the files you'll need.
Enter the regular BtS XML folder in the same directory as the unitinfos.xml file:
(Documents/Civilization IV/Beyond the Sword/Assets/XML) and grab these files from each of the following folders:

  • Art/CIV4ArtDefines_Civilization.xml
  • Art/CIV4ArtDefines_Leaderhead.xml
  • Art/CIV4ArtDefines_Unit.xml
  • Art/CIV4ArtDefines_Building.xml
  • Civilizations/CIV4LeaderHeadInfos.xml
  • Civilizations/CIV4CivilizationInfos.xml
  • Interface/CIV4ColorVals.xml
  • Interface/CIV4PlayerColorInfos.xml
  • Buildings/CIV4BuildingInfos.xml
  • Buildings/CIV4CityLSystem.xml
  • GameInfo/CIV4DiplomacyInfos.xml

Now, you should have all of these folders in Test_Mod, so open Test_Mod's XML directory and place each file into their corresponding folders. Always remember when adding a new file to give it Read & Write permissions. (cmd-I --> Change 'read only' to 'read & write'.)

Once all of your files are taken care of, you'll need some art. I have packaged together, which includes Hiawatha by The_Capo, a Mohawk Archer by Bernie_14, and a Longhouse and flag from Civ Gold. Link to the File

Now you're going to need to know where to put those files. Open Test_Mod/Assets/Art, and create these folders:
  • Leaderheads
  • Units
  • Interface
  • Structures
  • Now, inside of Interface, add a Buttons and a TeamColor folder. Inside of Structures, add a Buildings folder.
  • Next, place Hiawatha in the Leaderheads folder, Mohawk in the Units folder, FlagDECAL_Iroquois.dds in Interface/TeamColor, and Longhouse in Structures/Buildings. We will use buttons later in the art section of the tutorial.

Next, I will show you how to add the XML to put the Civilization together. (Here is a link to Jecrell's tutorial, if you can't wait for me.) ;)

CIV4CivilizationsInfos.xml
Spoiler :
To start, open up Civilizations/CIV4CivilizationInfos.xml and do a search for 'native_america'. The easiest way to create a new XML entry is to copy an existing one, so we will copy Native America's. Copy from <CivilizationInfo> to </CivilizationInfo> and paste the copy right underneath it. You will notice how the tabs are aligned for each Civ, so try to keep that order. Now we'll go tag by tag for each change.

The first tag you'll see is the <Type> tag. This is the actual tag that makes each civ different to the game.
  • Change the CIVILIZATION_NATIVE_AMERICA to CIVILIZATION_IROQUOIS.
  • The next four tags are all pretty self explanatory; they set up the text for each respective area. Again, Remove NATIVE_AMERICA and replace with IROQUOIS.

The next tag designates the player's color. To see all of the color options, you will have to open up Interface/CIV4PlayerColorInfos.xml.
  • Open it up and search for dark_purple. This is Rome's color scheme, and you'll notice they use a Dark Purple primary, a dark yellow secondary, and a dark purple text.
  • Copy Rome's scheme, and rename it's <type> as PLAYER_COLOR_IROQUOIS_PURPLE.
  • Now, skip to the secondary color tag, and rename it as COLOR_PLAYER_WHITE.
  • Rename the text tag as COLOR_PLAYER_PURPLE_TEXT. For our primary color, however, I will show you how to make a custom color.
  • Rename the primary color tag and COLOR_PLAYER_IROQUOIS_PURPLE and open up Interface/CIV4ColorVals.xml.
I want a purple that is in between Rome's (the darkest) and Babylon's (middle) colors.
  • Do a search for dark_purple, copy it and rename it as COLOR_PLAYER_IROQUOIS_PURPLE, same as in the PlayerColors file.
  • Set your tags to these values for an Iroquois Purple (I hope ;) ). fRed=0.65 fGreen=0.25 fBlue=0.90 and fAlpha=1.00
As you can see, you can make any teamcolor or text color in this file, then set them up via the PlayerColors.xml file.

Now save those files and return to CivilizationInfos.xml.
  • Rename the <DefaultPlayerColor> tag to PLAYERCOLOR_IROQUOIS_PURPLE.
  • The next tag is the <ArtDefineTag>. For now, just name it ART_DEF_CIVILIZATION_IROQUOIS and we will set that up later.
  • Skip on down to the <Cities> tag. You will see that there are a bunch of <City> tags with TXT_KEY's in them. Delete all of these except one.
Here I will show you a trick about TXT_KEY's. Anytime you see them, they are just referencing to an xml text file. If that text path doesn't exist, the game simply will use what is inside of the tags instead of going to the reference. Therefore, you can simply put the city name inside of the <city> tag instead of a TXT_KEY and it will work just fine. Personally, I only do this for cities, but you can do this for any TXT_KEY reference. The only time I would STRONGLY recommend not doing this shortcut is for Civilopedia entries and multi-lingual mods. The Civilopedia entries are too long and cluttered to put in the file you're in and are better left for the text file, and multi-lingual mods will not be able to take advantage of the language tags provided by use a text file. I will show you how to set up text files once our Civ is created. I got the Iroquois city list from here.

Once your city list is finished, move down to the <Buildings> tag. This is where the unique Building is defined. Our UB will be the Longhouse, and it will replace the courthouse.
  • Just replace BUILDINGCLASS_OBELISK with BUILDINGCLASS_COURTHOUSE, and BUILDING_NATIVE_AMERICA_TOTEM with BUILDING_LONGHOUSE. Remember now that the Longhouse doesn't exist yet; we will make it later.
  • Building classes define a type of building, and any building that is in the standard game and buildable by anyone has its own class. Classes also define whether its a national or world wonder, and if there is a limit on how many are allowed. These are similar for unit classes as well. Check out the Modiki for specifics.
  • Do this same thing for the <unit> tag, replacing UNITCLASS_AXEMAN with UNITCLASS_LONGBOWMAN, and UNIT_NATIVE_AMERICA_DOG_SOLDIER with UNIT_MOHAWK_ARCHER.
  • The next tag we will focus on is the <FreeTechs> tag.This is the starting tags for each Civ, but I will leave it as Agriculture and Fishing for the Iroquois.
  • Our final tag is the <Leaders> tag. Change LEADER_SITTING_BULL to LEADER_HIAWATHA. This, of course, sets our leader to be Hiawatha. There are more tags I could talk about, but these are the basics. You can always find out more in the modiki.
The next part of the tutorial will deal with how to add the Leaderhead and the Unique Building/Unit.

Adding the leaderhead
Spoiler :
Open up Civilizations/CIV4LeaderheadInfos.xml. This file is huge, since it stores a lot of data for all of the AI attitude weights. When you add a leader, just copy one that you think would be similar to your leader, in this case Sitting Bull, and use that.
  • First, Change the first four lines where it says SITTING_BULL to HIAWATHA.
  • Next, scroll down to the <Traits> tag, and change Hiawatha's traits to TRAIT_INDUSTRIOUS and TRAIT_EXPANSIVE.
  • One more thing you may want to note, is the favorite civic tag above the trait tag. In this case we will leave it as Environmentalism, but beyond that, changing leaders up is a bit more difficult.
That's all for that file, and now we have our leader xml set up.


Adding the Unique Unit
Spoiler :
Open up Units/CIV4UnitInfos.xml. Since we'll be replacing the Longbowman, copy that entry.
  • Change the <Type> tag to UNIT_MOHAWK_ARCHER. (But not the Class tag)
  • Go down to the <Description> tag, and change that and the two after it from LONGBOWMAN to MOHAWK_ARCHER.
  • Scroll down towards the bottom of the entry, and change the <earlyArtDefine> tag to ART_DEF_UNIT_MOHAWK_ARCHER.
  • There are many different bonuses we can give to our new unit, which you can look up in the modiki. We will give the Mohawk Archer a free Woodsman I promotion. To do this, search for the <FreePromotions/> tag. Notice it is an empty tag. Change it to look like below.
Code:
<FreePromotions>
				<FreePromotion>
					<PromotionType>PROMOTION_WOODSMAN1</PromotionType>
					<bFreePromotion>1</bFreePromotion>
				</FreePromotion>
			</FreePromotions>
That's all for this file; save it and we will add our UB.


Adding the Unique Building

:nuke: Under Construction :nuke:
 
Reserved for Troubleshooting

I know I haven't got much of a start yet, but I wanted to get something up before I go back to school (I'm on my lunch right now). I do have the next 6 days off though, so there is plenty of progress to be made.

Go ahead and post! :D
 
This looks like it should be pretty helpful. I'll be watching this for when it's complete.
 
+1 and very thanks to Flintlock1415 for this tutorial !
I will see when completed ;)
 
Bullet or numbered points, perhaps? Or any kind of pictures, if any are appropriate. Screenshots for those of us who get lost in the words?
 
I'm little afraid by the tall of work, it seems that you will make a complete editor non official for civ 4 BTS Mac, i'm very interested by an editor ala Civ 2 or 3...
 
I'm little afraid by the tall of work, it seems that you will make a complete editor non official for civ 4 BTS Mac, i'm very interested by an editor ala Civ 2 or 3...

To be honest Lachlan, an editor like Civ3 had would just make modding BTS harder not easier. BTS is extremely customizable and modular and any editor UI just would not be able to easily display or implement most of the options. Civ2 and Civ3 pretty much had all their options in a single file so it was much easier to have a editor UI for these. Of course there was also so much much less that you could edit too.

If an editor did exist you'd still find yourself doing a lot of xml changes anyway, to get things exactly how you want. So, as we've suggested before, take the time to learn xml editing. It's not hard once you get started and there's a ton of modding potential with just xml alone. Flintlock's tutorial here is a fantastic way to get underway, and the Modiki on this site is a great reference for what all the tags mean.

It's worth it, trust me.
 
XML is really not difficult at all, just by messing around with it for a bit you can really learn a lot. It can be a bit tedious, I know, but not hard. ;)

I can tell now that I won't have time to create an editor until next summer, if I ever do get an opportunity to try it again.
 
I will training myself on Civ 3 before attacking Civ 4...

I will wait the first mod bts mac... To try myself after...
 
I think I'm going to put the full tutorial into a downloadable pdf, and just post a reference guide up here. Its just too long, so really only people actually fully following it for the first time will benefit. Besides, I will have more images in a pdf.

I won't have time for this again until this weekend, so does anyone have suggestions on the best way to make a pdf? I was thinking just using Powerpoint and converting from there, unless there is a better way to do it.
 
I assume you want to use Powerpoint because you don't have Keynote or Pages?

Use any document creation software you feel is appropriate. With the Print dialog, select PDF at bottom left, and print to a PDF file.

You can even create different pages or sections in different apps. You can then use Preview to collate the separate pages/sections into a single document. Open each section and drag/drop pages between the sidebars. This is all assuming you have a recent version of OS X/Preview.
 
Top Bottom