Re: [Code] do_advance

From: Derek L. Karnes (
Date: 09/11/96

A friend of mine wrote:
I just noticed this problem today; possibly you already encountered it.
When advancing someone to a level lower than his current level, he gets put to that level except his
stats like H,V, and M are his stats at level 1. He'll be level 19 (for example) with these level 1
values. This is because do_advance() makes a call to do_start() for when someone is advanced a level
that is lower than their current level. It then assigns the newlevel to the victim's current level.
Also, do_start() rerolls the guy's ability scores.

Here's my 5 minute hack to fix it:

  struct char_data *victim;
  char *name = arg, *level = buf2;
  int newlevel, oldlevel;
  int str, intel, wis, dex, con, cha, add;
  void do_start(struct char_data *ch);

  void gain_exp(struct char_data * ch, int gain);

  two_arguments(argument, name, level);

  if (*name) {
    if (!(victim = get_char_vis(ch, name))) {
      send_to_char("That player is not here.\r\n", ch);
  } else {
    send_to_char("Advance who?\r\n", ch);

  if (GET_LEVEL(ch) <= GET_LEVEL(victim)) {
    send_to_char("Maybe that's not such a great idea.\r\n", ch);
  if (IS_NPC(victim)) {
    send_to_char("NO!  Not on NPC's.\r\n", ch);
  if (!*level || (newlevel = atoi(level)) <= 0) {
    send_to_char("That's not a level!\r\n", ch);
  if (newlevel > LVL_IMPL) {
    sprintf(buf, "%d is the highest possible level.\r\n", LVL_IMPL);
    send_to_char(buf, ch);
  if (newlevel > GET_LEVEL(ch)) {
    send_to_char("Yeah, right.\r\n", ch);
  if (newlevel == GET_LEVEL(victim)) {
    send_to_char("They are already at that level.\r\n", ch);
  oldlevel = GET_LEVEL(victim);
  if (newlevel < GET_LEVEL(victim)) {
	/* store the char's stats, advance him from 1 to new level
            then reset his old stats. */
    str = victim->real_abils.str;
    add = victim->real_abils.str_add;
    dex = victim->real_abils.dex;
    intel = victim-> ;
    con = victim->real_abils.con;
    cha = victim->real_abils.cha;
    wis = victim->real_abils.wis;
    send_to_char("You are momentarily enveloped by darkness!\r\n"
		 "You lose all your levels, but then\r\n", victim);
    sprintf(buf," %s %d", GET_NAME(victim), newlevel);
    do_advance(ch, buf, 0, 0);
    victim->real_abils.str_add = add;
    victim-> =  intel;
    victim->real_abils.wis =  wis;
    victim->real_abils.dex =  dex;
    victim->real_abils.str =  str;
    victim->real_abils.con =  con;
    victim->real_abils.cha = cha;
  } else {
    act("$n makes some strange gestures.\r\n"
	"A strange feeling comes upon you,\r\n"
	"Like a giant hand, light comes down\r\n"
	"from above, grabbing your body, that\r\n"
	"begins to pulse with colored lights\r\n"
	"from inside.\r\n\r\n"
	"Your head seems to be filled with demons\r\n"
	"from another plane as your body dissolves\r\n"
	"to the elements of time and space itself.\r\n"
	"Suddenly a silent explosion of light\r\n"
	"snaps you back to reality.\r\n\r\n"
	"You feel slightly different.", FALSE, ch, 0, victim, TO_VICT);

  send_to_char(OK, ch);

  sprintf(buf, "(GC) %s has advanced %s to level %d (from %d)",
	  GET_NAME(ch), GET_NAME(victim), newlevel, oldlevel);
	 (titles[(int) GET_CLASS(victim)][newlevel].exp) - GET_EXP(victim));
  save_char(victim, NOWHERE);

                                    \ | /
                        \  /---------------------\  /
                       --    --
                        /  \---------------------/  \
                                    / | \
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   |

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