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, confirm your email, resolve issues, 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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Sheath/Draw

Sheath/Draw

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


Pages: 1 2  

Posted by Shawncplus   USA  (21 posts)  Bio
Date Sat 14 Apr 2007 09:40 PM (UTC)
Message
I have completely worked out all the code for Sheath and Draw accept two bits, actually moving the weapon from and to the container.

I have all the checks and special item types in place for the sheath itemtype.

This is the code I have now

void do_sheath( CHAR_DATA * ch, char *argument )
{
   OBJ_DATA *w_weapon;
   OBJ_DATA *w_sheath;
   if( ( w_weapon = get_obj_wear( ch, argument ) ) == NULL )
   {
      send_to_char( "Sheath what?\r\n", ch );
      return;
   }
   if( ( w_sheath = get_eq_char(ch, WEAR_SHEATH ) ) == NULL )
   {
      send_to_char("\nYou must have something to put the weapon into.\r\n", ch);
      return;
   }
   else
   {
   w_weapon = obj_to_obj( w_sheath, w_weapon );
    ch_printf(ch, "You dextrously slide %s into %s", w_weapon->short_descr, w_sheath->short_descr);
    return;  
   }
}

void do_draw( CHAR_DATA * ch, char *argument )
{
   OBJ_DATA *w_weapon;
   OBJ_DATA *w_sheath;
   if( ( w_weapon = get_obj_wear( ch, argument ) ) == NULL )
   {
      send_to_char( "Draw what?\r\n", ch );
      return;
   }
   if( ( w_sheath = get_eq_char(ch, WEAR_SHEATH ) ) == NULL )
   {
      send_to_char("\nYou don't even have a sheath to draw from.\r\n", ch);
      return;
   }
   else
   {       

   obj_from_obj( w_weapon );
   w_weapon = obj_to_char( w_weapon, ch );
   equip_char(ch, w_weapon, WEAR_WIELD);
    ch_printf(ch, "You quickly draw %s from %s", w_weapon->short_descr, w_sheath->short_descr);
    return;  
   }
}


This makes some major bugs the way it currently is.
It sometimes duplicates the sheath when the MUD is rebooted, also it creates an infinite bug loop stating the weapon has already been released.
I have no clue where to go from here short of throwing my laptop against the wall.
Any help would be appreciated

Shawncplus,
LazyCode.info

Shawn B.
LazyCode.info
"I find myself in an industry that is identified by the frustration it causes it's customers."
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #1 on Sat 14 Apr 2007 09:43 PM (UTC)

Amended on Sat 14 Apr 2007 09:47 PM (UTC) by Zeno

Message
I don't see the code where it would produce a message saying it was already released.

There are also a few things you should do in the code. You should first check if the argument actually exists, before making it check if the argument is a valid item the player has.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Shawncplus   USA  (21 posts)  Bio
Date Reply #2 on Sat 14 Apr 2007 09:46 PM (UTC)

Amended on Sat 14 Apr 2007 09:52 PM (UTC) by Shawncplus

Message
No, when I shut the mud down it gives me a log bug
like [BUG] Object 810 has already been released! or something like that.

This is one of the bugs it shot out, it core dumped and I don't have GDC so this is all I got.

Log: [*****] BUG: equip_char: obj not being carried by ch!

Shawn B.
LazyCode.info
"I find myself in an industry that is identified by the frustration it causes it's customers."
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #3 on Sat 14 Apr 2007 09:48 PM (UTC)
Message
I don't see that in the stock source. What's the exact message?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Shawncplus   USA  (21 posts)  Bio
Date Reply #4 on Sat 14 Apr 2007 09:56 PM (UTC)
Message
I posted the bug. The weird thing is that the messages go as usual but it's not actually putting the item in it's in_obj even though in the obj_to_obj function it already sets it.

Shawn B.
LazyCode.info
"I find myself in an industry that is identified by the frustration it causes it's customers."
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #5 on Sat 14 Apr 2007 10:00 PM (UTC)
Message
You need to do obj_from_obj, and then obj_to_char I think.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Shawncplus   USA  (21 posts)  Bio
Date Reply #6 on Sat 14 Apr 2007 10:06 PM (UTC)
Message
I did that and it stopped the aforementioned bug but it still doesn't actually show in the list of items in the sheath. Also when I try to draw the item I get this bug.

Log: [*****] BUG: Obj_from_obj: null obj_from.

Shawn B.
LazyCode.info
"I find myself in an industry that is identified by the frustration it causes it's customers."
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #7 on Sat 14 Apr 2007 10:09 PM (UTC)
Message
What itemtype is the sheath? Container? If not, you need to make sure it's setup correctly to save objs inside of it.

But I'm a bit confused. Is sheath just a wear loc? Or is it a wear loc and an itemtype?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Shawncplus   USA  (21 posts)  Bio
Date Reply #8 on Sat 14 Apr 2007 10:11 PM (UTC)
Message
I have the wear location WEAR_SHEATH, the itemtype ITEM_SHEATH, and all the necessary functions. You can also directly put and get items from the sheath as long as they are weapons, and the sheath shows up on the eq list when you type eq as a new item. I also have it set up so it correctly creates the type and wear loc with oset

Shawn B.
LazyCode.info
"I find myself in an industry that is identified by the frustration it causes it's customers."
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #9 on Sat 14 Apr 2007 10:16 PM (UTC)
Message
I don't think the obj_to_char function returns anything, by the way.

And you say that bug message printed out in an infinite loop? I don't see how it could cause an infinite loop.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Shawncplus   USA  (21 posts)  Bio
Date Reply #10 on Sat 14 Apr 2007 10:19 PM (UTC)
Message
It's not anymore but I wanna break down why it's not actually placing the weapon inside the sheath. Because obj_to_char actually puts the item in the inventory. I tried a work around with obj_to_char then using equip_char(ch, w_weapon, WEAR_WIELD); but that didn't work either.

Shawn B.
LazyCode.info
"I find myself in an industry that is identified by the frustration it causes it's customers."
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #11 on Sat 14 Apr 2007 10:25 PM (UTC)

Amended on Sat 14 Apr 2007 10:26 PM (UTC) by Zeno

Message
Looking over my sheath/draw code, you're missing things:
separate_obj()
obj_from_char()
if char_died() [to be safe]

Oh and obj_to_char does return the obj, my bad.

I would also assume you should check if the item is valid to be sheathed.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Shawncplus   USA  (21 posts)  Bio
Date Reply #12 on Sat 14 Apr 2007 10:33 PM (UTC)

Amended on Sat 14 Apr 2007 10:58 PM (UTC) by Shawncplus

Message
This is the new code for sheath after the checks but it's still giving the same problem.

I'll add the died check later

   separate_obj(w_weapon);
   obj_from_char( w_weapon );
   w_weapon = obj_to_obj( w_sheath, w_weapon );
    ch_printf(ch, "You dextrously slide %s into %s", w_weapon->short_descr, w_sheath->short_descr);
    return;  



It's still not actually placing the item in the sheath. It did originally and I can't remember what the crap I changed.

EDIT: I was able to reproduce the error and this is it.

BUG: extract_obj: obj 1000 already extracted
!

Shawn B.
LazyCode.info
"I find myself in an industry that is identified by the frustration it causes it's customers."
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #13 on Sun 15 Apr 2007 12:59 AM (UTC)
Message
Did you do obj_from_char as well for sheathing?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Shawncplus   USA  (21 posts)  Bio
Date Reply #14 on Sun 15 Apr 2007 01:19 AM (UTC)
Message
That was the code for sheathing, I'm going to debug sheath before draw.


void do_sheath( CHAR_DATA * ch, char *argument )
{
   OBJ_DATA *w_weapon;
   OBJ_DATA *w_sheath;
   if( ( w_weapon = get_obj_wear( ch, argument ) ) == NULL )
   {
      send_to_char( "Sheath what?\r\n", ch );
      return;
   }
   if( ( w_sheath = get_eq_char(ch, WEAR_SHEATH ) ) == NULL )
   {
      send_to_char("\nYou must have something to put the weapon into.\r\n", ch);
      return;
   }
   else
   {

   separate_obj(w_weapon);
   obj_from_char( w_weapon );
   w_weapon = obj_to_obj( w_weapon, w_sheath );
    ch_printf(ch, "You dextrously slide %s into %s", w_weapon->short_descr, w_sheath->short_descr);
    return;  
   }
}


I can't figure out for the life of me what is going wrong here. I though it was because I didn't do save_char_obj but that just game me more and more bugs.

Shawn B.
LazyCode.info
"I find myself in an industry that is identified by the frustration it causes it's customers."
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.


65,978 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

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.