Haaru Map Extension

From LSWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 16:18, 28 May 2008 (edit)
Chaos (Talk | contribs)

← Previous diff
Current revision (12:35, 13 April 2012) (edit)
Nirnaeth (Talk | contribs)
(Reverse Engineering the Army_Ant_Colony.h)
 
Line 5: Line 5:
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'''. 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:+Here is an example of a control.c file:
#include <Army_Ant_Colony.h> #include <Army_Ant_Colony.h>
Line 35: Line 35:
// Set the prefix the map extension should use when generating rooms. // 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 // This instance will generate rooms in the folloing format 'map_x_y_z'. eg: map_0_-2_1
 + // This setting actually happens to be the same as the default.
$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. // Set the map configuration file. This is the file where you actually draw the ascii map.
Line 43: Line 44:
:)); :));
} }
 +
 +=Reverse Engineering the Army_Ant_Colony.h=
 +I see this skipped in almost every developer example/publication I've looked through, and it's fairly critical to proper function/development, and really understanding some of what is going on by reference here. To be clear, I'm not a dev on LS and I can't actually see this, so this is based on what I expect should be in this file.
 +
 + #ifndef _Army_Ant_Colony_Included
 + #define _Army_Ant_Colony_Included
 + #define Army_Ant_Colony "/d/Almeria/Cimbra/Army_Ant_Colony/"
 + #define Army_Ant_Colony_Daemon(x) (Army_Ant_Colony + "dmn/" + x)
 + #define Army_Ant_Colony_Definition(x) (Army_Ant_Colony + "def/" + x)
 + #define Army_Ant_Colony_Data(x) (Army_Ant_Colony + "dat/" + x)
 + #define Army_Ant_Colony_Room(x) (Army_Ant_Colony + "rms/" + x)
 + #define Army_Ant_Colony_Misc(x) (Army_Ant_Colony + "etc/" + x)
 + #endif
=Creating your definitions= =Creating your definitions=
Line 74: Line 88:
add_map_feature_realm("Army_Ant_Colony_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!+ // Here you can specify what will be displayed for this room when using the map tool. VERY HANDY!
set_map_feature_visualize("{{red}t}"); set_map_feature_visualize("{{red}t}");
Line 82: Line 96:
add_map_feature_description( add_map_feature_description(
"This is a tunnel made from {{yellow}sand} and {{brown}mud}. The walls have large gash marks " "This is 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 "+ "in them where it seems as though something or someone has dug its way through the "
"earth." "earth."
); );
Line 122: Line 136:
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. 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==
Line 142: Line 155:
...to be continued. ...to be continued.
 +
 +[[category: Coding Class]]

Current revision

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 example 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
        // This setting actually happens to be the same as the default.
        $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);
    :));
}

Reverse Engineering the Army_Ant_Colony.h

I see this skipped in almost every developer example/publication I've looked through, and it's fairly critical to proper function/development, and really understanding some of what is going on by reference here. To be clear, I'm not a dev on LS and I can't actually see this, so this is based on what I expect should be in this file.

#ifndef _Army_Ant_Colony_Included
  #define _Army_Ant_Colony_Included
  #define Army_Ant_Colony               "/d/Almeria/Cimbra/Army_Ant_Colony/"
  #define Army_Ant_Colony_Daemon(x)     (Army_Ant_Colony + "dmn/" + x)
  #define Army_Ant_Colony_Definition(x) (Army_Ant_Colony + "def/" + x)
  #define Army_Ant_Colony_Data(x)       (Army_Ant_Colony + "dat/" + x)
  #define Army_Ant_Colony_Room(x)       (Army_Ant_Colony + "rms/" + x)
  #define Army_Ant_Colony_Misc(x)       (Army_Ant_Colony + "etc/" + x)
#endif

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 specify 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(
        "This is 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 its 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.

Personal tools