make_corpse

Posted by Syriac on Wed 08 Sep 2010 04:22 AM — 7 posts, 33,148 views.

#0
Howdy all, once again here to ask the pros. Here's what I'm trying to do... I have an item flag (ITEM_STORED) - and what I want it to do is not separate an object from a player when they die. I traced that back to make_corpse where it separates objects and puts them in the corpse but I have had no success trying to make it pass over items with this flag - here is what I have currently.


    for ( obj = ch->first_carrying; obj; obj = obj_next )
    {
        obj_next = obj->next_content;

        obj_from_char( obj );

        if (IS_OBJ_STAT(obj, ITEM_STORED))
            break;

        if ( IS_NPC(ch) && (IS_OBJ_STAT( obj, ITEM_DEATHROT ) || IS_OBJ_STAT( obj, ITEM_INVENTORY)))
            extract_obj( obj );
 
        else if ( !IS_NPC(ch) && IS_OBJ_STAT(obj, ITEM_DEATHROT))
            extract_obj(obj);

        else if ( IS_OBJ_STAT(obj, ITEM_INVENTORY) && !IS_NPC(ch)  )
            obj_to_room(obj, get_room_index(ROOM_VNUM_DEATH));
        else
            obj_to_obj( obj, corpse );
    }


I've tried to do a return; instead of a break; - neither seems to work, had plenty of crashes during my failed attempts :( Hopefully someone has done something like this before!
Amended on Wed 08 Sep 2010 06:23 AM by Syriac
Australia Forum Administrator #1
You have it a bit late - you have already done:


obj_from_char( obj );


... before you test the flag.

Closer would be:


    for ( obj = ch->first_carrying; obj; obj = obj_next )
    {
        obj_next = obj->next_content;
  
        if (!IS_OBJ_STAT(obj, ITEM_STORED))
          {
          obj_from_char( obj );
  
          if ( IS_NPC(ch) && (IS_OBJ_STAT( obj, ITEM_DEATHROT ) || IS_OBJ_STAT( obj, ITEM_INVENTORY)))
              extract_obj( obj );
   
          else if ( !IS_NPC(ch) && IS_OBJ_STAT(obj, ITEM_DEATHROT))
              extract_obj(obj);
  
          else if ( IS_OBJ_STAT(obj, ITEM_INVENTORY) && !IS_NPC(ch)  )
              obj_to_room(obj, get_room_index(ROOM_VNUM_DEATH));
          else
              obj_to_obj( obj, corpse );
          }
    }

#2
I had tried that before too... for some reason it still goes poof. The objective is to keep the item in the inventory of the player without putting it in the corpse. SMAUG has a very backward system with dealing with this. *sigh* Moved the break before the obj_from_char portion and also tried that if statement in every possible form hehe. What a pain.
Amended on Wed 08 Sep 2010 06:28 AM by Syriac
Australia Forum Administrator #3
Well don't just try every combination and hope for the best.

Try using the debugger and see why it fails.

http://www.gammon.com.au/gdb
#4
    while ( (obj = ch->last_carrying) != NULL )
                extract_obj(obj);
 
 
    char_from_room(ch);
 
    if ( !fPull )
    {
        location = NULL;



This seems to be the issue in extract char (line 1 and 2, the while statement) - I've tried doing this

    while ( (obj = ch->last_carrying) != NULL )
     if (!IS_OBJ_STAT(obj, ITEM_STORED)) 
                extract_obj(obj); 


But that just crashes it... any ideas?
USA #5
You need to give us more information from the debugger for us to know how to help you debug this.
#6
hehe, ok I got it.. used smaug 1.8 to fix it, apparently some one else noticed the way this was coded was a bit messy.