Object Saving - Player File Question

  • Mudcraft
  • Topic Author
  • Offline
  • New Member
  • New Member
3 years 1 month ago #7803 by Mudcraft
Object Saving - Player File Question was created by Mudcraft

Having lots fun with the TBA code base and would also like to say hello along with the other new people to the site, it's so nice to see a codebase that is still supported and people still interested in mudding, many years ago spent my time on ROM and choose this for a new project, I have converted a few of my old zones and fitted them into the areas and started to on cosmetic changes first, my question pertains to PC death and how it saves the object file (or not in my case) I am using TBA 2018.1 and want to retain the objects on a PC up-to level 5 (no corpse hunting either) so I thought a few tweaks to make corpse, change a few lines in handler.c and all done.

All well and good, the PC corpse is not being made in the room and the objects/equip not being removed; however when it sends the character to the main menu the object save file vanishes (NPC are not affected and all works correctly)

I have grepped the files in areas such as unequip/obj removal looked for any if checks on saving, had a look over the obj_save file; but cannot locate the issue, the log informs me that the character when logging in has no equipment, as I am not use to the rent side of circle, perhaps someone with experience with the codebase could help, there is either an obvious area of code I am missing, or it may not be as simple as I first thought.

All other saving works, object saves are working when the play quits and logs; however if it a combat related death it's a different issue.

Any help appreciated.

Kind regards,

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

3 years 1 month ago #7821 by thomas
Replied by thomas on topic Object Saving - Player File Question
Sorry it took so long to get this post approved, Mudcraft. I was AFNC (away from network coverage).

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

3 years 1 month ago #7822 by thomas
Replied by thomas on topic Object Saving - Player File Question
The object file is empty because of the call to Crash_delete_crashfile here: github.com/tbamud/tbamud/blob/168f6df908.../src/handler.c#L1009

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

3 years 3 weeks ago #7946 by Sascha
Replied by Sascha on topic Object Saving - Player File Question
This is actually a pretty nifty idea. I can see how it would be player-friendly to have eq transfer upon 'death' to the respawned character, up to a certain level. When you have this worked out to your satisfaction, would you mind sharing it as a snippet so that those who would like to use it can do so?

Taking it a step further, this would also be a great option to have when setting up game parameters, perhaps in Cedit, crash/rent save options, where we could set a level for items to transfer with the character upon death. Any of our code-savvy folks interested in taking that on?

Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000

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

3 years 2 weeks ago #7982 by WhiskyTest
Replied by WhiskyTest on topic Object Saving - Player File Question
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.
You could even specify certain items which should not be lost, eg: ITEM_QUEST

Browser code showing two examples:
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);

  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;
  GET_OBJ_VAL(corpse, 0) = 0;	/* You can't store stuff in a corpse */
  GET_OBJ_VAL(corpse, 3) = 1;	/* corpse identifier */
  GET_OBJ_RENT(corpse) = 100000;
  if (IS_NPC(ch))

+ 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));

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

1 year 1 week ago #8666 by Angarth
Replied by Angarth on topic Object Saving - Player File Question
Sorry to bump an old thread, but in case anyone is still having this issue it can be solved, in addition to WhiskyTest's suggestion, by forcing a 'save' of their profile using the Crash_rentsave function.

In fight.c within void raw_kill

+ Crash_rentsave(ch, 0); // Force a save before extracting their character, to save inventory

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

Time to create page: 0.099 seconds