make_corpse() in Fight.C is where all the equipment gets moved from the dying character to the corpse.
You can encapsulate that part with an if IS_NPC bracket to prevent players losing their gear.
Code:
static void make_corpse(struct char_data *ch)
{
char buf2[MAX_NAME_LENGTH + 64];
struct obj_data *corpse, *o;
struct obj_data *money;
int i, x, y;
corpse = create_obj();
corpse->item_number = NOTHING;
IN_ROOM(corpse) = NOWHERE;
corpse->name = strdup("corpse");
snprintf(buf2, sizeof(buf2), "The corpse of %s is lying here.", GET_NAME(ch));
corpse->description = strdup(buf2);
snprintf(buf2, sizeof(buf2), "the corpse of %s", GET_NAME(ch));
corpse->short_description = strdup(buf2);
GET_OBJ_TYPE(corpse) = ITEM_CONTAINER;
for(x = y = 0; x < EF_ARRAY_MAX || y < TW_ARRAY_MAX; x++, y++) {
if (x < EF_ARRAY_MAX)
GET_OBJ_EXTRA_AR(corpse, x) = 0;
if (y < TW_ARRAY_MAX)
corpse->obj_flags.wear_flags[y] = 0;
}
SET_BIT_AR(GET_OBJ_WEAR(corpse), ITEM_WEAR_TAKE);
SET_BIT_AR(GET_OBJ_EXTRA(corpse), ITEM_NODONATE);
GET_OBJ_VAL(corpse, 0) = 0; /* You can't store stuff in a corpse */
GET_OBJ_VAL(corpse, 3) = 1; /* corpse identifier */
GET_OBJ_WEIGHT(corpse) = GET_WEIGHT(ch) + IS_CARRYING_W(ch);
GET_OBJ_RENT(corpse) = 100000;
if (IS_NPC(ch))
GET_OBJ_TIMER(corpse) = CONFIG_MAX_NPC_CORPSE_TIME;
else
GET_OBJ_TIMER(corpse) = CONFIG_MAX_PC_CORPSE_TIME;
+ if (IS_NPC(ch) || (!IS_NPC(ch) && GET_LEVEL(ch) > 5)) {
/* transfer character's inventory to the corpse */
corpse->contains = ch->carrying;
for (o = corpse->contains; o != NULL; o = o->next_content)
o->in_obj = corpse;
object_list_new_owner(corpse, NULL);
/* transfer character's equipment to the corpse */
for (i = 0; i < NUM_WEARS; i++)
+// add conditions to prevent losing items here
if (GET_EQ(ch, i) && !OBJ_FLAGGED(GET_EQ(ch, i), ITEM_QUEST))) {
remove_otrigger(GET_EQ(ch, i), ch);
obj_to_obj(unequip_char(ch, i), corpse);
}
/* 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;
+ }
obj_to_room(corpse, IN_ROOM(ch));
}