You could check to see if the player's momentum vector suddenly decreases quickly (Or, if you want to be mean, increase, too) And if that change is above a threshold, start doing damage. You could check the change over a matter of say... half a second? Quarter of a second? A few frames?
For example, I could walk off a cliff and suddenly jam myself in a corner with a MOMY of 40 and a MOMZ30, and I have 13 rings, and the threshold is 30.
If I rushed into the corner suddenly, that would be a change of 50. I would end up either dying, or losing all my rings and having none left. However, if I let myself hit the wall first, I'll lose 10 rings from damage, and fall harmlessly to the ground. Or, I could slow down, land on the ground and backpedal to a halt.