I am trying to make it so that if the player falls vertically a certain distance, the player will take damage to its health.

So far, this is the code that causes the player to fall with gravity:

Code:
action player_code()
{
   ...

   dtimer();
			
   if(c_trace(my.x, vector(my.x, my.y, my.z - my.FEET_HEIGHT), 
      IGNORE_ME | IGNORE_PASSABLE | IGNORE_PASSENTS | 
      USE_POLYGON))
   {
      time_elapsed = dtimer();
	      	
      my.z = target.z + (my.FEET_HEIGHT);	
	         
      DEBUG_VAR(my.z, 150);
      DEBUG_VAR(time_elapsed, 200);
	         
      gravity_var = 0;
      jumplck = 0;	
	         
      if(time_elapsed >= 20)
      {
         beep();
      }
   }

   ...	
}



I am assuming that I would use the dtimer() function somehow, in that if the player falls within a certain amount of time, the player will take a certain amount of damage?

Right now, I am trying to get the program to beep() while the player is falling in mid-air, and run the dtimer() during that period of falling. No beeping is occurring while the player falls in mid-air, with the above code. Does anyone know how I can measure how long the player falls?

I notice that the time_elapsed and my.z values using the DEBUG_VAR() function above disappear to nothing (no value visible) while the player falls in mid-air. These values only show up when the player is walking on the ground without falling.

Does anyone have an idea on how to make the player take damage while falling? I am trying different methods, but none seem to be working. Any help would be appreciated. Thank you.

Last edited by Ruben; 12/16/15 18:30.