do_award 1.1 snippet for EmberMUD
                      Install sheet by Rindar (Ron Cole)
             Code by Rindar (Ron Cole) and Raven (Laurie Zenner)


Notes:  This is a minor function inspired by a letter that I received 
from the ROM mailing list.  The function that inspired it was called 
do_bonus and sent by "John Strange" (gambit@communique.net).  In the
original, the award command allowed an immortal to give a player 
between -5000 and 5000 experience.  This was a decent feature.

        But I got to thinking about it, and thought that it would be
nice to be able to give people "awards" or "penalties" for various 
things:  when they reported bugs (bonus), when they did a good-job of
roleplaying (bonus), when they spammed the IC channels with OOC 
chat (penalty), or when they improperly harassed other characters 
(penalty).  But why stop with just experience?  Shouldn't gold, 
alignment, and objects be allows as well?  So I coded my own function,
and here it is.  It isn't an earth-shattering new feature, but it 
is a fun addition for EmberMUDs, and allows for manipulations of 
characters without having to SET them.


Install:  Follow the directions below to install the code.

     1)  You need to add the appropriate line of code to activate
       the AWARD command in interp.h.  Here is what ours looks like,  
       with the lines before and after /* */'ed out:

      /* DECLARE_DO_FUN( do_autosplit    ); */
         DECLARE_DO_FUN( do_award        );
      /* DECLARE_DO_FUN( do_backstab     ); */

     2)  Open interp.c and add the appropriate lines of code to
       activate the AWARD command.  Here is what ours looks like:
     
      /* { "advance",       do_levelgain,   POS_DEAD,        0,  LOG_NORMAL, 1 }, */
         { "award",         do_award,       POS_DEAD,       ML,  LOG_ALWAYS, 1 },
     /*  { "hotboot",       do_copyover,    POS_DEAD,       ML,  LOG_ALWAYS, 1 }, */

     3)  Insert the snippet at the bottom of the sheet into act_wiz.c.

     4)  Recompile.  You are done.

        In the next version of this code, I will add the ability to 
award practices and trainings.  If you find any problems with this 
function, feel free to e-mail me at the below address.

-= Rindar
(clogar@concentric.net)


** Note:  This function is provided "as is" and may be used so long as 
1)  The author's name is kept at the top of the function (if requested) and
2)  all other previous licensing aggreements are abided by.  The author 
assumes no responsibility for problems that occur through use or install-
ation, including lost wages, bugs, deletions, downtimes, etc...  Use at 
your own risk.  All new code is copyrighted by its author.


The do_award function:

/* do_award function coded by Rindar (Ron Cole) and Raven (Laurie Zenner).  */
void do_award( CHAR_DATA *ch, char *argument)
{
    CHAR_DATA *victim;
    char       buf  [ MAX_STRING_LENGTH ];
    char       arg1 [ MAX_INPUT_LENGTH ];
    char       arg2 [ MAX_INPUT_LENGTH ];
    char       arg3 [ MAX_INPUT_LENGTH ];
    int      value;
    int      level;
    int      levelvi;
    char     *maxed;
    long     maxlong  = 2147483647;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    argument = one_argument( argument, arg3 );
    
    /* have to initialize maxed or will get warnings when compiling */
    maxed = strdup( "maxed" );

    if ( arg1[0] == '\0' || arg3[0] == '\0' || !is_number( arg2 ) )
    {
        send_to_char( "Syntax: award <char> <amount> <type>.\n\r", ch );
        send_to_char( "Valid types: alignment, experience, gold, object.\n\r", ch );
        send_to_char( "NOTE: Substitute the object's VNUM for the amount.\n\r", ch );
        return;
    }
    
    if ( strncmp( arg3, "alignment",  strlen( arg3 ) )
    &&   strncmp( arg3, "experience", strlen( arg3 ) )
    &&   strncmp( arg3, "gold",       strlen( arg3 ) )
    &&   strncmp( arg3, "object",     strlen( arg3 ) ) )
    {
        send_to_char( "Valid types: alignment, experience, gold, object.\n\r", ch );
        send_to_char( "NOTE: Substitute the object's VNUM for the amount.\n\r", ch );
        return;
    }

    if (( victim = get_char_world ( ch, arg1 ) ) == NULL )
    {
      send_to_char("That person is not currently on-line.\n\r", ch);
      return;
    }
       
    if ( IS_NPC( victim ) )
    {
        send_to_char( "Not on NPC's.\n\r", ch );
        return;
    }

    level = get_trust(ch);
    levelvi = get_trust(victim);

    if ( ( level <= levelvi ) && ( ch != victim ) )
    {
        send_to_char( "You can only award those of lesser trust level.", ch );
        return;
    }


    value = atoi( arg2 );
    
    if ( value == 0 )
    {
       send_to_char( "The value must not be equal to 0.\n\r", ch );
       return;
    }

    if ( arg3[0] == 'a' ) /* alignment */
    {
       if ( value < -2000 || value > 2000 )
       {
           send_to_char( "You can only alter someone's alignment by -2000 to 2000 points.\n\r", ch );
           return;
       }
    
       if ((victim->alignment+value) > 1000)
       {
          value = (1000 - victim->alignment);
          victim->alignment = 1000;
          maxed = strdup( "high" );
       }

       else if ((victim->alignment+value) < -1000)
       {
          value = (-1000 - victim->alignment);
          victim->alignment = -1000;
          maxed = strdup( "low" );
       }
       else
          victim->alignment += value;

       if ( value == 0 )
       {
          sprintf( buf, "%s's alignment is already as %s as it can be.\n\r", victim->name, maxed );
          send_to_char(buf, ch);
          return;
       }
       else
       {
          sprintf( buf,"You alter %s's alignment by %d points.\n\r",victim->name, value);
          send_to_char(buf, ch);
       
          if ( value > 0 )
          { 
             sprintf( buf,"Your soul feels lighter and more virtuous!");
             send_to_char( buf, victim );
             return;
          }
          else
          {
             sprintf( buf,"You shudder deeply as your soul darkens.");
             send_to_char( buf, victim );
             return;
          }
       }
    }

    if ( arg3[0] == 'e' )  /* experience */
    {
       /* Cannot use the 'gain_exp' function since it won't
          give experience if the player is in the arena and it
          takes con away if they go below minimum experience
          (which could make them self-destruct).   That's just
          too mean to do during an 'award', since it might happen
          by mistake. */
          
    
       if ( victim->level >= LEVEL_HERO )
       {
          sprintf( buf, "%s cannot receive experience bonuses", victim->name );
          send_to_char( buf, ch );
          return;
       }
       
       if ( value < -1000000 || value > 1000000 )
       {
           send_to_char( "You can only award between -1000000 and 1000000 experience.\n\r", ch );
           return;
       }

       if ( victim->exp < 0 && value < 0 && victim->exp < ((-1*maxlong) - value) )
       {
          value   = (-1*maxlong) - victim->exp;
          victim->exp = (-1*maxlong);
          maxed   = strdup( "minumum" );
       }
       else if ( victim->exp > 0 && value > 0 && victim->exp > (maxlong - value) )
       {
          value   = maxlong - victim->exp;
          victim->exp = maxlong;
          maxed   = strdup( "maximum" );
       }
       else
          victim->exp += value;

       if ( value == 0 )
       {
          sprintf( buf, "%s already has the %s experience points possible.\n\r", victim->name, maxed );
          send_to_char( buf, ch );
          return;
       }
       else
       {
          sprintf( buf,"You award %s %d experience points.\n\r",victim->name, value);
          send_to_char(buf, ch);
       
          if ( value > 0 )
          { 
             sprintf( buf,"You receive %d experience points for your efforts!\n\r", value );
             send_to_char( buf, victim );
             return;
          }
          else
          {
             sprintf( buf,"You are drained of %d experience points!\n\r", value );
             send_to_char( buf, victim );
             return;
          }
       }
    }
    
    if (arg3[0] == 'g')  /* gold */
    {
       if ( value < -9999999 || value > 9999999 )
       {
           send_to_char( "You can only award between -9999999 and 9999999 gold.\n\r", ch );
           return;
       }

       if ( value < 0 && victim->gold < value )
       {
          value    = -1*victim->gold;
          victim->gold = 0;
          maxed    = strdup( "minumum" );
       }
       else if ( value > 0 && victim->gold > (maxlong - value) )
       {
          value   = maxlong - victim->exp;
          victim->exp = maxlong;
          maxed   = strdup( "maximum" );
       }
       else
          victim->gold += value;
          
       if ( value == 0 )
       {
          sprintf( buf, "%s already has the %s amount of gold allowed.\n\r", victim->name, maxed );
          send_to_char( buf, ch );
          return;
       }
       else
       {
          sprintf( buf,"You award %s %d gold coins.\n\r",victim->name, value);
          send_to_char(buf, ch);
       
          if ( value > 0 )
          { 
             sprintf( buf,"Your coin pouch grows heavier! You gain %d gold coins!\n\r", value );
             send_to_char( buf, victim );
             return;
          }
          else
          {
             sprintf( buf,"Your coin pouch grows lighter! You lose %d gold coins!\n\r", value );
             send_to_char( buf, victim );
             return;
          }
       }
    }

    if ( arg3[0] == 'o' )   /* objects */
    {
       OBJ_INDEX_DATA *pObjIndex;
       int level = get_trust(ch);
       OBJ_DATA *obj;

       if ( ( pObjIndex = get_obj_index( atoi( arg2 ) ) ) == NULL )
       {
           send_to_char( "There is no object with that vnum.\n\r", ch );
           return;
       }

       obj = create_object( pObjIndex, level );

       if ( victim->carry_number + get_obj_number( obj ) > can_carry_n( victim ) )
       {
          sprintf( buf,"Alas, %s is carrying too many items to receive that.\n\r",victim->name);
          send_to_char( buf, ch );
          extract_obj( obj );
          return;
       }

       if ( victim->carry_weight + get_obj_weight( obj ) > can_carry_w( victim ) )
       {
          sprintf( buf,"Alas, that is too heavy for %s to carry.\n\r",victim->name);
          send_to_char( buf, ch );
          extract_obj( obj );
          return;
       }
       
       obj_to_char( obj, victim );
       sprintf( buf,"You award %s item %d.\n\r",victim->name, value);
       send_to_char(buf, ch);
       
       sprintf( buf,"Your backpack seems heavier!\n\r");
       send_to_char( buf, victim );
       return;
    }
    
    return;
}  



 =============================================================================
/   ______ _______ ____   _____   ___ __    _ ______    ____  ____   _____   /
\  |  ____|__   __|  _ \ / ____\ / _ \| \  / |  ____|  / __ \|  _ \ / ____\  \
/  | |__     | |  | |_| | |     | |_| | |\/| | |___   | |  | | |_| | |       /
/  | ___|    | |  | ___/| |   __|  _  | |  | | ____|  | |  | |  __/| |   ___ \
\  | |       | |  | |   | |___| | | | | |  | | |____  | |__| | |\ \| |___| | /
/  |_|       |_|  |_|  o \_____/|_| |_|_|  |_|______|o \____/|_| \_|\_____/  \
\                                                                            /
 ============================================================================

------------------------------------------------------------------------------
ftp://ftp.game.org/pub/mud      FTP.GAME.ORG      http://www.game.org/ftpsite/
------------------------------------------------------------------------------

 This file came from FTP.GAME.ORG, the ultimate source for MUD resources.

------------------------------------------------------------------------------