[CODE] Spelllists

From: Søren P. Skou (serces@MUD.DK)
Date: 09/21/97


Hi there..

I got bored of everytime I put in a new spell, I had to update the
helpfiles. *yawn* The same for skills. So I put in a little thingie in
act.informative.c to do the thing for me.

ACMD(do_spellhelp)
{
/* Also Do Skill Help *chuckle* */
 int sortpos = 0;
 int sort_array[MAX_SKILLS+1];
 int a = 0, b = 0, tmp = 0;
 int class = GET_CLASS(ch);
 char inpt[256];
 extern char *pc_class_types[];

 skip_spaces(&argument);
 one_argument(argument, inpt);

 for (a = 0;a < NUM_CLASSES;a++) {
  if (is_abbrev(inpt, pc_class_types[a])) {
   class = a;
   b = 1;
   sprintf(buf, "The complete overview of abilities for %ss\r\n",
pc_class_type
   strcpy(buf2, buf);
   break;
  }
 }
 if (b != 1) {
  send_to_char("Sorry, you have to enter a valid class\r\n", ch);
  return;
 }

  for (a = 1; a < MAX_SKILLS; a++)
    sort_array[a] = a;

  for (a = 1; a < MAX_SKILLS - 1; a++)
    for (b = a + 1; b < MAX_SKILLS; b++)
   if (spell_info[sort_array[a]].min_level[class] >
       spell_info[sort_array[b]].min_level[class]) {
        tmp = sort_array[a];
        sort_array[a] = sort_array[b];
        sort_array[b] = tmp;
      }

 for (sortpos = 1; sortpos < MAX_SKILLS;sortpos++) {
  if (strcmp(spells[sort_array[sortpos]], "!UNUSED!"))
   if (spell_info[sort_array[sortpos]].min_level[class] < 101) {
   sprintf(buf, "%sLevel:%s %s%d%s %s%-20s%s ",
   CCWHT(ch, C_NRM), CCNRM(ch, C_NRM),
   CCBGRN(ch, C_NRM), spell_info[sort_array[sortpos]].min_level[class],
   CCNRM(ch, C_NRM),
   CCBGRN(ch, C_NRM), spells[sort_array[sortpos]], CCNRM(ch, C_NRM));
   strcat(buf2, buf);
   if (spell_info[sort_array[sortpos]].violent ||
       IS_SET(spell_info[sort_array[sortpos]].routines, MAG_DAMAGE))
     sprintf(buf, "%sViolent%s", CCBBLU(ch, C_NRM), CCNRM(ch, C_NRM));
   else
     sprintf(buf, "%sPeaceful%s", CCMAG(ch, C_NRM), CCNRM(ch, C_NRM));
   strcat(buf2, buf);
   strcat(buf2, "\r\n");
  }
 }
 page_string(ch->desc, buf2, 1);
}


All you need to do now, is to define the command in interpreter.c..

Okay, it's not nice (eg. All skills are peacefull. strangely enough..)
and probably could do a little cosmetics somehow, but at least this will
keep me away from updating the helpfiles all the time. :)

/Serces


     +------------------------------------------------------------+
     | 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/08/00 PST