[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  make_corpse
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

make_corpse

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


Posted by Syriac   (46 posts)  [Biography] 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!
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] 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
[Go to top] top

Posted by Syriac   (46 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] 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
[Go to top] top

Posted by Syriac   (46 posts)  [Biography] 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?
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] 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
[Go to top] top

Posted by Syriac   (46 posts)  [Biography] 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.
[Go to top] 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.


5,491 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]