Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
parse description bug
Dec 15, 2017, 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, Bing, Majestic-12, Yahoo!, Google

Members: 0
Guests: 18
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 » SmaugFUSS 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, 1:42 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:
void show_condition( CHAR_DATA * ch, CHAR_DATA * victim );


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->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 )
   {
      group_gain( ch, victim );


Change to:
   /*
    * Payoff for killing things.
    */
   if( victim->position == POS_DEAD )
   {
      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( xIS_SET( ch->act, PLR_AUTOGOLD ) )
         {
            init_gold = ch->gold;
            do_get( ch, "coins corpse" );
            new_gold = ch->gold;
            gold_diff = ( new_gold - init_gold );
            if( gold_diff > 0 )
            {
               snprintf( buf1, MAX_STRING_LENGTH, "%d", gold_diff );
               do_split( ch, buf1 );
            }
         }
         if( xIS_SET( ch->act, PLR_AUTOLOOT ) && victim != ch )   /* prevent nasty obj problems -- Blodkai */
            do_get( ch, "all corpse" );
         else
            do_look( ch, "in corpse" );

         if( xIS_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( xIS_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( xIS_SET( ch->act, PLR_AUTOLOOT ) )
               do_get( ch, "all corpse" );
            else
               do_look( ch, "in corpse" );
            if( !char_died(ch) && xIS_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 )
{
   OBJ_DATA *corpse_to_return = NULL;

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

   /* backup in case hp goes below 1 */
   if( NOT_AUTHED( victim ) )
   {
      bug( "%s: killing unauthed", __FUNCTION__ );
      return NULL;
   }

   stop_fighting( victim, TRUE );

   /*
    * Take care of morphed characters 
    */
   if( victim->morph )
   {
      do_unmorph_char( victim );
      return raw_kill( ch, victim );
   }

   mprog_death_trigger( ch, victim );
   if( char_died( victim ) )
      return NULL;

   /*
    * death_cry( victim ); 
    */

   rprog_death_trigger( victim );
   if( char_died( victim ) )
      return NULL;

   corpse_to_return = make_corpse( victim, ch );
   if( victim->in_room->sector_type == SECT_OCEANFLOOR
    || victim->in_room->sector_type == SECT_UNDERWATER
    || victim->in_room->sector_type == SECT_WATER_SWIM || victim->in_room->sector_type == SECT_WATER_NOSWIM )
      act( AT_BLOOD, "$n's blood slowly clouds the surrounding water.", victim, NULL, NULL, TO_ROOM );
   else if( victim->in_room->sector_type == SECT_AIR )
      act( AT_BLOOD, "$n's blood sprays wildly through the air.", victim, NULL, NULL, TO_ROOM );
   else
      make_blood( victim );

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

   set_char_color( AT_DIEMSG, victim );
   if( victim->pcdata->mdeaths + victim->pcdata->pdeaths < 3 )
      do_help( victim, "new_death" );
   else
      do_help( victim, "_DIEMSG_" );

   extract_char( victim, FALSE );
   if( !victim )
   {
      bug( "%s: oops! extract_char destroyed pc char", __FUNCTION__ );
      return NULL;
   }
   while( victim->first_affect )
      affect_remove( victim, victim->first_affect );
   victim->affected_by = race_table[victim->race]->affected;
   victim->resistant = 0;
   victim->susceptible = 0;
   victim->immune = 0;
   victim->carry_weight = 0;
   victim->armor = 100;
   victim->armor += race_table[victim->race]->ac_plus;
   victim->attacks = race_table[victim->race]->attacks;
   victim->defenses = race_table[victim->race]->defenses;
   victim->mod_str = 0;
   victim->mod_dex = 0;
   victim->mod_wis = 0;
   victim->mod_int = 0;
   victim->mod_con = 0;
   victim->mod_cha = 0;
   victim->mod_lck = 0;
   victim->damroll = 0;
   victim->hitroll = 0;
   victim->mental_state = -10;
   victim->alignment = URANGE( -1000, victim->alignment, 1000 );
/*  victim->alignment		= race_table[victim->race]->alignment;
-- switched lines just for now to prevent mortals from building up
days of bellyaching about their angelic or satanic humans becoming
neutral when they die given the difficulting of changing align */

   victim->saving_poison_death = race_table[victim->race]->saving_poison_death;
   victim->saving_wand = race_table[victim->race]->saving_wand;
   victim->saving_para_petri = race_table[victim->race]->saving_para_petri;
   victim->saving_breath = race_table[victim->race]->saving_breath;
   victim->saving_spell_staff = race_table[victim->race]->saving_spell_staff;
   victim->position = POS_RESTING;
   victim->hit = UMAX( 1, victim->hit );
   /*
    * Shut down some of those naked spammer killers - Blodkai 
    */
   if( victim->level < LEVEL_AVATAR )
      victim->mana = UMAX( 1, victim->mana );
   else
      victim->mana = 1;
   victim->move = UMAX( 1, victim->move );

   /*
    * Pardon crimes...                -Thoric
    */
   if( xIS_SET( victim->act, PLR_KILLER ) )
   {
      xREMOVE_BIT( victim->act, PLR_KILLER );
      send_to_char( "The gods have pardoned you for your murderous acts.\r\n", victim );
   }
   if( xIS_SET( victim->act, PLR_THIEF ) )
   {
      xREMOVE_BIT( victim->act, PLR_THIEF );
      send_to_char( "The gods have pardoned you for your thievery.\r\n", victim );
   }
   victim->pcdata->condition[COND_FULL] = 12;
   victim->pcdata->condition[COND_THIRST] = 12;
   if( IS_VAMPIRE( victim ) )
      victim->pcdata->condition[COND_BLOODTHIRST] = ( victim->level / 2 );

   if( IS_SET( sysdata.save_flags, SV_DEATH ) )
      save_char_obj( victim );
   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 >>