Hidden Doors / Search [by Joe Frohne]
Snippet Posted Wednesday, August 12th @ 11:28:28 PM, by George Greer in the Utils dept.
Added Apr 27, 1998. Click the link below to read it or download it.

From: Joe Frohne <frohne@POST.ITS.MCW.EDU>
Subject: Hidden Doors

A few people have asked about hidden doors and I have gotten so much from
the listserve and circlemud community that I figured its time to give
a little back.

Enjoy
------------------------------------------------------------------
structs.h

in the exit information section define

#define EX_HIDDEN (1 << 4)  /* exit is hidden */

act.informative.c

This is how I have my exit prompt set up...
It will show all doors that are not hidden like this

[Exits: e ^n]

void do_auto_exits(struct char_data * ch)
{
  int door;

  *buf = '\0';

  for (door = 0; door < NUM_OF_DIRS; door++)
    if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE)
      if (!IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED))
        sprintf(buf, "%s%c ", buf, LOWER(*dirs[door]));
      else
        if (!IS_SET(EXIT(ch, door)->exit_info, EX_HIDDEN))
          sprintf(buf, "%s^%c ", buf, LOWER(*dirs[door]));

  sprintf(buf2, "%s&B[ &gExits: &W%s&B]&n%s\r\n", CCCYN(ch, C_NRM),
          *buf ? buf : "None! ", CCNRM(ch, C_NRM));

  send_to_char(buf2, ch);
}

Add search command in act.informtive.c or wherever
My search command is a little raw, but functional.

ACMD(do_search)
{
  int door, chance = 1;

  *buf = '\0';

  if (IS_AFFECTED(ch, AFF_BLIND)) {
    send_to_char("You're blind, you can't see a damned thing!", ch);
    return;
  }

  send_to_char("\r\nYou begin to search the room...\r\n", ch);

  for (door = 0; door < NUM_OF_DIRS; door++) {
    if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE) {
      if (IS_SET(EXIT(ch, door)->exit_info, EX_HIDDEN)) {
        if (GET_RACE(ch) == RACE_ELF)
          chance += 1;
        if (GET_INT(ch) >= 17)
          chance += 1;
        if (number(1,6) <= chance) {
          sprintf(buf, "\r\n&WYou have found a secret door %s.&n\r\n", dirs[doo
r]);
          send_to_char(buf, ch);
          REMOVE_BIT(EXIT(ch, door)->exit_info, EX_HIDDEN);
        }
      }
    }
  }
  return;
}

act.movement.c

In perform_move add the check for EX_HIDDEN and show it same way as
no exit at all.

  else if (!EXIT(ch, dir) || EXIT(ch, dir)->to_room == NOWHERE)
    send_to_char("Alas, you cannot go that way...\r\n", ch);
  else if (IS_SET(EXIT(ch, dir)->exit_info, EX_HIDDEN) &&
           IS_SET(EXIT(ch, dir)->exit_info, EX_CLOSED))
    send_to_char("Alas, you cannot go that way...\r\n", ch);
  else if (IS_SET(EXIT(ch, dir)->exit_info, EX_CLOSED)) {
    if (EXIT(ch, dir)->keyword) {


Also:
  find_door()
  add the check for EX_HIDDEN to 2 places here, one is the last for()
  loop.  expand the if (EXIT(ch, door) to if (EXIT(ch, door) && IS_SET(
  EXIT(ch, door)->exit_info, EX_HIDDEN))

  also add it to a similar if check earlier in find_door()

interpreter.c

add the search command

ACMD(do_search);

{ "search", do_search, 0, 0,},

db.c

In db.c set the doors state.  In reset_zone() add ex_hidden stuff to this
case command.

    case 'D':                   /* set state of door */
      if (ZCMD.arg2 < 0 || ZCMD.arg2 >= NUM_OF_DIRS ||
          (world[ZCMD.arg1].dir_option[ZCMD.arg2] == NULL)) {
        ZONE_ERROR("door does not exist");
      } else
        switch (ZCMD.arg3) {
        case 0:
          REMOVE_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                     EX_LOCKED);
          REMOVE_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                     EX_CLOSED);
          REMOVE_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                     EX_HIDDEN);
          break;
        case 1:
          SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                  EX_CLOSED);
          REMOVE_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                     EX_LOCKED);
          REMOVE_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                     EX_HIDDEN);
          break;
        case 2:
          SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                  EX_LOCKED);
          SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                  EX_CLOSED);
          REMOVE_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                  EX_HIDDEN);
          break;
        case 3:
          SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                  EX_CLOSED);
          SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                  EX_HIDDEN);
          REMOVE_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                  EX_LOCKED);
          break;
        case 4:
          SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                  EX_CLOSED);
          SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                  EX_LOCKED);
          SET_BIT(world[ZCMD.arg1].dir_option[ZCMD.arg2]->exit_info,
                  EX_HIDDEN);
          break;
        }
      last_cmd = 1;
      break;

In whatever olc you use, add the ability to set doors in zedit as
hidden/closed or hidden/locked.



<< Help Topic Missing! [by Samedi] | Reply | View as text | Threaded | Home Command [by Gekke] >>

 


Related Links
  CircleMUD
download
Related Articles
More by greerga
 
 

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.