Re: [CODE] Some freeky advance problems

From: Rich Chiavaroli (rchiav@frontiernet.net)
Date: 08/23/99


On Mon, 23 Aug 1999, Phillip A Ames wrote:

OK, I changed level_exp to int level_exp(int level), and rewrote
advance_xp

void advance_xp(struct char_data * ch, int gain, int classnum, int
newlevel)
{
  int nextlev = (GET_CLASS_LEV(ch, classnum) + 1);
    sprintf(buf, "advance_xp called, %d gain, %d classnum", gain,
classnum);
    log(buf);
    log("%d nextlev", nextlev);
    log("%d before gain", GET_EXP(ch));
  GET_EXP(ch) += gain;
    log("XP after gain - %d", GET_EXP(ch));
  if (GET_EXP(ch) < 0)
    GET_EXP(ch) = 0;


  while(((level_exp(nextlev) - GET_EXP(ch)) < 0) && ((GET_CLASS_LEV(ch,
classnum) + 1) < newlevel)){
          log("level_exp(nextlev) - GET_EXP(ch)) = %d", (level_exp(nextlev) -
GET_EXP(ch)));
        advance_level(ch, classnum);
        nextlev++;
    nextlev = (GET_CLASS_LEV(ch, classnum) + 1);
          log("new nextlevel - %d", nextlev);
  }
}

And this is how its being called from do_advance...
  advance_xp(victim, (level_exp(newlevel) - GET_EXP(victim)),
GET_ADVANCE_CLASS(victim), newlevel);

And this is what comes up in my logs...

Aug 23 09:20:55 :: [**LEVEL**] Grathol advanced to level 0 in Helm
Aug 23 09:20:55 :: [**NEW PLAYER**] Grathol [127.0.0.1] .
Aug 23 09:20:56 :: Grathol entering game with no equipment.
Aug 23 09:21:38 :: [**SET**] Grathol's advance set to 1(Helm) by Gowron
Aug 23 09:22:01 :: (GC) Gowron has advanced Grathol to level 5 (from 1)
Aug 23 09:22:01 :: advance_xp called, 49999 gain, 1 classnum
Aug 23 09:22:01 :: 2 nextlev
Aug 23 09:22:01 :: 1 before gain
Aug 23 09:22:01 :: XP after gain - 50000
Aug 23 09:22:01 :: level_exp(nextlev) - GET_EXP(ch)) = -20000
Aug 23 09:22:01 :: [**LEVEL**] Grathol advanced to level 2 in Helm
Aug 23 09:22:01 :: new nextlevel - 3
Aug 23 09:22:01 :: level_exp(nextlev) - GET_EXP(ch)) = -10000
Aug 23 09:22:01 :: [**LEVEL**] Grathol advanced to level 3 in Helm
Aug 23 09:22:01 :: new nextlevel - 4


And these are the XP requirements for the first 10 levels
  /* Exp required for normal mortals is below */

    switch (level) {
      case  0: return 10000;
      case  1: return 20000;
      case  2: return 30000;
      case  3: return 40000;
      case  4: return 50000;
      case  5: return 50000;
      case  6: return 50000;
      case  7: return 50000;
      case  8: return 50000;
      case  9: return 75000;
      case 10: return 75000;
...


Any ideas? I'm stumped.


-- Well here's what I see..
I can't tell how you're handeling your exp calculations becsause there is
stuff missing. But what I deduce from your switch statement, exp is not
cumulative? Your switch statement looks like it's the exp required to get
to the next level. I also don't see anyplace that you set the players exp
to 0 so once they get to level 4, they will already be at the exp for
level 8.. which means that they will never pass the conditional check of
 while(((level_exp(nextlev) - GET_EXP(ch)) < 0) because it will equate to
0. I can't see how you handle the rest of it so this is only a guess.

Rich


     +------------------------------------------------------------+
     | 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