06 August, 2009

MUD world design, Part 3

So, it was a long dinner...

Yeah, still trying to get back to writing every day, even if most of it's crap. Any good writer will tell you that's the key.. write a LOT of crap, because every once in a while, some of it sticks and isn't too smelly.

So, we left off with the idea of wanting to build a gigantic MUD world, having a map drawn out of the Big Picture, and maybe having a few slaves...errr.. builders to help make things come to life. The problem is, when Joe comes up with a brilliant story idea for an ice cave, and we HAVE a perfect spot for an ice cave up in the mountains, nobody has yet written the chunk of the world between the mountains and the newbie village. So, either Joe has to shelve the idea for a while, or bang out a bunch of rooms to get to the area he really wants to work on. As you might guess, those "filler" rooms won't be very stellar quality, and there might be a whole lot of them!

That sucks.

How can we get around this? There are a couple of ways, and it really depends on how much control you want to have over your world vs. how much work you want to do. The easiest way (from the builder/admin's point of view, not from the coder's!) is to use something like Perlin Noise. The advantage of this kind of system over fractals is that it can be evaluated at a point without having to build the entire structure in memory. So, you come up with an algorithm that models terrain based on a noise-generated height map + another generated map for foliage + another map for climate + another map for types of mobs maybe, stir well, and voila! You have a self-generated world of infinite size!

Of course, if you want to go that route, you will also want to make a graphical viewer that you can use to generate maps with various seed values until you find one you like, and then zoom in and scroll around to find the perfect place to center your world. Once that's done, you hook up your game's room code so that if no hand-coded room exists for the coordinate in question, it generates one based on those map values. Since such a room is temporary, it won't take any space and will go away after nobody's been there for a while. But, since the noise functions aren't random, it will be regenerated exactly as before next time you go to those coordinates.

If you aren't willing to surrender that much control, there is also the tried-and-true method of drawing maps in a paint program and having your code read them in. The downside is that you DO have to store the image in memory so it can be referenced without disk I/O. You also have to chunk your world up into square segments.... AND if you do allow multiple maps, the edges have to line up. If you choose the idea above of using multiple maps for terrain/climate/etc, you may have some work getting all the overlapping to mesh cleanly (photoshop to the rescue?).

Whichever method you choose, the end result is the same. You now have to have coordinates for your outdoor rooms such that your mechanism for moving knows what to expect when you type "north". That's not to say you have to have coordinates for every room... you could omit them for hand-edited things... but you may wish to be careful how you link between custom sectons and generated ones.

Many MUDs use a kludgy version called an "overland" map, which works a bit like the old Ultima IV game. You walk around the "overland" and then "enter" places of interest. Thus, movement on the overland is always by coordinates, and movement in the zones is always NOT. I prefer a more seamless approach, where the exit can either point to a room (vnum, path, depends on your type of MUD), or a coordinate (which might map to an already existing room, or which might cause a new room to be generated). That makes the distinction between hand-edited rooms and "filler" less obvious. In fact, if you use coordinates everywhere AND you write a reasonably good description generator, you can just skip over the small handfuls of rooms you used to have to write into your areas as filler spaces (IE: the 4 grasslands on either side of a road, etc).

I could write more here, but this has been a draft long enough.. let it be live!

02 August, 2009

MUD world design, Part 2

So, last time I droned on about how worlds work, and how they evolve from a plan (or a lack thereof). I promised to show you how to make a big huge world and still be able to grow bits of it that aren't right next to each other, but first... we need to get a few things straight.

Most MUDs use the concept of a room, as I mentioned before. But what IS a room? What functions does it serve in the game? Do we *have* to use rooms?

We don't need rooms, but they make life simpler in a lot of ways. Most of those ways are good, but a few are lazy. The firs thing rooms do is provide containment. Put simply, players only see what is in the room they are in, they only see people (and NPC's) enter and leave that same room. Combat is limited to the participants in the room. Speech is typically also limited to the room boundaries.

From a coder's point of view, this means a whole lot of checks that we'd have to perform for every action the player or NPC attempts can be simplified down to "am I in the same room as my target?" That's a LOT easier than handling range, line of sight, cover, and all the other things a coordinate based game has to deal with.

It also makes life easier on the builder. When designing an area, the builder doesn't have to measure and count, they just write the descriptions appropriately for the number of rooms they want the player to traverse from point to point. Want the journey from the city gate to the goblin cave to be 20 moves? Easy! Build your road out 18 rooms from the gate, describing the countryside in chunks large enough to fit the distance... put the enterance to your cave there. Now build out a few rooms from the road for people that wander. Done.

Of course, explorer types like me will laugh, since your world has edges you didn't account for. You'd need to put forests that are too thick to get through, or mountains too steep to climb, or swamps... you get the idea. The "edge" rooms have to make you believe you can't go that way, so you won't try... else it breaks the immersion.

Still, you'll notice I never said how far (in distance) the cave actually were from the city. That's because it doesn't matter. Rooms can be any size, and most games treat them as no size at all. Gamers talk about distances in terms of how many rooms away things are, and even games that drain endurance as you walk, treat all rooms as the same size.

If that sounds kindof cheesy to you, you're in my camp. I like maps! I like things to make sense unless there's a good reason for them NOT to. I like to be able to head out across country and find my own way, rather than following roads and directions. To do this, one either has to be in a coordinate system, or a room system that is fully fleshed out so it works like a coordinate system.

That is the show stopper. If you want to keep rooms, AND you want a fully fleshed out world, most people sigh, roll up their sleeves, and build on a grid. The grid will have thousands of "filler" rooms, whose description is mostly cut-and-pasted, and which have nothing of interest other than random wandering monsters.

You are standing on a grassy plain. Tall grass waves gently in the breeze, and stretches out as far as you can see in every direction. You think there is a smudge of a mountain range far to the north, and a forest lies below you, miles to the west.
Yeah. You can cut and paste that into about 200 rooms, then change the description of the forest and fill in another 50-100 on the west side. Yawn. Your players will "thank" you for your effort by flipping to brief mode and typing "/repeat 100 w".

But what's the alternative? You don't want the sheep-rail guided system. You don't want the complexity of a full coordinate system (and the major rewrites to the entire combat and communication system it involves). What else can we do?

More to come... after dinner. :)

New Look

Well, I decided to update my template, and even though I lost a bit of my custom HTML hackery, this looks cleaner and is simpler to change and maintain. Yay for lazy consumers!