Adding Goods for Dummies

Discuss maps, trains and other modding topics
Post Reply
User avatar
Jancsika
Posts: 921
Joined: Thu Nov 02, 2006 3:40 pm
Location: Maryland

Adding Goods for Dummies

Post by Jancsika » Sat Dec 06, 2008 8:37 pm

Adding a new Good to a SAM

Some preliminary information:



SAM - Stand Alone Map - Through much time and experimentation it was discovered
that the main problem with crashing the game came from the amount of useless files
loaded in the game. Basically, the game loaded all the information it had in files, folders
and FPK files that came in the original game and from Mods, whether the data was
needed or not. Repeated restarts with nothing started in between caused the game
to reload most or all of the data again, but not overwriting what was there.
A group of smart people on this board devised a method that will load only the needed
data for the particular mapselected, thus greatly reducing the amount of memory used
and making the game more stable. And so the SAM was born.

BB - Building Block - a set of files usually contained in a zip that consists of a
BB_(name).fpk and a BB_(name).xml. Some may also contain a folder which consists of the
files contained in the FPK file.

BB XML file - this file consists of the XML code for the BB it is attached to. When using
these, do not use the first and last lines or any empty lines. These are only used to
balance out the XML code. A BB XML for an Engine will also contain five line of code that
is inserted into the Names XML. It is required that you do this in order for the Engine to
appear correctly in the roundhouse.

Notepad++ - best program for the editing of XML files. The best source is http://notepad-plus.sourceforge.net/uk/site.htm. Click on 'Download Notepad++ executable files' which will
take you to SourceForge.net. Download the latest version of the npp installer from there.
Then go back to the Notepad++ download site and get the 'XML Tools from the plugin list.

SMR folder - a folder usually found at
'C:\Documents and Settings\(user name)\My Documents\My Games\Sid Meier's Railroads!'
Refer to Mods - Maps, 'How to install SAMs......' to see how to set this up for SAM style
maps.

Any reference to XML files which are needed to get code to use are usually found in
'C:\Program Files\2K Games\Firaxis Games\Sid Meier's Railroads!\Assets\XML\' and will be refered
to as 'Original Files'.
-------------------------------------------------------------------------------
First I will show how to add a new "Good" to an existing SAM. There is a rather easy SAM called
New_England_SAM that is part of the download this tutorial. Extract it into the 'UserMaps' folder in
the SMR folder

This zip, like most SAMs, contains a map folder, in the case 'New_England', and, in this case, an FPK file, 'BB_New_England.fpk'. Some SAM zips may contain more FPKs. Start the game and get a
feeling for the map.
-----------------------------------------------------------------------------------------------
We want to add the Good Cotton to the scenario. This is also part of the download of this tutorial.
Unzip it into a temporary folder. Place the 'BB_Cotton.fpk' into 'UserMaps'.

Using Notepad++, open the RRT_Goods.xml file and the BB_Cotton.xml file. Copy the XML code
from the BB_Cotton.xml, excluding the first and last lines, and any empty lines as stated in the
preliminary information above. Paste it between '<RRTGoods> and the first '<Good>' as shown below:

<RRTGoods>
<Good>
<szName>Cotton</szName>
<szClass>Freight</szClass>
<szGTMLIcon>icon_Cotton_32.tga</szGTMLIcon>
<BitmapLarge>
<szFile>icon_Cotton_64.tga</szFile>
</BitmapLarge>
<BitmapSmall>
<szFile>icon_Cotton_32.tga</szFile>
</BitmapSmall>
<BitmapTiny>
<szFile>icon_Cotton_16.tga</szFile>
</BitmapTiny>
<BitmapCar>
<szFile>C3_CISV.tga</szFile>
<uiX>0</uiX>
<uiY>0</uiY>
<uiWidth>32</uiWidth>
<uiHeight>16</uiHeight>
</BitmapCar>
<BitmapCarEmpty>
<szFile>C3_CISV.tga</szFile>
<uiX>0</uiX>
<uiY>16</uiY>
<uiWidth>32</uiWidth>
<uiHeight>16</uiHeight>
</BitmapCarEmpty>
<Color>256,256,256</Color>
<MinPrice>8000</MinPrice>
<MaxPrice>16000</MaxPrice>
<szIndustryLeaderTitle>Cotton King</szIndustryLeaderTitle>
<szIndustryPlayerTitle>Cotton Brain</szIndustryPlayerTitle>
</Good>
<Good>
<szName>Arms</szName>
<szClass>BulkFreight</szClass>
<szGTMLIcon>Resource/Railroad/GoodIcons/icon_arms_32.tga</szGTMLIcon>
<BitmapLarge>
<szFile>Assets/Interface/Goods/icon_arms_64.tga</szFile>
</BitmapLarge>
<BitmapSmall>
<szFile>Assets/Interface/Goods/icon_arms_32.tga</szFile>
</BitmapSmall>
<BitmapTiny>
<szFile>Assets/Interface/Goods/icon_arms_16.tga</szFile>
</BitmapTiny>
<BitmapCar>
<szFile>Assets/Interface/Cars/CarIconSideViews.tga</szFile>
<uiX>0</uiX>
<uiY>0</uiY>
<uiWidth>32</uiWidth>
<uiHeight>16</uiHeight>
</BitmapCar>
<BitmapCarEmpty>
<szFile>Assets/Interface/Cars/CarIconSideViewsEmpty.tga</szFile>
<uiX>0</uiX>
<uiY>0</uiY>
<uiWidth>32</uiWidth>
<uiHeight>16</uiHeight>
</BitmapCarEmpty>
<Color>141,58,166</Color>
<MinPrice>25000</MinPrice>
<MaxPrice>50000</MaxPrice>
<szIndustryLeaderTitle>Archduke of Arms</szIndustryLeaderTitle>
<szIndustryPlayerTitle>Gun Runner</szIndustryPlayerTitle>
</Good>
<Good>
----//

//----
</Good>
</RRTGoods>

Save this and close both files.
=======================================================================
We have a Good, now we will need the means to transport it from where it is produced to the
industry that will use it: We need a 'TrainCar'. Since we have a TrainCar hauling Wool, we will
use the same TrainCar to haul Cotton. Here is how!
Below is the RRT_TrainCars_NewEngland.xml file.
<TrainCar>
<szName>Wool Car</szName>
</TrainCar >
It is just one line "<szName>Wool Car</szName>" because it is refering to the
"C:\Program Files\2K Games\Firaxis Games\Sid Meier's Railroads!\Assets\XML\RRT_TrainCars.xml" file.
In order to make it haul Cotton we have to copy it from
"C:\Program Files\2K Games\Firaxis Games\Sid Meier's Railroads!\Assets\XML\RRT_TrainCars.xml" file into "RRT_TrainCars_NewEngland.xml" file and instruct it to haul cotton.
We have to change the first two lines
This is how the edited XML file should look:

<RRTTrainCars>
<Train Cars?\/>
<RRTGoodCars>
<TrainCar>
<szName>Cotton Car</szName>
<szGood>Cotton</szGood>
<szModel>Wool_Car.kfm</szModel>
<szDummyModel>Wool_Car_dummies.nif</szDummyModel>
<szGroundClackSound>AS3D_CLACK_PLANET_GROUND</szGroundClackSound>
<szBridgeClackSound>AS3D_CLACK_PLANET_BRIDGE</szBridgeClackSound>
<RunLength>30</RunLength>
</TrainCar>
<TrainCar>
<szName>Mail Car</szName>
</TrainCar>
<TrainCar>
<szName>Passenger Car</szName>
</TrainCar>
<TrainCar>
<szName>Coal Car</szName>
</TrainCar>
<TrainCar>
<szName>Nitrates Car</szName>
</TrainCar>
<TrainCar>
<szName>Wool Car</szName>
</TrainCar>
<TrainCar>
<szName>Livestock Car</szName>
</TrainCar>
<TrainCar>
<szName>Fish Car</szName>
</TrainCar>
<TrainCar>
<szName>Steel Car</szName>
</TrainCar>
<TrainCar>
<szName>Medicine Car</szName>
</TrainCar>
<TrainCar>
<szName>Textile Car</szName>
</TrainCar>
<TrainCar>
<szName>Food Car</szName>
</TrainCar>
<TrainCar>
<szName>Arms Car</szName>
</TrainCar>
<TrainCar>
<szName>Manufactured Goods Car</szName>
</TrainCar>
<TrainCar>
<szName>Wood Car</szName>
</TrainCar>
</RRTGoodCars>
<RRTTenderCars>
<TenderCar>
----//

//----
</TenderCar>
</RRTTenderCars>
</RRTTrainCars>
--------------------------------------------------------------------------------------------------
Now we need an Out-of-Town Industy or commonly known as an 'Annex' to produce Cotton.
For reason of simplicity we will use an existing "Grain Farm" to produce the Cotton. It is located in the 'RRT_Industries_New England.xml'. There is only one line to the Grain Farm that means that the
game will produce only the default good, which is of course, 'Grain'.
We want to produce not only Grain, but also Cotton, therefore we have to go to the 'Original Files' and open 'RRT_Industries.xml' and copy the following lines:

<Production>
<!--Produces 1 grain-->
<Resource>
<Input>None</Input>
<Output>Grain</Output>
<InputOutputRatio>1.0</InputOutputRatio>
</Resource>
</Production>

Note: as second Resource is being added, "Cotton", we have to have something to produce
it from. In this case we are using Nitrates. We can not produce two different output Goods
from the same input Good, unless we are using 'None' as an input.

Locate the 'Grain farm' and insert the above lines between '<szName>Grain Farm</szName>'

and '</RRTIndustry>'. It will look like this:

<RRTIndustry>
<szName>Grain Farm</szName>
<Production>
<!--Produces 1 grain-->
<Resource>
<Input>None</Input>
<Output>Grain</Output>
<InputOutputRatio>1.0</InputOutputRatio>
</Resource>
</Production>
</RRTIndustry>

Copy the four lines between '<!--Produces 1 grain-->' and '</Production>' and paste them
below '</Resource>'. Change the lower 'None' to 'Nitrates' and the lower 'Grain' to 'Cotton'.
The 'Grain Farm' should look like this:

<RRTIndustry>
<szName>Grain Farm</szName>
<Production>
<!--Produces 1 grain-->
<Resource>
<Input>None</Input>
<Output>Grain</Output>
<InputOutputRatio>1.0</InputOutputRatio>
</Resource>
<Resource>
<Input>None</Input>
<Output>Grain</Output>
<InputOutputRatio>1.0</InputOutputRatio>
</Resource>
</Production>
</RRTIndustry>

Save the XML and close it.

Two very important things to remember in any editing - watch your spelling and watch where
you place your new code. One missing or wrong letter can cause a crash! And some members
have carefully copied code, being sure everything was correct, and pasted it, but their map
refused to show the new item. Repeated checking showed all the code to be correct. Only
after much frustration and checking everthing else in the map did they notice that they had
put it BELOW the last line of code!

Thanks to Snoopy to reviewing and making corrections. :P
Jancsika :mrgreen:

Post Reply