skills.c

toc/code/skills.c · 341.4 KB

From the archive fear2.1.3.tar.gz

Download the archive   « Back to the archive contents

/****************************************************************************
 * [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame      |   \\._.//   *
 * -----------------------------------------------------------|   (0...0)   *
 * SMAUG 1.4 (C) 1994, 1995, 1996, 1998  by Derek Snider      |    ).:.(    *
 * -----------------------------------------------------------|    {o o}    *
 * SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus,      |   / ' ' \   *
 * Scryn, Rennard, Swordbearer, Gorog, Grishnakh, Nivek,      |~'~.VxvxV.~'~*
 * Tricops and Fireblade                                      |             *
 * ------------------------------------------------------------------------ *
 * Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael        *
 * Chastain, Michael Quan, and Mitchell Tse.                                *
 * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,          *
 * Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe.     *
 * ------------------------------------------------------------------------ *
 *			     Player skills module			    *
 ****************************************************************************/

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "mud.h"


char *const spell_flag[] = { "water", "earth", "air", "astral", "area", "distant", "reverse",
   "noself", "_unused2_", "accumulative", "recastable", "noscribe",
   "nobrew", "group", "object", "character", "secretskill", "pksensitive",
   "stoponfail", "nofight", "nodispel", "deq", "noapplystack", "r3", "r4", "r5", "r6",
   "r7", "r8", "r9", "r10", "r11"
};

char *const spell_saves[] = { "none", "poison_death", "wands", "para_petri", "breath", "spell_staff" };

char *const spell_save_effect[] = { "none", "negate", "eightdam", "quarterdam", "halfdam", "3qtrdam",
   "reflect", "absorb"
};

char *const spell_damage[] = { "none", "fire", "water", "earth", "energy", "air", "holy", "unholy", "undead" };

char *const spell_action[] = { "none", "create", "destroy", "resist", "suscept", "divinate", "obscure",
   "change"
};

char *const spell_power[] = { "none", "minor", "greater", "major" };

char *const spell_class[] = { "none", "lunar", "solar", "travel", "summon", "life", "death", "illusion" };

char *const target_type[] = { "ignore", "offensive", "defensive", "self", "objinv", "objroom" };


void show_char_to_char(CHAR_DATA * list, CHAR_DATA * ch);
void show_list_to_char(OBJ_DATA * list, CHAR_DATA * ch, bool fShort, bool fShowN,  const int iDefaultAction);

int ris_save(CHAR_DATA * ch, int chance, int ris);
bool check_illegal_psteal(CHAR_DATA * ch, CHAR_DATA * victim);

/* from magic.c */
void failed_casting(struct skill_type *skill, CHAR_DATA * ch, CHAR_DATA * victim, OBJ_DATA * obj);


/*
 * Dummy function
 */
void skill_notfound(CHAR_DATA * ch, char *argument)
{
   send_to_char("Huh?\n\r", ch);
   return;
}


int get_ssave(char *name)
{
   int x;

   for (x = 0; x < sizeof(spell_saves) / sizeof(spell_saves[0]); x++)
      if (!str_cmp(name, spell_saves[x]))
         return x;
   return -1;
}

int get_starget(char *name)
{
   int x;

   for (x = 0; x < sizeof(target_type) / sizeof(target_type[0]); x++)
      if (!str_cmp(name, target_type[x]))
         return x;
   return -1;
}

int get_sflag(char *name)
{
   int x;

   for (x = 0; x < sizeof(spell_flag) / sizeof(spell_flag[0]); x++)
      if (!str_cmp(name, spell_flag[x]))
         return x;
   return -1;
}

int get_sdamage(char *name)
{
   int x;

   for (x = 0; x < sizeof(spell_damage) / sizeof(spell_damage[0]); x++)
      if (!str_cmp(name, spell_damage[x]))
         return x;
   return -1;
}

int get_saction(char *name)
{
   int x;

   for (x = 0; x < sizeof(spell_action) / sizeof(spell_action[0]); x++)
      if (!str_cmp(name, spell_action[x]))
         return x;
   return -1;
}

int get_ssave_effect(char *name)
{
   int x;

   for (x = 0; x < sizeof(spell_save_effect) / sizeof(spell_save_effect[0]); x++)
      if (!str_cmp(name, spell_save_effect[x]))
         return x;
   return -1;
}

int get_spower(char *name)
{
   int x;

   for (x = 0; x < sizeof(spell_power) / sizeof(spell_power[0]); x++)
      if (!str_cmp(name, spell_power[x]))
         return x;
   return -1;
}

int get_sclass(char *name)
{
   int x;

   for (x = 0; x < sizeof(spell_class) / sizeof(spell_class[0]); x++)
      if (!str_cmp(name, spell_class[x]))
         return x;
   return -1;
}

bool is_legal_kill(CHAR_DATA * ch, CHAR_DATA * vch)
{
   if (IS_NPC(ch) || IS_NPC(vch))
      return TRUE;
   if (ch->pcdata->clan && vch->pcdata->clan && ch->pcdata->clan == vch->pcdata->clan)
      return FALSE;
   if (is_safe(ch, vch))
      return FALSE;
   return TRUE;
}


extern char *target_name; /* from magic.c */

int check_twohand_shield(CHAR_DATA *ch)
{
   OBJ_DATA *shield;
   
   if ((shield = get_eq_char(ch, WEAR_SHIELD)) && IS_OBJ_STAT(shield, ITEM_TWOHANDED))
   {
      send_to_char("You cannot do that while wearing a two-handed shield.\n\r", ch);
      return FALSE;
   }
   else
      return TRUE;
}


/*
 * Perform a binary search on a section of the skill table
 * Each different section of the skill table is sorted alphabetically
 * Only match skills player knows				-Thoric
 */
bool check_skill(CHAR_DATA * ch, char *command, char *argument)
{
   int sn;
   int first = gsn_first_skill;
   int top = gsn_first_weapon - 1;
   int mana, blood;
   struct timeval time_used;
   CHAR_DATA *starget;
   sh_int begmod = 0; // Used to penalize beginners on the to hit on skills

   /* bsearch for the skill */
   for (;;)
   {
      sn = (first + top) >> 1;

      if (LOWER(command[0]) == LOWER(skill_table[sn]->name[0])
         && !str_prefix(command, skill_table[sn]->name)
         && (skill_table[sn]->skill_fun || skill_table[sn]->spell_fun != spell_null) && (can_use_skill(ch, 0, sn)))
         break;
      if (first >= top)
         return FALSE;
      if (strcmp(command, skill_table[sn]->name) < 1)
         top = sn - 1;
      else
         first = sn + 1;
   }

   if (!check_pos(ch, skill_table[sn]->minimum_position))
      return TRUE;

   if (IS_NPC(ch) && (IS_AFFECTED(ch, AFF_CHARM) || IS_AFFECTED(ch, AFF_POSSESS)))
   {
      send_to_char("For some reason, you seem unable to perform that...\n\r", ch);
      act(AT_GREY, "$n wanders around aimlessly.", ch, NULL, NULL, TO_ROOM);
      return TRUE;
   }

   /* check if mana is required */
   if (skill_table[sn]->min_mana)
   {
      mana = IS_NPC(ch) ? 0 : skill_table[sn]->min_mana;
      blood = UMAX(1, (mana + 4) / 8); /* NPCs don't have PCDatas. -- Altrag */
      if (IS_VAMPIRE(ch))
      {
         if (ch->pcdata->condition[COND_BLOODTHIRST] < blood)
         {
            send_to_char("You don't have enough blood power.\n\r", ch);
            return TRUE;
         }
      }
      else if (!IS_NPC(ch) && ch->mana < mana)
      {
         send_to_char("You don't have enough mana.\n\r", ch);
         return TRUE;
      }
   }
   else
   {
      mana = 0;
      blood = 0;
   }

   /*
    * Is this a real do-fun, or a really a spell?
    */
   if (!skill_table[sn]->skill_fun)
   {
      ch_ret retcode = rNONE;
      void *vo = NULL;
      CHAR_DATA *victim = NULL;
      OBJ_DATA *obj = NULL;
      int suc;

      target_name = "";

      switch (skill_table[sn]->target)
      {
         default:
            bug("Check_skill: bad target for sn %d.", sn);
            send_to_char("Something went wrong...\n\r", ch);
            return TRUE;

         case TAR_IGNORE:
            vo = NULL;
            starget = NULL;
            if (argument[0] == '\0')
            {
               if ((victim = who_fighting(ch)) != NULL)
                  target_name = victim->name;
            }
            else
               target_name = argument;
            break;

         case TAR_CHAR_OFFENSIVE:
            if (argument[0] == '\0' && (victim = who_fighting(ch)) == NULL)
            {
               ch_printf(ch, "Confusion overcomes you as your '%s' has no target.\n\r", skill_table[sn]->name);
               return TRUE;
            }
            else if (argument[0] != '\0' && (victim = get_char_room_new(ch, argument, 1)) == NULL)
            {
               send_to_char("They aren't here.\n\r", ch);
               return TRUE;
            }
            if (is_safe(ch, victim))
               return TRUE;

            if (ch == victim && SPELL_FLAG(skill_table[sn], SF_NOSELF))
            {
               send_to_char("You can't target yourself!\n\r", ch);
               return TRUE;
            }

            if (!IS_NPC(ch))
            {

               if (IS_AFFECTED(ch, AFF_CHARM) && ch->master == victim)
               {
                  send_to_char("You can't do that on your own follower.\n\r", ch);
                  return TRUE;
               }
            }

            check_illegal_pk(ch, victim);
            vo = (void *) victim;
            starget = victim;
            break;

         case TAR_CHAR_DEFENSIVE:
            if (argument[0] != '\0' && (victim = get_char_room_new(ch, argument, 1)) == NULL)
            {
               send_to_char("They aren't here.\n\r", ch);
               return TRUE;
            }
            if (!victim)
               victim = ch;

            if (ch == victim && SPELL_FLAG(skill_table[sn], SF_NOSELF))
            {
               send_to_char("You can't target yourself!\n\r", ch);
               return TRUE;
            }

            vo = (void *) victim;
            starget = victim;
            break;

         case TAR_CHAR_SELF:
            vo = (void *) ch;
            starget = ch;
            break;

         case TAR_OBJ_INV:
            if ((obj = get_obj_carry(ch, argument)) == NULL)
            {
               send_to_char("You can't find that.\n\r", ch);
               return TRUE;
            }
            vo = (void *) obj;
            starget = NULL;
            break;
            
         case TAR_OBJ_ROOM:
            if ((obj = get_obj_here(ch, argument)) == NULL)
            {
               send_to_char("You are not in the room with that.\n\r", ch);
               return TRUE;
            }

            vo = (void *) obj;
            starget = NULL;
            break;
      }

      /* waitstate */
      if (!ch->fighting)
         WAIT_STATE(ch, skill_table[sn]->beats*2);
      else
         ch->fight_timer = get_btimer(ch, sn, NULL);
      /* check for failure */
      if (!IS_NPC(ch) && ch->pcdata->ranking[sn] <= 1)
         begmod = 30;
      if (!IS_NPC(ch) && ch->pcdata->ranking[sn] == 2)
         begmod = 15;
      if (!IS_NPC(ch) && ch->pcdata->ranking[sn] == 4)
         begmod = -15;

      suc = 1;
      if (IS_NPC(ch))
      {
          if (number_percent() > 85)
             suc = 0;
      }
      else
      {
          if ((number_percent() + skill_table[sn]->difficulty * 5) > (90 + (ch->pcdata->learned[sn]*10)))
             suc = 0;
      }

      if (!suc)
      {
         failed_casting(skill_table[sn], ch, vo, obj);         
         learn_from_failure(ch, sn, starget);
            
         if (mana)
         {
            if (IS_VAMPIRE(ch))
               gain_condition(ch, COND_BLOODTHIRST, -blood / 2);
            else
            {
               ch->mana -= mana / 2;
               if (skill_table[sn]->type == SKILL_SKILL)
                  gain_mana_per(ch, victim, mana/2);
            }
         }
         return TRUE;
      }
      if (mana)
      {
         if (IS_VAMPIRE(ch))
            gain_condition(ch, COND_BLOODTHIRST, -blood);
         else
         {
            ch->mana -= mana;
            if (skill_table[sn]->type == SKILL_SKILL)
                  gain_mana_per(ch, victim, mana/2);
         }
      }
      start_timer(&time_used);
      retcode = (*skill_table[sn]->spell_fun) (sn, ch->level, ch, vo);
      end_timer(&time_used);
      update_userec(&time_used, &skill_table[sn]->userec);

      if (retcode == rCHAR_DIED || retcode == rERROR)
         return TRUE;

      if (char_died(ch))
         return TRUE;

      if (retcode == rSPELL_FAILED)
      {
         learn_from_failure(ch, sn, starget);
         retcode = rNONE;
      }
      else
      {
         learn_from_success(ch, sn, starget);
      }

      if (skill_table[sn]->target == TAR_CHAR_OFFENSIVE && victim != ch && !char_died(victim))
      {
         CHAR_DATA *vch;
         CHAR_DATA *vch_next;

         for (vch = ch->in_room->first_person; vch; vch = vch_next)
         {
            vch_next = vch->next_in_room;
            if (victim == vch && !victim->fighting && victim->master != ch)
            {
               retcode = one_hit(victim, ch, TYPE_UNDEFINED, LM_BODY);
               break;
            }
         }
      }
      return TRUE;
   }
   
   //for flee, don't remove
   if(!ch->fighting && !IS_NPC(ch))
        ch->fight_timer = 0;
        
   if(ch->fight_timer > 0)
   {
     displayFightTimer(ch);
     return TRUE;
   }
   if (mana)
   {
      if (IS_VAMPIRE(ch))
         gain_condition(ch, COND_BLOODTHIRST, -blood);
      else
      {
         ch->mana -= mana;
         if (skill_table[sn]->type == SKILL_SKILL)
            gain_mana_per(ch, NULL, mana/2);
      }
   }
   ch->prev_cmd = ch->last_cmd; /* haus, for automapping */
   ch->last_cmd = skill_table[sn]->skill_fun;
   start_timer(&time_used);
   (*skill_table[sn]->skill_fun) (ch, argument);
   end_timer(&time_used);
   update_userec(&time_used, &skill_table[sn]->userec);
   
   tail_chain();
   return TRUE;
}

void do_skin(CHAR_DATA * ch, char *argument)
{
   OBJ_DATA *korps;
   OBJ_DATA *corpse;
   OBJ_DATA *obj;
   OBJ_DATA *skin;
   bool found;
   char *name;
   char buf[MSL];

   found = FALSE;

   if (argument[0] == '\0')
   {
      send_to_char("Whose corpse do you wish to skin?\n\r", ch);
      return;
   }
   if ((corpse = get_obj_here(ch, argument)) == NULL)
   {
      send_to_char("You cannot find that here.\n\r", ch);
      return;
   }
   if ((obj = get_eq_char(ch, WEAR_WIELD)) == NULL)
   {
      send_to_char("You have no weapon with which to perform this deed.\n\r", ch);
      return;
   }
   if (corpse->item_type != ITEM_CORPSE_PC)
   {
      send_to_char("You can only skin the bodies of player characters.\n\r", ch);
      return;
   }
   if (wielding_skill_weapon(ch, 0) != 7)
   {
      send_to_char("There is nothing you can do with this corpse.\n\r", ch);
      return;
   }
   if (get_obj_index(OBJ_VNUM_SKIN) == NULL)
   {
      bug("Vnum 23 (OBJ_VNUM_SKIN) not found for do_skin!", 0);
      return;
   }
   korps = create_object(get_obj_index(OBJ_VNUM_CORPSE_PC), 0);
   skin = create_object(get_obj_index(OBJ_VNUM_SKIN), 0);
   name = IS_NPC(ch) ? korps->short_descr : corpse->short_descr;
   sprintf(buf, skin->short_descr, name);
   STRFREE(skin->short_descr);
   skin->short_descr = STRALLOC(buf);
   sprintf(buf, skin->description, name);
   STRFREE(skin->description);
   skin->description = STRALLOC(buf);
   act(AT_BLOOD, "$n strips the skin from $p.", ch, corpse, NULL, TO_ROOM);
   act(AT_BLOOD, "You strip the skin from $p.", ch, corpse, NULL, TO_CHAR);
/*  act( AT_MAGIC, "\nThe skinless corpse is dragged through the ground by a strange force...", ch, corpse, NULL, TO_CHAR);
    act( AT_MAGIC, "\nThe skinless corpse is dragged through the ground by a strange force...", ch, corpse, NULL, TO_ROOM);
    extract_obj( corpse ); */
   obj_to_char(skin, ch);
   return;
}

/*
 * Lookup a skills information
 * High god command
 */
void do_slookup(CHAR_DATA * ch, char *argument)
{
   char buf[MSL];
   char arg[MIL];
   int sn;
   int iRace;
   SKILLTYPE *skill = NULL;

   argument = one_argument(argument, arg);
   if (arg[0] == '\0')
   {
      send_to_char("Slookup what?\n\r", ch);
      return;
   }

   if (!str_cmp(arg, "all"))
   {
      for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
         pager_printf(ch, "Sn: %4d Slot: %4d Skill/spell: '%-20s' Damtype: %s\n\r",
            sn, skill_table[sn]->slot, skill_table[sn]->name, spell_damage[SPELL_DAMAGE(skill_table[sn])]);
   }
   else if (!str_cmp(arg, "mana"))
   {
      pager_printf(ch, " Sn   Name                       Mana  Tier  Sphere  Beats  Group\n\r");
      pager_printf(ch, "---------------------------------------------------------------------------\n\r");
      for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
      {
         if (atoi(argument) >= 1 && atoi(argument) <= 4)
         {
            if (atoi(argument) == skill_table[sn]->masterydiff[0])
            {
               pager_printf(ch, "%4d  %-25s  %-3d   %d     %d       %-2d     %d\n\r", sn, skill_table[sn]->name,
               skill_table[sn]->min_mana, skill_table[sn]->masterydiff[0], skill_table[sn]->stype, 
               skill_table[sn]->beats, skill_table[sn]->group[0]);
            }
         }
      }
      return;
   }

   else if (!str_cmp(arg, "prototype"))
   {
      pager_printf(ch, " Sn   Name                  Creator\n\r");
      pager_printf(ch, "-------------------------------------------\n\r");
      for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
         if (skill_table[sn]->prototype > 0)
         {
            pager_printf(ch, "%4d  %-20s  %-15s\n\r", sn, skill_table[sn]->name, skill_table[sn]->made_char);
         }
   }

   else if (!str_cmp(arg, "herbs"))
   {
      for (sn = 0; sn < top_herb && herb_table[sn] && herb_table[sn]->name; sn++)
         pager_printf(ch, "%d) %s\n\r", sn, herb_table[sn]->name);
   }
   else
   {
      SMAUG_AFF *aff;
      int cnt = 0;

      if (arg[0] == 'h' && is_number(arg + 1))
      {
         sn = atoi(arg + 1);
         if (!IS_VALID_HERB(sn))
         {
            send_to_char("Invalid herb.\n\r", ch);
            return;
         }
         skill = herb_table[sn];
      }
      else if (is_number(arg))
      {
         sn = atoi(arg);
         if ((skill = get_skilltype(sn)) == NULL)
         {
            send_to_char("Invalid sn.\n\r", ch);
            return;
         }
         sn %= 1000;
      }
      else if ((sn = skill_lookup(arg)) >= 0)
         skill = skill_table[sn];
      else if ((sn = herb_lookup(arg)) >= 0)
         skill = herb_table[sn];
      else
      {
         send_to_char("No such skill, spell, proficiency or tongue.\n\r", ch);
         return;
      }
      if (!skill)
      {
         send_to_char("Not created yet.\n\r", ch);
         return;
      }

      ch_printf(ch, "Sn: %4d Slot: %4d %s: '%-20s'\n\r", sn, skill->slot, skill_tname[skill->type], skill->name);
      if (skill->prototype)
         ch_printf(ch, "Prototype:  %s  ", (skill->prototype == 0) ? "No" : "Yes");
      if (skill->made_char)
         ch_printf(ch, "Made By:  %s  ", skill->made_char);
      ch_printf(ch, "\n\r");
      if (skill->info)
         ch_printf(ch, "DamType: %s  ActType: %s   ClassType: %s   PowerType: %s\n\r",
            spell_damage[SPELL_DAMAGE(skill)], spell_action[SPELL_ACTION(skill)], spell_class[SPELL_CLASS(skill)], spell_power[SPELL_POWER(skill)]);
      if (skill->flags)
      {
         int x;

         strcpy(buf, "Flags:");
         for (x = 0; x < 32; x++)
            if (SPELL_FLAG(skill, 1 << x))
            {
               strcat(buf, " ");
               strcat(buf, spell_flag[x]);
            }
         strcat(buf, "\n\r");
         send_to_char(buf, ch);
      }
      ch_printf(ch, "Saves: %s  SaveEffect: %s\n\r", spell_saves[(int) skill->saves], spell_save_effect[SPELL_SAVE(skill)]);

      if (skill->difficulty != '\0')
         ch_printf(ch, "Difficulty: %d\n\r", (int) skill->difficulty);

      ch_printf(ch, "Tier %d  TrainerNum %d  Group %d  Sphere %d", skill->masterydiff[0], skill->bookinfo[0], skill->group[0], skill->stype);
      if (skill->targetlimb > 0)
         ch_printf(ch, " Targetlimb %d\n\r", skill->targetlimb);
      else
         send_to_char("\n\r", ch);

      ch_printf(ch, "Type: %s  Target: %s  Minpos: %d  Mana: %d  Beats: %d  Range: %d\n\r",
         skill_tname[skill->type],
         target_type[URANGE(TAR_IGNORE, skill->target, TAR_OBJ_ROOM)], skill->minimum_position, skill->min_mana, skill->beats, skill->range);
      ch_printf(ch, "Flags: %d  Guild: %d  Value: %d  Info: %d  Code: %s\n\r",
         skill->flags, skill->guild, skill->value, skill->info, skill->skill_fun ? skill_name(skill->skill_fun) : spell_name(skill->spell_fun));
      ch_printf(ch, "Dammsg: %s\n\rWearoff: %s\n", skill->noun_damage, skill->msg_off ? skill->msg_off : "(none set)");
      if (skill->dice && skill->dice[0] != '\0')
         ch_printf(ch, "Dice: %s\n\r", skill->dice);
      if (skill->teachers && skill->teachers[0] != '\0')
         ch_printf(ch, "Teachers: %s\n\r", skill->teachers);
      if (skill->components && skill->components[0] != '\0')
         ch_printf(ch, "Components: %s\n\r", skill->components);
      if (skill->participants)
         ch_printf(ch, "Participants: %d\n\r", (int) skill->participants);
      if (skill->userec.num_uses)
         send_timer(&skill->userec, ch);
      for (aff = skill->affects; aff; aff = aff->next)
      {
         if (aff == skill->affects)
            send_to_char("\n\r", ch);
         sprintf(buf, "Affect %d", ++cnt);
         if (aff->location)
         {
            strcat(buf, " modifies ");
            strcat(buf, a_types[aff->location % REVERSE_APPLY]);
            strcat(buf, " by '");
            strcat(buf, aff->modifier);
            if (aff->bitvector != -1)
               strcat(buf, "' and");
            else
               strcat(buf, "'");
         }
         if (aff->bitvector != -1)
         {
            strcat(buf, " applies ");
            strcat(buf, a_flags[aff->bitvector]);
         }
         if (aff->duration[0] != '\0' && aff->duration[0] != '0')
         {
            strcat(buf, " for '");
            strcat(buf, aff->duration);
            strcat(buf, "' rounds");
         }
         if (aff->location >= REVERSE_APPLY)
            strcat(buf, " (affects caster only)");
         strcat(buf, "\n\r");
         send_to_char(buf, ch);
         if (!aff->next)
            send_to_char("\n\r", ch);
      }
      if (skill->hit_char && skill->hit_char[0] != '\0')
         ch_printf(ch, "Hitchar   : %s\n\r", skill->hit_char);
      if (skill->hit_vict && skill->hit_vict[0] != '\0')
         ch_printf(ch, "Hitvict   : %s\n\r", skill->hit_vict);
      if (skill->hit_room && skill->hit_room[0] != '\0')
         ch_printf(ch, "Hitroom   : %s\n\r", skill->hit_room);
      if (skill->hit_dest && skill->hit_dest[0] != '\0')
         ch_printf(ch, "Hitdest   : %s\n\r", skill->hit_dest);
      if (skill->miss_char && skill->miss_char[0] != '\0')
         ch_printf(ch, "Misschar  : %s\n\r", skill->miss_char);
      if (skill->miss_vict && skill->miss_vict[0] != '\0')
         ch_printf(ch, "Missvict  : %s\n\r", skill->miss_vict);
      if (skill->miss_room && skill->miss_room[0] != '\0')
         ch_printf(ch, "Missroom  : %s\n\r", skill->miss_room);
      if (skill->die_char && skill->die_char[0] != '\0')
         ch_printf(ch, "Diechar   : %s\n\r", skill->die_char);
      if (skill->die_vict && skill->die_vict[0] != '\0')
         ch_printf(ch, "Dievict   : %s\n\r", skill->die_vict);
      if (skill->die_room && skill->die_room[0] != '\0')
         ch_printf(ch, "Dieroom   : %s\n\r", skill->die_room);
      if (skill->imm_char && skill->imm_char[0] != '\0')
         ch_printf(ch, "Immchar   : %s\n\r", skill->imm_char);
      if (skill->imm_vict && skill->imm_vict[0] != '\0')
         ch_printf(ch, "Immvict   : %s\n\r", skill->imm_vict);
      if (skill->imm_room && skill->imm_room[0] != '\0')
         ch_printf(ch, "Immroom   : %s\n\r", skill->imm_room);
      if (skill->type != SKILL_HERB)
      {
         if (skill->type == SKILL_RACIAL)
         {
            send_to_char("\n\r--------------------------[RACE USE]--------------------------\n\r", ch);
            for (iRace = 0; iRace < MAX_RACE; iRace++)
            {
               sprintf(buf, "%8.8s) lvl: %3d max: %2d%%", race_table[iRace]->race_name, skill->race_level[iRace], skill->race_adept[iRace]);
               if (!strcmp(race_table[iRace]->race_name, "unused"))
                  sprintf(buf, "                           ");
               if ((iRace > 0) && (iRace % 2 == 1))
                  strcat(buf, "\n\r");
               else
                  strcat(buf, "  ");
               send_to_char(buf, ch);
            }
         }

      }
      send_to_char("\n\r", ch);

   }

   return;
}

/*
 * Set a skill's attributes or what skills a player has.
 * High god command, with support for creating skills/spells/herbs/etc
 */
void do_sset(CHAR_DATA * ch, char *argument)
{
   char arg1[MIL];
   char arg2[MIL];
   char arg3[MIL]; /* Used for mastery setting -- Xerves 2/00 */
   CHAR_DATA *victim;
   int value;
   int mvalue = -1;
   int sn, i;
   bool fAll;

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

   if (arg1[0] == '\0' || arg2[0] == '\0' || argument[0] == '\0')
   {
      send_to_char("Syntax: sset <victim> <skill> <point value/keep> [mastery value]\n\r", ch);
      send_to_char("or:     sset <victim> all     <point value/keep> [mastery value]\n\r", ch);
      if (get_ftrust(ch) >= LEVEL_HI_STAFF) /* Tracker1 */
      {
         send_to_char("or:     sset save skill table\n\r", ch);
         send_to_char("or:     sset save herb table\n\r", ch);
         send_to_char("or:     sset create skill 'new skill'\n\r", ch);
         send_to_char("or:     sset create herb 'new herb'\n\r", ch);
         send_to_char("or:     sset create ability 'new ability'\n\r", ch);
      }
      if (get_ftrust(ch) >= LEVEL_STAFF) /* Tracker1 */
      {
         send_to_char("or:     sset <sn>     <field> <value>\n\r", ch);
         send_to_char("\n\rField being one of:\n\r", ch);
         send_to_char("  name code target minpos slot mana beats dammsg wearoff guild minlevel\n\r", ch);
         send_to_char("  type damtype acttype classtype powertype seffect flag dice value difficulty\n\r", ch);
         send_to_char("  affect rmaffect mastery hit miss die imm (char/vict/room) targetlimb\n\r", ch);
         send_to_char("  components teachers racelevel raceadept prototype madeby group tier sphere\n\r", ch);
         send_to_char("Affect having the fields: <location> <modfifier> [duration] [bitvector]\n\r", ch);
         send_to_char("(See AFFECTTYPES for location, and AFFECTED_BY for bitvector)\n\r", ch);
      }
      send_to_char("Skill being any skill or spell.\n\r", ch);
      return;
   }

   if (get_ftrust(ch) > LEVEL_HI_STAFF /* Tracker1 */
      && !str_cmp(arg1, "save") && !str_cmp(argument, "table"))
   {
      if (!str_cmp(arg2, "skill"))
      {
         send_to_char("Saving skill table...\n\r", ch);
         save_skill_table();
         save_classes();
         /* save_races(); */
         return;
      }
      if (!str_cmp(arg2, "herb"))
      {
         send_to_char("Saving herb table...\n\r", ch);
         save_herb_table();
         return;
      }
   }
   if (get_ftrust(ch) > LEVEL_HI_STAFF /* Tracker1 */
      && !str_cmp(arg1, "create") && (!str_cmp(arg2, "skill") || !str_cmp(arg2, "herb") || !str_cmp(arg2, "ability")))
   {
      struct skill_type *skill;
      sh_int type = SKILL_UNKNOWN;

      if (!str_cmp(arg2, "herb"))
      {
         type = SKILL_HERB;
         if (top_herb >= MAX_HERB)
         {
            ch_printf(ch, "The current top herb is %d, which is the maximum.  "
               "To add more herbs,\n\rMAX_HERB will have to be " "raised in mud.h, and the mud recompiled.\n\r", top_sn);
            return;
         }
      }
      else if (top_sn >= MAX_SKILL)
      {
         ch_printf(ch, "The current top sn is %d, which is the maximum.  "
            "To add more skills,\n\rMAX_SKILL will have to be " "raised in mud.h, and the mud recompiled.\n\r", top_sn);
         return;
      }
      CREATE(skill, struct skill_type, 1);
      skill->slot = 0;
      if (type == SKILL_HERB)
      {
         int max, x;

         herb_table[top_herb++] = skill;
         for (max = x = 0; x < top_herb - 1; x++)
            if (herb_table[x] && herb_table[x]->slot > max)
               max = herb_table[x]->slot;
         skill->slot = max + 1;
      }
      else
         skill_table[top_sn++] = skill;
      skill->min_mana = 0;
      skill->name = str_dup(argument);
      skill->noun_damage = str_dup("");
      skill->msg_off = str_dup("");
      skill->spell_fun = spell_smaug;
      skill->type = type;
      skill->prototype = 1;
      skill->made_char = ch->name;
      if (!str_cmp(arg2, "ability"))
         skill->type = SKILL_RACIAL;

      for (i = 0; i < MAX_RACE; i++)
      {
         skill->race_level[i] = LEVEL_IMMORTAL;
         skill->race_adept[i] = 95;
      }

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

   if (arg1[0] == 'h')
      sn = atoi(arg1 + 1);
   else
      sn = atoi(arg1);
   if (get_trust(ch) > LEVEL_STAFF /* Tracker1 */
      && ((arg1[0] == 'h' && is_number(arg1 + 1) && (sn = atoi(arg1 + 1)) >= 0) || (is_number(arg1) && (sn = atoi(arg1)) >= 0)))
   {
      struct skill_type *skill;

      if (arg1[0] == 'h')
      {
         if (sn >= top_herb)
         {
            send_to_char("Herb number out of range.\n\r", ch);
            return;
         }
         skill = herb_table[sn];
      }
      else
      {
         if ((skill = get_skilltype(sn)) == NULL)
         {
            send_to_char("Skill number out of range.\n\r", ch);
            return;
         }
         sn %= 1000;
      }

      if (!str_cmp(arg2, "difficulty"))
      {
         skill->difficulty = atoi(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "participants"))
      {
         skill->participants = atoi(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "damtype"))
      {
         int x = get_sdamage(argument);

         if (x == -1)
            send_to_char("Not a spell damage type.\n\r", ch);
         else
         {
            SET_SDAM(skill, x);
            send_to_char("Ok.\n\r", ch);
         }
         return;
      }
      if (!str_cmp(arg2, "acttype"))
      {
         int x = get_saction(argument);

         if (x == -1)
            send_to_char("Not a spell action type.\n\r", ch);
         else
         {
            SET_SACT(skill, x);
            send_to_char("Ok.\n\r", ch);
         }
         return;
      }
         
      if (!str_cmp(arg2, "classtype"))
      {
         int x = get_sclass(argument);

         if (x == -1)
            send_to_char("Not a spell class type.\n\r", ch);
         else
         {
            SET_SCLA(skill, x);
            send_to_char("Ok.\n\r", ch);
         }
         return;
      }
      if (!str_cmp(arg2, "powertype"))
      {
         int x = get_spower(argument);

         if (x == -1)
            send_to_char("Not a spell power type.\n\r", ch);
         else
         {
            SET_SPOW(skill, x);
            send_to_char("Ok.\n\r", ch);
         }
         return;
      }
      if (!str_cmp(arg2, "seffect"))
      {
         int x = get_ssave_effect(argument);

         if (x == -1)
            send_to_char("Not a spell save effect type.\n\r", ch);
         else
         {
            SET_SSAV(skill, x);
            send_to_char("Ok.\n\r", ch);
         }
         return;
      }
      if (!str_cmp(arg2, "flag"))
      {
         int x = get_sflag(argument);

         if (x == -1)
            send_to_char("Not a spell flag.\n\r", ch);
         else
         {
            TOGGLE_BIT(skill->flags, 1 << x);
            send_to_char("Ok.\n\r", ch);
         }
         return;
      }
      if (!str_cmp(arg2, "saves"))
      {
         int x = get_ssave(argument);

         if (x == -1)
            send_to_char("Not a saving type.\n\r", ch);
         else
         {
            skill->saves = x;
            send_to_char("Ok.\n\r", ch);
         }
         return;
      }

      if (!str_cmp(arg2, "code"))
      {
         SPELL_FUN *spellfun;
         DO_FUN *dofun;

         if ((spellfun = spell_function(argument)) != spell_notfound)
         {
            skill->spell_fun = spellfun;
            skill->skill_fun = NULL;
         }
         else if ((dofun = skill_function(argument)) != skill_notfound)
         {
            skill->skill_fun = dofun;
            skill->spell_fun = NULL;
         }
         else
         {
            send_to_char("Not a spell or skill.\n\r", ch);
            return;
         }
         send_to_char("Ok.\n\r", ch);
         return;
      }

      if (!str_cmp(arg2, "target"))
      {
         int x = get_starget(argument);

         if (x == -1)
            send_to_char("Not a valid target type.\n\r", ch);
         else
         {
            skill->target = x;
            send_to_char("Ok.\n\r", ch);
         }
         return;
      }
      if (!str_cmp(arg2, "sphere"))
      {
         if (atoi(argument) < 1 || atoi(argument) > MAX_SPHERE)
         {
            ch_printf(ch, "Valid range is 1 to %d.\n\r", MAX_SPHERE);
            return;
         }
         else
         {
            skill->stype = atoi(argument);
            send_to_char("Ok.\n\r", ch);
            return;
         }
      }
      if (!str_cmp(arg2, "targetlimb"))
      {
         if (atoi(argument) < 0 || atoi(argument) > 5)
         {
            send_to_char("Range is 0 to 5.\n\r", ch);
            return;
         }
         else
         {
            skill->targetlimb = atoi(argument);
            send_to_char("Ok.\n\r", ch);
            return;
         }
      }
      if (!str_cmp(arg2, "group"))
      {
         if (atoi(argument) < 1 || atoi(argument) > MAX_GROUP)
         {
            ch_printf(ch, "Valid range is 1 to %d.\n\r", MAX_GROUP);
            return;
         }
         else
         {
            skill->group[0] = atoi(argument);
            send_to_char("Ok.\n\r", ch);
            return;
         }
      }
      if (!str_cmp(arg2, "masterydiff") || !str_cmp(arg2, "mastery diff") || !str_cmp(arg2, "tier"))
      {
         if (atoi(argument) < 1 || atoi(argument) > MAX_RANKING)
         {
            ch_printf(ch, "Valid range is 1 to %d.\n\r", MAX_RANKING);
            return;
         }
         else
         {
            skill->masterydiff[0] = atoi(argument);
            send_to_char("Ok.\n\r", ch);
            return;
         }
      }
      if (!str_cmp(arg2, "minpos"))
      {
         skill->minimum_position = URANGE(POS_DEAD, atoi(argument), POS_DRAG);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "minlevel"))
      {
         skill->min_level = URANGE(1, atoi(argument), MAX_LEVEL);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "slot"))
      {
         skill->slot = URANGE(0, atoi(argument), 30000);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "mana"))
      {
         skill->min_mana = URANGE(0, atoi(argument), 2000);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "beats"))
      {
         skill->beats = URANGE(0, atoi(argument), 120);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "range"))
      {
         skill->range = URANGE(0, atoi(argument), 20);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "guild"))
      {
         skill->guild = atoi(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "value"))
      {
         skill->value = atoi(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "type"))
      {
         skill->type = get_skill(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "rmaffect"))
      {
         SMAUG_AFF *aff = skill->affects;
         SMAUG_AFF *aff_next;
         int num = atoi(argument);
         int cnt = 1;

         if (!aff)
         {
            send_to_char("This spell has no special affects to remove.\n\r", ch);
            return;
         }
         if (num == 1)
         {
            skill->affects = aff->next;
            DISPOSE(aff->duration);
            DISPOSE(aff->modifier);
            DISPOSE(aff);
            send_to_char("Removed.\n\r", ch);
            return;
         }
         for (; aff; aff = aff->next)
         {
            if (++cnt == num && (aff_next = aff->next) != NULL)
            {
               aff->next = aff_next->next;
               DISPOSE(aff_next->duration);
               DISPOSE(aff_next->modifier);
               DISPOSE(aff_next);
               send_to_char("Removed.\n\r", ch);
               return;
            }
         }
         send_to_char("Not found.\n\r", ch);
         return;
      }
      /*
       * affect <location> <modifier> <duration> <bitvector>
       */
      if (!str_cmp(arg2, "affect"))
      {
         char location[MIL];
         char modifier[MIL];
         char duration[MIL];

/*	    char bitvector[MIL];	*/
         int loc, bit, tmpbit;
         SMAUG_AFF *aff;

         argument = one_argument(argument, location);
         argument = one_argument(argument, modifier);
         argument = one_argument(argument, duration);

         if (location[0] == '!')
            loc = get_atype(location + 1) + REVERSE_APPLY;
         else
            loc = get_atype(location);
         if ((loc % REVERSE_APPLY) < 0 || (loc % REVERSE_APPLY) >= MAX_APPLY_TYPE)
         {
            send_to_char("Unknown affect location.  See AFFECTTYPES.\n\r", ch);
            return;
         }
         bit = -1;
         if (argument[0] != 0)
         {
            if ((tmpbit = get_aflag(argument)) == -1)
               ch_printf(ch, "Unknown bitvector: %s.  See AFFECTED_BY\n\r", argument);
            else
               bit = tmpbit;
         }
         CREATE(aff, SMAUG_AFF, 1);
         if (!str_cmp(duration, "0"))
            duration[0] = '\0';
         if (!str_cmp(modifier, "0"))
            modifier[0] = '\0';
         aff->duration = str_dup(duration);
         aff->location = loc;
         aff->modifier = str_dup(modifier);
         aff->bitvector = bit;
         aff->next = skill->affects;
         skill->affects = aff;
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "racelevel"))
      {
         char arg3[MIL];
         int race;

         argument = one_argument(argument, arg3);
         race = atoi(arg3);
         if (race >= MAX_RACE || race < 0)
            send_to_char("Not a valid race.\n\r", ch);
         else
            skill->race_level[race] = URANGE(0, atoi(argument), MAX_LEVEL);
         return;
      }
      if (!str_cmp(arg2, "raceadept"))
      {
         char arg3[MIL];
         int race;

         argument = one_argument(argument, arg3);
         race = atoi(arg3);
         if (race >= MAX_RACE || race < 0)
            send_to_char("Not a valid race.\n\r", ch);
         else
            skill->race_adept[race] = URANGE(0, atoi(argument), 100);
         return;
      }


      if (!str_cmp(arg2, "name"))
      {
         DISPOSE(skill->name);
         skill->name = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "prototype"))
      {
         int pro = atoi(argument);

         if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
         {
            send_to_char("Sorry, only staff can change this.\n\r", ch);
            return;
         }
         if (pro > 1 || pro < 0)
         {
            send_to_char("0 for no, 1 for yes\n\r", ch);
            return;
         }
         skill->prototype = atoi(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "madeby"))
      {
         if (get_trust(ch) < LEVEL_STAFF) /* Tracker1 */
         {
            send_to_char("Sorry, only staff can change this.\n\r", ch);
            return;
         }
         DISPOSE(skill->made_char);
         skill->made_char = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "dammsg"))
      {
         DISPOSE(skill->noun_damage);
         if (!str_cmp(argument, "clear"))
            skill->noun_damage = str_dup("");
         else
            skill->noun_damage = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "wearoff"))
      {
         DISPOSE(skill->msg_off);
         if (str_cmp(argument, "clear"))
            skill->msg_off = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "hitchar"))
      {
         if (skill->hit_char)
            DISPOSE(skill->hit_char);
         if (str_cmp(argument, "clear"))
            skill->hit_char = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "hitvict"))
      {
         if (skill->hit_vict)
            DISPOSE(skill->hit_vict);
         if (str_cmp(argument, "clear"))
            skill->hit_vict = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "hitroom"))
      {
         if (skill->hit_room)
            DISPOSE(skill->hit_room);
         if (str_cmp(argument, "clear"))
            skill->hit_room = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "hitdest"))
      {
         if (skill->hit_dest)
            DISPOSE(skill->hit_dest);
         if (str_cmp(argument, "clear"))
            skill->hit_dest = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "misschar"))
      {
         if (skill->miss_char)
            DISPOSE(skill->miss_char);
         if (str_cmp(argument, "clear"))
            skill->miss_char = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "missvict"))
      {
         if (skill->miss_vict)
            DISPOSE(skill->miss_vict);
         if (str_cmp(argument, "clear"))
            skill->miss_vict = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "missroom"))
      {
         if (skill->miss_room)
            DISPOSE(skill->miss_room);
         if (str_cmp(argument, "clear"))
            skill->miss_room = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "diechar"))
      {
         if (skill->die_char)
            DISPOSE(skill->die_char);
         if (str_cmp(argument, "clear"))
            skill->die_char = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "dievict"))
      {
         if (skill->die_vict)
            DISPOSE(skill->die_vict);
         if (str_cmp(argument, "clear"))
            skill->die_vict = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "dieroom"))
      {
         if (skill->die_room)
            DISPOSE(skill->die_room);
         if (str_cmp(argument, "clear"))
            skill->die_room = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "immchar"))
      {
         if (skill->imm_char)
            DISPOSE(skill->imm_char);
         if (str_cmp(argument, "clear"))
            skill->imm_char = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "immvict"))
      {
         if (skill->imm_vict)
            DISPOSE(skill->imm_vict);
         if (str_cmp(argument, "clear"))
            skill->imm_vict = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "immroom"))
      {
         if (skill->imm_room)
            DISPOSE(skill->imm_room);
         if (str_cmp(argument, "clear"))
            skill->imm_room = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "dice"))
      {
         if (skill->dice)
            DISPOSE(skill->dice);
         if (str_cmp(argument, "clear"))
            skill->dice = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "components"))
      {
         if (skill->components)
            DISPOSE(skill->components);
         if (str_cmp(argument, "clear"))
            skill->components = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      if (!str_cmp(arg2, "teachers"))
      {
         if (skill->teachers)
            DISPOSE(skill->teachers);
         if (str_cmp(argument, "clear"))
            skill->teachers = str_dup(argument);
         send_to_char("Ok.\n\r", ch);
         return;
      }
      do_sset(ch, "");
      return;
   }
   //sset <victim> <skill> <point value> <mastery value>
   if ((victim = get_char_world(ch, arg1)) == NULL)
   {
      if ((sn = skill_lookup(arg1)) >= 0)
      {
         sprintf(arg1, "%d %s %s", sn, arg2, argument);
         do_sset(ch, arg1);
      }
      else
         send_to_char("They aren't here.\n\r", ch);
      return;
   }

   if (IS_NPC(victim))
   {
      send_to_char("Not on NPC's.\n\r", ch);
      return;
   }
   argument = one_argument(argument, arg3);
   fAll = !str_cmp(arg2, "all");
   sn = 0;
   if (!fAll && (sn = skill_lookup(arg2)) < 0)
   {
      send_to_char("No such skill or spell.\n\r", ch);
      return;
   }
   if (!is_number(arg3) && str_cmp(arg3, "keep"))
   {
      send_to_char("Point Value must be numeric.\n\r", ch);
      return;
   }

   value = atoi(arg3);
   if (!str_cmp(arg3, "keep"))
      value = -1;
   if (value < -1 || value > MAX_SKPOINTS)
   {
      ch_printf(ch, "Point Value range is 0 to %d.\n\r", MAX_SKPOINTS);
      return;
   }
   if (argument[0] != '\0')
   {
      if (!is_number(argument))
      {
         send_to_char("Mastery Value must be numeric.\n\r", ch);
         return;
      }

      mvalue = atoi(argument);
      if (mvalue < 0 || mvalue > MAX_RANKING)
      {
         ch_printf(ch, "Mastery Value range is 0 to %d.\n\r", MAX_RANKING);
         return;
      }
   }  
   if (fAll)
   {
      for (sn = 0; sn < top_sn; sn++)
      {
         /* Fix by Narn to prevent ssetting skills the player shouldn't have. */
         if (skill_table[sn]->name)
         {
            if (value >= 0)
               victim->pcdata->learned[sn] = value;
            if (mvalue >= 0)
               victim->pcdata->ranking[sn] = mvalue;
            if ((skill_table[sn]->group[0] < 23 || skill_table[sn]->group[0] > 29)
            && (skill_table[sn]->group[0] < 31 || skill_table[sn]->group[0] > 34))
            {
               if (value >= 0)
                  victim->pcdata->spellpoints[skill_table[sn]->group[0]] = value;
               if (mvalue >= 0)
                  victim->pcdata->spellgroups[skill_table[sn]->group[0]] = mvalue;
            }        
         }
      }
   }
   else
   {
      if ((skill_table[sn]->group[0] < 23 || skill_table[sn]->group[0] > 29)
      && (skill_table[sn]->group[0] < 31 || skill_table[sn]->group[0] > 34))
      {
         if (value >= 0)
            victim->pcdata->spellpoints[skill_table[sn]->group[0]] = value;
         if (mvalue >= 0)
            victim->pcdata->spellgroups[skill_table[sn]->group[0]] = mvalue;
      }
      if (value >= 0)  
         victim->pcdata->learned[sn] = value;
      if (mvalue >= 0)
         victim->pcdata->ranking[sn] = mvalue;
   }
   return;
}
int group_in_sphere(int group)
{
   switch (group)
   {
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
         return 3;
      
      case 6:
      case 19:
      case 20:
      case 21:
      case 22:
      case 23:
         return 4;
      
      case 7:
      case 8:
      case 9:
      case 10:
      case 18:
         return 5;
         
      case 11:
      case 12:
      case 13:
         return 2;
      
      case 14:
      case 15:
      case 16:
      case 17:
         return 1;
      
   }
   return 0;
}

//Gets values to modify flux on a skill/spell, the actually "curving" of the system to prevent super characters
//Can make some beginnger skills/spells master difficulty to learn if you are going against the grain
int get_skillflux_value(CHAR_DATA *ch, int ssn)
{  
   int sn;
   int i;
   int snvalue = 0;   //Point value for the sn's group/mastery
   int restvalue = 0; //Point value for the other groups/mastery
   int totalvalue = 0; //Point total for all spheres.
   int diff = 0;
   int master = 0;
   int specialist = 0;
   //Check to see if points are setup yet in spherepoints and grouppoints
   if (ch->pcdata->spherepoints[1] == -1 || ch->pcdata->grouppoints[1] == -1)
   {
      for (i = 1; i <= MAX_SPHERE; i++)
         ch->pcdata->spherepoints[i] = 0;
      for (i = 1; i <= MAX_GROUP+5; i++)
         ch->pcdata->grouppoints[i] = 0;
      for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
      {
         if (skill_table[sn]->group[0] > 0)
         {
            if (skill_table[sn]->stype == 4 && skill_table[sn]->group[0] != 6)
            {
               ch->pcdata->grouppoints[skill_table[sn]->group[0]+MAX_GROUP] += ch->pcdata->learned[sn];
               ch->pcdata->spherepoints[skill_table[sn]->stype] += ch->pcdata->learned[sn];
            }
            else
            {
               ch->pcdata->grouppoints[skill_table[sn]->group[0]] += ch->pcdata->learned[sn];
               ch->pcdata->spherepoints[skill_table[sn]->stype] += ch->pcdata->learned[sn];
            }
         }
      }
   }
   //Check to see if player is beyond Beginner
   for (sn = 0; sn < top_sn && skill_table[sn] && skill_table[sn]->name; sn++)
   {
      if ((ch->pcdata->ranking[sn] >= 2 || ch->pcdata->learned[sn] >= 6) 
      &&  (skill_table[sn]->type == SKILL_SPELL || skill_table[sn]->type == SKILL_SKILL))
      {
         diff = 1; //Beyond the "grace period" above the curve
         break;
      }
   }
   //Next check groups, if the sn is in the "master" sphere, compare against other groups instead of spheres
   //Has to possess majority of points or more
   for (i = 1; i <= MAX_SPHERE; i++)
   { 
      totalvalue += ch->pcdata->spherepoints[i];
   }
   for (i = 1; i <= MAX_SPHERE; i++)
   {
      if (ch->pcdata->spherepoints[i] > totalvalue/2) // > 50 percent of all points
         break;
   }
   if (ch->pcdata->spherepoints[skill_table[ssn]->stype] == totalvalue)
   {
      specialist = 1;
      master = 1;
   }
   else if (i > MAX_SPHERE) 
      master = 0;      //no master sphere 
   else if (skill_table[ssn]->stype == i)
      master = 1;      //skill is in master sphere
   else if (i <= MAX_SPHERE) 
      master = 0;      //there is a master sphere, but you aren't in it
      
   if (master == 1 && diff == 1) //spell/skill is in the master sphere   
   {
      int group = skill_table[ssn]->group[0];
      
      if (skill_table[ssn]->stype == 4 && skill_table[ssn]->group[0] != 6)
         group = skill_table[ssn]->group[0]+MAX_GROUP;
      for (i = 1; i <= MAX_GROUP+5; i++)
      {
         if (group_in_sphere(i) == skill_table[ssn]->stype)
         {
            if (i == group)
               snvalue += ch->pcdata->grouppoints[i];
            else
               restvalue += ch->pcdata->grouppoints[i];
         }
      }
   }
   else //spell/skill is not in the master sphere
   {
      for (i = 1; i <= MAX_SPHERE; i++)
      {
         if (skill_table[ssn]->stype == i)
            snvalue += ch->pcdata->spherepoints[i];
         else
            restvalue += ch->pcdata->spherepoints[i];
      }
   }
   //now we have all the values talied, lets spit out the percents and modify based on the "curve"
   
   //a slightly less mean curve when you first start out so you can start a few different things at once before
   //getting blasted by the curve
   if (diff == 0)
   {
      if (snvalue > restvalue)
         return 100;
      else
         return 70;
   }   	
   if (restvalue <= 0 || specialist == 1)
      diff = 1000;
   else
      diff = 1000*snvalue/(restvalue+snvalue);
   //1000 diff means 1:1  500 diff means 1:2  10000 diff means 10:1, etc.  Higher the more dominant the group/sphere
   //Lower the less dominant.  Higher dominance equals more gain, pretty straight.
   if (master == 0) //no dominant group, lets make one :-)
   {
      if (diff < 1000)
      {
         return (diff*100/1000);
      }
      else
         return 100;
   }
   if (master == 1) //bonus if you are learning in the master sphere
   {
      if (diff < 1000)
      {
         return 60+(diff*40/1000);
      }
      else
         return 100;
   }
   return 100;
}

//return points earned on percent based on mastery alone, used for learn_from_success/failure
int base_learn_value(CHAR_DATA *ch, int sn)
{
   int change = 0;
   int pos = 0;
   
   if (ch->pcdata->learned[sn] >= 1 && ch->pcdata->learned[sn] <= 4)
   {
      if (ch->pcdata->learned[sn] == 1)
         change = number_range(500, 750);
      if (ch->pcdata->learned[sn] == 2)
         change = number_range(400, 600);
      if (ch->pcdata->learned[sn] == 3)
         change = number_range(350, 550);
      if (ch->pcdata->learned[sn] == 4)
         change = number_range(300, 500);
   }
   else if (ch->pcdata->learned[sn] >= 5 && ch->pcdata->learned[sn] <= 7)
   {
      if (ch->pcdata->learned[sn] == 5)
         change = number_range(200, 300);
      if (ch->pcdata->learned[sn] == 6)
         change = number_range(170, 250);
      if (ch->pcdata->learned[sn] == 7)
         change = number_range(130, 190);
      
      if (ch->pcdata->ranking[sn] == 1 && ch->pcdata->learned[sn] >= 5)
         change /= 3;
   }
   else if (ch->pcdata->learned[sn] >= 8 && ch->pcdata->learned[sn] <= 10)
   {
      if (ch->pcdata->learned[sn] == 8)
         change = number_range(80, 120);
      if (ch->pcdata->learned[sn] == 9)
         change = number_range(65, 90);
      if (ch->pcdata->learned[sn] == 10)
         change = number_range(50, 70);
         
      if (ch->pcdata->ranking[sn] == 1)
         change = 1;
      if (ch->pcdata->ranking[sn] == 2 && ch->pcdata->learned[sn] >= 8)
         change /= 3;
   }
   else if (ch->pcdata->learned[sn] >= 11 && ch->pcdata->learned[sn] <= 13)
   {
      if (ch->pcdata->learned[sn] == 11)
         change = number_range(35, 45);
      if (ch->pcdata->learned[sn] == 12)
         change = number_range(25, 30);
      if (ch->pcdata->learned[sn] == 13)
         change = number_range(20, 25);
         
      if (ch->pcdata->ranking[sn] < 4)
         change = 1;
   }
   else if (ch->pcdata->learned[sn] >= 14 && ch->pcdata->learned[sn] <= 19)
   {
      change = number_range(5, 15);
      
      if (ch->pcdata->learned[sn] >= 15 && ch->pcdata->ranking[sn] < 5)
         change = 0;
      if (ch->pcdata->learned[sn] >= 18 && ch->pcdata->ranking[sn] < 6)
         change = 0;
   }
   else
   {
      if (ch->pcdata->spercent[sn] > 3000)
         change = 0;
      else
         change = number_range(3, 10);
   }
   
   change = change * sysdata.exp_percent / 100;
      
   if (change > 0)
      pos = 1;
      
   if (ch->race == RACE_HUMAN)
      change = change * 150 / 100;
   if (sn > 0 && sn < top_sn && skill_table[sn] && skill_table[sn]->name && skill_table[sn]->type == SKILL_SPELL && ch->race == RACE_OGRE)
      change = change * 20 / 100;
   else
   {
      if (ch->race == RACE_OGRE)
         change = change * 80 / 100;
   }
   if (sn > 0 && sn < top_sn && skill_table[sn] && skill_table[sn]->name && skill_table[sn]->type == SKILL_SPELL && ch->race == RACE_FAIRY)
      change = change * 175 / 100;
      
   //Agent sphere for hobbits
   if (sn > 0 && sn < top_sn && skill_table[sn] && skill_table[sn]->name && skill_table[sn]->stype == 2 && ch->race == RACE_HOBBIT)
      change = change * 175 / 100;   
   if (skill_table[sn]->difficulty >= 0 && skill_table[sn]->difficulty <= 13)
   {
      if (skill_table[sn]->difficulty == 1)
         change = change * 95 / 100;   
      if (skill_table[sn]->difficulty == 2) 
         change *= .9;
      if (skill_table[sn]->difficulty == 3)
         change = change * 80 / 100;   
      if (skill_table[sn]->difficulty == 4)
         change = change * 70 / 100;   
      if (skill_table[sn]->difficulty == 5)
         change = change * 65 / 100;
      if (skill_table[sn]->difficulty == 6)
         change = change * 50 / 100;
      if (skill_table[sn]->difficulty == 7)
         change = change * 33 / 100;
      if (skill_table[sn]->difficulty == 8)
         change = change * 25 / 100;
      if (skill_table[sn]->difficulty == 9)
         change = change * 20 / 100;
      if (skill_table[sn]->difficulty == 10)
         change = change * 15 / 100;
      if (skill_table[sn]->difficulty == 11)
         change = change * 10 / 100;
      if (skill_table[sn]->difficulty == 12)
         change = change * 5 / 100;
      if (skill_table[sn]->difficulty == 13)
         change = change * 1 / 100;   
   }
   else
   {
      bug("Sn %d as a difficulty out of the range >= 0 <= 13", sn);
   } 
   change = change * get_skillflux_value(ch, sn) / 100;  
   if (change < 1 && pos == 1)
      change = 1;

   return change;
}

/* Added these back in, but made the chance to increase minimal -- Xerves 11/1/99 */
// Put back in for new skill system, a more hybrid version of stock/new system -- Xerves 2001
void learn_from_success(CHAR_DATA * ch, int sn, CHAR_DATA *target)
{
   int change;
   SKILLTYPE *skill = get_skilltype(sn);
   int pos = 0;
   int x;
   
   if (IS_NPC(ch))
      return;
      
   if (sn == -1)
      return;
      
   for (x = 0; x < 5; x++)  //no learning list
   {
      if (ch->pcdata->nolearn[x] == sn)
         return;
   }
      
   change = base_learn_value(ch, sn); 
   if (change > 0)
      pos = 1;  
   
   if (target && !IS_NPC(target) && is_affected(target, sn) && !SPELL_FLAG(skill, SF_ACCUMULATIVE) && !SPELL_FLAG(skill, SF_RECASTABLE))
      change /= 3; //Come on quit casting the bloody spell already if they have it already
   
   if (target && IS_NPC(target) && xIS_SET(target->act, ACT_MOUNTSAVE))
   {
      change = 0;
      pos = 0;
   }
   if (change < 1 && pos == 1)
      change = 1;  
   ch->pcdata->spercent[sn] += change;
   if (ch->pcdata->spercent[sn] >= 10000)
   {
      ch_printf(ch, "&R*********************************************************************\n\r");
      ch_printf(ch, "&R*****Your skills in %s has increased 1 Point.*****\n\r", skill_table[sn]->name);
      ch_printf(ch, "&R*********************************************************************\n\r");
      ch->pcdata->learned[sn]++;
      ch->pcdata->spercent[sn] = 200; //So skill doesn't go down in a few minutes
      if (skill_table[sn]->stype == 4 && skill_table[sn]->group[0] != 6)
      {
         ch->pcdata->grouppoints[skill_table[sn]->group[0]+MAX_GROUP]++;
         ch->pcdata->spherepoints[skill_table[sn]->stype]++;
      }
      else
      {
         ch->pcdata->grouppoints[skill_table[sn]->group[0]]++;
         ch->pcdata->spherepoints[skill_table[sn]->stype]++;
      }
   }
   return;
}

void learn_from_failure(CHAR_DATA * ch, int sn, CHAR_DATA *target)
{
   int change;
   SKILLTYPE *skill = get_skilltype(sn);
   int x;
   
   int pos = 0;
   
   if (IS_NPC(ch))
      return;
      
   if (sn == 1)
      return;
      
   for (x = 0; x < 5; x++)  //no learning list
   {
      if (ch->pcdata->nolearn[x] == sn)
         return;
   }
      
   change = base_learn_value(ch, sn); 
   if (change > 0)
      pos = 1;  
      
   change /= 3; //Failure gives you only 1/3 of the points
   
   if (sn == gsn_critical) //slow this down quite a bit on failures...
      change /= 4;
   
   if (target && !IS_NPC(target) && is_affected(target, sn) && !SPELL_FLAG(skill, SF_ACCUMULATIVE) && !SPELL_FLAG(skill, SF_RECASTABLE))
      change /= 3; //Come on quit casting the bloody spell already if they have it already
   
   if (target && IS_NPC(target) && xIS_SET(target->act, ACT_MOUNTSAVE))
   {
      change = 0;
      pos = 0;
   }
   if (change < 1 && pos == 1)
      change = 1;  
      
   ch->pcdata->spercent[sn] += change;
   if (ch->pcdata->spercent[sn] >= 10000)
   {
      ch_printf(ch, "&R*********************************************************************\n\r");
      ch_printf(ch, "&R*****Your skills in %s has increased 1 Point.*****\n\r", skill_table[sn]->name);
      ch_printf(ch, "&R*********************************************************************\n\r");
      ch->pcdata->learned[sn]++;
      ch->pcdata->spercent[sn] = 200; //So skill does not go down in a few minutes
      if (skill_table[sn]->stype == 4 && skill_table[sn]->group[0] != 6)
      {
         ch->pcdata->grouppoints[skill_table[sn]->group[0]+MAX_GROUP]++;
         ch->pcdata->spherepoints[skill_table[sn]->stype]++;
      }
      else
      {
         ch->pcdata->grouppoints[skill_table[sn]->group[0]]++;
         ch->pcdata->spherepoints[skill_table[sn]->stype]++;
      }
   }
   return;
}
void do_gouge(CHAR_DATA * ch, char *argument)
{
   CHAR_DATA *victim;
   AFFECT_DATA af;
   sh_int dam;
   int chance;
   sh_int level;
   sh_int mastery;

   mastery = MASTERED(ch, gsn_gouge);
   level = POINT_LEVEL(LEARNED(ch, gsn_gouge), MASTERED(ch, gsn_gouge));

   if (IS_NPC(ch) && IS_AFFECTED(ch, AFF_CHARM))
   {
      send_to_char("You can't concentrate enough for that.\n\r", ch);
      return;
   }

   if (!can_use_skill(ch, 0, gsn_gouge))
   {
      send_to_char("You do not yet know of this skill.\n\r", ch);
      return;
   }

   if (ch->mount)
   {
      send_to_char("You can't get close enough while mounted.\n\r", ch);
      return;
   }

   if ((victim = who_fighting(ch)) == NULL)
   {
      send_to_char("You aren't fighting anyone.\n\r", ch);
      return;
   }
   chance = 15+(level/6)+((get_curr_dex(ch) - get_curr_dex(victim))*2);
   chance = ((get_curr_dex(victim) - get_curr_dex(ch)) * 10) + 10;
   if (!IS_NPC(ch) && !IS_NPC(victim))
      chance += sysdata.gouge_plr_vs_plr;
   if (victim->fighting && victim->fighting->who != ch)
      chance += sysdata.gouge_nontank;
   if (number_range(1, 100) <= chance)
   {
      dam = number_range(1, 1+(level/20));
      global_retcode = damage(ch, victim, dam, gsn_gouge, 0, -1);
      if (global_retcode == rNONE)
      {
         if (!IS_AFFECTED(victim, AFF_BLIND))
         {
            af.type = gsn_blindness;
            af.location = APPLY_TOHIT;
            af.modifier = -4;
            af.duration = number_range(8+(level/10), 10+(level/8));
            af.bitvector = meb(AFF_BLIND);
            affect_to_char(victim, &af);
            act(AT_SKILL, "You can't see a thing!", victim, NULL, NULL, TO_CHAR);
         }
         ch->fight_timer = skill_table[gsn_gouge]->beats;
         victim->fight_timer += 2*skill_table[gsn_gouge]->beats;
      }
      else if (global_retcode == rVICT_DIED)
      {
         act(AT_BLOOD, "Your fingers plunge into your victim's brain, causing immediate death!", ch, NULL, NULL, TO_CHAR);
      }
      if (global_retcode != rCHAR_DIED && global_retcode != rVICT_DIED && global_retcode != rBOTH_DIED)
         learn_from_success(ch, gsn_gouge, victim);
   }
   else
   {
      ch->fight_timer = skill_table[gsn_gouge]->beats;
      global_retcode = damage(ch, victim, 0, gsn_gouge, 0, -1);
      learn_from_failure(ch, gsn_gouge, victim);
   }

   return;
}

void do_manashot(CHAR_DATA *ch, char *argument)
{
   int level;
   CHAR_DATA *victim = NULL;
   int dam;
   
   level = POINT_LEVEL(LEARNED(ch, gsn_manashot), MASTERED(ch, gsn_manashot));
   
   if (ch->fighting)
      victim = ch->fighting->who;
   if (argument[0] != '\0')
   {
      if ((victim = get_char_room_new(ch, argument, 1)) == NULL)
      {
         send_to_char("Your target is not in the room with you.\n\r", ch);
         return;
      }
   }
   if (!check_twohand_shield(ch))
      return;
   if (!victim)
   {
      send_to_char("Syntax:  manashot <target>\n\rDo not need to supply a target if fighting.\n\r", ch);
      return;
   }
   if (is_room_safe(ch))
   {
      send_to_char("This room is a safe area, you cannot fight here.\n\r", ch);
      return;
   }
   dam = UMAX(6, level-2);
   dam = number_range(dam*80/100, dam*120/100);
   if (is_immune(victim, -1, RIS_MAGIC))
   {
      act(AT_WHITE, "$n releases a powerful manashot toward $N, but $N is immune to magic.", ch, NULL, victim, TO_NOTVICT);
      act(AT_WHITE, "$n releases a powerful manashot toward you, but you are immune to magic.", ch, NULL, victim, TO_VICT);
      act(AT_WHITE, "You release a powerful manashot toward $N, but $N is immune to magic.", ch, NULL, victim, TO_CHAR);
      damage(ch, victim, 0, gsn_manashot, 0, -1);
      return;
   }
   if (saves_spell_staff(level, victim))
      dam = dam * 3 / 4;
   act(AT_WHITE, "$n channels $s energy and blasts $N with a powerful manashot.", ch, NULL, victim, TO_NOTVICT);
   act(AT_WHITE, "$n channels $s energy and blasts you with a powerful manashot.", ch, NULL, victim, TO_VICT);
   act(AT_WHITE, "You channel your energy and blast $N with a powerful manashot.", ch, NULL, victim, TO_CHAR);
   damage(ch, victim, dam, gsn_manashot, 0, -1);
   learn_from_success(ch, gsn_manashot, victim);
   if (ch->fighting)
      ch->fight_timer = get_btimer(ch, gsn_manashot, NULL);
   else
      WAIT_STATE(ch, skill_table[gsn_manashot]->beats*2);
   return;
}

void do_manaburst(CHAR_DATA *ch, char *argument)
{
   int level;
   CHAR_DATA *vch;
   CHAR_DATA *vch_next;
   int dam;
   int num = 0;
   
   level = POINT_LEVEL(LEARNED(ch, gsn_manaburst), MASTERED(ch, gsn_manaburst));
   if (is_room_safe(ch))
   {
      send_to_char("This room is a safe area, you cannot fight here.\n\r", ch);
      return;
   }
   if (!check_twohand_shield(ch))
      return;
   act(AT_WHITE, "$n starts scream and a large amount of energy pours and hits everything around $m.", ch, NULL, NULL, TO_ROOM);
   act(AT_WHITE, "You start screaming and a large amount of energy pours out and hits everything around you.", ch, NULL, NULL, TO_CHAR);
   for (vch = ch->in_room->first_person; vch; vch = vch_next)
   {
      vch_next = vch->next_in_room;

      if (ch->coord->x != vch->coord->x || ch->coord->y != vch->coord->y
         || ch->map != vch->map)
         continue;

      if (!IS_NPC(vch) && xIS_SET(vch->act, PLR_WIZINVIS) && vch->pcdata->wizinvis >= LEVEL_IMMORTAL)
         continue;
         
      if (IS_NPC(vch) && IS_AFFECTED(vch, AFF_CHARM) && vch->master == ch)
         continue;
         
      if (!IS_NPC(ch) && IS_NPC(vch) && IS_ACT_FLAG(vch, ACT_MOUNTSAVE))
         continue;

      if (vch != ch && (IS_NPC(ch) ? !IS_NPC(vch) : IS_NPC(vch)))
      {
         num++;
         dam = 30+level*15/10;
         dam = number_range(dam*80/100, dam*120/100);
         if (saves_spell_staff(level, vch))
            dam = dam * 3 / 4;
         damage(ch, vch, dam, gsn_manaburst, 0, -1);
      }
      if (char_died(ch))
         return;
   }
   if (ch->fighting)
      ch->fight_timer = get_btimer(ch, gsn_manaburst, NULL);
   else
      WAIT_STATE(ch, skill_table[gsn_manaburst]->beats*2);
   if (num)
      learn_from_success(ch, gsn_manaburst, NULL);
   return;
}

void do_nervestrike(CHAR_DATA *ch, char *argument)
{
   CHAR_DATA *victim;
   AFFECT_DATA af;
   int chance;
   int level;
   bool fail;
   
   level = POINT_LEVEL(LEARNED(ch, gsn_nervestrike), MASTERED(ch, gsn_nervestrike));

   if (IS_NPC(ch) && IS_AFFECTED(ch, AFF_CHARM))
   {
      send_to_char("You can't concentrate enough for that.\n\r", ch);
      return;
   }
   if (!IS_NPC(ch) && ch->pcdata->ranking[gsn_nervestrike] <= 0)
   {
      send_to_char("Hard to strike at a nerve if you don't even know where one is.\n\r", ch);
      return;
   }
   if (!ch->fighting || !ch->fighting->who)
   {
      send_to_char("You can only use this during the heat of battle.\n\r", ch);
      return;
   }
   if ((victim = get_char_room_new(ch, argument, 1)) == NULL)
   {
      victim = ch->fighting->who;
   }
   if (is_safe(ch, victim))
   {
      send_to_char("You cannot nervestrike that target.\n\r", ch);
      return;
   }
   check_illegal_pk(ch, victim);
   check_attacker(ch, victim);
   if (!IS_NPC(ch) && HAS_WAIT(ch))
   {
      send_to_char("You are too busy in battle to do that.\n\r", ch);
      return;
   }
   ch->fight_timer = get_btimer(ch, gsn_nervestrike, NULL);
   fail = FALSE;
      
   chance = 5+level/4;
      
   if (!IS_NPC(ch) && !IS_NPC(victim))
      chance -= sysdata.stun_plr_vs_plr;
   else
      chance -= sysdata.stun_regular;
      
   chance += ((get_curr_dex(victim) + get_curr_str(victim)) - (get_curr_dex(ch) + get_curr_str(ch))) * 3;
   chance += URANGE(-10, (get_curr_int(ch)-14)/2 + (get_curr_wis(ch)-14)/2, 10);
   chance += victim->saving_para_petri;
   if (victim->max_hit > 2000)
      chance /= 2;
   if (victim->max_hit > 5000)
      chance /= 2;
   chance = URANGE(5, chance, 45);
   if (!fail)
   {
      if (number_range(1, 100) > chance)
         fail = TRUE;
   }
   if (!fail)
   {
      learn_from_success(ch, gsn_nervestrike, victim);
      ch->fight_timer = skill_table[gsn_nervestrike]->beats;
      act(AT_SKILL, "$N lunges at your neck and strikes a vital nerve.  You are PARALYZED TEMPORARILY!", victim, NULL, ch, TO_CHAR);
      act(AT_SKILL, "You lunge at $N's neck and strike a vital nerve.  $N is PARALYZED TEMPORARILY!", ch, NULL, victim, TO_CHAR);
      act(AT_SKILL, "$n lunges at $N's neck and strike a vital nerve.  $N is PARALYZED TEMPORARILY!", ch, NULL, victim, TO_NOTVICT);
      if (!IS_AFFECTED(victim, AFF_PARALYSIS))
      {
         af.type = gsn_stun;
         af.location = APPLY_ARMOR;
         af.modifier = -3;
         af.duration = 5+(MASTERED(ch, gsn_nervestrike)*3/2);
         if (IS_NPC(ch))
            af.duration = 2+MASTERED(ch, gsn_nervestrike);
         af.bitvector = meb(AFF_PARALYSIS);
         affect_to_char(victim, &af);
         update_pos(victim);
      }
      start_hating(victim, ch);
      start_hunting(victim, ch);
   }
   else
   {
      ch->fight_timer = skill_table[gsn_nervestrike]->beats;
      learn_from_failure(ch, gsn_nervestrike, victim);
      act(AT_SKILL, "$n lunges at your neck and attempts to strike a vital nerve, but $e misses.", ch, NULL, victim, TO_VICT);
      act(AT_SKILL, "You try to strike a vital nerve on $N's neck, but you miss.", ch, NULL, victim, TO_CHAR);
      act(AT_SKILL, "$n lunges at $N's neck and attempts to strike a vital nerve, but $e fails.", ch, NULL, victim, TO_NOTVICT);
      start_hating(victim, ch);
      start_hunting(victim, ch);
   }
   return;
}

void do_quickcombo(CHAR_DATA *ch, char *argument)
{
   CHAR_DATA *victim = NULL;
   int level;
   int sn[6];
   char arg[MIL];
   int x, y;
   int right;
   char buf[MSL];
   int remain;
   
   for (x = 0; x <= 5; x++)
      sn[x] = 0;
   level = POINT_LEVEL(LEARNED(ch, gsn_quickcombo), MASTERED(ch, gsn_quickcombo));
   
   if (argument[0] == '\0')
   {
      send_to_char("Syntax:  quickcombo <right/left> <strike1> <strike2> [strike3] [strike4] [strike5] [victim]\n\r", ch);
      send_to_char("Note: strike3-5 is available if you have expert/elite/flawless in quickcombo.\n\r", ch);
      return;
   }
   argument = one_argument(argument, arg);
   if (!str_cmp(arg, "right"))
      right = 1;
   else
      right = 0;
   argument = one_argument(argument, arg);
   if ((sn[1] = skill_lookup(arg)) < 1)
   {
      send_to_char("Strike1 is not a valid strike.\n\r", ch);
      return;
   }
   if (skill_table[sn[1]]->group[0] != 7) //Group with all the strikes
   {
      send_to_char("Strike1 has to be an actual strike (ex: blitz)\n\r", ch);
      return;
   }
   argument = one_argument(argument, arg);
   if ((sn[2] = skill_lookup(arg)) < 1)
   {
      send_to_char("Strike2 is not a valid strike.\n\r", ch);
      return;
   }
   if (skill_table[sn[2]]->group[0] != 7) //Group with all the strikes
   {
      send_to_char("Strike2 has to be an actual strike (ex: blitz)\n\r", ch);
      return;
   }
   one_argument(argument, arg);
   if ((sn[3] = skill_lookup(arg)) >= 1)
   {
      argument = one_argument(argument, arg); 
      if (MASTERED(ch, gsn_quickcombo) < 3)
      {
         send_to_char("You can only specify a 3rd strike if you have expert or higher mastery.\n\r", ch);
         return;
      }
      if (skill_table[sn[3]]->group[0] != 7) //Group with all the strikes
      {
         send_to_char("Strike3 has to be an actual strike (ex: blitz)\n\r", ch);
         return;
      }
   }
   one_argument(argument, arg);
   if ((sn[4] = skill_lookup(arg)) >= 1)
   {
      argument = one_argument(argument, arg); 
      if (MASTERED(ch, gsn_quickcombo) < 5)
      {
         send_to_char("You can only specify a 4rd strike if you have elite or higher mastery.\n\r", ch);
         return;
      }
      if (skill_table[sn[4]]->group[0] != 7) //Group with all the strikes
      {
         send_to_char("Strike4 has to be an actual strike (ex: blitz)\n\r", ch);
         return;
      }
   }
   one_argument(argument, arg);
   if ((sn[5] = skill_lookup(arg)) >= 1)
   {
      argument = one_argument(argument, arg); 
      if (MASTERED(ch, gsn_quickcombo) < 5)
      {
         send_to_char("You can only specify a 5th strike if you have flawless or higher mastery.\n\r", ch);
         return;
      }
      if (skill_table[sn[5]]->group[0] != 7) //Group with all the strikes
      {
         send_to_char("Strike5 has to be an actual strike (ex: blitz)\n\r", ch);
         return;
      }
   }
   for (x = 1; x <= 5; x++)
   {
      for (y = 1; y <= 5; y++)
      {
         if (x == y)
            continue;
         if (sn[x] <= 0 || sn[y] <= 0)
            continue;
         if (skill_table[sn[x]]->targetlimb == skill_table[sn[y]]->targetlimb)
            break;
      }
      if (y != 6)
      {    
         send_to_char("Each strike has to target a different limb.\n\r", ch);
         return;
      }
   } 
   if (ch->fighting)
      victim = ch->fighting->who;
   if (argument[0] != '\0')
   {
      if ((victim = get_char_room_new(ch, argument, 1)) == NULL)
      {
         send_to_char("Your target is not in the room with you.\n\r", ch);
         return;
      }
   }
   if (!victim)
   {
      do_quickcombo(ch, "");
      return;
   }
   if (is_room_safe(ch))
   {
      send_to_char("This room is a safe area, you cannot fight here.\n\r", ch);
      return;
   }
   sprintf(buf, "'%s' %s", victim->name, right ? "right" : "left");
   //Legs/Arms need right/left argument
   if (skill_table[sn[1]]->targetlimb == 1 || skill_table[sn[1]]->targetlimb == 2)
      (*skill_table[sn[1]]->skill_fun) (ch, buf);
   else
      (*skill_table[sn[1]]->skill_fun) (ch, victim->name);
      
   if (skill_table[sn[2]]->targetlimb == 1 || skill_table[sn[2]]->targetlimb == 2)
      (*skill_table[sn[2]]->skill_fun) (ch, buf);
   else
      (*skill_table[sn[2]]->skill_fun) (ch, victim->name);
      
   if (sn[3] > 0)
   {
      if (skill_table[sn[3]]->targetlimb == 1 || skill_table[sn[3]]->targetlimb == 2)
         (*skill_table[sn[3]]->skill_fun) (ch, buf);
      else
         (*skill_table[sn[3]]->skill_fun) (ch, victim->name);
   }
   if (sn[4] > 0)
   {
      if (skill_table[sn[4]]->targetlimb == 1 || skill_table[sn[4]]->targetlimb == 2)
         (*skill_table[sn[4]]->skill_fun) (ch, buf);
      else
         (*skill_table[sn[4]]->skill_fun) (ch, victim->name);
   }
   if (sn[5] > 0)
   {
      if (skill_table[sn[5]]->targetlimb == 1 || skill_table[sn[5]]->targetlimb == 2)
         (*skill_table[sn[5]]->skill_fun) (ch, buf);
      else
         (*skill_table[sn[5]]->skill_fun) (ch, victim->name);
   }
   remain = ch->fight_timer * UMAX(40, (100-(level*2/3))) % 100;
   ch->fight_timer = ch->fight_timer * UMAX(40, (100-(level*2/3))) / 100;
   if (number_range(1, 100) <= remain)
      ch->fight_timer += 1;
   if (ch->fight_timer < 1)
      ch->fight_timer = 1;
   learn_from_success(ch, gsn_quickcombo, victim);
   return;
}

void do_kickdirt(CHAR_DATA * ch, char *argument)
{
   CHAR_DATA *victim;
   AFFECT_DATA af;
   int chance;
   sh_int level;
   sh_int mastery;
   int sector;

   mastery = MASTERED(ch, gsn_kickdirt);
   level = POINT_LEVEL(LEARNED(ch, gsn_kickdirt), MASTERED(ch, gsn_kickdirt));

   if (IS_NPC(ch) && IS_AFFECTED(ch, AFF_CHARM))
   {
      send_to_char("You can't concentrate enough for that.\n\r", ch);
      return;
   }

   if (!can_use_skill(ch, 0, gsn_kickdirt))
   {
      send_to_char("You do not yet know of this skill.\n\r", ch);
      return;
   }

   if (ch->mount)
   {
      send_to_char("What do you want to do, blind your target with your mount?.\n\r", ch);
      return;
   }

   if ((victim = who_fighting(ch)) == NULL)
   {
      send_to_char("You aren't fighting anyone.\n\r", ch);
      return;
   }
   if (IN_WILDERNESS(ch))
   {
      sector = map_sector[ch->map][ch->coord->x][ch->coord->y];
   }
   else
   {
      sector = ch->in_room->sector_type;   
   }   
   if (sector != SECT_FIELD && sector != SECT_FOREST && sector != SECT_HILLS && sector != SECT_MOUNTAIN
   &&  sector != SECT_DESERT && sector != SECT_UNDERGROUND && sector != SECT_MINEGOLD && sector != SECT_MINEIRON
   &&  sector != SECT_HCORN && sector != SECT_HGRAIN && sector != SECT_STREE && sector != SECT_NTREE
   &&  sector != SECT_SCORN && sector != SECT_NCORN && sector != SECT_SIRON && sector != SECT_NIRON
   &&  sector != SECT_SGRAIN && sector != SECT_NGRAIN && sector != SECT_JUNGLE && sector != SECT_SHORE
   &&  sector != SECT_SWAMP && sector != SECT_PATH && sector != SECT_PLAINS && sector != SECT_BURNT
   &&  sector != SECT_STONE && sector != SECT_SSTONE && sector != SECT_NSTONE)
   {
      send_to_char("There has to be dirt on the ground to kick.\n\r", ch);
      return;
   }
   chance = 15+(level/4)+((get_curr_dex(ch) - get_curr_dex(victim))*5);
   if (number_range(1, 100) <= chance)
   {
      act(AT_RED, "$n kicks dirt into the eyes of $N blinding $M.", ch, NULL, victim, TO_NOTVICT);
      act(AT_RED, "$n kicks dirt into your eyes blinding you!", ch, NULL, victim, TO_VICT);
      act(AT_RED, "You kick dirt into the eyes of $N blinding $M.", ch, NULL, victim, TO_CHAR);
      if (!IS_AFFECTED(victim, AFF_BLIND))
      {
         af.type = gsn_blindness;
         af.location = APPLY_TOHIT;
         af.modifier = -2;
         af.duration = number_range(4+(level/10), 6+(level/8));
         af.bitvector = meb(AFF_BLIND);
         affect_to_char(victim, &af);
         act(AT_SKILL, "You can't see a thing!", victim, NULL, NULL, TO_CHAR);
      }
      ch->fight_timer = skill_table[gsn_kickdirt]->beats;
      learn_from_success(ch, gsn_kickdirt, victim);
   }
   else
   {
      act(AT_RED, "$n kicks dirt toward the eyes of $N, but $E dodges it.", ch, NULL, victim, TO_NOTVICT);
      act(AT_RED, "$n kicks dirt toward your eyes, but you happen to dodge it.", ch, NULL, victim, TO_VICT);
      act(AT_RED, "You kick dirt toward the eyes of $N, but $E dodges it.", ch, NULL, victim, TO_CHAR);
      ch->fight_timer = skill_table[gsn_kickdirt]->beats;
      learn_from_failure(ch, gsn_kickdirt, victim);
   }
   return;
}

void do_detrap(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   OBJ_DATA *obj;
   OBJ_DATA *trap;
   TRAP_DATA *ntrap;
   OBJ_DATA *tool;
   int percent;
   sh_int level;
   sh_int mastery;
   
   trap = NULL;
   ntrap = NULL;

   mastery = MASTERED(ch, gsn_detrap);
   level = POINT_LEVEL(LEARNED(ch, gsn_detrap), MASTERED(ch, gsn_detrap));

   switch (ch->substate)
   {
      default:
         if (IS_NPC(ch) && IS_AFFECTED(ch, AFF_CHARM))
         {
            send_to_char("You can't concentrate enough for that.\n\r", ch);
            return;
         }
         argument = one_argument(argument, arg);
         if (!can_use_skill(ch, 0, gsn_detrap))
         {
            send_to_char("You do not yet know of this skill.\n\r", ch);
            return;
         }
         if (arg[0] == '\0')
         {
            send_to_char("Detrap what?\n\r", ch);
            return;
         }
         if (ms_find_obj(ch))
            return;
         if (ch->mount)
         {
            send_to_char("You can't do that while mounted.\n\r", ch);
            return;
         }
         if ((obj = get_obj_here(ch, arg)) == NULL)
         {
            send_to_char("You can't find that here.\n\r", ch);
            return;
         }
         act(AT_ACTION, "You carefully begin your attempt to remove a trap from $p...", ch, obj, NULL, TO_CHAR);
         act(AT_ACTION, "$n carefully attempts to remove a trap from $p...", ch, obj, NULL, TO_ROOM);
         ch->alloc_ptr = str_dup(obj->name);
         add_timer(ch, TIMER_DO_FUN, 6, do_detrap, 1);
         WAIT_STATE( ch, skill_table[gsn_detrap]->beats*2 );
         return;
      case 1:
         if (!ch->alloc_ptr)
         {
            send_to_char("Your detrapping was interrupted!\n\r", ch);
            bug("do_detrap: ch->alloc_ptr NULL!", 0);
            return;
         }
         strcpy(arg, ch->alloc_ptr);
         DISPOSE(ch->alloc_ptr);
         ch->alloc_ptr = NULL;
         ch->substate = SUB_NONE;
         break;
      case SUB_TIMER_DO_ABORT:
         DISPOSE(ch->alloc_ptr);
         ch->substate = SUB_NONE;
         send_to_char("You carefully stop what you were doing.\n\r", ch);
         return;
   }

   if ((obj = get_obj_here(ch, arg)) == NULL)
   {
      send_to_char("You can't find that here.\n\r", ch);
      return;
   }
   trap = get_trap(obj);
   if (obj->trap)
   {
      ntrap = obj->trap;
      trap = NULL;
   }
   if (!trap && !ntrap)
   {
      send_to_char("You find no trap on that.\n\r", ch);
      return;
   }

   percent = UMIN(100, 30 + level + URANGE(-15, (14-get_curr_lck(ch))*3, 20));
   if (ntrap)
      percent -= ntrap->difficulty;
   
   if (ntrap && ntrap->toolkit > 0)
   {
      for (tool = ch->first_carrying; tool; tool = tool->next_content) 
      {
         if (tool->item_type == ITEM_TRAPTOOL && tool->value[0] == ntrap->toolkit)
            percent += ntrap->toolnegate;
      }
   }

   separate_obj(obj);
   if (number_range(1, 100) > percent)
   {
      send_to_char("Ooops!\n\r", ch);
      pre_spring_trap(ch, trap, ntrap, obj);
      learn_from_failure(ch, gsn_detrap, NULL);
      return;
   }
   if (ntrap)
   {
      if (ntrap->uid >= START_INV_TRAP)
      {
         UNLINK(ntrap, first_trap, last_trap, next, prev);
         ntrap->obj->trap = NULL;
         DISPOSE(ntrap);   
         save_trap_file(NULL, NULL);
      }
      else
      {
         ntrap->obj->trap = NULL;
         ntrap->obj = NULL;
         ntrap->area = NULL;
      }
   }
   if (trap)
      extract_obj(trap);

   send_to_char("You successfully remove a trap.\n\r", ch);
   learn_from_success(ch, gsn_detrap, NULL);
   return;
}

void do_dig(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   OBJ_DATA *obj;
   OBJ_DATA *startobj;
   bool found, shovel;
   EXIT_DATA *pexit;
   sh_int mastery;

   mastery = 10;

   if (IS_ONMAP_FLAG(ch))
   {
      send_to_char("You cannot dig on an overland map.\n\r", ch);
      return;
   }

   switch (ch->substate)
   {
      default:
         if (IS_NPC(ch) && IS_AFFECTED(ch, AFF_CHARM))
         {
            send_to_char("You can't concentrate enough for that.\n\r", ch);
            return;
         }
         if (ch->mount)
         {
            send_to_char("You can't do that while mounted.\n\r", ch);
            return;
         }
         one_argument(argument, arg);
         if (arg[0] != '\0')
         {
            if ((pexit = find_door(ch, arg, TRUE)) == NULL && get_dir(arg) == -1)
            {
               send_to_char("What direction is that?\n\r", ch);
               return;
            }
            if (pexit)
            {
               if (!IS_SET(pexit->exit_info, EX_DIG) && !IS_SET(pexit->exit_info, EX_CLOSED))
               {
                  send_to_char("There is no need to dig out that exit.\n\r", ch);
                  return;
               }
            }
         }
         else
         {
            switch (ch->in_room->sector_type)
            {
               case SECT_CITY:
               case SECT_INSIDE:
                  send_to_char("The floor is too hard to dig through.\n\r", ch);
                  return;
               case SECT_WATER_SWIM:
               case SECT_WATER_NOSWIM:
               case SECT_UNDERWATER:
                  send_to_char("You cannot dig here.\n\r", ch);
                  return;
               case SECT_AIR:
                  send_to_char("What?  In the air?!\n\r", ch);
                  return;
            }
         }
         add_timer(ch, TIMER_DO_FUN, 3, do_dig, 1);
         ch->alloc_ptr = str_dup(arg);
         send_to_char("You begin digging...\n\r", ch);
         act(AT_PLAIN, "$n begins digging...", ch, NULL, NULL, TO_ROOM);
         return;

      case 1:
         if (!ch->alloc_ptr)
         {
            send_to_char("Your digging was interrupted!\n\r", ch);
            act(AT_PLAIN, "$n's digging was interrupted!", ch, NULL, NULL, TO_ROOM);
            bug("do_dig: alloc_ptr NULL", 0);
            return;
         }
         strcpy(arg, ch->alloc_ptr);
         DISPOSE(ch->alloc_ptr);
         break;

      case SUB_TIMER_DO_ABORT:
         DISPOSE(ch->alloc_ptr);
         ch->substate = SUB_NONE;
         send_to_char("You stop digging...\n\r", ch);
         act(AT_PLAIN, "$n stops digging...", ch, NULL, NULL, TO_ROOM);
         return;
   }

   ch->substate = SUB_NONE;

   /* not having a shovel makes it harder to succeed */
   shovel = FALSE;
   for (obj = ch->first_carrying; obj; obj = obj->next_content)
      if (obj->item_type == ITEM_SHOVEL)
      {
         shovel = TRUE;
         break;
      }

   /* dig out an EX_DIG exit... */
   if (arg[0] != '\0')
   {
      if ((pexit = find_door(ch, arg, TRUE)) != NULL && IS_SET(pexit->exit_info, EX_DIG) && IS_SET(pexit->exit_info, EX_CLOSED))
      {
         if (number_range(1, 100) <= mastery * (shovel ? 8 : 1))
         {
            REMOVE_BIT(pexit->exit_info, EX_CLOSED);
            send_to_char("You dig open a passageway!\n\r", ch);
            act(AT_PLAIN, "$n digs open a passageway!", ch, NULL, NULL, TO_ROOM);
            return;
         }
      }
      send_to_char("Your dig did not discover any exit...\n\r", ch);
      act(AT_PLAIN, "$n's dig did not discover any exit...", ch, NULL, NULL, TO_ROOM);
      return;
   }

   startobj = ch->in_room->first_content;
   found = FALSE;

   for (obj = startobj; obj; obj = obj->next_content)
   {
      /* twice as hard to find something without a shovel */
      if (IS_OBJ_STAT(obj, ITEM_BURIED) && (number_range(1, 100) <= mastery * (shovel ? 8 : 1)))
      {
         found = TRUE;
         break;
      }
   }

   if (!found)
   {
      send_to_char("Your dig uncovered nothing.\n\r", ch);
      act(AT_PLAIN, "$n's dig uncovered nothing.", ch, NULL, NULL, TO_ROOM);
      return;
   }

   separate_obj(obj);
   xREMOVE_BIT(obj->extra_flags, ITEM_BURIED);
   act(AT_SKILL, "Your dig uncovered $p!", ch, obj, NULL, TO_CHAR);
   act(AT_SKILL, "$n's dig uncovered $p!", ch, obj, NULL, TO_ROOM);
   if (obj->item_type == ITEM_CORPSE_PC || obj->item_type == ITEM_CORPSE_NPC)
      adjust_favor(ch, 14, 1);

   return;
}


void do_search(CHAR_DATA * ch, char *argument)
{
   char arg[MIL];
   OBJ_DATA *obj;
   OBJ_DATA *container;
   OBJ_DATA *startobj;
   int percent, door;
   sh_int mastery;

   mastery = 30;

   door = -1;
   switch (ch->substate)
   {
      default:
         if (IS_NPC(ch) && IS_AFFECTED(ch, AFF_CHARM))
         {
            send_to_char("You can't concentrate enough for that.\n\r", ch);
            return;
         }
         if (ch->mount)
         {
            send_to_char("You can't do that while mounted.\n\r", ch);
            return;
         }
         argument = one_argument(argument, arg);
         if (arg[0] != '\0' && (door = get_door(arg)) == -1)
         {
            container = get_obj_here(ch, arg);
            if (!container)
            {
               send_to_char("You can't find that here.\n\r", ch);
               return;
            }
            if (container->item_type != ITEM_CONTAINER)
            {
               send_to_char("You can't search in that!\n\r", ch);
               return;
            }
            if (IS_SET(container->value[1], CONT_CLOSED))
            {
               send_to_char("It is closed.\n\r", ch);
               return;
            }
         }
         add_timer(ch, TIMER_DO_FUN, 3, do_search, 1);
         send_to_char("You begin your search...\n\r", ch);
         ch->alloc_ptr = str_dup(arg);
         return;

      case 1:
         if (!ch->alloc_ptr)
         {
            send_to_char("Your search was interrupted!\n\r", ch);
            bug("do_search: alloc_ptr NULL", 0);
            return;
         }
         strcpy(arg, ch->alloc_ptr);
         DISPOSE(ch->alloc_ptr);
         break;
      case SUB_TIMER_DO_ABORT:
         DISPOSE(ch->alloc_ptr);
         ch->substate = SUB_NONE;
         send_to_char("You stop your search...\n\r", ch);
         return;
   }
   ch->substate = SUB_NONE;
   if (arg[0] == '\0')
      startobj = ch->in_room->first_content;
   else
   {
      if ((door = get_door(arg)) != -1)
         startobj = NULL;
      else
      {
         container = get_obj_here(ch, arg);
         if (!container)
         {
            send_to_char("You can't find that here.\n\r", ch);
            return;
         }
         startobj = container->first_content;
      }
   }

   if ((!startobj && door == -1) || IS_NPC(ch))
   {
      send_to_char("You find nothing.\n\r", ch);
      return;
   }

   percent = mastery;

   if (door != -1)
   {
      EXIT_DATA *pexit;

      if ((pexit = get_exit(ch->in_room, door)) != NULL
         && IS_SET(pexit->exit_info, EX_SECRET) && IS_SET(pexit->exit_info, EX_xSEARCHABLE) && number_range(1,100) <= mastery)
      {
         act(AT_SKILL, "Your search reveals the $d!", ch, NULL, pexit->keyword, TO_CHAR);
         act(AT_SKILL, "$n finds the $d!", ch, NULL, pexit->keyword, TO_ROOM);
         REMOVE_BIT(pexit->exit_info, EX_SECRET);
         return;
      }
   }
   else
      for (obj = startobj; obj; obj = obj->next_content)
      {
         if (IS_OBJ_STAT(obj, ITEM_HIDDEN) && number_range(1, 100) <= mastery)
         {
            separate_obj(obj);
            xREMOVE_BIT(obj->extra_flags, ITEM_HIDDEN);
            act(AT_SKILL, "Your search reveals $p!", ch, obj, NULL, TO_CHAR);
            act(AT_SKILL, "$n finds $p!", ch, obj, NULL, TO_ROOM);
            return;
         }
      }

   send_to_char("You find nothing.\n\r", ch);
   return;
}

void set_thief(CHAR_DATA *ch, CHAR_DATA *victim)
{
   INTRO_DATA *intro = NULL;
   CHAR_DATA *rch;
   
   if (!IS_NPC(victim))
   {
      for (intro = victim->pcdata->first_introduction; intro; intro = intro->next)
      {
         if (intro->pid == ch->pcdata->pid && can_see_intro(ch, victim))
         {
            if (intro->value > 0)
               intro->value *=-1;
            intro->value -=15000;
            if (intro->value < -150000)
               intro->value = -150000;
            SET_BIT(intro->flags, INTRO_MYTHIEF);
            REMOVE_BIT(intro->flags, INTRO_THIEF);
            intro->lastseen = time(0);
            break;
         }
      }
   }
   
   if (!IS_NPC(victim) && !intro && can_see_intro(ch, victim))
   {
      CREATE(intro, INTRO_DATA, 1);
      intro->pid = ch->pcdata->pid;
      intro->value = -15000;
      intro->lastseen = time(0);
      SET_BIT(intro->flags, INTRO_MYTHIEF);
      LINK(intro, victim->pcdata->first_introduction, victim->pcdata->last_introduction, next, prev);   
   }

   for (rch = ch->in_room->first_person; rch; rch = rch->next)
   {
      if (!IS_NPC(rch))
      {
         for (intro = rch->pcdata->first_introduction; intro; intro = intro->next)
         {
            if (rch->pcdata->pid == intro->pid && rch != ch && rch != victim && can_see_intro(rch, victim))
            {
               if (intro->value > 100000)
                  continue;
               if (intro->value > 0)
                  intro->value *=-1;
               intro->value -=15000;
               if (intro->value < -150000)
                  intro->value = -150000;
               intro->lastseen = time(0);
              
               if (!IS_SET(intro->flags, INTRO_MYTHIEF))
                   SET_BIT(intro->flags, INTRO_THIEF);
               break;
            }
         }
         if (!intro && can_see_intro(rch, victim) && rch != ch && rch != victim)
         {
            CREATE(intro, INTRO_DATA, 1);
            intro->pid = ch->pcdata->pid;
            intro->value = -15000;
            intro->lastseen = time(0);
            SET_BIT(intro->flags, INTRO_THIEF);
            LINK(intro, rch->pcdata->first_introduction, rch->pcdata->last_introduction, next, prev);   
         }  
         save_char_obj(rch);
      }
   }
   if (!IS_NPC(victim))
      save_char_obj(victim);       
   save_char_obj(ch);
}

void do_gathertinder(CHAR_DATA *ch, char *argument)
{
   int chance = 0;
   OBJ_DATA *tinder;
   int sector;
   
   if (IN_WILDERNESS(ch))
   {
      sector = map_sector[ch->map][ch->coord->x][ch->coord->y];
   }
   else
   {
      sector = ch->in_room->sector_type;   
   }
   if (sector == SECT_FOREST || sector == SECT_STREE || sector == SECT_NTREE)
   {
      if (sector == SECT_FOREST)   
         chance = 85;
      if (sector == SECT_STREE)
         chance = 55;
      if (sector == SECT_NTREE)
         chance = 20;
      if (number_range(1, 100) <= chance)
      {
         act(AT_ORANGE, "$n starts to search around for some free tinder and happens to find some.", ch, NULL, NULL, TO_ROOM);
         act(AT_ORANGE, "You start to search around for some free tinder and happen to find some!", ch, NULL, NULL, TO_CHAR);
         tinder = create_object(get_obj_index(OBJ_VNUM_TINDER), 1);
         if (!tinder)
         {
            bug("do_gathertinder.  Missing the tinder vnum!");
            return;
         }
         obj_to_room(tinder, ch->in_room, ch);
         WAIT_STATE(ch, PULSE_PER_SECOND*4);
         return;
      }
      else
      {
         act(AT_GREEN, "$n starts to search around for some free tinder, but happens to find none.", ch, NULL, NULL, TO_ROOM);
         act(AT_GREEN, "You start to search around for some free tinder, but you happen to fine none.", ch, NULL, NULL, TO_CHAR);
         WAIT_STATE(ch, PULSE_PER_SECOND*10);
         return;
      }
   }
   else
   {
      send_to_char("This will only work in an area highly populated with trees.\n\r", ch);
      return;
   }
}

void do_startfire(CHAR_DATA * ch, char *argument)
{
   OBJ_DATA *tinder;
   OBJ_DATA *flint;
   OBJ_DATA *knife;
   OBJ_DATA *fire;
   int sector;
   int chance;
   int level = POINT_LEVEL(LEARNED(ch, gsn_startfire), MASTERED(ch, gsn_startfire));
   
   if (IN_WILDERNESS(ch))
   {
      sector = map_sector[ch->map][ch->coord->x][ch->coord->y];
   }
   else
   {
      sector = ch->in_room->sector_type;   
   }
   if ((knife = get_eq_char(ch, WEAR_WIELD)) == NULL)
   {
      send_to_char("You need to be wielding some knife like weapon to do this.\n\r", ch);
      return;
   }
   if (wielding_skill_weapon(ch, 0) != 7)
   {
      send_to_char("You need to be wielding some knife like weapon to do this.\n\r", ch);
      return;
   }
   for (tinder = ch->first_carrying; tinder; tinder = tinder->next_content)
   {
      if (tinder->item_type == ITEM_TINDER)
      {
         break;
      }
   }
   if (!tinder)
   {
      send_to_char("You need to have some tinder to start a fire.  See (HELP STARTFIRE) to see how to get tinder.\n\r", ch);
      return;
   }
   for (flint = ch->first_carrying; flint; flint = flint->next_content)
   {
      if (flint->item_type == ITEM_FLINT)
      {
         break;
      }
   }
   if (!flint)
   {
      send_to_char("You need to have a flint to start a fire.  See (HELP STARTFIRE) to see how to get a flint.\n\r", ch);
      return;
   }
   if (sector == SECT_WATER_SWIM || sector == SECT_WATER_NOSWIM || sector == SECT_UNDERWATER || sector == SECT_AIR
   ||  sector == SECT_OCEANFLOOR || sector == SECT_OCEAN || sector == SECT_RIVER)
   {
      send_to_char("You need dry ground to start a fire.\n\r", ch);
      return;
   }
   
   chance = 1 + (level*3/2);
   
   if (number_range(1, 100) <= chance)
   {
      act(AT_RED, "$n pulls out a $p and strikes it against a flint....a fire starts burning up the tinder.", ch, knife, NULL, TO_ROOM);
      act(AT_RED, "You pull out a $p and strike it against a flint....luckily a fire starts burning up the tinder.", ch, knife, NULL, TO_CHAR);
      learn_from_success(ch, gsn_startfire, NULL);
      fire = create_object(get_obj_index(OBJ_VNUM_FIRE), 1);
      if (!fire)
      {
         bug("do_startfire.  Missing the fire vnum!");
         return;
      }
      WAIT_STATE(ch, PULSE_PER_SECOND*2);
      obj_to_room(fire, ch->in_room, ch);
      separate_obj(tinder);
      obj_from_char(tinder);
      extract_obj(tinder);
      return;
   }
   else
   {
      act(AT_GREEN, "$n pulls out a $p and strikes it against a flint....no such luck though creating a fire.", ch, knife, NULL, TO_ROOM);
      act(AT_GREEN, "You pull out a $p and strike it against a flint.....no luck today, the tinder did not catch fire.", ch, knife, NULL, TO_CHAR);
      learn_from_failure(ch, gsn_startfire, NULL);
      WAIT_STATE(ch, PULSE_PER_SECOND*5);
      return;
   }
}
   
void do_forage(CHAR_DATA * ch, char *argument)
{
   int sector;
   int food;
   char name[MSL];
   char shortd[MSL];
   char longd[MSL];
   char arg[MIL];
   int fv=1;
   int chance;
   int speed = PULSE_PER_SECOND*6;
   OBJ_DATA *ofood;
   
   if (check_npc(ch))
      return;
      
   if (argument[0] == '\0')
   {
      send_to_char("Syntax:  forage food [quick/normal/long]\n\r", ch);
      send_to_char("Syntax:  forage water [quick/normal/long]\n\r", ch);
      return;
   }
   
   if (IN_WILDERNESS(ch))
   {
      sector = map_sector[ch->map][ch->coord->x][ch->coord->y];
   }
   else
   {
      sector = ch->in_room->sector_type;   
   }
   argument = one_argument(argument, arg);
   
   if (!str_cmp(arg, "water"))
   {
      for (ofood = ch->first_carrying; ofood; ofood = ofood->next_content)
      {
         if (ofood->item_type == ITEM_DRINK_CON)
         {
            break;
         }
      }
      if (!ofood)
      {
         send_to_char("You need something to hold the water.\n\r", ch);
         return;
      }
      if (ofood->value[1] >= ofood->value[0])
      {
         send_to_char("Your drinking container is full.\n\r", ch);
         return;
      }
      if (sector == SECT_WATER_SWIM || sector == SECT_WATER_NOSWIM || sector == SECT_RIVER)
      {
         act(AT_GREEN, "$n gets on $s knees and fills up $p with fresh water.", ch, ofood, NULL, TO_ROOM);
         act(AT_GREEN, "You get on your knees and fill up $p with fresh water.", ch, ofood, NULL, TO_CHAR);
         ofood->value[1] = ofood->value[0];
         learn_from_success(ch, gsn_forage, NULL);
         WAIT_STATE(ch, speed);
         return;
      }
      else if (sector == SECT_FIELD || sector == SECT_FOREST || sector == SECT_HILLS || sector == SECT_PLAINS ||
               sector == SECT_HCORN || sector == SECT_HGRAIN || sector == SECT_STREE || sector == SECT_NTREE ||
               sector == SECT_SCORN || sector == SECT_NCORN || sector == SECT_SGRAIN || sector == SECT_NGRAIN ||
               sector == SECT_PATH || sector == SECT_STONE || sector == SECT_SSTONE || sector == SECT_NSTONE)
      {
         chance = 5 + (POINT_LEVEL(LEARNED(ch, gsn_forage), MASTERED(ch, gsn_forage)/2));
         if (!str_cmp(argument, "quick"))
         {
            chance -= 15;
            speed = PULSE_PER_SECOND*3;
         }
         else if (!str_cmp(argument, "long"))
         {
            chance += 15;
            speed = PULSE_PER_SECOND*14;
         }
         if (number_range(1, 100) > chance)
         {
            act(AT_GREEN, "$n gets on $s knees and starts to search for water....but finds none.", ch, NULL, NULL, TO_ROOM);
            act(AT_GREEN, "You get on your knees and search for water....no water here.", ch, NULL, NULL, TO_CHAR);
            learn_from_failure(ch, gsn_forage, NULL);
            WAIT_STATE(ch, speed);
            return;
         }   
         else
         {
            act(AT_GREEN, "$n gets on $s knees and fills up $p with fresh water.", ch, ofood, NULL, TO_ROOM);
            act(AT_GREEN, "You get on your knees and fill up $p with fresh water.", ch, ofood, NULL, TO_CHAR);
            separate_obj(ofood);
            ofood->value[1] = ofood->value[0];
            learn_from_success(ch, gsn_forage, NULL);
            WAIT_STATE(ch, speed);
            return;
         }  
      }
      else if (sector == SECT_OCEANFLOOR || sector == SECT_OCEAN || sector == SECT_UNDERWATER)
      {
         send_to_char("You cannot find fresh water here.\n\r", ch);
         return;
      }
      else
      {
         send_to_char("You cannot forage for water here, sorry.\n\r", ch);
         return;
      }
   }
   if (!str_cmp(arg, "food"))
   {
      if (IN_WILDERNESS(ch) && sector == SECT_HCORN && resource_sector[ch->map][ch->coord->x][ch->coord->y] >= 3000)
      {
         chance = 30 + (POINT_LEVEL(LEARNED(ch, gsn_forage), MASTERED(ch, gsn_forage)/2));
         if (!str_cmp(argument, "quick"))
         {
            chance -= 15;
            speed = PULSE_PER_SECOND*3;
         }
         else if (!str_cmp(argument, "long"))
         {
            chance += 20;
            speed = PULSE_PER_SECOND*14;
         }
         if (number_range(1, 100) > chance)
         {
            act(AT_GREEN, "$n gets on $s knees and starts to forage for food, but is able to find nothing.", ch, NULL, NULL, TO_ROOM);
            act(AT_GREEN, "You get on your knees and start to forage for food, but you are not able

Showing the first 100 KB of 341.4 KB. Download the archive for the full file.

Site Stats

Snippets: 1791
Codebases: 571