Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 Couple bugs
Yesterday, 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
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
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, DotBot, Google

Members: 0
Guests: 19
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » Bug with Pets wearing equipme...
Forum Rules | Mark all | Recent Posts

Bug with Pets wearing equipment causing Player Equipment to be stripped
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Dec 30, 2006, 3:44 pm   Last edited Dec 30, 2006, 5:16 pm by Samson
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

EDIT: To save space, post was fixed to show just changes.

In Handler.c:

In can_carry_n Find:
   if( IS_NPC( ch ) && xIS_SET( ch->act, ACT_PET ) )
      return 0;


Change to:
   if( IS_NPC( ch ) && xIS_SET( ch->act, ACT_PET ) )
      return ch->level *50;


In can_carry_w, Remove:
   if( IS_NPC( ch ) && xIS_SET( ch->act, ACT_PET ) )
      return 0;


In save.c:
void fwrite_mobile( FILE * fp, CHAR_DATA * mob )
{
   if( !IS_NPC( mob ) || !fp )
      return;
   fprintf( fp, "#MOBILE\n" );
   fprintf( fp, "Vnum	%d\n", mob->pIndexData->vnum );
   if( mob->in_room )
      fprintf( fp, "Room	%d\n",
               ( mob->in_room == get_room_index( ROOM_VNUM_LIMBO )
                 && mob->was_in_room ) ? mob->was_in_room->vnum : mob->in_room->vnum );
   if( mob->name && mob->pIndexData->player_name && str_cmp( mob->name, mob->pIndexData->player_name ) )
      fprintf( fp, "Name     %s~\n", mob->name );
   if( mob->short_descr && mob->pIndexData->short_descr && str_cmp( mob->short_descr, mob->pIndexData->short_descr ) )
      fprintf( fp, "Short	%s~\n", mob->short_descr );
   if( mob->long_descr && mob->pIndexData->long_descr && str_cmp( mob->long_descr, mob->pIndexData->long_descr ) )
      fprintf( fp, "Long	%s~\n", mob->long_descr );
   if( mob->description && mob->pIndexData->description && str_cmp( mob->description, mob->pIndexData->description ) )
      fprintf( fp, "Description %s~\n", mob->description );
   fprintf( fp, "Position %d\n", mob->position );
   fprintf( fp, "Flags %s\n", print_bitvector( &mob->act ) );
/* Might need these later --Shaddai
  de_equip_char( mob );
  re_equip_char( mob );
  */
   if( mob->first_carrying )
      fwrite_obj( mob, mob->last_carrying, fp, 0, OS_CARRY, FALSE );
   fprintf( fp, "EndMobile\n" );
   return;
}


Replace with:
void fwrite_mobile( FILE * fp, CHAR_DATA * mob )
{
   if( !IS_NPC( mob ) || !fp )
      return;
   de_equip_char( mob );
   fprintf( fp, "#MOBILE\n" );
   fprintf( fp, "Vnum	%d\n", mob->pIndexData->vnum );
   if( mob->in_room )
      fprintf( fp, "Room	%d\n",
               ( mob->in_room == get_room_index( ROOM_VNUM_LIMBO )
                 && mob->was_in_room ) ? mob->was_in_room->vnum : mob->in_room->vnum );
   if( mob->name && mob->pIndexData->player_name && str_cmp( mob->name, mob->pIndexData->player_name ) )
      fprintf( fp, "Name     %s~\n", mob->name );
   if( mob->short_descr && mob->pIndexData->short_descr && str_cmp( mob->short_descr, mob->pIndexData->short_descr ) )
      fprintf( fp, "Short	%s~\n", mob->short_descr );
   if( mob->long_descr && mob->pIndexData->long_descr && str_cmp( mob->long_descr, mob->pIndexData->long_descr ) )
      fprintf( fp, "Long	%s~\n", mob->long_descr );
   if( mob->description && mob->pIndexData->description && str_cmp( mob->description, mob->pIndexData->description ) )
      fprintf( fp, "Description %s~\n", mob->description );
   fprintf( fp, "Position %d\n", mob->position );
   fprintf( fp, "Flags %s\n", print_bitvector( &mob->act ) );
   if( mob->first_carrying )
      fwrite_obj( mob, mob->last_carrying, fp, 0, OS_CARRY, FALSE );
   fprintf( fp, "EndMobile\n" );
   re_equip_char( mob );
   return;
}


Save.c

In fread_mobile, Find:
case 'E':
            if( !str_cmp( word, "EndMobile" ) )
            {
               if( inroom == 0 )
                  inroom = ROOM_VNUM_TEMPLE;
               pRoomIndex = get_room_index( inroom );
               if( !pRoomIndex )
                  pRoomIndex = get_room_index( ROOM_VNUM_TEMPLE );
               char_to_room( mob, pRoomIndex );
               return mob;
            }
            break;


Change to:
case 'E':
            if( !str_cmp( word, "EndMobile" ) )
            {
               if( inroom == 0 )
                  inroom = ROOM_VNUM_TEMPLE;
               pRoomIndex = get_room_index( inroom );
               if( !pRoomIndex )
                  pRoomIndex = get_room_index( ROOM_VNUM_TEMPLE );
			   char_to_room( mob, pRoomIndex );
			   re_equip_char( mob );
               return mob;
            }
            break;


And there you have it, Pets can now be equipped and saved/loaded without causing any form off wiered strippyness of the owner.
       
Post is unread #2 Dec 30, 2006, 6:06 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Ok. A much larger and more involved fix - I want confirmation from someone else that this works before going forward on this:

handler.c, can_carry_n

Locate and remove:
   if( IS_NPC( ch ) && xIS_SET( ch->act, ACT_PET ) )
      return 0;


handler.c, can_carry_w

Locate and remove:
   if( IS_NPC( ch ) && xIS_SET( ch->act, ACT_PET ) )
      return 0;


save.c

Locate:
OBJ_DATA *save_equipment[MAX_WEAR][MAX_LAYERS];


Below that, add:
OBJ_DATA *mob_save_equipment[MAX_WEAR][MAX_LAYERS];


save.c, de_equip_char

Locate:
   for( x = 0; x < MAX_WEAR; x++ )
      for( y = 0; y < MAX_LAYERS; y++ )
         save_equipment[x][y] = NULL;


Change to:
   for( x = 0; x < MAX_WEAR; x++ )
   {
      for( y = 0; y < MAX_LAYERS; y++ )
      {
         if( IS_NPC( ch ) )
            mob_save_equipment[x][y] = NULL;
         else
            save_equipment[x][y] = NULL;
      }
   }


Locate:
            for( x = 0; x < MAX_LAYERS; x++ )
               if( !save_equipment[obj->wear_loc][x] )
               {
                  save_equipment[obj->wear_loc][x] = obj;
                  break;
               }


Change to:
            for( x = 0; x < MAX_LAYERS; x++ )
            {
               if( IS_NPC( ch ) )
               {
                  if( !mob_save_equipment[obj->wear_loc][x] )
                  {
                     mob_save_equipment[obj->wear_loc][x] = obj;
                     break;
                  }
               }
               else
               {
                  if( !save_equipment[obj->wear_loc][x] )
                  {
                     save_equipment[obj->wear_loc][x] = obj;
                     break;
                  }
               }
            }


save.c, re_equip_char

Replace the function with:
void re_equip_char( CHAR_DATA * ch )
{
   int x, y;

   for( x = 0; x < MAX_WEAR; x++ )
   {
      for( y = 0; y < MAX_LAYERS; y++ )
      {
         if( IS_NPC( ch ) )
         {
            if( mob_save_equipment[x][y] != NULL )
            {
               if( quitting_char != ch )
                  equip_char( ch, mob_save_equipment[x][y], x );
               mob_save_equipment[x][y] = NULL;
            }
            else
               break;
         }
         else
         {
            if( save_equipment[x][y] != NULL )
            {
               if( quitting_char != ch )
                  equip_char( ch, save_equipment[x][y], x );
               save_equipment[x][y] = NULL;
            }
            else
               break;
         }
      }
   }
}


save.c, fwrite_obj

Locate:
   for( wear = 0; wear < MAX_WEAR; wear++ )
      for( x = 0; x < MAX_LAYERS; x++ )
         if( obj == save_equipment[wear][x] )
         {
            wear_loc = wear;
            break;
         }
         else if( !save_equipment[wear][x] )
            break;


Change to:
   for( wear = 0; wear < MAX_WEAR; wear++ )
   {
      for( x = 0; x < MAX_LAYERS; x++ )
      {
         if( ch )
         {
            if( IS_NPC( ch ) )
            {
               if( obj == mob_save_equipment[wear][x] )
               {
                  wear_loc = wear;
                  break;
               }
               else if( !mob_save_equipment[wear][x] )
                  break;
            }
            else
            {
               if( obj == save_equipment[wear][x] )
               {
                  wear_loc = wear;
                  break;
               }
               else if( !save_equipment[wear][x] )
                  break;
            }
         }
      }
   }


save.c, fread_obj

Locate:
                        for( x = 0; x < MAX_LAYERS; x++ )
                           if( !save_equipment[wear_loc][x] )
                           {
                              save_equipment[wear_loc][x] = obj;
                              slot = x;
                              reslot = TRUE;
                              break;
                           }


Change to:
                        for( x = 0; x < MAX_LAYERS; x++ )
                        {
                           if( IS_NPC( ch ) )
                           {
                              if( !mob_save_equipment[wear_loc][x] )
                              {
                                 mob_save_equipment[wear_loc][x] = obj;
                                 slot = x;
                                 reslot = TRUE;
                                 break;
                              }
                           }
                           else
                           {
                              if( !save_equipment[wear_loc][x] )
                              {
                                 save_equipment[wear_loc][x] = obj;
                                 slot = x;
                                 reslot = TRUE;
                                 break;
                              }
                           }
                        }


Locate:
                     if( reslot && slot != -1 )
                        save_equipment[wear_loc][slot] = obj;


Change to:
                     if( reslot && slot != -1 )
                     {
                        if( IS_NPC( ch ) )
                           mob_save_equipment[wear_loc][slot] = obj;
                        else
                           save_equipment[wear_loc][slot] = obj;
                     }


save.c, load_char_obj

Locate:
   for( x = 0; x < MAX_WEAR; x++ )
      for( i = 0; i < MAX_LAYERS; i++ )
         save_equipment[x][i] = NULL;


Change to:
   for( x = 0; x < MAX_WEAR; x++ )
      for( i = 0; i < MAX_LAYERS; i++ )
      {
         save_equipment[x][i] = NULL;
         mob_save_equipment[x][i] = NULL;
      }


save.c, fwrite_mobile

Locate:
   if( !IS_NPC( mob ) || !fp )
      return;


Below that, add:
   de_equip_char( mob );


Locate and remove:
/* Might need these later --Shaddai
  de_equip_char( mob );
  re_equip_char( mob );
  */


Locate:
   if( mob->first_carrying )
      fwrite_obj( mob, mob->last_carrying, fp, 0, OS_CARRY, FALSE );
   fprintf( fp, "EndMobile\n" );


Below that, add:
   re_equip_char( mob );


save.c, fread_mobile

Locate:
         case '#':
            if( !str_cmp( word, "#OBJECT" ) )
               fread_obj( mob, fp, OS_CARRY );
            break;


Change to:
         case '#':
            if( !str_cmp( word, "#OBJECT" ) )
            {
               fread_obj( mob, fp, OS_CARRY );
               fMatch = TRUE;
               break;
            }
            break;


Locate:
               char_to_room( mob, pRoomIndex );


Below that, add:
               re_equip_char( mob );
       
Pages:<< prev 1 next >>