Mapping For Dummies/Lesson1
From UFO:AI
Contents |
Lesson1: MyFirstMap
The general plan
Whenever you begin a map, it's best to have a plan in your head of what you're going for. If you're looking for a jungle scene with a river, a recreation of Stonehenge, a random map for a desert scene, or the Taj Mahal, even this basic step helps flesh out your imagination. Once you get more used to the editor, you'll have an idea of what's reasonable and what's not, but at least you'll have a starting point.
The second thing to think of is while a small map is a good place to start, there's a lot of space to fill in a map if you don't want to start off in a shooting gallery. What looks big in the editor while you're working on details is actually pretty small compared to the models. A real map will take time, patience, and love. It gets faster as you get more used to the tools, but anything thrown together looks just that... thrown together.
Our first plan, then, is to start with something small we can build off of later. We want to build a couple of simple components that we can copy/paste to something else, or that we could easily attach more to later. Our plan, then, is to make a small shed, or perhaps a large gatehouse, at the edge of a lawn. With this, we could easily attach a house to one side, perhaps a street in front or behind, and we have a ready made 'landing area' for the troops.
When we're done, we'll have something that looks like this:
Note: You have be very careful of the dimensions - this is extremly important to let the pathfinding work as you expected. See this tutorial for more in depth information, however, I'll walk you through not tripping on yourself for now.
The Shed
If at any time during this tutorial your status bar in the lowerleft reads something other then "QE4 Drag Tool: move and resize objects", hit the Q key to make sure you're in the right mode. There's also buttons on the toolbar that can switch you between modes. The modes are translate, rotate, scale, QE4 Drag, and Clipper.
Our first task, then, is to give the people something to walk around on, namely, a floor. So, we start off by making a brush that will act as our floor. We want a little room to move around in, and a character takes up 32x32 for each 'move'. So, we'll make our Floor 128x128. Click and drag from 0x0 -> 128x128The first item you build though tries to be a cube, and from then on will take the hidden height of the last object you worked with (So when looking from the XY view, it will autoassign the z to the same as last object). Since we don't want some giant box, but a floor, we need to make the height of the object 4. Why 4? A character is 60 units tall, and a level is 64. That leaves us 4 units to play with the ground if we intend to cap off a ceiling. Right now, though, it looks like this:
So, Ctrl-Tab to the XZ view, and then click outside the object and drag it inwards. You'll probably want to adjust your grid by hitting 3, and then zooming in to the grid with INS/DEL. A few things of note when dealing with floors. Anyplace that you intend a player to be able to walk to MUST be above the Z=0 line. You can make negative z areas... but you'll break the pathfinding if any of the animated models find their way there. You'll want the final product to look something like this:
That's better, that looks like a real floor now. To rotate the camera view like you see above, rightclick in the camera area and push it around until it rotates to a more overhead view. Remember to right click again to deactivate the mouse activity and for the keys to operate as expected. Close the Surface Inspector by clicking the X in the corner, or by typing S again.
Now, we need some walls. Walls work with the same concept as floors, a width of 4 being the maximum a character can deal with and still move into its 32x32 block. Build a few brushes and drag them as needed, you want it to look like this:
There's a few important things to note in the above images. For starters, none of the brushes overlap. The walls are 60 units high, from 4-64 (remember our floor is 0-4), and none of them overlap each other at the corners. This is important because overlapping brushes makes the build file for the final map much larger in size for no reason.
In the overhead view, notice that I've left the 'door' from 32 to 64. The pathfinding works along the Grid 6 levels, every 32 marks being a 'step'. So, 0-32 is one box, 32-64 is another box, and so on. Players and aliens need these to be lined up so the pathfinding works correctly.
NOTE: An NPC or Alien CAN walk through any 24x24 space available to it (I've tested it as of Version 2.1), however, you cannot actively place a player there unless the 32x32 grid lines up properly. This means unless you're intending to give a huge positional advantage to the NPCs, do NOT stray from making sure your 'walking areas' are in the correct 32x32 locations.
Now, Let's apply some texture to the walls. I happen to like the 'dirtybrick', also found in tex_buildings. You will have to alter the stretch on this brick as well for a more realistic look. 0.2 for both horizontal and vertical in the Surface Inspector (S key) does nicely, as seen here:So, we've generated the beginning of a perfectly good building. It has no windows yet, I'm aware, and we'll get to those later, as it's easier to deal with those in another copy of GtkRadiant with the Clipper tool and we haven't gotten that far yet. Save the map in case something gets awkward in the next session so you can start over.
The Shed's Roof and using the cone tool
So, it looks kinda silly being unprotected from the rain and all that you say? Well, I agree! So, let's roof our new building.
First, let's build the brush. Head off to an area not being used by the current design and build yourself a 128x128 box. This is the time when you might start thinking about keeping two copies of GtkRadient open. One for working with a small sample of brushes, another for the primary map. You can copy/paste between the two applications very easily, and it's something you'll have to do to work with the prefab_ files.
So, we've got our brush. Now, we need the cone tool (well, we want it to look like a real roof, right?). So, with our brush selected, click the Brush menu at the top, then choose Cone...
A window comes up, asking us 'Arbitrary Sides'. In this case, we only want 4 (the maximum is 32 and creates a pretty decent circular cone). We end up with a diamond that looks like this:
So, we need to go to the Modify Menu, and then use the Arbitrary Rotation tool to spin this 45 degrees on the z axis. Type 45 into the Z, and click OK.
Now we need to adjust the height of the object and it's Z position. First, switch to a 'Z' view with Ctrl Tab so you can see the object from the side. It's one giant honkin' cone at the moment, far to tall for a normal roof. Type V so you can grab Vertexes (corners), and then select the upper most point and drag it down so it's only 32, then type V again to turn off corner selection.
Now drag the roof so it's bottom sits on the line for 64. It should end up looking like this:
So, switch back to the XY view with Ctrl Tab, and drag it over the top of your building. You have a roof! Kind of. It's brick!
Let's change around the textures here, and while we're at it, learn how to apply textures to each individual face of an object. With the roof selected, click 'F'. You should get little green dots in the different areas of the cone. When you click one, you select only that face. Unfortunately, the only way to be sure what face you selected is in the camera view, or via the blue dot. You should see something like this:Now, we apply a texture. Staying in tex_buildings, there's a roof002 that looks nice. Set the stretch for horizontal and vertical to 0.1 for it in the Surface inspector (remember, the S key). Now, when you're looking at it in the camera view, as we apply this texture to each face, some of them will be turned sideways to the roof. That's okay, and it's easy to fix. In the surface inspector, there's the Rotate option, right underneath where you've set the stretch. Set it to 90 when it's sideways, and you'll turn them straight.
Now, let's set the bottom of the roof to something useful. click the green dot in the center of the cone and you'll select the 'bottom face' of the cone. This will only really be visible if a person chooses the 'character view' in game, but we might as well be complete about our process. Using pageup/pagedown, and the arrow keys, let's get our viewpoint inside the new building.
tex_buildings.Woodvfloor (This will be the notation from here on for any texture I recommend application) looks pretty good on the ceiling very stretched out, so it looks like large planks of lumber. Let's stick with that. You can always shrink them down and rotate them in the surface inspector if you choose to. Hit F to turn off face selection.
Well, while we're here, and we're dealing with multiple levels, I guess now's a good time to introduce the level flags. These flags indicate when and where an object can be seen, when the player chooses a different 'level' to view (1-8) in the game. We want a user to be able to see into the building here, so now we've got at least 2 levels on our map. The level flags let us control this.
So, with our entire roof selected, let's go to the Surface Inspector. At the bottom, there's level flags. Turn on all flags from level 2 through level 8. This means we don't want it visible when viewing level 1. Due to the setup of the system, when all flags are unchecked, it acts as though it's visible on all levels, so you may see other maps not check anything on level 1 brushes. However, it's good practice.
Unselect the roof with ESC, and switch to a Z view. Click drag across all the rest of the brushes (the floor and walls), and open surface inspector. Activate all level flags from 1-8.
If you need more help dealing with level flags, please see this tutorial: Mapping/Tutorials/Levelflags. I will assume from here on that you can set a level flag.
Landscaping
Note: If you need to see more detail, rt-click the image to open in a new window, then 'download high resolution image'. I've shrunk them down so the page isn't overly heavy as they're each a nearly full screen shot.
Well, now we'll dump some grassy areas outside our new little building. Simple to do, we just build out two brushes as floors and attach the tex_nature.grass001 texture to it, like so:
And now, for some hedging. Think of it as installing walls only z32 high. There's a texture for hedges, too, so use tex_nature.hedge002. (Don't forget to adjust stretch on both the hedge and the grass in the Surface Inspector)
Now, I've never seen a completely flat lawn. It's usually got a bit of dip and rise to it. Not that for this game a flat region isn't acceptable, but nothing sells a groundpiece like not being freshly bulldozed. So, let's make ourselves a little groundswell.
The easiest way to do this with your tools is to make a new brush, then cone it for 7 sides. Now, select Vertexes (V) and Edges (E) and shove the cone around some. This is a good time to goof around with just how much you can affect a cone (or any brush for that matter) by hauling its pieces around the map. Adding extra corners by moving an edge around can get you some very interesting displays. I recommend doing something along these lines, however:
Please notice that the 'edges' of the hill meet the ground level, so that our models can walk up and down onto the hill.
Set the map lighting in the worldspawn
Type L to bring up the entity list, then scroll down and select 'worldspawn'. Type N to bring up the entity properties.
In the screen that comes up, the top shows the class of the object you're working with, the next box is a description of the entity type and what can be set to it, the third box is the actual properties, and the last area allows you to edit these values.
To alter a value, select it in the third area, and then change the value listed in the two textboxes below and hit ENTER.
To add a new value, type the key (property name) into the Key textbox, then the value into that textbox, and hit ENTER.
You'll want to set your settings to the following (more information and links can be found at Mapping/Tutorials/Setting_worldspawn_flags):
| KEY | Value Nighttime | Value Daytime | Comment |
|---|---|---|---|
| maxlevel | 2 | 2 | Set this appropriately as you build taller maps. |
| light | 80 | 190 | Desert might max this out at 255 |
| _color | 0.9 0.9 1 | 0.9 0.9 1 | Sun color |
| angles | 30 210 | 30 210 | Angle of the sun light |
| ambient | 0.25 0.25 0.275 | 0.45 0.45 0.45 | Ambient sun light color |
An alternate and simple way to do this is to set the worldspawn via the Plugins Menu at the top, and using the UFO:AI list.
That's all there is to it. You've got a functional map now. All we need to do is compile it into game code.
Build and view!
Save your map under a name, such as "MyHouse". It will get a .map extension. This is the file you share with others for comparisons and edits. However, the game uses .bsp files, which you compile from inside GtkRadiant or via commandline. There's an entire tutorial here for compiling, however, just go to the menu 'Build' and select 'Final Build'.
Note: If things go horribly wrong here, or seem to take forever, you probably need to go to Build-Customize..., select 'Final Build', and remove the -chop 32 option.
Once it's done the Command Window that pops up will close itself (Windows). Now all we need to do is boot up a copy of UFO:AI, and head for the console. Easiest way to do this is on the title screen tap the ~ button in the upper left corner of the keyboard. now, type in "maplist". You should see whatever name you saved your .map under in this list. Type "map myhouse" to launch the map.
When you launch a map this way you don't actually establish any player controllable characters, however if you've added them, you can see NPC's and any aliens the NPC's can see wander around the map.
Congratulations! You've built your first map for UFO:AI.
Cleanup and Best Practices
Reducing Exposed Face Count
Now, one of the better practices you should have used and I hadn't bothered telling you about yet was reducing face count. Every face the renderer doesn't have to draw helps reduce the compiler's and game renderer's work.
One of the easiest things you can do is cornering the edges. At each of our four corners, we have an exposed, 4 grid wide space... with a little modification, we deal with this. Put your map on Grid '4' with 3, and then select your brush. Use e to select edges, and then drag the edge of the brush with the exposed edge in one grid. Deselect a few times (to get out of edge selection then brush selection), and select it's neighbor. Use edge again, and drag it out to cover the missing angle. The following two images will help you make sense of the desired result (thanks to User:Mattn for the images):
You want to do this when it makes sense and you're removing a face from exposure. Brush corners (not T's) make a prime example for this, as both the shed and the hedges can gain by this. If you're grabbing a prefab or building your own brush, unless you want someone behind it or there's a purpose to it being away from a wall, press it to the wall and remove unneeded faces on the brush.
Another way would be to try to reduce facecount on the walls and floor (extending the walls down to cover the floor's sides), but because they would just expose the bottom of the walls, it doesn't help us, here anyway. If we had multi-leveled buildings, we'd put the floor inside the walls, and cover the sides of the floor with the walls.
It is one of the ways to have a cleaner way of mapping.
Links
- Mapping for Dummies: Lesson 2
- Mapping - Tutorials and more
- Mapping/Dimensions - Explicit tutorial on Dimensions.
- Mapping/Tutorials/Levelflags - Explicit tutorial on setting Level flags.
- Mapping/Compile - Compiling .bsp file information.
- Console - Accessing the in-game console.

