Re: Rankings instead of Levels

From: Michael Gallagher (m_gally@hotmail.com)
Date: 06/11/00


no, i have level, rank and exp saved into the player_table. And it doesn't
recheck everyone's rank when someone gains exp. Let me put the main
functions here.

extern struct player_index_element *player_table;
extern int top_of_p_table;

/*I know this is a big dirty function but it only
runs when the mud boots and with the "resetrank"
command*/
void reset_rankings(void)
{
int i, j, k, r = 1;

for (i = (LVL_IMMORTAL - 1); i > 0; i--) {
  for (j = level_exp(0, i+1); j > level_exp(0, i); j -= 100) {
   for (k = 0; k <= top_of_p_table; k++) {
    if (player_table[k].level == i) {
     if (player_table[k].exp > j) {
      player_table[k].rank = r;
      r++;
     }
    }
   }
  }
}
return;
}

int get_rank(struct char_data *ch)
{
int i, j;

for (i = 0; i <= top_of_p_table; i++)
   if (!strcmp(player_table[i].name, GET_NAME(ch)))
     return (player_table[i].rank);

return(0);
}

/*This is what we run to change rankings within
the game, rather than run everyone's. We check
one player against the ranking higher than her/him.*/

void check_rank(struct char_data *ch)
{
int i, j;

for (i = 0; i <= top_of_p_table; i++)
  if (!strcmp(player_table[i].name, GET_NAME(ch)))
   for (j = 0; j <= top_of_p_table; j++)
    if ((player_table[i].rank + 1) == player_table[j].rank)
      break;


if (!i || !j)
   return;

if (player_table[i].level > player_table[j].level) {
   player_table[i].rank++;
   player_table[j].rank--;
   check_rank(ch);
}
else if (player_table[i].level == player_table[j].level) {
  if (player_table[i].exp > player_table[j].exp) {
   player_table[i].rank++;
   player_table[j].rank--;
   check_rank(ch);
  }
}
}

This probably explains it better.
Subliminal
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


     +------------------------------------------------------------+
     | 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 : 04/10/01 PDT