|
Adding exits to bpl15 [by Peter Ajamian] |
|
|
|
Posted Saturday, August 28th @ 07:30:35 AM, by George Greer in the Rooms dept.
Peter Ajamian writes,
"The following is a snippet I did to source which is not stock.
While the directions are general enough to apply to just about
any bpl15 source (I have even gotten it to work on a bpl14 source),
you may have to tweak with things some in order to get it to work.
If you have problems implementing the snippet send me an email
and I'll be glad to help you in any way I can..."
There is a slight complication when adding directions such
as northwest, southeast, etc. You have to account for
two possible commands being entered, the player may enter
northwest, or (s)he may just enter nw. This accountability
adds a significant amount of extra coding to add these directions.
In constants.c:
- find the entry for const char *dirs[] and add the following to the end of the list (right before the "\n" entry)...
"northwest",
"northeast",
"southeast",
"southwest",
"in",
"out",
- directly following the char *dirs[] entry create a new array as follows...
const char *abbr_dirs[] =
{
"n",
"e",
"s",
"w",
"u",
"d",
"nw",
"ne",
"se",
"sw",
"in",
"out",
"\n"
};
Find the array int rev_dir[] delete the whole thing and replace it with the following...
int rev_dir[] =
{
/* North */ SOUTH,
/* East */ WEST,
/* South */ NORTH,
/* West */ EAST,
/* Up */ DOWN,
/* Down */ UP,
/* NW */ SOUTHEAST,
/* NE */ SOUTHWEST,
/* SE */ NORTHWEST,
/* SW */ NORTHEAST,
/* In */ OUT,
/* Out */ IN
};
In constants.h:
- find the following line...
extern const char *dirs[];
- immediately following it add...
extern const char *abbr_dirs[];
In structs.h:
- Find the #defines for NORTH, SOUTH, etc... and add the following after DOWN...
#define NORTHWEST 6
#define NORTHEAST 7
#define SOUTHEAST 8
#define SOUTHWEST 9
#define IN 10
#define OUT 11
- find the following line...
#define NUM_OF_DIRS 6 /* number of directions in a room (nsewud) */
- and change it to...
#define NUM_OF_DIRS 12 /* number of directions in a room (nsewud) */
In interpreter.h:
- find the #defines for SCMD_NORTH, SCMD_SOUTH, etc. After SCMD_DOWN add the following...
#define SCMD_NW 7
#define SCMD_NE 8
#define SCMD_SE 9
#define SCMD_SW 10
#define SCMD_IN 11
#define SCMD_OUT 12
In interpreter.c:
- find the entries for "north", "south", etc. in the command table. After the entry for "down" add the following...
{ "northwest", POS_STANDING, do_move , 0, SCMD_NW },
{ "nw" , POS_STANDING, do_move , 0, SCMD_NW },
{ "northeast", POS_STANDING, do_move , 0, SCMD_NE },
{ "ne" , POS_STANDING, do_move , 0, SCMD_NE },
{ "southeast", POS_STANDING, do_move , 0, SCMD_SE },
{ "se" , POS_STANDING, do_move , 0, SCMD_SE },
{ "southwest", POS_STANDING, do_move , 0, SCMD_SW },
{ "sw" , POS_STANDING, do_move , 0, SCMD_SW },
{ "in" , POS_STANDING, do_move , 0, SCMD_IN },
{ "out" , POS_STANDING, do_move , 0, SCMD_OUT },
in act.informative.c:
- In the function do_auto_exits find the following line...
slen += sprintf(buf + slen, "%c ", LOWER(*dirs[door]));
- and replace it with...
slen += sprintf(buf + slen, "%s ", abbr_dirs[door]);
- In ACMD(do_exits) find...
sprintf(buf2, "%-5s - [%5d] %s\r\n", dirs[door],
- and replace it with...
sprintf(buf2, "%-5s - [%9d] %s\r\n", dirs[door],
- also find...
sprintf(buf2, "%-5s - ", dirs[door]);
- and replace it with...
sprintf(buf2, "%-9s - ", dirs[door]);
- In ACMD(do_look) find...
/* did the char type 'look ?' */
else if ((look_type = search_block(arg, dirs, FALSE)) >= 0)
look_in_direction(ch, look_type);
- and replace it with the following (note do NOT try to optimize this by making it a single if statement with the two comparisons joined by ||)...
/* did the char type 'look ?' */
else if ((look_type = search_block(arg, dirs, FALSE)) >= 0)
look_in_direction(ch, look_type);
else if ((look_type = search_block(arg, abbr_dirs, FALSE)) >= 0)
look_in_direction(ch, look_type);
In act.movement.c:
- In the function find_door find...
if ((door = search_block(dir, dirs, FALSE)) == -1) { /* Partial Match */
- and replace it with the following two lines (re-indent the lines after as appropriate, do NOT try to optimize by using a single if statement)...
if ((door = search_block(dir, dirs, FALSE)) == -1) /* Partial Match */
if ((door = search_block(dir, abbr_dirs, FALSE)) == -1) {
In house.c:
- In the function hcontrol_build_house find...
if ((exit_num = search_block(arg1, dirs, FALSE)) < 0) {
- and replace it with the following lines (again, do NOT optimize)...
if ((exit_num = search_block(arg1, dirs, FALSE)) < 0)
if ((exit_num = search_block(arg1, abbr_dirs, FALSE)) < 0) {
********** Do the following if you have Oasis OLC installed...***********
This is based on the version of Oasis OLC that comes with DG-Scripts pl7a...
In redit.c:
- In the function redit_disp_menu find...
sprintf(buf,
#if defined(CLEAR_SCREEN)
"^[[H^[[J"
#endif
"-- Room number : [%s%d%s] Room zone: [%s%d%s]\r\n"
"%s1%s) Name : %s%s\r\n"
"%s2%s) Description :\r\n%s%s"
"%s3%s) Room flags : %s%s\r\n"
"%s4%s) Sector type : %s%s\r\n"
"%s5%s) Exit north : %s%d\r\n"
"%s6%s) Exit east : %s%d\r\n"
"%s7%s) Exit south : %s%d\r\n"
"%s8%s) Exit west : %s%d\r\n"
"%s9%s) Exit up : %s%d\r\n"
"%sA%s) Exit down : %s%d\r\n"
"%sB%s) Extra descriptions menu\r\n"
"%sS%s) Script : %s%s\r\n"
"%sQ%s) Quit\r\n"
"Enter choice : ",
cyn, OLC_NUM(d), nrm,
cyn, zone_table[OLC_ZNUM(d)].number, nrm,
grn, nrm, yel, room->name,
grn, nrm, yel, room->description,
grn, nrm, cyn, buf1,
grn, nrm, cyn, buf2,
grn, nrm, cyn,
room->dir_option[NORTH] && room->dir_option[NORTH]->to_room != -1
?
world[room->dir_option[NORTH]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[EAST] && room->dir_option[EAST]->to_room != -1 ?
world[room->dir_option[EAST]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[SOUTH] && room->dir_option[SOUTH]->to_room != -1
?
world[room->dir_option[SOUTH]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[WEST] && room->dir_option[WEST]->to_room != -1 ?
world[room->dir_option[WEST]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[UP] && room->dir_option[UP]->to_room != -1 ?
world[room->dir_option[UP]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[DOWN] && room->dir_option[DOWN]->to_room != -1 ?
world[room->dir_option[DOWN]->to_room].number : -1,
grn, nrm,
grn, nrm, cyn, room->proto_script?"Set.":"Not Set.",
grn, nrm
);
- and replace the whole mess with...
sprintf(buf,
#if defined(CLEAR_SCREEN)
"^[[H^[[J"
#endif
"-- Room number : [%s%d%s] Room zone: [%s%d%s]\r\n"
"%s1%s) Name : %s%s\r\n"
"%s2%s) Description :\r\n%s%s"
"%s3%s) Room flags : %s%s\r\n"
"%s4%s) Sector type : %s%s\r\n"
"%s5%s) Exit north : %s%6d %sB%s) Exit northwest : %s%d\r\n"
"%s6%s) Exit east : %s%6d %sC%s) Exit northeast : %s%d\r\n"
"%s7%s) Exit south : %s%6d %sD%s) Exit southeast : %s%d\r\n"
"%s8%s) Exit west : %s%6d %sE%s) Exit southwest : %s%d\r\n"
"%s9%s) Exit up : %s%6d %sF%s) Exit in : %s%d\r\n"
"%sA%s) Exit down : %s%6d %sG%s) Exit out : %s%d\r\n"
"%sH%s) Extra descriptions menu\r\n"
"%sS%s) Script : %s%s\r\n"
"%sQ%s) Quit\r\n"
"Enter choice : ",
cyn, OLC_NUM(d), nrm,
cyn, zone_table[OLC_ZNUM(d)].number, nrm,
grn, nrm, yel, room->name,
grn, nrm, yel, room->description,
grn, nrm, cyn, buf1,
grn, nrm, cyn, buf2,
grn, nrm, cyn,
room->dir_option[NORTH] && room->dir_option[NORTH]->to_room != -1
?
world[room->dir_option[NORTH]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[NORTHWEST] &&
room->dir_option[NORTHWEST]->to_room != -1
?
world[room->dir_option[NORTHWEST]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[EAST] && room->dir_option[EAST]->to_room != -1 ?
world[room->dir_option[EAST]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[NORTHEAST] &&
room->dir_option[NORTHEAST]->to_room != -1 ?
world[room->dir_option[NORTHEAST]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[SOUTH] && room->dir_option[SOUTH]->to_room != -1
?
world[room->dir_option[SOUTH]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[SOUTHEAST] &&
room->dir_option[SOUTHEAST]->to_room
!= -1 ? world[room->dir_option[SOUTHEAST]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[WEST] && room->dir_option[WEST]->to_room != -1 ?
world[room->dir_option[WEST]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[SOUTHWEST] &&
room->dir_option[SOUTHWEST]->to_room != -1
?
world[room->dir_option[SOUTHWEST]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[UP] && room->dir_option[UP]->to_room != -1 ?
world[room->dir_option[UP]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[IN] && room->dir_option[IN]->to_room != -1 ?
world[room->dir_option[IN]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[DOWN] && room->dir_option[DOWN]->to_room != -1 ?
world[room->dir_option[DOWN]->to_room].number : -1,
grn, nrm, cyn,
room->dir_option[OUT] && room->dir_option[OUT]->to_room != -1 ?
world[room->dir_option[OUT]->to_room].number : -1,
grn, nrm,
grn, nrm, cyn, room->proto_script?"Set.":"Not Set.",
grn, nrm
);
- in the function redit_parse find the following...
case 'a':
case 'A':
OLC_VAL(d) = DOWN;
redit_disp_exit_menu(d);
break;
- and directly following it add...
case 'b':
case 'B':
OLC_VAL(d) = NORTHWEST;
redit_disp_exit_menu(d);
break;
case 'c':
case 'C':
OLC_VAL(d) = NORTHEAST;
redit_disp_exit_menu(d);
break;
case 'd':
case 'D':
OLC_VAL(d) = SOUTHEAST;
redit_disp_exit_menu(d);
break;
case 'e':
case 'E':
OLC_VAL(d) = SOUTHWEST;
redit_disp_exit_menu(d);
break;
case 'f':
case 'F':
OLC_VAL(d) = IN;
redit_disp_exit_menu(d);
break;
case 'g':
case 'G':
OLC_VAL(d) = OUT;
redit_disp_exit_menu(d);
break;
- also find the following...
case 'b':
case 'B':
/*
* If the extra description doesn't exist.
*/
- and replace it with...
case 'h':
case 'H':
/*
* If the extra description doesn't exist.
*/
********** Do the following if you have DG-Scripts installed...***********
Based on DG-Scripts pl7a...
In dg_mobcmd.c:
- Find the following line...
extern const char *dirs[];
- directly following it add...
extern const char *abbr_dirs[];
- In ACMD(do_mdoor) find...
if ((dir = search_block(direction, dirs, FALSE)) == -1) {
- and replace it with...
if ((dir = search_block(direction, dirs, FALSE)) == -1)
if ((dir = search_block(direction, abbr_dirs, FALSE)) == -1) {
In dg_objcmd.c:
- find the following line...
extern const char *dirs[];
- and following it add...
extern const char *abbr_dirs[];
- In OCMD(do_odoor) find...
if ((dir = search_block(direction, dirs, FALSE)) == -1) {
- and replace it with...
if ((dir = search_block(direction, dirs, FALSE)) == -1)
if ((dir = search_block(direction, abbr_dirs, FALSE)) == -1) {
In dg_wldcmd.c:
- find the following line...
extern const char *dirs[];
- and following it add...
extern const char *abbr_dirs[];
- In WCMD(do_wdoor) find...
if ((dir = search_block(direction, dirs, FALSE)) == -1) {
- and replace it with the following...
if ((dir = search_block(direction, dirs, FALSE)) == -1)
if ((dir = search_block(direction, abbr_dirs, FALSE)) == -1) {
In dg_scripts.c:
- In the function find_replacement find...
} else if (!str_cmp(field, "down")) {
if (r->dir_option[DOWN])
sprintbit(r->dir_option[DOWN]->exit_info ,exit_bits, str);
else
*str = '\0';
- immediately following it add...
} else if ((!str_cmp(field, "northwest")) || (!str_cmp(field, "nw")))
{
if (r->dir_option[NORTHWEST])
sprintbit(r->dir_option[NORTHWEST]->exit_info ,exit_bits, str);
else
*str = '\0';
} else if ((!str_cmp(field, "northeast")) || (!str_cmp(field, "ne")))
{
if (r->dir_option[NORTHEAST])
sprintbit(r->dir_option[NORTHEAST]->exit_info ,exit_bits, str);
else
*str = '\0';
} else if ((!str_cmp(field, "southeast")) || (!str_cmp(field, "se")))
{
if (r->dir_option[SOUTHEAST])
sprintbit(r->dir_option[SOUTHEAST]->exit_info ,exit_bits, str);
else
*str = '\0';
} else if ((!str_cmp(field, "southwest")) || (!str_cmp(field, "sw")))
{
if (r->dir_option[SOUTHWEST])
sprintbit(r->dir_option[SOUTHWEST]->exit_info ,exit_bits, str);
else
*str = '\0';
} else if (!str_cmp(field, "in")) {
if (r->dir_option[IN])
sprintbit(r->dir_option[IN]->exit_info ,exit_bits, str);
else
*str = '\0';
} else if (!str_cmp(field, "out")) {
if (r->dir_option[OUT])
sprintbit(r->dir_option[OUT]->exit_info ,exit_bits, str);
else
*str = '\0';
In dg_triggers.c:
- In the function greet_mtrigger find...
int rev_dir[] = { SOUTH, WEST, NORTH, EAST, DOWN, UP };
- and replace it with...
extern int rev_dir[];
In the function enter_wtrigger find...
int rev_dir[] = { SOUTH, WEST, NORTH, EAST, DOWN, UP };
- and replace it with...
extern int rev_dir[];
AFAIK those are all the places that need to be changed in order to make the additonal directions
work, but in case I left something out or you have other patches in your code that need to be
changed, try grepping the source for the following key words and looking in that vicinity to make
further changes...
dirs NORTH north NUM_OF_DIRS rev_dir SCMD_NORTH
Regards,
Peter
<< Object Surprise! Mob appears and attacks player! [by John Melvin III] | Reply | View as text | Flattened | FTP Uploads 1999/08/29 >> |
|
Related Links |
|
|
|
CircleMUD Snippets |
|
|
Note: Not all of these snippets will work perfectly with
your version of code, so be prepared to fix one
or two bugs that may arise, and please let me know
what you needed to do to fix it. Sending a corrected
version is always welcome.
|
Finally, if you wish to use any of the snippets from this
page, you are more than welcome, just mention the
authors in your credits. If you wish to release any
of these snippets to the public on another site,
contact me FIRST.
|
|
|
|
|
|
|