eldhamud/boards/
eldhamud/clans/
eldhamud/classes/
eldhamud/councils/
eldhamud/deity/
eldhamud/doc/
eldhamud/doc/DIKU/
eldhamud/doc/MERC/
eldhamud/doc/mudprogs/
eldhamud/gods/
eldhamud/houses/
eldhamud/lockers/
eldhamud/player/a/
/****************************************************************************
 *   _______  _        ______            _______  _______           ______   *
 *  (  ____ \( \      (  __  \ |\     /|(  ___  )(       )|\     /|(  __  \  *
 *  | (    \/| (      | (  \  )| )   ( || (   ) || () () || )   ( || (  \  ) *
 *  | (__    | |      | |   ) || (___) || (___) || || || || |   | || |   ) | *
 *  |  __)   | |      | |   | ||  ___  ||  ___  || |(_)| || |   | || |   | | *
 *  | (      | |      | |   ) || (   ) || (   ) || |   | || |   | || |   ) | *
 *  | (____/\| (____/\| (__/  )| )   ( || )   ( || )   ( || (___) || (__/  ) *
 *  (_______/(_______/(______/ |/     \||/     \||/     \|(_______)(______/  *
 *              +-+-+-+  +-+-+-+-+-+-+-+  +-+-+-+-+-+-+-+-+-+-+              *
 *              |T|h|e|  |O|a|k|l|a|n|d|  |C|h|r|o|n|i|c|l|e|s|              *
 *              +-+-+-+  +-+-+-+-+-+-+-+  +-+-+-+-+-+-+-+-+-+-+              *
 * ------------------------------------------------------------------------- *
 * EldhaMUD code (C) 2003-2005 by Robert Powell (Tommi)                      *
 * EldhaMUD Team: Celest, Altere and Krelowyn                                *
 * ------------------------------------------------------------------------- *
 *                                                                           *
 ****************************************************************************/
#include <sys/types.h>
#include <string.h>
#include "./Headers/mud.h"
#include "./Headers/leatherworker.h"


/*Tailor skill by Tamarae -(tamarae@zdnetonebox.com) written for The Kravothian Mysts
 *Tailoring is the act of sewing pieces of material together to create handmade clothing
 *which in turn can be dyed many different colors and worn.  Part of the Tailoring group
 *written by Tamarae
 *Tailor skill by Tamarae -(tamarae@zdnetonebox.com)
 *Syntax: tailor <material> <clothing type>
 *
 * Tailor skill ported over to smaug1.4a by Vladaar 12-22-01 
 *
 *Modified and changed how it works, SmaugFUSS1.4 by Tommi 2005*/

void do_tailor( 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 random_number;

  /* Do we have the skill? */
  if ( !IS_NPC(ch) && !(LEARNED(ch,gsn_tailor)))
    {
      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, bracer, vest, whip\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, bracer, vest, whip\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 != OBJ_VNUM_CORPSE)
    {
      send_to_char("Sorry, you many only tailor the skins of corpses.\n\r", ch);
      return;
    }

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

  if ( number_percent() < LEARNED(ch, gsn_tailor)  ) /* create the clothing - success! */
    {
      if (!str_cmp(arg2,"cap"))
        {
          clothing = create_object(get_obj_index(OBJ_VNUM_CLOTHING), 0);
          SET_BIT(clothing->wear_flags,ITEM_WEAR_HEAD);
          strcpy(ctype, "cap" );
          clothing->weight = 10;
        }
      else if (!str_cmp(arg2,"scarf"))
        {
          clothing = create_object(get_obj_index(OBJ_VNUM_CLOTHING), 0);
          SET_BIT(clothing->wear_flags,ITEM_WEAR_NECK);
          strcpy(ctype, "scarf" );
          clothing->weight = 5;
        }

      else if (!str_cmp(arg2,"bracer"))
        {
          clothing = create_object(get_obj_index(OBJ_VNUM_CLOTHING), 0);
          SET_BIT(clothing->wear_flags,ITEM_WEAR_WRIST);
          strcpy(ctype, "bracer" );
          clothing->weight = 5;
        }
      else if (!str_cmp(arg2,"vest"))
        {
          clothing = create_object(get_obj_index(OBJ_VNUM_CLOTHING), 0);
          SET_BIT(clothing->wear_flags,ITEM_WEAR_ABOUT);
          strcpy(ctype, "vest" );
          clothing->weight = 5;
        }
      else if (!str_cmp(arg2,"tunic"))
        {
          clothing = create_object(get_obj_index(OBJ_VNUM_CLOTHING), 0);
          SET_BIT(clothing->wear_flags,ITEM_WEAR_BODY);
          strcpy(ctype, "tunic" );
          clothing->weight = 15;
        }
      else if (!str_cmp(arg2,"gloves"))
        {
          clothing = create_object(get_obj_index(OBJ_VNUM_CLOTHING), 0);
          SET_BIT(clothing->wear_flags,ITEM_WEAR_HANDS);
          strcpy(ctype, "pair of gloves" );
          clothing->weight = 5;
        }
      else if (!str_cmp(arg2,"boots"))
        {
          clothing = create_object(get_obj_index(OBJ_VNUM_CLOTHING), 0);
          SET_BIT(clothing->wear_flags,ITEM_WEAR_FEET);
          strcpy(ctype, "pair of boots" );
          clothing->weight = 10;
        }
      else if (!str_cmp(arg2,"pants"))
        {
          clothing = create_object(get_obj_index(OBJ_VNUM_CLOTHING), 0);
          SET_BIT(clothing->wear_flags,ITEM_WEAR_LEGS);
          strcpy(ctype, "pair of pants" );
          clothing->weight = 15;
        }
      else if (!str_cmp(arg2,"belt"))
        {
          clothing = create_object(get_obj_index(OBJ_VNUM_CLOTHING), 0);
          SET_BIT(clothing->wear_flags,ITEM_WEAR_WAIST);
          strcpy(ctype, "belt" );
          clothing->weight = 5;
        }
      else if (!str_cmp(arg2,"cloak"))
        {
          clothing = create_object(get_obj_index(OBJ_VNUM_CLOTHING), 0);
          SET_BIT(clothing->wear_flags,ITEM_WEAR_ABOUT);
          strcpy(ctype, "cloak" );
          clothing->weight = 20;
        }
      else if (!str_cmp(arg2,"whip"))
        {
          clothing = create_object(get_obj_index(OBJ_VNUM_FORGE_WEAPON), 0);

          clothing->value[0] = 13; //set the condition to perfect
          if(ch->level < 10)	// sets the num dice
            clothing->value[1] = 4;
          else if(ch->level < 20)
            clothing->value[1] = 6;
          else if(ch->level < 30)
            clothing->value[1] = 8;
          else if(ch->level < 40)
            clothing->value[1] = 10;
          else if(ch->level < 50)
            clothing->value[1] = 12;
          else if(ch->level < 60)
            clothing->value[1] = 14;
          else if(ch->level < 70)
            clothing->value[1] = 16;
          else if(ch->level < 80)
            clothing->value[1] = 18;
          else if(ch->level < 90)
            clothing->value[1] = 20;
          else
            clothing->value[1] = 22;


          clothing->value[2] = ch->level* 2;  //sets the size dice
          if (clothing->value[2] <= 20)
            clothing->value[2] = 20;

          clothing->level = ch->level;
          clothing->cost = 100;
          clothing->value[0] = 13;
          clothing->value[3] = 4;
          clothing->weight = 10;

          sprintf( buf, "tailored leather whip" );
          STRFREE( clothing->name );
          clothing->name = STRALLOC (buf);
          sprintf( buf, "a handmade tailored leather whip");
          STRFREE( clothing->short_descr );
          clothing->short_descr = STRALLOC ( buf );
          sprintf( buf, "A handmade tailored leather whip by %s", ch->name);
          STRFREE( clothing->description );
          clothing->description = STRALLOC ( buf );
          obj_to_char( clothing, ch );
          extract_obj( material );
          send_to_char("You snip and sew, creating a new leather whip.\n\r", ch);
          act( AT_ACTION, "$n snips and sews creating a new leather whip.", ch, NULL, NULL, TO_ROOM );
          learn_from_success( ch, gsn_tailor );
          return;

        }
      else
        {
          send_to_char( "Available clothing types:  cap, scarf, gloves, boots, belt, pants, tunic, cloak\n\r", ch);
          return;
        }

      random_number = number_range(0, 9);
      switch( random_number )
        {
        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;
        }
      separate_obj( material );
      obj_from_char( material );
      clothing->level = ch->level;
      clothing->cost = ( ch->level ) * 75;


      clothing->value[0] = ch->level / 4 + 5;
      if (clothing->value[0] < 5)
        clothing->value[0] = 5;
      clothing->value[1] = clothing->value[0];
      clothing->value[3] = 13;
      SET_BIT(clothing->item_type,ITEM_ARMOR);
      SET_BIT(clothing->wear_flags,ITEM_TAKE);
      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 );
      obj_to_char( clothing, ch );
      extract_obj( material );
      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, TO_ROOM );
      learn_from_success( ch, gsn_tailor );
      return;
    }

  else
    random_number = number_range(0, 100);
  if (random_number < 20) /*did the sewkit break?*/
    {

      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 );
      extract_obj( sewkit );
      learn_from_failure( ch, gsn_tailor );
      return;
    }
  else if (random_number > 20 && random_number < 40) /*small chance to loose all your material*/
    {
      send_to_char( "Your thread knots, and your material is ruined.\n\r", ch);
      act( AT_ACTION, "$n gets a knot in the thread and ruins the material.", ch, NULL, NULL, TO_ROOM);
      extract_obj( material );
      learn_from_failure( ch, gsn_tailor );
      return;
    }

  else if (random_number > 40 && random_number < 60)
    {
      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);
      learn_from_failure( ch, gsn_tailor );
      return;
    }

  else if (random_number >60 && random_number < 100)
    {
      send_to_char("A small tear appears in the fabric, destroying all your work.\n\r", ch);
      act( AT_ACTION, "$n tears the fabric, making a total mess.", ch, NULL, NULL, TO_ROOM);
      learn_from_failure( ch, gsn_tailor );
      return;
    }
}