Magic Jar
6th-level necromancy
Casting Time: 1 minute
Range: Self
Components: V,S,M (a gem, crystal, reliquary, or some other ornamental container worth at least 500 gp)
Duration: Until dispelled
Your body falls into a catatonic state as your soul leaves it and enters the container you used for the spell's material component. While your soul inhabits the container, you are aware of your surroundings as if you were in the container's space. You can't move or use Reactions. The only action you can take is to project your soul up to 100 feet out of the container, either returning to your living body (and Ending the spell) or attempting to possess a Humanoids body.
You can attempt to possess any Humanoid within 100 feet of you that you can see (creatures warded by a Protection from Evil and Good or Magic Circle spells can't be possessed). The target must make a Charisma saving throw. On a failure, your soul moves into the target's body, and the target's soul becomes trapped in the container. On a success, the target resists your efforts to possess it, and you can't attempt to possess it again for 24 hours.
Once you possess a creature's body, you control it. Your game Statistics are replaced by the Statistics of the creature though you retain your Alignment and your Intelligence, Wisdom, and Charisma scores. You retain the benefit of your own class feature. If the target has any class levels, you can't use any of its Class Features.
Meanwhile, the possessed creature's soul can perceive from the container using its own Senses, but it can't move or take Actions at all.
While possessing a body, you can use your action to return from the host body to the container if it is within 100 feet of you, returning the host creature's soul to its body. If the host body dies while you're in it, the creature dies, and you must make a Charisma saving throw against your own Spellcasting DC. On a success, you return to the container if it is within 100 feet of you. Otherwise, you die.
If the container is destroyed or the spell ends, your soul immediately returns to your body. If your body is more than 100 feet away from you, or if your body is dead when you attempt to return to it, you die. If another creature's soul is in the container when it is destroyed, the creature's soul returns to its body if the body is alive and within 100 feet. Otherwise, that creature dies.
When the spell ends, the container is destroyed.