Welcome to the Builder Academy

Question Moving corpse on death

More
12 Jun 2012 03:58 #48 by Vatiken
Replied by Vatiken on topic Re: Moving corpse on death
I had a whole big post written explaining everything in detail then I accidentally hit Ctrl+DESTROY-EVERYTHING, and so much for that.

Basically, you supply a vnum through cedit for a start room, 3001 I believe. In db.c there is a function called real_room() used to turn that VIRTUAL NUMBER(vnum) into a REAL_NUMBER(rnum). Your make_corpse() function uses an rnum(REAL NUMBER) to place the corpse in:
Code:
obj_to_room(OBJECT, REAL_NUMBER);

So, all you should need to do is supply a VNUM, turn it into an RNUM, and use obj_to_room() to place the corpse in that room.

tbaMUD developer/programmer

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

More
12 Jun 2012 17:06 #53 by Halenbane
Ok so basically I have taken the last few hours digging around to add this in. I have added it to cedit and other areas. I am not sure where I'm missing my define, so I will post what changes I have made, and then my error. Maybe you can make some sense of it. It's probably something I'm simply overlooking.

First the Error

fight.c:316: warning: implicit declaration of function 'MORTAL_CORPSE_ROOM'

Line 316 - obj_to_room(corpse, MORTAL_CORPSE_ROOM(ch));

Code Below

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 */
+ }

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

More
13 Jun 2012 01:01 #55 by Vatiken
Replied by Vatiken on topic Re: Moving corpse on death
From the look of your code, what you should have is:
Code:
obj_to_room(obj, r_mortal_corpse_room);
Everything else looks pretty good, although I think you may of done more work then you needed to. My previous message was my attempt to try and explain the difference between RNUM and VNUM (I was confused about this system way back when), and how to use the system to get the result you need.

Something like this in fight.c probably would of sufficed:
Code:
#define CORPSE_ROOM 1111 /* Corpse Room VNUM */ ... void make_corpse() { ... room_rnum corpse_room; ... if ((corpse_room = real_room(CORPSE_ROOM)) != NOWHERE) obj_to_room(obj, corpse_room); /* Our corpse room exists, place the corpse there */ else obj_to_room(obj, IN_ROOM(ch)); /* Hmmm... missing the corpse room, just place the corpse where we died. */

That said, the way you went about it does have the added benefit of being able to be adjusted in-game if necessary without re-compiling the MUD.

tbaMUD developer/programmer

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

More
13 Jun 2012 01:24 #57 by Halenbane
Yeah, I figured if I was going to have the option I wanted it in cedit. I edited fight.c changing the line to:

obj_to_room(corpse, r_mortal_corpse_room);

It now works fine. No problems , clean compile. Tested and I see no issues.

I'll put it up for others to use if any may find use of it. Thanks for the direction :D

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

More
13 Jun 2012 13:56 #67 by Halenbane
I didn't notice this before, but it seems that npc corpse also go to the mortal_corpse_room.

Any ideas?

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

More
13 Jun 2012 18:52 #69 by Halenbane
After looking at it for a second I found it was easier than I thought to fix this.

Forgot an if statement to differ the two

in fight.c

ch->carrying = NULL;
IS_CARRYING_N(ch) = 0;
IS_CARRYING_W(ch) = 0;
+if (IS_NPC(ch))
+ obj_to_room(corpse, IN_ROOM(ch));
+else
obj_to_room(corpse, r_mortal_corpse_room);
}

I'll update my snippet accordingly

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

Time to create page: 0.455 seconds