Haaru Map Extension
From LSWiki
Revision as of 18:10, 15 February 2008 (edit) Mort (Talk | contribs) ← Previous diff |
Revision as of 01:14, 16 February 2008 (edit) Mort (Talk | contribs) Next diff → |
||
Line 1: | Line 1: | ||
- | 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. | + | =Introduction= |
+ | 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 a 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. | ||
- | =Using the Extension= | + | =Extension Setup= |
- | + | The first thing you'll need to do is create your project directory structure. This is easily done by using the [[perform project setup]] command. After you create your project directory structure you'll want to create your daemon control and set it to use the map extension. This file should be created in '''<project>/dmn/''' and named '''control.c'''. | |
- | 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: | Here is an exampe of a control.c file: | ||
Line 19: | Line 19: | ||
set_area("Army_Ant_Colony"); | set_area("Army_Ant_Colony"); | ||
add_extension(LS_Extension("pathfinder")); | add_extension(LS_Extension("pathfinder")); | ||
+ | |||
+ | // Set the definition files the daemon should use | ||
+ | // when using the map extension. | ||
set_definition_registration(([ | set_definition_registration(([ | ||
Army_Ant_Colony_Definition("map_*") : 0, | Army_Ant_Colony_Definition("map_*") : 0, | ||
Line 25: | Line 28: | ||
Army_Ant_Colony_Definition("map_*") : 0, | Army_Ant_Colony_Definition("map_*") : 0, | ||
])); | ])); | ||
+ | |||
+ | // Add the map extension and set it up. | ||
add_extension(LS_Extension("map"), (: | add_extension(LS_Extension("map"), (: | ||
+ | // Set the base room to use. | ||
$1->set_base_room(Army_Ant_Colony_Room("Map_Base.c")); | $1->set_base_room(Army_Ant_Colony_Room("Map_Base.c")); | ||
+ | // Set the prefix the map extension should use when generating rooms. | ||
+ | // This instance will generate rooms in the folloing format 'map_x_y_z'. eg: map_0_-2_1 | ||
$1->set_room_prefix(Army_Ant_Colony_Room("map_")); | $1->set_room_prefix(Army_Ant_Colony_Room("map_")); | ||
+ | // Set the map configuration file. This is the file where you actually draw the ascii map. | ||
$1->set_map_conf(Army_Ant_Colony_Data("map.conf")); | $1->set_map_conf(Army_Ant_Colony_Data("map.conf")); | ||
+ | // Set the maps directionality level. Basically how many directions you want to map to use. | ||
+ | // See /lib/map.h for all defined directionalities. | ||
$1->set_map_directionality(Map_Directionality_Basic); | $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= | =Creating your definitions= | ||
Line 95: | Line 86: | ||
); | ); | ||
- | // What adjacent rooms with display in their description of what is next to them. | + | // What adjacent rooms will display in their description of what is next to them. |
set_map_feature_adjacency( | set_map_feature_adjacency( | ||
"%t is a tunnel." | "%t is a tunnel." | ||
Line 108: | Line 99: | ||
set_map_feature_access(Map_Access_Walk); | 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. | + | // Here I 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. | // This allows me to have tunnels on every Z axis with out interfering with each other. | ||
set_map_feature_access(([ | set_map_feature_access(([ | ||
Direction_Up : Map_Access_Tunnel, | Direction_Up : Map_Access_Tunnel, | ||
Direction_Down : 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. | // 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. | + | // By default the access is determined by the room you're going to, but this function allows you to override that. |
set_map_feature_access_override(([ | set_map_feature_access_override(([ | ||
- | Direction_Up : Map_Access_Tunnel, | + | Direction_Up : Map_Access_Tunnel, |
- | Direction_Down : 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. | // Here I specify that in this rooms description, I don't want to see what is above or below me. | ||
+ | // This is so people don't see a tunnel above or below this tunnel, since there's supposed to be earth | ||
+ | // between them. You can of course accomplish all this with an actual whole Z axis between tunnels, but | ||
+ | // that would require twice as many Z axises. | ||
set_map_feature_adjacency_suppression(({ | set_map_feature_adjacency_suppression(({ | ||
- | Direction_Up, | + | Direction_Up, |
- | Direction_Down | + | Direction_Down |
- | })); | + | })); |
} | } | ||
+ | |||
+ | I would recommend looking in '''/lib/map.h''' for the different types of Map_Access_* that are available. Also good is '''/lib/terrains.h''' to see what types of terrains are available to use. Look at other area definition files for more examples of different types of terrains. I learned a lot from looking at the Hanoma, Liathyr, and River Tethys areas. | ||
==Map_Feature_Type_Overlay== | ==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 where the detail goes into your map. You can use overlays to place descriptions, abstract items, content, etc into rooms. |
- | Here is an example of an overlay I used for any of my tunnels that I wanted to actually have Up or Down access. | + | Here is an example of an overlay I used for adding mushroom patches to some of the rooms. |
+ | |||
+ | #include <Army_Ant_Colony.h> | ||
+ | #include <room.h> | ||
+ | |||
+ | inherit Army_Ant_Colony_Definition("Map_Overlay_Base"); | ||
+ | |||
+ | void configure() { | ||
+ | ::configure(); | ||
+ | set_map_feature_name("mushroom patch"); | ||
+ | add_map_feature_contents(Army_Ant_Colony_Misc("mushroom_patch")); | ||
+ | } | ||
- | ... will finish later. | + | ...to be continued. |
Revision as of 01:14, 16 February 2008
Contents |
Introduction
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 a 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.
Extension Setup
The first thing you'll need to do is create your project directory structure. This is easily done by using the perform project setup command. After you create your project directory structure you'll want to create your daemon control and set it to use the map extension. 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 the definition files the daemon should use // when using the map extension. set_definition_registration(([ Army_Ant_Colony_Definition("map_*") : 0, ])); set_definition_unregistration(([ Army_Ant_Colony_Definition("map_*") : 0, ])); // Add the map extension and set it up. add_extension(LS_Extension("map"), (: // Set the base room to use. $1->set_base_room(Army_Ant_Colony_Room("Map_Base.c")); // Set the prefix the map extension should use when generating rooms. // This instance will generate rooms in the folloing format 'map_x_y_z'. eg: map_0_-2_1 $1->set_room_prefix(Army_Ant_Colony_Room("map_")); // Set the map configuration file. This is the file where you actually draw the ascii map. $1->set_map_conf(Army_Ant_Colony_Data("map.conf")); // Set the maps directionality level. Basically how many directions you want to map to use. // See /lib/map.h for all defined directionalities. $1->set_map_directionality(Map_Directionality_Basic); :)); }
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 will 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 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. // By default the access is determined by the room you're going to, but this function allows you to override that. 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. // This is so people don't see a tunnel above or below this tunnel, since there's supposed to be earth // between them. You can of course accomplish all this with an actual whole Z axis between tunnels, but // that would require twice as many Z axises. set_map_feature_adjacency_suppression(({ Direction_Up, Direction_Down })); }
I would recommend looking in /lib/map.h for the different types of Map_Access_* that are available. Also good is /lib/terrains.h to see what types of terrains are available to use. Look at other area definition files for more examples of different types of terrains. I learned a lot from looking at the Hanoma, Liathyr, and River Tethys areas.
Map_Feature_Type_Overlay
Here is where the detail goes into your map. You can use overlays to place descriptions, abstract items, content, etc into rooms.
Here is an example of an overlay I used for adding mushroom patches to some of the rooms.
#include <Army_Ant_Colony.h> #include <room.h> inherit Army_Ant_Colony_Definition("Map_Overlay_Base"); void configure() { ::configure(); set_map_feature_name("mushroom patch"); add_map_feature_contents(Army_Ant_Colony_Misc("mushroom_patch")); }
...to be continued.