That 'if (weapon->common.spellID == 159

' was a nasty hack that I put in when no-one knew how to test whether a spell was beneficial or not. I changed it so that beneficial spells were cast on the wielder and non-beneficial on the target when I found the byte in the spell_struct, but my change never made it into the code.
I think there are some problems with Cancel Magic spells as they're flagged as non-beneficial but need to be cast on the wielder. It should mostly work anyway
K.