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, Google, Yandex

Members: 0
Guests: 4
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] autogold/sac/loot/etc. ...
Forum Rules | Mark all | Recent Posts

[Bug] autogold/sac/loot/etc. do not work correctly
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 23, 2006, 2:11 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Bug: autogold/sac/loot/etc. do not work correctly
Danger: Low - Mainly an annoyance issue
Found by: Valcados
Fixed by: Valcados

---

fight.c

Below:
bool get_cover( CHAR_DATA * ch );
bool dual_flip = FALSE;


Add:
bool loot_coins_from_corpse( CHAR_DATA *ch, OBJ_DATA *corpse )
{
   OBJ_DATA *content, *content_next;
   int oldgold = ch->gold;

   for( content = corpse->first_content; content; content = content_next )
   {
      content_next = content->next_content;

      if( content->item_type != ITEM_MONEY )
         continue;
      if( !can_see_obj( ch, content ) )
         continue;
      if( !CAN_WEAR( content, ITEM_TAKE ) && ch->top_level < sysdata.level_getobjnotake )
         continue;
      if( IS_OBJ_STAT( content, ITEM_PROTOTYPE ) && !can_take_proto( ch ) )
         continue;

      act( AT_ACTION, "You get $p from $P", ch, content, corpse, TO_CHAR );
      act( AT_ACTION, "$n gets $p from $P", ch, content, corpse, TO_ROOM );
      obj_from_obj( content );
      check_for_trap( ch, content, TRAP_GET );
      if( char_died( ch ) )
         return FALSE;

      oprog_get_trigger( ch, content );
      if( char_died( ch ) )
         return FALSE;

      ch->gold += content->value[0] * content->count;
      extract_obj( content );
   }

   if( ch->gold - oldgold > 1 && ch->position > POS_SLEEPING )
   {
      char buf[MAX_INPUT_LENGTH];

      snprintf( buf, MAX_INPUT_LENGTH, "%d", ch->gold - oldgold );
      do_split( ch, buf );
   }
   return TRUE;
}


fight.c, damage

Locate and remove:
   char buf1[MAX_STRING_LENGTH];
   int init_gold, new_gold, gold_diff;


Locate:
   /*
    * Payoff for killing things.
    */
   if( victim->position == POS_DEAD )
   {
      CHAR_DATA *gch;

      group_gain( ch, victim );


Change to:
   /*
    * Payoff for killing things.
    */
   if( victim->position == POS_DEAD )
   {
      CHAR_DATA *gch;
      OBJ_DATA *new_corpse;

      group_gain( ch, victim );


Locate:
      set_cur_char( victim );
      raw_kill( ch, victim );
      victim = NULL;

      if( !IS_NPC( ch ) && loot )
      {
         /*
          * Autogold by Scryn 8/12 
          */
         if( IS_SET( ch->act, PLR_AUTOGOLD ) )
         {
            init_gold = ch->gold;
            do_get( ch, "credits corpse" );
            new_gold = ch->gold;
            gold_diff = ( new_gold - init_gold );
            if( gold_diff > 0 )
            {
               sprintf( buf1, "%d", gold_diff );
               do_split( ch, buf1 );
            }
         }
         if( room && ch && ch->in_room && ch->in_room->vnum == room )
         {
            if( IS_SET( ch->act, PLR_AUTOLOOT ) && nocorpse == 0 )
               do_get( ch, "all corpse" );
            else if( nocorpse == 0 )
               do_look( ch, "in corpse" );

            if( IS_SET( ch->act, PLR_AUTOSAC ) )
               do_sacrifice( ch, "corpse" );
         }
      }


Change to:
      set_cur_char( victim );
      new_corpse = raw_kill( ch, victim );
      victim = NULL;

      if( !IS_NPC( ch ) && loot && new_corpse && new_corpse->item_type == ITEM_CORPSE_NPC
       && new_corpse->in_room == ch->in_room && can_see_obj( ch, new_corpse ) && ch->position > POS_SLEEPING )
      {
         /*
          * Autogold by Scryn 8/12 
          */
         if( IS_SET( ch->act, PLR_AUTOGOLD ) && !loot_coins_from_corpse( ch, new_corpse ) )
            return rBOTH_DIED;

         if( new_corpse && !obj_extracted(new_corpse) && new_corpse->in_room == ch->in_room
          && ch->position > POS_SLEEPING && can_see_obj( ch, new_corpse ) )
         {
            if( IS_SET( ch->act, PLR_AUTOLOOT ) )
               do_get( ch, "all corpse" );
            else
               do_look( ch, "in corpse" );
            if( !char_died(ch) && IS_SET( ch->act, PLR_AUTOSAC ) && !obj_extracted(new_corpse)
             && new_corpse->in_room == ch->in_room && ch->position > POS_SLEEPING
             && can_see_obj( ch, new_corpse ) )
               do_sacrifice( ch, "corpse" );
         }
      }


fight.c, raw_kill

Replace the entire function with:

OBJ_DATA *raw_kill( CHAR_DATA * ch, CHAR_DATA * victim )
{
   CHAR_DATA *victmp;
   OBJ_DATA *corpse_to_return;
   OBJ_DATA *obj, *obj_next;
   SHIP_DATA *ship;
   char buf[MAX_STRING_LENGTH];
   char buf2[MAX_STRING_LENGTH];
   char arg[MAX_STRING_LENGTH];

   if( !victim )
   {
      bug( "%s: null victim!", __FUNCTION__ );
      return NULL;
   }

   strcpy( arg, victim->name );

   stop_fighting( victim, TRUE );

   if( ch && !IS_NPC( ch ) && !IS_NPC( victim ) )
      claim_disintigration( ch, victim );

   /* Take care of polymorphed chars */
   if( IS_NPC( victim ) && IS_SET( victim->act, ACT_POLYMORPHED ) )
   {
      char_from_room( victim->desc->original );
      char_to_room( victim->desc->original, victim->in_room );
      victmp = victim->desc->original;
      do_revert( victim, "" );
      return raw_kill( ch, victmp );
   }

   if( victim->in_room && IS_NPC( victim ) && victim->vip_flags != 0 && victim->in_room->area
       && victim->in_room->area->planet )
   {
      victim->in_room->area->planet->population--;
      victim->in_room->area->planet->population = UMAX( victim->in_room->area->planet->population, 0 );
      victim->in_room->area->planet->pop_support -= ( float )( 1 + 1 / ( victim->in_room->area->planet->population + 1 ) );
      if( victim->in_room->area->planet->pop_support < -100 )
         victim->in_room->area->planet->pop_support = -100;
   }

   if( !IS_NPC( victim ) || !IS_SET( victim->act, ACT_NOKILL ) )
      mprog_death_trigger( ch, victim );
   if( char_died( victim ) )
      return NULL;

   if( !IS_NPC( victim ) || !IS_SET( victim->act, ACT_NOKILL ) )
      rprog_death_trigger( ch, victim );
   if( char_died( victim ) )
      return NULL;

   if( !IS_NPC( victim ) || ( !IS_SET( victim->act, ACT_NOKILL ) && !IS_SET( victim->act, ACT_NOCORPSE ) ) )
      corpse_to_return = make_corpse( victim, ch );
   else
   {
      for( obj = victim->last_carrying; obj; obj = obj_next )
      {
         obj_next = obj->prev_content;
         obj_from_char( obj );
         extract_obj( obj );
      }
   }

   if( IS_NPC( victim ) )
   {
      victim->pIndexData->killed++;
      extract_char( victim, TRUE );
      victim = NULL;
      return corpse_to_return;
   }

   set_char_color( AT_DIEMSG, victim );
   do_help( victim, "_DIEMSG_" );

   /* swreality chnages begin here */

   for( ship = first_ship; ship; ship = ship->next )
   {
      if( !str_cmp( ship->owner, victim->name ) )
      {
         STRFREE( ship->owner );
         ship->owner = STRALLOC( "" );
         STRFREE( ship->pilot );
         ship->pilot = STRALLOC( "" );
         STRFREE( ship->copilot );
         ship->copilot = STRALLOC( "" );

         save_ship( ship );
      }
   }

   if( victim->plr_home )
   {
      ROOM_INDEX_DATA *room = victim->plr_home;

      STRFREE( room->name );
      room->name = STRALLOC( "An Empty Apartment" );

      REMOVE_BIT( room->room_flags, ROOM_PLR_HOME );
      SET_BIT( room->room_flags, ROOM_EMPTY_HOME );

      fold_area( room->area, room->area->filename, FALSE );
   }

   if( victim->pcdata && victim->pcdata->clan )
   {
      if( !str_cmp( victim->name, victim->pcdata->clan->leader ) )
      {
         STRFREE( victim->pcdata->clan->leader );
         if( victim->pcdata->clan->number1 )
         {
            victim->pcdata->clan->leader = STRALLOC( victim->pcdata->clan->number1 );
            STRFREE( victim->pcdata->clan->number1 );
            victim->pcdata->clan->number1 = STRALLOC( "" );
         }
         else if( victim->pcdata->clan->number2 )
         {
            victim->pcdata->clan->leader = STRALLOC( victim->pcdata->clan->number2 );
            STRFREE( victim->pcdata->clan->number2 );
            victim->pcdata->clan->number2 = STRALLOC( "" );
         }
         else
            victim->pcdata->clan->leader = STRALLOC( "" );
      }

      if( !str_cmp( victim->name, victim->pcdata->clan->number1 ) )
      {
         STRFREE( victim->pcdata->clan->number1 );
         if( victim->pcdata->clan->number2 )
         {
            victim->pcdata->clan->number1 = STRALLOC( victim->pcdata->clan->number2 );
            STRFREE( victim->pcdata->clan->number2 );
            victim->pcdata->clan->number2 = STRALLOC( "" );
         }
         else
            victim->pcdata->clan->number1 = STRALLOC( "" );
      }

      if( !str_cmp( victim->name, victim->pcdata->clan->number2 ) )
      {
         STRFREE( victim->pcdata->clan->number2 );
         victim->pcdata->clan->number1 = STRALLOC( "" );
      }
      victim->pcdata->clan->members--;
   }

   if( !victim )
   {
      DESCRIPTOR_DATA *d;

      /*
       * Make sure they aren't halfway logged in. 
       */
      for( d = first_descriptor; d; d = d->next )
         if( ( victim = d->character ) && !IS_NPC( victim ) )
            break;
      if( d )
         close_socket( d, TRUE );
   }
   else
   {
      int x, y;

      quitting_char = victim;
      save_char_obj( victim );
      saving_char = NULL;
      extract_char( victim, TRUE );
      for( x = 0; x < MAX_WEAR; x++ )
         for( y = 0; y < MAX_LAYERS; y++ )
            save_equipment[x][y] = NULL;
   }

   sprintf( buf, "%s%c/%s", PLAYER_DIR, tolower( arg[0] ), capitalize( arg ) );
   sprintf( buf2, "%s%c/%s", BACKUP_DIR, tolower( arg[0] ), capitalize( arg ) );

   rename( buf, buf2 );

   sprintf( buf, "%s%c/%s.clone", PLAYER_DIR, tolower( arg[0] ), capitalize( arg ) );
   sprintf( buf2, "%s%c/%s", PLAYER_DIR, tolower( arg[0] ), capitalize( arg ) );

   rename( buf, buf2 );

   return corpse_to_return;
}


makeobjs.c

Locate:
void make_corpse( CHAR_DATA * ch, CHAR_DATA * killer )


Change to:
OBJ_DATA *make_corpse( CHAR_DATA * ch, CHAR_DATA * killer )


Locate:
   obj_to_room( corpse, ch->in_room );
   return;


Change to:
   return obj_to_room( corpse, ch->in_room );


mud.h

Locate:
void raw_kill args( ( CHAR_DATA * ch, CHAR_DATA * victim ) );


Change to:
OBJ_DATA *raw_kill( CHAR_DATA *ch, CHAR_DATA *victim );


Locate:
void make_corpse args( ( CHAR_DATA * ch, CHAR_DATA * killer ) );


Change to:
OBJ_DATA *make_corpse( CHAR_DATA * ch, CHAR_DATA * killer );


Valcados said:


First, autogold fails to loot "1 gold coin" if that's all the mob has. Second, the code for doing these various corpse related things could be more robust, if you added a slaying get prog to the "%d gold coins" object, autogold might very well crash the MUD. Third, absolutely no checks are made to see that the corpse exists, that it's in the same room as the player, that the player can see it, or that the player is conscious enough to rifle through its pockets. Fourth, weight/inventory problems prevent players from autogolding, even though gold is weightless and spaceless.
       
Pages:<< prev 1 next >>