Improve NPC spell casting AI

Addresses issue #218.