Re: [CODE] Exp code and formula

From: Mark Dickey (mark@BESTWEB.NET)
Date: 11/18/97


Ok, there are a couple things.  The first is the first list of if/else
statements.  The way it is working takes CPU than is needed.  Try:

 /* Level modifications to exp */
if (GET_LEVEL(ch) >= 0 && GET_LEVEL(ch) < 10)
   mod = 1;
else if (GET_LEVEL(ch) < 20)
   mod = 2;
else if (GET_LEVEL(ch) < 30)
   mod = 4;

ETC....

This will keep it going through until it matches one of the statements,
and then it will continue on.

The next thing is about the HUMAN thing.  When you have tested the exp,
are you always having the character a human?  I would guess that it works
while the player is not a human, and stops working if it is a human.

Also, for the human section, I would do:

/* If character is human, grant a 10% xp bonus */

if (IS_HUMAN(ch)) {
  h_mod = exp / 10;
  exp = exp - h_mod;
}

This might or might not help, but it will, at least, make the computer
work less hard.

Well,

Mark Dickey

PS.  I have left the other code in case people want to review what I am
answering.

On Tue, 18 Nov 1997, Chuck Reed wrote:

> I am trying to figure out an exp formula for levels.  I thought I finally
> had it when it starts going crazy in the game.  This is the stuff I have for
> it at the end of utils.c.  For the first 10 levels, players have to have -1
> exp and then on out, the exp_to_level is far higher than it should be (ie
> 142K instead of 13K).  Here is the code I am using:
>
>
> int exp_to_level(struct char_data *ch)
> {
> int exp, mod, h_mod;
>
> /* Level modifications to exp */
> if (GET_LEVEL(ch) >= 0 && GET_LEVEL(ch) < 10)
>    mod = 1;
> if (GET_LEVEL(ch) >= 10 && GET_LEVEL(ch) < 20)
>    mod = 2;
> if (GET_LEVEL(ch) >= 20 && GET_LEVEL(ch) < 30)
>    mod = 4;
> if (GET_LEVEL(ch) >= 30 && GET_LEVEL(ch) < 40)
>    mod = 8;
> if (GET_LEVEL(ch) >= 40 && GET_LEVEL(ch) < 50)
>    mod = 16;
> if (GET_LEVEL(ch) >= 50 && GET_LEVEL(ch) < 60)
>    mod = 25;
> else
>    mod = 30;
>
> /*   THE FORMULA!!!!!! */
> if (GET_LEVEL(ch) = 1)
>    exp = 800;
> else
>    exp = GET_LEVEL(ch) * 500 * ((GET_LEVEL(ch) - 1) / 10) * mod;
>
> /* If character is human, grant a 10% xp bonus */
> h_mod = exp * (1 / 10);
> if (IS_HUMAN(ch))
>    exp = exp - h_mod;
>
> return exp;
> }


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



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