Core/Mechanics: Improve shapeshift form code.

Originally by VladimirMangos.