(no subject)

From: Sean P. Mountcastle (mountcas@pluto.ee.cua.edu)
Date: 01/22/95


     I am sorry for posting that lame question about variable
assignment.  But now I have another question that I hope will
test your C Programming knowledge a bit more.
     I have changed the levelling routine so that you can only
gain levels while with in your guild (well, any guild for that
matter).  It seems to work the way intended when the character
does not meet the criterion for advancing.  But if the character
is able to advance then it just swallows the command (as if the
player had just hit return).  I have included the code so that
hopefully someone can spot my mistake.
     Thanks in advance, for any help you could offer.


SPECIAL(guild_low)
{
  int skill_num, percent;
  int can_level = FALSE;

  extern struct spell_info_type spell_info[];
  extern struct int_app_type int_app[26];

  if (IS_NPC(ch) || !CMD_IS("practice") || !CMD_IS("gain"))
    return 0;

  skip_spaces(&argument);

  if (CMD_IS("practice")) 
  {
     if (GET_LEVEL(ch) >= 15) 
     {
     send_to_char("I have taught you all that I know, you must seek another.\r\n",ch);
     return 1; 
     }
     if (!*argument) 
     {
     list_skills(ch);
     return 1;
     }
     if (GET_PRACTICES(ch) <= 0) 
     {
     send_to_char("You do not seem to be able to practice now.\r\n", ch);
     return 1;
     }

     skill_num = find_skill_num(argument);

     if (skill_num < 1 || GET_LEVEL(ch) < spell_info[skill_num].min_level[(int) GET_CLASS(ch)]) 
     {
     sprintf(buf, "You do not know of that %s.\r\n", SPLSKL(ch));
     send_to_char(buf, ch);
     return 1;
     }
     if (GET_SKILL(ch, skill_num) >= LEARNED(ch)) 
     {
     send_to_char("You are already learned in that area.\r\n", ch);
     return 1;
     }
     send_to_char("You practice for a while...\r\n", ch);
     GET_PRACTICES(ch)--;

     percent = GET_SKILL(ch, skill_num);
     percent += MIN(MAXGAIN(ch), MAX(MINGAIN(ch), int_app[GET_INT(ch)].learn));

     SET_SKILL(ch, skill_num, MIN(LEARNED(ch), percent));

     if (GET_SKILL(ch, skill_num) >= LEARNED(ch))
     send_to_char("You are now learned in that area.\r\n", ch);
     return 1;
  }

  if (CMD_IS("gain"))
  {
     if (GET_LEVEL(ch) >= 15) 
     {
     send_to_char("I have taught you all that I know, you must seek another.\r\n", ch);
     return 1; 
     }
     if (!IS_NPC(ch)) 
     {
     if ((GET_RACE(ch) == RACE_HALFELF)
        && (GET_CLASS(ch) == (CLASS_MONK || \
        CLASS_KNTAHKISIS || CLASS_KNSOLAMNIA)) && \
        (GET_LEVEL(ch) >= 12)) 
     {
        can_level = FALSE;
        send_to_char("You race prohibits you from advancing any further.\r\n",ch); 
     }
     if ((GET_RACE(ch) == RACE_DWARF) && (GET_CLASS(ch) == (CLASS_MAGIC_USER || \
        CLASS_THIEF || CLASS_DRUID || CLASS_ASSASSIN || CLASS_BARD || \
        CLASS_KNTAHKISIS || CLASS_KNSOLAMNIA)) && \
        (GET_LEVEL(ch) >= 12)) 
     {
        can_level = FALSE;
        send_to_char("You race prohibits you from advancing any further.\r\n",ch); 
     }
     if ((GET_RACE(ch) == RACE_GNOME) && (GET_CLASS(ch) == (CLASS_WARRIOR || \
        CLASS_MONK || CLASS_ASSASSIN || CLASS_BARD || CLASS_RANGER || \
        CLASS_KNTAHKISIS || CLASS_KNSOLAMNIA)) && (GET_LEVEL(ch) >= 10)) 
     {
        can_level = FALSE;
        send_to_char("You race prohibits you from advancing any further.\r\n",ch); 
     }
     if ((GET_RACE(ch) == RACE_DROW) && (GET_CLASS(ch) == CLASS_KNSOLAMNIA) && \
        (GET_LEVEL(ch) >= 3)) 
     {
        can_level = FALSE;
        send_to_char("You race prohibits you from advancing any further.\r\n",ch); 
     }
     if ((GET_RACE(ch) == RACE_DROW) && (GET_CLASS(ch) == (CLASS_MONK || \
        CLASS_DRUID || CLASS_CLERIC))) 
     {
        can_level = FALSE;
        send_to_char("You race prohibits you from advancing any further.\r\n",ch); 
     }
     if ((GET_RACE(ch) == RACE_MINOTAUR) && (GET_CLASS(ch) == (CLASS_CLERIC || \
        CLASS_MAGIC_USER || CLASS_DRUID || CLASS_BARD || CLASS_KNSOLAMNIA || \
        CLASS_KNTAHKISIS)) && (GET_LEVEL(ch) >= 4)) 
     {
        can_level = FALSE;
        send_to_char("You race prohibits you from advancing any further.\r\n",ch); 
     }
     if ((GET_RACE(ch) == RACE_CENTAUR) && (GET_CLASS(ch) == (CLASS_THIEF || \
        CLASS_ASSASSIN || CLASS_BARD || CLASS_KNTAHKISIS || \
        CLASS_KNSOLAMNIA)) && (GET_LEVEL(ch) >= 2)) 
     {
        can_level = FALSE;
        send_to_char("You race prohibits you from advancing any further.\r\n",ch); 
     }
     if ((GET_RACE(ch) == RACE_QUALINESTI) && (GET_CLASS(ch) == (CLASS_THIEF || \
        CLASS_ASSASSIN || CLASS_KNTAHKISIS || CLASS_KNSOLAMNIA)) && \
        (GET_LEVEL(ch) >= 5)) 
     {
        can_level = FALSE;
        send_to_char("You race prohibits you from advancing any further.\r\n",ch); 
     }
     if ((GET_RACE(ch) == RACE_SILVANESTI) && (GET_CLASS(ch) == (CLASS_THIEF || \
        CLASS_ASSASSIN || CLASS_KNTAHKISIS || CLASS_KNSOLAMNIA)) && \
        (GET_LEVEL(ch) >= 4)) 
     {
        can_level = FALSE;
        send_to_char("You race prohibits you from advancing any further.\r\n",ch); 
     }
     if ((GET_RACE(ch) == RACE_KAGONESTI) && (GET_CLASS(ch) == (CLASS_CLERIC || \
        CLASS_MAGIC_USER || CLASS_BARD || CLASS_KNTAHKISIS || \
        CLASS_KNSOLAMNIA)) && (GET_LEVEL(ch) >= 4)) 
     {
        can_level = FALSE;
        send_to_char("You race prohibits you from advancing any further.\r\n",ch); 
     }
     if ((GET_RACE(ch) == RACE_KENDER) && (GET_CLASS(ch) == (CLASS_CLERIC || \
        CLASS_MAGIC_USER || CLASS_WARRIOR || CLASS_KNTAHKISIS || \
        CLASS_KNSOLAMNIA))) 
     {
        can_level = FALSE;
        send_to_char("You race prohibits you from advancing any further.\r\n",ch); 
     }
     if ((GET_CLASS(ch) == (CLASS_MAGIC_USER || CLASS_CLERIC || CLASS_DRUID))
        && (GET_REL(ch) == REL_NONE)) 
     {
        can_level = FALSE;
        send_to_char("You must declare a religion before the guild will allow you to advance any further.\r\n",ch); 
     }
     else
       can_level = TRUE;
     return 1;
     }

     if ((can_level) && GET_LEVEL(ch) < LVL_HERO &&
     GET_EXP(ch) >= exp_needed(GET_CLASS(ch), GET_LEVEL(ch) + 1)) 
     {
     while (GET_LEVEL(ch) < LVL_HERO &&
           GET_EXP(ch) >= exp_needed(GET_CLASS(ch), GET_LEVEL(ch) + 1)) 
     {
           send_to_char("You rise a level!\r\n", ch);
           GET_LEVEL(ch) += 1;
           advance_level(ch);
           is_altered = TRUE;
           return 1; 
     } 
     }
     else {
     send_to_char("Sorry you are unable to gain levels at this time.\r\n",ch);
     return 1; 
     }
  } return 0;
}

     I have made 3 other guild routines based on this one, the
only difference is that they will not teach people who are lower
than the last level covered by the previous guild spec_proc, and
they will only advance people up to a certain level.  Also, I know
that the huge block of if statements, based on race and level could
be combined into one HUGE if statement, but I think it is easier to
read like this.  (But, would combining them into one if statement
optimize the code, and reduce lag a bit?).

     Thanks again,

     - Sean Mountcastle

     P.S. Once this is fixed I have another question regarding
the porting of CircleMUD to Ms-Dos (which is easier for me to add
non-OS dependant code in, and test).  So far I have ported it
successfully - the only problem is that instead of being taken
into the game, I am outside of the game and the screen gets
filled with what is supposed to go into the logs....



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