Post tutorial Report RSS [C&C 3] Beginning coder's guide #2

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

Posted by on - 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

<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:

<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:

<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:

<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:

<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:

<Cmd>Command_ConstructNODMilitantRocketEliteSquad</Cmd>

3) Find id="AllUnitsConstruct_CommandSet"

Find below Nod Rocket Squad commandest, Command_ConstructNODMilitantRocketSquad.

<Cmd>Command_ConstructNODMilitantRocketSquad</Cmd>

Add after it:

<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:

<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:

<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:

<Position
X="0"
Y="-10" />
<Position
X="0"
Y="10" />

Add:

<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:

<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:

<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):

<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:

<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:

<?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):

<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):

</AssetDeclaration>

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

Now your UpdatedIcons.xml file should contain:

<?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:

<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):

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

2) Delete it.

3) Tags

<!--

and

-->

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.

<!-- begins the comment
--> ends it

4) Before

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

add the comment:

<!-- REQUIRED DATA FILES -->

5) Before

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

add the comment:

<!-- GDI UNITS -->

6) Before

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

add the comment:

<!-- NOD UNITS -->

7) Before

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

add the comment:

<!-- GLOBAL DATA -->

8) Before

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

add the comment:

<!-- ART DATA -->

9) Mod.xml should look like this now:

<?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_King_of_Salt
Jason_King_of_Salt - - 2,364 comments

How much of this Overlaps with RA3 I wonder?

Reply Good karma Bad karma+2 votes
feillyne Author
feillyne - - 5,816 comments

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

Reply Good karma+1 vote
Tehkrad
Tehkrad - - 118 comments

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

;]

Reply Good karma Bad karma+2 votes
feillyne Author
feillyne - - 5,816 comments

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

Reply Good karma+1 vote
sam_23694
sam_23694 - - 949 comments

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?

Reply Good karma Bad karma+1 vote
DanielK00
DanielK00 - - 2 comments

You need to replace the < weaponsetupdate > line with
<WeaponSetUpdate
id="ModuleTag_WeaponSetUpdate">
That will solve the issue

Reply Good karma Bad karma+1 vote
GEN.ZOOL
GEN.ZOOL - - 946 comments

I want to get 6 units within a GrenadeSoldierSquad but I can't get it to be one squad. It comes out as 4 units in a squad and two extra units that are not selectable. How can I fix this?

Reply Good karma Bad karma+1 vote
Guest
Guest - - 687,512 comments

This comment is currently awaiting admin approval, join now to view.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: