eldhamud/boards/
eldhamud/clans/
eldhamud/classes/
eldhamud/councils/
eldhamud/deity/
eldhamud/doc/
eldhamud/doc/DIKU/
eldhamud/doc/MERC/
eldhamud/doc/mudprogs/
eldhamud/houses/
eldhamud/src/o/CVS/
void do_forge( CHAR_DATA *ch, char *argument )
{
  char arg1[MAX_INPUT_LENGTH];
  char arg2[MAX_INPUT_LENGTH];
  char buf[MAX_INPUT_LENGTH];
  char exdesc[20], ctype[20];
  OBJ_DATA *clothing, *material, *sewkit;
  int chance, x, mnum, rnum, xnum;

  mnum=1;
  chance = (int) (LEARNED( ch,gsn_forge));
  /* Do we have the skill? */
  if ( !IS_NPC(ch) && !(LEARNED(ch,gsn_forge)))
    {
      send_to_char( "You better leave that to those who have been trained to tailor.\n\r", ch );
      return;
    }

  argument = one_argument( argument, arg1 );

  if ( arg1[0] == '\0' )
    {
      send_to_char( "Tailor using which material?\n\r", ch );
      send_to_char( "Syntax: tailor corpse <clothing>\n\r", ch);
      send_to_char( "Available clothing types:  cap, scarf, gloves, boots, belt, pants, tunic, cloak\n\r", ch);
      return;
    }

  if ( ( material = get_obj_carry( ch, arg1 ) ) == NULL )
    {
      send_to_char( "You do not have any material to stitch.\n\r", ch );
      return;
    }
  if (material->pIndexData->vnum != 10)
    {
      send_to_char("Sorry, you many only tailor the skins of corpses.\n\r", ch);
      return;
    }
  argument = one_argument( argument, arg2 );
  if ( arg2[0] == '\0' )
    {
      send_to_char( "Syntax: tailor corpse <clothing>\n\r", ch);
      send_to_char( "Which type of clothing are you trying to tailor?\n\r", ch );
      send_to_char( "Available clothing types:  cap, scarf, gloves, boots, belt, pants, tunic, cloak\n\r", ch);
      return;
    }

  sewkit  = get_eq_char(ch,WEAR_HOLD);

  if (sewkit == NULL || sewkit->item_type != ITEM_SEWKIT)
    {
      send_to_char("You need a sewing kit in order to tailor.\n\r",ch);
      return;
    }

  /* create the clothing - success! */
  if (number_percent() < chance)
    {
      clothing = create_object(get_obj_index(OBJ_VNUM_CLOTHING), 0);
      clothing->level = number_range( 1, ch->level);
      clothing->cost = ( ch->level ) * 75;
      SET_BIT(clothing->item_type,ITEM_HANDMADE);
      SET_BIT(clothing->wear_flags,ITEM_TAKE);
      if (!str_cmp(arg2,"cap"))
        {
          SET_BIT(clothing->wear_flags,ITEM_WEAR_HEAD);
          strcpy(ctype, "cap" );
          clothing->weight = 10;
          mnum = 2;
        }
      else if (!str_cmp(arg2,"scarf"))
        {
          SET_BIT(clothing->wear_flags,ITEM_WEAR_NECK);
          strcpy(ctype, "scarf" );
          clothing->weight = 5;
          mnum = 2;
        }
      else if (!str_cmp(arg2,"tunic"))
        {
          SET_BIT(clothing->wear_flags,ITEM_WEAR_BODY);
          strcpy(ctype, "tunic" );
          clothing->weight = 15;
          mnum = 10;
        }
      else if (!str_cmp(arg2,"gloves"))
        {
          SET_BIT(clothing->wear_flags,ITEM_WEAR_HANDS);
          strcpy(ctype, "pair of gloves" );
          clothing->weight = 5;
          mnum = 3;
        }
      else if (!str_cmp(arg2,"boots"))
        {
          SET_BIT(clothing->wear_flags,ITEM_WEAR_FEET);
          strcpy(ctype, "pair of boots" );
          clothing->weight = 10;
          mnum = 5;
        }
      else if (!str_cmp(arg2,"pants"))
        {
          SET_BIT(clothing->wear_flags,ITEM_WEAR_LEGS);
          strcpy(ctype, "pair of pants" );
          clothing->weight = 15;
          mnum = 8;
        }
      else if (!str_cmp(arg2,"belt"))
        {
          SET_BIT(clothing->wear_flags,ITEM_WEAR_WAIST);
          strcpy(ctype, "belt" );
          clothing->weight = 5;
          mnum = 2;
        }
      else if (!str_cmp(arg2,"cloak"))
        {
          SET_BIT(clothing->wear_flags,ITEM_WEAR_ABOUT);
          strcpy(ctype, "cloak" );
          clothing->weight = 20;
          mnum = 10;
        }
      else
        {
          send_to_char( "Available clothing types:  cap, scarf, gloves, boots, belt, pants, tunic, cloak\n\r", ch);
          return;
        }
      rnum = number_range(0, 9);

      switch( rnum )
        {
        case 0:
          strcpy(exdesc, "fringed" );
          break;
        case 1:
          strcpy(exdesc, "embroidered" );
          break;
        case 2:
          strcpy(exdesc, "lacy"    );
          break;
        case 3:
          strcpy(exdesc, "scalloped" );
          break;
        case 4:
          strcpy(exdesc, "reinforced" );
          break;
        case 5:
          strcpy(exdesc, "stitched" );
          break;
        case 6:
          strcpy(exdesc, "double-stitched" );
          break;
        case 7:
          strcpy(exdesc, "patched" );
          break;
        case 8:
          strcpy(exdesc, "tailored" );
          break;
        case 9:
          strcpy(exdesc, "woven" );
          break;
        }

      sprintf( buf, "%s %s", exdesc, ctype );
      STRFREE( clothing->name );
      clothing->name = STRALLOC (buf);
      sprintf( buf, "a handmade %s %s", exdesc, ctype );
      STRFREE( clothing->short_descr );
      clothing->short_descr = STRALLOC ( buf );
      sprintf( buf, "A handmade %s crafted by %s", ctype, ch->name);
      STRFREE( clothing->description );
      clothing->description = STRALLOC ( buf );
      mnum = 10;
      for (x=1; x<=mnum; x++)
        {
          send_to_char( "increment\n\r", ch);
	  material = get_obj_carry (ch, arg1 );
	  
          if (material == NULL)
            {
              send_to_char( "You didn't realize it when you started, but you haven't enough material\n\r", ch);
              return;
            }
          extract_obj( material );
        }
      obj_to_char( clothing, ch );
      send_to_char("You snip and sew, creating a new piece of clothing.\n\r", ch);
      act( AT_ACTION,"$n snips and sews, creating a new piece of clothing.", ch, NULL, NULL, T0_ROOM);
      xnum = number_range(0, 100);
      if (xnum < 25) /*did the sewkit break?*/
        {
          extract_obj( sewkit );
          act( AT_ACTION, "$n pulls too hard on the needle and it breaks!", ch, NULL, NULL, TO_ROOM);
          send_to_char( "You pull too hard on the needle and it breaks!\n\r", ch );
        }
      learn_from_failure( ch, gsn_forge );
      return;
    }

  else  /* failure of skill */
    {
      for (x=number_range(1,9); x<=mnum; x++)
        {
          material = get_obj_carry (ch, arg1 );
          if (material == NULL)
            {
              send_to_char( "Your thread knots, and your material is ruined.\n\r", ch);
              return;
            }
          extract_obj( material );
        }
      send_to_char("You snip and sew, but only make a mess.\n\r", ch);
      act( AT_ACTION, "$n snips and sews but doesn't make anything useful.", ch, NULL, NULL, TO_ROOM);
      xnum = number_range(0, 100);
      if (xnum < 25) /*did the sewkit break?*/
        {
          extract_obj( sewkit );
          act( AT_ACTION, "$n pulls too hard on the needle and it breaks!", ch, NULL, NULL, TO_ROOM);
          send_to_char( "You pull too hard on the needle and it breaks!\n\r", ch );
        }
      learn_from_success( ch, gsn_forge );
    }
}