The way it's usually done is that you either have a value in your RAM saying what height you're at or a value saying how fast you're moving up or down. I think warrock uses the former method, but I'm not entirely sure. Tsearch is the way to go for this I think, look for a value that's positive when you're climbing and negative when you're falling (that program that freezes a game while you use Tsearch would be helpful here, but as I've complained about loudly, I can't find it). Or just use the handy trainer.