I've been trying to wrap my head around doing this but I can't think of a good way to go about it.
What I'm trying to do is replicate the damage effect from the old Zelda games. However I can't think of a way to do this in general and even if I do, I can't image how I'd make sure the player doesn't get jammed into a wall.
I hate essentially asking "make this for me" but I really can't think of any solutions.