Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 parse description bug
Yesterday, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Exalead, Google

Members: 0
Guests: 2
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SWR FUSS Bugfix List » [Bug] wear_obj is an evil lit...
Forum Rules | Mark all | Recent Posts

[Bug] wear_obj is an evil little bitch
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 17, 2005, 4:02 pm   Last edited Sep 19, 2005, 6:52 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Bug: wear_obj is an evil little bitch
Danger: Low - Inconsistent handling of wielding/wearing items
Found by: Remcon
Fixed by: Remcon

---

act_obj.c, wear_obj

Locate:
      case ITEM_HOLD:
         if( get_eq_char( ch, WEAR_DUAL_WIELD ) )
         {
            send_to_char( "You cannot hold something AND two weapons!\n\r", ch );
            return;
         }
         if( !remove_obj( ch, WEAR_HOLD, fReplace ) )
            return;
         if( obj->item_type == ITEM_DEVICE
             || obj->item_type == ITEM_GRENADE
             || obj->item_type == ITEM_FOOD
             || obj->item_type == ITEM_PILL
             || obj->item_type == ITEM_POTION
             || obj->item_type == ITEM_DRINK_CON
             || obj->item_type == ITEM_SALVE
             || obj->item_type == ITEM_KEY || !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
         {
            act( AT_ACTION, "$n holds $p in $s hands.", ch, obj, NULL, TO_ROOM );
            act( AT_ACTION, "You hold $p in your hands.", ch, obj, NULL, TO_CHAR );
         }
         equip_char( ch, obj, WEAR_HOLD );
         oprog_wear_trigger( ch, obj );
         return;


Change to:
      case ITEM_HOLD:
         if( get_eq_char( ch, WEAR_DUAL_WIELD )
         || ( get_eq_char( ch, WEAR_WIELD )
         && ( get_eq_char( ch, WEAR_MISSILE_WIELD ) ) ) )
         {
            send_to_char( "You cannot hold something AND two weapons!\n\r", ch );
            return;
         }
         if( !remove_obj( ch, WEAR_HOLD, fReplace ) )
            return;
         if( obj->item_type == ITEM_DEVICE
             || obj->item_type == ITEM_GRENADE
             || obj->item_type == ITEM_FOOD
             || obj->item_type == ITEM_PILL
             || obj->item_type == ITEM_POTION
             || obj->item_type == ITEM_DRINK_CON
             || obj->item_type == ITEM_PIPE
             || obj->item_type == ITEM_HERB
             || obj->item_type == ITEM_SALVE
             || obj->item_type == ITEM_KEY || !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
         {
            act( AT_ACTION, "$n holds $p in $s hands.", ch, obj, NULL, TO_ROOM );
            act( AT_ACTION, "You hold $p in your hands.", ch, obj, NULL, TO_CHAR );
         }
         equip_char( ch, obj, WEAR_HOLD );
         oprog_wear_trigger( ch, obj );
         return;


Locate:
      case ITEM_WIELD:
         if( ( tmpobj = get_eq_char( ch, WEAR_WIELD ) ) != NULL && !could_dual( ch ) )
         {
            send_to_char( "You're already wielding something.\n\r", ch );
            return;
         }

         if( tmpobj )
         {
            if( can_dual( ch ) )
            {
               if( get_obj_weight( obj ) + get_obj_weight( tmpobj ) > str_app[get_curr_str( ch )].wield )
               {
                  send_to_char( "It is too heavy for you to wield.\n\r", ch );
                  return;
               }
               if( !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
               {
                  if( !obj->action_desc || obj->action_desc[0] == '\0' )
                  {
                     act( AT_ACTION, "$n dual-wields $p.", ch, obj, NULL, TO_ROOM );
                     act( AT_ACTION, "You dual-wield $p.", ch, obj, NULL, TO_CHAR );
                  }
                  else
                     actiondesc( ch, obj, NULL );
               }
               equip_char( ch, obj, WEAR_DUAL_WIELD );
               oprog_wear_trigger( ch, obj );
            }
            return;
         }

         if( get_obj_weight( obj ) > str_app[get_curr_str( ch )].wield )
         {
            send_to_char( "It is too heavy for you to wield.\n\r", ch );
            return;
         }

         if( !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
         {
            if( !obj->action_desc || obj->action_desc[0] == '\0' )
            {
               act( AT_ACTION, "$n wields $p.", ch, obj, NULL, TO_ROOM );
               act( AT_ACTION, "You wield $p.", ch, obj, NULL, TO_CHAR );
            }
            else
               actiondesc( ch, obj, NULL );
         }
         equip_char( ch, obj, WEAR_WIELD );
         oprog_wear_trigger( ch, obj );
         return;


Change to:
      case ITEM_MISSILE_WIELD:
      case ITEM_WIELD:
         if( !could_dual( ch ) )
         {
            if( !remove_obj( ch, WEAR_MISSILE_WIELD, fReplace ) )
               return;
            if( !remove_obj( ch, WEAR_WIELD, fReplace ) )
               return;
            tmpobj = NULL;
         }
         else
         {
            OBJ_DATA *mw, *dw, *hd;
            tmpobj = get_eq_char( ch, WEAR_WIELD );
            mw = get_eq_char( ch, WEAR_MISSILE_WIELD );
            dw = get_eq_char( ch, WEAR_DUAL_WIELD );
            hd = get_eq_char( ch, WEAR_HOLD );

            if( tmpobj )
            {
               if( !can_dual( ch ) )
                  return;

               if( get_obj_weight( obj ) + get_obj_weight( tmpobj ) > str_app[get_curr_str( ch )].wield )
               {
                  send_to_char( "It is too heavy for you to wield.\n\r", ch );
                  return;
               }

               if( mw || dw )
               {
                  send_to_char( "You're already wielding two weapons.\n\r", ch );
                  return;
               }

               if( hd )
               {
                  send_to_char( "You're already wielding a weapon AND holding something.\n\r", ch );
                  return;
               }

               if( !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
               {
                  act( AT_ACTION, "$n dual-wields $p.", ch, obj, NULL, TO_ROOM );
                  act( AT_ACTION, "You dual-wield $p.", ch, obj, NULL, TO_CHAR );
               }
               if( 1 << bit == ITEM_MISSILE_WIELD )
                  equip_char( ch, obj, WEAR_MISSILE_WIELD );
               else
                  equip_char( ch, obj, WEAR_DUAL_WIELD );
               oprog_wear_trigger( ch, obj );
               return;
            }

            if( mw )
            {
               if( !can_dual( ch ) )
                  return;

               if( 1 << bit == ITEM_MISSILE_WIELD )
               {
                  send_to_char( "You're already wielding a missile weapon.\n\r", ch );
                  return;
               }

               if( get_obj_weight( obj ) + get_obj_weight( mw ) > str_app[get_curr_str( ch )].wield )
               {
                  send_to_char( "It is too heavy for you to wield.\n\r", ch );
                  return;
               }

               if( tmpobj || dw )
               {
                  send_to_char( "You're already wielding two weapons.\n\r", ch );
                  return;
               }

               if( hd )
               {
                  send_to_char( "You're already wielding a weapon AND holding something.\n\r", ch );
                  return;
               }

               if( !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
               {
                  act( AT_ACTION, "$n wields $p.", ch, obj, NULL, TO_ROOM );
                  act( AT_ACTION, "You wield $p.", ch, obj, NULL, TO_CHAR );
               }
               equip_char( ch, obj, WEAR_WIELD );
               oprog_wear_trigger( ch, obj );
               return;
            }
         }

         if( get_obj_weight( obj ) > str_app[get_curr_str( ch )].wield )
         {
            send_to_char( "It is too heavy for you to wield.\n\r", ch );
            return;
         }

         if( !oprog_use_trigger( ch, obj, NULL, NULL, NULL ) )
         {
            act( AT_ACTION, "$n wields $p.", ch, obj, NULL, TO_ROOM );
            act( AT_ACTION, "You wield $p.", ch, obj, NULL, TO_CHAR );
         }
         if( 1 << bit == ITEM_MISSILE_WIELD )
            equip_char( ch, obj, WEAR_MISSILE_WIELD );
         else
            equip_char( ch, obj, WEAR_WIELD );
         oprog_wear_trigger( ch, obj );
         return;


Locate:
/*
 * See if char can dual wield at this time			-Thoric
 */
bool can_dual( CHAR_DATA * ch )
{
   if( !could_dual( ch ) )
      return FALSE;

   if( get_eq_char( ch, WEAR_DUAL_WIELD ) )
   {
      send_to_char( "You are already wielding two weapons!\n\r", ch );
      return FALSE;
   }
   if( get_eq_char( ch, WEAR_HOLD ) )
   {
      send_to_char( "You cannot dual wield while holding something!\n\r", ch );
      return FALSE;
   }
   return TRUE;
}


Change to:
bool can_dual( CHAR_DATA * ch )
{
   bool wield = FALSE, nwield = FALSE;

   if( !could_dual( ch ) )
      return FALSE;
   if( get_eq_char( ch, WEAR_WIELD ) )
      wield = TRUE;
   /* Check for missile wield or dual wield */
   if( get_eq_char( ch, WEAR_MISSILE_WIELD ) || get_eq_char( ch, WEAR_DUAL_WIELD ) )
      nwield = TRUE;
   if( wield && nwield )
   {
      send_to_char( "You are already wielding two weapons... grow some more arms!\n\r", ch );
      return FALSE;
   }
   if( ( wield || nwield ) && get_eq_char( ch, WEAR_SHIELD ) )
   {
      send_to_char( "You cannot dual wield, you're already holding a shield!\n\r", ch );
      return FALSE;
   }
   if( ( wield || nwield ) && get_eq_char( ch, WEAR_HOLD ) )
   {
      send_to_char( "You cannot hold another weapon, you're already holding something in that hand!\n\r", ch );
      return FALSE;
   }
   return TRUE;
}


The problems with all of this are so numerous I'm not even sure where to start, but the fixes here should bring the whole mess under control once and for all.
       
Pages:<< prev 1 next >>