It looks to be all in the "gravity_player" function to me.
I cant help that much cause I suck at c-script.
But I can tell you these two important things.
1> Your "accelerate(speed_down,5,0.1)" calculation wont work because speed_down is being
reset back to zero every time the function is called. That means EVERY frame.
2> Your gravity function tries to calculate a downward distance, but never actually uses it.
There is NO C_MOVE....
Hope this is of some help.