adding hidden doors

Login to reply  Page: « < 1 of 1 > »
19 Feb 2010 - 20:212367
adding hidden doors
Sorry if this is already addressed; Someone was asking me how to do this so I figured I'd just post it.

In structs.h

  /* Exit info: used in room_data.dir_option.exit_info */
  #define EX_ISDOOR                (1 << 0)   /* Exit is a door                 */
  #define EX_CLOSED                (1 << 1)   /* The door is closed             */
  #define EX_LOCKED                (1 << 2)   /* The door is locked             */
  #define EX_PICKPROOF             (1 << 3)   /* Lock can't be picked           */
+ #define EX_HIDDEN                (1 << 4)   /* Door can't be seen on autoexit */

And then in redit.c

replace:

  case REDIT_EXIT_DOORFLAGS:
    number = atoi(arg);
-   if (number < 0 || number > 2) {
+   if (number < 0 || number > 4) {
      write_to_output(d, "That's not a valid choice!\r\n");
      redit_disp_exit_flag_menu(d);
    } else {
-     /* Doors are a bit idiotic, don't you think? :) -- I agree. -gg */
-     OLC_EXIT(d)->exit_info = (number == 0 ? 0 :
-		               (number == 1 ? EX_ISDOOR :
-		               (number == 2 ? EX_ISDOOR | EX_PICKPROOF : 0)));
+     if (number == 1)
+       OLC_EXIT(d)->exit_info = EX_ISDOOR;
+     else if (number == 2)
+       OLC_EXIT(d)->exit_info = EX_ISDOOR | EX_PICKPROOF;
+     else if (number == 3)
+       OLC_EXIT(d)->exit_info = EX_ISDOOR | EX_HIDDEN;
+     else if (number == 4)
+       OLC_EXIT(d)->exit_info = EX_ISDOOR | EX_HIDDEN | EX_PICKPROOF;
+     else
+       OLC_EXIT(d)->exit_info = 0;
+
      /* Jump back to the menu system. */
      redit_disp_exit_menu(d);
    }
    return;

leave the comment regarding idiot doors in if you wish, i think it still applies here. :)

then also in redit.c

  /* Weird door handling! */
- if (IS_SET(OLC_EXIT(d)->exit_info, EX_ISDOOR)) {
-   if (IS_SET(OLC_EXIT(d)->exit_info, EX_PICKPROOF))
-     strncpy(door_buf, "Pickproof", sizeof(door_buf)-1);
-   else
-     strncpy(door_buf, "Is a door", sizeof(door_buf)-1);
+   if (IS_SET(OLC_EXIT(d)->exit_info, EX_PICKPROOF))
+     if (IS_SET(OLC_EXIT(d)->exit_info, EX_HIDDEN))
+       strncpy(door_buf, "Is a hidden pickproof door.", sizeof(door_buf) - 1);
+     else
+       strncpy(door_buf, "Is a pickproof door.", sizeof(door_buf)-1);
+   else if (IS_SET(OLC_EXIT(d)->exit_info, EX_HIDDEN))
+     strncpy(door_buf, "Is a hidden door.", sizeof(door_buf)-1);
+   else
+     strncpy(door_buf, "Is a door.", sizeof(door_buf)-1);
- } else
+   else
      strncpy(door_buf, "No door", sizeof(door_buf)-1);

(That last section is not in true patch form. It deletes and readds the same lines but I think it's clear what needs to be done. If you follow it as if it were true patch form, you still won't go wrong.)

Finally, in act.informative.c

static void do_auto_exits(struct char_data *ch)
{
  int door, slen = 0;

  send_to_char(ch, "%s[ Exits: ", CCCYN(ch, C_NRM));

  for (door = 0; door < NUM_OF_DIRS; door++) {
    if (!EXIT(ch, door) || EXIT(ch, door)->to_room == NOWHERE)
      continue;
    if (EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED) && !CONFIG_DISP_CLOSED_DOORS)
      continue;
+   if (EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED) && EXIT_FLAGGED(EXIT(ch, door), EX_HIDDEN))
+     continue;
    if (EXIT_FLAGGED(EXIT(ch, door), EX_CLOSED))
      send_to_char(ch, "%s(%c)%s ", CCRED(ch, C_NRM), LOWER(*dirs[door]), CCCYN(ch, C_NRM));
    else
      send_to_char(ch, "%c ", LOWER(*dirs[door]));
    slen++;
  }

  send_to_char(ch, "%s]%s\r\n", slen ? "" : "None!", CCNRM(ch, C_NRM));
}


__________________
The Augmented Dimension 2.0
mud.themudhost.net port 5000

The Hidden Grotto
(Currently being patched up from Circle 3.0 to tba3.62)
Old version: a-d.codewarp.org 8229
Progress: http://a-d.codewarp.org/~schlittk/grotto_changelog.txt

Last edited by Kyle (19 Feb 2010 - 20:22)
Login to reply  Page: « < 1 of 1 > »