temp.z should be set to a fixed value (use something like 5000 or 10,000 but don't multiply it with time_step). Also, I see that you have 2 lines of code that set movement_speed.z at the bottom; one of them has to go.
Try to use "if ((str_cmpi ("ROCK_03.bmp", hit.texname))" (without the quotes) to compare the texture name. I didn't test it, but it could solve your problem.