Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 Resets not working.
Yesterday, 5:52 pm
By dbna2
 I am trying to compile smaugfuss1.8
Yesterday, 4:52 pm
By Remcon
 Compendium of bugs in SmaugFUSS
Yesterday, 8:42 am
By Remcon
SIGCONT?
May 13, 2013, 9:49 am
By Aurin
Try/Catch function?
May 10, 2013, 10:36 am
By Zeno
QSF Portal
Author: QSF Portal Team
Submitted by: Samson
Raspberry Pi Diff File
Author: Dretzile
Submitted by: Dretzile
Replacement mp_*_passage funcs
Author: Andril
Submitted by: Andril
g++ 4.6 unused variables patch
Author: diff
Submitted by: Andril
LOP 1.43
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Google, GudrunVZT, AZCGerald

Members: 2
Guests: 15
Stats
Files
Topics
Posts
Members
Newest Member
440
3,577
18,322
3,854
AuroraXNE
Today's Birthdays
RandellTT (38), KatrinBri (100), LeslieMcc (54)
Related Links
Smaug Building Institute
» SmaugMuds.org » Codebases » LoP Codebase » Issue in mprog_bribe_trigger ...
Forum Rules | Mark all | Recent Posts

Issue in mprog_bribe_trigger in mud_prog.c
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Dec 29, 2009, 8:18 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupLoP Team
Posts1,594
JoinedJul 26, 2005

Open up the mud_prog.c program and find the mprog_bribe_trigger function and replace it with this
void mprog_bribe_trigger( CHAR_DATA *mob, CHAR_DATA *ch, int amount )
{
   char buf[MSL];
   MPROG_DATA *mprg;
   OBJ_DATA *obj;
   int useprog = 0, amdiff = 0, uamount = 0, onprog;

   if( is_npc( mob ) && can_see( mob, ch ) && HAS_PROG( mob->pIndexData, BRIBE_PROG ) )
   {
      /* Don't let a mob trigger itself, nor one instance of a mob trigger another instance. */
      if( is_npc( ch ) && ch->pIndexData == mob->pIndexData )
         return;

      obj = create_object( get_obj_index( OBJ_VNUM_MONEY_SOME ), 0 );
      if( !obj )
      {
         bug( "%s: failed to create object using vnum %d.", __FUNCTION__, OBJ_VNUM_MONEY_SOME );
         return;
      }

      snprintf( buf, sizeof( buf ), obj->short_descr, num_punct( amount ) );
      STRSET( obj->short_descr, buf );
      obj->value[0] = amount;
      obj = obj_to_char( obj, mob );
      decrease_gold( mob, amount );

      uamount = ( obj->value[0] * obj->count );

      /* Go through once to see which we should use */
      onprog = 0;
      for( mprg = mob->pIndexData->mudprogs; mprg; mprg = mprg->next )
      {
         ++onprog;
         if( ( mprg->type == BRIBE_PROG ) && ( uamount >= atoi( mprg->arglist ) ) && ( amdiff == 0 || ( uamount - atoi( mprg->arglist ) ) < amdiff ) )
         {
            amdiff = ( uamount - atoi( mprg->arglist ) );
            useprog = onprog;
         }
      }

      /* Go through it again and use the closest bribe program to the amount */
      onprog = 0;
      for( mprg = mob->pIndexData->mudprogs; mprg; mprg = mprg->next )
      {
         if( ++onprog != useprog )
            continue;

         if( ( mprg->type == BRIBE_PROG ) && ( uamount >= atoi( mprg->arglist ) ) )
         {
            increase_gold( mob, uamount );
            mprog_driver( mprg->comlist, mob, ch, obj, NULL, false );
            if( obj )
               extract_obj( obj );
            break;
         }
      }
   }
}

This is only for LoP since there are lots of changes to gold handling on LoP.
Feel free to use what you want for the change for SmaugFUSS etc... for the addition.

This fixes a crashing issue when giving a mobile gold that has a bribe program.
(The old one uses amount in the snprintf for the obj->short_descr when it should be using num_punct( amount ).)
It also adds in so if you have more then one bribe program it takes the highest (closest) to the amount given to the mobile to execute instead of the lower ones so order won't be an issue with them.
       
Pages:<< prev 1 next >>

 
Contact Us