Re: Max levels gain

From: Daniel W. Burke (dwb@ix.netcom.com)
Date: 06/27/96


On Thu, 27 Jun 1996, Iggy wrote:

> 
> Anyone knows how to change gain_exp function so the players won't be able
> to advance more than one level per kill ?  Also, when they gain a level
> their exp should be set on 0. Here is the function:
> ----------------------------------
> void gain_exp(struct char_data * ch, int gain)
> {
>   int is_altered = FALSE;
>   int num_levels = 0;
>   char buf[128];
> 
>   if (!IS_NPC(ch) && ((GET_LEVEL(ch) < 1 || GET_LEVEL(ch) >= LVL_IMMORT)))
>     return;
> 
>   if (IS_NPC(ch)) {
>     GET_EXP(ch) += gain;
>     return;
>   }
>   if (gain > 0) {

Right here add some code like this:

      /* Decide what the max gain he can have for his level, before 
       * counting max_exp_gain */
      gain = MIN(((titles[(int)GET_CLASS(ch)][(int) GET_LEVEL(ch)+1].exp -
                titles[(int)GET_CLASS(ch)][(int) GET_LEVEL(ch)].exp) /4), gain);

>     gain = MIN(max_exp_gain, gain);     /* put a cap on the max gain per kill */
>     GET_EXP(ch) += gain;
>     while (GET_LEVEL(ch) < LVL_IMMORT &&
>         GET_EXP(ch) >= titles[(int) GET_CLASS(ch)][GET_LEVEL(ch) + 1].exp) {
>       GET_LEVEL(ch) += 1;
>       num_levels++;
>       advance_level(ch);
>       is_altered = TRUE;
>     }
>  
>     if (is_altered) {
>       if (num_levels == 1)
>         send_to_char("You rise a level!\r\n", ch);
>       else {
>         sprintf(buf, "You rise %d levels!\r\n", num_levels);
>         send_to_char(buf, ch);
>       }
>       set_title(ch, NULL);
>       check_autowiz(ch);
>     }
>   } else if (gain < 0) {
>     gain = MAX(-max_exp_loss, gain);    /* Cap max exp lost per death */
>     GET_EXP(ch) += gain;
>     if (GET_EXP(ch) < 0)
>       GET_EXP(ch) = 0;
>   }
> } 



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