Keen:Next Tutorial

Utilities for editing Keen:Galaxy and Keen:Dreams levels.
Post Reply
User avatar
Ceilick
Deputy Administrator
Posts: 401
Joined: Wed Sep 03, 2003 2:35 am

Keen:Next Tutorial

Post by Ceilick »

In an effort to promote Keen Galaxy modding and levelpacks, I'm writing this tutorial for Keen:Next, z-one's fantastic level editor, which I consider to be the best and most useful of our three existing Keen Galaxy level editors (the other two being Ted5 and The Photachyon Transceiver).

I've tried to keep things as simple as possible in writing this so that even someone who knows nothing about keen editing can understand what to do. Hope this catches the interest of a few people who are either interested or currently using the other editors. Let me know about any problems that occur, anything in this tutorial that's unclear, or anything that was missed :)

So let's get started!

First, you'll need to download several things:

The Keen Next Editor:
http://hely.fw.hu/editor/knedit099.zip

Keen 4 version 1.4 (courtesy of ckguy and the bipship):
http://www.tl-dr.org/downloads/keen/off ... n4-1.4.zip

Tilesets (courtesy of me):
http://files.commanderkeen.org/users/ce ... tTiles.zip
(Note: included here are the tiles for Keens 4-6 as well as TkoK and DitD)

Once downloaded, organize your files how you like, I keep mine with a base 'Keen Next' folder which contains all the keen:next items as well as a 'keen4-1.4' folder and a 'tiles' folder.

First important thing to do is prepare your copy of keen 4 for editing. Inside the base Keen:next folder you'll find another folder titled 'patch'. Inside this folder you'll want to gather unlzexe, patch4, go4.bat, and ck4patch. Copy all these files into your Keen4-1.4 folder. Next, place your keen4.exe icon onto the unlzexe icon. This should make the execute compatible with ck patch.

Now that that's done, run the kmaps application in the base keen next folder. Whenever I do this, I always get an error “access violation at address blah blah blah”. I have no idea what this means, but ignoring it hasn't ever given me any trouble, so if it pops up, just hit ok :)

When the editor opens, the first thing to do is go up to 'file' then 'new'. A 'project properties' window will appear. Give your project a title (it doesn't matter what you name it) and then check the “keen project” box. We'll be using Keen4, which is the default setting. If you're planning to edit keen 5 or 6, just make sure to select those in the box next to “keen project”. Next we need to choose the tileset. In the image file section, go to 'browse' and select the tileset you want to use (in this case, tiles4.png). After all this, click 'ok'.

The tiles should load on the right side of editor menu. You can adjust the tile menu width with the mouse by selecting the left edge.

Before we can import the gamemaps, we have to extract them in a way that Keen:next can read them. Go to 'file', then 'create keen files'. Browse to your Keen4-1.4 folder and select the execute. Note: this will only work if you used unlzexe on the keen4e.exe. Your keen map files should now be created. Note: You only after to do this 1 time for each episode, unless you use a different copy of Keen#e.exe.

Now it's time to load a map! Go to 'file', then 'Import Keen Map”. In your Keen4-1.4 folder, select 'maphead.ck4'. You should now be presented with a 'map select' box. Choose the level you'd like to edit. Let's start with the shadowlands.

The shadowlands map should now be loaded in the main editing area. Note: In keen galaxy, there are two tilesets and thus two types of tiles: background and foreground. You can toggle between which ones you view by going to 'view' and checking/unchecking layer 1 and layer 2. I usually find it's best to leave both layers visible, however. Do make sure that, in the view section, you have 'fade unused layers' unchecked. This makes level viewing easier.

You can change tiles on the map by selecting one from the tilesheet on the right with the mouse. If you notice in the upper left, the default tile tool is the pencil/paintbrush. You can click and place, or you can click and drag with this tool. There is also a waterdropper tool. This is useful for selecting a tile currently on the map to use. Note: the waterdropper will 'pick up' the tile from the tileset you're currently in; if you currently have a background tile select and use the waterdropper, it will pick up the background tile on the map. If you want a foreground tile, scroll down in the tileset on the right and select one of the foreground tiles, then use the waterdropper on the map.

Keen: Next has a handy function that allows you to make 'stamps' of a large area of tiles. To do this, click the top left corner of the area of tiles you want in the tileset. Then go to the bottom right corner of that area, while holding shift, and select that tile. Doing this successfully will result in the stamp image appearing on the left side of the editor. You can now use the paintbrush tool to place this stamp, and you can reselect this stamp at any time you're editing.

Note: In keen 4-6, special 'invisible' tiles are used in the foreground tilset on the world map. These can be kind of hard to figure out (since they're invisible!) so I either suggest: using the waterdropper tool to figure out what's what, editing the tiles4.png with some basic lines to show whats what (once you figure them out of course), or simply experimenting.

On the world map, you'll notice little white icons that look like this: (!). These are the level sprites. To place these, use the little cog tool up in the upper left. When this tool is used to click the map, you'll get an 'info plane' box asking for an x and y coordinate.

On the world map, this is how the coordinates work:
The x coordinate determines what kind of sprite is used. An X of 192 designates the sprite as a level entrance. Note: you cannot place a level entrance on a tile that appears over keen or on an animating tile.

An x of 208 is a level block (like those used in the slug village); this sprite does not actually block keen, but is placed over a foreground tile that does. When the level is beaten, the foreground tile is removed.

An x value of 240 is for the flag holders.

Y coordinates only designate what level the sprite is associated with.

Go ahead and make a few tile changes. When you're ready to save, go to 'file', then 'export keen map', then select 'maphead.ck4', click yes, and reselect the shadowlands and click ok. Note: if you like, You can rename the shadowlands here before you click ok. The name you choose will only appear in the editor, however, and not in the in-game text.

Now that we know how to edit the world map, lets try a level. God to “import keen map” again, and then select “The perilous Pit” (this is a good level to teach some basic).

We'll start by sprite placement. Up in the upper left corner, theres a little icon that looks like an arachnut. Click this and the sprite menu should appear in place of the tileset. To place a sprite, make sure you have the paintbrush icon selected, then click the sprite you want to place. Note: some enemies appear more than once in this sprite menu; this is for enemies that appear on easy, moderate, and hard. You can see little numbers that designate this, but a general rule is that they order they appear in on the menu matches the easy/medium/harder order.

To switch back to tiles from sprites, click the little icon to the right of the arachnut icon you used to get to the sprite menu.

Now lets learn how to place a keygem holder. First place the foreground keygem tile somewhere on the map (it can be anywhere). Next place a door (these are also foreground tiles) somewhere (anywhere). Now comes the harder part. Using your mouse, hold it over the highest tile of the door. In the lower left side of the editor, you'll notice that the map coordinates for this tile appear. Memorize or write these down. Now, remember the cog tool form the world map? Select that and then click your keygem holder. Enter in the coordinates for you door. You've now got a work door (don't forget to provide a gem for it via the sprite menu!)

Doors that keen walks through are a bit harder. To begin, place two door tiles on the map (try using the stamp method here, clicking the top left of the door, holding shift, and clicking the bottom right). Place your two doors on the map. Now we've got to determine the coordinates again. Go to one of your doors and hold the mouse over the tile below the bottom left door tile. For example, the perilous pit door location by the mad mushroom as a coordinate of 7, 24. We also need the coord next to it. This is 8, 24.

Now that we have these written down, let's go to the door we want to connect to this spot. For the sake of changing things, we'll connect the house in the upper right of the level to this door. As you can see, the door sprites are placed on the door itself. Let's edit where this door takes us by using the cog tool and click the sprite on the left. It'll come up with the current sprite info. Lets change the first one to an x of 7 and a y of 24. We'll do the same to the sprite on the right, giving it an x of 8 and a y of 24. Now this door is connected to the other, but we need to make sure the same is vice versa. Check the coordinates using the same method as before of the tiles below this door.

Did you get 49, 14 and 50, 14? Good! Now scroll over to that door on the fart left and change the sprites using the same method as before. You've now made a new door system in the level!

Now lets take a look at that switch next to the the Madmushroom in the lower left. For a fast way to learn where this sprite connects to without using the cog tool, hold you mouse over this sprite. See where it gives you the normal tile location (8, 52 for this one), glance to the right of this and you'll notice that there is also a 22, 39. This is the location this sprite connections to. If you go to coord 22, 39, you'll see that a sprites sits there. This type of sprite is a block for elevator sprites (both of which are placeable in the sprites menu). You can create your own switches following the same guidelines as this.

When your done editing the level, go to 'file', then 'export keen map', and select 'maphead.ck4'. Choose to replace the perilous pit and you're all set!

Ready to play the levels you've edited? Go to your 'keen4-1.4' folder and select go4.bat (you may need dosbox for this to work correctly. And you're all set! Enjoy your levels and I hope we see some Keen 4-6 levelpacks in the future!

Final Notes: Keen:Next is NOT compatible with Ted5; you cannot edit some levels in ted5 and then switch to keen:next. I do not know if The Photachyon Transceiver is compatible, but I suspect not.

There are more tools and functions that Keen:next can perform. There are cut and paste tools, a painbucket tool, and a level resizing tool to name a few. If anyone needs help with these, I'd be glad to lend a hand, but what is included above should be more than enough to get started :)

levellass
Posts: 2997
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Very nice. I have some short notes on Keen maps to add:


Keen 4-6 limits and issues:


DOORS:

A door is composed of three parts, a 'top' at least one tile high, a 'middle' and a 'bottom', both 1 tile high. To make a door taller than 3 tiles, you must use more than 1 top tile. Tiles are arranged in columns (Doors can only be one tile wide.)

The 'top' and 'bottom' tiles of a door may be the same tile.

Keyholders point to the TOP of a door.

If a door isn't set up properly, either some parts of the door won't animate (You have placed top, middle and bottom tiles incorrectly on a door taller than 3 tiles.) or tiles that shouldn't animate will. (You have NOT placed a bottom or middle tile in your door so Keen is using ground as the door's bottom.)

If you get a lot of gibberish when the door opens ('Static tiles') then the problem is Tileinfo related; all door tiles must animate to another tile, and door animations must be 4 tiles in length. (3 x 4 or 12 tiles per complete door.), otherwise Keen will get confused.

Door tiles must animate to the NEXT tile in the tileset, not the previous one, or two tiles ahead, the NEXT. Failure to do so will make the door go gibberish. (This means doors cannot animate in a loop, unless that loop is larger than 4 tiles and a switch is used to 'reset' the door.)

IF a one of a door's LAST animation frames is given BOTH an animation time AND a time to animate, the it will disappear after it opens. This can be useful for deleting a door.


LEVELS:

If a sprite tries to use an image not in its cache (Picture store), you will get the error 'Tried to place a uncached sprite' followed by the image number. This will occur ONLY when the offending sprite acts, so you can test to see what sprite is causing the problem.

If there are too many sprites in a level you will get the error 'No space left in objarray'; the game has run out of memory to store sprites. This usually occurs at level start, but may occur if you have something making new sprites in-level that reaches the limit. To fix this, remove sprites from your level. Be careful of using item sprites when item tiles will do.

If you have too many different types of tiles (Back AND fore) then you will get the error 'No space left in tilearray'; this means that the game does not have enough memory to store all your different tile types. Foreground tiles use 8x the memory of background tiles. You shouldn't have more than about 400 tile types total (Back and fore) in a level, usually 100 back and 300 fore.

You cannot have more than 20 actively animating tiles on-screen at any one time, this includes item tiles. This will cause an anim tile error. (Not enough memory to animate all these tiles.)

The size of a level in TED is only a guideline, as is the tile and icon counts. ALL tiles in an animation are loaded into a level, and sprites take up more memory the larger and better animated they are. The only generality is smaller levels are smaller in size. Using the F10 + M cheat will tell you how much memory is free in your level at a certain time. Sadly, this varies by about 10K depending on what has happened BEFORE the level loads, and can vary by another 10K IN the level. Sprites take up much more memory than tiles.


MUSIC:

No music file can be longer than 63.9Kb (NOT 64!) Any file larger than this will cause an error when played (Doesn't support 64K reads yet!)

If a level is 'too large' for its music file, the error 'Not enough memory to play background music!' will occur. This is an indication of either large levels or large music files. Remember, the default music is seldom over 10Kb in size. To reduce this error, either make your level smaller (See LEVELS) or change the music to a smaller file.


TILE ANIMATIONS:

This is related to Tileinfo, not TED. Back up your tileinfo regularly to avoid bugs. To test for a problem, blank a level then copy-paste segments of tiles into the level (100 at a time until you encounter the bug is useful.) When you find the segment causing trouble, halve the segment and test again (first 50 tiles, no. Second fifty, yes. First 25 of that, no...) Doing this will locate an error in usually less than 20 checks.

There are two types of animation, timed and untimed. Timed animations MUST form a loop (1->2->3->...->1) and will repeat over and over in a level. They are reset when games are saved and often used for animations. Untimed are used for doors, bridges, switches, etc. Door and keyholder animations need not form a loop, but others must (Unless you want to do something fancy, like open THEN close doors). They animate ONE frame when Keen does something (Flicks a switch, places a gem, etc)

If you see gibberish instead of an animation, then you have placed an animating background over an animating foreground. For memory reasons this is not allowed.

You cannot make two tiles animate to the SAME tile. This is true of timed AND untimed animations. Two things may happen, if the tile is NOT part of a loop, the level will freeze after a short time, if it IS this causes an 'unending animation loop' error, followed by the number of the tile that animated to cause this.

If you have an animation loop with a tile in it with no animation time, it will be 'cut out' of the loop (In a 4 tile loop you will see only 3 tiles.)

You cannot make a bridge, door or similar animate into a tile with an animation time, this will cause the tile to go gibberish-y

A tile given an animation time but no tile to animate to will aniamte to itself. You will notice nothing, but it will eat up a lot of memory.

User avatar
Tulip
Posts: 394
Joined: Mon Jun 16, 2008 2:40 pm
Location: Heidelberg, Germany
Contact:

Post by Tulip »

This comes right in time. Copied and saved, if I'm lucky I'm gonna make a Keen Galaxy level today, just for practice.

levellass
Posts: 2997
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

I wonder if a 4-6 levelpack could be mooted? TED lets us copy and paste levels from other GAMEMAPS files...

Mink
Posts: 192
Joined: Sat Nov 03, 2007 4:08 pm
Location: Providence, RI, US

Post by Mink »

Excellent tutorial, Ceilick. And to think I've been using The Photachyon Transceiver all this time because I could never get this to work (the two aren't compatible, by the way). I'll have to use this once I'm done with my current level pack. I especially like the stamp function.
levellass wrote:I wonder if a 4-6 levelpack could be mooted? TED lets us copy and paste levels from other GAMEMAPS files...
Wow, I never realized that. We really should do a 4-6 community level pack some time.

User avatar
darthslaw
Posts: 4
Joined: Wed Feb 25, 2009 5:07 pm
Location: Maryland

Post by darthslaw »

Final Notes: Keen:Next is NOT compatible with Ted5; you cannot edit some levels in ted5 and then switch to keen:next.
Actually, you can open TED5 maps in Keen:Next. Here's what you need to do (for Keen4):

1) In TED5, save and carmacize your maps (do not use InstantCarma).

2) Now that your 'gamemaps.ck4' file is carmacized, make a copy and name it 'editmaps.ck4'. Keen:Next will be unable to find the maps without this step.

3) Finally, you need to fix 'maphead.ck4'. To do this, run this on the command prompt (or put it in a .bat file and run):

Code: Select all

fixmhead.exe ck4mhead.obj maphead.ck4
Make sure you run this in the TED5 directory, where 'fixmhead.exe' and 'ck4mhead.obj' are located.

DONE -- Your 'maphead.ck4' and 'editmaps.ck4' files are now ready for use in Keen:Next.


At this time, I haven't figured out how (or even if) you can go from Keen:Next to TED5.

I also don't know why I can't make IC's "carmacized" output work in K:N (get the "Bad EDITMAPS format" error), when they work fine in the keen games... I guess carmacizing in TED isn't a terrible price to pay, though, since you only need to do it once per project conversion.


In any case, your tutorial is excellent, Ceilick. Great job.

Also a big thanks to levellass, for your "limits and issues" list -- When I run into problems, I'll be sure to run through that list for troubleshooting.


-------------------------------

General Stuff:

I know I'm kinda just popping out of nowhere, so, hello Keen Modding :-)

I've been lurking around here since late winter/early spring, tinkering with the Keen:Galaxy modding tools. I haven't really done any work worth distributing yet, but hopefully I'll have something to show off in the future. I've enjoyed the experience so far, messing around from time to time with both basic and advanced modding techniques. I doubt this is a hobby from which I will retire any time soon (yay for modding old games ;-) )

So again, hello, and thanks for reading.

levellass
Posts: 2997
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

It should thus be possible to make a BAT file to automatically rename the gamemaps file and fix the maphead. Come to think of it, a few modifications to Keen:Next would allow that.

User avatar
Grimson
Posts: 63
Joined: Mon Mar 22, 2010 3:45 pm

Post by Grimson »

Sorry to bump this old topic, but how can I create those hidden passages behind the foreground tiles? I can't seem to figure this out, I tried to look at the official Keen maps but I noticed no difference between normal, unaccessable areas and these hidden areas.

Oh, and a second question. What does the Layer 3 do? I notice no difference in levels if I turn the Layer 3 visibility on and off from View.

levellass
Posts: 2997
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Hey ho hup la!

Layer 3 is the sprite layer, it *should* show Keen, enemies, door and switch pointers and such.


Secret passages DO use other tiles, but in the default art they're identical looking to normal tiles. Thus whenever I do maps, I make sure I invert the colors of my secret passage tiles so I can still tell what they are, but also see *where* they are (Before release I re-invert them.) I suggest you do this, or you will have a terrible time figuring out which tiles are which.

User avatar
Grimson
Posts: 63
Joined: Mon Mar 22, 2010 3:45 pm

Post by Grimson »

Thanks for the info, though I figured the secret passage tile thing already when I looked at some of Keen 8's levels (tiles covering the secret passages were marked by purple lines) after posting ;)

Nospike
Posts: 158
Joined: Fri Apr 23, 2010 1:54 pm
Location: Some cool place, idk

Post by Nospike »

This is an awesome tutorial. I always keep my browser opened on this page when making levels.
This *really* needs to be stickied.

Post Reply