in the demilich quest, where you get the golden arms legs and torso, I entered the final dungeon and used a chain contingency (I removed the exp cap and am playing the whole game through with a single mage

with 3 horid wiltings and that kills the first lich in nothing flat, but than the demi lich comes out, he keeps casting imprisonment on me, and damn can he cast it fast, I can barly keep my spell traps up... but thats not the problem, the problem is that for some reason when he casts imprisonment or does something else (I dont know what) all my spells are regenerated, but seemingly so are his, so I can sit there and cast spell trap indefinetly, but I cant ever really hurt him, but he never really hurts me, and neither of us ever run out of spells, on top of that none of my spells seem to work on him... power word kill, finger of death, disintigrate, flesh to stone... I have tried nearly everything, and it always says "spell ineffective" which tells me nothing
to sum up the lick and myself keep regenerating spells, and he is seemingly invincible can anyone help me???!!!!