A Question About Experience

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chris
    PosChengband Maintainer
    • Jan 2008
    • 702

    #16
    Originally posted by Derakon
    Looking in the code, the "expfactor" variable appears to be what determines experience needed to level up, and it's stored as a byte, as is the racial (but not the class-based) modifiers it derives from. So yes, there's a strong possibility of rollover. As best I can tell, the experience needed for the next level is given as the experience needed for the previous level multiplied by expfactor and divided by 100; thus, at worst you can make a character that levels up 2.55 times slower than the base rate.
    Just a warning, you might overflow when calculating experience requirements as well. Chengband allows ridiculous racial/class/personality xp requirements, so I've run into this issue. Try something like the following rather than naked table reads sprinkled throughout the code:
    Code:
    int exp_requirement(int level)
    {
    	int base = player_exp[level-1];
    	if (base % 100 == 0)
    		return base / 100 * p_ptr->expfact;
    	else
    		return base * p_ptr->expfact / 100;
    }

    Comment

    • Derakon
      Prophet
      • Dec 2009
      • 9022

      #17
      Oh, I was wrong about how requirements are calculated. They aren't based on the requirement for the previous level, but rather on a table of base values stored in tables.c, called player_exp. So if you wanted to change the levelup requirements for all characters, you could modify that.

      Comment

      Working...
      😀
      😂
      🥰
      😘
      🤢
      😎
      😞
      😡
      👍
      👎