[Code] Skillstat Command for Immorts

From: John Evans (evansj@texas.net)
Date: 02/25/97


I found that sometimes I wanted to give a character a 10% boost (or
penalty) to a particular skill or spell for a finished quest, or as
punishment or for whatever reason.

I then discovered that there was NO way to tell what a person's current
skill levels are at! I mean, I could have snooped them and forced them to
type "prac", but that wasn't what I wanted. I wanted to know the EXACT
percentage they their skill was at.

This bit of code does that. It will show the skills and spells that they
currently have, and how learned they are in the skill. The code is a bit
messy because it is the first immort command that I have ever coded.

If you find any problems with the command or that is wasteful is
allocating memory, let me know along with some advice on how to make the
function better.

Enjoy!

----- interpreter.c -----

Search for:
ACMD(do_skillset)

Add:
ACMD(do_skillstat)

Search for:
  { "skillset" , POS_SLEEPING, do_skillset , LVL_GRGOD, 0 },

Add:
  { "skillstat", POS_SLEEPING, do_skillstat, LVL_GRGOD, 0 },


----- act.wizard.c -----

Just add the following to the bottom of the file:

int spell_sort_info[MAX_SKILLS+1];
extern char *spells[];

void sort_for_skillstat(void)
{
  int a, b, tmp;

  /* initialize array */
  for (a = 1; a < MAX_SKILLS; a++)
    spell_sort_info[a] = a;

  /* Sort.  'a' starts at 1, not 0, to remove 'RESERVED' */
  for (a = 1; a < MAX_SKILLS - 1; a++)
    for (b = a + 1; b < MAX_SKILLS; b++)
      if (strcmp(spells[spell_sort_info[a]], spells[spell_sort_info[b]]) > 0) {
        tmp = spell_sort_info[a];
        spell_sort_info[a] = spell_sort_info[b];
        spell_sort_info[b] = tmp;
      }
}

char *show_skill_quality(int percent)
{
  static char buf[256];

  if (percent == 0)
    strcpy(buf, " (not learned)");
  else if (percent <= 10)
    strcpy(buf, " (awful)");
  else if (percent <= 20)
    strcpy(buf, " (bad)");
  else if (percent <= 40)
    strcpy(buf, " (poor)");
  else if (percent <= 55)
    strcpy(buf, " (average)");
  else if (percent <= 70)
    strcpy(buf, " (fair)");
  else if (percent <= 80)
    strcpy(buf, " (good)");
  else if (percent <= 85)
    strcpy(buf, " (very good)");
  else
    strcpy(buf, " (superb)");

  return (buf);
}

ACMD(do_skillstat)
{
  extern char *spells[];
  extern struct spell_info_type spell_info[];
  int i, sortpos = 0;
  struct char_data *vict = 0;

  argument = one_argument(argument, arg);

  if (!*arg) {
    send_to_char("Stats on who's skills?\r\n", ch);
    return;
  }

  if ((vict = get_char_vis(ch, arg))) {
    sprintf(buf, "%s's knows the following skills/spells:\r\n",
                  GET_NAME(vict));
    strcpy(buf2, buf);

    for (sortpos = 1; sortpos < MAX_SKILLS; sortpos++) {
      i = spell_sort_info[sortpos];
      if (strlen(buf2) >= MAX_STRING_LENGTH - 32) {
        strcat(buf2, "**OVERFLOW**\r\n");
        break;
      }
      if (GET_LEVEL(vict) >= spell_info[i].min_level[(int) GET_CLASS(vict)]) {
        sprintf(buf, "%-20s (%-3d) %s\r\n", spells[i], 
              GET_SKILL(vict, i), show_skill_quality(GET_SKILL(vict, i)));
        strcat(buf2, buf);
      }
    }
  }
  else
    strcpy(buf2, "No such player around.\r\n");

  page_string(ch->desc, buf2, 1);
}


That should do it for you. If you find anyway to improve upon this, please
let me know at evansj@texas.net.

(BTW - This is nothing more than a hack of the "guild" spec proc.)

John Evans

mailto:evansj@texas.net
http://www.texas.net/~evansj   [RPGs, SCA, MUDs and Search Engines]
slanted.elfwerks.com:2020      [Slanted Reality]

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
|    Or send 'info circle' to majordomo@cspo.queensu.ca     |
+-----------------------------------------------------------+



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