This script will allow your states to have a mana shield. You can enable various effects, like Absorbing, Splitting or Replenishing damage (to name a few).
Use the these notetags in your state’s notebox. Then watch the magic happen.
Remember that there are settings in the script.