Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ make_corpse

make_corpse

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Syriac   (46 posts)  Bio
Date Wed 08 Sep 2010 04:22 AM (UTC)

Amended on Wed 08 Sep 2010 06:23 AM (UTC) by Syriac

Message
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!
Top

Posted by Nick Gammon   Australia  (23,046 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 08 Sep 2010 06:13 AM (UTC)
Message
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 );
          }
    }


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Syriac   (46 posts)  Bio
Date Reply #2 on Wed 08 Sep 2010 06:27 AM (UTC)

Amended on Wed 08 Sep 2010 06:28 AM (UTC) by Syriac

Message
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.
Top

Posted by Nick Gammon   Australia  (23,046 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 08 Sep 2010 06:30 AM (UTC)
Message
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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Syriac   (46 posts)  Bio
Date Reply #4 on Wed 08 Sep 2010 04:05 PM (UTC)
Message
    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?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #5 on Wed 08 Sep 2010 04:34 PM (UTC)
Message
You need to give us more information from the debugger for us to know how to help you debug this.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Syriac   (46 posts)  Bio
Date Reply #6 on Wed 08 Sep 2010 04:45 PM (UTC)
Message
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.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


22,776 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.