Welcome to the Builder Academy

Question Help with older snippet - dedicated Corpse Room - Mostly Working small glitch

More
24 May 2025 00:18 #10712 by wlessard1
I found this snippet on Circlemud repository and finally got around to working it into my mud. This is not a mud that will be online just me puttering around and I am not a programmer so I am not sure where to look.

Anyways it works almost perfectly. What I am trying to figure out is how to keep the PC corpse going to the room but the NPC corpse to stay where it is killed. That is the problem I have the NPC corpses are going to the corpse room. If you can help appreciate but since it is not going public, it isn't like I can't just work around it. 

Thanks for any help, much appreciated for everything here anyways. Love the coding and mud base.

*************************************************************
* USE THIS TO MAKE PLAYER CORPSES SPAWN TO A SPECIFIED ROOM *
* IF YOU HAVE ANY TROUBLE FEEL FREE TO CONTACT ME AT        *
* Halenbane@gmail.com.                                      *
*************************************************************


In DB.C

room_rnum r_mortal_start_room;  /* rnum of mortal start room    */
room_rnum r_immort_start_room;  /* rnum of immort start room    */
room_rnum r_frozen_start_room;  /* rnum of frozen start room    */
+room_rnum r_mortal_corpse_room; /* rnum of mortal corpse room    */


static void check_start_rooms(void)
{
  if ((r_mortal_start_room = real_room(CONFIG_MORTAL_START)) == NOWHERE) {
    log("SYSERR:  Mortal start room does not exist.  Change in config.c.");
    exit(1);
  }
  if ((r_immort_start_room = real_room(CONFIG_IMMORTAL_START)) == NOWHERE) {
    if (!mini_mud)
      log("SYSERR:  Warning: Immort start room does not exist.  Change in config.c.");
    r_immort_start_room = r_mortal_start_room;
  }
  if ((r_frozen_start_room = real_room(CONFIG_FROZEN_START)) == NOWHERE) {
    if (!mini_mud)
      log("SYSERR:  Warning: Frozen start room does not exist.  Change in config.c.");
    r_frozen_start_room = r_mortal_start_room;
  }
+ if ((r_mortal_corpse_room = real_room(CONFIG_MORTAL_CORPSE)) == NOWHERE) {
+  if (!mini_mud)
+    log("SYSERR: Mortal corpse room does not exist. Change in config.c.");
+  r_mortal_corpse_room = r_mortal_start_room;
+  }
+}






  /* Room numbers. */
  CONFIG_MORTAL_START          = mortal_start_room;
  CONFIG_IMMORTAL_START        = immort_start_room;
  CONFIG_FROZEN_START          = frozen_start_room;
+ CONFIG_MORTAL_CORPSE          = mortal_corpse_room;

  CONFIG_DON_ROOM_1            = donation_room_1;
  CONFIG_DON_ROOM_2            = donation_room_2;
  CONFIG_DON_ROOM_3            = donation_room_3;


          strncpy(buf, "Reading menu in load_config()", sizeof(buf));
          CONFIG_MENU = fread_string(fl, buf);
          parse_at(CONFIG_MENU);
        } else if (!str_cmp(tag, "min_rent_cost"))
          CONFIG_MIN_RENT_COST = num;
        else if (!str_cmp(tag, "min_wizlist_lev"))
          CONFIG_MIN_WIZLIST_LEV = num;
        else if (!str_cmp(tag, "mortal_start_room"))
          CONFIG_MORTAL_START = num;
+      else if (!str_cmp(tag, "mortal_corpse_room"))
+        CONFIG_MORTAL_CORPSE = num;
        else if (!str_cmp(tag, "map_option"))
          CONFIG_MAP = num;
        else if (!str_cmp(tag, "medit_advanced_stats"))
          CONFIG_MEDIT_ADVANCED = num;
        break;


IN CEDIT.C


  /* Room Numbers */
  OLC_CONFIG(d)->room_nums.mortal_start_room = CONFIG_MORTAL_START;
  OLC_CONFIG(d)->room_nums.immort_start_room = CONFIG_IMMORTAL_START;
  OLC_CONFIG(d)->room_nums.frozen_start_room = CONFIG_FROZEN_START;
+ OLC_CONFIG(d)->room_nums.mortal_corpse_room = CONFIG_MORTAL_CORPSE;
  OLC_CONFIG(d)->room_nums.donation_room_1  = CONFIG_DON_ROOM_1;
  OLC_CONFIG(d)->room_nums.donation_room_2  = CONFIG_DON_ROOM_2;
  OLC_CONFIG(d)->room_nums.donation_room_3  = CONFIG_DON_ROOM_3;



  /* Room Numbers */
  CONFIG_MORTAL_START = OLC_CONFIG(d)->room_nums.mortal_start_room;
  CONFIG_IMMORTAL_START = OLC_CONFIG(d)->room_nums.immort_start_room;
  CONFIG_FROZEN_START = OLC_CONFIG(d)->room_nums.frozen_start_room;
+ CONFIG_MORTAL_CORPSE = OLC_CONFIG(d)->room_nums.mortal_corpse_room;
  CONFIG_DON_ROOM_1  = OLC_CONFIG(d)->room_nums.donation_room_1;
  CONFIG_DON_ROOM_2  = OLC_CONFIG(d)->room_nums.donation_room_2;
  CONFIG_DON_ROOM_3  = OLC_CONFIG(d)->room_nums.donation_room_3;



  fprintf(fl, "* The virtual number of the room that frozen people should enter at.\n"
              "frozen_start_room = %d\n\n", CONFIG_FROZEN_START);

+  fprintf(fl, "* The virtual number of the room that corpses of dead players go to.\n"
+              "mortal_corpse_room = %d\n\n", CONFIG_MORTAL_CORPSE);

  fprintf(fl, "* The virtual numbers of the donation rooms.  Note: Add donation rooms\n"
              "* sequentially (1 & 2 before 3). If you don't, you might not be able to\n"
              "* donate. Use -1 for 'no such room'.\n"

        "Enter your choice : ",
        grn, nrm, cyn, OLC_CONFIG(d)->room_nums.mortal_start_room,
        grn, nrm, cyn, OLC_CONFIG(d)->room_nums.immort_start_room,
        grn, nrm, cyn, OLC_CONFIG(d)->room_nums.frozen_start_room,
+      grn, nrm, cyn, OLC_CONFIG(d)->room_nums.mortal_corpse_room,
        grn, nrm, cyn, OLC_CONFIG(d)->room_nums.donation_room_1,


        case 'c':
        case 'C':
        write_to_output(d, "Enter the room's vnum where frozen people should load into : ");
        OLC_MODE(d) = CEDIT_FROZEN_START_ROOM;
        return;

+      case 'd':
+      case 'D':
+      write_to_output(d, "Enter the room's vnum where mortal corpses shoul load into : ");
+      OLC_MODE(d) = CEDIT_MORTAL_CORPSE_ROOM;
+      return;




          "Enter the room's vnum where frozen people should load into : ");
      } else {
        OLC_CONFIG(d)->room_nums.frozen_start_room = atoi(arg);
        cedit_disp_room_numbers(d);
      }
      break;

+    case CEDIT_MORTAL_CORPSE_ROOM:
+      if (!*arg) {
+        write_to_output(d,
+          "That is an invalid choice!\r\n"
+          "Enter the room's vnum where mortal corpses should load into : ");
+      } else {
+        OLC_CONFIG(d)->room_nums.mortal_corpse_room = atoi(arg);
+        cedit_disp_room_numbers(d);
+      }
+      break;


IN CONFIG.C

/* Virtual number of room that frozen players should enter at. */
room_vnum frozen_start_room = 1202;

+/* Virtual number of room that player corpse should load into */
+room_vnum mortal_corpse_room = 3085;


IN UTILS.H

/* Room Numbers */
/** Get the mortal start room. */
#define CONFIG_MORTAL_START    config_info.room_nums.mortal_start_room
/** Get the immortal start room. */
#define CONFIG_IMMORTAL_START  config_info.room_nums.immort_start_room
/** Get the frozen character start room. */
#define CONFIG_FROZEN_START    config_info.room_nums.frozen_start_room
/** Get the mortal corpse room. */
+#define CONFIG_MORTAL_CORPSE    config_info.room_nums.mortal_corpse_room
+/** Get the 1st donation room. */
#define CONFIG_DON_ROOM_1      config_info.room_nums.donation_room_1
/** Get the second donation room. */


IN STRUCTS.H

struct room_numbers
{
  room_vnum mortal_start_room; /**< vnum of room that mortals enter at.  */
  room_vnum immort_start_room; /**< vnum of room that immorts enter at.  */
  room_vnum frozen_start_room; /**< vnum of room that frozen ppl enter.  */
+ room_vnum mortal_corpse_room; /** < vnum of room that corpse is placed. */
  room_vnum donation_room_1; /**< vnum of donation room #1.            */
  room_vnum donation_room_2; /**< vnum of donation room #2.            */
  room_vnum donation_room_3; /**< vnum of donation room #3.            */
};


IN OASIS.H

#define CEDIT_MORTAL_START_ROOM        40
#define CEDIT_IMMORT_START_ROOM        41
#define CEDIT_FROZEN_START_ROOM        42
+#define CEDIT_MORTAL_CORPSE_ROOM        43
#define CEDIT_DONATION_ROOM_1          44

**Be sure to remember to fix the numbers**


IN DB.H

/* Mud configurable variables */
extern int no_mail;
extern int mini_mud;
extern int no_rent_check;
extern time_t boot_time;
extern int circle_restrict;
extern room_rnum r_mortal_start_room;
extern room_rnum r_immort_start_room;
extern room_rnum r_frozen_start_room;
+extern room_rnum r_mortal_corpse_room;


IN CONFIG.H

/* Room Numbers */
extern room_vnum mortal_start_room;
extern room_vnum immort_start_room;
extern room_vnum frozen_start_room;
+extern room_vnum mortal_corpse_room;
extern room_vnum donation_room_1;


IN GENWLD.C

  /* Update the loadroom table. Adds 1 or 0. */
  r_mortal_start_room += (r_mortal_start_room >= found);
  r_immort_start_room += (r_immort_start_room >= found);
  r_frozen_start_room += (r_frozen_start_room >= found);
+ r_mortal_corpse_room += (r_mortal_corpse_room >= found);



  if (r_frozen_start_room == rnum) {
    log("WARNING: GenOLC: delete_room: Deleting frozen start room!");
    r_frozen_start_room = 0;    /* The Void */
  }
+ if (r_mortal_corpse_room == rnum) {
+  log("WARNING: GenOLC: delete_room: Deleting mortal corpse room!");
+  r_mortal_corpse_room = 0;    /* The Void */
+ }


IN FIGHT.C

  /* transfer gold */
  if (GET_GOLD(ch) > 0) {
    /* following 'if' clause added to fix gold duplication loophole. The above
    * line apparently refers to the old "partially log in, kill the game
    * character, then finish login sequence" duping bug. The duplication has
    * been fixed (knock on wood) but the test below shall live on, for a
    * while. -gg 3/3/2002 */
    if (IS_NPC(ch) || ch->desc) {
      money = create_money(GET_GOLD(ch));
      obj_to_obj(money, corpse);
    }
    GET_GOLD(ch) = 0;
  }
    ch->carrying = NULL;
  IS_CARRYING_N(ch) = 0;
  IS_CARRYING_W(ch) = 0;
  if (IS_NPC(ch))
  -  obj_to_room(corpse, IN_ROOM(ch));
  + obj_to_room(corpse, r_mortal_corpse_room); /* halwork <--This was a bugger - Halenbane */
}

The last one had to be changed, removed the else statement and cleaned up the line.

Please Log in or Create an account to join the conversation.

More
29 May 2025 19:37 #10730 by thomas
Not sure I understand your solution.

I would assume the code should look like this:
Code:
if (IS_NPC(ch)) obj_to_room(corpse, IN_ROOM(ch)); else obj_to_room(corpse, r_mortal_corpse_room);
Otherwise, all corpses go to the mortal_corpse_room.
The following user(s) said Thank You: wlessard1

Please Log in or Create an account to join the conversation.

More
29 May 2025 20:37 #10735 by wlessard1
I was working on it earlier this week. Looking at other code that was similar and I actually came to that coding setup with the If Else.

Thank you very much though for the response and help.

Please Log in or Create an account to join the conversation.

Time to create page: 0.212 seconds