For fans of C&C, BFME and Dune games, plus every game using one of the universes as its battleground.

Report article RSS Feed [C&C 3] Beginning coder's guide #2

Beginning coder's guide #2, how to create new units.

Posted by feillyne on Dec 18th, 2009
Basic Client Side Coding.

I) The previous tutorial, which should be read/followed first:
Moddb.com

II) Colours:
Existing or required or created by game devs
User-created / to create
Other important

III) Required files & programs:
1. All from the previous tutorial. ;-)

2. We will need also UI icons from official C&C3 website:
Files.ea.com
Extract them to MOD SDK folder, overwriting Art folder. You can also unpack them, and cut & paste Images folder to Art directory inside MOD SDK.

3. Any graphics editor supporting .TGA file format, such as GIMP:
Downloads.sourceforge.net

IV) Some cleaning up.

1. Shortcuts.
Make a shortcut to MOD SDK folder and place it somewhere near to have a quick access to your SDK.
You can also make a shortcut to your mod folder inside MOD SDK folder, and if you have localised version of C&C3 (French, Italian, German, etc.), to the not localised compiled folder of your mod (inside My Documents directory) to remember that you need to copy appropriate files from the not localised folder to translated one.

2. Creating additional folders.
1) Go to data folder inside FirstMod directory
2) create GDI folder
3) move GDIRifleSoldierSquad.xml and GDIRifleSoldier.xml files into the newly created folder (GDI).

3. Updating file directories.
1) Open Mod.xml with a text editor
2) Correct file paths changing
DATA:FirstMod/Data/GDIRifleSoldier.xml
DATA:FirstMod/Data/GDIRifleSoldierSquad.xml
to
DATA:FirstMod/Data/GDI/GDIRifleSoldier.xml
DATA:FirstMod/Data/GDI/GDIRifleSoldierSquad.xml

V) Adding new units

1. Create an additional folder Nod inside FirstMod/data directory

2. Go back to CnC3Xml inside MOD SDK main folder.
1) Choose NOD (should be Nod! :-D) folder, then Units
2) copy NODMilitantRocketSquad.xml files to your lately created Nod folder (inside FirstMod/data directory)
3) untick read-only (select it, right-click, click properties, uncheck read-only option)
4) rename
NODMilitantRocketSquad.xml
to
NODMilitantRocketEliteSquad.xml

3. Open Mod.xml
1) Include NODMilitantRocketEliteSquad.xml

html4strict code:
<Include type="all" source="DATA:FirstMod/Data/Nod/NODMilitantRocketEliteSquad.xml"/>

4. Open NODMilitantRocketEliteSquad.xml
1) id="NODMilitantRocketSquad"
It's the game/engine name of the unit (or in this case, the name of a squad of the unit).
Rename it to:
id="NODMilitantRocketEliteSquad"
2) CommandSet="NODMilitantRocketSquadCommandSet"
This code snippet is responsible for respawn/move of the unit after the creation.
Rename it to:
CommandSet="NODMilitantRocketEliteSquadCommandSet"
3)
Description="Desc:NODMilitantRocket"
TypeDescription="Type:NODMilitantRocket"
Name:NODMilitantRocket
rename them to
Description="Desc:NODMilitantRocketElite"
TypeDescription="Type:NODMilitantRocketElite"
Name:NODMilitantRocketElite

5. Open mod.str
1) Add:
NAME:NODMilitantRocketElite
"Nod Elite Rocket Squad"
END

TYPE:NODMilitantRocketElite
"Nod nonpareil Rocket Squad"
END

DESC:NODMilitantRocketElite
"The elite Nod Rocket Squad ready to destroy whole cities and all of GDI bases!"
END

2) Note similarities between mod.str and NODMilitantRocketEliteSquad.xml names:
Name:NODMilitantRocketElite = NAME:NODMilitantRocketElite
Desc:NODMilitantRocketElite = DESC:NODMilitantRocketElite
Type:NODMilitantRocketElite = TYPE:NODMilitantRocketElite
(lower/upper-case/caps doesn't make any difference)

6. Create a folder Global inside FirstMod/data.

7. Go back to CnC3Xml, choose GlobalData, then copy LogicCommand and LogicCommandSet to your newly created Global folder (inside FirstMod/data).
(Also, select them both, right-click, click properties, uncheck read-only option - both files can be made writable simultaneosly.)

8. Open LogicCommand.xml
1) Search for:

html4strict code:
<LogicCommand
Type="UNIT_BUILD"
id="Command_ConstructNODMilitantRocketSquad">
<span class="mceItemObject" >NODMilitantRocketSquad</span>
</LogicCommand>

or simply look for:
id="Command_ConstructNODMilitantRocketSquad"
Prefix "Command_Construct" is a prefix defined a construct command, and believe me, you don't want to change that. ;-D
NODMilitantRocketSquad, however, is what we want to change.
NODMilitantRocketSquad is taken from id= property found in NODMilitantRocket(Elite)Squad.xml earlier on.
The whole id with the prefix will be used later on as a construct command inside Hand of Nod commandset.

Create NODMilitantRocketEliteSquad construct command, taking NODMilitantRocketSquad as an example.

It should look like:

html4strict code:
<LogicCommand
Type="UNIT_BUILD"
id="Command_ConstructNODMilitantRocketEliteSquad">
<span class="mceItemObject" >NODMilitantRocketEliteSquad</span>
</LogicCommand>

Note: the construct command in this example creates a squad of the actual unit (not the unit itself).

9. Open LogicCommandSet.xml
1) Find NODMilitantRocketSquad's commandset.

It should look like:

html4strict code:
<LogicCommandSet
id="NODMilitantRocketSquadCommandSet">
<Cmd>Command_StanceDrillDown</Cmd>
<Cmd>Command_AttackMove</Cmd>
<Cmd>Command_NodCallForTransportInfantry</Cmd>
</LogicCommandSet>

Now you need to change the id only.
Rename
id="NODMilitantRocketSquadCommandSet"
to
id="NODMilitantRocketEliteSquadCommandSet

2) Find NODMilitantRocketSquad construct command.

It should look like:

html4strict code:
<Cmd>Command_ConstructNODMilitantRocketSquad</Cmd>

This construct command, as you can see, belongs to Nod Hand of Nod commandset (id="NODHandOfNODCommandSet").

You know what's next? :-) Yes!

Add after the above construct command for Nod Rocket Squad, create one for the elite squad:
Command_ConstructNODMilitantRocketEliteSquad
between cmd and /cmd tags (cmd stands for command, the "/" character denotes end of the command).

In the end it should be like this:

html4strict code:
<Cmd>Command_ConstructNODMilitantRocketEliteSquad</Cmd>

3) Find id="AllUnitsConstruct_CommandSet"

Find below Nod Rocket Squad commandest, Command_ConstructNODMilitantRocketSquad.

html4strict code:
<Cmd>Command_ConstructNODMilitantRocketSquad</Cmd>

Add after it:

html4strict code:
<Cmd>Command_ConstructNODMilitantRocketEliteSquad</Cmd>


10. Remember about adding include references to your files, unless you don't want to see lately created Elite Rocket Squad on the sidebar. ;-)
Inside FirstMod/data/Mod.xml, add:

html4strict code:
<Include type="all" source="DATA:FirstMod/Data/Global/LogicCommand.xml"/>
<Include type="all" source="DATA:FirstMod/Data/Global/LogicCommandSet.xml"/>


VI) Enlarging squads, ie. so-called "hordes".

1. Open NODMilitantRocketEliteSquad.xml
1) Find HordeContain tag. Something like this:

html4strict code:
<HordeContain
id="ModuleTag_HordeContain"

2) Look for "slots" property and change the amount to 4 (from 2), so it looks like:
Slots="4"

3) Then, within the tag HordeContain, find another one, namely InitialPayload.

Change unit's amount to 4 from 2, changing Count="2" to Count="4".

Now, now, you know very well what these properties mean. :-)

4) Now, you need only to change positions of our new blood for rocket squads:
After:

html4strict code:
<Position
X="0"
Y="-10" />
<Position
X="0"
Y="10" />

Add:

html4strict code:
<Position
X="10"
Y="-10" />
<Position
X="10"
Y="10" />

Ah, remember about Nod Confessor, a so-called banner carrier! He has such a position:

html4strict code:
<Pos
x="10"
y="0" />

So you mustn't get other infantry units in his way!

VII) Adding and linking new icons.

1. Have you downloaded the icon pack from EA at the very start of this tutorial? :-) (Step III) 2. )

2. If you've already done it, then go to MOD SDK main folder, choose Art folder, then Images.
1) Create an empty UpdatedIcons.xml file (remember about the extension .xml!)

2) Open packedimages.xml

3) look for NODMilitantMissile
(Not NODMilitantRocket or NODMilitantRocketSquad or NODMilitantRocketEliteSquad!)

Why NODMilitantMissile, not NODMilitantRocket?

Because in files NODMilitantRocketEliteSquad.xml / NODMilitantRocketSquad.xml / NODMilitantRocket.xml, portraits/cameos/icons are defined otherwise. Take a loot at NODMilitantRocketEliteSquad.xml
Find SelectPortrait and ButtonImage properties.
What do you see? :-)

SelectPortrait="Portrait_NODMilitantMissile"
ButtonImage="Portrait_NODMilitantMissile"

4) You should find the icon reference:

html4strict code:
<Texture id="PackedImages_177" File="PackedImages_177.tga" OutputFormat="A8R8G8B8" GenerateMipMaps="false" AllowAutomaticResize="false"/>

<PackedTextureImage id="Portrait_NODMilitantMissile" Texture="PackedImages_177" Rotated="false">
<Dimensions x="128" y="128"/>
<Coords x="0" y="0"/>
<TextureDimensions x="128" y="128"/>
</PackedTextureImage>

Now, copy this code to your file UpdatedIcons.xml

(Note: if you want to find a particular icon, just look at SelectPortrait/ButtonImage property inside the appropriate unit file, then File inside packedimages.xml)

5) Glance at how many .tga files you have inside Images folder.

Let's count... 220! Yes.

So you need to make a reference to a file #221 (a new icon), so the code copied above looks like (change all 177's to 221's):

html4strict code:
<Texture id="PackedImages_221" File="PackedImages_221.tga" OutputFormat="A8R8G8B8" GenerateMipMaps="false" AllowAutomaticResize="false"/>

<PackedTextureImage id="Portrait_NODMilitantMissile" Texture="PackedImages_221" Rotated="false">
<Dimensions x="128" y="128"/>
<Coords x="0" y="0"/>
<TextureDimensions x="128" y="128"/>
</PackedTextureImage>

Dimensions property defines the size of an icon.
Coords property defines where the icon inside an image file can be found.
Texture dimensions property defines the size of the image file.

Conclusion: Some of the .tga files contain multiple icons!

Ah, also change NODMilitantMissile to NODMilitantMissileElite (to have Portrait_NODMilitantMissileElite as a reference).

6) Note that Nod Rocket Infantry unit has an icon in PackedImages_177.tga file.
Let's take a look at that file. Is it correct? Yes! That's the icon for Nod rocket trooper.

Copy this file and paste if in the same directory (MOD SDK/Art/Images) and rename it to PackedImages_221.tga

7) Edit PackedImages_221.tga with your graphics editor. You can use a colourise option. In GIMP, you need to go to Colours -> Colorize.

Colourise your image to other colours (so you can tell the new elite rocket infantry squad from others).

8) Before we forget, we need to xmlise UpdatedIcons xml file. ;-) Because we have there only this:

html4strict code:
<Texture id="PackedImages_221" File="PackedImages_221.tga" OutputFormat="A8R8G8B8" GenerateMipMaps="false" AllowAutomaticResize="false"/>

<PackedTextureImage id="Portrait_NODMilitantMissileElite" Texture="PackedImages_221" Rotated="false">
<Dimensions x="128" y="128"/>
<Coords x="0" y="0"/>
<TextureDimensions x="128" y="128"/>
</PackedTextureImage>

Open UpdatedIcons.xml

So, what do we need?

A declaration that .xml file is indeed a xml file:

html4strict code:
<?xml version='1.0' encoding='UTF-8'?>

Put it before all else.

Now we need a decleration that it's EALA xml file (not xml files of other programs/companies):

html4strict code:
<AssetDeclaration xmlns="uri:ea.com:eala:asset" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

After the main xml declaration (ie after ).

And the end of the so-called asset declaration (EALA's one):

html4strict code:
</AssetDeclaration>

This one must be after everything else (at the end of the file content).

Now your UpdatedIcons.xml file should contain:

html4strict code:
<?xml version='1.0' encoding='UTF-8'?>
<AssetDeclaration xmlns="uri:ea.com:eala:asset" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <Texture id="PackedImages_221" File="PackedImages_221.tga" OutputFormat="A8R8G8B8" GenerateMipMaps="false" AllowAutomaticResize="false"/>
 
  <PackedTextureImage id="Portrait_NODMilitantMissileElite" Texture="PackedImages_221" Rotated="false">
    <Dimensions x="128" y="128"/>
    <Coords x="0" y="0"/>
    <TextureDimensions x="128" y="128"/>
  </PackedTextureImage>

</AssetDeclaration>


3. Open NODMilitantRocketEliteSquad.xml

Correct portrait references:
change
SelectPortrait="Portrait_NODMilitantMissile"
ButtonImage="Portrait_NODMilitantMissile"

to
SelectPortrait="Portrait_NODMilitantMissileElite"
ButtonImage="Portrait_NODMilitantMissileElite"

4. Open Mod.xml

You need to make a reference to the icon pack info (the icon declaration in UpdatedIcons.xml):
Add before the code below:

html4strict code:
<Include type="all" source="ART:Images/UpdatedIcons.xml" />


VIII) Some additional cleaning up.

1. Create a folder Images inside main FirstMod folder (where you have data folder!)

2. Open Mod.xml
and change the reference path of UpdatedIcons.xml
ART:Images/UpdatedIcons.xml
to
DATA:FirstMod/Images/UpdatedIcons.xml

3. Cut & copy PackedImages_221.tga and UpdatedIcons.xml to your Images folder inside FirstMod directory (MOD SDK/Mods/FirstMod/Images)

4. Open Mod.xml
1) Find such code (if there's one):

html4strict code:
<!--
mod.xml is the central include for mod setup data.   
-->

2) Delete it.

3) Tags

html4strict code:
<!--

and

html4strict code:
-->

denote comments, and they aren't interpreted by mod compiler/builder. You can put there and ONLY there what you want. Comment tags are for comments, it's that simple, really.

html4strict code:
<!-- begins the comment
--> ends it

4) Before

html4strict code:
<Include type="reference" source="DATA:static.xml" />
<Include type="reference" source="DATA:global.xml" />

add the comment:

html4strict code:
<!-- REQUIRED DATA FILES -->

5) Before

html4strict code:
<Include type="all" source="DATA:FirstMod/Data/GDI/GDIRifleSoldier.xml"/>
<Include type="all" source="DATA:FirstMod/Data/GDI/GDIRifleSoldierSquad.xml"/>

add the comment:

html4strict code:
<!-- GDI UNITS -->

6) Before

html4strict code:
<Include type="all" source="DATA:FirstMod/Data/Nod/NODMilitantRocketEliteSquad.xml"/>

add the comment:

html4strict code:
<!-- NOD UNITS -->

7) Before

html4strict code:
<Include type="all" source="DATA:FirstMod/Data/Global/LogicCommand.xml"/>
<Include type="all" source="DATA:FirstMod/Data/Global/LogicCommandSet.xml"/>

add the comment:

html4strict code:
<!-- GLOBAL DATA -->

8) Before

html4strict code:
<Include type="all" source="ART:Images/UpdatedIcons.xml" />

add the comment:

html4strict code:
<!-- ART DATA -->

9) Mod.xml should look like this now:

html4strict code:
<?xml version="1.0" encoding="UTF-8"?>
<AssetDeclaration xmlns="uri:ea.com:eala:asset" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Tags></Tags>
  <Includes>
      <!-- GLOBAL DATA -->
      <Include type="reference" source="DATA:static.xml" />
      <Include type="reference" source="DATA:global.xml" />

                <!-- GDI UNITS -->
                <Include type="all" source="DATA:FirstMod/Data/GDI/GDIRifleSoldier.xml"/>
                <Include type="all" source="DATA:FirstMod/Data/GDI/GDIRifleSoldierSquad.xml"/>
               
                <!-- NOD UNITS -->
                <Include type="all" source="DATA:FirstMod/Data/Nod/NODMilitantRocketEliteSquad.xml"/>
               
                <!-- GLOBAL DATA -->
                <Include type="all" source="DATA:FirstMod/Data/Global/LogicCommand.xml"/>
                <Include type="all" source="DATA:FirstMod/Data/Global/LogicCommandSet.xml"/>

      <!-- ART DATA -->
                <Include type="all" source="DATA:FirstMod/Images/UpdatedIcons.xml" />
   
  </Includes>
</AssetDeclaration>

Make additional breaks between lines if you haven't. ;-)

IX) Finishing.

1. Run ealamodstudio.exe
(Remember about moving the mod folder from not translated version to your localised one if you have C&C3 in other language than English.)

2. Run control panel, then click game browser button, launch FirstMod and check Nod faction (especially Hand of Nod)!

Post comment Comments
Jason_Zombolt
Jason_Zombolt Dec 18 2009, 12:29pm says:

How much of this Overlaps with RA3 I wonder?

+2 votes     reply to comment
feillyne Author
feillyne Dec 18 2009, 12:33pm replied:

Almost everything. Let's say, except CnC3Xml, which must be replaced by SageXml. Also squads... I couldn't make them for RA3.

+1 vote   reply to comment
Tehkrad
Tehkrad Feb 18 2010, 6:35pm says:

there are errors in this guide... such as the one about 1.

<span class="mceItemObject" >NODMilitantRocketSquad</span>

should have <Object>NODMilitantRocketEliteSquad</Object>
instead like the other logiccommands contents

;]

+2 votes     reply to comment
feillyne Author
feillyne Feb 19 2010, 3:39am replied:

Right... hmm... strange, it must have been added by Moddb article/html editor.

Here's my original text-only (w/o style formatting) tutorial:
Grans-productions.com

+1 vote   reply to comment
Fighter96
Fighter96 Oct 23 2010, 10:02am says:

when i make this Mod and i have install but id not work
and the first tutorial with GDISquad work not too
why pls help me

+1 vote     reply to comment
KOYK_GR
KOYK_GR May 11 2014, 1:49pm replied: +1 vote     reply to comment
sam_23694
sam_23694 Jan 22 2011, 6:56am says:

the only error with this 1 hav is this which comes up in the mod builder
Error: GameObject NODMilitantRocketEliteSquad has an unnamed module WeaponSetUpdate in file e:\program files\electronic arts\command & conquer 3\mod sdk\mods\firstmod\data \nod\nodmilitantrocketelitesquad.xml

and wen i play it all the name and description hav Missing:NODMilitantRocketEliteSquad

any help?

+1 vote     reply to comment
ItaliaStyle03
ItaliaStyle03 Oct 24 2011, 11:46am says:

Stream Sorter
ifest" not found

LoD Stream Builder
ifest" not found
1 bestand(en) gekopieerd.

Hash Fix
ifest" not found
Manifest Path: D:\Program Files\Electronic Arts\Command & Conquer 3 TBW (Kane Edition )\MOD SDK\builtmods\mods\FirstMod\data\mod.manifest
ifest" not found
ram Files\Electronic Arts\Command & Conquer 3 TBW (Kane Edition )\MOD SDK\builtmods\mods\FirstMod\data\mod.man
Critical: "D:\Program Files\Electronic Arts\Command & Conquer 3 TBW (Kane Edition )\MOD SDK\builtmods\mods\FirstMod\data\mod.man
Build failed on step 6

This is what my buildstudio says ? i really wanna learn this could anyone help me ?

+1 vote     reply to comment
Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Established
Oct 5, 2009
Privacy
Public
Subscription
Open to all members
Contact
Send Message
Email
Members Only
Membership
Join this group
Group Watch
Track this group
Tutorial
Browse
Tutorials
Report Abuse
Report article
Related Games
C&C3: Tiberium Wars
C&C3: Tiberium Wars Single & Multiplayer Real Time Strategy
Related Engines
SAGE (Strategy Action Game Engine)
SAGE (Strategy Action Game Engine) Proprietary Released Jun 14, 2001
Related Groups
C&C Paradise
C&C Paradise Fans & Clans group with 1,470 members
C&C Society
C&C Society Web & Community group with 214 members
Electronic Arts
Electronic Arts Developer & Publisher
SAGE 2D & 3D fans
SAGE 2D & 3D fans Fans & Clans group with 1,333 members