Spells on objects question.

From: Fionn Colvin (gavry@ozemail.com.au)
Date: 05/24/99

Heya all,
             I'm in the final stages of adding spell affects to items.
So I can have glasses of detect invis, boots of stealth, etc etc. All
works fine bar 1 aspect.

My stystem works as follows.

In equip_char in handler.c, when a new item is equiped by a character it
checks if the item has any spell/skill affects on it. If it has spell
affects it calls mag_affects in magic.c with the spell affect and a
savingthrow of -1 so I can tell there that its from an object. In
magic.c I change savingthrow to SAVING_ROD if its -1 and set from_object
variable to 1. Then at the bottom I have this:

  if (from_object)
    for (i = 0; i < MAX_SPELL_AFFECTS; i++)
      af[i].duration = -1;

That all works great.

Now part 2.

In unequip_char in handler.c I again check if the item being removed has
a spell affect(s) on it. If it does I remove them all with
affect_from_char, I then go through all the characters equiped items and
see if any of them give the character the spell I just removed. If so I
add it back to the character as I did in equip_char. Again this all
works fine.

Now to the problem.

If I wear an item that gives me say, detect invis, then I cast detect
invis on myself and then remove the item I can't work out how to keep
the affect from the spell on me. Any ideas on how I can do this would be
greatly appreciated.

Some code snippets

from equip_char

  /* Add Object Spell Affects */

  if (GET_OBJ_SPELL(obj, 0) > 0)
    for (i = 0; i < MAX_OBJ_SPELLS; i++)
      if ((skill = GET_OBJ_SPELL(obj, i)) > 0) {
        if (IS_OBJ_SPELL(obj, i))
          mag_affects(GET_OBJ_SPELLLVL(obj, i), ch, ch, skill, -1);
        else if (IS_OBJ_SKILL(obj, i)) {
          amount = GET_SKILL(ch, skill) + GET_OBJ_SPELLLVL(obj, i);
          SET_SKILL(ch, skill, amount);
        if (strcmp(GET_OBJ_YMESSAGE(obj, i), "None"))
          act(GET_OBJ_YMESSAGE(obj, i), TRUE, ch, obj, 0, TO_CHAR);
        if (strcmp(GET_OBJ_RMESSAGE(obj, i), "None"))
          act(GET_OBJ_RMESSAGE(obj, i), TRUE, ch, obj, 0, TO_ROOM);

from unequip_char

  /* Remove Object Spell Affects */

  if (GET_OBJ_SPELL(obj, 0) > 0)
    for (i = 0; i < MAX_OBJ_SPELLS; i++) {
      if ((skill = GET_OBJ_SPELL(obj, i)) > 0) {
        if (IS_OBJ_SPELL(obj, i)) {
          affect_from_char(ch, skill);
          for (j = 0; j < NUM_WEARS; j++)
            if (tobj = GET_EQ(ch, j))
              if ((GET_OBJ_SPELL(tobj, 0) > 0) && (tobj != obj))
                for (k = 0; k < MAX_OBJ_SPELLS; k++)
                  if ((GET_OBJ_SPELL(tobj, k) == skill) &&
(IS_OBJ_SPELL(tobj, k)))
                    mag_affects(GET_OBJ_SPELLLVL(tobj, k), ch, ch,
skill, -1);
        else if (IS_OBJ_SKILL(obj, i)) {
          amount = MAX(0, (GET_SKILL(ch, skill) -= GET_OBJ_SPELLLVL(obj,
          SET_SKILL(ch, skill, amount);


     | 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 : 12/15/00 PST