Varea system example, different way to do area

Varea system example, different way to do area

Postby Suhis » 08.07.2011 18:08:48

with this system you can make your area rooms fit in 1 file and it handles exits automaticly.

room numbers are counted from up left corner like we read text.

filename: varea_d.c
Code: Select all
#include <mudlib.h>
#include <varea.h>

inherit VAREA;

void reset(status arg)
{
  ::reset(arg);
//special exits, normal exits are handled by maps
  add_exit("<P>room_0_0", "enter");
}

int process_message( int msg, mapping rdata )
{
  ::process_message(msg, rdata);

  switch( msg )
  {
    case R_CREATE:   PCALL("create_" + LAYER, rdata); break;
    case R_RESET:    break;
    case R_INIT:    PCALL("init_" + LAYER, rdata); break;
    default:
  }
  return 1;
}

//things which can be done in different rooms
void init_room( mapping rdata )
{
  switch( ID )
  {
   //in room 0_0 you can use pull or pull2 commands
    case "room_0_0":
      OBJ -> vadd_action("pull");   
      OBJ -> vadd_action("pull", "pull2");
      break;
    case "room_0_1":
      OBJ -> vadd_action("secret");   
      break;
    default:
  }
}

//room descs, etc most of the things can be used here that can be used in normal rooms
void create_room( mapping rdata )
{
  switch( ID )
  {
    case "room_0_0":
      OBJ -> set_short("Entrance");
      OBJ -> set_long("type 'pull rope'");
      break;
    case "room_0_1":
      OBJ -> set_short("Room");
      OBJ -> set_long("type 'secret'");
      break;
    case "room_1_0":
      OBJ -> set_short("Secret room");
      OBJ -> set_long("Secret room");
      OBJ -> add_exit("<P>room_0_1", "out");
      break;
    default:
  }
}
//what happens in room if you pull
status vcmd_pull(string arg, mapping rdata)
{
  if(arg == "rope")
  {
    write("You pull the rope lightly and the bell chimes loudly. \n");
    return 1;
  }

  write("Pull what?\n");
  return 1;
}
//what happens in room if you type secret
status vcmd_secret(string arg, mapping rdata)
{
  move_object( this_player(), "VA:/vareas/examples/sample3/room_1_0" );
  return 1;
}



and map file: varea.map 
Code: Select all
;comment line
;
[room]
R R
|
R
[end]
Suhis
 
Posts: 180
Joined: 31.01.2004 13:31:16

Return to Manuals

Who is online

Users browsing this forum: No registered users and 1 guest

cron