Welcome to the Builder Academy

Question Change corpse location upon player death.

More
13 Jun 2012 01:34 - 13 Jun 2012 18:54 #58 by Halenbane
Hey Everyone,

A good many of my players are new to mudding, and are really enjoying the exploration aspect of the game, but they get disheartened when they die , and are not able to make it back to their corpse. This snippet will allow you to set a room where player corpses will go when they die. Very similar to mortal_start_room. This isn't for everyone, but maybe a few of you will benefit from it. Thanks Vatiken for a nudge in the right direction here and there. *Mutters about fight.c*

I'm not the best tutorial maker, I just tried to keep track of things as I went along. You will notice I don't have numerical line locations , but that is mostly because I'm modified to the point it wouldn't do you much good.

If you have any questions at all, I will do my best to help.

SNIP

----

Code:
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)); else obj_to_room(corpse, r_mortal_corpse_room); /* halwork */ } + obj_to_room(corpse, r_mortal_corpse_room); /* <--This was a bugger - Halenbane */ }
Last edit: 13 Jun 2012 18:54 by Halenbane. Reason: Updated obj_to_room in fight.c

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

More
13 Jun 2012 18:59 #70 by rudeboyrave
Be sure to make a way for corpses to save, in case of crash or reboot!

CyberASSAULT
www.cyberassault.org
cyberassault.org 11111
A post-apocalyptic, sci-fi MUD.

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

Time to create page: 0.286 seconds