[CODE] Odd Bug Strikes Every 3rd SKILL_XXX

From: Robert Moon (LegalWriter@earthlink.net)
Date: 05/27/99

I have come across an odd bug that I can't figure out.  An argument for my
modified skillo() function parses incorrectly for EVERY 3rd SKILL_XXX.  My
brain has turned to mush trying to figure this out.  If anyone can see
what's going on, any assistance would be most appreciated.  :)   Here is
the relevant information and further explanation:

The code is p15, 128-bit modified; classes removed.  I added 2 arguments to
skillo() and severed it completely from spello().  I duplicated all
relevant spello() subroutines for corresponding skillo() subroutines.  The
2 new arguments added to skillo() dictate the number of GET_PRACTICES it
costs to (a) learn a skill for the first time and (b) increase your
knowledge of that skill once you know it.  In stock p15 code, it only costs
1 GET_PRACTICE each time someone learns or increases a spell or skill, per
SPECIAL(guild) in spec_procs.c.  I wanted to have it cost more to learn a
skill the first time.  Having modified all the relevant files, my new
system works.  --Except for every 3rd skill defined in spells.h.

For simplicity sake, I set all skills to cost 10 GET_PRACTICES the first
time you practice it and 5 GET_PRACTICES each time thereafter.  In
spells.h, my SKILL_XXXs start at 201.  Skill #201 (combat arts) subtracts
the appropriate GET_PRACTICES for both initally learning a new spell (10
GET_PRACTICES) and for subsequently practicing it further (5
GET_PRACTICES).  However, starting with Skill #202 -- and every 3rd skill
thereafter (205, 208, 211, 214, 217, etc) -- the initial cost of 10
GET_PRACTICES for learning a new skill is appropriately subtracted from the
player's records. BUT...  the subsequent cost of increasing knowledge in
those errant skills is only decremented by 1 GET_PRACTICES rather than 5
GET_PRACTICES.  I have no idea why.  Here are some relevant code snippets
that may unravel the mystery:

In spell_parser.c (and correspondingly in spells.h), these functions were

void skillo(int skl, const char *name, int init_cost, int sub_cost)
  skill_info[skl].init_cp_cost = init_cost;
  skill_info[skl].sub_cp_cost = sub_cost;
  skill_info[skl].name = name;

void mag_assign_skills(void)
  int i;
/* MAX_SPELLS is 200 (from 1-200).  MAX_SKILLS is 299 (from 201-299) */
  for (i = MAX_SPELLS + 1; i <= MAX_SKILLS; i++)

  skillo(SKILL_COMBAT_ARTS, "combat arts", 10, 5);      /* 201 in spells.h */
  skillo(SKILL_SPELLCRAFT, "spellcraft", 10, 5);        /* 202 in spells.h */
  skillo(SKILL_SWORDS, "swords", 10, 5);                        /* 203 in spells.h */
  skillo(SKILL_POLEARMS, "polearms", 10, 5);            /* 204 in spells.h */
  skillo(SKILL_DODGING, "dodging", 10, 5);              /* 205 in spells.h */
  skillo(SKILL_HEALING, "healing", 10, 5);              /* 206 in spells.h */
  skillo(SKILL_APPRAISING, "appraising", 10, 5);        /* 207 in spells.h */
  skillo(SKILL_WOODWORKING, "woodworking", 10, 5);      /* 208 in spells.h */
  skillo(SKILL_HORSE_RIDING, "horse riding", 10, 5);    /* 276 in spells.h */

In spec_procs.c, SPECIAL(guild) is modified as follows:

  int skill_num;


  if (GET_SKILL(ch, skill_num) > 0) {   /* Has he practiced this yet? */
    if (GET_PRACTICES(ch) >= skill_info[skill_num].sub_cp_cost)
      GET_PRACTICES(ch) -= skill_info[skill_num].sub_cp_cost;
    else {
      send_to_char("You do not have enough character points to increase
your skill!\r\n", ch);  /* "Character Points" replace "practices" in my MUD */
      return (1);
  else {  /*  It's a new skill to this character!  */
    if (GET_PRACTICES(ch) >= skill_info[skill_num].init_cp_cost)
      GET_PRACTICES(ch) -= skill_info[skill_num].init_cp_cost;
    else {
      send_to_char("You do not have enough character points to learn a new
skill!\r\n", ch);
      return (1);

  /* Now increase the skill by 1 "percent" regardless of intelligence
   * I'm actually using "ranks" and not "percentages"
  SET_SKILL(ch, skill_num, GET_SKILL(ch, skill_num) + 1);
  send_to_char("You practice a while....\r\n", ch);
  return (1);

As you can see in the spello() calls, "spellcraft" is set to decrement a
player's GET_PRACTICES by 5 if he practices it a 2nd or more times.
However the bug has spellcraft, dodging, woodworking, and every 3rd skill
thereafter only decrementing the player's GET_PRACTICES by 1 if he learns 2
or more ranks in those skills.  (The inital cost of 10 GET_PRACTICES oddly
seems to still decrement properly.)  Any help is most appreciated!  Thanks
in advance.

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

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