Oh well I didn't consider that haha, in the example above they would be lost.
In that case, I think you can get away with a minor change extracting the item instead of dropping it on the room, but in the cases where the corpse is being carried or are inside a container no changes are made.
The code would be like this (it's a one line change from stock TBA code):
Code:
if (!GET_OBJ_TIMER(j)) {
if (j->carried_by)
act("$p decays in your hands.", FALSE, j->carried_by, j, 0, TO_CHAR);
else if ((IN_ROOM(j) != NOWHERE) && (world[IN_ROOM(j)].people)) {
act("A quivering horde of maggots consumes $p.",
TRUE, world[IN_ROOM(j)].people, j, 0, TO_ROOM);
act("A quivering horde of maggots consumes $p.",
TRUE, world[IN_ROOM(j)].people, j, 0, TO_CHAR);
}
for (jj = j->contains; jj; jj = next_thing2) {
next_thing2 = jj->next_content; /* Next in inventory */
obj_from_obj(jj);
if (j->in_obj)
obj_to_obj(jj, j->in_obj);
else if (j->carried_by)
obj_to_room(jj, IN_ROOM(j->carried_by));
else if (IN_ROOM(j) != NOWHERE)
extract_obj(jj); /* simply extract the obj <--- Change is here */
else
core_dump();
}
extract_obj(j);
}
}
But that would still make non-carried PC corpses (ie. a player died and didn't make their way back to their corpse in time) to lose their items when their corpse's timers expired.
A solution to that would be to somehow identify the corpses as being NPC or PC corpses, but that requires more changes in code and I'm not sure if it's worth or optimal though.
I would go about it like this, in fight.c look for the function make_corpse() and change this section as follows:
Code:
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))
+ if (IS_NPC(ch)) {
GET_OBJ_TIMER(corpse) = CONFIG_MAX_NPC_CORPSE_TIME;
+ GET_OBJ_VAL(corpse, 3) = 1; /* NPC corpse identifier */
- else
+ } else {
GET_OBJ_TIMER(corpse) = CONFIG_MAX_PC_CORPSE_TIME;
+ GET_OBJ_VAL(corpse, 3) = 2; /* PC corpse identifier */
+ }
That way NPC corpses will be identified with Value 3 = 1 and PC corpses would be Value 3 = 2.
(It says 3 in there but it's the 4th value, the count starts from 0, remember that! lol)
Then in the point_update() function in limits.c you check for this value to know if an object should be dropped on the ground or left in the corpse to be thrown away:
Code:
if (!GET_OBJ_TIMER(j)) {
if (j->carried_by)
act("$p decays in your hands.", FALSE, j->carried_by, j, 0, TO_CHAR);
else if ((IN_ROOM(j) != NOWHERE) && (world[IN_ROOM(j)].people)) {
act("A quivering horde of maggots consumes $p.",
TRUE, world[IN_ROOM(j)].people, j, 0, TO_ROOM);
act("A quivering horde of maggots consumes $p.",
TRUE, world[IN_ROOM(j)].people, j, 0, TO_CHAR);
}
for (jj = j->contains; jj; jj = next_thing2) {
next_thing2 = jj->next_content; /* Next in inventory */
obj_from_obj(jj);
if (j->in_obj)
obj_to_obj(jj, j->in_obj);
else if (j->carried_by)
obj_to_room(jj, IN_ROOM(j->carried_by));
else if (IN_ROOM(j) != NOWHERE)
if (GET_OBJ_VAL(j, 3) == 2) /* PC corpse, drop objects in the room */
obj_to_room(jj, IN_ROOM(j));
else /* NPC corpse, extract obj */
extract_obj(jj);
else
core_dump();
}
extract_obj(j);
}
I won't be able to test those now so beware lol.