bug in magic.c

Login to reply  Page: « < 1 of 1 > »
23 Jan 2010 - 19:252254
bug in magic.c
In mag_affects function:
  /* If this is a mob that has this affect set in its mob file, do not perform 
   * the affect.  This prevents people from un-sancting mobs by sancting them 
   * and waiting for it to fade, for example. */
  if (IS_NPC(victim) && !affected_by_spell(victim, spellnum))
    for (i = 0; i < MAX_SPELL_AFFECTS; i++)
      if (AFF_FLAGGED(victim, af[i].bitvector)) {
	send_to_char(ch, "%s", CONFIG_NOEFFECT);
	return;
      }
This bit of code only works for spells which have an AFF_ flag. However, for spells which don't have an affect, the check will send the CONFIG_NOEFFECT message.

For example, if you cast "armor" on a mob, you will get "Okay." But if you then cast "bless" on that mob, you will get the CONFIG_NOEFFECT message. This occurs because both BLESS and ARMOR do not set the af[0].bitvector for each spell effect, which therefore defaults to 0.

Fortunately, the fix is very easy:

  if (IS_NPC(victim) && !affected_by_spell(victim, spellnum))
    for (i = 0; i < MAX_SPELL_AFFECTS; i++)
-      if (AFF_FLAGGED(victim, af[i].bitvector)) {
+      if (AFF_FLAGGED(victim, af[i].bitvector) && (af[i].bitvector > 0) {
	send_to_char(ch, "%s", CONFIG_NOEFFECT);
	return;
      }
Therefore, if the spell doesn't add an AFF flag, the spell won't fail. For any spells where this is a potential problem, it is necessary to add the appropriate AFF_ flag.


24 Jan 2010 - 15:022257
I think it would be better to change the affect_modify() function in handler.c, checking if bitv!=0 before SET_BIT_AR and REMOVE_BIT_AR. This way, the flag 0, that should not be used, would not be added.


Login to reply  Page: « < 1 of 1 > »