Map making by hand

From BZFlagWiki
Revision as of 18:38, 8 February 2017 by Zehra (Talk | contribs) (Building World Objects: cleanup)

Jump to: navigation, search
Plywood hammer100x101.gif There is still documentation to be done here!! If you feel up to the task, please have a go at it. Specifically what needs to be added is:
Major re-organization, transform away from "chat" style. Need to reference pages elsewhere on the wiki in place of much of the content which appears to be building up here. Create them if necessary, or see the list here.

Editing by hand is still a common way of creating maps. Although there's a number of GUI options for creating maps such as BZEdit, BZWTools, BZFed, PyBZEdit and IBZEdit. Many map-makers use a basic text-editor. This can be due to the enjoyment of the challenge of creating a map by hand or due to a lack of graphics modeling capability.

Text Editors

Most text-editors designed for coding/programming are more than sufficient for editing bzw files. Although word-processing programs such as Microsoft Word can be used, there are many cheaper (free) and more efficient programs designed specifically for coding. If you are interested in syntax highlighting, look at the forum topic.

Windows

  • Notepad
  • PSPad
  • NoteTab
  • Notepad ++ - a tabbed editor based on Scite.

Mac

  • TextWrangler
  • TextEdit

Linux

  • Command-line editors such as nano, emacs, pico, vim, or ed.
  • GEdit
  • Kate
  • Scite

Editing existing maps

Beginning mapmakers should spend some time studying and making small changes in existing maps to see how things work. In the client, maps can be saved for editing by joining the desired server and choosing: Options>Save World. Maps can also be saved by issuing the /saveworld command. The map should be a simple map when getting started. One may find it easier to create a file in BZEdit and open the resulting file in the text-editor. One can gain experience by also converting map objects into their mesh equivalents such as converting a box into a meshbox or a pyramid into a meshpyramid.

Getting Started

One should become familiar with the BZW syntax before attempting to create a map by hand from scratch or have on hand a reference card. Also knowing the coordinates of where object placement(s) will occur based on the options set. The way world units are oriented in a normal right hand rule coordinate system with positive Z being the "UP" direction. "north" on the in game radar is the positive Y direction in map coordinates. This image shows a typical map, with the origin and axis directions clearly marked out. MapCoordinateSystem.png

The positioning of map objects in the "position" of an object goes as such. The first setting is for the "X" axis with the second being for the "Y" axis and the third being for the "Z" axis. The same applies to the "size" in a world object.

A good way to start learning is to begin with simple world objects and settings:

# Example world with settings and box
# The number sign is not needed for a map to function, but is used for comments.
world 
  size 400 
end 
options 
  +r 
  -j 
  -set _tankSpeed 25 
  -ms 5 
  -mp 0,2,0,2,0,2 
end 
box 
  name box1 
  position 0 0 0 
  size 10 10 10 
  rotation 0 
end 

Example map explained

First, it says:

# Example world with settings and box
# The number sign is not needed for a map to function, but is used for comments.

(Note: the # sign is used for comments.)

This is many times added by map editors, but with different comments.(depending on editor)

The next thing is:

world 
  size 400 # Sets the world size to 400 (800 x 800 total)
end 

This is rather self-explanatory. It's the <size> of the <world> (The BZFlag arena).

Next is an <options> section:

options 
  +r   # Enable Ricochet
  -j   # Enable Jumping
  -set _tankSpeed 25  # Sets the tank speed to 25 bzunits/second
  -ms 5  # Sets the maximum shots (per tank) to 5
  -mp 0,2,0,2,0,2  # Maximum of 2 Red Players, 2 Blue Players, and 2 Observers
end 

This allows you to define in the map file certain options that are also available from the command line when you start the bzfs server, or in the optional server config file. Options embedded into a world file will override those input on the command line or in a config file.

The commands listed here are: Ricochet, Jumping, Tank speed, Max Shots, and Max Players. These are rather self explanatory, except for Max Players. Each number represents how many of each of the following team players are allowed in the game (in the order listed): Rogue, Red, Green, Blue, Purple, Observer. Each number defines the max number of players per category.

For more info, see Options Object.

We now come to:

box 
  name box1      # Generally unused
  position 0 0 0 # X Y Z Position
  size 10 10 10  # X Y Z Size (bzunits from the position of the box)
  rotation 0     # Rotation (in degrees)
end 

This is a <box> with a <name> of <box1>. The <position> is 0,0,0 in R3[1]. The rest is pretty self explanatory.

Important: EVERY STATEMENT MUST HAVE AN END. If a statement does not have an end you will get an error.

Basic Definitions

Objects
Objects are the basic building blocks of the bzw file. Objects begin with a line declaring the object, some fields describing that object, and a line that closes the object (usually with "end"). Each of these sections of the object is important.
Comments
BZFS ignores anything in a line following the #; the line has been "commented out." It is highly recommended that comments be used often, both for the mapmaker and for others that may see the map.
3D Cartesian Coordinate System
In most objects, you will see three numbers after position and size. These numbers are coordinates on a graph. The first number is the x coordinate (left and right) the middle number is the y coordinate (forward and backward) and the third number is the z coordinate (height and depth). Another way of thinking of it is: x = width, y = depth, z = height. (Those accustomed to the Y axis determining height will have to slightly adjust their thinking.)

Optional client setup

There are some options that appear useful when editing a map, especially when editing by hand.

showCoordinates
The BZFlag client is capable of displaying a tank's current location for the player at the top right corner, right below the clock. This feature is being activated by executing the "/localset showCoordinates 1" command to the chat line.

Building World Objects

We're getting to the part of building world objects in a map. Most of the objects covered are quite simple to understand and program into a map. The first objects covered are the simple objects. The overview will first deal with boxes then move onto bases and then to pyramids.

More Complex World Objects

Meshbox

Perhaps the simplest mesh object is the meshbox. Here is an example of a meshbox:

meshbox
 position 0 0 0  # x-pos, y-pos, height
 rotation 0  # rotation in degrees (rotation is optional and does not have to be included)
 size 10 10 10  # x-len, y-len, height
end

As with the box object, position defines where the meshbox should be located. Rotation defines the angle it should be rotated to (about the Z-axis), and size defines how big or small the object should be. Now, if you're looking for something a little fancier, you can try code similar to this:

meshbox
 name example
 position 0 0 0
 rotation 0 (rotation is optional and does not have to be included)
 size 10 10 10
 shift 0 0 0
 shear 0 0 0
 scale 0 0 0
 spin 0 0 0 0
 outside matref my_cool_wall
 top matref my_cool_roof
 phydrv example_physics
 obstacle
end

Valid parameters for a meshbox are:

name
defines the name of meshbox, often unused
position
defines the position of the meshbox in X-pos, Y-pos and the height of the meshbox in Z.
rotation
defines a rotation around the Z axis for the meshbox, in degrees.
size
defines the distance from the center to the side of the meshbox in X and Y, and the total height of the meshbox in Z.
shift
shift the meshbox (repeatable)
shear
(repeatable)
scale
defines the scale of the meshbox in x,y, and z, 1 is the default, lower values make it smaller (repeatable)
spin angle
rotate the meshbox around a vector by angle. The vector <nx, ny, nz> must be a unit vector. Because the BZFlag client doesn't clip objects against the ground, it is advisable to ensure that the meshbox is rotated up and away from the ground. Otherwise, the meshbox will appear to be super-imposed on the ground, rather than embedded into it. (repeatable)
phydrv
reference to a predefined physics driver.
matref
reference to a predefined material.
obstacle
 ??


What's the difference? This object will be treated as an obstacle. The outside walls (as opposed to inside, top, or bottom) will appear with the "my_cool_wall" material, and the roof (top) will have "my_cool_roof." Of course, if you want a material on all sides of the object, you can simply omit the "top" specification at the start of the line, and simply have: "matref my_cool_material." Also, you can specify a physics driver to the object, to influence tank behavior a bit.

By default, a meshbox will have red brick walls, and a grey stone roof. However, if a material is specified by the map creator, the appearance depends on the designer's choosing. Contrary to a Box, a height 0 meshbox at ground level is not visible.

Meshpyramid

Several meshpyr, with the one in the middle having the default texture

A meshpyr is a BZW map object that constructs a specialized mesh that has the geometric appearance of a Pyramid. It replaces the pyramid object as of v2.0.0 and is compatible with materials and physics drivers.

An meshpyr without a material definition will use the default material used by a standard pyramid object. Geometrically a meshpyr is identical to a standard pyramid object.

meshpyr
 name example 1
 position 0.0 0.0 0.0
 size 15 15 15 
 rotation 0.0
 matref Mymaterial
 phydrv MyPhydrv
end

Valid parameters for the Meshpyr object are:

name
name
position
positon on map
rotation
rotate on z axis
size
size amount
matref
apply a material/texture here
phydrv
assign a physics driver

The Cone

Most objects have similar parameters as the basic box. For instance, the code for a cone may look something like this:

cone
  name cone1
  position 0 0 0
  size 10 10 20
  divisions 128
end

Divisions basically decide how smooth the cone is. The higher the divisions the more smooth the cone is. A division of 4 would look like a pyramid. Another parameter that can be added to the cone object is angle. If you say angle 180, that would make 1/2 of a cone, 90 would make 1/4 of a cone, and so on.

The Arc

An arc is basically a cylinder. However it doesn’t have to be a perfect cylinder depending on certain options you select. For an arc the only required options are divisions, position and size. Just like the cone divisions have the same effect, position and size are all the same. Once again you can have an oval shaped cylinder type thing. Now, you WILL find more options to an arc than to a cone, for example the ratio option. The ratio options let you basically put a hole in the cylinder. So if you have the option: ratio 1 you would have a full cylinder. If you say for example ratio .3 or any number less than 1 you will get a hole in the cylinder. The bigger the number, the smaller the hole. Angle allows you to do a semicircle. Rotation, once again, isn't really needed, unless you need a semicircle that has a certain specific orientation in your map. all the options like spin and shear are the same for this object too! phydrv and matref I’ll show later.

The screenshot below shows three arcs. The only difference between them is the inner radius number. The first is set to 1, the second to .5, and the third to .1. Notice how the texture on the top surface of the arc becomes "stretched" when the radius is less than one.

Bzfi0015.png

Here is the code for the arc with the .1 ratio:

arc
	divisions 16 # number of subdivisions
	angle 360 # the sweep angle
	ratio .1 # (outrad - inrad) / outrad
	position 0.0 -42 0.0
	size 10 10 1
	rotation 0.0
	shift 0 0 0 # (repeatable)
	scale 1 1 1 # (repeatable)
	shear 0 0 0 # (repeatable)
	smoothbounce # ricochets use normals
end

Now lets see what happens if we change the angle value. The ones below use 60, 120, and 240. This is where you would need to use rotate to get the arc oriented the way you want.

Arcs.jpg

Here is the code for the 60 degree arc:

arc
	divisions 16 # number of subdivisions
	angle 60 # the sweep angle
	ratio .5 # (outrad - inrad) / outrad
	position 0.0 0.0 0.0
	size 10 10 1
	rotation 0.0
	shift 0 0 0 # (repeatable)
	scale 1 1 1 # (repeatable)
	shear 0 0 0 # (repeatable)
	smoothbounce # ricochets use normals
end


Let’s move to the sphere:

The Sphere

The only options required to make a sphere are position, size, and divisions. All these options do the same thing as they did in the objects above. You may also have an oval like sphere. You make an oval like sphere simply by making the x and y's different sizes just like in the cone and arc. The radius option is just a substitute for size. You can write size 10 10 10 or radius 10. Both do the same thing. However if you want an oval shaped sphere you have to use size. Rotation wouldn't really have an effect and the shear and spin works the same for this object.

Getting more help

  • The links at the bottom of the Map Making page.
  • The original creator of this page is flight, you can email him at dirtbikerdude_91@yahoo.com and he will be happy to answer any questions that he is capable of answering.

Special Objects

There are certain objects that are often coded by hand because it is simpler or it is impossible to do with graphical map creation tools.

Materials

Example:

material 
  name mat1 
  addtexture blue_bolt.png 
end 
meshbox 
  position 0 0 0 
  size 10 10 10 
  rotation 0 
  matref mat1 
end 

Material is letting the computer know that a material is about to be explained to it. You name it so that way you can reference it with the matref. The name can be any thing you want as long as it does not have any spaces. You type in addtexture and you state a texture name. Now, how do you know what texture names there are to use?

On Linux: Running ls /usr/share/bzflag/*.png in a terminal will show the list of pictures.

On Mac: If you control click (right click) on the bzflag icon, click show package contents, click contents, and click resources, those are the pictures you may use.

On Windows: The default path is C:\Program Files\BZFlag\data\*.png

What you will find are images that are used in every day games. The top of a base, the wall of a base. A bullet which is blue_bolt.png (as was used above). The full path to the texture needs to be used if the texture is not found in that directory. Any customized textures should be uploaded to the BZFlag Image Submission System before the map is hosted publicly.

Servers running bzfs 2.0.8 and earlier will require "meshbox" and "meshpyr" in order to apply textures and physics to these objects.


Instead of creating a new texture, many interesting and creative things can be done with the "diffuse" parameter in the material object. You can add the diffuse command and it will look like this diffuse 1 1 1 1. The first number is the amount of red that will be in the meshobject. The second number is the amount of green, the third is the amount of blue. So you can mix those colors to make more colors. You may use a range from 0-1. For example diffuse .3 .5 .26 1. The fourth number determines the opacity or transparency (the see-throughability). 0 is invisible, .5 is half invisible, and 1 is normal.

material 
  name mat1 
  diffuse .5 .25 .1 .6 
  addtexture mesh.png 
end

Physics

The format of the physics driver is like this: (note that not all the commands are used concurrently, there is no point in using a death driver with a linear driver, etc.)

physics
  name example_phydrv
  linear 0.0 0.0 0.0 # x/y/z linear velocities
  angular 0.0 0.0 0.0 # rotation freq, x/y coordinates
  slide 0.0 # time until max velocity (> 0.0 enables)
  death Message goes here.
  # the 'death' property requires a non-blank message
end

Physics drivers subject your tank to external forces. If you have ever played laser mania by Louman then you may have encountered on the outskirts of the map an object that you can jump on and you go really fast, that is a physics driver. Physics and materials are both similar in that you must first define them, and then apply them to an object. When you define a mesh object (regular BXFlag objects, such as boxes can't use physics drivers) you can reference that physics driver by using the phydrv command just like you would use the matref command for materials. There are different physics commands: Linear, Angular, Slide and Death. The physics driver used in the Louman map mentioned above is a linear driver. Linear physics makes your tank move in a line. The numbers after a linear command are how much "force" is applied in a given axis x y z, and you can have force applied in more than one axis. The direction is NOT along the axis of the object you apply the physics driver to, but along the major world axis, so if your object is rotated 45 degrees, you would need to put values for both x and y in your physics driver. 45 degrees is fairly easy, but other angles would require figuring out the proportions needed to move the tank along an object rotated to a given angle, it can get a bit tricky.

Example:

physics 
  name phy1 
  linear 50 0 0 
end 

This will make your tank move at a speed of 50 in a positive x direction you may use -50 and it will make it go the other way.

physics 
  name phy2 
  linear 0 50 0 
end 

This will make your tank move at a speed of 50 in a positive y direction:

physics 
  name phy3 
  linear 0 0 50 
end 

This will make your tank jump (bounce) at a speed of 50:

physics 
  name phy4 
  slide 5 0 
end 

This will make your tank basically feel like it's on ice. Whichever way the tank is moving it will keep moving that way.

physics 
  name phy5 
  death haha! you died 
end 

This will make the tank die when it touches the object that refers to this and the message haha! you died will be displayed to that person.

example:

 physics 
   name phy1 
   death I like you better dead! 
 end

 meshbox 
   position 0 0 0 
   size 10 10 10 
   rotation 0 
   phydrv phy1                       # Or what ever you named the physics.
 end

This is applied to an object in a manner similar to that of a material. Both physics and materials must be created in the map file before they are referenced. The example below illustrates incorrectly placing a material definition after it is referenced by the meshbox:

 meshbox 
   position 0 0 0 
   size 10 10 10 
   rotation 0 
   matref mat1 
 end 

 material 
   name mat1 
   addtexture blue_team.png 
 end

Groups

A group is cluster of objects that can be "gathered together" and treated as if they were a single object. Certain things cannot be included in groups:

  • textureMatrix
  • dynamicColor
  • material
  • physics
  • links
  • weapon
  • zone

Notice that while teleporters aren't excluded from groups, you can't create links to teleporters within a group, except for purely random ones using "*"(asterisk) for the link. (this may not be entirely accurate, Trepan at one point hinted that there is a way around this...)

Groups can be nested (you can have a group that is included in another group).

For example if a map editor is making a forest, and each tree contains 2 objects, the editor doesn't want to type up the code for each tree over and over again. What he can do is tell BZFS that these objects = tree. And then whenever he wants to make a tree he just calls that group, as shown below.

Example:

First define a group of obects as a tree...

  define tree
  
  box
  position 0 0 0
  size 2 2 4
  end
  
  pyramid
  position 0 0 3
  size 5 5 10
  end
  
  enddef

...then, to call the "tree" group, just:

  group tree
  position 0 0 0
  end

Transformations

Transformations are simple ways of modifying objects so that maps have some variety. These can get complicated so I will only give you a sample of what they can do. There are 3 transformations shift, spin, and shear. You can find a more in depth page here: 3d Transformations

Shift

Shift moves an object by the amount of units that you specify from its present position. the object..

 box
 position 10 10 0
 end

is at place 10 10 0

while the object..

 box
 position 10 10 0
 shift 0 0 10
 end

is at position 10 10 10.

Spin

Spinning an object is just like rotating an object but can be on a different axis. (y and x) When you rotate it is around the center of the object. Remember: Only spin-able objects can be spun. Here is what the code looks like:

meshbox
  position 0 0 0 
  rotation 0
  size 10 10 10
  spin 45 0 1 0
end

The meshbox will now be tilted 45 degrees on its y axis. Spin code has four numbers, the first one is how many degrees to spin. The last three are for which axis's to spin, by placing a value of more than 0. Spin can be a bit tricky and unintuitive to use. It is not exactly like rotate, because it is possible to "spin" something so that it ends up "underneath" the BZFlag playing field.

Spin is often best used with shift. Think of the center of your map as a sort of "construction yard". You position objects at location 0 0 0, then spin and shift them to the location you want.

Here is what you get if you use the above code in a map:

Bzfi0012.png

Looks fairly normal in this screenshot, doesn't it. But if you drive around, the box will behave oddly, and appear to "float" in front of your HUD. What has happened is that the box hasn't rotated around it's own axis, but around the world axis for the whole BZFlag arena! But if we add some code to shift the box up above the z plane, it will look normal in-game.

So if we make a simple change to the above code and add a shift statement and shift the box up in z (this is not the z axis of the box, but the world axis of our game arena):

meshbox
  position 0 0 0 
  rotation 0
  size 10 10 10
  spin 45 0 1 0
  shift 0 0 10
end

...we get this:

Bzfi0013.png

... and the box doesn't do the weird "float" thing any more. This "construction yard" technique is really handy, you just "build" your stuff smack in the middle of your map, then spin and shift it to where you want it (in the example above, it could have been shifted in x and y as well. Just don't shift and then spin, or you will be back to having things "float" again.

With shift and spin you can also work with groups and make a "master" group in the middle of your map, then shift and spin multiple copies to other locations on your map.

See also

Map Editors

BZEdit BZEditWin32 BZFed BZWTools DI-Machine
IBZEdit Modeltool PyBZEdit Wings3D

Map Objects

Arc Base Box Color(BZW) Cone Define DrawInfo
DynamicColor GroundMaterial Group Include Link Linkmaterial Material
Mesh Meshbox Meshpyr Options (object) Physics Pyramid Sphere
Teleporter Tetra TextureMatrix WaterLevel Weapon (object) World (object) Zone

Helpful links