1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[TUT] skin and add new Bonus Resources and add Improvements

Discussion in 'Civ4 - Modding Tutorials & Reference' started by Master Lexx, Jan 12, 2006.

  1. Master Lexx

    Master Lexx Warlord

    Joined:
    Nov 28, 2005
    Messages:
    187
    Tuturial: how to skin and add new bonus resources and improvments to the game

    I am the creator of GreenMod, I already included 9 new resources there. I want to share my knowledge and give instructions on how to do this for your own. How to alter the skins of existing resources to re use them for new ones, how to add new improvements and how to setup the xml files CIV4BonusInfos.xml , CIV4ImprovementInfos.xml , CIV4ArtDefines_Bonus.xml , CIV4ArtDefines_Improvement.xml , CIV4BuildInfos.xml , CIV4UnitInfos.xml .

    If you have any ideas or corrections regarding my guide, please send them to me via personal message!
    (or maybe you want some extra pics or description to something, simply pm me!)

    Here I will take the most difficult example on how to add a bonus resource, other bonus resources may be more simply but if you can make this difficult one, you will also be able to make all the simple ones. You can always look into GreenMod if you want to see it working. This tutorial is made for mod makers, who have some basic knowledge about graphics painting and know how to alter xml files. Don´t even try to ask here how to begin an own mod or where to get the xml files from and other basic things!

    I don’t speak native English, so please forgive me my sometimes worse word selection.

    You need Paint Shop Pro (http://www.zdnet.de/downloads/prg/s/l/de0DSL_is-wc.html, shareware)
    Also get a hex editor (HexWorkshop, http://bpsoft.com/ , shareware)
    A xml editor (notepad++, http://notepad-plus.sourceforge.net/uk/about.php , freeware)
    A dds converter (DDSConverter 2.1, http://eliteforce2.filefront.com/file/DDS_Converter;29412 , freeware)
    And make sure that in the DDSConverter options “save alpha if any” is activated!

    Also extract all the game resources with the pak extractor (there are w2k and wxp versions). The folder where you extracted your ingame art directory with this, will be refered by me as “exart”. (http://forums.civfanatics.com/showthread.php?t=137265)

    Other abbreviations:
    dir = directory
    pic = picture
    ddsc = dds converter
    impr = improvement
    mymod = dir of the mod (Civ4\Mods\Mymod)


    First some basic knowledge about selections and alpha channels with Painst Shop Pro.

    The alpha channel is just second picture in a picture. This alpha channel can only use grey scale colours, a black pixel at a sertain position in the alpha channel means that the same pixel in the real pic will not be visible (0%) outside the graphics programm. White means complete visible (100%). All colours between black and white represent a different transparency for the real pic between 0% and 100% visible.

    There are three possibilities to edit the alpha channel in PSP. First go into the menu – selection – selection (load/save) – load selection out of alpha channel. Now you see a new selection, this represents any not complete black colour in the alpha channel. So you can´t know if this is nearly invisible or complete visible.



    One way to make this visible is to go in the menu – selection – edit selection , now you can see the alpha channel represented with red colour on top of your real pic. With a black color you can remove the visible parts, with a white colour you can add new visible parts to the selection.



    Another way is to go menu – selection – selection (load/save) – save selection as file , the new file can be edited like every other pic. But only use greyscale colours there, because you want to use it again as selection/alpha channel later.



    A cheap although easy way to edit the alpha channel is to just let it be a selection. If you hold shift pressed while working with the selection tool you can add a new selection to the existing one (like complete white) and if you hold ctrl pressed you can remove something from the actual selection (like complete black). This is my preferred way to alter the alpha channel, but remember that the existing selection may not be all white, it can be every value between black and up to white.



    After you edited the selection or loaded it from a file, you need to save this again into the alpha channel of this file. Menu – selection – selection (load/save) – save selection into alpha channel, as name use the same name the existing alpha channel already has or it may add a second alpha channel but not all formats support more than one alpha channel (like dds).



    Remember after this you still need to save the file itself!
     
  2. Master Lexx

    Master Lexx Warlord

    Joined:
    Nov 28, 2005
    Messages:
    187
    Okay let´s start, you have your own mod and want to include the resource “lemon” into it.

    The ingame texture artwork:

    First open google, maybe wikipedia and search for lemons, see how the plant really looks. Lemons can grow on rather small bushes but also on big trees. Now start the game and place all resources and look, if any of the 3d models are useable to change their skins to make a new resource with one of them. The resource “spices” is very nice, it looks like many small bushes that have some fruits hanging down on them. So you chose this. The new resource doesn´t has to look really realistic, the most time players will not zoom in, so it just has to look good from a far distance.

    Go into exart and search for the spices dir, you can find it in exart\terrain\resources\spices\ . Now copy over the dir to mymod\art\terrain\resources\spices\ . With this the game simply uses the new spices dir instead of original one, so you can easily make changes to it and see how they look without any xml work to do. Of course this just replaces the resource instead of adding a new one, but you will later make a real new resource out of it.

    Now use ddsc and convert all the dds files in the spices dir into psd. Do never use jpg or bmp because they don´t support a alpha channel. Tga, png and psd are fine. Make a backup of all the psd files into a sub dir for the case that you need the originals later. No fear, if you delete the dir, the original spices out of the pak files will be used again by the game.



    Of couse you can´t know how the 3d model of this looks so try this, paint all the parts in the psd files into one color each, then select everything and save the selection into the alpha channel. So with everything selected, go into menu – selection – selection (load/save) – save selection into alpha channel, name the new alpha channel exactly like the old one, so it overwrites the old alpha channel instead adding a second one (which wouldn´t work for dds). Do remember that you still have to save the file itself after you saved the new alpha channel into it. For this case you modify the file spices_l.psd, and after all paintings are made you convert it back to dds and start the game to see how it looks.



    On my ingame pic you can see on the top left the unworked spices, in the middle the unworked spices with the plantation improvement, and in the lower right the worked (with citizen) spices plantation. Now you see which parts in the psd files are used for which part of the 3d model. What you can´t see here is, that the blue part is layed on top the yellow part, because we made the whole pic visible with the new alpha channel. You could also not alter the alpha channel and then you will see a bit better which texture part is for which 3d part. But eg if you want to use the dye 3d model it is really helpful to see all the 3d model parts. Make a screenshot of this and make notes on a sheet of paper so you don´t forget how the 3d model looks and what textures are layered on what 3d model parts.





    Maybe you have noticed that there are two files: spices_L.dds and spices.dds. Sometimes there are even more files, each for one purpose. Here the spices_L.dds is used for the ingame textures and the spices.dds is used for the civilopedia textures. The dye resource eg has 4 files, steam.dds (this is appearing over the round container, if you don´t want steam, simply make the alpha channel all black), dye.dds for civilopedia textures, dyeL.dds and dye_Lsystem.dds are maybe for the case with plantation and without. You should simply make your changes to the ingame one file and if you think that it´s finished, copy over the changed texture parts to the other files. Sometimes the textures aren´t shown in game, then it can be that you have to write the L in the filename uppercase. This happened once for me, and was fixed by an uppercase L.

    Now you know that the blue and yellow parts are used for the fruits in the case that there is no plantation or that there is a plantation and it is worked. The red part is used if it has a plantation but is not worked. The textures for the fruits are spread into all 4 directions. I can´t help you with painting the new textures, with this you are on your own. But make it simple and alter only the blue part and copy this over to the yellow part because there are two levels of leaves with fruits and no player will be able to distinguish if they are the same. And because you want the fruits to be shown in any case you also copy it over to the red part.



    Of course you still don´t have the fitting alpha channel. The simple way is, to load the original one as selection and repaint the alpha channel around your new fruits. For this simply have the original alpha channel loaded as selection, zoom in and hold shift pressed for adding areas to the selection or have ctrl pressed for subtraction from the selection. If you repainted the selection for one of the parts, you can save the whole selection as file, open this alpha file and copy over the ready made alpha part to the other alpha parts, save it and load the selection from this alpha file into your real texture file. In the alpha file, all black areas mean that the textures will not be visible, whereas white means that this texture area is visible, a grey means that this texture area will be half transparent.

    Note that each part has it´s own dimensions, you can´t see the borders. The texture file itself is 256x256 in size, each of the yellow, red and blue parts is 128x64 pixel in size. You can always paint borders in the file by yourself, it doesn´t matter in the case they aren´t shown because of black alpha or if you will overwrite them later. PSP shows in the status bar which dimensions your current selection has and over which pixel your mouse pointer currently is, this really helps. Also note that the colours may not be converted completely, eg a real red in the psd may be shown in the game as a little darker red, remember this in your colour selection.

    Save the loaded alpha selection into the alpha channel, save your file, copy over all the changed parts (coloured and alpha) to the other file and convert both files into dds again, finished. The best thing is, always to save the alpha channel of both files as file, and copy over the parts in the ready made alpha file to the other alpha file. If you save a slection into an alpha channel, remember that the alpha channel name has to be identical with the existing alpha channel name so it replaces the existing one.

    All resources have different dds files for different puposes. Eg. my sulphur resource was made out of the silver resource, but I had to change a little dds file which was used for the shimmering effect on the silver, I had to make it complete grey to get a solid yellow for sulphur. You need to find out for what purpose all the dds files are.

    Also note, all the resources with plantations need extensive modifications to the CIV4PlotLSystem.xml because they extensively use the Lsystem. This system is used for placing all the little bushes and the plantation building so that roads run between them and not through them. All the silver/stone/… resources can be easily modified, you just need to change the dir name of them. Rice has shimmering water and this cannot be removed, also it has three textures, they are switched depending on if it has a farm on it or if it is worked. You cannot change this. The wheat resource also always changes if it has a farm on it. The best modifiable resources are dye and spices. In GreenMod I used dye for “tea”, marble for salt, wheat for potatoes, spices for coffee, silver for sulphur, clam for pearls, spices for lemons, dye for cotton, and the chichen itza wonder for ancient temple.
     
  3. Master Lexx

    Master Lexx Warlord

    Joined:
    Nov 28, 2005
    Messages:
    187
    The ingame icons artwork:

    There are four icons for each resource. Two are the little icons in city screen and if you scroll over the resource on the map, two others which are basically the same are the bigger icons which are shown in civilopedia and in the game if you press ctrl-R. First you need to open google and search for lemon, switch to picture search, size small for this. You need a pic with size between 50x50 up to 300x300. The important fact is, that is has to look good after you resized it to 50x50, the overall size used is 64x64 but there is a border included.
    I found this one:

    So let´s get the icon for spices. You can find it here exart\interface\buttons\worldbuilder\spices.dds , copy it over to mymod\art\interface\buttons\worldbuilder\spices.dds and convert it to psd. Open it, paint all the spices art black, and only let the borders untouched. Now open the picture of lemon you found (you can also paint your own), be sure to have a black background, for this it is always good if the existing background is solid or transparent, it´s hard work to get the pic out of a varying background. If the background is of a solid colour, simply select everything, copy it, change the second colour in the colour palette panel to the background colour of the pic and paste the selection into a new pic as transparent selection. With this, the background colour of the pic is seen as transparent colour in PSP. If your lemon file already has a transparent background, you have simple work.

    The new lemon pic now has the lemon with a black background. Get rid of all the black borders, cut them off, so you have the lemon art in the middle and a few pixel of black as border on all four sides. Now resize the pic, copy everything, have black as transparent and paste it as transparent selection into the spices.psd pic. If it fits well in it between the borders you completed the first step. There should always be around 4 pixel space between the original borders and the lemon art, if it is too big, start over, undo the resize change in the lemon pic and restart resizing it and again copy it over to the spices.psd.



    So now your spices.psd is well made, you have the original borders and you have the lemon art in it. But again, you need to repaint the alpha channel. So load a selection out of the existing alpha channel, deselect all the original art alpha selections, nothing but the borders should left. Remember that the current selection can mean any colour but black, so you can´t know if the current selection is fully transparent or barley visible. Then add the whole area of the lemon to the existing selection and make it one pixel bigger, so you get a black border around you lemon. Save the selection into the alpha channel and save the file, convert it to dds, finished.

    Of course you can also save the alpha selection as file and there add the one pixel border around the lemon as grey instead of white so you would get a smoother transition between the lemon and the outside area. And then again reload the alpha and save it into the spices.psd file.

    That´s everything you have to do to get a button for the worldbuilder working. But you could be nice and do some more work. The game can load those pictures out of the single spices.dds and out of the unit_resource_atlas.dds. So if you go into the game and want to see if your new spices.dds is working, you will still see the old one because the game doesn´t load it from this single file. The big atlas.dds has all the pics of the units and resources in it, it is a big pic which can be loaded into the ram easily. I think the use of a single dds file for each resource wouldn´t be that memory efficient for the game as the big file is.

    So you make your own big file in which you can put all your resources, units, buildings and all other graphics. Convert the unit_resource_atlas.dds to psd, rename it to mymod_atlas.psd. Open it, make everything black, open your spices.psd and copy the whole graphic as selection in the top left of your mymod_atlas.psd. Load the alpha channel of mymod_atlas.dds and save the selection as file. Open this alpha file, make it all black. Save the alpha channel of your spices.psd as file, open this alpha file too. Copy over all the graphics out of the spcies alpha pic into the top left corner of your mymod_atlas alpha pic. Save your big alpha pic and load it into your mymod_atlas.psd file, save this selection into the alpha channel and save the pic itself. Now you have your own big atlas file, with one little resource graphic (including border) and a working alpha channel for this whole file.

    You must not resize this mymod_atlas.psd. I tried it and the game wasn´t able to load any graphics out of it then. It should stay on it´s original size. Also make sure, that the alpha channel is placed correctly, a one pixel mistake can make a visible difference.


    The ingame mini icons artwork:

    So there are still two small icons used by every resource, we have to add them. And again copy over Assets\Res\Fonts\GameFont.tga and GameFont75.tga to mymod\Res\Fonts\ .
    Those two tga files each have a set of all the miniicons, each graphic in GameFont.tga has to be 21x20 in size and GameFont75.tga needs all graphics in size 16x16. Of course you still have the lemon pic with the lemon art and black background. Now again try to resize it to, but to 21x20 and there should be one pixel space between all borders, so the lemon should be 18x19 in size. Copy it all over into the next empty square, just next to movies icon. Paint a black border around this lemon art. But make the rest in the box white. Load the alpha channel as selection and add the new lemon art including the black border to the existing selection and save the new selection into the alpha channel.

    There is no need to add the selection pixel by pixel, just add the icon box (without the pink borders) to the whole selection and then use the magic selection staff, hold ctrl pressed and deselect the white areas around the new lemon art, that´s much faster and easier.

    Now look on the movies resource square, it has a light blue/green dot on the right side on the pink grid. Get the colour of this dot and paint the dot at the exactly same position right on your lemon square with this colour. This little dot indicates, that this square is used. If you don´t place it, the game will simply start over and take the first resource miniicon. Okay, save the file, and do the same with the GameFont75.tga. But this time you don´t have to convert the files, because they are used as tga by the game.



    The order in which the resources appear in CIV4ArtDefines_Bonus.xml tell the game which miniicon to use. If there are more resources than minicon sqauares with a blue/green dot on the side, the game will start over at the beginning. If this dot is placed correctly but you can´t see the miniicon in the game, you maybe forgot to repaint the alpha channel or to save it correctly for this new resource icon.
     
  4. Master Lexx

    Master Lexx Warlord

    Joined:
    Nov 28, 2005
    Messages:
    187
    The xml art defines part:

    Copy over the CIV4ArtDefines_Bonus.xml to your mymod\Assets\XML\Art\CIV4ArtDefines_Bonus.xml. Open it, copy the whole part of the resource you used (spices here) and paste it on the bottom but obey the xml opening and closing tag rules! In type, change the name of the resource to lemon. fScale is the size of it ingame, fInterfaceScale is the size of it in civilopedia. Nif tells which 3d model to use, kfm tells which animations to use. Button tells which icon graphics to use, first it tries the last path, so it will look in Art/Greenmod_atlas.dds, x coordinate 7, y coordinate 3. But if you don´t have a big file for many of those icons, you could just use: <Button>Art/Interface/Buttons/WorldBuilder/Lemon.dds</Button>

    This should look like this:
    PHP:
    <BonusArtInfo>
        <
    Type>ART_DEF_BONUS_LEMON</Type>
        <
    fScale>0.5</fScale>
        <
    fInterfaceScale>1.5</fInterfaceScale>
        <
    NIF>Art/Terrain/Resources/Lemon/Lemqes.nif</NIF>
        <
    KFM>Art/Terrain/Resources/Lemon/Lemqes.kfm</KFM>
        <
    Button>,Art/Interface/Buttons/WorldBuilder/Lemon.dds,Art/Greenmod_atlas.dds,7,3</Button>
    </
    BonusArtInfo>
    Okay, now I have to explain something. This lemon example is a very difficult one. My sulphur was just silver, I modified the files, saved them and renamed the dir to sulphur. So I can use:
    PHP:
    <NIF>Art/Terrain/Resources/Sulphur/Silver.nif</NIF>
    <
    KFM>Art/Terrain/Resources/Sulphur/Silver.kfm</KFM>
    Think about it. Place roads on a tile, place a mine on another one, and roads with a mine on another one too. Now place silver on all of them, nothing changes, the roads stay the same, the improvement too. So it doesn´t use the LSystem. It is used for the calculation of roads, the resources itself and the improvement and the look of the improvement on different eras.

    But all the plantation resources are difficult. So I didn´t only changed the name of the dir, I also changed all the names of the files in it, I renamed them from spices to lemqes. I also opened all the files with a hex editor and renamed all appearances of spices to lemqes, Spices to Lemqes, spice to lemqe and Spice to Lemqe. Stupid name, I know. I just wanted to make sure the overall byte value count stays the same in the file, just for the case that there is some simple error checksum used to validate the file. But I didn´t changed the name if it was used for sound, eg. SOUND:AS3D_IMPROV_SPICE_WORKED because I don´t want to include a new sound. Maybe it will also work if you use a real custom name, but in any case you must not delete or insert a new byte into the file! And remember that there is sometimes a “s” added to the ending of the name and sometimes not, take this into account, it should not be changed.

    So why the hell change all names? Because of the CIV4PlotLSystem.xml . Get it and copy it to mymod\Assets\XML\Buildings\CIV4PlotLSystem.xml . Open it, there you need to search for all appearances of spices. There are around 200 lines you need to change or copy over.

    I tried to get it to work without hexediting the resource files and only change the name in the CIV4PlotLSystem.xml , but whatever I did, I couldn´t get it to work. So I went the easy way, I renamed every appearance of Spices to Lemqes, so there was no need to think in depth what to change, simply copy everything of spices in the xml, paste it directly below the spices part and again replace every name in the new lines.

    First copy everything from <!-- SPICE crops --> until <!-- SUGAR crops --> . Then change all the names, but do not change the case, so lower and uppercase have to stay lower and uppercase. Do it like:
    PHP:
    <!-- LEMON (Lemqescrops -->
    <
    ArtRef Name="art:lemon_crop">
        <!-- 
    when worked by plantation -->
        <
    Attribute_Class="Scalar">NIF:Art/Terrain/Resources/Lemon/Lemqes_LSystem.nif::2x2_01_Lemqe_Worked</Attribute>
        <
    Attribute Class="Improvement">IMPROVEMENT_PLANTATION</Attribute>
        <
    Attribute Class="Bonus">BONUS_LEMON</Attribute>
        <
    Attribute Class="Scalar">bCutTrees:1</Attribute>
        <
    Attribute Class="Scalar">bBonusWorkedOnly:1</Attribute>
        <
    Attribute Class="Scalar">bIsPartOfBonus:1</Attribute>
        <
    Attribute Class="Scalar">szBatchGroup:lemqe_crop</Attribute>
        <
    Scale>0.8</Scale>
        <
    Rotate>+45</Rotate>
    </
    ArtRef>
    Do this again and again for all spices parts you find. Later you will find something like this:

    <Attribute Class="Bonus">NO_BONUS,BONUS_ALL,!BONUS_SILK,!BONUS_DYE,!BONUS_SUGAR,!BONUS_SPICES </Attribute>

    Change it to this:

    <Attribute Class="Bonus">NO_BONUS,BONUS_ALL,!BONUS_SILK,!BONUS_DYE,!BONUS_SUGAR,!BONUS_SPICES,!BONUS_LEMON</Attribute>

    Go on with this again, if you see “,BONUS_SPICES” , change it to “,BONUS_SPICES, BONUS_LEMON” .
    The same with this: “!BONUS_SPICES” , change to “!BONUS_SPICES, !BONUS_LEMON” .

    The BONUS_NAME has to be named after the real bonus name you that is used in CIV4ArtDefines_Bonus.xml and CIV4BonusInfos.xml .

    So maybe we get a better description if the SDK comes out, but even if this happens, you still would need to add in all those xml entries. I am pretty sure the names of the files in the files are used here too, so the hexedit way is a safe and easy way and maybe the only possible.
     
  5. Master Lexx

    Master Lexx Warlord

    Joined:
    Nov 28, 2005
    Messages:
    187
    The xml bonus resources part:

    Get this file CIV4BonusInfos.xml and copy it over to mymod\Assets\XML\Terrain\CIV4BonusInfos.xml .
    You will have to add a complete new resource, so the best way to start is to copy everything from the resource you used as blueprint and paste it at the bottom of the file. You need to change the first lines before it can work:
    PHP:
    <BonusInfo>
        <
    Type>BONUS_LEMON</Type>
        <
    Description>TXT_KEY_BONUS_LEMON</Description>
        <
    Civilopedia>TXT_KEY_BONUS_LEMON_PEDIA</Civilopedia>
        <
    BonusClassType>BONUSCLASS_GENERAL</BonusClassType>
        <
    ArtDefineTag>ART_DEF_BONUS_LEMON</ArtDefineTag>
        <
    TechReveal>NONE</TechReveal>
        <
    TechCityTrade>TECH_CALENDAR</TechCityTrade>
        <
    TechObsolete>NONE</TechObsolete>
        <
    YieldChanges>
            <
    iYieldChange>1</iYieldChange>
            <
    iYieldChange>0</iYieldChange>
            <
    iYieldChange>0</iYieldChange>
        </
    YieldChanges>
        <
    iAITradeModifier>0</iAITradeModifier>
        <
    iHealth>0</iHealth>
        <
    iHappiness>1</iHappiness>
        <
    iPlacementOrder>5</iPlacementOrder>
        <
    iConstAppearance>40</iConstAppearance>
        <
    iMinAreaSize>3</iMinAreaSize>
        <
    iMinLatitude>0</iMinLatitude>
        <
    iMaxLatitude>60</iMaxLatitude>
        <
    Rands>
            <
    iRandApp1>25</iRandApp1>
            <
    iRandApp2>25</iRandApp2>
            <
    iRandApp3>0</iRandApp3>
            <
    iRandApp4>0</iRandApp4>
        </
    Rands>
        <
    iPlayer>100</iPlayer>
        <
    iTilesPer>0</iTilesPer>
        <
    iMinLandPercent>0</iMinLandPercent>
        <
    iUnique>0</iUnique>
        <
    iGroupRange>1</iGroupRange>
        <
    iGroupRand>50</iGroupRand>
        <
    bArea>1</bArea>
        <
    bHills>1</bHills>
        <
    bFlatlands>1</bFlatlands>
        <
    bNoRiverSide>0</bNoRiverSide>
        <
    bNormalize>1</bNormalize>
        <
    TerrainBooleans/>
        <
    FeatureBooleans>
            <
    FeatureBoolean>
                <
    FeatureType>FEATURE_JUNGLE</FeatureType>
                <
    bFeature>1</bFeature>
            </
    FeatureBoolean>
            <
    FeatureBoolean>
                <
    FeatureType>FEATURE_FOREST</FeatureType>
                <
    bFeature>1</bFeature>
            </
    FeatureBoolean>
        </
    FeatureBooleans>
        <
    FeatureTerrainBooleans>
            <
    FeatureTerrainBoolean>
                <
    TerrainType>TERRAIN_GRASS</TerrainType>
                <
    bFeatureTerrain>1</bFeatureTerrain>
            </
    FeatureTerrainBoolean>
            <
    FeatureTerrainBoolean>
                <
    TerrainType>TERRAIN_PLAINS</TerrainType>
                <
    bFeatureTerrain>1</bFeatureTerrain>
            </
    FeatureTerrainBoolean>
        </
    FeatureTerrainBooleans>
    </
    BonusInfo>
    If you don´t want to include a civilopedia description, change the third line to: <Civilopedia/>
    But you should already know how to change xml files and know the rules. Everything between <BonusInfo> and </BonusInfo> describes the resource. But you should already know the basic xml rules.

    Now I try to give a description of each xml tag:
    Type = name of the resource
    Description = key of the xml part for the name of the resource in all languages
    Civilopedia = key of the civilopedia entries for all languages of the resource
    BonusClassType = class of the bonus, there are explicit classes which will disable some options here like iGroupRand, but others like iArea are still taken into account. With the class general all other options are used, all the other classes are used so that this resource is placed equally in the world and maybe the AI also uses this to kow what will give more growth for a city like class grain or what is very important like with both files rush or modern.

    ArtDefineTag = the key where it can find all infos about where the files for this resource can be found and which icon it will get.
    TechReveal = which tech is needed before this resource is shown on the map
    TechCityTrade = which tech is needed before this resource can be used for happy or health or use for units
    TechObsolete = which tech makes it invalid for happy or health or trade
    PHP:
    <YieldChanges>
        <
    iYieldChange>1</iYieldChange>
        <
    iYieldChange>2</iYieldChange>
        <
    iYieldChange>3</iYieldChange>
    </
    YieldChanges>
    This can be a positive or negative change for the resource on this title, first is food, second production, third commerce.

    AITradeModifier = bigger sizes mean, the AI will pay more to get this resource in trade but also wants more if you want to get this in trade. (Oil is 20, most others 0)
    iHealth = how much health you get in every connected city for this resource
    iHappiness = how much happiness you get in every connected city for this resource
    iPlacementOrder = the way how the game places this resource on a new created world, so food resources are well spread, marble and stone are further away from civs,… those are different placement orders, just think of where resources are usually placed or start a new game and look how they are placed in the world and how near they are to civ start places.
    iron and oil have 0,
    copper and horse have 1,
    alu and coal and uran have 2,
    stone and marble have 3,
    food resources have 4,
    money resources have 5,
    water resources have 6

    iConstAppearance = this is a percentage, 100 mens full amount placed, 50 means only the half amount is placed, 200 the double amount. This depends on iPlayer! But it seems to have a limit, even if set to 2000 there are no more than 20 resources placed on a huge map.
    iMinAreaSize = I believe, this is the minimum distance from which point of the same resource can be placed again.
    iMinLatitude = the minimum latitude from where this resource appears, latitude 0 is a circle around the world exactly between north and south pole.
    iMaxLatitude = the maximum latitude up until which the resource will be placed, latitude 100 are two points, the north pole and the south pole. Resources are never placed at latitude over 90. On some maps where there is no north and south pole, the north and south borders are latitude 90.
    Rands = Those are percentages, the first is the chance that the resource will be placed one title away from the through iPlacementOrder calculated position, the second is the chance that it again appears one title away from the new position. There is no need for a third and fourth chance, because this will just be overhead because the chance is too low.
    iPlayer = a percentage, this is the basic value for determining how many resources to place, 100 means one per player, 50 one per two players, 200 two per player. 0 has a special meaning, all food resources have this, the game then places as they fit
    iTitlesPer = I believe this is the minimum amount of titles needed for placing one of this resource.
    iMinLandPercent = if the resource will be placed on water and land, this is the percentage of how many of this will be placed on land.
    iUnique = this sets how the AI thinks about the resource, so higher means more important, so the AI is more likely to start a war because of it and sees this as primary target.
    copper, alu, marble, stone and the most others have 0,
    all water resources have 1,
    banana and deer have 2,
    coal has has 4,
    horse and uran have 6,
    iron and oil have 7
    iGroupRange = if iGroupRand is used, this sets how far away a more of this resource will be placed
    iGroupRand = this is the percentage, how likely it is that there is another resource of this placed next to this one
    bArea = if this is set and the map has more than one continent this resource will only be placed on one continent instead of all over the map
    bHills = if set, the resource can be placed on a hill
    bFlatlands = if set, the resource can be placed on flatlands
    bNoRiverSide = if set, the resource will not be placed next to a river
    bNormalize = means it is used for starting location normalization (extra resources that are added to even out starting locations)
    PHP:
    <TerrainBooleans>
        <
    TerrainBoolean>
            <
    TerrainType>TERRAIN_SNOW</TerrainType>
            <
    bTerrain>1</bTerrain>
        </
    TerrainBoolean>
        <
    TerrainBoolean>
            <
    TerrainTypeTERRAIN_GRASS </TerrainType>
            <
    bTerrain>1</bTerrain>
        </
    TerrainBoolean>
    </
    TerrainBooleans>
    <
    FeatureBooleans>
        <
    FeatureBoolean>
            <
    FeatureType>FEATURE_JUNGLE</FeatureType>
            <
    bFeature>1</bFeature>
        </
    FeatureBoolean>
    </
    FeatureBooleans>
    <
    FeatureTerrainBooleans>
        <
    FeatureTerrainBoolean>
            <
    TerrainType>TERRAIN_GRASS</TerrainType>
            <
    bFeatureTerrain>1</bFeatureTerrain>
        </
    FeatureTerrainBoolean>
    </
    FeatureTerrainBooleans>
    TerrainBooleans tell on which terrain the resource can be placed. FeatureBooleans tell on which features in connection to the terrain of FeatureterrainBoolean[/B] the resource can be placed. FeatureTerrainBooleans tell on which terrain that also has one of the specified features the resource can be placed. The above example tells, that the resource can be placed on snow or grass or grass with jungle. If you want to make only terrains valid, use TerrainBooleans, if you want it to be placed on a terrain that also has a certain feature you need to use FeatureBooleans and FeatureTerrainBooleans, if you also want it to appear on a terrain but also on the same terrain with a certain feature you have to specify it in all three Booleans.
    bUseLSystem = if it should use the L System, I am sure this means that it should use a standard generic L-System, because those resources which doesn´t use the lsystem here are very simple and don´t need it or they have all lsystem informations stored in the CIV4PlotLSystem.xml .
     
  6. Master Lexx

    Master Lexx Warlord

    Joined:
    Nov 28, 2005
    Messages:
    187
    The xml improvements part:

    Of course you also need to tell the game which improvement really activates the effects of the resource. Get CIV4ImprovementInfos.xml and copy it over to mymod \Assets\XML\Terrain\CIV4ImprovementInfos.xml . If you just modified an existing resource like spices (which needs a plantation) and want to add this to the plantation improvement, search for spices, copy this xml parts and paste it below the existing one, you only need to change the YieldChanges and the name of this resource. Like this:
    PHP:
    <BonusTypeStruct>
        <
    BonusType>BONUS_LEMON</BonusType>
        <
    bBonusMakesValid>1</bBonusMakesValid>
        <
    bBonusTrade>1</bBonusTrade>
        <
    iDiscoverRand>0</iDiscoverRand>
        <
    YieldChanges>
            <
    iYieldChange>1</iYieldChange>
            <
    iYieldChange>0</iYieldChange>
            <
    iYieldChange>1</iYieldChange>
        </
    YieldChanges>
    </
    BonusTypeStruct
    BonusType = name of the resource
    bBonusMakesValid = the improvement can always be built on this resource.
    bBonusTrade = if it is allowed to trade this resource
    iDiscoverRand = the chance in 1/x per turn, that this resource can appear on this title if this improvement is built on this title. This makes no sense for all resources whose improvements cannot be built without them. But a mine can be built without gold, so there is a random chance that you can find gold later on this title.
    YieldChanges = this changes food, production, commerce if this improvement is built on this resource, this is added to the terrain yields and the bonus yields.

    Now the new ressource should basicaly work.


    The descriptions and civilopedia xml part:


    You should note although you now have a new resource, it has no ingame name and no civilopedia entry. The easiest thing is, to get this file: CIV4GameTextInfos_Objects.xml and copy it over to mymod\Assets\XML\Text\CIV4GameTextInfos_Objects.xml . But the Texts used for descriptions and civilopedia are special. If you have this file in your mod dir, the game will use this instead of the existing one. But if you rename this file to MymodGameTextInfos_Objects.xml the game will still use all the entries in this file instead of the existing one, but you don&#180;t have to include all the entries here, you can simply delete all entries in this file and just add your new ones, so the game loads those as additional entries. So delete every not needed xml entries in there but let one stay and alter the tags. Like this:
    PHP:
    <TEXT>
        <
    Tag>TXT_KEY_BONUS_LEMON</Tag>
        <
    English>Lemons</English>
        <
    French>
            <
    Text>Citrons</Text>
            <
    Gender>Male</Gender>
            <
    Plural>0</Plural>
        </
    French>
        <
    German>
            <
    Text>Zitronen</Text>
            <
    Gender>Female</Gender>
            <
    Plural>0</Plural>
        </
    German>
        <
    Italian>
            <
    Text>Limoni</Text>
            <
    Gender>Male</Gender>
            <
    Plural>0</Plural>
        </
    Italian>
        <
    Spanish>
            <
    Text>Limones</Text>
            <
    Gender>Male</Gender>
            <
    Plural>0</Plural>
        </
    Spanish>
    </
    TEXT>
    The text key has to be the same that you specified in CIV4BonusInfos.xml in the Description tag. For the translation you can use this: http://freetranslation.com/ it is good enough for a few words, keep your words simple and never try to translate a real text! It would be unreadable.

    If you also specified a civilopedia key in CIV4BonusInfos.xml, do the same thing, get CIV4GameText_Civilopedia_Bonuses.xml , copy it to Mymod\Assets\XML\Text\CIV4GameText_Civilopedia_Bonuses.xml and rename it to MymodGameText_Civilopedia_Bonuses.xml. Delete everything but one entry in it an alter this. The civilopedia text is really just a nice addon, you can&#180;t translate the text into languages which you don&#180;t speak. But it&#180;s easy, go to http://wikipedia.org/ and search there. So you can include the English text (most people can talk English nowadays) and if you speak more languages, search the wikipedia in another language for this subject and include some text from there too for another language. For all languages where you can&#180;t get a good text, simply let them empty. Now the resource should be working.
     
  7. Master Lexx

    Master Lexx Warlord

    Joined:
    Nov 28, 2005
    Messages:
    187
    The extended xml improvements part:

    Maybe you don&#8217;t simply want to add a resource to an existing improvement but rather want to make a complete new improvement. So try to add a desert windmill.

    First again you need to specify how this improvement looks. Get CIV4ArtDefines_Improvement.xml and copy it over to Mymod\Assets\XML\Art\CIV4ArtDefines_Improvement.xml . Copy one of those parts and paste it at the bottom and change it like you did with the CIV4ArtDefines_Bonus.xml . It should look like this:
    PHP:
    <ImprovementArtInfo>
        <
    Type>ART_DEF_IMPROVEMENT_DESERTWINDMILL</Type>
        <
    bExtraAnimations>0</bExtraAnimations>
        <
    fScale>1.3</fScale>
        <
    fInterfaceScale>0.6</fInterfaceScale>
        <
    NIF>Art/Structures/Improvements/WindMill/WindMill_Mod.nif</NIF>
        <
    KFM>Art/Structures/Improvements/WindMill/WindMill_Mod.kfm</KFM>
        <
    Button>,Art/Interface/Buttons/Builds/BuildWindMill.dds,Art/Interface/Buttons/Actions_Builds_LeaderHeads_Specialists_Atlas.dds,5,8</Button>
    </
    ImprovementArtInfo>
    The NIF file is the 3d model file, it auto loads the textures, you can let the kfm empty if it has no animations or shouldn&#8217;t have.

    Of course you can simply look through all the atlas dds files which have all the icons in them and simply set the icon path to one of them.

    Type = the name of this improvement art, you need this in another file
    bExtraAnimations = only the farm has this set, so use this if you add a new farm
    fScale = the size of the improvement ingame
    fInterfaceScale = the size of this improvement in the civilopedia
    NIF = the 3d model of the improvement
    KFM = the infos for the animations of this improvement
    Button = which icons to use for this, it first tries the last one out of a big file


    So you also need to add a new improvement, open CIV4ImprovementInfos.xml and copy one of the improvements and paste it at the bottom. It should look like this:
    PHP:
    <ImprovementInfo>
        <
    Type>IMPROVEMENT_DESERTWINDMILL</Type>
        <
    Description>TXT_KEY_IMPROVEMENT_DESERTWINDMILL</Description>
        <
    Civilopedia>TXT_KEY_IMPROVEMENT_WINDMILL_PEDIA</Civilopedia>
        <
    ArtDefineTag>ART_DEF_IMPROVEMENT_DESERTWINDMILL</ArtDefineTag>
        <
    YieldChanges>
            <
    iYieldChange>0</iYieldChange>
            <
    iYieldChange>0</iYieldChange>
            <
    iYieldChange>4</iYieldChange>
        </
    YieldChanges>
        <
    bHillsMakesValid>0</bHillsMakesValid>
        <
    bFreshWaterMakesValid>0</bFreshWaterMakesValid>
        <
    bRiverSideMakesValid>0</bRiverSideMakesValid>
        <
    bNoFreshWater>0</bNoFreshWater>
        <
    bRequiresFlatlands>0</bRequiresFlatlands>
        <
    bRequiresRiverSide>0</bRequiresRiverSide>
        <
    bRequiresIrrigation>0</bRequiresIrrigation>
        <
    bCarriesIrrigation>0</bCarriesIrrigation>
        <
    bRequiresFeature>0</bRequiresFeature>
        <
    bWater>0</bWater>
        <
    bGoody>0</bGoody>
        <
    bPermanent>0</bPermanent>
        <
    iTilesPerGoody>0</iTilesPerGoody>
        <
    iGoodyRange>0</iGoodyRange>
        <
    iUpgradeTime>0</iUpgradeTime>
        <
    iAirBombDefense>5</iAirBombDefense>
        <
    iDefenseModifier>0</iDefenseModifier>
        <
    iPillageGold>5</iPillageGold>
        <
    TerrainMakesValids>
            <
    TerrainMakesValid>
                <
    TerrainType>TERRAIN_DESERT</TerrainType>
                <
    bMakesValid>1</bMakesValid>
            </
    TerrainMakesValid>
        </
    TerrainMakesValids>
        <
    FeatureMakesValids/>
        <
    ImprovementPillage/>
        <
    ImprovementUpgrade/>
        <
    TechYieldChanges/>
        <
    RouteYieldChanges/>
        <
    bGraphicalOnly>0</bGraphicalOnly>
    </
    ImprovementInfo>
    Type = the internal name of this improvement
    Description = the key of the entry which holds all names for this improvement
    Civilopedia = the key for the entry which holds the civilopedia texts
    ArtDefineTag = this is the tag you specified in CIV4ArtDefines_Improvement.xml as Type
    PrereqNatureYields = the amount of food, production, commerce that already has to be on the title before the imp can be built there, note that a river adds one commerce and that a forest adds one production
    YieldChanges = food, production, commerce changes if this improvement has been built on a title
    bHillsMakesValid = if set, the impr always can be built on a hill, regardless of anything else
    bFreshWaterMakesValid = if set, the impr always can be built next to a river or a lake
    bRiverSideMakesValid = if set, the impr always can be built next to a river
    bRequiresIrrigation = if set, the impr needs an irrigated title next to it before it can be built
    bCarriesIrrigation = if set, the impr will count as irrigated so you can irrigate titles next to it
    bRequiresFeature = if set, the impr needs the specified feature existing or it will be removed
    bWater = if set, the impr needs water to be built on
    bGoody = if set, the impr gives a goody if somebody enters it&#180;s title (like the goody hut)
    bPermanent = if set, the impr cannot be destroyed, it stays for the rest of the game
    iTitlesPerGoody = for every this many titles there is one of this goody placed
    iGoodyRange = the distance from which this goody can be seen by a unit
    iUpgradeTime = the time in turns that is needed on standard gamespeed until it upgrades to another impr
    iAirBombDefense = the defence of this impr against attacks by air units, it seems that if the strength of the air unit is equal to the airbombdefense, there is a 1 to 1 chance that it get&#180;s destroyed on attack
    iDefenseModifier = the defence percentage added to all units on the title of the impr
    iPillageGold = the base gold value that a unit get&#180;s if this impr is pillaged
    TerrainMakesValid = here you can specify on which terrains this impr can always be built
    FeatureMakesValid = here you can specify on which features this impr can always be built
    BonusTypeStructs = the bonus resources that make the impr valid to be placed on
    ImprovementPillage = this is the impr to which this one is downgraded if it is pillaged
    ImprovementUpgrade = the impr to which this one is upgraded after the iUpgradeTime
    TechYieldChanges = food, production, commerce changes for this impr after the specified tech has been researched
    RouteYieldChanges = food, produktion, commerce changes if a road or railroad was built on the impr title
    bGraphicalOnly = this is only set for land and water worked, you should let this 0


    So, the art defines are correct and the improvement also, next get CIV4BuildInfos.xml and copy over to mymod\Assets\XML\Units\CIV4BuildInfos.xml . Open it and add a new buildtype. Simply copy one and paste it at the bottom. But you need to change the values.
    PHP:
    <BuildInfo>
        <
    Type>BUILD_DESERTWINDMILL</Type>
        <
    Description>TXT_KEY_BUILD_DESERTWINDMILL</Description>
        <
    Help/>
        <
    PrereqTech>TECH_ELECTRICITY</PrereqTech>
        <
    iTime>800</iTime>
        <
    bKill>0</bKill>
        <
    ImprovementType>IMPROVEMENT_DESERTWINDMILL</ImprovementType>
        <
    RouteType>NONE</RouteType>
        <
    EntityEvent>ENTEVENT_BUILD</EntityEvent>
        <
    FeatureStructs/>
        <
    HotKey>KB_W</HotKey>
        <
    bAltDown>0</bAltDown>
        <
    bShiftDown>1</bShiftDown>
        <
    bCtrlDown>0</bCtrlDown>
        <
    iHotKeyPriority>0</iHotKeyPriority>
        <
    Button>,Art/Interface/Buttons/Builds/BuildWindMill.dds,Art/Interface/Buttons/Actions_Builds_LeaderHeads_Specialists_Atlas.dds,5,8</Button>
    </
    BuildInfo>
    Type = name of this build type
    Description = text key for the entry with all names of this, it&#180;s the same like with all other text xml files, copy over the Civ4GameTextInfos.xml, rename to MymodGameTextInfos.xml and modify it, let just one entry with the name you specified here.
    Help = Again a key to a text file, text that is displayed if you move your mouse over the build button. Maybe you should just let this empty.
    Prereqtech = this tech is needed before the button is showing up in the worker menu. You can also set this to NONE.
    iTime = the time needed to build this, the standard worker has a speed of 100, so if the time here is et to 1000 it will need 10 turns on standard gamespeed.
    bKill = if set, the unit will be killed after this has been built
    ImprovementType = the name of the type you spciefied in CIV4ImprovementInfos.xml for the new improvement
    RouteType = you can specify road or railroad here, this is built then
    EntityEvent = here you specify what animation of the workers is played (if they use hammers or shovels or mining equipment)
    FeatureStructs = here you can specify features, which tech is needed to build this impr if this feature is here, and what to do with them if this impr is build on them, you can set additional time if there is forest, how much production the next city gains through this and if this feature will be removed after the time is over.
    Button = this is the graphic you will see in the workers menu to build this improvement

    One last file still needs modification, get CIV4UnitInfos.xml and copy it over to Mymod\Assets\XML\Units\CIV4UnitInfos.xml . Open it, search for &#8220;scrub&#8221; and you will jump directly to all the worker menu options. So directly under this paste:
    PHP:
    <Build>
        <
    BuildType>BUILD_DESERTWINDMILL</BuildType>
        <
    bBuild>1</bBuild>
    </
    Build>
    This will include this option to the worker menu, but remember that there are two workers in civ4! The normal one and the Indian fast worker, so simply search for the next appearance of &#8220;scrub&#8221; and paste the option there too.

    Quick explanation of the connection between those files: In CIV4UnitInfos.xml you added the option that there should be a new button in the workers menu. All infos about this button are stored in the CIV4BuildInfos.xml. There you also specified which improvement this should place from CIV4ImprovementInfos.xml. And there you specified which one out of the CIV4ArtDefinesImprovements.xml is the right art specification with 3d model and animations. The Type you always specified is used to access the right one.

    END of this guide :)

    I hope somebody has a use for this, spelling mistakes and corrections can be sent to me via pm!
     
  8. Exavier

    Exavier Destroyer of Worlds

    Joined:
    Nov 14, 2005
    Messages:
    906
    Location:
    Phoenix, Arizona, USA
    nice work... now to actually read it :p

    EDIT: thankyou very much. I am horrible with 2D graphics editing (probobly because i didn't know how to work with the Alpha chanel to figure out what to edit). Going to have fun now :p
     
  9. Ereonus

    Ereonus Chieftain

    Joined:
    Dec 24, 2005
    Messages:
    3
    Location:
    St Vallier (fr)
    Thanks for your fantastic work, you do and explain all i want to do !!!!


    GREAT thanks

    :goodjob:
     
  10. LittleRedPoint

    LittleRedPoint Slaver

    Joined:
    Dec 13, 2004
    Messages:
    155
    Location:
    Estonia (EU)
    Thank you for your great tutorial! This cover a path that was missing in the tutorial section! :goodjob:
     
  11. Ereonus

    Ereonus Chieftain

    Joined:
    Dec 24, 2005
    Messages:
    3
    Location:
    St Vallier (fr)
    How do you modify the .nif files, can you give us a list of all tools you use.

    The tools for all the modifications you do.

    Thanks
     
  12. Exavier

    Exavier Destroyer of Worlds

    Joined:
    Nov 14, 2005
    Messages:
    906
    Location:
    Phoenix, Arizona, USA
    Noone can edit the Nif files Civ4 uses atm... for the resorces he used a different similar kind and just reskinned it.
     
  13. RED DIAMOND

    RED DIAMOND Prince

    Joined:
    Dec 24, 2005
    Messages:
    380
    You did a fantastic job on adding resources Exavier.:goodjob:
     
  14. Exavier

    Exavier Destroyer of Worlds

    Joined:
    Nov 14, 2005
    Messages:
    906
    Location:
    Phoenix, Arizona, USA
    um wrong name for credit :p
    I have only added 1 resorce... Steel... and thats still in the beta for the next version of my mod :p
     
  15. Master Lexx

    Master Lexx Warlord

    Joined:
    Nov 28, 2005
    Messages:
    187
    So let&#180;s thank exavier for writing 4k words in a foreign language and spending many hours with this.

    :mad: :mad: :mad: This really is not nice! :mad: :mad: :mad:
     
  16. Zuul

    Zuul Mod lister!

    Joined:
    Nov 13, 2005
    Messages:
    1,117
    Location:
    Sweden
    No lets thank Master Lexx instead. Exavier already got his 15 min ;p.
     
  17. Exavier

    Exavier Destroyer of Worlds

    Joined:
    Nov 14, 2005
    Messages:
    906
    Location:
    Phoenix, Arizona, USA
    I thought it was pretty funny... but I made sure to point out the error :)
     
  18. GIR

    GIR It'sNotStupidIt'sAdvanced

    Joined:
    Jul 12, 2005
    Messages:
    884
    Location:
    EU
  19. Crypticnight

    Crypticnight Chieftain

    Joined:
    Dec 11, 2005
    Messages:
    9
    Excelent work! And great explanations!:) This tuturial adds yet another perspective to my thoughts upon your mod and the time that you have spent on your project. Bravo!:goodjob:
     
  20. KGrevstad

    KGrevstad Warlord

    Joined:
    Dec 14, 2005
    Messages:
    110
    Location:
    Pacific Northwest
    Excellent work, Master Lexx, on both this tutorial and your GreenMod. However, I am trying to merge portions of your GreenMod into my mod, which already includes the Lost Wonders mod. The Lost Wonders mod already has modified the GameFont.tga files so now I need to merge your graphics with those of the Lost Wonders.

    I am using gimp. When I bring up the file for editing, I do get all the lovely icons, but what I don't get is the pink grid (and the background is gey/white checkerboard, which is just gimp, probably). Is this pink grid part of the image, an artifact of PaintShop, or meta-information about the image? Without the pink grid, I also don't have the blue-green activation dot.

    Am I doing something wrong here, or is gimp simply unable to manipulate these files?

    --Kristine
     

Share This Page