C&C: How to create new units - a tutorial: The Mutant
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Well, CCEdit v4 is just about finished (it is at Beta 0.99 and available at
my website - mentioned below), so I thought that I'd try and start up a
little discussion about how you can go about creating "new" units for C&C.
After all, we have to do something to fill the wait for RA.

Let me define "new" first:
I do not mean add in additional units to C&C. This is impossible. What I
mean is that you change the characteristics of a currently existing
unit/building so that it takes on the desired properties of the unit that
you wish to create.

There are a couple of programs that you will need first:
1. CCEdit v4. Although officially a Beta, it is 99% finished and is fully
functional. It lets you edit every value of every unit in C&C. It will also
be used to create the patch files that will contain your new unit.
You can obtain this file from:
http://www.geocities.com/TimesSquare/5458
in the C&C section.

2. Mix Manager v3.1 or higher. If you wish to go that extra step and actually
change the *graphics* for the units in C&C, then you will need this program
and its associated files. There are programs here that let you extract the
graphics from the C&C files, convert them to pcx files, and convert pcx files
to the C&C format. You just use any paint (or 3D modelling) program to edit
the pcx files.
You can obtain this file from:
http://www.geocities.com/SiliconValley/8682

Naturally enough, you need C&C :)


I'll go through this process by using an example. This is a little unit
that I thought up called the Mutant.

Background of the mutant: The effects of Tiberium upon humans was usually
fatal, but there were a few cases where the person exposed to tiberium
didn't die but instead underwent strange biological changes. Just like
trees were genetically twisted into becoming blossom trees, so some humans
were mutated. Making the Hulk look like a wimp, their mutation resulted in
incredible strength and endurance. Strangely, this mutation did not provide
protection from the effects of tiberium poisoning.

Note: this unit isn't meant to become a unit that you buy, it is meant to
introduce a little element of surprise into games on maps where there are
civilian units running around. This unit behaves like civilian units, in
that after it has taken a little bit of damage, it begins to run around a
lot. A pair of mutants can easily take out a gun turret, but they will run
around a lot doing so. Being as tough as they are, they just keep on coming
back for more punishment.

Ok, the first thing to do is to start CCEdit. Go to the Infantry screen
and scroll down the list of infantry units until the civilian infantry unit
C2 is selected. You can do this with any unit really, but I chose C2 for a
number of reasons:
1. C1 and C7 are the technician units that you get when you sell silos.
2. the colouring of the C2 character is a rough estimation of the final
   colours I'd like to use.

Now, bring up the tab and cause all patch variables to be false (as you
only want a few variables to be changed). Swap sides so that the values list
is current. You want to make the following changes to this unit:
As you make these changes, remember to press the Space bar so that the value
will be stored in the patch file.

* 'Speed' is changed to 12
This makes the mutant the fastest infantry unit around, although it is
still slower than nearly all the vehicles.

* 'Primary weapon' is changed to Dinosaur Bite 1 (chew)
This weapon is used because, while it does excellent damage against
lightly armoured targets, heavily armoured units (tanks etc) don't take
nearly as much damage. Using Dinosaur Bite 2 (gore) is too inbalancing, as
this chews through anything.

* 'visual radius' is set to 2

* change the 'Can be built by' so that the Multi-teams cannot build the unit
(just in case someone is using the funpark option: you play with M4 there).

* 'Hit points' is changed to 127
The mutant is a tough nut to crack.

* 'Shots before reload' is changed to Unlimited

* 'Unit can aim' is set to Yes
Please note: I'm not 100% sure that this title is correct - ie this
variable may not be needed to have the unit aim (in fact, I'm pretty sure
that it isn't). I worked this value out a while ago and my notes from then
are pretty pathetic - the unit seems to work fine if this is kept at No.

The changes have been made. As you look along your patch list, you should
see that there are 7 green circles (or 6 if you didn't set the 'unit can aim'
variable). Go to the main screen, bring up the command tab, and select
'Make a patch'. Name the patch file something like 'mutant', or something
obvious. You have now created a patch file containing the mutant unit. You
can give this patch file to people and have then use CClite (or CCEdit)
to use this, and the only values it will change are the 7 ones you altered
above. If you want, you can save the values to your game.dat file, or not
- you can just use CClite to instaall the patch when you wannt to use it.

Now, it is good form to also supply a patch that will get rid of this
alteration. If you haven't saved the changes, then all you need to do is
hit 'Undo ALL', which will revert the values you changed back to what they
were before. Then just create another patch, calling this one 'unmutant'
or something. The undo command will not work if you have saved the
information to file - in this case, you have to go back and change the
values by hand. Using the undo command will leave the patch variables
unchanged, but will revert those values that have been altered since the
last save (or the start of the program), which makes it perfect for
creating a patch file that undoes the changes.

Now someone can use your mutant patch, then de-install it with ease. These
patches are fully portable between versions of C&C, so there is no problem
with creating it on (say) a version 1.20 of C&C and having it used by a
version 1.07 person.

Nothing to it :)


Now we move on to the advanced stage - changing the graphics.
An important note must be added here: if you are altering the graphics
for a unit and basing your work on the art that comes with C&C (ie simply
recolouring a unit), you should NOT distribute this art. The artwork in
C&C is copyright to Westwood, and it is not a good idea to post their
artwork around the place - they are likely to get annoyed.
However, if you do the graphics from the ground up, there are no problems
with distributing the artwork, as you own it.

Ok, first thing you want to do is extract the graphics for the unit
(in this case the C2 civilian). Get Mix Manager out and open the conquer.mix
file with it. The C2 unit is at Index 46 (or Position 186), but Vladan has
identified it "UNIT: Civilian #2". Extract it. Accept the offered filename.
It should be "C2.SHP".

Now you want to open the file 'temperat.mix' and extract the palette from it.
It is at Index 62 (or Position 42). Accept the default file name. This should
be "temperat.pal". Quit Mix Manager.

Some editing notes:
-WINTER.PAL and TEMPERATE.PAL are  exactly the same.
-Make sure your colors are the samme in all theaters. I've sseen some graphics
that screwed up pretty hard in Desert because the maker edited them with the
Temperate palette. To prevent this from happening, make a palette where all
differences between Desert and Temperate are replaced by some ugly never-used
color. To avoid mixing up the black color and the background, change that
color too. I suggest using bright purple as background.

Now, you want the program shp2pcx (comes with the distribution). First,
you might want to get some information about the images contained within
the c2.shp file. Type:
shp2pcx -i c2.shp
You should see this on your screen:
SHP2PCX   SHP to PCX converter V1.01  Copyright (C)1996 Vladan Bato

SHP Info :
 -Number of frames : 375
 -Frame Width      : 50
 -Frame Height     : 39
 -Unknown Field 1  : 0066h
 -Unknown Field 2  : 0073h
 -Unknown Field 3  : 000000A7h

From this, you can see that each picture in this file is 50 pixels in
width and 39 in height, and that there are 375 in total.
Now, you want to convert this to a pcx file. Do the following command
(for example):
shp2pcx c2.shp
This will create the file 'c2.pcx' which will contain all the graphics
from this .shp file.
If you want to get a single column of frames, use the command:
shp2pcx -c:1 c2.shp
This can be useful in some cases (ie having all the graphics in a single
column rather than as multiple frames per row).
If you used the command: shp2pcx c2.shp, you should see the information:
SHP2PCX   SHP to PCX converter V1.01  Copyright (C)1996 Vladan Bato

Loading palette : TEMPERAT.PAL
SHP Info :
 -Number of frames : 375
 -Frame Width      : 50
 -Frame Height     : 39
 -Unknown Field 1  : 0066h
 -Unknown Field 2  : 0073h
 -Unknown Field 3  : 000000A7h
PCX Info :
 -Columns : 12
 -Rows    : 32
 -Width   : 600
 -Height  : 1248
You should take a note of all this (write it down), as you will need it
to convert the pcx files back to .shp format.

Now, go away and do whatever you plan to do to the c2.pcx file that you
just created.

To convert your edited PCX-file back to the .shp format, use the command:
pcx2shp -n:375 -w:50 -h:39 -c:12 -u1:0066h -u2:0073h -u3:000000a7h c2.pcx
(I don't think the Unknown Fields are important. I 've never had any
 problems leaving them blank when making shp-files)

This will convert the file c2.pcx to the file c2.shp.

Note: You can also use MSHP2PCX.EXE and MPCX2SHP.EXE. Although you'll end up
with a few hundred images, it's a lot easier to convert back to .shp format.
No Width and Height junk, just give the number of frames and it works.


Now, you need to replace this new file in C&C. The easiest way to do this
is to make a new mix-file that starts with the letters "SC". All the rest
of the name you can make up yourself, so for the mutant, we can call it
SCMUTANT.MIX. The filenames SC-000.MIX and SC-001.MIX are used by the
Covert Operations, so you 'd better not use them.

Put this mix-file in your C&C directory.
Rename your shp file to whatever unit you want to replace, here c2.shp.
Now, put your c2.shp in this new mix-file, and the next time you play C&C
and come across a C2 civilian unit, your new graphics will be shown.

Cool eh? :)

Now, say that you have done all that, created the patch files and created
some all new graphics, and want to distribute them so that other people
can use them. What you should do is the following:

Create 2 batch files - one to install your new beasty, and one to uninstall
it. You could also make a menu and use only one batch file, but that's too
complicated to explain here. I'll give an example using the mutant.

Say I have 3 files: mutant.pat, unmutant.pat and mutant.mix
I would create a zip file containing the following files:
mutant.pat, unmutant.pat, mutant.mix, mutant.bat, unmutant.bat,
cclite.exe, cclite.txt, ccnames.exe, ccnames.txt, mmlite.exe, and mmlite.txt.
On my experiment, this resulted in a zip file of just over 60K in size.

CCNAMES and MMLITE are only necessary if you want to change the unit's name.

The mix-file mutant.mix should contain your new c2.shp. The internal file
MUST HAVE the name (name ID) of the unit it replaces!!! Otherwise C&C
won't accept it. If the unit can be built, you can also include an icon
in the mix-file. This icon will be accepted by C&C when it has the right
name format: "[unit]ICON.SHP", here c2icon.shp. Of course, you can't build
this one, so we don't include an icon.

Note: for structures, the same thing can be done for a build-up animation.
The name format for a build-up anim is "[unit]MAKE.SHP" This also works for
buildings without an original build-up animation like the civilian buildings.
All buildings except for the Hospital can be sold when they have a build-up
anim. The minimum number of images for a build-up animation is 20, any less
makes C&C crash :(

You can also use ccnames.exe to change the name.

You can get as esoteric as you like, but your batch files would look
something like:

mutant.bat:
@echo off
echo Installing Mutant, please wait...
copy mutant.mix SCMUTANT.MIX >nul
cclite -silent -u mutant.pat
if not exist conquer.eng mmlite local.mix -e conquer.eng >nul
ccnames conquer.eng -r:219 "mutant" >nul
echo Done

This will copy your mix-file to the "SC"-name format that C&C recognises,
then call cclite to change the GAME.DAT values, and then change the name
in CONQUER.ENG.
CONQUER.ENG doesn't need to be put back into LOCAL.MIX to replace the names:
it acts in the same way as MISSION.INI, but for names instead of briefings.
The "if not exist" command allows the user to keep a changed CONQUER.ENG in
his C&C directory.
The number behind the "-r:" (here 219) is the location in CONQUER.ENG where
the unit's name is located. To see which number you have to use, extract
CONQUER.ENG from LOCAL.MIX, start ccnames.exe and look it up in the list.
Easy, right?
By putting ">nul" behind a line, you make sure the program you run on that
line doesn't print anything on the screen. CCLite doesn't need that, because
the "-silent" parameter has the same effect.

unmutant.bat:
@echo off
echo Uninstalling Mutant, please wait...
if exist SCMUTANT.MIX del SCMUTANT.MIX >nul
cclite -silent -u unmutant.pat
if exist conquer.eng ccnames conquer.eng -r:219 "Bill" >nul
echo Done

This wil delete the copied mix-file with the new C2 graphics in it, and
call cclite to change the values with the patch that you created to undo
the mutant changes. Then, it restores the civilian's original name
(Yes, they have names). As some people already have a changed CONQUER.ENG
in their C&C dir, I wouldn't delete this file.

Note that the name change has no effect on civilians, as they are always
called "civilian". I just put it in to make the example more complete.
The names of some special civilians can be changed, as they are shown to
the enemy. These civilians are Nikoomba (C10), DELPHI and MOEBIUS.
But to keep the normal missions playable, I wouldn't change any of these.
Just imagine fighting a monster-Nikoomba in the first Nod-mission :(


That's it. You now have all the information you need to go out and create
new units for C&C. Just read the documentation that comes with Mix Manager
and CCEdit, and do it thoroughly. I have absolutely no artistic ability, so
can't produce any new artwork myself, but hope that this will give some of
the C&C fans out there who do have artistic talent an incentive (and the
knowledge) about how to go about doing this.

Some information that may be useful about which theatres the various
civilian buildings appear in:
  There are 3 theatres, desert, winter and temperate, which tell C&C
  which graphics set to use. Those units and structures that appear in
  all theatres are stored in the conquer.mix file. Those that are
  specific to a particular theatre are stored in the appropriate .mix
  file (desert.mix, winter.mix and temperat.mix).

  The civilian building ARCO (the Oil Tanker) appears in all theaters.

  The civilian building V19 (the Oil Pump) appears in all theatres.

  The civilian buildings V01 to V18 appear in both the winter and temperate
  theatres. Please note, the graphics of these structures do change
  depending on whether you are in the winter or temperate theatres.
  For Temperate theater, the extension of the shp-files is ".tem"
  for Winter this is ".win"

  The civilian buildings V20 to V37 appear only in the desert theatre.
  (btw, V37 is supposed to be the Westwood Studios building)
  For Desert theater, the extension of the shp-files is ".des".

  Theater-specific buildings need to be replaced in a special way: you
  need two shp-files. One with the .shp extension, the other one with the
  extension of the theater you want it to show up in (.tem / .win / .des).
  If you want it to act like a normal building that's visible in all three
  theaters, you need all three of them.
  Note that the actual graphics are read from the .tem, .win and .des files,
  NOT from the .shp file. It doesn't matter if the .shp file is different
  from the theater-specific files. It just has to be there, that's all.


Andrew
(author of CCEdit)


Completed and corrected by
Nyerguds (http://cnc2sw.planetcnc.gamespy.com)