Re: Question about find_skill_num()

From: Angus Mezick (angus@EDGIL.CCMAIL.COMPUSERVE.COM)
Date: 09/22/98


Whoa, just getting back from vaca George? ;)  Well, here is my find_skill_num()
function.  It will match cast 'm m' to magic missile.  Woo Woo!  Sorry about the
indentation, C&P screwed it up a little.  I reverted my spell code to use:
   {"armor",  30, 10, 2, POS_FIGHTING,
    TAR_CHAR_ROOM, NON_VIOLENT, MAG_AFFECTS,
    UU, 8,UU,10,UU,12,UU,UU,UU,15,15,UU,UU,UU,UU,UU,UU,UU,UU,
    IS_SPELL,5},
because we like this format better, so you might need to change some things.
(the last int is casting_time and the IS_SPELL is for sorting)
--Angus


int find_skill_num(char *name)
{
   int skindex = 0, ok;
   char *temp, *temp2;
   char *first=get_buffer(256);
   char *first2=get_buffer(256);

   if(*name=='!')
      return -1;
   for(skindex=1;skindex<MAX_SPELLS;skindex++)
      {
      if (is_abbrev(name, spells[spell_sort_info[skindex]].spell_name))
       {
       release_buffer(first2);
       release_buffer(first);
       return spell_sort_info[skindex];
       }

      ok = 1;
      temp = any_one_arg(spells[spell_sort_info[skindex]].spell_name, first);
      temp2 = any_one_arg(name, first2);
      while (*first && *first2 && ok)
       {
       if (!is_abbrev(first2, first))
          ok = 0;
       temp = any_one_arg(temp, first);
       temp2 = any_one_arg(temp2, first2);
       }

      if (ok && !*first2)
       {
       release_buffer(first2);
       release_buffer(first);
       return spell_sort_info[skindex];
       }
      }
   release_buffer(first2);
   release_buffer(first);
   return -1;
}


______________________________ Reply Separator _________________________________
Subject: Re:  Question about find_skill_num()
Author:  INTERNET:CIRCLE@POST.QUEENSU.CA at CSERVE
Date:    9/21/98 11:38 PM

rve.com>

On Thu, 10 Sep 1998, Angus Mezick wrote:

>Just wondering why we don't use spells[spell_sort_info[i]] instead of spells[i]
>for searching for spell numbers.  Just replace all instances of skindex with

I'd assume because all the !UNUSED! end up at the top of the sorted list.

>spell_sort_info[skindex].  We recently ran into a problem with a skill named
>shock following the shocking grasp spell and the player not being able to
>practice the skill.  Anyone see any problems with this? esp since we spend all
>that time bubble sorting all the spells/skills during boot.

qsort() now.  Shouldn't really be a problem, but beware of the !RESERVED!
and !UNUSED! spells popping up first.  They're filtered out of the
list_skills() function by this line:

    if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)]) {


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST