View Single Post
Posts: 108 | Thanked: 329 times | Joined on Apr 2010 @ Bosnia and Herzegovina
#93
Allrighty then... Making a Defense Gear level involves three steps: making the tile-map (terrain), making the flow-map (substitute for actual pathfinding) and writing meta info and waves.

STEP 1 - Using Smled

Open it up (duuh). This isn't really a "Defense Gear editor", I started it years ago to be my universal go-to 2D map editor, so it has many (for a project of this type) features for editing maps, even creating/editing tilesets, brushes, entities, etc. But we won't be using most of these. It's set up now to automaticaly load the Defense Gear tileset. Don't try editing it or adding new tiles, this won't transfer to the game.

Before you begin, resize the map to 64x64 (upper edge, toolbar). By default, roll mouse wheel to select tile (right edge of the window), left click to "paint" it, right click to erase (blue means empty, but don't leave anything empty for DG maps), and middle button drag to scroll around. You can even swap middle and right in "Configuration...". To speed up the process, you can use flood fill (paint bucket on the left), and "Managed brush". When switched to managed brush, select "Kanjon2" from drop-down list, and try painting with it. It probably won't always work as you expect it to, but can be very useful to fill in the right edge tiles for you (when such exist). You can even select, copy and paste with Selection tool. Play around, try to figure it out. Anyways, whatever you do, don't use entities and don't modify the tileset. Also, I think 16 (or 17?) tiles from each edge are blocked for construction, so keep that in mind, use the status bar for current XY coordinates. And, half a tile next to obstacle tiles are also impassable (this's where the "cliff" is), and try not to push multiple creeps throgh a 1-tile wide canyons, they might easily get stuck.

Smled has its own format for saving maps, so you'll want to use that one if you want to keep the map for later editing. That's the one when you use regular Load/Save. For in-game use, go to Export, and select the last option, Map (Raw...). This will save a .map file, which we'll use next in GFlow and later in the game itself. Please note that this is not reversible - Smled can't load/import .map files.


STEP 2 - Using GFlow

(if you downloaded it before this post, download it again, important bugfix)

Defense Gear has no pathfinding. *record scratch* All creeps are actually acting like particles in a vector force field, something like in fluid dynamics. With the twist that you have to "draw" the fluid flow yourself, because I couldn't be bothered to program a real fluid solver to do this thing automagically. This one is very ugly and flickery and unfinished, but here's how to use it - place your .map file in the same folder where GFlow.jar is, run GFlow, press K, and type in your map name (without ".map" extension). Now, you should see your map in black and blue. Now, you'll have to "comb" the vectors by dragging your mouse in such a way that in all walkable tiles, vectors will point in the directions creeps should go next from there. You can adjust "brush size" with mouse wheels. Be very careful about the edges, since creeps have no intelligence and no pathfinding ability - this map is all they have and they will blindly follow it. Also, make sure it goes all the way off the map, as if there were more space. This vector field needs to push creeps from their spawn point to the edge of the map and push them off it. When you've got something, press N to normalize vectors (might not notice the difference, but it's important), and then S to save it. Two new files should appear, the .bin one is GFlow's save (can be loaded with L), and .vfl is for the game to read.


STEP 3 - Metafiles and waves

The best approach here would be to open up some existing files and see for yourself what's in there, it's simple textual stuff. A level needs its main INI file (like defense2.ini). In there you'll see "map-file" which have the name of your .map file that you've exported from Smled. "vector-file" is your vector field file (.vfl) from GFlow. startX and startY are the coordinates to point the camera at when you start the level. Please note that these are in game units, where a tile is 2x2 units (not the smartest decision, had its reasons in the begining and then it was too late to change). So, the center of tile (X, Y) would be (X*2+1, Y*2+1). "wave-file" is the template for wave files, "%d" part will be replaced with a number, so "defense2-w%d.dat" yields "defense2-w0.dat", "defense2-w1.dat", "defense2-w2.dat", etc. And, total count of such files for current level, under "wave-count". Next up, you have spawn points. I don't remember what's the maximum, but try to keep it under 10. These are also in game units. Don't ever put them all the way on the edge (0 coordinate, or 130). Signs are not in game unis, but in tile coordinates (as read from Smled). Ang(les) are in degrees. Zero points right, and positive direction is CCW, if I remember correctly. Wave files are very simple, they're just a sequence of (creep type, spawn point, pause), each in a new line. See creep-data.ini for creep types, spawn point numbers are the ones from map .INI, and pause is in frames (60 frames = 1 second).

For the time being, there is no way to "add" maps to the game. You'll have to back up and replace some of the original maps. I'd like to extend this, so game can detect new maps and put them in the selection menu, but I can't promise it.

Also, I know this is more of a random ramble than a guide, but that's all I can provide for now. If there are any questions or problems, don't hesitate to post.
 

The Following 11 Users Say Thank You to TheBurek For This Useful Post: