Ammunition

Bullets, shotgun shells, rail gun slugs

You can almost find all you want to know about bullets in the fire_lead function in g_weapon.c. Bullets are not entities in the world. It is just a matter of a muzzle flash and sparks or gib at the right position in the world. The game DLL uses the trace function of the game import API to project the bullet's path and at the point of impact the game DLL orders for the effects. The projection is even different for water and air. The bullets change their direction somewhat when fired into water.

In water the fire_lead function also orders bubble trails to be rendered.

Grenades, BFG blasts, blaster bolts, rockets

These are entities with edict_t structures. Therefore, they can think and they use the think function to time their detonation. They also have touch function, which can be used to explode when touching other entities dynamic or static. When you fire or throw grenades, new entites are spawned and given velocities and mass. Once away, they are on their own.