To help the monsters hunt the player, the player places a trail of invisible entites as he moves. These footsteps or pheromone trail is limited in length and is actually represented as a circular buffer of entities. Each of these entities tells when the player stepped here and in what direction the player was moving when he stepped here. Actually, the direction is the vector from the previous footstep to the current, which is not as useful as a vector pointing at the next footstep. Footsteps are only printed if the previous footprint is out of sight. This minimizes the number of footsteps but allows the monsters to track the player around corners.
You can find the code for the trail in p_trail.c.