I've got a command I'm working on, modify, to
basically add hp, mana, etc to an object.  It's
supposed to check if the object already has hp/etc
applied to it, and if it does then it combines the
current and added values to the one apply.  The
problem I'm getting is that if the object doesn't load
with, say mana, on it then it won't combine the
values.  But if it DOES load with mana on it, then it
will.  Any suggestions would be appreciated.
-Matt Foltz
P.S.  Please send replies directly to me - I'm not
subscribed to the list.

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com
void do_modify(CHAR_DATA *ch, char *argument, int sn)
{
    char arg1 [MAX_INPUT_LENGTH];
    char arg2 [MAX_INPUT_LENGTH];
    char arg3 [MAX_INPUT_LENGTH];
    AFFECT_DATA *paf; 
    OBJ_DATA *obj;
    int enchant_value = 0, enchant_type;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    argument = one_argument( argument, arg3 );

    if ( arg1[0] == '\0' || arg2[0] == '\0' || arg3[0] == '\0' )
    {
        send_to_char("Syntax:\n\r",ch);
        send_to_char("\n\rmodify <object> <field> <value>\n\r",ch);
        send_to_char("Field being one of:\n\r",                               
ch );
        send_to_char("hp mana move hitroll damroll saves\n\r", ch);
        send_to_char("ac str int wis dex con\n\r", ch);
        return;
    }

    if ( ( obj = get_obj_carry( ch, arg1, ch ) ) == NULL )
    {
        send_to_char("You do not have that item.\n\r", ch);
        return;
    }

    if ( !is_number ( arg3 ) )
    {
       send_to_char("Value must be numerical\n\r", ch );
       return;
    }

    enchant_value = atoi ( arg3 );

    if ( !str_prefix( arg2, "hp" ) )
       enchant_type = APPLY_HIT;
    else if ( !str_prefix ( arg2, "mana" ) )
       enchant_type = APPLY_MANA;
    else if ( !str_prefix ( arg2, "move" ) )
       enchant_type = APPLY_MOVE;
    else if ( !str_prefix ( arg2, "hitroll" ) )
       enchant_type = APPLY_HITROLL;
    else if ( !str_prefix ( arg2, "damroll" ) )
       enchant_type = APPLY_DAMROLL;
    else if ( !str_prefix ( arg2, "saves" ) )
       enchant_type = APPLY_SAVING_SPELL;
    else if ( !str_prefix ( arg2, "ac" ) )
       enchant_type = APPLY_AC;
    else if ( !str_prefix ( arg2, "str" ) )
       enchant_type = APPLY_STR;
    else if ( !str_prefix ( arg2, "int" ) )
       enchant_type = APPLY_INT;
    else if ( !str_prefix ( arg2, "wis" ) )
       enchant_type = APPLY_WIS;
    else if ( !str_prefix ( arg2, "dex" ) )
       enchant_type = APPLY_DEX;
    else if ( !str_prefix ( arg2, "con" ) )
       enchant_type = APPLY_CON;
    else
    {
       send_to_char("That modification field does not exist.\n\r", ch);
       return;
    }

    for (paf = obj->pIndexData->affected; paf != NULL; paf = paf->next) 
    {
          if ( paf->location == enchant_type )
          {
              paf->type = sn;
              paf->modifier += enchant_value;
              paf->level = ch->level;
              send_to_char("Ok.\n\r",ch );
              return;
          }
          else
          {
             AFFECT_DATA *af_new;
             af_new = new_affect();
        
             af_new->next = obj->affected;
             obj->affected = af_new;
    
             af_new->where       = paf->where;
             af_new->type        = UMAX(0,paf->type);
             af_new->level       = paf->level;
             af_new->duration    = paf->duration;
             af_new->location    = enchant_type;
             af_new->modifier    = enchant_value;
             af_new->bitvector   = paf->bitvector;
          }
    }

    send_to_char("Ok.\n\r",ch);
    return;
}

Reply via email to