Keen Galaxy Modding Tutorial (by Levellass)

From KeenWiki
Jump to navigation Jump to search

This page has full instructions for setting up and modifying Commander Keen Galaxy (4-6) There are three broad sections, the first deals with setting up an unaltered copy of a Keen Galaxy game for modding, the second deals with a pre-prepared suite of files already set up and available for download and the third lists some things to keep in mind before releasing a mod.

This page should allow a new modder to use and understand all the basic concepts related to Keen Galaxy modification and allow them to create their own mods.

Setting up

1.) The unaltered game directory.

For this demonstration an unaltered copy of Keen 4 v1.4 will be used. (Picture 1) It contains nine files, only five of which are of use to us. We will therefore delete CATALOG.EXE, LICENSE.DOC, ORDER.FRM, and README.DOC (Picture 2)

2.) Delete 'extra' files.


3.) After decompression.

The next step is to decompress the executable. Keen Galaxy executables are LZW compressed and can be decompressed with UNLZEXE Here the 16 bit version is used, but those on newer systems (Windows 7, Linux) should use the 32 bit version. The usage of the program is described on its' page, basically it's drag-and-drop. The executable is decompressed and the compressed executable is turned into a .OLZ file. (Picture 3) We can now delete the .OLZ file and UNZEXE


4.) Before setup.
5.) After setup.

The next step is to set the game up for level editing, which will also give us the basis for several other steps. Here we're using the original Keen Galaxy editor, TED5, though other level editors are available. First we copy CK4Patch, TED5 and TEDSETUP to the folder (Picture 4) and run TEDSETUP. This results in the creation of several files. (Picture 5) We can now delete TEDSETUP.

CKPatch is a utility that patches Keen, to work it needs a batch file and a patch file. The batch file (GO4.BAT here) tells CKPatch what patch file to run. To play the mod you simply run the batch file. The batch file created simply contains the text

@echo off
if not exist fixmhead.exe goto just_run_it
fixmhead ck4mhead.obj maphead.ck4
on errorlevel 1 goto error
copy gamemaps.ck4 custmaps.ck4
ck4patch patch4.pat -nowait

Most of this is garbage and unnecessary. We'll cut this down to:

ck4patch patch4.pat -nowait

We could rename the patch file if we wanted, but for simplicity here we won't. Next we turn our attention to the patch file. This is a plain text file, just like the batch file, so we can open it with notepad (Or as said before, rename it to a text file, both the file and in the batch file.) It contains the text:

# Patch file for Keen - use with CK4PATCH.EXE
%ext ck4
%gamemaps custmaps.ck4
%maphead maphead.ck4
6.) Instantcarma.

The %gamemaps line is complicating, so we can delete it. We are now set up to edit levels. To edit levels, simply run TED5. TED5 is a DOS application and so will need Dosbox to run. (Details on how to use TED5 can be found on its page.) Once levels have been edited and carmackized, the game can be run with the batch file.

However many chose to use the utility Instant Carma with TED5, which changes the 'temporary' maps (MAPTHEAD, MAPTEMP) into proper game files much more quickly. We will use this in our example, copying the file instantcarma.exe to our folder. It is run by simply clicking the file, which will automatically convert any levels it finds. (Picture 4) Notice the creation of maphead.ck4, the file referenced in the patch file. Notice also the GAMEMAPS.CK4 file is a different size (much larger) These are now modified game maps that you can play.

Instantcarma must be run every time you edit the maps with TED5, otherwise you will get a 'map too tall!' error when trying to load a level.

Due to some of the limitations of TED5 (mostly people's problems in running it with some versions and setups of Dosbox) an alternative level editor Keen: Next is available which does not need instantcarma. Maps created with it are incompatible with TED5.


It should be apparent that the file PATCH4.PAT is the patch file in which all are placed. These change a number of things in the game, from enemy behavior to Keen himself. You should familiarize yourself with making additions to the patch file, a lot of modding is based upon it. (For example, you cannot play your custom levels without the level map head patch.)


7.) Before extraction.

Now that level editing and patching are set up, we move on to editing graphics. There are two main things this involves, editing the actual graphics and editing tile properties. We copy the required files to the mod directory, to edit tile properties, CK456DTli, for graphics, some version of ModKeen (lmodkeen will be used here, see picture 7.)

Notice we create the directory 'GRAPHICS'; this is for our game graphics to be extracted to. You don't have to have a separate directory for them, but as there are about 500 separate files, it keeps things much cleaner this way. Graphics are extracted by lmodkeen with:

lmodkeen.exe -episode=4 -export -bmpdir="GRAPHICS"
8.) Graphics folder.

It should be pretty self-explanatory as to what each bit means, we are extracting Keen 4 graphics to the sub-directory GRAPHICS. If you look in the directory (Picture 8) you should now see a number of bitmap and other files. These are the game graphics, and, within a few limitations, you can edit them as you wish.

To import the graphics we use the 'reverse' of our export command;

lmodkeen.exe -episode=4 -import -bmpdir="GRAPHICS"

Now a number of changes have occurred; KEEN4.PAT has been created, this contains a patch for the new graphics:

%ext ck4
%version 1.4
# Load the modified graphics
%egahead EGAHEAD.CK4

Do not use this file as a patch file! It is overwritten every time new graphics are imported and will thus totally blank anything placed in it. Instead we copy the %egahead patch into our previous patch file giving us:

%ext ck4
%maphead maphead.ck4
%egahead EGAHEAD.CK4

You should now be able to play the game with both modified levels and graphics. The next step is editing tile properties. This is important because you will likely spend a lot of effort in making new tiles and will like to be able to customize their properties and animation. CK456Dtli comes with its own instructions and help and should have some information on its page. To run it you will need to specify two tile bitmaps and a tile information file. (The tile file should have been copied along with CK456Dtli.)

Be careful when saving, many a modder has accidentally saved their files in the wrong directory. The program remembers the last place it has accessed, be it your graphics directory or another mod project. In our example we have to be careful not to save to the GRAPHICS subdirectory. We also need to patch the new tileinfo by adding this line to our patchfile:

%patchfile $249C2 "Keen4.tli"

Music and sounds

We now have most of a mod's basic structures in place. Levels, patches and graphics should be fully functional. The next step is music and sounds. However there are only two utilites that can modify the Keen sounds and music, WDC and KeenWave, the first is not a dedicated Keen program and can be troublesome to use, the second is currently a beta. Thus, for the moment no instructions for setting up music editing will be given here.

Cleaning up

Now that the mod has been set up, some housekeeping may be in order. A number of files will be regularly produced that are not needed and it can be tiring to have to constantly type commands in for various programs. Thus savvy modders may wish to use batch files that automatically import and clean up any unwanted debris. This is how the pre-prepared files used in the second section of this page work.

Pre-prepared files

TODO: Make a bundle of files for this section and complete a brief description of them.

Releasing a mod

Additional cleanup should be done before a mod is released. Mostly this involves cleaning up unneeded files. To do this, first copy your mod directory somewhere temporary, so you don't wreck it if you want to fiddle with things later. (Very likely, bugs often occur that you will miss.) The graphics directory should be deleted, along with any other directories you're keeping stuff in, unless you want player to see them. (Concept art say.) The MAPTEMP and MAPTGEAD files should be removed, as well as all the utilities used when modding. Finally, you should delete the keen executable, it is illegal to distribute it, and though it is not strictly enforced, it is good practice to ensure you are not breaking copyright law.

This should leave you with just the necessary files to play your mod, plus any 'etras' players might enjoy. (Notably the Keen 6 mod Dead in the Desert had a help file included as the Keen 6 game did NOT have one.)

Files are often zipped and hosted on a Keen site or file sharing service available for download.

See Also

External links