Fall damage based on distance fallen rather than velocity?

If you want to keep track of distance fallen, I would store your current z location value in a variable the moment that you are simultaneously moving downward (-z velocity) and not touching the ground (otherwise walking down a slope will count as “falling”). Then later when you hit the ground, get the distance you fell by subtracting your start fall position z and your current z location.