anchor.diff:          (id-name (intern (format nil "+SPELL-~a+" name))))
       `(progn
          (defun ,func-name (caster level target)
  -         (flet ((affect (&key duration modifier location)
  -                  (affect-to-char target
  -                                  (make-instance 'affected-type
  -                                                 :kind ,id-name
  -                                                 :owner (idnum-of caster)
  -                                                 :duration duration
  -                                                 :level level
  -                                                 :modifier modifier
  -                                                 :location location)))
  -                (set-affbit (idx bit &key duration)
  -                  (affect-to-char target
  -                                  (make-instance 'affected-type
  -                                                 :kind ,id-name
  -                                                 :owner (idnum-of caster)
  -                                                 :duration duration
  -                                                 :level level
  -                                                 :aff-index idx
  -                                                 :bitvector bit)))
  -                (to-caster (str)
  -                  (send-to-char caster "~a~%" str))
  -                (to-target (str)
  -                  (send-to-char target "~a~%" str))
  -                (to-room (str)
  -                  (act target :place-emit str)))
  -           (declare (ignorable #'affect #'to-target #'to-room #'to-caster #'set-affbit)
  -                    (dynamic-extent #'affect #'to-target #'to-room #'to-caster
  -                                    #'set-affbit))
  -           ,@body))
  +         (let ((duration (floor level 4)))
  +           (flet ((duration (new-duration)
  +                    (setf duration new-duration))
  +                  (affect (&key (modifier 0) (location +apply-none+))
  +                    (affect-to-char target
  +                                    (make-instance 'affected-type
  +                                                   :kind ,id-name
  +                                                   :owner (idnum-of caster)
  +                                                   :duration duration
  +                                                   :level level
  +                                                   :modifier modifier
  +                                                   :location location)))
  +                  (set-affbit (idx bit)
  +                    (affect-to-char target
  +                                    (make-instance 'affected-type
  +                                                   :kind ,id-name
  +                                                   :owner (idnum-of caster)
  +                                                   :duration duration
  +                                                   :level level
  +                                                   :aff-index idx
  +                                                   :bitvector bit)))
  +                  (to-caster (str)
  +                    (send-to-char caster "~a~%" str))
  +                  (to-target (str)
  +                    (send-to-char target "~a~%" str))
  +                  (to-room (str)
  +                    (act target :place-emit str)))
  +             (declare (ignorable #'affect #'to-target #'to-room #'to-caster #'set-affbit)
  +                      (dynamic-extent #'affect #'to-target #'to-room #'to-caster
  +                                      #'set-affbit))
  +             ,@body)))
          (when (null (aref *spell-info* ,id-name))
            (setf (aref *spell-info* ,id-name) (make-instance 'spell-info)))
          (setf (func-of (aref *spell-info* ,id-name)) (function ,func-name)))))
   
   (define-spell armor ()
  -  (affect :duration 24 :modifier (+ (floor level 4) 20) :location +apply-ac+)
  +  (duration 24)
  +  (affect :location +apply-ac+ :modifier (+ (floor level 4) 20))
     (to-target "You feel someone protecting you."))
   
   (define-spell chill-touch ()
  -  (affect :duration 4 :modifier (- (1+ (floor level 16))) :location +apply-str+)
  +  (duration 4)
  +  (affect :location +apply-str+ :modifier (- (1+ (floor level 16))))
     (to-target "You feel your strength wither!"))
   
   (define-spell barkskin ()
  +  (duration (dice 4 (1+ (floor level 8))))
     (when (affected-by-spell target +spell-stoneskin+)
       (affect-from-char target +spell-stoneskin+))
     (when (affected-by-spell target +spell-thorn-skin+)
       (affect-from-char target +spell-thorn-skin+))
  -  (affect :duration (dice 4 (1+ (floor level 8))) :modifier -10 :location +apply-ac+)
  +  (affect :location +apply-ac+ :modifier -10)
     (to-target "Your skin tightens up and hardens."))
   
   (define-spell stoneskin ()
  +  (duration(dice 4 (1+ (floor level 8))))
     (when (affected-by-spell target +spell-barkskin+)
       (affect-from-char target +spell-stoneskin+))
     (when (affected-by-spell target +spell-thorn-skin+)
       (affect-from-char target +spell-thorn-skin+))
  -  (affect :duration (dice 4 (1+ (floor level 8))) :modifier -10 :location +apply-ac+)
  +  (affect :location +apply-ac+ :modifier -10)
     (to-target "Your skin hardens to a rock-like shell.")
     (to-room "$n's skin turns a pale, rough grey."))
   
  
positive.code:     ((mob-flagged target +mob-noblind+)
       (to-caster "You fail.~%"))
      (t
       (affect :location +apply-hitroll+ :modifier -4 :duration 2)
       (affect :location +apply-ac+ :modifier 40 :duration 2)
       (set-affbit 0 +aff-blind+ :duration 2)
       (if (is-good target)
           (to-target "You feel extremely righteous")
           (to-target "You feel a dark power enter your soul.")))))
  
  (define-spell breathe-water ()
    (set-affbit 0 +aff-waterbreath+ :duration (+ 10 level))
    (to-target "You are now able to breathe underwater."))
  
  (define-spell spirit-track ()
    (affect :duration level)
    (to-target "You can now sense trails to other creatures."))
  
  (define-spell word-stun ()
  
negative.code:      (remove-all-combat target)
       (setf (position-of target) +pos-stunned+)
       (wait-state target (* 2 +pulse-violence+))
       (duration 1)
       (affect :location +apply-int+ :modifier -1)
       (to-target "You have been stunned!")
       (to-room "$n suddenly looks stunned!"))))
  
  (define-spell blur ()
    (duration (+ 2 (floor level 4)))
    (affect :location +apply-ac+ :modifier -10)
    (set-affbit 1 +aff-blur+)
    (to-target "Your image suddenly starts to blur and shift.")
    (to-room "The image of $n suddenly starts to blur and shift."))
  
  (define-spell curse ()
    (duration (+ 1 (floor level 2)))
    (affect :location +apply-hitroll+ :modifier (- (+ 1 (floor level 8))))
    (affect :location +apply-damroll+ :modifier (- (+ 1 (floor level 8))))
    (set-affbit 1 +aff-curse+)
    (to-target "You feel very uncomfortable.")
    (to-room "$n briefly glows with a sick red light!"))
  
  (define-spell detect-align ()
    (duration (+ 12 level))
    (set-affbit 1 +aff-detect-align+)
    (to-target "Your eyes tingle."))
  
  (define-spell detect-invis ()
    (duration (+ 12 level))
    (set-affbit 1 +aff-detect-invis+)
    (to-target "Your eyes tingle."))
  
  (define-spell detect-magic ()
    (duration (+ 12 level))
    (set-affbit 1 +aff-detect-magic+)
    (to-target "Your eyes tingle."))
  
  (define-spell detect-poison ()
    (duration (+ 12 level))
    (set-affbit 2 +aff3-detect-poison+)
    (to-target "Your eyes tingle."))
  
  (define-spell detect-scrying ()
    (duration level)
    (affect)
    (to-target "You are now aware."))
  
  (define-spell displacement ()
    (duration (if (> level 48) 6 4))
    (set-affbit 2 +aff2-displacement+)
    (to-target "Your image will now be displaced from its actual position."))
  
  (define-spell endure-cold ()
    (duration 24)
    (set-affbit 2 +aff2-endure-cold+)
    (to-target "You can now endure the coldest of cold."))
  
  (define-spell fire-shield ()
    (duration (+ 6 (floor level 8)))
    (affect :location +apply-ac+ :modifier -8)
    (set-affbit 2 +aff2-fire-shield+)
    (to-target "A sheet of flame appears before your body.")
    (to-room "A sheet of flame appears before $n!"))
  
  (define-spell haste ()
    (duration (floor level 4))
    (set-affbit 2 +aff2-haste+)
    (to-target "You start moving FAST."))
  
  (define-spell infravision ()
    (duration (+ 12 (floor level 4)))
    (set-affbit 1 +aff-infravision+)
    (to-target "Your eyes glow red.")
    (to-room "$n's eyes glow red."))
  
  (define-spell divine-illumination ()
    (duration (+ 8 level))
    (set-affbit 2 +aff2-divine-illumination+)
    (cond
      ((is-good caster)
       (to-target "You are surrounded with a soft holy light.")
       (to-room "$n is surrounded by a soft holy light."))
      ((is-evil caster)
       (to-target "You are surrounded with an unholy light.")
       (to-room "$n is surrounded by an unholy light."))
      (t
       (to-target "You are surrounded with a sickly light.")
       (to-room "$n is surrounded by a sickly light."))))
  
  (define-spell glowlight ()
    (duration (+ 8 level))
    (set-affbit 1 +aff-glowlight+)
    (to-target "The area around you is illuminated with ghostly light.")
    (to-room "A ghostly light appears around $n."))
  
  (define-spell invisible ()
    (duration (+ 12 (floor level 4)))
    (affect :location +apply-ac+ :modifier -20)
    (set-affbit 1 +aff-invisible+)
    (to-target "You vanish.")
    (to-room "$n slowly fades out of existence."))
  
  (define-spell greater-invis ()
    (duration (+ 3 (floor level 8)))
    (if (aff-flagged target +aff-invisible+)
        (affect :location +apply-ac+ :modifier -20)
        (affect :location +apply-ac+ :modifier -4))
    (set-affbit 1 +aff-invisible+)
    (to-target "You vanish.")
    (to-room "$n slowly fades out of existence."))
  
  (define-spell invis-to-undead ()
    (duration (+ 3 (floor level 8)))
    (set-affbit 2 +aff2-invis-to-undead+)
    (to-target "The undead can no longer see you."))
  
  (define-spell animal-kin ()
    (duration (+ 12 (floor level 4)))
    (set-affbit 2 +aff2-animal-kin+)
    (to-target "You feel a strong kinship with animals."))
  
  (define-spell magical-prot ()
    (duration (+ 3 (floor level 4)))
    (affect :location +apply-saving-spell+ :modifier (+ (- (floor level 8)) 1))
    (to-target "You are now protected somewhat against the forces of magic.")
    (to-room "A shimmering aura appears around $n's body, then dissipates."))
  
  (define-spell petrify ()
    (duration level)
    (set-affbit 2 +aff2-petrified+)
    (to-target "You feel petrified as your body TURNS TO STONE!")
    (to-room "$n suddenly turns to stone and stops in $s tracks!"))
  
  (define-spell gas-breath ()
    (when (needs-to-breathe target)
      (duration level)
      (affect :location +apply-str+ :modifier -2)
      (cond
        ((> level (+ 40 (random-range 0 8)))
         (set-affbit 3 +aff3-poison-3+))
        ((> level (+ 30 (random-range 0 9)))
         (set-affbit 3 +aff3-poison-2+))
        (t
         (set-affbit 1 +aff-poison+)))
      (to-target "You inhale the vapors and get violently sick!")
      (to-room "$n gets violently ill from inhaling the vapors!")))
  
  (define-spell poison ()
    (unless (is-undead target)
      (duration level)
      (affect :location +apply-str+ :modifier -2)
      (cond
        ((> level (+ 40 (random-range 0 8)))
         (set-affbit 3 +aff3-poison-3+))
        ((> level (+ 30 (random-range 0 9)))
         (set-affbit 3 +aff3-poison-2+))
        (t
         (set-affbit 1 +aff-poison+)))
      (to-target "You get violently sick!")
      (to-room "$n gets violently ill!")))
  
  (define-spell prismatic-sphere ()
    (duration (+ 2 (int-of caster)))
    (set-affbit 3 +aff3-prismatic-sphere+)
    (to-target "A prismatic sphere of light appears around you!")
    (to-room "A prismatic sphere of light appears, surrounding $n!"))
  
  (define-spell sickness ()
    (unless (is-sick target)
      (duration (- (dice level 8) (* (con-of target) 2)))
      (affect :location +apply-hitroll+ :modifier (- (floor level 5)))
      (affect :location +apply-damroll+ :modifier (- (floor level 5)))
      (set-affbit 3 +aff3-sickness+)))
  
  (define-spell shroud-obscurement ()
    (duration (+ 10 (floor level 2)))
    (set-affbit 3 +aff3-shroud-obscurement+)
    (to-target "An obscuring shroud forms in the space around you.")
    (to-room "An obscuring shroud forms around $n."))
  
  (define-spell slow ()
    (duration (+ 1 (floor level 4)))
    (affect :location +apply-dex+ :modifier (- (random-range 0 (floor level 16))))
    (set-affbit 2 +aff2-slow+)
    (to-target "Your movements slow to a tortured crawl."))
  
  (define-spell prot-from-evil ()
    (duration 12)
    (cond
      ((is-evil target)
       (affect :location (random-elt (list +apply-str+
                                           +apply-int+
                                           +apply-con+
                                           +apply-cha+
                                           +apply-hitroll+
                                           +apply-damroll+))
               :modifier (- (floor level 8)))
       (to-target "You feel terrible!"))
      (t
       (set-affbit 1 +aff-protect-evil+)
       (to-target "You feel invulnerable against the forces of evil!"))))
  
  (define-spell prot-from-good ()
    (duration 12)
    (cond
      ((is-good target)
       (affect :location (random-elt (list +apply-str+
                                           +apply-int+
                                           +apply-con+
                                           +apply-cha+
                                           +apply-hitroll+
                                           +apply-damroll+))
               :modifier (- (floor level 8)))
       (to-target "You feel terrible!"))
      (t
       (set-affbit 1 +aff-protect-good+)
       (to-target "You feel invulnerable against the forces of good!"))))
  
  (define-spell protect-from-devils ()
    (duration (+ 12 (floor level 8)))
    (set-affbit 2 +aff2-prot-devils+)
    (to-target "The devilish races will have difficulty harming you."))
  
  (define-spell prot-from-lightning ()
    (duration (+ 12 (floor level 4)))
    (set-affbit 2 +aff2-prot-lightning+)
    (to-target "You feel like standing on a hill holding a flagpole!"))
  
  (define-spell prot-from-fire ()
    (duration (+ 12 (floor level 4)))
    (set-affbit 2 +aff2-prot-fire+)
    (to-target "You feel like joining the local volunteer fire department!"))
  
  (define-spell undead-prot ()
    (duration (+ 12 (floor level 8)))
    (set-affbit 2 +aff2-protect-undead+)
    (to-target "The undead are toast.  You're bad."))
  
  (define-spell regenerate ()
    (duration (+ (floor (level-of caster)
                        10)
                 (floor (remort-gen-of caster)
                        2)))
    (set-affbit 1 +aff-regen+)
    (to-target "Your body begins to regenerate at an accelerated rate."))
  
  (define-spell rejuvenate ()
    (duration 3)
    (set-affbit 1 +aff-rejuv+)
    (to-target "You will heal faster while sleeping."))
  
  (define-spell sanctuary ()
    (duration 4)
    (set-affbit 1 +aff-sanctuary+)
    (cond
      ((is-evil target)
       (to-target "A cloud of darkness surrounds you!")
       (to-room "$n is surrounded by a cloud of darkness."))
      (t
       (to-target "A white aura momentarily surrounds you!")
       (to-room "$n is surrounded by a white aura."))))
  
  (define-spell sleep ()
    (unless (or (mob-flagged target +mob-nosleep+)
                (is-undead target))
      (duration (+ 4 (floor level 10)))
      (set-affbit 1 +aff-sleep+)
      (when (> (position-of target) +pos-sleeping+)
        (to-target "You feel very sleepy...ZZzzzz...")
        (to-room "$n goes to sleep.")
        (setf (position-of target) +pos-sleeping+))))
  
  (define-spell strength ()
    (duration (+ 4 (floor level 2)))
    (affect :location +apply-str+ :modifier (+ 1 (random-range 0 (floor level 8))))
    (to-target "You feel stronger!"))
  
  (define-spell word-of-intellect ()
    (duration (if (> level 18) 2 1))
    (affect :location +apply-int+ :modifier (+ 4 (floor level 2)))
    (setf (aff-flags-of target) (logandc2 (aff-flags-of target) +aff-confusion+))
    (to-target "Your mental faculties improve!"))
  
  (define-spell sense-life ()
    (duration 1)
    (set-affbit 1 +aff-sense-life+)
    (to-target "You feel your awareness improve."))
  
  (define-spell telekinesis ()
    (duration (floor level 2))
    (set-affbit 2 +aff2-telekinesis+)
    (to-target "You feel able to carry a greater load."))
  
  (define-spell true-seeing ()
    (duration (+ 1 (floor level 4)))
    (set-affbit 2 +aff2-true-seeing+)
    (to-target "You can now see things as they really are.")
    (to-room "$n's eyes open wide."))
  
  (define-spell waterwalk ()
    (duration 24)
    (set-affbit 1 +aff-waterwalk+)
    (to-target "You feel webbing between your toes."))
  
  (define-spell mana-shield ()
    (duration -1)
    (affect)
    (to-target "Your mana will now absorb a percentage of damage."))
  
  (define-spell power ()
    (duration (+ 4 (floor level 4)))
    (affect :location +apply-str+ :modifier (+ 1 (dice 1 (floor level 16))))
    (to-target "A psychic finger on your brain makes you feel stronger!"))
  
  (define-spell weakness ()
    (duration (+ 4 (floor level 4)))
    (affect :location +apply-str+ :modifier (- (+ 1 (dice 1 (floor level 16)))))
    (to-target "A psychic finger on your brain makes you feel weaker!"))
  
  (define-spell clumsiness ()
    (duration (+ 4 (floor level 4)))
    (affect :location +apply-str+ :modifier (- (+ 1 (dice 1 (floor level 8)))))
    (to-target "A psychic finger on your brain makes you feel less agile!"))
  
  (define-spell intellect ()
    (duration (+ 4 (floor level 4)))
    (affect :location +apply-int+ :modifier (+ 1 (dice 1 (floor level 16))))
    (to-target "Your mental faculties improve!"))
  
  (define-spell confusion ()
    (duration (+ 1 (floor level 4)))
    (affect :location +apply-hitroll+ :modifier (- (+ 1 (floor level 7))))
    (set-affbit 1 +aff-confusion+)
    (to-target "You suddenly feel very confused!")
    (wait-state target (* 2 +pulse-violence+))
    (when (> (position-of target)
             +pos-sleeping+)
      (to-room "$n stops in $s tracks and stares off into space.")))
  
  (define-spell endurance ()
    (duration (+ 1 (floor level 4)))
    (affect :location +apply-move+ :modifier (+ 10 (* level 2)))
    (to-target "You feel your energy capacity rise."))
  
  (define-spell fear ()
    (cond
      ((or (is-undead target)
           (is-dragon target)
           (is-devil target))
       (when caster
         (act caster :target target
              :subject-emit "You fail to affect $N!"))
       (to-caster "You feel a wave of fear pass over you!"))
      (t
       (duration (+ 1 (floor level 16)))
       (affect)
       (to-target "You suddenly feel very afraid!")
       (to-room "$n looks very afraid!"))))
  
  (define-spell telepathy ()
    (duration (+ 1 (floor level 16)))
    (affect)
    (to-target "Your telepathic senses are greatly heightened."))
  
  (define-spell confidence ()
    (duration (+ 3 (floor level 4)))
    (affect :location +apply-hitroll+ :modifier (dice 2 (+ 1 (floor level 8))))
    (affect :location +apply-saving-spell+ :modifier (- (dice 1 (+ 1 (floor level 8)))))
    (set-affbit 1 +aff-confidence+)
    (to-target "You suddenly feel very confident!"))
  
  (define-spell nopain ()
    (duration (+ 1 (dice 3 (+ 1 (floor level 16)))))
    (set-affbit 1 +aff-nopain+)
    (to-target "You feel like you can take anything!")
    (to-room "$n ripples $s muscles and grins insanely!"))
  
  (define-spell retina ()
    (duration (+ 12 (floor level 2)))
    (set-affbit 1 +aff-retina+)
    (to-target "The rods of your retina are stimulated!")
    (to-room "$n's eyes shine brightly."))
  
  (define-spell adrenaline ()
    (duration (+ 3 (floor level 8)))
    (affect :location +apply-hitroll+ :modifier (dice 1 (+ 1 (floor level 8))))
    (set-affbit 1 +aff-adrenaline+)
    (to-target "A rush of adrenaline hits your brain!"))
  
  (define-spell dermal-hardening ()
    (duration (dice 4 (+ 1 (floor level 8))))
    (affect :location +apply-ac+ :modifier -10)
    (to-target "You feel your skin tighten up and thicken."))
  
  (define-spell vertigo ()
    (duration 6)
    (affect :location +apply-hitroll+ :modifier (- (+ 2 (floor level 10))))
    (affect :location +apply-dex+ :modifier (- (+ 1 (floor level 16))))
    (set-affbit 2 +aff2-vertigo+)
    (to-target "You feel a wave of vertigo rush over you!")
    (to-room "$n staggers in a dazed way."))
  
  (define-spell breathing-stasis ()
    (duration (* (dice 1 (+ 1 (floor level 8)))
                 (floor level 16)))
    (affect :location +apply-move+ :modifier (- (floor level 2) 50))
    (set-affbit 3 +aff3-nobreathe+)
    (to-target "Your breathing rate drops into a static state"))
  
  (define-spell metabolism ()
    (duration (dice 2 (+ 2 (floor level 8))))
    (affect :location +apply-saving-chem+ :modifier (floor level 4))
    (set-affbit 3 +aff3-nobreathe+)
    (to-target "Your metabolism speeds up."))
  
  (define-spell relaxation ()
    (duration (dice 2 (+ 2 (floor level 8))))
    (affect :location +apply-move+ :modifier (- (floor level 2) 35))
    (affect :location +apply-str+ :modifier -1)
    (set-affbit 3 +aff3-mana-tap+)
    (to-target "Your body and mind relax."))
  
  (define-spell cell-regen ()
    (duration (dice 1 (+ 1 (floor level 8))))
    (affect :location +apply-con+ :modifier 1)
    (to-target "Your cell regeneration rate increases.")
  
    (when (affected-by-spell target +skill-hamstring+)
      (affect-from-char target +skill-hamstring+)
      (to-target "The wound on your leg closes!")
      (to-room "The gaping wound on $n's leg closes.")))
  
  (define-spell psishield ()
    (duration (+ 3 (dice 1 (+ 1 (floor level 8)))))
    (set-affbit 3 +aff3-psishield+)
    (to-target "You feel a psionic shield form around your mind."))
  
  (define-spell motor-spasm ()
    (duration (+ 1 (random-range 0 (floor level 16))))
    (affect :location +apply-dex+ :modifier (- (random-range 0 (floor level 8))))
    (to-target "Your muscles begin spasming uncontrollably."))
  
  (define-spell psychic-resistance ()
    (duration (+ 3 (dice 1 (+ 1 (floor level 8)))))
    (affect :location +apply-saving-psi+ :modifier (- (+ 5 (floor level 8))))
    (to-target "The psychic conduits of your mind become resistant to external energies."))
  
  (define-spell psychic-crush ()
    (duration (+ 2 (dice 1 (+ 1 (floor level 16)))))
    (affect :location +apply-mana+ :modifier (- (+ 5 (floor level 8))))
    (set-affbit 3 +aff3-psychic-crush+))
  
  (define-spell psychic-feedback ()
    (duration (+ (floor level 8)
                 (dice 1 (+ 1 (floor level 8)))))
    (affect)
    (to-target "You well now send psychic feedback to anyone who attacks you."))
  