Haaru Map Extension
From LSWiki
Revision as of 18:10, 15 February 2008
The map extension can make short work of creating a new area. Below I will go through what I've learned about the map extension while trying to create my first area. Everything should be taken with grain of salt, but all in all I think most of what I'll say is pretty accurate. I'm sure there's a lot I'm missing though. If you know something that will help other developers create better areas, please add it. This is a work in progress.
Contents |
Using the Extension
After you create your project directory structure, the first thing you'll want to do is to create your daemon control and set it to use the map extension. For new developers, this file should be created in <project>/dmn/ and named control.c.
Here is an exampe of a control.c file:
#include <Army_Ant_Colony.h> #include <daemon.h> inherit "/std/daemon"; inherit "/mod/daemon/broker"; inherit "/mod/daemon/control"; void configure() { ::configure(); set_creator("haaru"); set_area("Army_Ant_Colony"); add_extension(LS_Extension("pathfinder")); set_definition_registration(([ Army_Ant_Colony_Definition("map_*") : 0, ])); set_definition_unregistration(([ Army_Ant_Colony_Definition("map_*") : 0, ])); add_extension(LS_Extension("map"), (: $1->set_base_room(Army_Ant_Colony_Room("Map_Base.c")); $1->set_room_prefix(Army_Ant_Colony_Room("map_")); $1->set_map_conf(Army_Ant_Colony_Data("map.conf")); $1->set_map_directionality(Map_Directionality_Basic); :)); }
The set_definition_registration and set_definition_unregistration are very important. This tells the daemon what files to use as definitions. Definitions are what the map extension uses to create rooms. Directly below that is where we actually add the map extension.
$1->set_base_room(Army_Ant_Colony_Room("Map_Base.c"));
This line sets the base room file to use.
$1->set_room_prefix(Army_Ant_Colony_Room("map_"));
This line sets the room prefix. When the map extension creates a room it will use this prefix along with the cordinates of the room. So lets say you go to the cordinates 0, 0, 1 in your area. The map extension creates the room with the name map_0_0_1. Simple enough.
$1->set_map_conf(Army_Ant_Colony_Data("map.conf"));
This line sets the file to use for map generation. Here is an example of a map.conf file. We will go more into the map.conf file later on.
$1->set_map_directionality(Map_Directionality_Basic);
This sets the directionality of your map. Basically this tells the map extension what directions you want included in your map. You can find these defined at /lib/map.h
Those are the only extension settings I've used. I'm sure there are probably more.
Creating your definitions
The next thing you'll probably want to do is create your definitions. Your definitions rely mostly on the file /std/def/map_feature. I would recommend reading it. There are currently only two map feature types.
- Map_Feature_Type_Area
- Map_Feature_Type_Overlay
Map_Feature_Type_Area
The area type is probably best described as a sort of base room type. Say a tunnel, room, wall, etc. If everything unique about the area is removed what would be left. Below are some areas that I used in my project.
map_area_air.c map_area_sandstone.c map_area_wall.c map_area_tunnel.c map_area_submerged_tunnel.c
Here are the contents of the map_area_tunnel.c file.
#include <Army_Ant_Colony.h> #include <room.h> inherit Army_Ant_Colony_Definition("Map_Area_Base"); void configure() { ::configure(); // The name of the map feature, this should match the name of your file after the "map_area_" prefix. set_map_feature_name("tunnel"); set_map_feature_summary("a tunnel"); add_map_feature_terrain(Terrain_Underground); add_map_feature_terrain(Terrain_Tunnel); add_map_feature_realm("Army_Ant_Colony_Tunnel"); // Here you can specifiy what will be displayed for this room when using the map tool. VERY HANDY! set_map_feature_visualize("{{red}t}"); // Here you specify the UNIQUE character associated to this map area. This is used when you actually create your map. set_map_feature_specify("t"); add_map_feature_description( "You are in a tunnel made from {{yellow}sand} and {{brown}mud}. The walls have large gash marks " "in them where it seems as though something or someone has dug it's way through the " "earth." ); // What adjacent rooms with display in their description of what is next to them. set_map_feature_adjacency( "%t is a tunnel." ); set_map_feature_item_descriptions(([ ({ "marks"}) : "The marks are clearly made from the ants that inhabit this colony. " "The size of the gashes are a clear reminder of how dangerous these creatures are.", ])); // Set how the room is accessed. set_map_feature_access(Map_Access_Walk); // Here I specifically specified that to access this room type from above or below you would have to tunnel. // This allows me to have tunnels on every Z axis with out interfering with each other. set_map_feature_access(([ Direction_Up : Map_Access_Tunnel, Direction_Down : Map_Access_Tunnel ])); // Here I specified that in order for anyone exiting this room going up or down, they will have to tunnel. // Again this allows me to have tunnels on every Z axis. set_map_feature_access_override(([ Direction_Up : Map_Access_Tunnel, Direction_Down : Map_Access_Tunnel ])); // Here I specify that in this rooms description, I don't want to see what is above or below me. set_map_feature_adjacency_suppression(({ Direction_Up, Direction_Down })); }
Map_Feature_Type_Overlay
Here is where the detail goes into your map. I used overlays to handle special access restriction, directional description suppression and so on. I also put in abstract items and room contents using overlays.
Here is an example of an overlay I used for any of my tunnels that I wanted to actually have Up or Down access.
... will finish later.