[code][long] memorize question

From: Brian Williams - Nashak (bmw@EFN.ORG)
Date: 10/04/97


So far, so good. Except for one thing: I can't seem to get forget to work
how I want it to. I mean, say you have memorized 3 magic missiles, 3 chill
touch, and 3 fireballs.. if you forget magic missile it works perfect,
makes you only have 2 magic missiles. If you forget something that isn't
the first spell you have memorized, it forgets all the spells of that
type, i.e. if you have those spells memorized and forget chill touch, you
forget all 3 for some reason. I can't seem to figure this out, because all
spells go through the same function, so I don't see why it is any
different no matter what spell it is. The code follows:
ACMD(do_forget)
{
  char spellname[MAX_INPUT_LENGTH];
  int spellnum, slot = 0, x;

  if (IS_NPC(ch))
    return;

  if (!*argument) {
    send_to_char("Forget what?!\r\n", ch);
    return;
  } else {
    one_argument(argument, spellname);
    spellnum = find_skill_num(spellname);

    if (spellnum == -1) {
      send_to_char("Forget what?!\r\n", ch);
      return;
    }

    for (x = 0; x < MAX_SPELL_SLOTS; x++) {
      if (MEMORIZED(ch, x) != 0) {
        if (MEMORIZED(ch, x) == spellnum) {
          slot = x;
          break;
        }
      } else {
        slot = -1;
        break;
      }
    }

    if (slot == -1) {
      send_to_char("You do not even have that spell in your memory.\r\n", ch);
      return;
    }

    forget_spell(ch, slot);
    sprintf(spellname, "%s", spells[spellnum]);
    sprintf(buf, "You purge %s from your memory.\r\n", spellname);
    send_to_char(buf, ch);
  }
}

void forget_spell(struct char_data *ch, int slot)
{
  int x;

  MEMORIZED(ch, slot) = 0;
  for (x = 1; x < MAX_SPELL_SLOTS; x++) {
    if (MEMORIZED(ch, x) && MEMORIZED(ch, x-1) == 0) {
      MEMORIZED(ch, x-1) = MEMORIZED(ch, x);
      MEMORIZED(ch, x) = 0;
    } else
      break;
  }
}




       /-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=X=-=-=-=-=-=-=-=-=-=-=-\
       |  Brian M. Williams          | 02/02/83 | bmw@efn.org          |
       X=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=X
       | Boccob the Uncaring, Lord of All Magic | Nashak Stonehand     |
       | accolademud.hermesnet.net 5000         | coyote.toon.org 6000 |
       \=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-X-=-=-=-=-=-=-=-=-=-=-=/


     +------------------------------------------------------------+
     | 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